Impress to start hidden

Discuss the presentation application
Post Reply
horai
Posts: 2
Joined: Thu Oct 05, 2017 8:50 pm

Impress to start hidden

Post 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:
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
Ubuntu 14.04, Libre Office Version: 4.2.8.2
Build ID: 420m0(Build:2)
User avatar
MTP
Volunteer
Posts: 1620
Joined: Mon Sep 10, 2012 7:31 pm
Location: Midwest USA

Re: Impress to start hidden

Post by MTP »

Which line in the macro is highlighted when the crash occurs?
OpenOffice 4.1.1 on Windows 10, HSQLDB 1.8 split database
horai
Posts: 2
Joined: Thu Oct 05, 2017 8:50 pm

Re: Impress to start hidden

Post by horai »

It crashes when presentation is started, therefore this line:
Presentation.Start()

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
Ubuntu 14.04, Libre Office Version: 4.2.8.2
Build ID: 420m0(Build:2)
User avatar
MTP
Volunteer
Posts: 1620
Joined: Mon Sep 10, 2012 7:31 pm
Location: Midwest USA

Re: Impress to start hidden

Post by MTP »

Have you tried adjusting the wait time before the .start()? If you change it to 7 seconds (7000), does it still crash?
OpenOffice 4.1.1 on Windows 10, HSQLDB 1.8 split database
Post Reply