I would like to kindly ask you for a help.
I am trying to automatize Libre office and I don't want to start any GUI while loading presentation:
To run presentation, I am using this command:
soffice --norestore --hidden --invisible "macro:///MyLibrary1.module1.addListener(file:///home/horai/prezentace1.odp)"
I wrote this script according to this link:
http://ooo-forums.apache.org/en/forum/v ... =9&t=22548
This script works when setting value of Property variable "Hidden" to "False"
But I really don't know what I am doing wrong, I am a macro newbie, I tried almost all parameter change to document loading, but when presentation is about to start, it always crashes, I blamed installation, upgrade also didn't help, I blamed old Ubuntu version, so I tried on my Raspberry where it is supposed to run, with the same crash result, I must be doing something wrong since it crashes on both platforms and I found many examples where this way of loading works
I am enclosing macro code:
Code: Select all
Global Doc As Object
Global Presentation As Object
Global Controller As Object
Global Listener As Object
Global Slide As Long
Global FileProperties(2) As New com.sun.star.beans.PropertyValue
Global Url As String
Global Counter As Integer
Global oSlideList as Object
Global oSlide as Object
REM Sub addListener(Url As String)
Sub addListener
Url = "file:///home/horai/prezentace.odp"
FileProperties(0).Name = "ReadOnly"
FileProperties(0).Value = True
FileProperties(0).Name = "Hidden"
FileProperties(0).Value = True
REM setting this to true used to work but now crashes :)
Doc = StarDesktop.loadComponentFromURL(Url, "_blank", 0, FileProperties())
oSlideList = Doc.getDrawPages
Presentation = Doc.Presentation
Listener = createUnoListener("EV_","com.sun.star.presentation.XSlideShowListener")
wait(100)
Presentation.Start()
wait(100)
Controller = Presentation.Controller
Controller.addSlideShowListener(Listener)
end sub
Sub EV_paused(oEv)
End Sub
Sub EV_resumed(oEv)
End Sub
Sub EV_slideTransitionStarted(oEv)
End Sub
Sub EV_slideTransitionEnded(oEv)
End Sub
Sub EV_slideAnimationEnded(oEv)
End Sub
Function getURLFromString(s$, optional protocol)
REM returns a com.sun.star.util.URL or Basic Null for invalid urls
Dim url as new com.sun.star.util.URL
Dim srv, bSuccess as Boolean
if isMissing(protocol) then protocol = ""
srv = createUnoService("com.sun.star.util.URLTransformer")
url.Complete = s
if len(protocol)>0 then
bSuccess = srv.parseSmart(url, protocol)
else
bSuccess = srv.parseStrict(url)
endif
if bSuccess then
getURLFromString = url
else
getURLFromString = Null
endif
End Function
Sub EV_slideEnded(oEv)
Slide = Controller.getCurrentSlideIndex
If Slide = 0 Then
oSlide = oSlideList.getByIndex(Slide)
name = oSlide.getName
Dim url as new com.sun.star.util.URL
url = getURLFromString(Doc.getUrl, "file:")
Dim filename2 As String
filename2 = "Video1.ts"
Dim filename1 As String
filename1 = url.Name
Dim filename As String
filename = filename1 & filename2
REM print filename
REM Shell("/usr/bin/cvlc",2 , "--play-and-exit -f /home/horai/" + filename,true)
REM Shell("/usr/bin/cvlc",2 , "--play-and-exit -f /mnt2/home/horai/Desktop/converted.mp4",true)
End If
End Sub
Sub EV_hyperLinkClicked(oEv)
End Sub
Sub EV_disposing(oEv)
End Sub
Sub Macro1
End Sub
Sub Macro2
End Sub