Source code for ooodev.draw.master_draw_page

from __future__ import annotations
from typing import TYPE_CHECKING, TypeVar, Generic
import uno


from ooodev.adapter.beans.property_change_implement import PropertyChangeImplement
from ooodev.adapter.beans.vetoable_change_implement import VetoableChangeImplement
from ooodev.adapter.drawing.master_page_comp import MasterPageComp
from ooodev.draw.partial.draw_page_partial import DrawPagePartial
from ooodev.format.inner.style_partial import StylePartial
from ooodev.loader import lo as mLo
from ooodev.loader.inst.lo_inst import LoInst
from ooodev.office import draw as mDraw
from ooodev.office.partial.office_document_prop_partial import OfficeDocumentPropPartial
from ooodev.utils.partial.lo_inst_props_partial import LoInstPropsPartial
from ooodev.utils.partial.prop_partial import PropPartial
from ooodev.utils.partial.qi_partial import QiPartial
from ooodev.utils.partial.service_partial import ServicePartial

if TYPE_CHECKING:
    from com.sun.star.drawing import XDrawPage
    from ooodev.proto.component_proto import ComponentT

_T = TypeVar("_T", bound="ComponentT")


[docs]class MasterDrawPage( DrawPagePartial[_T], LoInstPropsPartial, OfficeDocumentPropPartial, MasterPageComp, PropertyChangeImplement, VetoableChangeImplement, ServicePartial, QiPartial, PropPartial, StylePartial, Generic[_T], ): """Represents a draw page.""" # Draw page does implement XDrawPage, but it show in the API of DrawPage Service.
[docs] def __init__(self, owner: _T, component: XDrawPage, lo_inst: LoInst | None = None) -> None: if lo_inst is None: lo_inst = mLo.Lo.current_lo self._owner = owner LoInstPropsPartial.__init__(self, lo_inst=lo_inst) if not isinstance(owner, OfficeDocumentPropPartial): raise ValueError("owner must be an instance of OfficeDocumentPropPartial") OfficeDocumentPropPartial.__init__(self, owner.office_doc) DrawPagePartial.__init__(self, owner=self, component=component, lo_inst=self.lo_inst) MasterPageComp.__init__(self, component) # pylint: disable=no-member generic_args = self._ComponentBase__get_generic_args() # type: ignore PropertyChangeImplement.__init__(self, component=self.component, trigger_args=generic_args) VetoableChangeImplement.__init__(self, component=self.component, trigger_args=generic_args) ServicePartial.__init__(self, component=component, lo_inst=self.lo_inst) QiPartial.__init__(self, component=component, lo_inst=self.lo_inst) PropPartial.__init__(self, component=component, lo_inst=self.lo_inst) StylePartial.__init__(self, component=component)
[docs] def get_master_page(self) -> MasterDrawPage[_T]: """ Gets master page Raises: DrawError: If error occurs. Returns: MasterDrawPage: Master Page. """ page = mDraw.Draw.get_master_page(self.component) # type: ignore return MasterDrawPage(owner=self._owner, component=page, lo_inst=self.lo_inst)
[docs] def get_notes_page(self) -> MasterDrawPage[_T]: """ Gets the notes page of a slide. Each draw page has a notes page. Raises: DrawPageMissingError: If notes page is ``None``. DrawPageError: If any other error occurs. Returns: MasterDrawPage: Notes Page. See Also: :py:meth:`~.draw.Draw.get_notes_page_by_index` """ page = mDraw.Draw.get_notes_page(self.component) # type: ignore return MasterDrawPage(owner=self._owner, component=page, lo_inst=self.lo_inst)
# region Properties @property def owner(self) -> _T: """Component Owner""" return self._owner
# endregion Properties