blob: 1b190faf4585670e56d8778e8af3438e9be18de6 [file] [log] [blame]
<snippet language="OOBasic" application="Writer">
<keywords>
<keyword>Cursor</keyword>
<keyword>TextCursor</keyword>
<keyword>XParagraphCursor</keyword>
<keyword>ParaStyleName</keyword>
<keyword>gotoNextParagraph </keyword>
<keyword>gotoEndOfParagraph </keyword>
<keyword>paragraphs</keyword>
<keyword>traversal</keyword>
<keyword>traverse</keyword>
<keyword>enumerate</keyword>
<keyword>iterate</keyword>
</keywords>
<authors>
<author id="and" initial="true" email="andrew@pitonyak.org">Andrew Pitonyak</author>
<author id="mi" email="mi@sun.com">Michael Hoennig</author>
<author id="tomsontom" initial="false" email="tom.schindl@bestsolution.at">Tom Schindl</author>
</authors>
<question heading="paragraph style">
How do I look at each paragraphs style?
</question>
<answer>
<p>
The following code snippet traverses a document noticing each used paragraph
style.
</p>
<listing>
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 &amp; """" &amp; sCurStyle &amp; """" &amp; CHR$(10)
Loop Until NOT vCurCursor.gotoNextParagraph( False )
MsgBox s, 0, "Styles in Document"
End Sub
</listing>
</answer>
<changelog>
<change author-id="tomsontom" date="2004-06-22">Modified to match codesnippet.dtd v2.0, added syntax highlighting</change>
<change author-id="and" date="0000-00-00">Initial version</change>
</changelog>
</snippet>