Load files into Writer only?
Jens Tröger
jens.troeger at light-speed.de
Sat Mar 14 21:25:54 PDT 2015
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!
On Thu, Mar 05, 2015 at 05:53:35AM +0100, Jens Tröger wrote:
> One way of approaching the problem below is by checking the file type of
> the document, before handing it off to the soffice instance. Checking
> the extension only might be too flimsy, perhaps libmagic can help?
>
> There is a list of supported file formats here:
>
> http://en.wikipedia.org/wiki/LibreOffice#Supported_file_formats
>
> but it seems rather tedious to me to check manually for Writer document
> files. Is there a better way?
>
> Cheers.
>
>
> On Thu, Feb 26, 2015 at 05:36:18PM +0100, Jens Tröger wrote:
> > Hi,
> >
> > Is there a way to load Writer supported documents only, and dismiss
> > (fail) on others? For example, I connect to an office server like so
> >
> > local = uno.getComponentContext()
> > resolver = local.ServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", local)
> > context = resolver.resolve("uno:pipe,name=foopipe;urp;StarOffice.ComponentContext")
> > desktop = context.ServiceManager.createInstanceWithContext("com.sun.star.frame.Desktop", context)
> >
> > Now I'd like to
> >
> > desktop.loadComponentFromURL()
> >
> > and if that file is e.g. and image that Writer can not open, then fail.
> > Same for any other file which is not a Writer supported file. I've
> > looked at this call
> >
> > http://www.openoffice.org/api/docs/common/ref/com/sun/star/lang/XMultiComponentFactory.html#createInstanceWithArgumentsAndContext
> >
> > but can't figure out if that's the right way to go. Or should I check
> > if the file is of a certain type before I pass it on to office? In that
> > case though, I might reject some funky format which Writer supports,
> > just because I didn't know about it.
> >
> > Thanks!
> > Jens
>
--
Jens Tröger
http://savage.light-speed.de/
More information about the LibreOffice
mailing list