OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Restore default formatting to a series of paragraphs.

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Code Snippets
View previous topic :: View next topic  
Author Message
JohnV
Administrator
Administrator


Joined: 07 Mar 2003
Posts: 8984
Location: Lexinton, Kentucky, USA

PostPosted: Tue Mar 22, 2011 4:12 pm    Post subject: Restore default formatting to a series of paragraphs. Reply with quote

This macro can be used to restore default formatting to a series paragraphs when selecting then to do so would remove other direct formatting like italics, bold and underlining. It will work on an entire document or a selected portion thereof.

Code:
Sub DefaultFormatting 'Writer
Dim oDoc, oVC, oTC, oEnd, document, dispatcher, Selection as Boolean
oDoc = ThisComponent
oVC = oDoc.CurrentController.getViewCursor
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
If Not oVC.IsCollapsed then
  oTC = oDoc.Text.createTextCursorByRange(oVC.Start)
  oEnd = oDoc.Text.createTextCursorByRange(oVC.End)
  Selection = true
 Else oTC = oDoc.Text.createTextCursor
  oEnd = oDoc.Text.createTextCursor
EndIf
Do
 If Selection AND oDoc.Text.CompareRegionEnds(oTC,oEnd) = -1 then Exit Do
 oVC.gotoRange(oTC,false)
 oVC.gotoEndOfLine(false)
 dispatcher.executeDispatch(document, ".uno:ResetAttributes", "", 0, Array())
Loop While oTC.gotoNextParagraph(false)
End sub
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Code Snippets All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group