How to choose between OpenOffice and LibreOffice in API/SDK

1.6k views Asked by At

I'm converting one of our in-house apps to use OpenOffice/LibreOffice in addition to MS Office.

I was originally worried that it would be difficult to support both OpenOffice and LibreOffice, but I installed the LibreOffice SDK and to my surprise it launched the Apache OpenOffice installation (I have both installed).
So far it has been working perfectly, so my worries about OpenOffice/LibreOffice compatibility have gone away.

My question is how do you tell the bootstrap method which version to launch?
Is there a way to specify LibreOffice instead of OpenOffice if both are installed?
I'm developing in Visual Studio with C#/.NET, but I've gotten pretty good at translating examples from other languages since the OO/LO API examples on the web are so skimpy.

1

There are 1 answers

0
Quaternion On

Since you mentioned that solution in other languages may be translated/viable:

This is a Java solution.

Background

With OOo/LO (OpenOffice.org and LibreOffice respectively) when using Java you need to use juh.jar to establish the connection and this jar must be in the installation folder of OOo/LibreOffice and on the classpath.

This is pretty difficult if you're using maven or installing on a web container... to get around this, this page: https://forum.openoffice.org/en/forum/viewtopic.php?f=44&t=2520&sid=42b65314c6f727fe42315c9910e443b7 has a download as part of the first post (Feb 10, 2008) and I used the same jar today (Jan 30, 2014) and can verify that it work with LibreOffice 4.1.4 on Ubuntu 13.10. So that should give you further compatibility assurance!

Solution

The provided solution as can be seen on that page changes the connection string from:

//following assumes juh.jar is in the OOo/LO installation folder and is also on the classpath
com.sun.star.uno.XComponentContext xContext = com.sun.star.comp.helper.Bootstrap.defaultBootstrap_InitialComponentContext();

To the following which allows you to have juh.jar as a project resource but also requires bootstrapconnection.jar to be part of the project, because the installation folder is not relative to the juh.jar file it must be explicitly declared, like so:

//fully qualified names used to avoid any ambiguity
String oooExeFolder = "/opt/libreoffice4.1/program/";
com.sun.star.uno.XComponentContext xContext = ooo.connector.BootstrapSocketConnector.bootstrap(oooExeFolder);

The source code is also available in the downloaded jar.

Both OOo/LO start using "soffice".

Having looked over the code (bootstrapconnector.jar) it does not look overly long and should be pretty easy to convert.

My question is how do you tell the bootstrap method which version to launch?

  • convert the code contained in bootstrapconnector.jar to C# and you should be good to go
  • determine the paths to "soffice"
  • figure out which one is appropriate to pass in