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


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/

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.