Writer page thumbnail-like view

Shared Libraries
Forum rules
For sharing working examples of macros / scripts. These can be in any script language supported by OpenOffice.org [Basic, Python, Netbean] or as source code files in Java or C# even - but requires the actual source code listing. This section is not for asking questions about writing your own macros.
Post Reply
JeJe
Volunteer
Posts: 2785
Joined: Wed Mar 09, 2016 2:40 pm

Writer page thumbnail-like view

Post by JeJe »

Install: Copy and paste the macros to MyMacros/Standard library or another library of your choice.

Usage: Open a second window for your document and set the zoom so the pages are thumbnail size.
Run the MakePagePreview macro from that window's menu.
Then whenever you click a page in the thumbnails window the main window will then go to that page.

Warning: NOT EXHAUSTIVELY TESTED - just to in OO only seems to work for me level: USE AT OWN RISK.

Code: Select all

Sub MakePagePreview()
dim oDocView,oMouseClickHandler
	oDocView = ThisComponent.currentController
	oMouseClickHandler = createUnoListener("PagePreviewH_", "com.sun.star.awt.XMouseClickHandler")
	oDocView.addMouseClickHandler (oMouseClickHandler)
End Sub

Sub PagePreviewH_disposing(oEvt)
End Sub

Function PagePreviewH_mousePressed(Ev) As Boolean
'	PagePreviewH_mousePressed = False
End Function
	'

Function PagePreviewH_mouseReleased(Ev) As Boolean
	dim fff1 as boolean,fff2 as boolean,pwin,fulltitle,title,a,i,ff,st2,f,pnumber,controller1,controller2,VC2
	
	on error goto hr
	pwin=ev.source.accessiblecontext.getaccessibleparent.accessiblecontext.getaccessibleparent.accessiblecontext.getaccessibleparent
	fulltitle = pwin.accessiblecontext.titledbordertext
	a= instr(1,fulltitle," :")
	if a then
		title = left(fulltitle,a-1)
	else
		a = instr(1,fulltitle," -")
		title = left(fulltitle,a-1)
	end if
	ff = stardesktop.frames


	for i =0 to ff.count -1
		f = ff.getbyindex(i)
		st2 = f.gettitle
		if st2 =fulltitle then
			controller1 = f.controller
			fff1 = true
		else
			if  st2 <>fulltitle and instr(1,st2,title)=1 then
				controller2 = f.controller
				fff2 = true
			end if
		end if
		if fff1 = true and fff2 = true then exit for

	next

	pnumber = controller1.viewcursor.page

	controller2.componentwindow.setfocus
	wait 100
	VC2 = controller2.viewcursor

	VC2.jumpToPage(pnumber,false)
	
	hr:

end function


Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Post Reply