OO-Snippets: paragraph style

Commons

KeywordsCursor, TextCursor, XParagraphCursor, ParaStyleName, gotoNextParagraph , gotoEndOfParagraph , paragraphs, traversal, traverse, enumerate, iterate
LanguageOOBasic
ApplicationWriter
AuthorsAndrew Pitonyak (initial)
Michael Hoennig
Tom Schindl
Supported Versions
Supported OS
Question How do I look at each paragraphs style?
Answer

The following code snippet traverses a document noticing each used paragraph style.

Code-Snippet-Listing (snippet-source)

Sub PrintAllParagraphStyles
  Dim s As String
  Dim vCurCursor As Variant
  Dim vText As Variant
  Dim sCurStyle As String

  vText = ThisComponent.Text
  vCurCursor = vText.CreateTextCursor()
  vCurCursor.GoToStart(False)
  Do
    If NOT vCurCursor.gotoEndOfParagraph( True ) Then Exit Do
    sCurStyle = vCurCursor.ParaStyleName
    s = s & """" & sCurStyle & """" & CHR$(10)
  Loop Until NOT vCurCursor.gotoNextParagraph( False )
  MsgBox s, 0, "Styles in Document"
End Sub

Changelog

DateUserModification
2004-06-22tomsontomModified to match codesnippet.dtd v2.0, added syntax highlighting
0000-00-00andInitial version

and