Source code for ooodev.adapter.util.replaceable_partial

from __future__ import annotations
from typing import TYPE_CHECKING
import uno  # pylint: disable=unused-import
from import XReplaceable
from ooodev.adapter.util.searchable_partial import SearchablePartial
from ooodev.adapter.util.replace_descriptor_comp import ReplaceDescriptorComp

    from ooodev.utils.type_var import UnoInterface
    from import XSearchDescriptor

[docs]class ReplaceablePartial(SearchablePartial): """ Partial Class XReplaceable. """ # pylint: disable=unused-argument
[docs] def __init__(self, component: XReplaceable, interface: UnoInterface | None = XReplaceable) -> None: """ Constructor Args: component (XReplaceable): UNO Component that implements ```` interface. interface (UnoInterface, optional): The interface to be validated. Defaults to ``XReplaceable``. """ SearchablePartial.__init__(self, component=component, interface=interface) self.__component = component
# region XReplaceable
[docs] def create_replace_descriptor(self) -> ReplaceDescriptorComp: """ Creates a descriptor which contains properties that specify a search in this container. Returns: ReplaceDescriptorComp: The replace descriptor. """ return ReplaceDescriptorComp(self.__component.createReplaceDescriptor()) # type: ignore
[docs] def set_replace_string(self, replace: str) -> None: """ Sets the string to replace the found string with. Args: replace (str): The string to replace the found string with. """ # not documented in the API # self.__component.setReplaceString(replace) # type: ignore
[docs] def replace_all(self, desc: XSearchDescriptor) -> int: """ Searches and replace all occurrences of whatever is specified. Returns: int: The number of replacements. """ return self.__component.replaceAll(desc)
# endregion XReplaceable