Class Info

class ooodev.utils.info.Info[source]
property language

Static read-only property

Gets the Current Language of the LibreOffice Instance

Returns:

First two chars of language in lower case such as en-US

Return type:

str

property version

Static read-only property

Gets the running LibreOffice version

Returns:

version as string such as "7.3.4.2"

Return type:

str

property version_info

Static read-only property

Gets the running LibreOffice version

Returns:

version as tuple of integers such as (7, 3, 4, 2)

Return type:

tuple

class Filter(value)[source]

Every filter inside LibreOffice is specified by the properties of this enum.

ALIEN = 64

The filter may lose some information upon saving.

DEFAULT = 256

This is the “best” filter for the document type it works on that is guaranteed not so lose any data on export. By default this filter will be used or suggested for every storing process unless the user has chosen a different default filter in the options dialog.

EXPORT = 2

The filter supports the service com.sun.star.document.ExportFilter. It will be shown in the dialog “File-Export”. If the filter also has the “IMPORT” flag set, it will be shown in the dialog “File-Save”. This makes sure that a format that a user chooses in the save dialog can be loaded again. The same is not guaranteed for a format chosen in “File-Export”.

IMPORT = 1

This filter is used only for internal purposes and so can be used only in API calls. Users won’t see it ever.

INTERNAL = 8

This filter is used only for internal purposes and so can be used only in API calls. Users won’t see it ever.

NOTINCHOOSER = 8192

This filter will not be shown in the dialog box for choosing a filter in case Apache OpenOffice was not able to detect one

NOTINFILEDIALOG = 4096

This filter will not be shown in the file dialog’s filter list

OWN = 32

The filter is a native Apache OpenOffice format (ODF or otherwise).

PREFERRED = 268435456

The filter is preferred in case of multiple filters for the same file type exist in the configuration

READONLY = 65536

All documents imported by this filter will automatically be in read-only state

SUPPORTSSELECTION = 1024

Filter can export only the selected part of a document. This information enables Apache OpenOffice to enable a corresponding check box in the “File-Export” dialog.

TEMPLATE = 4

Filter denotes a template filter (means, by default all documents opened by it become an “untitled” one)

TEMPLATEPATH = 16

Must always be set together with “TEMPLATE” to make this feature flag work; soon becoming deprecated

THIRDPARTYFILTER = 524288

The filter is a UNO component filter, as opposed to the internal C++ filters. This is an artifact that will vanish over time.

AKA: 3RDPARTYFILTER

class RegPropKind(value)[source]

An enumeration.

PROPERTY = 1
VALUE = 2
classmethod create_configuration_view(path)[source]

Create Configuration View.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:

path (str) – path

Raises:

ConfigError – if unable to create configuration view

Returns:

Property Set

Return type:

XHierarchicalPropertySet

classmethod doc_type_service(doc)[source]

Prints service type to console and return service type.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

doc (Any) – office document

Returns:

Service type

Return type:

Lo.Service

static get_available_services(obj)[source]

Gets available services for obj.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

obj (object) – obj that implements XMultiServiceFactory interface.

Raises:

Exception – If unable to get services.

Returns:

List of services.

Return type:

List[str]

Changed in version 0.34.0: Now also supports XServiceInfo

classmethod get_config(node_str)[source]
classmethod get_config(node_str, node_path: str)
classmethod get_config(node_str, node_path=None)

Get config.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:
  • node_str (str) – node string

  • node_path (str) – node_path

Raises:

ConfigError – if unable to get config

Returns:

config

Return type:

object

Example

props = mLo.Lo.qi(
    XPropertySet,
    mInfo.Info.get_config(node_str="Other", node_path="/org.openoffice.Office.Writer/Layout/"),
)
ts_val = props.getPropertyValue("TabStop") # int val
static get_config_props(node_path)[source]

Get config properties.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:

node_path (str) – nod path

Raises:

PropertyError – if unable to get get property set

Returns:

Property set

Return type:

XPropertySet

classmethod get_dirs(setting)[source]

Gets dirs paths from settings.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:

setting (str) – setting

Returns:

List of paths

Return type:

List[str]

Changed in version 0.11.14: - Added support for expanding macros.

static get_doc_type(fnm)[source]

Gets doc type from file path.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:

fnm (PathOrStr) – File Path

Raises:

ValueError – if Unable to get doc type

Returns:

Doc Type.

Return type:

str

static get_ext(fnm)[source]

Gets file extension without the ..

Method is Lo Instance Safe for use with multiple documents.

Parameters:

fnm (PathOrStr) – file path

Raises:

ValueError – If fnm is empty string

Returns:

Extension if Found; Otherwise, None

Return type:

str | None

classmethod get_extension_info(id)[source]

Gets info for an installed extension in LibreOffice.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:

id (str) – Extension id.

Returns:

Extension info.

Return type:

Tuple[str, …]

classmethod get_extension_loc(id)[source]

Gets location for an installed extension in LibreOffice.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:

id (str) – Extension id.

Returns:

Extension location on success; Otherwise, None.

Return type:

str | None

static get_filter_names()[source]

Gets filter names.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Returns:

Filter names.

Return type:

Tuple[str, …]

static get_filter_props(filter_nm)[source]

Gets filter properties.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:

filter_nm (str) – Filter Name.

Returns:

List of PropertyValue.

Return type:

List[PropertyValue]

classmethod get_font_descriptor(name, style)[source]

Gets font descriptor for a font name with a font style such as Bold Italic.

This method is useful for obtaining a font descriptor for a specific font name and style, which can be used for various purposes such as setting the font of text in a document or application.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:
  • name (str) – Font Name

  • style (str) – Font Style

Returns:

Instance if found; Otherwise None.

Return type:

FontDescriptor

New in version 0.9.0.

static get_font_general_name()[source]

Gets a general font such as Times New Roman (windows) or Liberation Serif.

Method is Lo Instance Safe for use with multiple documents.

Returns:

Font Name

Return type:

str

See also

Fonts on Document Foundation’s wiki

static get_font_mono_name()[source]

Gets a general font such as Courier New (windows) or Liberation Mono.

Method is Lo Instance Safe for use with multiple documents.

Returns:

Font Name

Return type:

str

See also

Fonts on Document Foundation’s wiki

classmethod get_font_names()[source]

Gets font names.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Returns:

Font names

Return type:

List[str]

static get_fonts()[source]

Gets fonts.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Returns:

Font Descriptors

Return type:

Tuple[FontDescriptor, …]

Get the first directory that contain the Gallery database and multimedia files.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Raises:

ValueError if unable to obtain gallery dir.

Returns:

Gallery Dir

Return type:

Path

static get_identifier(obj)[source]

Gets identifier name such as com.sun.star.text.TextDocument.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

obj (object) – uno object that implements XModule

Raises:

ValueError – if unable to get identifier name

Returns:

identifier name

Return type:

str

static get_implementation_name(obj)[source]

Gets implementation name such as com.sun.star.comp.deployment.PackageInformationProvider.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

obj (object) – uno object that implements XServiceInfo

Raises:

ValueError – if unable to get implementation name

Returns:

implementation name

Return type:

str

static get_interface_types(target)[source]

Get interface types.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

target (object) – object that implements XTypeProvider interface.

Raises:

Exception – If unable to get services.

Returns:

Tuple of interfaces.

Return type:

Tuple[object, …]

classmethod get_interfaces(target: object)[source]
classmethod get_interfaces(type_provider: com.sun.star.lang.XTypeProvider)
classmethod get_interfaces(*args, **kwargs)

Gets interfaces.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • target – (object): object that implements XTypeProvider.

  • type_provider (XTypeProvider) – type provider.

Raises:

Exception – If unable to get interfaces.

Returns:

List of interfaces.

Return type:

List[str]

static get_methods(interface_name)[source]

Get Interface Methods.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:

interface_name (str) – name of interface.

Returns:

List of methods

Return type:

List[str]

static get_methods_obj(obj, property_concept=None)[source]

Get Methods of an object such as a doc.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • obj (object) – Object to get methods of.

  • property_concept (PropertyConceptEnum | None, optional) – Type of method to get. Defaults to PropertyConceptEnum.ALL.

Raises:

Exception – If unable to get Methods

Returns:

List of method names found for obj

Return type:

List[str]

static get_mime_type(fnm)[source]

Get mime type for a file path.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

fnm (PathOrStr) – file path

Returns:

Mime type of file if found. Defaults to ‘application/octet-stream’

Return type:

str

static get_name(fnm)[source]

Gets the file’s name from the supplied string minus the extension.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

fnm (PathOrStr) – File path

Raises:
  • ValueError – If fnm is empty string

  • ValueError – If fnm is not a file

Returns:

File name minus the extension

Return type:

str

classmethod get_office_dir()[source]

Gets file path to the office dir. e.g. "C:\Program Files (x86)\LibreOffice 7".

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Raises:

ValueError – if unable to obtain office path.

Returns:

Path as string

Return type:

str

classmethod get_office_theme()[source]

Gets the Current LibreOffice Theme.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Returns:

LibreOffice Theme Name such as LibreOffice Dark

Return type:

str

Note

Older Version of LibreOffice will return empty string.

New in version 0.9.1.

classmethod get_page_style_props(doc)[source]

Gets style properties for page styles.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

doc (Any) – office docs.

Raises:

MissingInterfaceError – if a required interface cannot be obtained.

Returns:

property set.

Return type:

XPropertySet

classmethod get_paragraph_style_props(doc)[source]

Gets style properties for paragraph styles.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

doc (Any) – office docs.

Raises:

MissingInterfaceError – if a required interface cannot be obtained.

Returns:

property set.

Return type:

XPropertySet

static get_paths(setting)[source]

Gets access to LO’s predefined paths.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:

setting (str | InfoPathsKind) – property value

Raises:

ValueError – if unable to get paths

Returns:

paths

Return type:

str

Note

There are two different groups of properties. One group stores only a single path and the other group stores two or more paths - separated by a semicolon.

Some setting values (as listed in the OpenOffice docs for PathSettings) are found in InfoPathsKind

static get_pip()[source]

Gets Package Information Provider.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Raises:

MissingInterfaceError – if unable to obtain XPackageInformationProvider interface.

Returns:

Package Information Provider.

Return type:

XPackageInformationProvider

classmethod get_reg_item_prop(item)[source]
classmethod get_reg_item_prop(item, prop)
classmethod get_reg_item_prop(item, prop, node: str)
classmethod get_reg_item_prop(item, *, kind: ooodev.utils.info.Info.RegPropKind)
classmethod get_reg_item_prop(item, *, kind: ooodev.utils.info.Info.RegPropKind, idx: int)
classmethod get_reg_item_prop(item, prop, *, idx: int)
classmethod get_reg_item_prop(item, prop, node: str, kind)
classmethod get_reg_item_prop(item, prop='', node=None, kind=RegPropKind.PROPERTY, idx=0)

Gets value from registrymodifications.xcu.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • item (str) – item name

  • prop (str) – property value

  • node (str) – node

  • kind (Info.RegPropKind) – property or value

  • idx (int) – (int): index of value to return

Raises:

ValueError – if unable to get value

Returns:

value from registrymodifications.xcu. e.g. Writer/MailMergeWizard, None, MailAddress

Return type:

str

Note

Often is it not necessary to get value from registry. Which is not available in macro mode.

Often the configuration option can be gotten via get_config().

See also

get_config()

classmethod get_reg_mods_path()[source]

Get registered modifications path.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Returns:

registered modifications path

Return type:

str

classmethod get_service_names()[source]
classmethod get_service_names(service_name: str)
classmethod get_service_names(service_name=None)

Gets service names.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:

service_name (str) – service name.

Raises:

Exception – If error occurs.

Returns:

List of service names.

Return type:

List[str]

static get_services(obj)[source]

Gets service names.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

obj (object) – obj that implements XServiceInfo

Returns:

service names

Return type:

List[str]

classmethod get_style_container(doc, family_style_name)[source]

Gets style container of document for a family of styles.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • doc (Any) – office document

  • family_style_name (str) – Family style name

Raises:

MissingInterfaceError – if unable to obtain XNameContainer interface

Returns:

Style Family container

Return type:

XNameContainer

static get_style_families(doc)[source]

Gets a list of style family names.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

doc (Any) – office document.

Raises:
  • MissingInterfaceError – If Doc does not implement XStyleFamiliesSupplier interface.

  • Exception – If unable to get style Families.

Returns:

Style Families.

Return type:

XNameAccess

classmethod get_style_family_names(doc)[source]

Gets a sorted list of style family names.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

doc (Any) – office document

Raises:

Exception – If unable to names.

Returns:

List of style names

Return type:

List[str]

classmethod get_style_names(doc, family_style_name)[source]

Gets a list of style names.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • doc (Any) – office document.

  • family_style_name (str) – name of family style.

Raises:

Exception – If unable to access Style names.

Returns:

List of style names.

Return type:

List[str]

classmethod get_style_props(doc, family_style_name, prop_set_nm)[source]

Get style properties for a family of styles.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • doc (Any) – office document.

  • family_style_name (str) – name of family style.

  • prop_set_nm (str) – property set name.

Raises:

MissingInterfaceError – if a required interface cannot be obtained.

Returns:

Property set.

Return type:

XPropertySet

classmethod get_type_name(obj)[source]

Gets type name such as com.sun.star.table.TableSortField from uno object.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

obj (Any) – Uno object

Returns:

Full type name if found; Otherwise; None

Return type:

str | None

static get_unique_fnm(fnm)[source]

If a file called fnm already exists, then a number is added to the name so the filename is unique.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

fnm (str) – file path

Returns:

unique file path

Return type:

str

static get_user_defined_props(doc)[source]

Gets user defined properties.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

doc (Any) – office document.

Raises:

PropertiesError – if unable to access properties.

Returns:

Property container.

Return type:

XPropertyContainer

classmethod is_alien(filter_flags)[source]

Gets if filter flags has Filter.ALIEN flag set.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

filter_flags (Filter) – Flags.

Returns:

True if flag is set; Otherwise, False.

Return type:

bool

classmethod is_default(filter_flags)[source]

Gets if filter flags has Filter.DEFAULT flag set.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

filter_flags (Filter) – Flags.

Returns:

True if flag is set; Otherwise, False.

Return type:

bool

static is_doc_type(obj, doc_type)[source]

Gets if doc is a particular doc type.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • obj (object) – office document

  • doc_type (Service, str) – Doc type or service name such as com.sun.star.text.TextDocument.

Returns:

True if obj matches; Otherwise, False

Return type:

bool

classmethod is_export(filter_flags)[source]

Gets if filter flags has Filter.EXPORT flag set.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

filter_flags (Filter) – Flags.

Returns:

True if flag is set; Otherwise, False.

Return type:

bool

static is_image_mime(mime_type)[source]

Gets if mime-type is a known image type.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

mime_type (str) – mime type e.g. application/x-openoffice-bitmap

Returns:

True if known mime-type; Otherwise False

Return type:

bool

classmethod is_import(filter_flags)[source]

Gets if filter flags has Filter.IMPORT flag set.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

filter_flags (Filter) – Flags.

Returns:

True if flag is set; Otherwise, False.

Return type:

bool

classmethod is_instance(obj, class_or_tuple)[source]

Return whether an object is an instance of a class or of a subclass thereof.

UNO object error when used with isinstance. This method will return False if obj is a UNO object.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • obj (Any) – Any object. If UNO object then comparison is done by Lo.is_uno_interfaces(); Otherwise, built in isinstance is used.

  • class_or_tuple (Any) – A tuple, as in isinstance(x, (A, B, ...)), may be given as the target to check against. This is equivalent to isinstance(x, A) or isinstance(x, B) or … etc. When a UNO object is being compared then this should be a type or tuple of types that are expected by Lo.is_uno_interfaces()

Returns:

True if is instance; Otherwise, False.

Return type:

bool

Example

def __delitem__(self, _item: int | str | DrawPage | XDrawPage) -> None:
    if mInfo.Info.is_instance(_item, int):
        self.delete_slide(_item)
    elif mInfo.Info.is_instance(_item, str):
        slide = super().get_by_name(_item)
        if slide is None:
            raise MissingNameError(f"Unable to find slide with name '{_item}'")
        super().remove(slide)
    elif mInfo.Info.is_instance(_item, mDrawPage.DrawPage):
        super().remove(_item.component)
    elif mInfo.Info.is_instance(_item, XDrawPage):
        super().remove(_item)
    else:
        raise TypeError(f"Unsupported type: {type(_item)}")

See also

is_uno_interfaces()

Changed in version 0.17.14: Add support to check UNO objects.

New in version 0.17.11.

classmethod is_interface_obj(obj)[source]

Gets is an object contains interfaces.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

obj (Any) – Object to check.

Returns:

True if obj contains interface; Otherwise, False.

Return type:

bool

classmethod is_internal(filter_flags)[source]

Gets if filter flags has Filter.INTERNAL flag set.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

filter_flags (Filter) – Flags.

Returns:

True if flag is set; Otherwise, False.

Return type:

bool

classmethod is_not_in_chooser(filter_flags)[source]

Gets if filter flags has Filter.NOTINCHOOSER flag set.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

filter_flags (Filter) – Flags.

Returns:

True if flag is set; Otherwise, False.

Return type:

bool

classmethod is_not_in_file_dialog(filter_flags)[source]

Gets if filter flags has Filter.NOTINFILEDIALOG flag set.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

filter_flags (Filter) – Flags.

Returns:

True if flag is set; Otherwise, False.

Return type:

bool

classmethod is_own(filter_flags)[source]

Gets if filter flags has Filter.OWN flag set.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

filter_flags (Filter) – Flags.

Returns:

True if flag is set; Otherwise, False.

Return type:

bool

classmethod is_preferred(filter_flags)[source]

Gets if filter flags has Filter.PREFERRED flag set.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

filter_flags (Filter) – Flags.

Returns:

True if flag is set; Otherwise, False.

Return type:

bool

classmethod is_read_only(filter_flags)[source]

Gets if filter flags has Filter.READONLY flag set.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

filter_flags (Filter) – Flags.

Returns:

True if flag is set; Otherwise, False.

Return type:

bool

classmethod is_same(obj1, obj2)[source]

Determines if two Uno object are the same.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • obj1 (Any) – First Uno object

  • obj2 (Any) – Second Uno Object

Returns:

True if objects are the same; Otherwise False.

Return type:

bool

static is_struct(obj)[source]

Gets if an object is a UNO Struct.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

obj (Any) – Object to check.

Returns:

True if obj is Struct; Otherwise, False

Return type:

bool

classmethod is_support_selection(filter_flags)[source]

Gets if filter flags has Filter.SUPPORTSSELECTION flag set.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

filter_flags (Filter) – Flags.

Returns:

True if flag is set; Otherwise, False.

Return type:

bool

classmethod is_template(filter_flags)[source]

Gets if filter flags has Filter.TEMPLATE flag set.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

filter_flags (Filter) – Flags.

Returns:

True if flag is set; Otherwise, False.

Return type:

bool

classmethod is_template_path(filter_flags)[source]

Gets if filter flags has Filter.TEMPLATEPATH flag set.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

filter_flags (Filter) – Flags.

Returns:

True if flag is set; Otherwise, False.

Return type:

bool

classmethod is_third_party_filter(filter_flags)[source]

Gets if filter flags has Filter.THIRDPARTYFILTER flag set.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

filter_flags (Filter) – Flags.

Returns:

True if flag is set; Otherwise, False.

Return type:

bool

static is_type_enum(obj, type_name)[source]

Gets if an object is a UNO enum of matching type.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • obj (Any) – Object to test if is uno enum

  • type_name (str) – Type string such as com.sun.star.sheet.GeneralFunction

Returns:

True if obj is uno enum and obj matches type_name; Otherwise, False

Return type:

bool

static is_type_enum_multi(alt_type: str, enum_type: Type[enum.Enum], enum_val: enum.Enum) bool[source]
static is_type_enum_multi(alt_type: str, enum_type: Type[enum.Enum], enum_val: str) bool
static is_type_enum_multi(alt_type: str, enum_type: Type[enum.Enum], enum_val: enum.Enum, arg_name: str) bool
static is_type_enum_multi(alt_type: str, enum_type: Type[enum.Enum], enum_val: str, arg_name: str) bool
static is_type_enum_multi(alt_type, enum_type, enum_val, arg_name='')

Gets if an multiple inheritance enum, such as a str, Enum is of expected type.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • alt_type (str) – Alternative Type, In the case of a str, Enum this would be str

  • enum_type (Type[Enum]) – Expected Enum Type

  • enum_val (Enum) – Actual Enum Value

  • arg_name (str, optional) – Argument name used to pass enum value into method.

Raises:

TypeError – If arg_name is passed into this method and the type check fails.

Returns:

True if enum_val is valid alt_type or enum_type; Otherwise, False

Return type:

bool

Example

>>> from ooodev.utils.kind import chart2_types as ct

>>> val = ct.Area3dKind.PERCENT_STACKED_AREA_3D
>>> print(is_enum_type("str", ct.ChartTemplateBase, val))
True
>>> print(is_enum_type("str", ct.ChartTypeNameBase, val))
False
>>> print(is_enum_type("str", ct.ChartTypeNameBase, val, "input_enum"))
TypeError: Parameter "input_enum" must be of type "str" or "ChartTypeNameBase"
static is_type_interface(obj, type_name)[source]

Gets if an object is a Uno interface of matching type.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • obj (object) – Object to test if is interface

  • type_name (str) – Type string such as ‘com.sun.star.uno.XInterface’

Returns:

True if ‘obj’ is interface and ‘obj’ matches ‘type_name’; Otherwise, False

Return type:

bool

static is_type_struct(obj, type_name)[source]

Gets if an object is a Uno Struct of matching type.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • obj (Any) – Object to test if is struct.

  • type_name (str) – Type string such as com.sun.star.table.CellRangeAddress.

Returns:

True if obj is struct and obj matches type_name; Otherwise, False.

Return type:

bool

static is_uno(obj)[source]

Gets if an object is a UNO object.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

obj (object) – Object to check

Returns:

True if is UNO object; Otherwise, False

Return type:

bool

Note

This method only check for type pyuno, therefore UNO struct are not considered UNO objects in this context.

New in version 0.9.0.

classmethod list_extensions()[source]

Prints extensions to console.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Return type:

None

static mime_doc_type(mime_type)[source]

Gets document type from mime type.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

mime_type (str) – mime type

Returns:

Document type. If mime_type is unknown then ‘DocType.UNKNOWN’

Return type:

Lo.DocType

classmethod parse_language_code(lang_code)[source]

Parses a language code into a Locale object.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

lang_code (str) – Language code such as "en-US"

Returns:

Locale object

Return type:

Locale

Raises:

ValueError – If lang_code is not valid.

classmethod parse_languange_code(cls, lang_code)[source]

Parses a language code into a Locale object.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

lang_code (str) – Language code such as "en-US"

Returns:

Locale object

Return type:

Locale

Raises:

ValueError – If lang_code is not valid.

Deprecated since version 0.9.4: Use parse_language_code() instead.

classmethod print_doc_properties(doc)[source]

Prints document properties to console.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

doc (Any) – office document

Return type:

None

classmethod print_doc_props(dps)[source]

Prints doc properties to console.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

dps (XDocumentProperties) – document properties.

Return type:

None

Return type:

None

Parameters:

dps (com.sun.star.document.XDocumentProperties) –

classmethod report_doc_type(doc)[source]

Prints doc type to console and return doc type.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

doc (object) – office document

Returns:

Document type.

Return type:

Lo.DocType

classmethod set_config(node_path, node_str, val)[source]

Sets config.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:
  • node_path (str) – node path

  • node_str (str) – node name

  • val (object) – node value

Returns:

True on success; Otherwise, False

Return type:

bool

static set_config_props(node_path)[source]

Get config properties.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:

node_path (str) – Node path of properties

Raises:

mEx.ConfigError – if Unable to get config properties

Returns:

Property Set

Return type:

XPropertySet

static set_doc_props(doc, subject, title, author)[source]

Set document properties for subject, title, author.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • doc (Any) – office document.

  • subject (str) – subject.

  • title (str) – title.

  • author (str) – author.

Raises:

PropertiesError – If unable to set properties.

Return type:

None

static show_container_names(print_name, nc)[source]

Prints Name Container elements to console.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • print_name (str) – Name to display. Can be empty string.

  • nc (XNameContainer) – Name Container to print element names of.

static show_conversion_values(value, frm)[source]

Prints values of conversions to terminal.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • value (Any) – Any numeric value

  • frm (mConvert.Length) – The unit type of value.

Return type:

None

Note

Useful to help determine what different conversion of value are.

New in version 0.9.0.

Return type:

None

Parameters:
classmethod show_enum_name_values(obj)[source]

Prints Enum Name and Values to console.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

obj (object) – Object that contains enum values. Can be a Name such as com.sun.star.awt.MenuItemType or a UNO enum.

Return type:

None

classmethod show_interfaces(obj_name, obj)[source]

Prints interfaces in obj to console.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • obj_name (str) – Name of object for printing

  • obj (object) – obj that contains interfaces.

Return type:

None

classmethod show_methods(interface_name)[source]

Prints methods to console for an interface.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:

interface_name (str) – name of interface.

Return type:

None

classmethod show_methods_obj(obj, property_concept=None)[source]

Prints method to console for an object such as a doc.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • obj (object) – Object to get methods of.

  • property_concept (PropertyConceptEnum | None, optional) – Type of method to get. Defaults to PropertyConceptEnum.ALL.

Return type:

None

classmethod show_services(obj_name, obj)[source]

Prints services to console.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • obj_name (str) – service name

  • obj (object) – obj that implements XServiceInfo

Return type:

None

static support_service(obj, *service)[source]

Gets if obj supports a service.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • obj (object) – Object to check for supported service

  • *service (str) – Variable length argument list of UNO namespace strings such as com.sun.star.configuration.GroupAccess

Returns:

True if obj supports any passed in service; Otherwise, False

Return type:

bool

NODE_L10N = '/org.openoffice.Setup/L10N'
NODE_OFFICE = '/org.openoffice.Setup/Office'
NODE_PATHS = ('/org.openoffice.Setup/Product', '/org.openoffice.Setup/L10N')
NODE_PRODUCT = '/org.openoffice.Setup/Product'
REG_MOD_FNM = 'registrymodifications.xcu'