Laurent ,
try this code and download "xray to inspect your different objects
sub zoek
controller=thiscomponent.getCurrentController()
oViewcursor=controller.getViewCursor()
xray oViewcursor
' only a vieuwcursor knows about a position
xSearchDescr = thiscomponent.createSearchDescriptor()
xSearchDescr.SearchString = "text to find"
xSearchDescr.SearchCaseSensitive = 0
xSearchDescr.SearchWords = 0
oFound = thiscomponent.findFirst( xSearchDescr )
' oFound is a textcursor
xray xfound
' the viewcursor has to folow the textcursor
'now we move the vieuwcursor to textcursor
oViewcursor.gotorange(ofound,false)
xray oFound
print Viewcursor.page
end sub
Thanks Fernand,
This is my code to search:
controller=doc.getCurrentController()
cursor=controller.getViewCursor()
xSearchDescr = doc.createSearchDescriptor()
xSearchDescr.SearchString = "term to search"
xSearchDescr.SearchCaseSensitive = 0
xSearchDescr.SearchWords = 0
xFound = doc.findFirst( xSearchDescr )
i=0
while xFound>0:
nbpage=cursor.getPage()
print "%d:%d"%(i,nbpage)
i=i+1
xFound = doc.findNext( xFound.End, xSearchDescr )
However the page displayed is always 1.
What is the Thiscomponent
is the document !
you are referring to, is it my Doc or is it the SearchDescriptor ?
Thanks !
Laurent
Crivello, Laurent wrote:
Dear All,
I have a bit of code to search multiple instances of a string in a writer
document.
This works fine.
However I would now like to find out at which page number these strings appear.
The Viewcursor kwows the page
with the Api >>> Thiscomponent.currentcontroler.ViewCursor.page
Hope it helps
Fernand
How can I find this ?
Thanks for your help,
Laurent
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org
For additional commands, e-mail: dev-h...@api.openoffice.org