REM ***** BASIC ***** ' ' soplayer written in OpenOffice.org Basic ' ' Version 0.1 - July 30, 2004 by Takamichi Akiyama ' ' License: GNU GPL ' ' This macro allows you to load an Impress file, start presentation, and then close it. ' ' Installation ' Create a new macro library. Any name, for instance 'Stealth', could be OK. ' Create a new module in the library ' Copy the following code into the module ' ' Usage ' cd C:\Program Files\OpenOffice.org1.1.2\program ' soffice -nologo macro:///Stealth.Module1.Play("C:\Documents and Settings\Tora\My Documents\OOo\PlayPresentation\Test.sxi") ' Option Explicit Sub Test Play("C:\Documents and Settings\Tora\My Documents\OOo\PlayPresentation\Test.sxi") End Sub Sub Play(sFilename As String) Dim oDoc As Object Dim sUrl As String Dim Args(0) As New com.sun.star.beans.PropertyValue 'MsgBox sFilename sUrl = ConvertToURL(sFilename) Args(0).Name = "Hidden" Args(0).Value = True oDoc = StarDesktop.loadComponentFromURL(sUrl, "_blank", 0, Args()) 'oDoc = ThisComponent if HasUnoInterfaces(oDoc, "com.sun.star.presentation.XPresentationSupplier") Then 'debug oDoc StartPresentation(oDoc) 'msgbox oDoc.Presentation.IsFullScreen if (oDoc.Presentation.IsFullScreen) Then do Wait 2000 'MsgBox isOnGoing(oDoc) loop While (isOnGoing(oDoc)) 'msgbox "Finished" oDoc.close(True) End If Else MsgBox sFilename & " is not an Impress file." End If End Sub Function isOnGoing(oDoc As Object) As Boolean Dim xController As Object Dim sTitle As String Dim oDesktop As Object Dim oComponents As Object Dim nCount As Integer Dim oEnumeration As Object Dim oElement As Object Dim xFrame As Object xController = oDoc.getCurrentController() sTitle = xController.getFrame().Title 'msgbox sTitle nCount = 0 oDesktop = CreateUnoService("com.sun.star.frame.Desktop") oComponents = oDesktop.getComponents() if oComponents.hasElements() Then oEnumeration = oComponents.createEnumeration() do while (oEnumeration.hasMoreElements()) oElement = oEnumeration.nextElement() if HasUnoInterfaces(oElement, "com.sun.star.presentation.XPresentationSupplier") Then 'debug oElement xController = oElement.getCurrentController() 'debug xController xFrame = xController.getFrame() 'debug xFrame If xFrame.Title = sTitle Then nCount = nCount + 1 End If end if loop End If isOnGoing = (nCount >= 2) End Function Private Sub StartPresentation(oDoc As Object) Dim oPresentation As Object oPresentation = oDoc.Presentation 'debug oPresentation ' For details: http://api.openoffice.org/docs/common/ref/com/sun/star/presentation/Presentation.html oPresentation.AllowAnimations = True oPresentation.CustomShow = "" oPresentation.FirstPage = "" oPresentation.IsAlwaysOnTop = False oPresentation.IsAutomatic = False oPresentation.IsEndless = False oPresentation.IsFullScreen = True 'oPresentation.IsLivePresentation = oPresentation.IsMouseVisible = True oPresentation.IsShowAll = True oPresentation.IsTransitionOnClick = True oPresentation.IsShowLogo = False oPresentation.Pause = 10 oPresentation.StartWithNavigator = False oPresentation.UsePen = True oPresentation.Start() End Sub Private Sub debug(oObject as Object) msgBox(oObject.dbg_properties) Dim oProperties As Object Dim sName As String Dim oValue As Any Dim sBuffer As String Dim i As Integer oProperties = oObject.getPropertySetInfo().getProperties() if isEmpty(oProperties) Then msgbox "This object has no Property" else for i = LBound(oProperties) To UBound(oProperties) sName = oProperties(i).Name oValue = oObject.getPropertyValue(sName) 'msgbox sName if isObject(oValue) Then sBuffer = sBuffer + sName + " is an object" + Chr(13) 'msgbox oValue.dbg_methods elseif isEmpty(oValue) Then sBuffer = sBuffer + sName + " is Empty" + Chr(13) elseif isNull(oValue) Then sBuffer = sBuffer + sName + " is Null" + Chr(13) else sBuffer = sBuffer + sName + "=" & Cstr(oValue) + Chr(13) end if next i msgbox sBuffer end if msgBox(oObject.dbg_methods) msgBox(oObject.dbg_supportedInterfaces) end sub