我想检索 LibreOffice Impress 中的当前元素以对其应用更改。
例如,我正在尝试检索此形状以使用宏更改其中的文本。
我试图用 X 射线工具查找信息,但没有成功。
要获取当前选定的形状:
oSel = ThisComponent.getCurrentController.getSelection()
oShape = oSel.getByIndex(0)
Print oShape.getString()
要遍历幻灯片中的所有形状,请从XrayToolThisComponent.getDrawPages()
开始,然后使用。
您可能还会发现以下 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()