Page 1 of 1

Impress to start hidden

PostPosted: Thu Oct 05, 2017 9:00 pm
by horai
Dear all,

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: ... =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   Expand viewCollapse view
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
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_","")
Controller = Presentation.Controller

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 or Basic Null for invalid urls
Dim url as new
Dim srv, bSuccess as Boolean
   if isMissing(protocol) then protocol = ""
   srv = createUnoService("")
   url.Complete = s
   if len(protocol)>0 then
        bSuccess = srv.parseSmart(url, protocol)
        bSuccess = srv.parseStrict(url)
   if bSuccess then
      getURLFromString = url
      getURLFromString = Null
End Function

Sub EV_slideEnded(oEv)

Slide = Controller.getCurrentSlideIndex
If Slide = 0 Then
oSlide = oSlideList.getByIndex(Slide)
name = oSlide.getName
Dim url as new
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

Re: Impress to start hidden

PostPosted: Fri Oct 06, 2017 8:27 pm
by MTP
Which line in the macro is highlighted when the crash occurs?

Re: Impress to start hidden

PostPosted: Sat Oct 07, 2017 7:14 am
by horai
It crashes when presentation is started, therefore this line:

If I set "Hidden" to false, then it starts and does tasks correctly, but maybe it's running by luck and I have done a mistake which will not be tolerated next time

Thank you

Re: Impress to start hidden

PostPosted: Tue Oct 10, 2017 9:04 pm
by MTP
Have you tried adjusting the wait time before the .start()? If you change it to 7 seconds (7000), does it still crash?