本文介绍了LibreOffice如何恢复当前元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在LibreOffice Impress中检索当前元素以对其进行更改.
I want to retrieve the current element in LibreOffice Impress to apply changes to it.
例如,我正在尝试检索此形状以使用宏更改其中的文本.
For example, I'm trying to retrieve this shape to change the text in it with macros.
我试图用X射线工具查找信息,但没有成功.
I tried to find information with the X-ray tool but without success.
推荐答案
要获取当前选择的形状:
To get the currently selected shape:
oSel = ThisComponent.getCurrentController.getSelection()
oShape = oSel.getByIndex(0)
Print oShape.getString()
要遍历幻灯片中的所有形状,请从 ThisComponent.getDrawPages()开始,然后使用 XrayTool .
To iterate through all shapes in the slide, start with ThisComponent.getDrawPages()
and then use XrayTool.
您可能还会发现以下python代码段很有帮助:
You may also find the following snippet of python code helpful:
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()
这篇关于LibreOffice如何恢复当前元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!