[Solved] How to tell where my ViewCursor is currently at?

The Application Programming Interface and the OASIS Open Document Format

[Solved] How to tell where my ViewCursor is currently at?

Postby mlsoong » Sun Jun 17, 2012 12:59 am

Hi
I am new to this forum and had tried to find a solution to my problem
Am writing a macro to read line by line of a document in Writer until the end of the document. I put into a loop a dispatcher goDown, then a dispatcher EndOfLineSel to read the line with the viewcursor.getstring. How do I know that I have finished reading the last line? Does the goDown dispatcher return a "I am at EndOfDocument" flag or if the cursor has a "atEndOfDocument" flag?
Thanks & Regards
mlsoong
Last edited by mlsoong on Sun Jun 17, 2012 3:32 am, edited 1 time in total.
OpenOffice 3.3 on Windows XP
mlsoong
 
Posts: 2
Joined: Sat Jun 16, 2012 8:05 am

Re: How to tell where my viewcursor is currently at?

Postby FJCC » Sun Jun 17, 2012 1:35 am

I would use the compareRegionEnds() method of the Text object of the document.
Code: Select all   Expand viewCollapse view
oText = ThisComponent.Text
VCurs = ThisComponent.CurrentController.ViewCursor
VCurs.gotoStart(False)  'move to start of document
VCurs.gotoEndOfLine(True)
Print VCurs.String
While oText.compareRegionEnds(VCurs.End, oText.End) <> 0  ' will = 0 when the Cursor.End is on top of the Text.End
   VCurs.goDown(1, False)
   VCurs.gotoStartOfLine(False)
   VCurs.gotoEndOfLine(True)
Print VCurs.String
Wend
Windows 10 and Linux Mint, since 2017
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
FJCC
Moderator
 
Posts: 8177
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: [Solved] How to tell where my viewcursor is currently at

Postby mlsoong » Sun Jun 17, 2012 3:33 am

Thanks FJCC. It is exactly what I need, and it works like a charm.
OpenOffice 3.3 on Windows XP
mlsoong
 
Posts: 2
Joined: Sat Jun 16, 2012 8:05 am


Return to UNO API and ODF

Who is online

Users browsing this forum: No registered users and 2 guests