Hello Laurent,
On Tuesday 28 April 2009, 11:00, Crivello, Laurent wrote:
> Thanks Fernand,
>
> This is my code to search:
>
> controller=doc.getCurrentController()
> cursor=controller.getViewCursor()
...
> nbpage=cursor.getPage()
you must send the view cursor to the range.
> print "%d:%d"%(i,nbpage)
> i=i+1
> xFound = doc.findNext( xFound.End, xSearchDescr )
>
> However the page displayed is always 1.
test the following with a long document containing hyperlinks on different
pages:
Option Explicit
Sub [Search Hyperlinks]
Dim oDoc as Object
oDoc = ThisComponent
Dim oViewCursor as Object
oViewCursor = oDoc.getCurrentController().getViewCursor()
Dim oSearchDescriptor as Object
oSearchDescriptor = oDoc.createSearchDescriptor()
oSearchDescriptor.setValueSearch( false)
Dim Props(0) as New com.sun.star.beans.PropertyValue
Props(0).Name = "HyperLinkURL"
oSearchDescriptor.setSearchAttributes(Props)
Dim oResultSet as Object
oResultSet = oDoc.findAll( oSearchDescriptor )
Dim n&, oResult as Object, sURL$
For n = 0 to oResultSet.getCount()-1
oResult = oResultSet.getByIndex(n)
sURL = oResult.HyperLinkURL
oViewCursor.goToRange(oResult, false)
MsgBox oViewCursor.getPage()
Next
End Sub
If you don't want the whole text range to be selected, use something like
oViewCursor.goToRange(oResult.getStart(), false)
Regards
--
Ariel Constenla-Haile
La Plata, Argentina
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]