Source code for ooodev.adapter.container.child_partial

from __future__ import annotations
from typing import Any, TYPE_CHECKING
import uno

from import XChild

from ooodev.exceptions import ex as mEx
from ooodev.loader import lo as mLo

    from ooodev.utils.type_var import UnoInterface
    from import XInterface

[docs]class ChildPartial: """ Partial class for XChild. """ # pylint: disable=unused-argument
[docs] def __init__(self, component: XChild, interface: UnoInterface | None = XChild) -> None: """ Constructor Args: component (XChild): UNO Component that implements ```` interface. interface (UnoInterface, optional): The interface to be validated. Defaults to ``XChild``. """ def validate(comp: Any, obj_type: Any) -> None: if obj_type is None: return if not mLo.Lo.is_uno_interfaces(comp, obj_type): raise mEx.MissingInterfaceError(obj_type) validate(component, interface) self.__component = component
# region XChild
[docs] def get_parent(self) -> XInterface: """Returns the parent of the object.""" return self.__component.getParent()
[docs] def set_parent(self, parent: XInterface) -> None: """Sets the parent of the object.""" self.__component.setParent(parent)
# endregion XChild
[docs]def get_builder(component: Any) -> Any: """ Get the builder for the component. Args: component (Any): The component. Returns: DefaultBuilder: Builder instance. """ # pylint: disable=import-outside-toplevel from ooodev.utils.builder.default_builder import DefaultBuilder builder = DefaultBuilder(component) builder.add_import( name="ooodev.adapter.container.child_partial.ChildPartial", uno_name="", optional=False, init_kind=2, ) return builder