Source code for ooodev.adapter.container.name_replace_partial

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

from import XNameReplace
from ooodev.adapter.container.name_access_partial import NameAccessPartial
from ooodev.utils.builder.default_builder import DefaultBuilder

    from ooodev.utils.type_var import UnoInterface

T = TypeVar("T")

[docs]class NameReplacePartial(NameAccessPartial[T], Generic[T]): """ Partial Class for XNameReplace. """ # pylint: disable=unused-argument
[docs] def __init__(self, component: XNameReplace, interface: UnoInterface | None = XNameReplace) -> None: """ Constructor Args: component (XNameReplace): UNO Component that implements ````. interface (UnoInterface, optional): The interface to be validated. Defaults to ``XNameReplace``. """ NameAccessPartial.__init__(self, component, interface) self.__component = component
# region XNameReplace
[docs] def replace_by_name(self, name: str, element: T) -> None: """Replaces the element with the specified name. Args: name (str): The name of the element to be replaced. element (T): The new element. """ self.__component.replaceByName(name, element)
# endregion XNameReplace
[docs]def get_builder(component: Any) -> DefaultBuilder: """ Get the builder for the component. Args: component (Any): The component. Returns: DefaultBuilder: Builder instance. """ builder = DefaultBuilder(component) builder.set_omit("") builder.set_omit("") builder.auto_add_interface("") return builder