How to get XTextRange showing on the screen

The Application Programming Interface and the OASIS Open Document Format

How to get XTextRange showing on the screen

Postby kwalcock » Thu Aug 20, 2015 2:43 am

For a watermarking application I need to figure out what portion of a Writer document the user can see so that I can watermark other portions without disturbing the user. I can even assume a simple document with no frames or tables, etc.

So far the closest I have found is to use an XTextViewCursor, do a screenUp(), and then take the range from there to the beginning of the document. Likewise, I can do a screenDown() and then take the range to the end of the document. The part in between, approximately, is to be avoided.

Unfortunately, with the XTextViewCursor, the results of screenUp() and screenDown() are actually visible, which won't be good for the user trying to type. I can use lockControllers() to prevent some screen updates, but the page margins and the window background still show the flicker of the text scrolling up and down.

Does anyone else know of a better way to get the range(s) of text showing on the screen or of a way to prevent the flicker? Are there other controllers than need to be locked?

The current code is something like

ThisComponent.lockControllers()
viewCursor = ThisComponent.getCurrentController().getViewCursor()
viewCursor.screenDown()
MsgBox("Check for flicker in case it doesn't show")
viewCursor.screenUp()
ThisComponent.unlockControllers()

Thanks
Apache OpenOffice 4.0.1
Windows, Linux, MacOS
kwalcock
 
Posts: 24
Joined: Thu Oct 09, 2014 11:54 am

Re: How to get XTextRange showing on the screen

Postby FJCC » Thu Aug 20, 2015 4:38 am

If I run the macro GetData, then go to the document and move the view to elsewhere, running RestoreVdata makes the view jump back to the state stored in Vdata.
Code: Select all   Expand viewCollapse view
Global Vdata
Sub GetData
Vdata = ThisComponent.CurrentController.getViewData()
End Sub

Sub RestoreVdata
ThisComponent.CurrentController.restoreViewData(Vdata)
End Sub

The content of Vdata is
5860;17826;120;0;15500;13675;22863;0;0
but I don't know what the various numbers mean. The information you want must be in there somewhere.
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: 7230
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: How to get XTextRange showing on the screen

Postby kwalcock » Thu Aug 20, 2015 7:28 am

Thanks for alerting me to the interesting possibility. The values returned are

ViewId, ViewLeft, ViewTop, VisibleLeft, VisibleTop, VisibleRight, VisibleBottom, ZoomType, ViewLayoutColumns, ViewLayoutBookMode, ZoomFactor, and IsSelectedFrame.

If I scroll around in the document without changing cursor position, the returned values do not change. I therefore do not think they can be used to figure out what text the user is seeing.
Apache OpenOffice 4.0.1
Windows, Linux, MacOS
kwalcock
 
Posts: 24
Joined: Thu Oct 09, 2014 11:54 am


Return to UNO API and ODF

Who is online

Users browsing this forum: No registered users and 1 guest