ooouno is a library of all (more than 4300) classes, typings and types for the LibreOffice API.
ooouno is for version 2024.2
of LibreOffice API.
More about LibreOffice.
Read the docs here
ooouno on Anaconda
$ conda install -c conda-forge ooouno
ooouno PyPI
$ pip install ooouno
All class found in LO API are recreated in this library.
- For instance:
from ooo.dyn.style.line_spacing import LineSpacing
is equivalent tofrom com.sun.star.style import LineSpacing
There are four namespaces representing LO API in this library.
ooo.lo
contains all static python classes. The format isooo.lo.<ns>.<snake_case_name>.<PascalCaseName>
from ooo.lo.uno.x_interface import XInterface
def foo(input:str) -> XInterface: ...
Namespace ooo.dyn
contains static and dynamic classes depending on class type.
The format is ooo.dyn.<ns>.<snake_case_name>.<PascalCaseName>
This namespace has dynamic classes that are changed at runtime. For classes that are dynamic are fully or partially replaced by UNO version at runtime.
This allows for typings while in design time (working in IDE) and at runtime UNO classes are created instead.
>>> from ooo.dyn.style.line_spacing import LineSpacing as DynLineSpacing
>>> from ooo.lo.style.line_spacing import LineSpacing as LoLineSpacing
>>> dyn_lns = DynLineSpacing(Height=10, Mode=3)
>>> lo_lns = LoLineSpacing(Height=10, Mode=3)
>>> assert dyn_lns.Height == 10
>>> assert dyn_lns.Mode == 3
>>> type(dyn_lns).__name__
'com.sun.star.style.LineSpacing'
>>> type(lo_lns).__name__
'LineSpacing'
As of version 2.0.0
the ooo.csslo
namespace is deprecated. Use the ooo.lo
namespace instead.
ooo.csslo
contains static classes as LO API style imports.ooo.csslo.<ns>.<PascalCaseName>
When importing from ooo.csslo
all classes in that namespace are also loaded.
Under some circumstances this may not be desired. Such as packaging with stickytape.
>>> from ooo.lo.style.line_spacing import LineSpacing as LoLineSpacing
>>> from ooo.csslo.style import LineSpacing as CssLineSpacing
>>> LoLineSpacing is CssLineSpacing
True
>>> ls = CssLineSpacing()
>>> type(ls).__name__
'LineSpacing'
As of version 2.0.0
the ooo.cssdyn
namespace is deprecated. Use the ooo.dyn
namespace instead.
Namespace ooo.cssdyn
contains static and dynamic classes depending on class type as LO API style imports.
When importing from ooo.cssdyn
all classes in that namespace are also loaded.
Under some circumstances this may not be desired. Such as packaging with stickytape.
>>> from ooo.dyn.style.line_spacing import LineSpacing as DynLineSpacing
>>> from ooo.cssdyn.style import LineSpacing as CssLineSpacing
>>> DynLineSpacing is CssLineSpacing
True
>>> ls = CssLineSpacing()
>>> type(ls).__name__
'com.sun.star.style.LineSpacing'
When using ooo as typings then import from ooo.lo
or ooo.csslo
.
When using ooo interactively such as creating struts, enums, singletons, const classes then
import from ooo.dyn
or ooo.cssdyn
.
Development environment is configured using poetry.
It is recommended to install virtual environment locally.
To Configure poetry to install virtual environment in local folder:
poetry config virtualenvs.in-project true
After virtual environment has been set up.
Link UNO files into virtual environment.
oooenv cmd-link -a
Run toggle command to set virtual environment.
oooenv env -t