com.sun.star.comp.forms.ODatabaseForm

Hello everyone,

A form, which is visible in form navigator is of “com.sun.star.comp.forms.ODatabaseForm” type/service. Yet I looked it up in both, Libreoffice and Apache OO API reference, and I cannot find any information pertaining to it. But after looking up the Forms service, and finding the insertByName method inherited from XNameContainer interface, the only way that I found to create that form programmatically would be by the following code:

oForm = createUnoService(“com.sun.star.comp.forms.ODatabaseForm”)
ThisComponent.Sheets(0).DrawPage.Forms.InsertByName(“FormName”, oForm)

Questions that I’d like to ask are:

  1. Why isn’t this service listed in the API Reference? I understand that the form gets automatically added when creating a new control, such as a button. But through my learning process I just wanted to understand the methodology behind this. I went through all three of Mr. Pitonyak’s books and did not find anything pertaining to it. The only mention which I found of this service was in ch. 9 of LibreOffice Base Handbook. But even that did not answer my question.

  2. This has to do with the semantics of methods definition in the API Reference. When I looked up the insertByName function, it’s definition shows two parameters. First the name of the form to be created in a string format, and second is "[in] any aElement ". In all honesty, it’s completely by fluke that I actually figured it out and created the oForm object, and defined it as ODatabaseForm. Some of those parameter definitions are truly incoherent to a layman like myself. I’d like to ask if there is any literature to which I could refer to get a better understanding of how to read those definitions? Or is it just a matter of practice and experience?

Thank you in advance for any suggestions.

Hello,

Don’t know anything about that.

However, in AndrewBase, section 2.3.2 is a macro to create a database form. It uses com.sun.star.form.component.Form.

That’s pretty much it. Getting use to where to look for something. The API is helpful and MRI or XRay is a must. Pitonyak books are good reference. Using Ask & AOO forum & others. Helps to know how to search the net.

1 Like

However, in AndrewBase, section 2.3.2 is a macro to create a database form. It uses com.sun.star.form.component.Form .

I completely missed that! Page 14, thank you!! Just tried, and it does precisely the same thing. Interesting, I wonder if one is just a reference to the other?

I just looked at the inheritance diagram https://api.libreoffice.org/docs/idl/ref/servicecom_1_1sun_1_1star_1_1form_1_1component_1_1Form.html and sure enough, it is part of the Forms collection.

That’s pretty much it. Getting use to where to look for something. The API is helpful and MRI or XRay is a must. Pitonyak books are good reference. Using Ask & AOO forum & others. Helps to know how to search the net.

Have I picked a fairly difficult language to learn due to lack of extensive documentation? When you compare Python or Javascript, there is very little on LO/AOO Basic :).

I do have MRI installed, and I just watched @JohnSUN awesome YouTube video on it a couple of hours ago. Very powerful tool.

1 Like

For LO macros, the API is necessary. Doesn’t matter the language you use although there is not much in the way of Javascript. In Basic there are the Pitonyak and LO manuals and many, many posts here and on the AOO forum. Plenty of Basic examples. There is more & more on Python. See the on-line help and enter Python for the search → LibreOffice 7.2 Help.

Would actually say there is a lot there. The problem is understanding how to use it and all the different places to look. Takes some time. For me the first six months were tough and for the next X years you keep finding out more and more.

1 Like