Thanks for the code snippet.
I still have a problem detecting page break bookmarks when there is a
bookmark at the top of the page (see attached). Note: The image in the
sample file is prefixed by a bookmark. Would checking for an existing
bookmark in a paragraph and then moving to the end of the previous paragraph
before a insert the pagebreak marker bookmark solve this problem?
I was wondering if it was possible/straightforward to remove an existing
bookmarks as a preprocessing step? I could then assume that the inserted
bookmarks are page break markers? However, would this have sideeffects?
Andrew Douglas Pitonyak wrote:
>
>
>
> ianmcr wrote:
>> Hi,
>>
>> I am working on an export filter for producing accessible HTML. I first
>> iterate through the document and insert bookmarks at the start of each
>> page
>> to indicate an automatic page break. I then iterate through the document
>> creating a new HTML page at each page break.
>>
>> I need to compare the names of the names of the bookmarks as a iterate
>> trhough the text.
>> In the following example, I need to differentiate between
>> "PageBreakMarker"
>> and "_1118825921".
>>
>> - <text:p text:style-name="P4">
>> <text:bookmark text:name="PageBreakMarker" />
>> <text:bookmark-start text:name="_1118825921" />
>> <text:bookmark-end text:name="_1118825921" />
>> - <draw:frame ... />
>> </draw:frame>
>> </text:p>
>>
>> I can detect a bookmark by the following:
>>
>> Reference<XPropertySet> xPropertySet(currentXTextRange, UNO_QUERY);
>> Any aPortionType =
>> xPropertySet->getPropertyValue(rtl::OUString::createFromAscii("TextPortionType"));
>> rtl::OUString oPortionType;
>> if (aPortionType >>= oPortionType)
>> {
>> return (portionType == "Bookmark");
>> }
>>
>> How do I find the name of the programatic name of the bookmark (ie. the
>> strings "PageBreakMarker" or "_1118825921" )?
>>
> Note that I do not bother iterating over text in tables and such, but if
> you had one, it would find the name...
>
> Sub IteratePortions()
> Dim oText
> Dim oEnum
> Dim oPara
> Dim oParaEnum
> Dim oPortion
> Dim oPortionCursor
> Dim sPortionString$
>
> oText = ThisComponent.getText()
> oEnum = oText.createEnumeration ()
>
> Do While oEnum.hasMoreElements
> oPara = oEnum.nextElement
> If oPara.supportsService("com.sun.star.text.Paragraph") Then
> oParaEnum = oPara.createEnumeration ()
>
> Do While oParaEnum.hasMoreElements ()
> oPortion = oParaEnum.nextElement
>
> Select Case oPortion.TextPortionType
> Case "Text"
> 'oPortionCursor = oText.createTextCursorByRange (oPortion, 0)
> oPortionCursor = oText.createTextCursorByRange (oPortion)
> sPortionString = oPortionCursor.getString ()
> Case "Bookmark"
> Print FindBookmarkName(oPortion)
> Case Else
> 'Print oPortion.TextPortionType()
> End Select
> Loop
> End If
> Loop
> End Sub
>
> Function FindBookmarkName(oPortion) As String
> Dim oText
> Dim oMarks
> Dim oMark
> Dim oCurs
> Dim i As Integer
>
> oText = oPortion.getText()
> oMarks = ThisComponent.getBookmarks()
>
> For i = 0 To oMarks.getCount() - 1
> oMark = oMarks.getByIndex(i)
> If EqualUNOObjects(oMark.getAnchor().getText(), oText) Then
> 'Inspect(oMark.getAnchor().getStart())
> If (oText.compareRegionEnds (oPortion, oMark.getAnchor()) = 0 AND _
> oText.compareRegionStarts (oPortion, oMark.getAnchor()) = 0)
> Then
> FindBookmarkName = oMark.getName()
> End If
> End If
> Next
> End Function
>
>
> --
> Andrew Pitonyak
> My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
> My Book: http://www.hentzenwerke.com/catalog/oome.htm
> Info: http://www.pitonyak.org/oo.php
> See Also: http://documentation.openoffice.org/HOW_TO/index.html
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
http://www.nabble.com/file/7173/2003_05_ict_strategy_p30.doc
2003_05_ict_strategy_p30.doc
--
View this message in context:
http://www.nabble.com/Find-the-name-of-a-bookmark-while-iterating-through-text-tf3394969.html#a9495652
Sent from the openoffice - dev mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]