I'm showing how easy this is here - to encourage people to take this up - using Writer's go to page dialog. LO has one of these but OO doesn't. This feature is a tiny amount of code, less than an hour's work in Basic to create from scratch. With the code written for you, by following the steps below its a few minutes.
Create a simple extension
Goto Tools Menu/macros/Organise Dialogs/Libraries Tab
Click on new to create a library called GoToPage and click edit to edit it.
Create a module called GoToPageM and add the code below
Code: Select all
REM ***** BASIC *****
dim pgdlg 'the dialog
sub ShowGoToPage 'shows the dialog to go to a page
DialogLibraries.LoadLibrary("GoToPage") 'load the dialog library
pgdlg= CreateUnoDialog(DialogLibraries.GetByName("GoToPage").GetByName("GoToPageD")) 'load the dialog
pgdlg.getcontrol("Label2").model.label ="of " & thiscomponent.currentcontroller.pagecount 'set a label on the dialog to show the pagecount
pgdlg.execute 'execute the dialog
end sub
sub gotopageKeyPress(ev) 'event fired by the Textbox keyPresses.
if ev.keycode = 1280 then gotopageBtnExecute 'if return then Calls the gotopageBtnExecute sub
end sub
sub gotopageBtnExecute() ' fired by the okay button. Goes to the page
newpgno = val(pgdlg.getcontrol("TextField1").model.text) 'get the page number from the textbox
if newpgno <= thiscomponent.currentcontroller.pagecount and newpgno>=0 then 'make sure its in range
vc = thiscomponent.currentcontroller.viewcursor 'get the viewcursor
vc.jumpToPage(newpgno,false) 'this line does the work
end if
pgdlg.endexecute 'close the dialog
' if pgdlg.getcontrol("StickyButton").model.state = 0 then pgdlg.endexecute 'version with "StickyButton" to not close if pressed down
end sub
Set the Cancel button to be a cancel button, the TextField's keypress event to call gotopageKeyPress, the Okay button's execute event to call gotopageBtnExecute.
goback to Tools Menu/macros/Organise Dialogs/Libraries Tab
Click on your GoToPage library / Click export and export as an extension.
That's it!
Same as LibreOffice's goto page dialog in Basic! You just need to add a menu item in the edit menu which calls the ShowGoToPage sub to run it.
Note the brevity of the code - less than 20 lines. You can follow it by looking at the comments.
If you look at the supplied extension I made one tiny improvement - I added a button with a pin label and the toggle set to yes. I made it so the dialog won't automatically close if that button is pressed down by adding half a line of code. This extra feature is two minutes work tops. You can now jump about through the pages without having to reopen the dialog.
Edit: note the dialog won't work if loaded from the IDE.. the ShowGoToPage has to be called from Writer by adding that menu item, or using run...
Edit2: amended code to comment out and replace "StickyButton" line with original to just unload the dialog.