Source code for ooodev.adapter.util.refreshable_partial

from __future__ import annotations
from typing import Any, TYPE_CHECKING
import uno
from import XRefreshable
from ooodev.exceptions import ex as mEx
from ooodev.loader import lo as mLo

    from ooodev.utils.type_var import UnoInterface
    from import XRefreshListener

[docs]class RefreshablePartial: """ Partial Class XRefreshable. """ # pylint: disable=unused-argument
[docs] def __init__(self, component: XRefreshable, interface: UnoInterface | None = XRefreshable) -> None: """ Constructor Args: component (XRefreshable): UNO Component that implements ```` interface. interface (UnoInterface, optional): The interface to be validated. Defaults to ``XRefreshable``. """ 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 XRefreshable
[docs] def add_refresh_listener(self, listener: XRefreshListener) -> None: """ Adds the specified listener to receive the event \"refreshed.\" """ self.__component.addRefreshListener(listener)
[docs] def refresh(self) -> None: """ refreshes the data of the object from the connected data source. """ self.__component.refresh()
[docs] def remove_refresh_listener(self, listener: XRefreshListener) -> None: """ removes the specified listener. """ self.__component.removeRefreshListener(listener)
# endregion XRefreshable
[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.util.refreshable_partial.RefreshablePartial", uno_name="", optional=False, init_kind=2, ) return builder