Ayuda de LibreOffice 25.2
Los siguientes exemplos aplicar a un nuevu diálogu llamáu "Dialog1". Utilice les ferramientes de la barra Cuadru de ferramientes del editor de diálogos pa crear el diálogu y amestar los controles siguientes: una caxellu de verificación denominada "Casillaverificación1", un campu d'etiqueta denomináu "Etiqueta1", un botón denomináu "Botóncomandu1" y un cuadru de llista denomináu "Cuadrulista1".
Fai un usu coherente de les mayúscules y les minúscules cuando axuntes un control a una variable d'oxetu.
Function LoadDialog(Libname as String, DialogName as String, Optional oLibContainer)
Dim oLib as Object ' com.sun.star.script.XLibraryContainer
Dim oLibDialog as Object
Dim oRuntimeDialog as Object
If IsMissing(oLibContainer) Then
oLibContainer = DialogLibraries
End If
oLibContainer.LoadLibrary(LibName)
oLib = oLibContainer.GetByName(Libname)
oLibDialog = oLib.GetByName(DialogName)
oRuntimeDialog = CreateUnoDialog(oLibDialog)
LoadDialog() = oRuntimeDialog
End Function
LoadDialog function is stored in Tools.ModuleControls available from Application Macros and Dialogs.
REM definición global de variables
Dim oDialog1 AS Object
Sub StartDialog1
With GlobalScope.BasicLibraries
If Not .IsLibraryLoaded("Tools") Then .LoadLibrary("Tools")
End With
oDialog1 = Tools.ModuleControls.LoadDialog("Standard", "Dialog1")
oDialog1.Execute()
End Sub
Sub Sample1
With GlobalScope.Basiclibraries
If Not .IsLibraryLoaded("Tools") Then .LoadLibrary("Tools")
End With
oDialog1 = Tools.LoadDialog("Standard", "Dialog1")
REM llograr modelu de diálogu
oDialog1Model = oDialog1.Model
REM amosar testu de Label1
oLabel1 = oDialog1.GetControl("Label1")
MsgBox oLabel1.Text
REM afitar testu nuevu pal control Label1
oLabel1.Text = "Ficheros nuevos"
REM amosar propiedaes de modelu pal control CheckBox1
oCheckBox1Model = oDialog1Model.CheckBox1
MsgBox oCheckBox1Model.Dbg_Properties
REM afitar estáu nuevu pa CheckBox1 pa modelu del control
oCheckBox1Model.State = 1
REM amosar propiedaes de modelu pal control CommandButton1
oCMD1Model = oDialog1Model.CommandButton1
MsgBox oCMD1Model.Dbg_Properties
REM amosar propiedaes del control CommandButton1
oCMD1 = oDialog1.GetControl("CommandButton1")
MsgBox oCMD1.Dbg_Properties
REM executar diálogu
oDialog1.Execute()
End Sub
Sub AddEntry
With GlobalScope.Basiclibraries
If Not .IsLibraryLoaded("Tools") Then .LoadLibrary("Tools")
End With
oDialog1 = ModuleControls.LoadDialog("Standard", "Dialog1")
REM amiesta una entrada nueva al cuadru de llista
oDialog1Model = oDialog1.Model
oListBox = oDialog1.GetControl("ListBox1")
Dim iCount as integer
iCount = oListbox.ItemCount
oListbox.additem("Elementu nuevu" & iCount,0)
End Sub
Sub RemoveEntry
With GlobalScope.Basiclibraries
If Not .IsLibraryLoaded("Tools") Then .LoadLibrary("Tools")
End With
oDialog1 = Tools.ModuleControls.LoadDialogLoadDialog("Standard", "Dialog1")
REM desaniciar la primer entrada del cuadru de llista
oDialog1Model = oDialog1.Model
oListBox = oDialog1.GetControl("ListBox1")
oListbox.removeitems(0,1)
End Sub