Date: prev next · Thread: first prev next last
2017 Archives by date, by thread · List index


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 <mikekaganski@hotmail.com> 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/


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.