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


Jens Tröger wrote:

I've done some digging around, and I've figured out how to spawn a
Writer instance.  But then I get stuck when I try to load the document.
There's more code here:

  https://forum.openoffice.org/en/forum/viewtopic.php?f=25&t=75608#p345563

Any help with this would be greatly appreciated :-)

Thanks!

document = desktop.loadComponentFromURL("file:///path/to/document.odt", "_blank", 0, ())
if document.supportsService('com.sun.star.text.TextDocument'):
   ...

You can also specify in the loadComponentFromUrl call thet you want Writer documents preferably, 
but this doesn't prevent LO to open other types also that it recognizes:

from com.sun.star.beans import PropertyValue
prop = PropertyValue('FilterName', 0, 'writer', 0)
document = desktop.loadComponentFromURL("file:///path/to/document.odt", "_blank", 0, (prop,))

It only means that LO will treat it as a Writer document if it can't inder the type from the file 
itself.
-- 
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.