I have a document containing just a couple of macros which I use for document conversion. The macros are
the first one opens the file passed as an argument and exports it as PDF /including the notes pages/. The second one simply quits openoffice/libreoffice.
With openoffice I can use this nicely to perform document conversion with customized options wrt standard ones. Also I find it very convenient to have the macros in a file, rather than to install them directly inside the application.
In this way, carrying with me just the macro file and a script I can do my conversions regardless of the specific instance of openoffice I am on.
Now this thing that works perfectly in openoffice, does not work with libreoffice. The issue seems to be the Shutdown macro not working in libre.
Its content is
Any clue why does this not work in libreoffice and works in openoffice?
StarDesktop.Terminate() indeed appears to be broken in libreoffice.
If you have a code snippet like the following
libreoffice on invocation displays both the box "ONE" and then the box "TWO", then hangs with no window.
Good catch; thanks. Noel ? :-)
found a possibly simpler testcase
does not work (libreoffice remains open)
works (openoffice opens and closes)
(In reply to comment #0)
> Sub Shutdown()
> End Sub
> Any clue why does this not work in libreoffice and works in openoffice?
Works for me!! I can think of no changes that would impact this behaviour. Additionally I would stress that calling Stardesktop.terminate in this way is unwise, I suspect that only by luck this doesn't core dump, tearing the ground from underneath basic whilst it's still running doesn't sound like a good idea ;-)
Is the quickstarter running ? I see the behaviour you describe in that scenario
Sergio, putting the bug into needs info ( see Whiteboard and keywords above ) please remove them when you can provide the info
(In reply to comment #3)
> found a possibly simpler testcase
> libreoffice ".uno:Quit"
> does not work (libreoffice remains open)
> soffice ".uno:Quit"
> works (openoffice opens and closes)
can you please open a seperate bug for that behaviour I think it is a completely different issue.
in reply to Noel's first message:
thanks for looking it... I strongly suspected that calling stardesktop.terminate in this way could be problematic, yet it was the suggested way on one of openoffice wikis (cannot remember where i got it, but I can try looking into it). If there is a better way to achieve the goal I would be happy to know. Maybe can you hint me a pointer (even out of this bug report, if it is inappropriate here).
For the note about "quickstarter..." I am on linux... I thought it was not available on this platform, is it?
for the "works for me" bit... I noticed this weird behaviour...
libreoffice helper.odt macro://helper/Standard.Module1.Shutdown\(\)
libreoffice opens and closes just fine. But if I call
libreoffice helper.odt macro://helper/Standard.Module1.DoSomething\(\) macro://helper/Standard.Module1.Shutdown\(\)
libreoffice opens, executes the DoSomething task just fine, then executes Shutdown, but does not close on the stardesktop.terminate()
... and in reply to the second one:
I run into the ".uno:Quit" because on one of the openoffice mailing list I found it indicated as a way to "test" the stardesktop.terminate() behaviour. If I remember correctly the entry was saying something like ".uno:Quit" goes through the dispatcher, but ultimately calls the stardesktop.terminate() api.
If appropriate, I will definitively open a different bug.
Note that if the ".uno:Quit" is made to work, I can modify my scripts to do
libreoffice helper.odt macro://helper/Standard.Module1.DoSomething\(\) ".uno:Quit"
(this works on openoffice.org). BTW would this be a more appropriate way to shut down openoffice after having executed a task?
I have seen that a quickstarter is in fact available on this version of the code.
The problem is present either with or without the quickstarter, though.
Created attachment 42886 [details]
Created a test case, a document with just the following macro:
msgbox("Ready to quit")
I have the following results in linux (ubuntu maverick 64bit) where both libreoffice 3.3 and openoffice.org 3.3 are installed
soffice prova.odt macro://prova/Standard.Module1.Shutdown\(\)
openoffice.org opens, opens the (empty) file prova.odt, prints the dialog "Ready to quit" on click on the OK button exits.
This is a nice behavior. Means that one can put macro code in a helper document and use it to script operations to be applied on other documents without any need to install a macro set within openoffice. Document automation can work under the following lines
soffice -headless helper.odt macro://helper.Standard.Module1.Process\(target_document.odt\)
This, assuming that the helper document contains a macro named process that does something on a target document and then invokes StarDesktop.Terminate()
On the invokation of the above command, soffice starts, performs the desired operation on the target document and quits. Also this is great for office automation, since it works anywhere, with no need to install anything apart, just providing the helper.
Since this has been the standard behavior of openoffice.org for ages, I came to rely on it and now I have many helper scripts that I use in this way.
libreoffice prova.odt macro://prova/Standard.Module1.Shutdown\(\)
libreoffice opens, opens the (empty) file prova.odt, prints the dialog "Ready to quit" on click on the OK button closes its window, then happyly reopens it and stays alive.
This is an unfortunate behavior. I cannot anymore do document automation like before. If I assume to have an helper script like before and I put something like
libreoffice -headless helper.odt macro://helper.Standard.Module1.Process\(target_document.odt\)
the script will hang forever, since libreoffice does not terminate after having performed its duty.
Also this is incosistent with openoffice.org and means that anyone having document automation scripts like mine cannot migrate to libreoffice.
1) Using the same approach as in "unoconv" does not seem to be an option to solve my document automation problem. Unoconv developers report themselves that they cannot start and stop reliably openoffice as a listener.
2) In the libreoffice test the quickstarter is disabled.
3) As already mentioned, the same kind of inconsistency between openoffice.org and libreoffice can be seen by
openoffice.org starts and terminates
libreoffice starts and does not terminate.
Please do not disregard this inconsistency between libreoffice and openoffice.org. It is not just something to put on a wishlist. It means that
anyone relying on document automation solutions developed for openoffice.org now
cannot migrate to libreoffice.
(In reply to comment #9)
> 3) As already mentioned, the same kind of inconsistency between openoffice.org
> and libreoffice can be seen by
> soffice ".uno:Quit"
> openoffice.org starts and terminates
> libreoffice ".uno:Quit"
> libreoffice starts and does not terminate.
I think that this is the key problem and ( the quit command ) is imho a bug, regarding the use of terminate from within a macro to shutdown the office I still remain unconvinced that it is wise. But.. I also begin to think the root cause of the behaviour of the macro and this above is the same
fixed on master, should appear in 3.3.1 ( thanks for the example doc and description it helped alot )
This is great news, many thanks!
related patches are