Where to find information on properties of dialog controls that can be changed at runtime and how to do so

Hello everyone,

I’m trying to move from Microsoft Office VBA to LibreOffice Basic, but I’m hitting some snags.

In Excel VBA, I have a program that loads and displays a PDF dynamically in a WebBrowser control on a form at runtime.

In LibreOffice Basic, I see that I can display the first page of a PDF in an ImageControl at design time by setting the Graphics property to the file that I would like to display (perhaps because this is the thumbnail of the PDF, but that is beside the point).

However, I was unable to find any information on whether the Graphics property on an ImageControl can also be changed at runtime and if so, how to do it.

At design time, the Graphics property shows the path to the file like this:


However, the following code does not work:

Sub StartDialog1()
	Dim oDialog1 as Object
	oDialog1 = loadDialog("Standard","Dialog1")
	oDialog1.ImageControl1.Graphics = "file:///C:/Users/<username>/Desktop/test.pdf"
end sub

Variations that I tried to guess such as oDialog1.ImageControl1.Graphics = loadGraphics("file:///C:/Users/<username>/Desktop/test.pdf") or oDialog1.ImageControl1.Graphics = loadPicture("file:///C:/Users/<username>/Desktop/test.pdf") also did not work.

Interestingly, the error that I see in every case does not indicate that I am attempting to load an image the wrong way, it indicates that ImageControl1 does not exist or cannot be accessed:


I also noticed that there is no code autocompletion for oDialog1 or ImageControl1 at design time. This seems to make sense, since the oDialog1 variable is declared as a generic object, so the IDE cannot know what it is until it is instantiated.

However, I find the following behavior puzzling: When I add a watch to the variable oDialog1 and step through the code, I see that after the loadDialog command is executed, the variable oDialog1 is of the type stardiv.Toolkit.UnoDialogControl. But when I try to declare the variable oDialog1 as stardiv.Toolkit.UnoDialogControl so that I can see its properties and methods at design time, it throws an error.

Basic syntax error.
Unknown data type stardiv.Toolkit.UnoDialogControl

The VBA language reference says the following about the Picture property:

While designing a form, you can use the control’s property page to assign a bitmap to the Picture property. While running a form, you must use the LoadPicture function to assign a bitmap to Picture.

Does similar detailed information exist for the LibreOffice ImageControl (and other controls), and if so, where can I find it? Thanks!


P.S. When I search for ImageControl in the documentation (Omega Search: imagecontrol), it shows two results: SFDialogs.DialogControl service and SFDocuments.FormControl service. Both documents mention ImageControl in connection with a property called Picture (which the control does not seem to have), but neither mention a property called Graphics (which the control does have). Am I missing something?

For the image control in a dialog see code in this post → Macro to load an image into an imagecontrol in Calc - #3 by Ratslinger
For documentation (some as the is much scattered) see:
Creating a Basic Dialog
LibreOffice Developer's Guide: Chapter 19 - Graphical User Interfaces - The Document Foundation Wiki
For examining items such as oDialog1 use an object inspector such as MRI. See → Basic: At runtime how do I best investigate values inside variables and find available resources? - #2 by Ratslinger

Providing your VBA gets converted to Python, you can use Python REPL console to introspect UNO objects as described in

Thanks, this works very well. So if I understand correctly, it is not possible to access the properties of ImageControl1 directly as a child objects (or properties) of the Dialog1 object, I have to use GetModel to get a reference to the (object?) model of Dialog1, then I can work with it.
Playing around with this code, I also just discovered that the three lines

oModel = oDialog1.getModel()
oObj1 = oModel.getByName("NAME_OF_IMAGE_CONTROL")
oObj1.ImageURL = sURL

can be reduced to

oDialog1.getModel().getByName("ImageControl1").ImageURL = sURL

But do I understand correctly that there is no centralized language reference that provides information such as this? Couldn’t we create a page in help.libreoffice.org that explains how to load an image into an ImageControl using this technique?
And what about the syntax error that I get when trying to declare a variable with
Dim oDialog1 As stardiv.Toolkit.UnoDialogControl (strong typing)
instead of
Dim oDialog1 As Object (weak typing)?
Why does that happen?
I installed MRI today but haven’t figured out how it works yet.

Thanks for this tip, I’ll look into it!
P.S. Can someone please remove the restrictions on posting multiple links and embedded screen shots in posts for me? Thanks!
P.P.S. Sorry for all the extra dots between paragraphs, but I didn’t see any way to get some space between paragraphs for legibility.

In this case yes. There are other cases where the access to a control is available through an event.

Not that I recall. Anyone can offer to work on documentation.
Often code here is posted in simpler form because many are dealing with macros for a first time.

Not very knowledgeable on the toolkit. Can create windows & maybe a bit more.

Try <br>

Believe the restriction is only for the first 24 hours.

A couple of more links for you:

In that case I would like to offer to work on documentation. Where do I apply?

By the way, why is the property called ImageURL when accessing it programmatically and Graphics when accessing it in properties page of the control in the dialog editor?

Probably won’t get an answer to that. If a design issue, it can go back many, many years. There are a number of questionable items in LO. When using Base, there is the Form you use and the internal Form(s) where the controls are placed. There are multiple Text Boxes. More I’m sure.

Ah ok. Is it possible to raise issues on Gitlab for things like this to have them fixed in some future update, or what is the correct procedure? If the label in the UI / IDE is changed to match the naming convention of the API, this would most likely not break anything.

All problems and enhancements go through Bugzilla