【问题标题】:How to get name & label of UnoCheckBoxControl?如何获取 Uno CheckBox 控件的名称和标签?
【发布时间】:2015-04-16 13:25:22
【问题描述】:

我想获取 LibreOffice Basic 对话框中包含的某些控件的名称和标签。

我可以在我的示例控件上调用getImplementationName()

我得到了这些:stardiv.Toolkit.UnoEditControlstardiv.Toolkit.UnoCheckBoxControlstardiv.Toolkit.UnoRadioButtonControl

我感兴趣的是这些控件的名称,在使用 GUI 构建它们时进行了参数化。

这是我的代码:

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

【问题讨论】:

    标签: libreoffice openoffice-basic libreoffice-basic


    【解决方案1】:

    您应该使用 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
    ...
    

    【讨论】:

      猜你喜欢
      • 2012-07-16
      • 2021-08-14
      • 1970-01-01
      • 2014-07-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多