Class SpreadsheetDrawPages

Introduction

The SpreadsheetDrawPages class represents the collection of draw pages in a Calc document.

This class contains several python magic methods to make it behave like a collection.

Getting Number of Pages

To get the number of pages in a draw document, use the built in len() method:

>>> doc = CalcDoc(Calc.create_doc(loader))
>>> len(doc.draw_pages)
1

Getting a Draw Page

Get Draw Page by Index.

>>> doc = CalcDoc(Calc.create_doc(loader))
>>> doc.draw_pages[0]
<ooodev.calc.SpreadsheetDrawPage object at 0x7f8b1c0b4a90>

To get the last sheet in a document, use the -1 index:

>>> doc = CalcDoc(Calc.create_doc(loader))
>>> doc.draw_pages[-1]
<ooodev.calc.SpreadsheetDrawPage object at 0x7f8b1c0b4a90>

Alternatively, you can get a draw page direct from Class CalcSheet using the draw_page property.

Deleting a Draw Page

To delete a sheet, use the del keyword:

Delete by draw page index.

>>> doc = CalcDoc(Calc.create_doc(loader))
>>> # other code
>>> del doc.draw_pages[0]

Iterating over Draw Pages

To iterate over the draw pages in a document, use the for keyword:

>>> doc = CalcDoc(Calc.create_doc(loader))
>>> for draw_page in doc.draw_pages:
...     print(draw_page.name)

Class Declaration

class ooodev.calc.SpreadsheetDrawPages(owner, slides, lo_inst=None)[source]

Bases: LoInstPropsPartial, DrawPagesComp, QiPartial, ServicePartial, TheDictionaryPartial, CalcDocPropPartial, Generic[_T]

Class for managing Spreadsheet Draw Pages.

__delitem__(_item)[source]

Removes a draw page from the sheet.

Parameters:

_item (int | SpreadsheetDrawPage[_T] | XDrawPage) – Index, name, or object of the draw page.

Raises:

TypeError – If the item is not a supported type.

Return type:

None

__getitem__(idx)[source]

Gets the draw page at the specified index.

This is short hand for get_by_index().

Parameters:

idx (int) – The index of the draw page. Idx can be a negative value to get from the end of the document.

Returns:

The drawpage with the specified index.

Return type:

SpreadsheetDrawPage[_T]

See also

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

Constructor

Parameters:
  • owner (DrawDoc) – Owner Document

  • sheet (XDrawPages) – Document Pages.

  • slides (XDrawPages) –

  • lo_inst (LoInst | None) –

Return type:

None

__iter__()[source]

Iterates through the draw pages.

Returns:

current instance.

Return type:

SpreadsheetDrawPage[_T]

__len__()[source]

Gets the number of draw pages in the document.

Returns:

Number of draw pages in the document.

Return type:

int

__next__()[source]

Gets the next draw page.

Returns:

The next draw page.

Return type:

SpreadsheetDrawPage[_T]

delete_page(idx)[source]

Deletes a draw page

Parameters:

idx (int) – Index. Can be a negative value to delete from the end of the document. For example, -1 will delete the last slide.

Returns:

True on success; Otherwise, False

Return type:

bool

get_by_index(idx)[source]

Gets the element with the specified index.

Parameters:

idx (int) – The index of the element. Idx can be a negative value to get from the end of the document. For example, -1 will get the last slide.

Raises:

IndexError – If unable to find slide with index.

Returns:

The drawpage with the specified index.

Return type:

SpreadsheetDrawPage

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_services()

Gets service names for the instance.

Returns:

service names

Return type:

List[str]

has_elements()

Determines whether the container has elements.

Return type:

bool

insert_new_by_index(idx)[source]

Creates and inserts a new GenericDrawPage or MasterPage into this container.

Parameters:

idx (int) – The index at which the new page will be inserted. idx can be a negative value to insert from the end of the document. For example, -1 will insert at the end of the document.

Returns:

The new page.

Return type:

SpreadsheetDrawPage

insert_page(idx)[source]

Inserts a draw page at the given position in the document

Parameters:

idx (int) – Index, can be a negative value to insert from the end of the document. For example, -1 will insert at the end of the document.

Returns:

New slide that was inserted.

Return type:

SpreadsheetDrawPage

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(page)

Removes a DrawPage or MasterPage from this container.

Parameters:

page (Any) – The page to be removed.

Return type:

None

support_service(*service)

Gets if instance supports a service.

Parameters:

*service (str) – Variable length argument list of UNO namespace strings such as com.sun.star.configuration.GroupAccess

Returns:

True if instance supports any passed in service; Otherwise, False

Return type:

bool

property calc_doc: CalcDoc

Calc Document.

Return type:

CalcDoc

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

DrawPages Component

Return type:

DrawPages

property extra_data: TheDict

Extra Data Key Value Pair Dictionary.

Properties can be assigned properties and access like a dictionary and with dot notation.

Note

This is a dictionary object that can be used to store key value pairs. Generally speaking this data is not part of the object’s main data structure and is not saved with the object (document).

This property is used to store data that is not part of the object’s main data structure and can be used however the developer sees fit.

Return type:

TheDict

property lo_inst: LoInst

Lo Instance

Return type:

LoInst

property office_doc: OfficeDocumentT

Office Document.

Return type:

OfficeDocumentT

property owner: _T

Returns: _T: Draw or Impress document.

Return type:

TypeVar(_T, bound= ComponentT)