Load files into Writer only?
Piet van Oostrum
piet at vanoostrum.org
Sun Mar 15 11:36:15 PDT 2015
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 at vanoostrum.org>
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]
More information about the LibreOffice
mailing list