Как я могу изменить его, чтобы вместо этого получать тот же результат только для формул в текущем выборе? Мне удалось получить все фигуры на странице, но как узнать, находится ли данная фигура в текущем выделении?
Я использую LibreOffice 24.2.7.2 в Linux Mint 22.2.
Код: Выделить всё
import uno
def explore_objects_in_selection():
doc = XSCRIPTCONTEXT.getDocument()
selection = doc.getCurrentSelection()
# Useless variable in this code for now, equivalent to
#selection = doc.CurrentController.getSelection()
shapes = []
for draw_page in doc.getDrawPages():
# Maybe testing here if shape is in selection, but how?
for shape in draw_page:
shapes.append(shape)
for shape in shapes:
#if hasattr(shape, 'ShapeType'):
# In my doc, shape.ShapeType or shape.getShapeType()
# is 'FrameShape'
assert hasattr(shape.getEmbeddedObject(), 'Formula')
# Inner code of each formula in my doc
print(shape.getEmbeddedObject().Formula)
Подробнее здесь: https://stackoverflow.com/questions/798 ... writer-doc
Мобильная версия