In LO Basic IDE, code completion seems to work for some UNO objects but not for others

In the LO Basic code below, I dimension a variable called objDocBuilder and then use it to instantiate an object of the type com.sun.star.xml.dom.DocumentBuilder .

'Declarations

	Dim objDocBuilder As Variant

    [...]

'Create the UNO service and get it into the object variable

	objDocBuilder=CreateUnoService("com.sun.star.xml.dom.DocumentBuilder")

I can confirm that the precise object type is com.sun.star.xml.dom.DocumentBuilder by creating a watch (1) for the variable objDocBuilder and then instantiating the object (2):

I understand from another thread that it is possible to use code completion in the LO Basic IDE with UNO objects. It says:

When typing the method’s name, and pressing the Tab key once, it will complete the selected entry, pressing the Tab key again will cycle through the matches with the longest prefix. For example, when aVar.aMeth is typed, it will cycle through aMeth1, aMethod2, aMethod3 entries, and other entries are not hidden.
Example:
Dim aPicker As com.sun.star.ui.dialogs.XFilePicker
is a valid variable definition, its methods can be accessed via the dot (".") operator:
aPicker.getDisplayDirectory()"
The sample code shown here does work. As it says in Help it only applies to Methods and to objects of a UNO extended type and does not work on a generic Object or Variant Basic type so I guess that it is working as specified.

I can confirm that this works as described by typing the following code into the IDE:

image

When I type aPicker followed by a period, a small window opens up showing me (what appear to be) the available methods (properties do not seem to be in this list, and at this time I am not sure whether this is because the XFilePicker object has no public properties or whether they are just not shown).

Since this seems to work, I came to the conclusion that it should also be possible to use code completion in the same manner with the code in my first example above if I declare the variable objDocBuilder as com.sun.star.xml.dom.DocumentBuilder instead of Variant like this:

'Declarations

	Dim objDocBuilder As com.sun.star.xml.dom.DocumentBuilder

This, however, seems to cause the following error:

image

When switching back and forth between the different libraries and modules, I also see the following, more explicit, error message:

Does anyone know why this is happening?

1 Like

Menu Tools / Options… / LibreOffice / Basic IDE. Check “Use extended types”. Restart LO.
I wouldn’t have high hopes for LO’s implementation of IntelliSense.

2 Likes

Yes, that option is already activated:

Perhaps I need to set a reference to the library that contains the com.sun.star.xml.dom.DocumentBuilder type, something like this?

GlobalScope.BasicLibraries.loadlibrary("NAME_OF_LIBRARY")
1 Like

So in any case, if an Intellisense-type functionality is not possible with UNO objects in LO Basic, is something similar at least possible in some other IDE with some other language, for example Eclipse and Python?

My wording was different. :slightly_smiling_face:
Perhaps in the future the IDE for Basic will include a complete IntelliSense system, and there will also be an IDE for Python (now many users use the APSO extension).

1 Like

I’m still very confused by all of this. I would like to have a programming environment similar to VBA or Visual Basic .Net, with similar functionality, with similar code completion, syntax checking, and so on. I am willing to learn any new programming language, such as Java or Python, and learn to use any IDE to achieve this. Is this currently possible with LibreOffice / UNO, or is this something that we will have to wait for?

1 Like

»apso« does not claim to be a complete IDE. it great for organizing, and partially for debugging.

there is no need for an LO-python-IDE, there are enough tools out in the world which does the job pretty well!

1 Like

works for me

It’s a matter of priorities.
Much more important to me is that LibreOffice:

  • open source
  • maintained and developed by a team of developers who try to respond to user comments
  • multiplatform
  • fully supports several programming languages, including Python(!)…

…and a screenshot directly from notebook (after .<tab> )

start here for jupyter-notebook

I agree and also think all of these things are important.

But I must also keep my job-related responsibilities in mind. I am in business for myself. Either I get my work done or I get no pay. It’s that simple. My work responsibilities include many complex tasks that would be absolutely impossible to carry out without all the tools that I have written in VBA and VB.Net.

I would love to port these tools to an open source environment in general and to LibreOffice in particular, but I absolutely must do this in a way that does not eat up so much of my time that I neglect other aspects of my job. It has to be doable with as little extra effort as possible.

So I will rephrase my question: Is there any combination of programming language and IDE that offers anything like the functionality provided by VBA or VB.Net?

1 Like

For StarBasic? No.
Python? Yes.
Java? I don’t know.

I think I must be doing something wrong. When I select the object variable objDocBuilder, then go to Tools | Add-Ons | MRI <- Selection, it says void.

2023-03-29-1724

We migrated quite a lot of productive code from VBA to LO Basic in three years.
Time consuming (this is not a joke):

  • learning the LO object model 95%
  • coding 5%
1 Like

You have no idea how valuable this answer is for me! I finally feel like I’m making some progress. I will immediately stop my efforts with Basic and focus on Python.

If anyone would like to do a screen sharing session and show me what the corresponding setup looks like and walk me through the steps of creating a simple LibreOffice extension, I will gladly pay the usual rates you would pay on a site like CodeMentor.io.

1 Like

I honestly don’t know what to say. I’m stunned.

1 Like

Have you ever managed to set up IDE for libeoffice? I’m struggling with this now as well. I tried Xray, APSO and experimental autocompletion option in libreoffice, but none of them provide autocompletion. I don’t know how to learn scripting without this.