 | OO-Snippets: paragraph styleCommons| Keywords | Cursor, TextCursor, XParagraphCursor, ParaStyleName, gotoNextParagraph , gotoEndOfParagraph , paragraphs, traversal, traverse, enumerate, iterate |
|---|
| Language | OOBasic |
|---|
| Application | Writer |
|---|
| Authors | Andrew 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.
|
|---|
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| Date | User | Modification |
|---|
| 2004-06-22 | tomsontom | Modified to match codesnippet.dtd v2.0, added syntax highlighting | | 0000-00-00 | and | Initial version |
|