Call LibreOffice from Gambas

This may be impossible, but I will ask anyway.

Elsewhere on this forum a user asked the question “How to call LibreOffice from Visual Basic” and the answer was:

REM Instantiate OOo: this line is mandatory with VB for OOo API 
oSM = CreateObject ("com.sun.star.ServiceManager") 
REM Create the first and most important service 
oDesk = oSM.createInstance ("com.sun.star.frame. Desktop ")

My question is “How is “com.sun.star.ServiceManager” made known to VB?” There seems to be a missing declaration describing how to find it. Is this set up in environment variables perhaps?

My objective is to control LO from Gambas. In Gambas, I can call into shared libraries like so:

Extern getgid() As Integer In "/usr/lib64/libc:6"

Public Sub Form_Open()
  Dim intGid As Integer
  intGid = getgid()
  TextBox1.Text = "GID = "
  TextBox1.Insert(CStr(intGid))
End

As you can see, I have to declare a function and its location (which .so file) before I can call it. Is this even possible with LO? Are methods etc. contained in discrete files, or am I wasting my time trying?

Kind regards,
Doug

This isn’t a direct answer to your question, but might help you get on the right track until someone else, with more knowledge than I have, responds.

Given you are using Linux (Fedora) you can find the libraries in /opt/openoffice4/program; you can then play around with nm or objdump (see the relevant man pages for more info) to expose the functions in the shared libraries. I suspect the libraries you want to investigate will be the *uno.so libs.

If this answer helped you, please accept it by clicking the check mark :heavy_check_mark: to the left and, karma permitting, upvote it. If this resolves your problem, close the question, that will help other people with the same question.

Thanks robleyd. Scanning the .so files as you suggest is a good idea and I am planning to do so. It is a bit of a jigsaw to piece together the list of files and their contents, but, hey, that’s what an RDBMS is for! ":sunglasses:

If there is any way to use the LibreOffice shared libraries externally, I have not been able to find it. The .so files look to me like C++ classes. Unless someone is able to tell me otherwise, I will stop wasting my time looking for a way to control LO from Gambas.