【问题标题】:LibreOffice how to recup the current elementLibreOffice 如何恢复当前元素
【发布时间】:2020-01-26 19:59:10
【问题描述】:

我想检索 LibreOffice Impress 中的当前元素以应用更改。

例如,我正在尝试检索此形状以使用宏更改其中的文本。

我尝试使用 X 射线工具查找信息,但没有成功。

【问题讨论】:

    标签: libreoffice libreoffice-basic openoffice-impress


    【解决方案1】:

    获取当前选中的形状:

    oSel = ThisComponent.getCurrentController.getSelection()
    oShape = oSel.getByIndex(0)
    Print oShape.getString()
    

    要遍历幻灯片中的所有形状,请从 ThisComponent.getDrawPages() 开始,然后使用 XrayTool

    您还可能会发现以下 python 代码的 sn-p 很有帮助:

    def iterate_draw_shapes():
        oDrawPage = oDrawPages.getByIndex(1)
        for oShape in oDrawPage:
            if oShape.supportsService("com.sun.star.drawing.TextShape"):
                oTexts = oShape.createEnumeration()
                while oTexts.hasMoreElements():
                    oText = oTexts.nextElement()
                    oTextPortions = oText.createEnumeration()
                    while oTextPortions.hasMoreElements():
                        oTextPortion = oTextPortions.nextElement()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-02-06
      • 1970-01-01
      • 1970-01-01
      • 2015-11-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多