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


Jens Tröger wrote:

Hi,

As a follow-up to this thread, Piet (in a different thread: "Re: How
many degrees of headlessness do we need? [and LibreOffice crash]")
posted this snipped of code to open a Writer document only:

------------------------------------------------------------------------                         
                    
textdoc = ServiceManager.createInstance("com.sun.star.text.TextDocument")

loadURL = systemPathToFileUrl(realpath("test.odt")) 
inProps = (PropertyValue("URL", -1, loadURL, 0), PropertyValue("FilterName", -1, "writer8", 0)) 
textdoc.load(inProps) 

print(textdoc.Text.String) 

textdoc.close(True) 
------------------------------------------------------------------------                         
                    

While I couldn't use this due to a crash of createInstance(), it looks
to me as if this code would be an alternative to what we've discussed in
this thread.  I assume that loading, say, a Calc or an image would fail
here?

Cheers,
Jens

That is what I would expect. However, I tried it, and when I open an Excell sheet (.xls) or a PNG, 
it gives an error message, but when I use a .ods file, it just hangs (presumably in the load). And 
it won't be killed by ctrl-C. This probably should be considered a bug.

When I then kill the LO process, the Python program gives this error message:
SystemError: Couldn't instantiate python representation of structered UNO type 
com.sun.star.lang.DisposedException
-- 
Piet van Oostrum <piet@vanoostrum.org>
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]

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.