Source code for ooodev.adapter.ui.context_menu_interception_partial
from __future__ import annotations
from typing import Any, TYPE_CHECKING
from com.sun.star.ui import XContextMenuInterception
from ooodev.exceptions import ex as mEx
from ooodev.loader import lo as mLo
if TYPE_CHECKING:
from com.sun.star.ui import XContextMenuInterceptor
from ooodev.utils.type_var import UnoInterface
# https://wiki.documentfoundation.org/Framework/Tutorial/Context_Menu_Interception
[docs]class ContextMenuInterceptionPartial:
"""
Partial Class for XContextMenuInterception.
.. versionadded:: 0.20.0
"""
[docs] def __init__(
self, component: XContextMenuInterception, interface: UnoInterface | None = XContextMenuInterception
) -> None:
"""
Constructor
Args:
component (XContextMenuInterception): UNO Component that implements ``com.sun.star.ui.XContextMenuInterception``.
interface (UnoInterface, optional): The interface to be validated. Defaults to ``XContextMenuInterception``.
"""
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 XContextMenuInterception
# endregion XContextMenuInterception