You are here

OpenOffice.org Automation

6 posts / 0 new
Last post
Stojilcoviz
Offline
Last seen: 15 years 6 days ago
Joined: 2009-12-11 09:58
OpenOffice.org Automation

I'm trying to automate the task of filling some documents using OpenOffice.org.
I've already developed a fully working apps that use OpenOffice.org installed into the user computer. What I want now to do is not use the copy of OpenOffice.org installed into the user computer but the portable version of OpenOffice.org stored into a USB stick.
The application I made is developed using VB.NET.
In the application all starts by placing reference to some assemblies (dlls: cli_basetypes, cli_cppuhelper, cli_oootypes, cli_ure and cli_uretypes) into the project. These dll contains functions and definition I can use to access OOo API (or what are also called "UNO Services") and automate OpenOffice.org tasks (like starting an instance of the OOo desktop, loading files and doing stuff in general) Keep in mind thant I don't start OOo desktop by launching some executables, instead I simply make a call to a bootstap function built into these dll. This functions in turn ask Windows to launch OOo desktop and return an object I can use.
These dll gets installed into the GAC where OOo is installed into the PC. In the portable version of OOo they are not present.
Anyway, in the portable version, I've found the "OpenOfficePortable\App\openoffice\URE\bin" folder wich seems to contain many dll related to OOo UNO (specifically the cli_uno.dll is a dll compatible with .NET framework).

My question is: how can I instantiate the OOo desktop using a portable version on OOo?

Thanks.

John T. Haller
John T. Haller's picture
Offline
Last seen: 9 hours 12 min ago
AdminDeveloperModeratorTranslator
Joined: 2005-11-28 22:21
Don't Think You Can

I think that .NET requires the DLLs to be registered within Windows, which obviously isn't the case with the portable version. You need to reference the DLLs directly to use them. I can't assist further than that as I don't use .NET or UNO.

Sometimes, the impossible can become possible, if you're awesome!

Stojilcoviz
Offline
Last seen: 15 years 6 days ago
Joined: 2009-12-11 09:58
Hum...don't think so. I mean,

Hum...don't think so. I mean, the dlls I use (cli_basetypes, cli_cppuhelper, cli_oootypes, cli_ure and cli_uretypes) can just be put into the program folder's and it'll be happy with that. What must be registered into the system, I suppose, is OOo itself. Code snippet follows:


Dim xContext As XComponentContext = Bootstrap.bootstrap()
Dim xFactory As XMultiServiceFactory = xContext.getServiceManager()
Dim xDesktop As unoidl.com.sun.star.frame.XDesktop = DirectCast(xFactory.createInstance("com.sun.star.frame.Desktop"), _
unoidl.com.sun.star.frame.XDesktop)
Dim xComponentLoader As unoidl.com.sun.star.frame.XComponentLoader
xComponentLoader = DirectCast(xDesktop, unoidl.com.sun.star.frame.XComponentLoader)
Dim newDocPropHidden As New unoidl.com.sun.star.beans.PropertyValue("Hidden", 0, New uno.Any(True), unoidl.com.sun.star.beans.PropertyState.DEFAULT_VALUE)
Dim newDocPropTemplate As New unoidl.com.sun.star.beans.PropertyValue("AsTemplate", 1, New uno.Any(True), unoidl.com.sun.star.beans.PropertyState.DEFAULT_VALUE)
Dim arProps() As unoidl.com.sun.star.beans.PropertyValue = New unoidl.com.sun.star.beans.PropertyValue() {newDocPropHidden, newDocPropTemplate}
Dim xComponent As unoidl.com.sun.star.lang.XComponent
xComponent = xComponentLoader.loadComponentFromURL(ToURL(docFilePath), "_blank", 0, arProps)

The function Bootstrap.bootstrap() is declared into cli_cppuhelper.dll that is not part of OOo portable (but its installed by OOo standard). As you can see no arguments are supplied so I assume this function relies on Windows to start OOo.
In the OpenOfficePortable\App\openoffice\URE\bin\ folder I've found the cli_uno.dll that in turns references cli_basetypes.dll, cli_ure.dll and cli_uretypes.dll none of wich is present in the OOo Portable version.

John T. Haller
John T. Haller's picture
Offline
Last seen: 9 hours 12 min ago
AdminDeveloperModeratorTranslator
Joined: 2005-11-28 22:21
Copy Them

You can copy them in from a standard OO.o install to that same folder. But you'll see that the automation you're trying to run will still fail. Your code needs OO.o registered with Windows. The portable version, by its nature, doesn't do that.

Sometimes, the impossible can become possible, if you're awesome!

MarkoMLM
MarkoMLM's picture
Offline
Last seen: 9 years 1 month ago
DeveloperTranslator
Joined: 2006-01-16 04:08
It is hard to solve Your problem without the program itself ...

...

try the tipp of John, if it don't works You can send me a link or the program at markomlm[at]openoffice.org Smile

I think Citavi does something similar and it works with the portable version too, so there should be a way.

Paid for Software more or less?
What You need is OSS!

roberto.lando
Offline
Last seen: 13 years 11 months ago
Joined: 2011-01-05 09:37
Portable UNO API

I've the same problem. Any new clue?

Roberto L.

Log in or register to post comments