Add documentation for application
This commit is contained in:
parent
70d6e93b90
commit
6e745a4183
|
@ -0,0 +1,85 @@
|
|||
|
||||
Application
|
||||
-----------
|
||||
|
||||
Remember, always import library.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
import easymacro as app
|
||||
|
||||
|
||||
Current doc
|
||||
^^^^^^^^^^^
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
doc = app.active
|
||||
app.msgbox(doc.title)
|
||||
|
||||
|
||||
Iter docs
|
||||
^^^^^^^^^
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
for doc in app.docs:
|
||||
app.msgbox(doc.title)
|
||||
|
||||
|
||||
Count
|
||||
^^^^^
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
count = len(app.docs)
|
||||
app.msgbox(count)
|
||||
|
||||
|
||||
Get by name
|
||||
^^^^^^^^^^^
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
name = 'MyDoc.ods'
|
||||
if name in app.docs:
|
||||
doc = app.docs[name]
|
||||
app.msgbox(doc.title)
|
||||
|
||||
|
||||
New
|
||||
^^^
|
||||
|
||||
For default create new Calc document.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
doc = app.docs.new()
|
||||
app.msgbox(doc.type)
|
||||
|
||||
For new Writer document.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
doc = app.docs.new('writer')
|
||||
app.msgbox(doc.type)
|
||||
|
||||
Other documents.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
doc = app.docs.new('draw')
|
||||
app.msgbox(doc.type)
|
||||
|
||||
doc = app.docs.new('impress')
|
||||
app.msgbox(doc.type)
|
||||
|
||||
|
||||
Open
|
||||
^^^^
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
path = '/home/mau/MyDoc.ods'
|
||||
doc = app.docs.open(path)
|
||||
|
|
@ -2,7 +2,18 @@
|
|||
Library easymacro.py
|
||||
====================
|
||||
|
||||
.. include:: 01_tools.rst
|
||||
.. include:: 02_tools.rst
|
||||
**easymacro.py** it's a library for easily develop macros en LibreOffice con Python. It is an abstraction layer between the extensive and complex LibreOffice API UNO and your code.
|
||||
|
||||
Probably, your will be more happy if used it. :)
|
||||
|
||||
You can used **easymacro.py** with any extension or directly in your macros.
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:caption: Contents:
|
||||
|
||||
tools_for_debug.rst
|
||||
tools.rst
|
||||
application.rst
|
||||
calc.rst
|
||||
writer.rst
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
1.2) Tools
|
||||
^^^^^^^^^^
|
||||
Tools
|
||||
-----
|
||||
|
||||
Remember, always import library.
|
||||
|
|
@ -1,18 +1,6 @@
|
|||
|
||||
**easymacro.py** it's a library for easily develop macros en LibreOffice con
|
||||
Python. It is an abstraction layer between the extensive and complex LibreOffice
|
||||
API UNO and your code.
|
||||
|
||||
Probably, your will be more happy if used it. :)
|
||||
|
||||
You can used **easymacro.py** with any extension or directly in your macros.
|
||||
|
||||
|
||||
1) Tools
|
||||
--------
|
||||
|
||||
1.1) For debug
|
||||
^^^^^^^^^^^^^^
|
||||
Tools for debug
|
||||
---------------
|
||||
|
||||
**INFO_DEBUG**
|
||||
^^^^^^^^^^^^^^
|
|
@ -2882,6 +2882,9 @@ class LOCalcRange(object):
|
|||
return
|
||||
|
||||
def _cast(self, t, v):
|
||||
if not t:
|
||||
return v
|
||||
|
||||
if t == datetime.date:
|
||||
nv = datetime.date.fromordinal(int(v) + DATE_OFFSET)
|
||||
else:
|
||||
|
@ -3958,6 +3961,7 @@ class LODocs(object):
|
|||
return doc
|
||||
|
||||
def __len__(self):
|
||||
# ~ len(self._desktop.Components)
|
||||
for i, _ in enumerate(self._desktop.Components):
|
||||
pass
|
||||
return i + 1
|
||||
|
@ -6659,48 +6663,6 @@ def get_fonts():
|
|||
return device.FontDescriptors
|
||||
|
||||
|
||||
# ~ From request
|
||||
# ~ https://github.com/psf/requests/blob/master/requests/structures.py#L15
|
||||
class CaseInsensitiveDict(MutableMapping):
|
||||
|
||||
def __init__(self, data=None, **kwargs):
|
||||
self._store = OrderedDict()
|
||||
if data is None:
|
||||
data = {}
|
||||
self.update(data, **kwargs)
|
||||
|
||||
def __setitem__(self, key, value):
|
||||
# Use the lowercased key for lookups, but store the actual
|
||||
# key alongside the value.
|
||||
self._store[key.lower()] = (key, value)
|
||||
|
||||
def __getitem__(self, key):
|
||||
return self._store[key.lower()][1]
|
||||
|
||||
def __delitem__(self, key):
|
||||
del self._store[key.lower()]
|
||||
|
||||
def __iter__(self):
|
||||
return (casedkey for casedkey, mappedvalue in self._store.values())
|
||||
|
||||
def __len__(self):
|
||||
return len(self._store)
|
||||
|
||||
def lower_items(self):
|
||||
"""Like iteritems(), but with all lowercase keys."""
|
||||
values = (
|
||||
(lowerkey, keyval[1]) for (lowerkey, keyval) in self._store.items()
|
||||
)
|
||||
return values
|
||||
|
||||
# Copy is required
|
||||
def copy(self):
|
||||
return CaseInsensitiveDict(self._store.values())
|
||||
|
||||
def __repr__(self):
|
||||
return str(dict(self.items()))
|
||||
|
||||
|
||||
# ~ https://en.wikipedia.org/wiki/Web_colors
|
||||
def get_color(value):
|
||||
COLORS = {
|
||||
|
|
Loading…
Reference in New Issue