# Writer: Get current displayed page number via API/SDK

Hi,

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 close merge delete

Sort by » oldest newest most voted

Hi

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

more

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

( 2015-07-02 10:23:47 +0200 )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...

( 2015-07-02 11:01:29 +0200 )edit

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

( 2015-07-02 11:15:34 +0200 )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.

( 2015-07-02 11:51:48 +0200 )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)

( 2015-07-10 11:34:50 +0200 )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?

( 2015-07-10 16:20:54 +0200 )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.

( 2015-07-10 17:19:16 +0200 )edit

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

( 2015-08-05 15:57:23 +0200 )edit

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

( 2015-08-05 16:36:53 +0200 )edit