Hi Mike,
That would be a good answer to have, because finding documentation on this
topic is tricky. Here is how I currently handle this in Python:
pipe = …
p = subprocess.Popen("/…/soffice --accept='pipe,name=" + pipe +
";url;StarOffice.ServiceManager' --headless --invisible", shell=True)
# Wait for the pipe to become available.
local = uno.getComponentContext()
resolver =
local.ServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver”,
local)
context = resolver.resolve("uno:pipe,name=" + pipe +
";urp;StarOffice.ComponentContext")
desktop =
context.ServiceManager.createInstanceWithContext("com.sun.star.frame.Desktop",
context)
# Load the document
docfile = …
document = desktop.loadComponentFromURL("file://" + docfile, "_blank", 0,
props)
This creates a new office process and open the Writer document and connects to
it. Note the absence of the custom user installation (for performance reasons)!
Once I’m done with it, then:
document.close(True) # or if XCloseable doesn’t exist: document.dispose()
desktop.terminate()
# context.??
# resolver.??
# local.??
p.terminate()
The termination of the process p seems to destroy the other running soffice
process. Hence using custom user installations with
-env:UserInstallation=/tmp/random-dir but that just prolongs the process
creation noticeably!
Thanks!
Jens
> On Oct 19, 2017, at 16:48, Kaganski Mike <[email protected]> wrote:
> Hi,
>
> Maybe the real question is how to close a document without forcing
> soffice process (which is shared in your case among all open documents)
> shutdown?
>
> --
> Best regards,
> Mike Kaganski
>
--
Jens Tröger
http://savage.light-speed.de/
_______________________________________________
LibreOffice mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/libreoffice