Wie kann ich es ändern, um stattdessen nur für die Formeln in der aktuellen Auswahl das gleiche Ergebnis zu erhalten? Ich konnte alle Formen auf einer Seite abrufen, aber wie kann ich feststellen, ob eine bestimmte Form innerhalb der aktuellen Auswahl liegt?
Ich verwende LibreOffice 24.2.7.2 unter Linux Mint 22.2.
Code: Select all
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)
Mobile version