Ask Your Question

Writer: Get current displayed page number via API/SDK [closed]

asked 2015-06-26 10:43:38 +0100

urbanhusky gravatar image


I'm trying to get the current page number of where the document is shown (scrolled to), not where the cursor is located. How is this possible with the API?

P.S.: I'm using C++

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by Alex Kemp
close date 2020-08-22 16:51:56.652258

1 Answer

Sort by » oldest newest most voted

answered 2015-06-26 11:21:49 +0100

pierre-yves samyn gravatar image


With Basic, to find the information in the status bar I would do:

Sub PysDisplayedPageNumber

dim oBar as object, oContext as object
dim i as long

oBar = stardesktop.frames(0).layoutmanager.getElement("private:resource/statusbar/statusbar")
oContext = oBar.RealInterface.AccessibleContext

for i = 0 to oContext.AccessibleChildCount - 1
    if oContext.getAccessibleChild(i).AccessibleName = "Page Number" then
        print oContext.getAccessibleChild(i).Text
    end if
next i

End Sub

HTH - Regards

edit flag offensive delete link more


Unfortunately I hide the status bar so I don't seem to be able to access it this way.

urbanhusky gravatar imageurbanhusky ( 2015-07-02 10:23:47 +0100 )edit

Hide the status bar does not change... However be warned the tested text depends on the locale (e.g. Numéro de page with FR) and, of course, the context may change if there are several open documents: frames(0) should be adapted. it was an example a bit quickly made, sorry... and it's a little awkward. It is probably possible to find information more "upstream" (I do not know if this is correct english). Here I only find the display of the information) but I have no example for now...

pierre-yves samyn gravatar imagepierre-yves samyn ( 2015-07-02 11:01:29 +0100 )edit

Well, if I try to get the status bar, but have hidden it, I get NULL for it.

urbanhusky gravatar imageurbanhusky ( 2015-07-02 11:15:34 +0100 )edit

It works in my environment (windows 7). Sorry, I do not have time to investigate. I answer here for little time and I do not know if many developers respond. You might have better luck on the dedicated list. Regards.

pierre-yves samyn gravatar imagepierre-yves samyn ( 2015-07-02 11:51:48 +0100 )edit

I tried it again with Basic this time. Since I hide all status bars etc. in readonly mode, I cannot access the status bar. This script generates a BASIC runtime error. Object variable not set I also have very little to no control over the locale used so parsing the output could be tricky too. (Environment is Ubuntu)

urbanhusky gravatar imageurbanhusky ( 2015-07-10 11:34:50 +0100 )edit

I re-re-tried.. again... (with Basic) and I understand. I think I have tested opening the document with the status bar displayed, and then hiding the status bar, then launching the procedure. In this case the program does not generate an error because the object is in fact available. Conclusion: very sorry this can not help you. Have you no answer from the Dev list?

pierre-yves samyn gravatar imagepierre-yves samyn ( 2015-07-10 16:20:54 +0100 )edit

I just posted it to the user mailing list, I had the impression that the dev-list is more for actual development on libreoffice itself.

urbanhusky gravatar imageurbanhusky ( 2015-07-10 17:19:16 +0100 )edit

Unfortunately the mailing list didn't provide any help here - has anyone got anything?

urbanhusky gravatar imageurbanhusky ( 2015-08-05 15:57:23 +0100 )edit

I have nothing new. Have you tried #libreoffice channel on irc?

pierre-yves samyn gravatar imagepierre-yves samyn ( 2015-08-05 16:36:53 +0100 )edit

Question Tools

1 follower


Asked: 2015-06-26 10:43:38 +0100

Seen: 196 times

Last updated: Jun 26 '15