Add control to dialog in macro

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
FDB
Posts: 12
Joined: Mon Oct 16, 2023 3:36 pm

Add control to dialog in macro

Post by FDB »

I have a dialog for using with a database. This dialog can have a variable number of controls (labels, checkboxes and popup menus).
For experimental purposes, a label named "LabelName" is created manually in the dialog. I can pick up this label from the macro by using getControl.

Creating a second label in the macro CreateUnoService ("stardiv.Toolkit.UnoFixedTextControl") makes the correct object.
This empty (?) object can be modified for size/position.
However adding Text does not show up in the debugger.
Adding this label to the dialog results in error :
Type: com.sun.star.uno.RuntimeException
Message: createPeer: no model

Code: Select all

Option Base 1
Option Explicit

Sub Main
	dim hDialog
	GlobalScope.BasicLibraries.LoadLibrary("Tools")	' loading Tools library
	ThisComponent.CurrentController.connect	' https://forum.openoffice.org/en/m/viewtopic.php?t=42882

	hDialog = CreateUnoDialog(DialogLibraries.getByName("Standard").getByName("DialogTest"))
' type : stardiv.Toolkit.UnoDialogControl

	dim hLabel
	hLabel = hDialog.getControl ("LabelName")	' https://wiki.openoffice.org/wiki/Documentation/DevGuide/Basic/List_Box
' type = stardiv.Toolkit.UnoFixedTextControl

	dim hLabel2
	hLabel2 = CreateUnoService ("stardiv.Toolkit.UnoFixedTextControl")
	hLabel2.setText ("LLLLLLabel2text")
	hLabel2.PosSize.Width = 100
	hLabel2.PosSize.Height = 25
	hLabel2.PosSize.X = 27
	hLabel2.PosSize.Y = 50
	hDialog.addControl ("Label2Name", hLabel2)

	hDialog.Execute()
End Sub
What is missing ?
OpenOffice 4.1.14
OSX 10.14.6 (Mojave)
JeJe
Volunteer
Posts: 2814
Joined: Wed Mar 09, 2016 2:40 pm

Re: Add control to dialog in macro

Post by JeJe »

You haven't used setmodel so there isn't one.

viewtopic.php?t=71650
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Post Reply