Class DefaultBuilder
- class ooodev.utils.builder.default_builder.DefaultBuilder(component, lo_inst=None)[source]
- Parameters:
component (Any) –
lo_inst (LoInst | None) –
- __init__(component, lo_inst=None)[source]
Constructor.
- Parameters:
lo_inst (LoInst, optional) – Lo instance.
component (Any) –
- add_build_arg(*args)[source]
Add one or more import builder to the instance.
- Parameters:
args (BuildImportArg) – One or more BuildImportArg instance.
- Return type:
None
- add_class_property(name, value)[source]
Set a property.
- Parameters:
name (str) – Property name.
value (Any) – Property value.
- Return type:
None
- add_event(module_name, class_name, *, callback_name='on_lazy_cb', uno_name='', optional=False, check_kind=CheckKind.INTERFACE)[source]
Add an event to the builder.
- Parameters:
module_name (str) – Ooodev name of the module such as
ooodev.adapter.util.refresh_events
.class_name (str) – Ooodev class name such as
RefreshEvents
.callback_name (str) – Callback name such as
on_lazy_cb
.uno_name (str, optional) – UNO Name. such as
com.sun.star.container.XIndexAccess
.optional (bool, optional) – Specifies if the import is optional. Defaults to
False
.check_kind (CheckKind, int, optional) – Check Kind. Defaults to
CheckKind.INTERFACE
.
- Returns:
_description_
- Return type:
Note
check_kind
can be aCheckKind
or anint
:NONE = 0
SERVICE = 1
INTERFACE = 2
SERVICE_ALL = 3
INTERFACE_ALL = 4
SERVICE_ONLY = 5
INTERFACE_ONLY = 6
- add_event_arg(*args)[source]
Add one or more import event to the instance.
- Parameters:
args (BuildEventArg) – One or more BuildImportArg instance.
- Return type:
None
- add_import(name, *, uno_name='', optional=False, init_kind=InitKind.COMPONENT_INTERFACE, check_kind=CheckKind.NONE)[source]
Add an import to the builder.
- Parameters:
name (str) – Ooodev name such as
ooodev.adapter.container.index_access_partial.IndexAccessPartial
.uno_name (str, optional) – UNO Name. such as
com.sun.star.container.XIndexAccess
.optional (bool, optional) – Specifies if the import is optional. Defaults to
False
.init_kind (InitKind, int, optional) – Init Option. Defaults to
InitKind.COMPONENT_INTERFACE
.check_kind (CheckKind, int, optional) – Check Kind. Defaults to
CheckKind.NONE
.
- Returns:
BuildImportArg instance.
- Return type:
Note
init_kind
can be anInitKind
or anint
:NONE = 0
COMPONENT = 1
COMPONENT_INTERFACE = 2
check_kind
can be aCheckKind
or anint
:NONE = 0
SERVICE = 1
INTERFACE = 2
SERVICE_ALL = 3
INTERFACE_ALL = 4
SERVICE_ONLY = 5
INTERFACE_ONLY = 6
- add_ooodev_builder(mod_name, *, func_name='get_builder', make_optional=False)[source]
Add a builder from an ooodev name.
- Parameters:
name (str) – Ooodev name such as
ooodev.adapter.container.index_access_partial.IndexAccessPartial
.optional (bool, optional) – Specifies if the import is optional. Defaults to
False
.make_optional (bool, optional) – Specifies if the import is optional. Defaults to
False
.mod_name (str) –
func_name (str) –
- Return type:
None
- auto_add_interface(uno_name, optional=True, check_kind=CheckKind.INTERFACE)[source]
Add an import from a UNO name.
- Parameters:
uno_name (str) – UNO Name. such as
com.sun.star.container.XIndexAccess
.optional (bool, optional) – Specifies if the import is optional. Defaults to
True
.check_kind (CheckKind, int, optional) – Check Kind. Defaults to
CheckKind.INTERFACE
.
- Return type:
None
- auto_interface()[source]
Automatically add interfaces to the builder based on the component types.
- Return type:
None
- build_class(name, base_class, init_kind=InitKind.COMPONENT)[source]
Build the import.
- Parameters:
name (str) – Class Name. This can just be a class name or a full import name including the class. When a full import name is passed then the last part is used as the class name and parts before are used as the module name.
init_kind (InitKind, int, optional) – Init Option. Defaults to
InitKind.COMPONENT
.base_class (Type[Any], optional) – Base Class. Defaults to
BuilderBase
.
- Returns:
Class instance
- Return type:
Any
Note
init_kind
can be anInitKind
or anint
:NONE = 0
COMPONENT = 1
COMPONENT_INTERFACE = 2
CALLBACK = 3
LO_INST = 4
- get_builders()[source]
Get the list of BuildImportArg.
- Return type:
List
[BuildImportArg
]
- get_class_property(name, default=None)[source]
Get a property.
- Parameters:
name (str) – Property name.
default (Any, optional) – Default value if the property is not found. Defaults to
None
.
- Returns:
Property value.
- Return type:
Any
- get_class_type(name, base_class, set_mod_name=True)[source]
Build the import.
- Parameters:
name (str) – Class Name. This can just be a class name or a full import name including the class. When a full import name is passed then the last part is used as the class name and parts before are used as the module name.
init_kind (InitKind, int, optional) – Init Option. Defaults to
InitKind.COMPONENT
.base_class (Type[Any], optional) – Base Class. Defaults to
BuilderBase
.set_mod_name (bool, optional) – Set the module name. Defaults to
True
.
- Returns:
Class instance
- Return type:
Any
Note
init_kind
can be anInitKind
or anint
:NONE = 0
COMPONENT = 1
COMPONENT_INTERFACE = 2
CALLBACK = 3
LO_INST = 4
- get_events()[source]
Get the list of BuildImportArg.
- Return type:
List
[BuildEventArg
]
- get_import_names()[source]
Get the list of import names that have been added to the current instance.
- Return type:
List
[str
]
- has_import(name)[source]
Check if the builder has an import.
- Parameters:
name (str) – Ooodev or UNO name such as
ooodev.adapter.container.index_access_partial.IndexAccessPartial
orcom.sun.star.awt.XWindow
.- Return type:
bool
- has_omit(name)[source]
Check if the builder has an omit.
- Parameters:
name (str) – Ooodev or UNO name such as
ooodev.adapter.container.index_access_partial.IndexAccessPartial
orcom.sun.star.awt.XWindow
.- Return type:
bool
- has_type(t)[source]
Gets if the builder has a type in the partial or interface bases.
This check does not check for events.
- Return type:
bool
- Parameters:
t (Type[Any]) –
- init_class_properties(clz)[source]
Initialize the class properties.
- Return type:
None
- Parameters:
clz (Type[Any]) –
- init_classes(instance)[source]
Initialize the classes including the events.
- Return type:
None
- Parameters:
instance (Any) –
- insert_build_arg(idx, *args)[source]
Insert one or more import builder to the instance.
- Parameters:
idx (int) – The index to insert the import.
args (BuildImportArg) – One or more BuildImportArg instance.
- Return type:
None
- insert_event(idx, module_name, class_name, *, callback_name='on_lazy_cb', uno_name='', optional=False, check_kind=CheckKind.INTERFACE)[source]
Insert an event into the builder.
- Parameters:
idx (int) – The index to insert the import.
module_name (str) – Ooodev name of the module such as
ooodev.adapter.util.refresh_events
.class_name (str) – Ooodev class name such as
RefreshEvents
.callback_name (str) – Callback name such as
on_lazy_cb
.uno_name (str, optional) – UNO Name. such as
com.sun.star.container.XIndexAccess
.optional (bool, optional) – Specifies if the import is optional. Defaults to
False
.check_kind (CheckKind, int, optional) – Check Kind. Defaults to
CheckKind.INTERFACE
.
- Returns:
_description_
- Return type:
- insert_event_arg(idx, *args)[source]
Insert one or more import event to the instance.
- Parameters:
idx (int) – The index to insert the import.
args (BuildEventArg) – One or more BuildImportArg instance.
- Return type:
None
- insert_import(idx, name, *, uno_name='', optional=False, init_kind=InitKind.COMPONENT_INTERFACE, check_kind=CheckKind.NONE)[source]
Insert an import into the builder.
- Parameters:
idx (int) – The index to insert the import.
name (str) – Ooodev name such as
ooodev.adapter.container.index_access_partial.IndexAccessPartial
.uno_name (str, optional) – UNO Name. such as
com.sun.star.container.XIndexAccess
.optional (bool, optional) – Specifies if the import is optional. Defaults to
False
.init_kind (InitKind, int, optional) – Init Option. Defaults to
InitKind.COMPONENT_INTERFACE
.check_kind (CheckKind, int, optional) – Check Kind. Defaults to
CheckKind.NONE
.
- Returns:
BuildImportArg instance.
- Return type:
- merge(instance, make_optional=None, check_kind=None)[source]
Add the builders from another instance.
- Parameters:
instance (DefaultBuilder) – The instance to add the builders from.
make_optional (bool, None, optional) – Specifies if the import is optional. A value of None means do not change. Defaults to
None
.check_kind (CheckKind, int, None, optional) – Check Kind. A value of None means do not change. Defaults to
None
.
- Return type:
None
- pop_type(t)[source]
Removes a type from the partial or interface bases.
This will not remove events.
- Return type:
None
- Parameters:
t (Type[Any]) –
- remove_class_property(name)[source]
Remove a property.
- Parameters:
name (str) – Property name.
- Returns:
True if the property was removed; otherwise, False.
- Return type:
bool
- remove_event(module_name)[source]
Remove an event from the builder.
- Parameters:
module_name (str) – Ooodev name such as
ooodev.adapter.util.refresh_events.RefreshEvents
.- Return type:
None
- remove_import(name)[source]
Remove an import from the builder.
- Parameters:
name (str) – Ooodev name such as
ooodev.adapter.container.index_access_partial.IndexAccessPartial
.- Return type:
None
- set_omit(*names)[source]
Set the names to omit.
This is useful with the base class already implements the class.
- Parameters:
names (str) – The CASE Sensitive names to omit.
- Return type:
None
Note
Names can be the name of the
ooodev
full import name or the UNO name. Valid names such asooodev.adapter.container.name_access_partial.NameAccessPartial
orcom.sun.star.container.XNameAccess
.- Return type:
None
- Parameters:
names (str) –
- subscribe_class_create(cb)[source]
Subscribe to the class create event.
- Parameters:
cb (EventCallback) – Callback function.
- Return type:
None
Note
If the class init kind is
InitKind.CALLBACK
then an event is triggered. The event data is a dictionary with keysclass
,kind
. After the event is triggered, if the event data has keysargs
andkwargs
then they will be passed to the class constructor.- Return type:
None
- Parameters:
cb (Any) –
- subscribe_class_event_init(cb)[source]
Subscribe to the class event init event.
- Parameters:
cb (EventCallback) – Callback function.
- Return type:
None
Note
The event data is a dictionary with keys
triggers
,data
. After the event is triggered, if the event datatriggers
has key value pairs then they are passed to aGenericArgs
and passed to the event astrigger_args
.The default
event_data["triggers"]
contains keysrc_comp
(source component) andsrc_instance
(current event class instance).The default
event_data["data"]
contains keyclass
(event class type),instance
(current event class instance).- Return type:
None
- Parameters:
cb (Any) –
- subscribe_class_init(cb)[source]
Subscribe to the class init event.
- Parameters:
cb (EventCallback) – Callback function.
- Return type:
None
Note
If the class init kind is
InitKind.CALLBACK
callbacks subscribed here will be called. The event data is a dictionary with keysclass
,kind
. After the event is triggered, if the event data has keysargs
andkwargs
then they will be passed to the class constructor.- Return type:
None
- Parameters:
cb (Any) –
- subscribe_class_properties_init(cb)[source]
Subscribe to the class init properties event.
- Parameters:
cb (EventCallback) – Callback function.
- Return type:
None
Note
This event is triggered for each class property that is set. The event data is a dictionary with keys
name
,value
. After the event is triggered, if the event dataname
orvalue
is set then they will be used.- Return type:
None
- Parameters:
cb (Any) –
- property component: Any
- Return type:
Any
- property omits: Set[str]
- Return type:
Set
[str
]
- property partial_excludes: Set[str]
This is the set of suffixes that are excluded from having
_partial
append to the class name.These name should be in lower case such as
_listener
and_events
.- Return type:
Set
[str
]