JohnV Administrator

Joined: 07 Mar 2003 Posts: 8984 Location: Lexinton, Kentucky, USA
|
Posted: Tue Mar 22, 2011 4:12 pm Post subject: Restore default formatting to a series of paragraphs. |
|
|
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 |
|
|