[Solved] Impress: Selecting slides in presentation mode

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
platypus
Posts: 3
Joined: Sat Dec 24, 2016 2:34 pm

[Solved] Impress: Selecting slides in presentation mode

Post by platypus »

Season's greetings...

I have a multi-slide presentation which I need to have a macro starts the presentation, and then select various slides based on some data coming in on a serial port. I've got the serial port working (which I thought was going to be the hardest part), now I just need to do the slide selection.

After some attempts & Googling I've come up with this, but it only works before the presentation is started. I know I'm missing something quite fundamental but can't quite find it :(

Can somebody put me on the right track?
Thanks!

Code: Select all

	dim odoc as object
	dim odrawpage as object
	odoc = ThisComponent
	
	' oDoc.Presentation.Start() ' doesn't work when this line uncommented
	n = 3 ' for example
	oDrawPage = oDoc.getDrawPages().getByIndex(n)
	odoc.CurrentController.setCurrentPage(odrawpage)
	
Last edited by platypus on Tue Dec 27, 2016 2:32 pm, edited 1 time in total.
OpenOffice 4.13 on Windows 10
User avatar
RoryOF
Moderator
Posts: 34618
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Impress: Selecting slides in presentation mode

Post by RoryOF »

If there are a limited number of selections you could prepare a series of presentations, each for the sequence of its start slide then start OpenOffice with that presentation from the command line. This would move the serial port reading and resulting analysis into a Windows batch file. Analyse the serial input into a unique number then call the presentation with that number inserted from the command line.

You can customise the presentations by selecting the appropriate slides in order from /Slide Show/ Custom Slide Show within OpenOffice and giving it a suitable name.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
FJCC
Moderator
Posts: 9280
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Impress: Selecting slides in presentation mode

Post by FJCC »

I don't think you can change the slide order once the presentation is running. If you want to display a particular slide for each serial port input, I think you would have to define a single slide presentation using the input and restart the presentation. I expect that would look clunky.
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
User avatar
RoryOF
Moderator
Posts: 34618
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Impress: Selecting slides in presentation mode

Post by RoryOF »

FJCC wrote:I don't think you can change the slide order once the presentation is running. If you want to display a particular slide for each serial port input, I think you would have to define a single slide presentation using the input and restart the presentation. I expect that would look clunky.
That was my thought also, but if each lead slide requires a different sequence and/or selection in the presentation then having the (hopefully small) number of customised presentations, each stored under a unique (numbered) name, may be the way to go.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
platypus
Posts: 3
Joined: Sat Dec 24, 2016 2:34 pm

Re: Impress: Selecting slides in presentation mode

Post by platypus »

FJCC wrote:I don't think you can change the slide order once the presentation is running. If you want to display a particular slide for each serial port input, I think you would have to define a single slide presentation using the input and restart the presentation. I expect that would look clunky.
Ah OK, that would explain things. Mind you, there is a "go to slide" option on a right-click during the presentation, so there MAY be something buried somewhere...

I was hoping to use this as a simple way of demonstrating an interactive beacon. The IB spits out a string over a serial connection to a host when a connection is made to it and I was intending to extract certain fields then jump to the pertinent slide to display the correct audio/graphics depending on the connection. So my boss who will be doing the demos can easily put his own content on the slides & off he goes :super:

Maybe I'll have to have a rethink...

Thanks,
P
OpenOffice 4.13 on Windows 10
User avatar
RoryOF
Moderator
Posts: 34618
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Impress: Selecting slides in presentation mode

Post by RoryOF »

The OO API offers these hooks into a presentation
https://www.openoffice.org/api/docs/com ... oller.html
https://www.openoffice.org/api/docs/com ... eShow.html
https://www.openoffice.org/api/docs/com ... rBase.html

There are others, but these may suggest a method. I think you will have to program your application at the macro level, directly interfacing with the API; I don't know of any high level hooks that will allow you to do what you wish.

An existing extension
http://extensions.openoffice.org/en/pro ... slide-show
allows one generate a random slide show; its source code is available. This might be modified for your purpose.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
platypus
Posts: 3
Joined: Sat Dec 24, 2016 2:34 pm

Re: Impress: Selecting slides in presentation mode

Post by platypus »

OK I've managed to get something working now I've finally figured out what relates to what, which I couldn't get from the docs. So thanks to all, here is my snippet of test code for a presentation with 4 slides:
 Edit:  Forgot to say thank you!

Code: Select all


	dim oPres as object
	dim oCtrl as object
	dim n,c as long
	
	dim MySlideArray(4) as long

	MySlideArray(0) = 3
	MySlideArray(1) = 2
	MySlideArray(2) = 0
	MySlideArray(3) = 1
	
	oPres = ThisComponent.Presentation
	oPres.Start
	
	if oPres.IsRunning() then
		oCtrl = oPres.getController()
		c = oCtrl.GetSlideCount()
		for n = 0 to 3
			OCtrl.gotoSlideIndex(MySlideArray(n))
			wait 1000
		next
	else
		MsgBox("Presentation not running")	
	endif
 
OpenOffice 4.13 on Windows 10
Post Reply