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++

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

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

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…

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

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.

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)

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?

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.

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

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