0

I'd like to get the name and the label of some controls included in a dialog in LibreOffice Basic.

I can call getImplementationName() on my example controls.

I get these : stardiv.Toolkit.UnoEditControl, stardiv.Toolkit.UnoCheckBoxControl, stardiv.Toolkit.UnoRadioButtonControl.

What I'm interested in is the name of these controls, parametrized while building them with the GUI.

Here is my code :

Sub test()
    Dim Dlg As Object
    Dim Controls As Object
    Dim cControl As Object
    Dim I As Integer
    Dim A As String

    DialogLibraries.LoadLibrary("Standard")
    Dlg = CreateUnoDialog(DialogLibraries.Standard.BoiteDeDialogue1)

    Controls = Dlg.Controls

    I = 0
    A = ""
    For Each cControl In Controls
        I = I + 1
        A = A & cControl.getImplementationName()
        ' How to get back the name of cControl here ?
    Next cControl

    MsgBox "There is " & I & " controls in that form !" & A
End Sub
4

1 回答 1

2

您应该使用 XRAY(https://wiki.documentfoundation.org/Macros)之类的工具。有了它,您可以详细检查对象。因此,您会发现每个包含名称的控件都有一个模型 (com.sun.star.awt.XControlModel)。

...
    For Each cControl In Controls
        I = I + 1
        'xray cControl
        A = A & cControl.getModel().Name ' To get back the name of cControl.
    Next cControl
...
于 2015-04-18T16:28:36.530 回答