LibreOffice 如何恢复当前元素

LibreOffice how to recup the current element

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

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

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

获取当前选中的形状:

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

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

您可能还会发现以下 python 代码片段很有帮助:

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()