easymacro/docs/source/application.rst

123 lines
2.0 KiB
ReStructuredText

Application
===========
Remember, always import library.
.. code-block:: python
import easymacro as app
Create instances
----------------
* Instances without context
.. code-block:: python
toolkit = app.create_instance('com.sun.star.awt.Toolkit')
* Instances with context
.. code-block:: python
service = 'com.sun.star.awt.DialogProvider2'
dialog = app.create_instance(service, True)
* Get desktop
.. code-block:: python
desktop = app.create_instance('com.sun.star.frame.Desktop', True)
Or
.. code-block:: python
desktop = app.lo.desktop
Fonst
-----
* Get all fonts
.. code-block:: python
fonts = app.lo.fonts()
for f in fonts:
print(f'Name: {f.Name} - StyleName: {f.StyleName}')
Filters
-------
* Get all `support filters`_
.. code-block:: python
filters = app.lo.filters()
ds = []
for f in filters:
data = f"UI Name: {f['UIName']} - Name: {f['Name']} - Type: {f['Type']}"
app.debug(data)
Call dispatch
-------------
You can call any `dispatch command`_ used only if property or method no exists in original object or in `easymacro.py`
.. code-block:: python
doc = app.docs.active
command = 'Gallery'
app.lo.dispatch(doc, command)
Method automatically add `.uno:`
ClipBoard
---------
* Set text in clipboard
.. code-block:: python
app.clipboard.set('My Text')
* Get content of clipboard
.. code-block:: python
content = app.clipboard.content
app.debug(content)
Disable or enabled commands
---------------------------
You can disable any command.
.. code-block:: python
cmd = 'OpenFromCalc'
result = app.command.disable(cmd)
app.debug(result)
And enabled.
.. code-block:: python
result = app.command.enabled(cmd)
app.debug(result)
`OpenFromCalc` is options for open documents in calc, disable or enabled menu entry and icon toolbar.
.. _dispatch command: https://wiki.documentfoundation.org/Development/DispatchCommands
.. _support filters: https://help.libreoffice.org/latest/en-US/text/shared/guide/convertfilters.html