Class ShapeCollection

class ooodev.draw.ShapeCollection(owner, collection=None, lo_inst=None)[source]

Bases: LoInstPropsPartial, OfficeDocumentPropPartial, ShapeCollectionComp, QiPartial

Represents a shape collection.

__init__(owner, collection=None, lo_inst=None)[source]

Constructor

Parameters:
  • owner (Any) – Usually DrawDoc or ImpressDoc Instance.

  • collection (Any, optional) – The collection of shapes. If None, a new empty collection will be created.

  • lo_inst (LoInst | None) –

Return type:

None

add(shape)

Adds a shape to the collection.

Parameters:

shape (XShape) – The shape to add.

Return type:

None

combine(combine_op)[source]

Combines the shapes in the collection.

Parameters:

combine_op (ShapeCombKind | int) – Combine operation. 0 - Merge, 1 - Intersect, 2 - Subtract, 3 - Combine.

Raises:

ShapeError – If error occurs.

Returns:

Combined shape.

Return type:

DrawShape

Note

Combining is done using Dispatch Command.

get_by_index(idx)

Gets the element at the specified index.

Parameters:

idx (int) – The Zero-based index of the element.

Returns:

The element at the specified index.

Return type:

Any

get_count()

Gets the number of elements contained in the container.

Returns:

The number of elements.

Return type:

int

get_element_type()

Gets the type of the elements contained in the container.

Returns:

The type of the elements. None means that it is a multi-type container and you cannot determine the exact types with this interface.

Return type:

Any

get_height()[source]

Returns the height of the collection.

Return type:

UnitMM

get_width()[source]

Returns the width of the collection.

Return type:

UnitMM

group()[source]

Groups the shapes in the collection.

Raises:

ShapeError – If error occurs.

Returns:

Grouped shape.

Return type:

GroupShape

has_elements()

Determines whether the container has elements.

Return type:

bool

qi(atype, raise_err=False)

Generic method that get an interface instance from an object.

Parameters:
  • atype (T) – Interface type to query obj for. Any Uno class that starts with ‘X’ such as XInterface

  • raise_err (bool, optional) – If True then raises MissingInterfaceError if result is None. Default False

Raises:

MissingInterfaceError – If ‘raise_err’ is ‘True’ and result is None

Returns:

instance of interface if supported; Otherwise, None

Return type:

T | None

Note

When raise_err=True return value will never be None.

remove(shape)

Removes a shape from the collection.

Parameters:

shape (XShape) – The shape to remove.

Return type:

None

select_all(obj)

Selects all shapes in the collection.

Parameters:

obj (Any) – The object to select shapes from. Can be XController or XModel or DrawDoc, ImpressDoc ( or any object that implements GuiPartial)

Return type:

None

property component: com.sun.star.drawing.ShapeCollection

ShapeCollection Component

Return type:

ShapeCollection

property lo_inst: LoInst

Lo Instance

Return type:

LoInst

property office_doc: OfficeDocumentT

Office Document.

Return type:

OfficeDocumentT

property owner: DrawPage[Any]

Returns the owner of this instance.

Return type:

DrawPage[Any]