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


Michael Stahl wrote:

actually now i tried it out and the crash was pretty trivially fixed
with commit d360477d8740f29e2c2bc5f7bbd667df7cd26ee9

This is great! It works!

So now I have one more way to process a document "headless". And now no weird window will be 
created.

Code for reading a document:

------------------------------------------------------------------------ 
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)
------------------------------------------------------------------------


Code for writing a document:
------------------------------------------------------------------------
textdoc = ServiceManager.createInstance("com.sun.star.text.TextDocument")

textdoc.initNew()
textdoc.Text.String = "Hello World from initNew()"

saveURL = systemPathToFileUrl(realpath("test.odt"))
outProps = PropertyValue("Overwrite", -1, True, 0), # 1-tuple
textdoc.storeAsURL(saveURL, outProps)

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

Even with a non-headless LO start (but with --nologo --nodefault) no window is created.
-- 
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.