Compare commits

...

62 Commits

Author SHA1 Message Date
Mauricio Baeza 58a8970978 Writer. Add shapes. Change zoom 2021-09-25 20:17:11 -05:00
Mauricio Baeza 5144785dda Update version 2021-09-25 20:16:41 -05:00
Mauricio Baeza 9b7fe665cc Writer add shapes. Change zoom 2021-09-25 20:15:40 -05:00
Mauricio Baeza f597411d3e Add writer cursor move 2021-08-29 15:43:37 -05:00
Mauricio Baeza 33c86dcd56 Add new example Calc 2021-07-11 22:31:59 -05:00
Mauricio Baeza 23135d9ad7 Add insert math in writer 2021-07-10 17:30:36 -05:00
Mauricio Baeza cdbb00fad4 Start support for insert math in writer 2021-07-10 17:29:29 -05:00
Mauricio Baeza 37fc2568da Start support for insert math in writer 2021-07-10 15:08:57 -05:00
Mauricio Baeza 5e2236db54 Update readme 2021-07-10 11:37:24 -05:00
Mauricio Baeza d983fac3d1 Get user profile in paths 2021-07-09 22:40:24 -05:00
Mauricio Baeza 19e211ce0a Add property url from command buttons forms 2021-07-09 14:57:43 -05:00
Mauricio Baeza 87c8ead015 Get visible now return ranges object 2021-07-07 22:45:43 -05:00
Mauricio Baeza 37acf3cc06 Set and get dates 2021-07-06 22:29:05 -05:00
Mauricio Baeza 62d2cd25c1 Documentation for Calc 2021-07-04 19:33:44 -05:00
Mauricio Baeza b1355d5d88 Document for reference to ranges 2021-07-04 15:28:56 -05:00
Mauricio Baeza 6efa879c85 Add support for calc ranges 2021-07-04 13:19:03 -05:00
Mauricio Baeza 45e3f97e6c Fix in driver url 2021-07-04 12:47:06 -05:00
Mauricio Baeza 55dfe77aa9 Add support for calc ranges 2021-07-03 23:51:42 -05:00
Mauricio Baeza 043e5f5f29 End document for sheets 2021-07-03 21:59:22 -05:00
Mauricio Baeza 686f1f6aea Update easymacro.py 2021-07-03 19:23:47 -05:00
Mauricio Baeza 0e656fbecb Doc for sheets 2021-07-03 19:23:23 -05:00
Mauricio Baeza f9b2b7679a End document for docs 2021-07-03 17:32:51 -05:00
Mauricio Baeza fd2f5631be Update readme 2021-07-02 22:10:43 -05:00
Mauricio Baeza 298fceb1e2 Add properties 2021-07-02 22:10:16 -05:00
Mauricio Baeza 9f2c0999aa Update doc 2021-07-01 22:41:20 -05:00
Mauricio Baeza 370bdae3bb Add apendix 2021-07-01 22:40:55 -05:00
Mauricio Baeza 42141fa06d Add apendix 2021-06-30 22:26:08 -05:00
Mauricio Baeza 90dae8a9b4 Fix in name in attacht files whend send emails 2021-06-30 14:29:02 -05:00
Mauricio Baeza 108659da4a End methods for path 2021-06-30 11:52:00 -05:00
Mauricio Baeza 94d8c43b1b Add save PDF in memory 2021-06-29 22:01:10 -05:00
Mauricio Baeza 467280fca3 Add insert image from stream 2021-06-29 15:09:25 -05:00
Mauricio Baeza 80691ad797 Fix in copy method 2021-06-28 22:59:16 -05:00
Mauricio Baeza 33c2b18c33 Add propery properties to shapes 2021-06-26 21:39:47 -05:00
Mauricio Baeza 3674b9f542 Update doc 2021-06-25 22:56:38 -05:00
Mauricio Baeza fa781d3da1 Add build folder 2021-06-25 22:55:52 -05:00
Mauricio Baeza 327dd76291 Add examples for paths 2021-06-24 21:50:25 -05:00
Mauricio Baeza 210a79aa41 Delete locales 2021-06-24 19:56:14 -05:00
Mauricio Baeza b58b1ad093 Add examples for paths 2021-06-23 21:38:02 -05:00
Mauricio Baeza 20fbd98157 Add timeout in url open 2021-06-22 23:03:06 -05:00
Mauricio Baeza 35a0eecd79 Add examples for url open 2021-06-22 22:54:25 -05:00
Mauricio Baeza 21fcf5f274 Add examples for encrypt decrypt data 2021-06-22 22:32:49 -05:00
Mauricio Baeza 081a4fe05f Add examples for measure time 2021-06-22 22:07:36 -05:00
Mauricio Baeza 2527c60ed0 Add examples for save and get configurations 2021-06-22 21:56:27 -05:00
Mauricio Baeza 4b9a5e45a5 Add examples for get digests 2021-06-21 23:02:38 -05:00
Mauricio Baeza 7a58bb695b Add examples for timer 2021-06-21 22:47:39 -05:00
Mauricio Baeza abfab3d254 Add examples for call external programs 2021-06-21 22:36:48 -05:00
Mauricio Baeza 205e08fc6e Add connection for postgres and mariadb 2021-06-20 23:28:38 -05:00
Mauricio Baeza 27ae3fe66b Update changelog 2021-06-20 23:28:07 -05:00
Mauricio Baeza 89966c4b04 Add documentation for application 2021-06-19 22:47:36 -05:00
Mauricio Baeza 79d44763f6 Add documentation for application 2021-06-18 23:04:07 -05:00
Mauricio Baeza bac62657f9 Add some examples 2021-06-17 21:44:26 -05:00
Mauricio Baeza 69e2ce2b53 Add support for connections for postgres and mariadb 2021-06-15 21:57:29 -05:00
Mauricio Baeza 0c4cce2533 Start documentation in spanish 2021-06-11 12:29:31 -05:00
Mauricio Baeza 6e745a4183 Add documentation for application 2021-06-10 22:25:03 -05:00
Mauricio Baeza 70d6e93b90 Add method get_data for set types in data ranges 2021-06-09 23:11:40 -05:00
Mauricio Baeza 254447bc4d Add autostyles for tables Writer 2021-06-05 21:46:05 -05:00
Mauricio Baeza 25b1170cb4 Update changelog 2021-06-05 21:45:26 -05:00
Mauricio Baeza 72e175cdeb Add examples for calc, writer, base 2021-06-03 22:09:34 -05:00
Mauricio Baeza ed7ad9e7d7 Add make file 2021-06-03 18:39:03 -05:00
Mauricio Baeza 18c9caeb13 Add examples for application 2021-06-03 18:28:37 -05:00
Mauricio Baeza f15cebd20e Add example for Draw 2021-06-03 17:47:12 -05:00
Mauricio Baeza afa0b53a1a Add style to tables for Writer 2021-05-13 12:44:26 -05:00
152 changed files with 14323 additions and 4839 deletions

1
.gitignore vendored
View File

@ -5,7 +5,6 @@ __pycache__/
conf.py
files/
docs/
source/source/
# Virtualenv

View File

@ -1,3 +1,29 @@
v 0.19.0 [25-sep-2021]
- Writer. Insert shapes. Set zoom.
v 0.18.0 [29-aug-2021]
- Writer. Move cursor: start, end, left, right
v 0.17.0 [10-jul-2021]
- Add insert math in writer
v 0.16.1 [01-jul-2021]
- Change property is_connected in db
- Update doc
v 0.16.0 [20-jun-2021]
- Add connection for postgres and mariadb
- Fix in call macro Basic
v 0.15.0 [05-jun-2021]
- Add autostyle for Writer tables
v 0.14.0 [13-apr-2021]
- Fix: Get paragraphs in Writer
- Add support for data pilots

View File

@ -4,11 +4,12 @@ Scripts and library for develop macros and extensions for LibreOffice with Pytho
Develop in pure Python, not need any dependence.
Python 3.7+
LibreOffice 7.0+
LibreOffice SDK 7.0+
* Python 3.7+
* LibreOffice 7.0+
* LibreOffice SDK 7.0+
* Look [documentation](https://doc.cuates.net/zaz/)
#### Look [documentation](https://doc.cuates.net/zaz/)
## Free Software, not gratis software
@ -18,23 +19,27 @@ LibreOffice SDK 7.0+
#### but, don't make the mistake of many of *thinking only in gratis software* that so much damage has done to **Free Software**.
This extension have a cost of maintenance of 10 euros every year.
This extension have a cost of maintenance of 1 euros every year.
BCH: `qztd3l00xle5tffdqvh2snvadkuau2ml0uqm4n875d`
In order of preferred.
BTC: `3FhiXcXmAesmQzrNEngjHFnvaJRhU1AGWV`
Mauricio Baeza
```
Euros
IBAN: BE60 9671 0556 5870
SWIFT / BIC: TRWIBEB1XXX
```
ETH: `0x61a4f614a30ff686445751ed8328b82b77ecfc69`
* BCH: `qztd3l00xle5tffdqvh2snvadkuau2ml0uqm4n875d`
LTC: `MBcgQ3LQJA4W2wsXknTdm2fxRSysLaBJHS`
You have others cryptos, welcome too!
* ETH: `0x61a4f614a30ff686445751ed8328b82b77ecfc69`
* XRP: `rLSn6Z3T8uCxbcd1oxwfGQN1Fdn5CyGujK` Tag: `6643162`
* LTC: `MBcgQ3LQJA4W2wsXknTdm2fxRSysLaBJHS`
* BTC: `3FhiXcXmAesmQzrNEngjHFnvaJRhU1AGWV`
## Extensions develop with ZAZ
* https://gitlab.com/mauriciobaeza/zaz-barcode
* https://gitlab.com/mauriciobaeza/zaz-favorite
* https://gitlab.com/mauriciobaeza/zaz-easymacro
* https://gitlab.com/mauriciobaeza/zaz-pip
* https://gitlab.com/mauriciobaeza/zaz-inspect
* https://git.cuates.net/elmau/zaz-pip
* https://git.cuates.net/elmau/zaz-favorites
* https://git.cuates.net/elmau/zaz-functions

View File

@ -1 +1 @@
0.14.0
0.19.0

View File

@ -1,4 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 5d46d3053e6726ba8d2145d0ba9b5df3
config: 9dc485243b09862a9e5c34c02e1c395f
tags: 645f666f9bcd5a90fca523b33c5a78b7

BIN
doc/build/.doctrees/environment.pickle vendored Normal file

Binary file not shown.

BIN
doc/build/.doctrees/es/index.doctree vendored Normal file

Binary file not shown.

BIN
doc/build/.doctrees/index.doctree vendored Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
doc/build/.doctrees/main/base.doctree vendored Normal file

Binary file not shown.

BIN
doc/build/.doctrees/main/calc.doctree vendored Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
doc/build/.doctrees/main/config.doctree vendored Normal file

Binary file not shown.

Binary file not shown.

BIN
doc/build/.doctrees/main/email.doctree vendored Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
doc/build/.doctrees/main/intro.doctree vendored Normal file

Binary file not shown.

BIN
doc/build/.doctrees/main/path.doctree vendored Normal file

Binary file not shown.

BIN
doc/build/.doctrees/main/paths.doctree vendored Normal file

Binary file not shown.

BIN
doc/build/.doctrees/main/tools.doctree vendored Normal file

Binary file not shown.

Binary file not shown.

BIN
doc/build/.doctrees/main/writer.doctree vendored Normal file

Binary file not shown.

View File

@ -13,6 +13,8 @@ Welcome to ZAZ's documentation!
main/intro
main/config
main/easymacro
main/examples
main/apendixes
Indices and tables

View File

@ -0,0 +1,46 @@
Apendixes
---------
Remember, always import library.
.. code-block:: python
import easymacro as app
Get all filters in Calc sheet
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
* Fields in filter
.. code-block:: python
'Finalized': False,
'UIName': 'EPS - Encapsulated PostScript',
'UserData': <ByteSequence instance 'b'''>,
'TemplateName': '',
'Enabled': True,
'Mandatory': False,
'Name': 'impress_eps_Export',
'FilterService': '',
'Type': 'eps_Encapsulated_PostScript',
'UIComponent': 'com.sun.star.svtools.SvFilterOptionsDialog',
'Flags': 1090,
'FileFormatVersion': 0,
'DocumentService': 'com.sun.star.presentation.PresentationDocument',
'UINames': {
'en-US': 'EPS - Encapsulated PostScript',
'es': 'EPS - PostScript encapsulado'}
.. code-block:: python
filters = app.get_filters()
headers = (('DocumentService', 'UIName', 'Name', 'Type'),)
data = [(f['DocumentService'], f['UIName'], f['Name'], f['Type'])
for f in filters]
doc = app.docs.new()
doc[0]['A1'].data = headers
doc[0]['A2'].data = data

View File

@ -0,0 +1,510 @@
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
desktop1 = app.create_instance('com.sun.star.frame.Desktop', True)
# ~ or
desktop2 = app.get_desktop()
app.msgbox(desktop1 == desktop2)
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)
If contain
^^^^^^^^^^
.. code-block:: python
result = 'myfile.ods' in app.docs
app.msgbox(result)
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)
With arguments.
.. code-block:: python
args= {'Hidden': True}
doc = app.docs.new('writer', args)
msg = f'{doc.type} - {doc.title}'
app.msgbox(msg)
doc.visible = True
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)
While LibreOffice support format, you can open arbitrary file.
.. code-block:: python
path = '/home/mau/example.xlsx'
doc = app.docs.open(path)
With arguments.
.. code-block:: python
path = '/home/mau/example.odt'
args = {'Password': 'letmein'}
doc = app.docs.open(path, args)
Save
^^^^
.. code-block:: python
path = '/home/mau/myfile.ods'
doc = app.docs.new()
doc.save(path)
* If previously open and modify any file.
.. code-block:: python
doc.save()
* Open exists file and save with other name.
.. code-block:: python
path = '/home/mau/myfile.ods'
doc = app.docs.open(path)
new_path = '/srv/mau/other_name.ods'
doc.save(new_path)
Close
^^^^^
.. code-block:: python
doc = app.docs.new()
app.msgbox(doc.title)
doc.close()
To PDF
^^^^^^
* Save in path
.. code-block:: python
doc = app.active
path = '/home/mau/test.pdf'
doc.to_pdf(path)
* Save in memory
.. code-block:: python
doc = app.active
pdf = doc.to_pdf()
Export
^^^^^^
* Export common formats
.. code-block:: python
doc = app.docs.new()
path = '/home/mau/myfile.xlsx'
filter_name = 'xlsx'
doc.export(path, filter_name)
path = '/home/mau/myfile.xls'
filter_name = 'xls'
doc.export(path, filter_name)
doc = app.docs.new('writer')
path = '/home/mau/myfile.docx'
filter_name = 'docx'
doc.export(path, filter_name)
path = '/home/mau/myfile.doc'
filter_name = 'doc'
doc.export(path, filter_name)
path = '/home/mau/myfile.rtf'
filter_name = 'rtf'
doc.export(path, filter_name)
* For all support formats look `Apendix`_
* Export in memory.
.. code-block:: python
doc = app.docs.new()
filter_name = 'xlsx'
excel_doc = doc.export(filter_name=filter_name)
Fonst
^^^^^
* Get all fonts
.. code-block:: python
fonts = app.get_fonts()
for f in fonts:
print(f'Name: {f.Name} - StyleName: {f.StyleName}')
Filters
^^^^^^^
* Get all `support filters`_
.. code-block:: python
filters = app.get_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.active
command = '.uno:Gallery'
app.call_dispatch(doc, command)
Properties
^^^^^^^^^^
obj
~~~
* Get original object pyUNO (read only)
.. code-block:: python
doc = app.active
app.msgbox(type(doc))
app.msgbox(type(doc.obj))
title
~~~~~
.. code-block:: python
doc = app.active
app.msgbox(doc.title)
doc.title = 'New title'
app.msgbox(doc.title)
type
~~~~
* Get type document: calc, writer, etc. (read only)
.. code-block:: python
doc = app.active
app.msgbox(doc.type)
uid
~~~
* Get internal RuntimeUID form document. (read only)
.. code-block:: python
doc = app.active
app.msgbox(doc.uid)
is_saved
~~~~~~~~
* If document is saved in this or not (read only)
.. code-block:: python
doc = app.active
app.msgbox(doc.is_saved)
is_modified
~~~~~~~~~~~
* If document has been modified (read only)
.. code-block:: python
doc = app.active
app.msgbox(doc.is_modified)
is_read_only
~~~~~~~~~~~~
.. code-block:: python
doc = app.active
app.msgbox(doc.is_read_only)
path
~~~~
* Get path of document. (read only)
.. code-block:: python
doc = app.active
app.msgbox(doc.path)
dir
~~~
* Get only directory from path saved (read only)
.. code-block:: python
doc = app.active
app.msgbox(doc.dir)
file_name
~~~~~~~~~
* Get only file name from path saved (read only)
.. code-block:: python
doc = app.active
app.msgbox(doc.file_name)
name
~~~~
* Get only name without extension (read only)
.. code-block:: python
doc = app.active
app.msgbox(doc.file_name)
visible
~~~~~~~
* Hide or show document.
.. code-block:: python
doc = app.active
doc.visible = False
app.msgbox(doc.visible)
doc.visible = True
zoom
~~~~
* Get or set zoom value.
.. code-block:: python
doc = app.active
zoom = doc.zoom
app.msgbox(zoom)
doc.zoom = zoom * 2
app.msgbox(doc.zoom)
doc.zoom = zoom
selection
~~~~~~~~~
* **CAUTION**: Selection can be many things.
.. code-block:: python
doc = app.active
selection = doc.selection
app.msgbox(selection)
status_bar
~~~~~~~~~~
* Get status bar, always control in other thread.
.. code-block:: python
@app.run_in_thread
def update_status_bar(sb, text, limit):
sb.start(text, limit)
for i in range(limit):
sb.setValue(i)
app.sleep(1)
# ~ Is important free status bar
sb.end()
return
def main():
doc = app.active
update_status_bar(doc.status_bar, 'Line', 10)
return
Methods
^^^^^^^
set_focus
~~~~~~~~~
.. code-block:: python
name = 'MyDoc.ods'
if name in app.docs:
doc = app.docs[name]
doc.set_focus()
copy
~~~~
* Copy current selection
.. code-block:: python
doc = app.active
doc.copy()
paste
~~~~~
* Paste any content in clipboard
.. code-block:: python
doc = app.active
doc.paste()
.. _dispatch command: https://wiki.documentfoundation.org/Development/DispatchCommands
.. _support filters: https://help.libreoffice.org/latest/en-US/text/shared/guide/convertfilters.html
.. _Apendix: apendixes.html

20
doc/build/_sources/main/base.rst.txt vendored Normal file
View File

@ -0,0 +1,20 @@
Base
----
Remember, always import library.
.. code-block:: python
import easymacro as app
New database
^^^^^^^^^^^^
.. code-block:: python
path = '/home/mau/db.odb'
db = app.doc.connect(path)
app.msgbox(db.type)

18
doc/build/_sources/main/calc.rst.txt vendored Normal file
View File

@ -0,0 +1,18 @@
Calc
----
Remember, always import library.
.. code-block:: python
import easymacro as app
.. toctree::
:maxdepth: 2
calc_doc.rst
calc_sheets.rst
calc_ranges.rst
calc_ranges2.rst
calc_data.rst

View File

@ -0,0 +1,92 @@
Data
~~~~
Read
^^^^
* Get value from cell, automatic detect type and get value.
.. code-block:: python
sheet = app.active_sheet
cell = sheet['A1']
value = cell.value
info = f'Cell Type = {cell.type}\n\nCell Value = {cell.value}'
app.msgbox(info)
* Get date, time and datetime like data Python.
.. code-block:: python
sheet = app.active_sheet
cell = sheet['A1']
app.msgbox(cell.date)
app.msgbox(cell.time)
app.msgbox(cell.datetime)
* Get values from cell range.
.. code-block:: python
sheet = app.active_sheet
rango = sheet['A1:B5']
app.msgbox(rango.data)
* Get formulas
.. code-block:: python
sheet = app.active_sheet
rango = sheet['A1:B5']
app.msgbox(rango.formula)
* Get array formula
.. code-block:: python
sheet = app.active_sheet
rango = sheet['C10:E15']
app.msgbox(rango.array_formula)
* Get like dictionary
The first row in range are the keys.
.. code-block:: python
sheet = app.active_sheet
rango = sheet['A1:B5']
app.msgbox(rango.dict)
Write
^^^^^
* Automatic detect data type.
.. code-block:: python
sheet = app.active_sheet
# ~ Set int
sheet['A1'].value = 1
# ~ Set float
sheet['A2'].value = 10.5
# ~ Set string
sheet['A3'].value = 'Damn World'
# ~ Set formula
sheet['A4'].value = '=RAND()'
# ~ Set date
sheet['A5'].value = app.today()
# ~ Set time
sheet['A6'].value = app.now(True)
# ~ Set datetime
sheet['A7'].value = app.now()

View File

@ -0,0 +1,50 @@
Document
~~~~~~~~
Current doc
^^^^^^^^^^^
.. code-block:: python
doc = app.active
app.msgbox(doc.type)
Selection
^^^^^^^^^
* If selection is range get LOCalcRange, if selection is shape get LOShape, other selection get original pyuno object.
.. code-block:: python
doc = app.active
selection = doc.selection
app.msgbox(type(selection))
Headers
^^^^^^^
* Hide or show columns and rows headers.
.. code-block:: python
doc = app.active
app.msgbox(doc.headers)
doc.headers = not doc.headers
app.msgbox(doc.headers)
doc.headers = not doc.headers
Tabs
^^^^
* Hide or show tab sheets.
.. code-block:: python
doc = app.active
app.msgbox(doc.tabs)
doc.tabs = not doc.tabs
app.msgbox(doc.tabs)
doc.tabs = not doc.tabs

View File

@ -0,0 +1,190 @@
Cell and ranges
~~~~~~~~~~~~~~~
Cells
^^^^^
* By name
.. code-block:: python
sheet = app.active_sheet
cell = sheet['A1']
app.msgbox(cell.name)
* By position [row, column]
.. code-block:: python
cell = sheet[1, 4]
app.msgbox(cell.name)
Ranges
^^^^^^
* By name
.. code-block:: python
sheet = app.active_sheet
rango = sheet['B2:D5']
app.msgbox(rango.name)
* By position [start_row:end_row, start_column:end_column]
.. code-block:: python
rango = sheet[1:5,1:4]
app.msgbox(rango.name)
* Group ranges
.. code-block:: python
doc = app.active
sheet = doc.active
last = doc[-1]
with doc.ranges as r:
# Add one range
r.add(sheet['A1:B2'])
r2 = sheet['C4:D5']
r3 = last['E7:D8']
r4 = last['E10:F12']
# Add multiple ranges
r.add((r2, r3, r4))
app.debug(r.names)
* Get the same range in all sheets
.. code-block:: python
ranges = doc.get_ranges('A1:B1')
app.debug(ranges.names)
* Get columns by name.
.. code-block:: python
sheet = app.active_sheet
rango = sheet['B:B']
app.debug(rango.name)
rango = sheet['D:F']
app.debug(rango.name)
* Get columns by position.
.. code-block:: python
sheet = app.active_sheet
# Column B
rango = sheet[0:,1]
app.debug(rango.name)
# Columnas D:F
rango = sheet[0:,3:6]
app.debug(rango.name)
* Get rows
.. code-block:: python
sheet = app.active_sheet
# One row
row = sheet[1]
app.debug(row.name)
# Range rows
row = sheet[3:10,0:]
app.debug(row.name)
Info ranges
^^^^^^^^^^^
* Get absolute name
.. code-block:: python
sheet = app.active_sheet
rango = sheet['A1:E10']
app.msgbox(rango.name)
* Get address
.. code-block:: python
sheet = app.active_sheet
rango = sheet['A1']
a = rango.address
data = f"""Cell Address
Row: {a.Row}
Column: {a.Column}
"""
app.msgbox(data)
rango = sheet['A1:E10']
ra = rango.range_address
data = (
f'Range Address:\n\n'
f'Star Row: {ra.StartRow}\n'
f'End Row: {ra.EndRow}\n'
f'Star Column: {ra.StartColumn}\n'
f'End Column: {ra.EndColumn}\n'
)
app.msgbox(data)
Special ranges
^^^^^^^^^^^^^^
* Get used area
.. code-block:: python
sheet = app.active_sheet
rango = sheet.used_area
app.msgbox(rango.name)
* Get current region
.. code-block:: python
rango = sheet['A1'].current_region
app.msgbox(rango.name)
* Get next free cell
.. code-block:: python
cell = sheet['A1'].next_cell
app.msgbox(cell.name)
* Get merged area
.. code-block:: python
sheet = app.active_sheet
rango = sheet['A1'].merged_area
app.msgbox(rango.name)
* Get visible cells
.. code-block:: python
sheet = app.active_sheet
rangos = sheet['A1:E10'].visible
for r in rangos:
app.debug(r.name)
* Get empty cells
.. code-block:: python
sheet = app.active_sheet
rangos = sheet['A1:E10'].empty
for r in rangos:
app.debug(r.name)

View File

@ -0,0 +1,124 @@
Manipulate ranges
~~~~~~~~~~~~~~~~~
**Not, not is necesary select range for manipulate**
Select
^^^^^^
* Select from doc
.. code-block:: python
doc = app.active
sheet = app.active_sheet
cell = sheet['A1']
doc.select(cell)
* Select in self range
.. code-block:: python
sheet = app.active_sheet
rango = sheet['A1:C5']
rango.select()
Move
^^^^
.. code-block:: python
sheet = app.active_sheet
rango = sheet['A1:C5']
rango.move(sheet['E6'])
* Move to other sheet
.. code-block:: python
rango.move(doc[-1]['E6'])
Insert
^^^^^^
* Default insert down
.. code-block:: python
sheet = app.active_sheet
rango = sheet['A1:C1']
rango.insert()
* Insert and move right
.. code-block:: python
rango.insert(app.CellInsertMode.RIGHT)
* Insert entire rows
.. code-block:: python
rango.insert(app.CellInsertMode.ROWS)
* Insert entire columns
.. code-block:: python
rango.insert(app.CellInsertMode.COLUMNS)
Delete
^^^^^^
* Default move up
.. code-block:: python
sheet = app.active_sheet
rango = sheet['A1:C1']
rango.delete()
* Delete and move left
.. code-block:: python
rango.delete(app.CellDeleteMode.LEFT)
* Delete entire rows
.. code-block:: python
rango.delete(app.CellDeleteMode.ROWS)
* Delete entire columns
.. code-block:: python
rango.delete(app.CellDeleteMode.COLUMNS)
Copy
^^^^
* Using native method `copyRange`, current range always should be a cell and source should be a range.
.. code-block:: python
sheet = app.active_sheet
cell = sheet['A5']
source = sheet['D1:E4']
cell.copy_from(source)
* From range to cell
.. code-block:: python
sheet = app.active_sheet
rango = sheet['A1:C5']
target = sheet['E1']
rango.copy_to(target)

View File

@ -0,0 +1,332 @@
Sheets
~~~~~~
Active sheet
^^^^^^^^^^^^
.. code-block:: python
sheet = app.active_sheet
app.msgbox(sheet.name)
# or
doc = app.active
sheet = doc.active
Get by index
^^^^^^^^^^^^
.. code-block:: python
doc = app.active
sheet = doc[0]
app.msgbox(sheet.name)
Get by name
^^^^^^^^^^^
.. code-block:: python
doc = app.active
sheet = doc['Sheet1']
app.msgbox(sheet.name)
Contains
^^^^^^^^
.. code-block:: python
doc = app.active
app.msgbox('Sheet1' in doc)
Get tuple with all names
^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: python
doc = app.active
app.msgbox(doc.names)
Count
^^^^^
.. code-block:: python
doc = app.active
app.msgbox(len(doc))
New
^^^
* Always validate if new name not exists.
.. code-block:: python
doc = app.active
sheet = doc.new_sheet()
# CAUTION: If 'NewSheet' exists, reset it to clean sheet.
doc['NewSheet'] = sheet
# ~ or
sheet = doc.insert('NewSheet2')
* Insert multiple, get last insert.
.. code-block:: python
names = ('One', 'Two', 'Three')
sheet = doc.insert(names)
Move
^^^^
* Move by object to last position.
.. code-block:: python
sheet = doc[0]
doc.move(sheet)
* Move by name to last position.
.. code-block:: python
doc.move('Sheet1')
* Move to position.
.. code-block:: python
sheet = doc[0]
doc.move(sheet, 2)
* Move from sheet
.. code-block:: python
sheet = app.active_sheet
sheet.move()
* Move to position.
.. code-block:: python
sheet = app.active_sheet
sheet.move(2)
Remove
^^^^^^
* Remove by object.
.. code-block:: python
sheet = doc[0]
doc.remove(sheet)
* Remove by name.
.. code-block:: python
doc.remove('One')
* Remove from sheet.
.. code-block:: python
sheet = app.active_sheet
sheet.remove()
Copy
^^^^
* Copy inside the same spreadsheet.
* By object
.. code-block:: python
sheet = doc[0]
doc.copy_sheet(sheet, 'OtherSheet')
* By name
.. code-block:: python
doc.copy_sheet('Sheet1', 'Sheet2')
* From sheet
.. code-block:: python
sheet = app.active_sheet
sheet.copy(sheet.name + '_2')
Copy from
^^^^^^^^^
* Copy sheet from one spreadsheet to other.
.. code-block:: python
doc = app.active
doc_source = app.docs['Contacts.ods']
name_source = 'Names'
name_target = 'Names'
position = 0
doc.copy_from(doc_source, name_source, name_target, position)
Copy to
^^^^^^^
* Copy from sheet with the same name
.. code-block:: python
doc = app.docs.new()
sheet = app.active_sheet
sheet.copy_to(doc)
* Used new name
.. code-block:: python
doc = app.docs.new()
sheet = app.active_sheet
sheet.copy_to(doc, 'NewName')
Sort
^^^^
* Sort sheets by names.
.. code-block:: python
doc = app.active
doc.sort()
Name
^^^^
* Name visible by the user.
.. code-block:: python
sheet = app.active_sheet
app.msgbox(sheet.name)
sheet.name = 'NewName'
app.msgbox(sheet.name)
Code name
^^^^^^^^^
* Name only accessible by code.
.. code-block:: python
sheet = app.active_sheet
app.msgbox(sheet.code_name)
sheet.code_name = 'my_name'
app.msgbox(sheet.code_name)
Visible
^^^^^^^
* Apply only with spreadsheet with two or more sheets.
.. code-block:: python
sheet = app.active_sheet
app.msgbox(sheet.visible)
sheet.visible = not sheet.visible
app.msgbox(sheet.visible)
sheet.visible = not sheet.visible
Is protected
^^^^^^^^^^^^
* If sheet is protected with password.
.. code-block:: python
sheet = app.active_sheet
app.msgbox(sheet.is_protected)
Set password
^^^^^^^^^^^^
.. code-block:: python
sheet = app.active_sheet
sheet.password = 'letmein'
app.msgbox(sheet.is_protected)
Remove password
^^^^^^^^^^^^^^^
.. code-block:: python
sheet = app.active_sheet
sheet.password = 'letmein'
app.msgbox(sheet.is_protected)
sheet.unprotect('letmein')
app.msgbox(sheet.is_protected)
Tab color
^^^^^^^^^
.. code-block:: python
sheet = app.active_sheet
app.msgbox(sheet.color)
sheet.color = 'red'
app.msgbox(sheet.color)
# RGB
sheet.color = (125, 200, 10)
app.msgbox(sheet.color)
Document parent
^^^^^^^^^^^^^^^
.. code-block:: python
doc = sheet.doc
Activate
^^^^^^^^
.. code-block:: python
doc = app.active
# Get last sheet
sheet = doc[-1]
# Activate from doc
doc.activate(sheet)
# Activate from sheet
sheet.activate()

View File

@ -0,0 +1,34 @@
Library easymacro.py
====================
**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.
**IMPORTANT**: Majority objects are custom objects, you can always get original UNO object with property `obj`
.. code-block:: python
doc = app.active
app.msgbox(doc)
app.msgbox(doc.obj)
.. toctree::
:maxdepth: 2
:caption: Contents:
tools_for_debug.rst
tools.rst
paths.rst
email.rst
application.rst
calc.rst
writer.rst
base.rst

111
doc/build/_sources/main/email.rst.txt vendored Normal file
View File

@ -0,0 +1,111 @@
Email
-----
Remember, always import library.
.. code-block:: python
import easymacro as app
**IMPORTANT:** Always save your config the more security way possible.
Send email
^^^^^^^^^^
.. code-block:: python
from conf import PASSWORD
SERVER = dict(
server = 'mail.server.net' ,
port = 495,
ssl = True,
user = 'no-responder@noexiste.mx',
password = PASSWORD,
)
body = "Hello Ingrid\n\nWho are you?\n\nBest regards"
message = dict(
to = 'ingrid.bergman@love.you',
subject = 'I love you',
body = body,
)
app.send_email(SERVER, message)
* We can use fields `cc`, `bcc` too and send to more than one address emails.
.. code-block:: python
to = 'mail1@correo.com,mail2@correo.com,mail3@correo.com'
cc = 'other@correo.com'
bcc = 'hidden@correo.com'
* We can send too more than one message.
.. code-block:: python
message1 = dict(
to = 'ingrid.bergman@email.net',
subject = 'I love you',
body = "Hello Ingrid\n\nWho are you?\n\nBest regards",
)
message2 = dict(
to = 'sophia.loren@email.net',
subject = 'I love you',
body = "Hello Sophia\n\nWho are you?\n\nBest regards",
)
messages = (message1, message2)
app.send_email(SERVER, messages)
.. code-block:: bash
30/06/2021 13:43:23 - DEBUG - Connect to: mail.gandi.net
30/06/2021 13:43:24 - DEBUG - Email sent...
30/06/2021 13:43:26 - DEBUG - Email sent...
30/06/2021 13:43:26 - DEBUG - Close connection...
* Send with attachment
.. code-block:: python
files = '/home/mau/file.epub'
message = dict(
to = 'ingrid.bergman@email.net',
subject = 'I love you',
body = "Hello Ingrid\n\nWho are you?\n\nBest regards",
files = files,
)
* Send more than one file.
.. code-block:: python
files = (
'/home/mau/file1.epub',
'/home/mau/file2.epub',
)
* If your client email used `mbox` format, we can save in any path into your email client configuration.
.. code-block:: python
path_save = '/home/mau/.thunderbird/7iznrbyw.default/Mail/Local Folders/LibreOffice'
message = dict(
to = 'ingrid.bergman@email.net',
subject = 'I love you',
body = "Hello Ingrid\n\nWho are you?\n\nBest regards",
path = path_save
)
app.send_email(SERVER, message)
* All emails always send in other thread.
.. _cryptography: https://github.com/pyca/cryptography

View File

@ -0,0 +1,15 @@
Examples
========
Examples of macros used in production.
.. toctree::
:maxdepth: 2
:caption: Contents:
examples_app.rst
examples_calc.rst
examples_writer.rst
examples_draw.rst
examples_base.rst

View File

@ -0,0 +1,47 @@
For Application
---------------
Make custom menu
^^^^^^^^^^^^^^^^
Macro example in library ``mymacros``
.. code-block:: python
def show_info_debug():
app.msgbox(app.INFO_DEBUG)
return
Insert custom menu in menu Tools in Calc.
.. code-block:: python
def insert_menu_in_calc():
menus = app.menus['calc']
data = {
'Label': 'My Macros',
'CommandURL': 'zaz.my.macros',
'Index': 0,
'Submenu': [
{
'Label': 'Show info debug',
'CommandURL': {'library': 'mymacros', 'name': 'show_info_debug'},
'ShortCut': 'Ctrl+Shift+Alt+M'
},
],
}
menus.insert('Tools', data)
return
Delete menu
^^^^^^^^^^^
.. code-block:: python
def delete_menu():
menus = app.menus['calc']
menus.remove('Tools', 'zaz.my.macros')
return

View File

@ -0,0 +1,100 @@
For Base
--------
You need install ``peewee``
``pip install -U peewee``
Create table
^^^^^^^^^^^^
.. code-block:: python
import easymacro as app
from peewee import *
database_proxy = DatabaseProxy()
class BaseModel(Model):
class Meta:
database = database_proxy
legacy_table_names = False
class Contacts(BaseModel):
id = IdentityField()
name = CharField()
born = app.BaseDateField(null=True)
def create_table():
path = '/home/mau/test.odb'
if app.paths.exists(path):
db = app.docs.connect(path)
else:
db = app.docs.new('base', {'path': path})
tables = [Contacts]
db.initialize(database_proxy, tables)
return
Insert data
^^^^^^^^^^^
.. code-block:: python
def base_insert_data():
path = '/home/mau/test.odb'
db = app.docs.connect(path)
db.initialize(database_proxy)
rows = (
dict(name = 'Ingrid Bergman', born=app.dates.date(2001, 1, 1)),
dict(name = 'Sofia Loren', born=app.dates.date(2002, 2, 2)),
dict(name = 'Kim Novak', born=app.dates.date(2003, 3, 3)),
dict(name = 'Jane Fonda', born=app.dates.date(2004, 4, 4)),
dict(name = 'Marion Cotillar', born=app.dates.date(2005, 5, 5)),
)
for row in rows:
Contactos.insert(**row).execute()
return
Select data
^^^^^^^^^^^
.. code-block:: python
def base_select_data():
path = '/home/mau/test.odb'
db = app.docs.connect(path)
db.initialize(database_proxy)
query = Contactos.select()
rows = db.get_query(query).tuples
for row in rows:
print(row)
rows = db.get_query(query).dicts
for row in rows:
print(row)
return
You can get tuples or dict::
(1, 'Ingrid Bergman', datetime.date(2001, 1, 1))
(2, 'Sofia Loren', datetime.date(2002, 2, 2))
(3, 'Kim Novak', datetime.date(2003, 3, 3))
(4, 'Jane Fonda', datetime.date(2004, 4, 4))
(5, 'Marion Cotillar', datetime.date(2005, 5, 5))
{'id': 1, 'name': 'Ingrid Bergman', 'born': datetime.date(2001, 1, 1)}
{'id': 2, 'name': 'Sofia Loren', 'born': datetime.date(2002, 2, 2)}
{'id': 3, 'name': 'Kim Novak', 'born': datetime.date(2003, 3, 3)}
{'id': 4, 'name': 'Jane Fonda', 'born': datetime.date(2004, 4, 4)}
{'id': 5, 'name': 'Marion Cotillar', 'born': datetime.date(2005, 5, 5)}

View File

@ -0,0 +1,47 @@
For Calc
--------
Data to cell
^^^^^^^^^^^^
Automatic calculate size range.
.. code-block:: python
def calc_data_to_cell():
sheet = app.active_sheet
data = (
('Month', 'Total'),
('January', 100),
('February', 200),
('March', 300),
('April', 400),
('May', 500),
)
sheet['A1'].data = data
return
Copy visible cells
^^^^^^^^^^^^^^^^^^
.. code-block:: python
doc = app.active
rangos = doc.active['A1'].current_region.visible
doc.select(rangos)
doc.copy()
doc.active['A15'].select()
doc.paste()
Merge by row
^^^^^^^^^^^^
.. code-block:: python
rango = app.selection
rango.merge_by_row()

View File

@ -0,0 +1,27 @@
For Draw
-----------------
Save image from clipboard
^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: python
def save_image_from_clipboard():
# Target path
path = '/home/mau/Pictures'
# Open new hidden Draw doc
doc = app.docs.new('draw', {'Hidden': True})
# Paste image from clipboard and return
image = doc.paste()
# Save image
image.save(path)
# Close document
doc.close()
app.msgbox('Image saved')
return

View File

@ -0,0 +1,24 @@
For Writer
----------
Set autostyle in table
~~~~~~~~~~~~~~~~~~~~~~
.. code-block:: python
def writer_table_set_style():
doc = app.active
table = doc.tables[0]
table.style = 'Academic'
return
Insert math formula
~~~~~~~~~~~~~~~~~~~
.. code-block:: python
formula = '%LAMBDA_{deg","t}=1 + %alpha_deg SQRT {M_t over M_{(t=0)}-1}~"."'
text = app.selection
text.insert_math(formula)

View File

@ -25,9 +25,9 @@ Requirements
In:
* ArchLinux
* sudo pacman -S libreoffice-fresh-sdk
* ``sudo pacman -S libreoffice-fresh-sdk``
* Ubuntu 20.04+
* sudo apt install libreoffice-script-provider-python libreoffice-dev
* ``sudo apt install libreoffice-script-provider-python libreoffice-dev``
Installation

614
doc/build/_sources/main/paths.rst.txt vendored Normal file
View File

@ -0,0 +1,614 @@
Paths and files
---------------
Remember, always import library.
.. code-block:: python
import easymacro as app
Get info path
^^^^^^^^^^^^^
.. code-block:: python
path = '/home/mau/myfile.ods'
p = app.paths(path)
app.debug(p.path)
app.debug(p.file_name)
app.debug(p.name)
app.debug(p.ext)
app.debug(p.size)
app.debug(p.url)
Or get information in a tuple
.. code-block:: python
path = '/home/mau/myfile.ods'
p = app.paths(path)
app.msgbox(p.info)
Exists path
^^^^^^^^^^^
.. code-block:: python
path = '/home/mau/test'
app.msgbox(app.paths.exists(path))
Path is file
^^^^^^^^^^^^
.. code-block:: python
path = '/home/mau/myfile.ott'
app.msgbox(app.paths.is_file(path))
Path is dir
^^^^^^^^^^^
.. code-block:: python
path = '/home/mau'
app.msgbox(app.paths.is_dir(path))
Get path home
^^^^^^^^^^^^^
.. code-block:: python
path = app.paths.home
app.msgbox(path)
Get path documents
^^^^^^^^^^^^^^^^^^
* Configurate in LibreOffice Paths
.. code-block:: python
path = app.paths.documents
app.msgbox(path)
Get path temp
^^^^^^^^^^^^^
.. code-block:: python
path = app.paths.temp_dir
app.msgbox(path)
Get path from LibreOffice configuration
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
* Default get path documents.
.. code-block:: python
path = app.paths.config()
app.msgbox(path)
* All options in `API XPathSettings`_
.. code-block:: python
path = app.paths.config('Config')
app.msgbox(path)
Get path executable python
^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: python
path_python = app.paths.python
app.msgbox(path_python)
Save and read text data
^^^^^^^^^^^^^^^^^^^^^^^
* Default encoding is UTF8
.. code-block:: python
data = """Do you want to know who you are? Don't ask. Act!
Action will delineate and define you.
Thomas Jefferson
"""
path = '/home/mau/temp.txt'
app.paths.save(path, data)
data = app.paths.read(path)
app.msgbox(data)
* Change encoding
.. code-block:: python
app.paths.save(path, data, 'iso-8859-1')
Save and read binary data
^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: python
data = b'Binary data'
path = '/home/mau/temp.bin'
app.paths.save_bin(path, data)
data = app.paths.read_bin(path)
app.msgbox(data)
Join paths
^^^^^^^^^^
.. code-block:: python
path_home = app.paths.home
file_name = 'test.ods'
path = app.paths.join(path_home, file_name)
app.msgbox(path)
Get a temporal path
^^^^^^^^^^^^^^^^^^^
.. code-block:: python
path_temp = app.paths.tmp()
app.msgbox(path_temp)
* Get with extension.
.. code-block:: python
path_temp = app.paths.tmp('.txt')
app.msgbox(path_temp)
* Save data in a temporal path
.. code-block:: python
data = """He who receives an idea from me,
receives instruction himself without lessening mine;
as he who lights his taper at mine,
receives light without darkening me.
Thomas Jefferson
"""
path_tmp = app.paths.save_tmp(data)
app.msgbox(path_tmp)
Get a temporal dir
^^^^^^^^^^^^^^^^^^
* All content and directory is deleted when exit context.
.. code-block:: python
data = """Do you want to know who you are? Don't ask. Act!
Action will delineate and define you.
Thomas Jefferson
"""
with app.paths.dir_tmp() as dt:
app.debug(app.paths.exists(dt))
path = app.paths.join(dt, 'test.txt')
app.paths.save(path, data)
app.debug(app.paths.exists(dt))
Get path for save
^^^^^^^^^^^^^^^^^
* Default open in user documents.
.. code-block:: python
path = app.paths.get()
app.msgbox(path)
* Open in other path.
.. code-block:: python
path_tmp = app.paths.temp_dir
path = app.paths.get(path_tmp)
app.msgbox(path)
* Add one filter
.. code-block:: python
path = app.paths.get(filters='xml')
app.msgbox(path)
* Add multiple filters
.. code-block:: python
path = app.paths.get(filters='xml,txt')
Select directory
^^^^^^^^^^^^^^^^
* Default open in user documents.
.. code-block:: python
path_dir = app.paths.get_dir()
app.msgbox(path_dir)
* Open in other path.
.. code-block:: python
path_tmp = app.paths.temp_dir
path_dir = app.paths.get_dir(path_tmp)
app.msgbox(path_dir)
Get path exists file
^^^^^^^^^^^^^^^^^^^^
* Default open in user documents.
.. code-block:: python
path_file = app.paths.get_file()
app.msgbox(path_file)
* Change init dir.
.. code-block:: python
path = '/home/mau'
path_file = app.paths.get_file(path)
app.msgbox(path_file)
* Add filter or filters.
.. code-block:: python
path_file = app.paths.get_file(filters='ods')
# or
path_file = app.paths.get_file(filters='ods,odt')
* Can select multiple files.
.. code-block:: python
path_file = app.paths.get_file(multiple=True)
Replace extension
^^^^^^^^^^^^^^^^^
.. code-block:: python
path = '/home/mau/myFile.ods'
path_new = app.paths.replace_ext(path, 'pdf')
app.msgbox(path_new)
Path in format URL <-> System
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: python
path = '/home/mau/myFile.ods'
path_url = app.paths.to_url(path)
app.msgbox(path_url)
path = app.paths.to_system(path_url)
app.msgbox(path)
Delete files and directories
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
**CAUTION**: Delete files and directories immediately, always confirm this action.
.. code-block:: python
path = '/home/mau/temp.bin'
result = app.paths.kill(path)
app.msgbox(result)
* Delete directory and all content.
.. code-block:: python
path = '/home/mau/safe_for_delete'
result = app.paths.kill(path)
app.msgbox(result)
Get files
^^^^^^^^^
This method use library `pathlib`
* Get files not recursively
.. code-block:: python
path = '/home/mau/Documents'
files = app.paths.files(path)
for f in files:
app.debug(f)
* Add filter
.. code-block:: python
files = app.paths.files(path, '*.pdf')
* Get from this directory and all subdirectories, recursively
.. code-block:: python
files = app.paths.files(path, '**/*.pdf')
This method use `os.walk`
* Get content files recursively
.. code-block:: python
path = '/home/mau/Documents'
files = app.paths.walk(path)
for f in files:
app.debug(f)
* Add filters
.. code-block:: python
files = app.paths.walk(path, 'ods')
# or filters
files = app.paths.walk(path, 'ods|odt')
Get directories
^^^^^^^^^^^^^^^
This method use library `pathlib`
* Get directories in path not recursively
.. code-block:: python
path = '/home/mau/Documents'
folders = app.paths.dirs(path)
for f in folders:
app.debug(f)
This method use `os.walk`
* Get directories in path recursively
.. code-block:: python
path = '/home/mau/Documents'
folders = app.paths.walk_dirs(path)
for f in folders:
app.debug(f)
* Get info in a tuple (ID_FOLDER, ID_PARENT, NAME)
.. code-block:: python
path = '/home/mau/Documents'
folders = app.paths.walk_dirs(path, True)
for f in folders:
app.debug(f)
Get install path extension from id
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: python
id_ext = 'net.elmau.zaz.EasyMacro'
path = app.paths.from_id(id_ext)
app.debug(path)
.. code-block:: bash
24/06/2021 21:47:29 - DEBUG - /home/mau/.config/libreoffice/4/user/uno_packages/cache/uno_packages/lu20665x29msz.tmp_/ZAZEasyMacro_v0.1.0.oxt
Verify if application exists
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: python
app_name = 'nosoffice'
app.msgbox(app.paths.exists_app(app_name))
app_name = 'soffice'
app.msgbox(app.paths.exists_app(app_name))
Open any type file
^^^^^^^^^^^^^^^^^^
Open with default application in OS.
.. code-block:: python
path = '/home/mau/Downloads/file.pdf'
app.paths.open(path)
path = '/home/mau/Projects/libre_office/zaz/doc/build/index.html'
app.paths.open(path)
Save and read json
^^^^^^^^^^^^^^^^^^
.. code-block:: python
path = '/home/mau/data.json'
data = {
'type': 'calc',
'name': 'myfile.ods',
}
app.paths.to_json(path, data)
data = app.paths.from_json(path)
app.msgbox(data)
Save and read csv
^^^^^^^^^^^^^^^^^
You can used the same way that `python csv`_
.. code-block:: python
path = '/home/mau/data.csv'
data = (
(1, 'one', app.now()),
(2, 'two', app.now()),
(3, 'three', app.now()),
)
app.paths.to_csv(path, data)
data = app.paths.from_csv(path)
app.msgbox(data)
Zip, unzip
^^^^^^^^^^
For default, save in the same directory with the same name + `.zip`
* Zip file
.. code-block:: python
source = '/home/mau/logo.svg'
path_zip = app.paths.zip(source)
app.debug(path_zip)
* Zip directory
.. code-block:: python
source = '/home/mau/test'
path_zip = app.paths.zip(source)
app.debug(path_zip)
* Set target
.. code-block:: python
source = '/home/mau/logo.svg'
target = '/home/mau/myfile.zip'
path_zip = app.paths.zip(source, target)
app.debug(path_zip)
* Read content of zip
.. code-block:: python
path_zip = '/home/mau/test.zip'
names = app.paths.zip_content(path_zip)
for n in names:
app.debug(n)
* Unzip in the same directory
.. code-block:: python
path_zip = '/home/mau/test.zip'
app.paths.unzip(path_zip)
* Unzip in other directory
.. code-block:: python
path_zip = '/home/mau/test.zip'
target = '/srv/mau'
app.paths.unzip(path_zip, target)
* Extract one or more files
.. code-block:: python
path_zip = '/home/mau/test.zip'
members = 'calc.ods'
app.paths.unzip(path_zip, members=members)
# or
members = ('calc.ods', 'subdir/file.md')
* Merge zips
.. code-block:: python
zips = (
'/home/mau/test.zip',
'/home/mau/pictures.zip',
)
target = '/srv/mau/file.zip'
result = app.paths.merge_zip(target, zips)
app.msgbox(result)
Copy files
^^^^^^^^^^
Copy with the same name
.. code-block:: python
path = '/home/mau/image.png'
target = '/home/mau/Pictures'
path_new = app.paths.copy(path, target)
app.msgbox(path_new)
Copy with other name
.. code-block:: python
path = '/home/mau/image.png'
target = '/home/mau/Pictures'
new_name = 'other_name.png'
path_new = app.paths.copy(path, target, name)
app.msgbox(path_new)
.. _API XPathSettings: http://api.libreoffice.org/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1util_1_1XPathSettings.html
.. _python csv: https://docs.python.org/3.7/library/csv.html

532
doc/build/_sources/main/tools.rst.txt vendored Normal file
View File

@ -0,0 +1,532 @@
Tools
-----
Remember, always import library.
.. code-block:: python
import easymacro as app
Info from PC
^^^^^^^^^^^^
* Operate system
.. code-block:: python
app.msgbox(app.OS)
* Current user
.. code-block:: python
app.msgbox(app.USER)
* Name PC
.. code-block:: python
app.msgbox(app.PC)
* Name desktop, only GNU/Linux
.. code-block:: python
app.msgbox(app.DESKTOP)
* Language
.. code-block:: python
app.msgbox(app.LANG)
* Language with variant
.. code-block:: python
app.msgbox(app.LANGUAGE)
* Application name
.. code-block:: python
app.msgbox(app.NAME)
* Application version
.. code-block:: python
app.msgbox(app.VERSION)
* In Windows
.. code-block:: python
app.msgbox(app.IS_WIN)
* In Mac
.. code-block:: python
app.msgbox(app.IS_MAC)
Message Box
^^^^^^^^^^^
.. code-block:: python
app.msgbox(app.IS_WIN, 'My Macro')
Show warning
^^^^^^^^^^^^
.. code-block:: python
message = 'Caution, this action is dangerous'
title = 'My App'
app.warning(message, title)
Show error box
^^^^^^^^^^^^^^
.. code-block:: python
message = 'ERROR: Contact technical support'
title = 'My App'
app.errorbox(message, title)
Make question
^^^^^^^^^^^^^
.. code-block:: python
message = 'Is easy Python?'
title = 'My App'
result = app.question(message, title)
app.msgbox(result)
InputBox
^^^^^^^^
* Normal data
.. code-block:: python
message = 'Type your name'
default = ''
title = 'My App'
result = app.inputbox(message, default, title)
app.msgbox(result)
* Private data
.. code-block:: python
message = 'Type your password'
default = ''
title = 'My App'
echochar = "*"
result = app.inputbox(message, default, title, echochar)
app.msgbox(result)
Date and times
^^^^^^^^^^^^^^
* Get today
.. code-block:: python
app.msgbox(app.today())
* Get now
.. code-block:: python
app.msgbox(app.now())
* Get now only time
.. code-block:: python
app.msgbox(app.now(True))
* Get `epoch time`_
.. code-block:: python
app.msgbox(app.get_epoch())
* Simple measure time
.. code-block:: python
app.start()
app.sleep(5)
seconds = app.end(True)
app.msgbox(seconds)
Thread
^^^^^^
You can execute any macro in thread
* Normal execution
.. code-block:: python
def show_time(seconds):
app.sleep(seconds)
app.msgbox(app.NAME)
return
def main(args=None):
show_time(5)
app.msgbox('Finish...')
return
* Run in thread
.. code-block:: python
@app.run_in_thread
def show_time(seconds):
app.sleep(seconds)
app.msgbox(app.NAME)
return
def main(args=None):
show_time(5)
app.msgbox('Finish...')
return
Dictionary <-> properties
^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: python
args = {
'Hidden': True,
'Password': 'letmein',
}
properties = app.dict_to_property(args)
app.msgbox(properties)
data = app.data_to_dict(properties)
app.msgbox(data)
Tuples or lists to dictionary
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: python
tuple_of_tuples = (
('Hidden', True),
('Password', 'letmein'),
)
data = app.data_to_dict(tuple_of_tuples)
app.msgbox(data)
list_of_lists = [
['Hidden', True],
['Password', 'letmein'],
]
data = app.data_to_dict(list_of_lists)
app.msgbox(data)
Json
^^^^
.. code-block:: python
data = {
'Hidden': True,
'Password': 'letmein',
}
json = app.json_dumps(data)
app.msgbox(json)
data = app.json_loads(json)
app.msgbox(data)
Call Macros
^^^^^^^^^^^
You can any macro, for default call macros Python.
.. code-block:: python
def show_message():
app.msgbox(app.INFO_DEBUG)
return
def main(args=None):
args = {
'library': 'test',
'name': 'show_message',
}
app.call_macro(args)
return
Of course is better call directly if both macros are the same languaje, but, you can call macro in Basic too.
.. code-block:: vbnet
Sub show_message()
MsgBox "Basic from Python"
End Sub
Call from Python with.
.. code-block:: python
args = {
'language': 'Basic',
'library': 'Standard',
'module': 'Module1',
'name': 'show_message',
}
app.call_macro(args)
Execute macro in other thread
.. code-block:: python
app.call_macro(args, True)
Call external program
^^^^^^^^^^^^^^^^^^^^^
.. code-block:: python
app_name = 'gnome-calculator'
app.run(app_name)
app.msgbox('ok')
Call command line and capture output
.. code-block:: python
args = 'ls -lh ~'
result = app.run(args, True)
app.debug(result)
.. code-block:: bash
21/06/2021 22:27:22 - DEBUG - total 1.3M
drwxr-xr-x 5 mau mau 4.0K Jun 17 13:09 Desktop
drwxr-xr-x 6 mau mau 4.0K Jun 15 12:35 Documents
drwxr-xr-x 2 mau mau 4.0K Jun 21 20:26 Downloads
drwxr-xr-x 2 mau mau 4.0K Jun 21 16:18 Pictures
drwxr-xr-x 13 mau mau 4.0K Jun 21 15:34 Projects
drwxr-xr-x 2 mau mau 4.0K May 11 18:48 Templates
drwxr-xr-x 2 mau mau 4.0K Jun 20 23:27 Videos
Call command line and capture output line by line.
.. code-block:: python
args = 'ls -lh /home/mau'
for line in app.popen(args):
app.debug(line)
.. code-block:: bash
21/06/2021 22:34:42 - DEBUG - total 1.3M
21/06/2021 22:34:42 - DEBUG - drwxr-xr-x 5 mau mau 4.0K Jun 17 13:09 Desktop
21/06/2021 22:34:42 - DEBUG - drwxr-xr-x 6 mau mau 4.0K Jun 15 12:35 Documents
21/06/2021 22:34:42 - DEBUG - drwxr-xr-x 2 mau mau 4.0K Jun 21 20:26 Downloads
21/06/2021 22:34:42 - DEBUG - -rw-r----- 1 mau mau 1.3M Jun 14 11:53 out.png
21/06/2021 22:34:42 - DEBUG - drwxr-xr-x 2 mau mau 4.0K Jun 21 16:18 Pictures
21/06/2021 22:34:42 - DEBUG - drwxr-xr-x 13 mau mau 4.0K Jun 21 15:34 Projects
21/06/2021 22:34:42 - DEBUG - drwxr-xr-x 2 mau mau 4.0K May 11 18:48 Templates
21/06/2021 22:34:42 - DEBUG - drwxr-xr-x 2 mau mau 4.0K Jun 20 23:27 Videos
Timer
^^^^^
Execute any macro every seconds.
.. code-block:: python
TIMER_NAME = 'clock'
def show_time():
app.debug(app.now(True))
return
def start_clock():
seconds = 1
macro = {
'library': 'test',
'name': 'show_time',
}
app.start_timer(TIMER_NAME, seconds, macro)
return
def stop_clock():
app.stop_timer(TIMER_NAME)
return
def main(args=None):
start_clock()
return
Execute `stop_clock` for stop timer.
.. code-block:: bash
21/06/2021 22:43:17 - INFO - Timer started... show_time
21/06/2021 22:43:18 - DEBUG - 22:43:18.080315
21/06/2021 22:43:19 - DEBUG - 22:43:19.082211
...
21/06/2021 22:43:46 - DEBUG - 22:43:46.126446
21/06/2021 22:43:47 - DEBUG - 22:43:47.128487
21/06/2021 22:43:47 - INFO - Timer stopped... show_time
Get digest
^^^^^^^^^^
.. code-block:: python
data = 'LibreOffice with Python'
digest = app.sha256(data)
app.msgbox(digest)
digest = app.sha512(data)
app.msgbox(digest)
Save and get configurations
^^^^^^^^^^^^^^^^^^^^^^^^^^^
You can save any data.
.. code-block:: python
my_app = 'my_extension'
data = {
'path': '/home/mau/work',
'save_data': True,
}
app.set_config('config', data, my_app)
app.msgbox('Save config')
data = app.get_config('config', my_app)
app.msgbox(data)
Render string
^^^^^^^^^^^^^
.. code-block:: python
template = """Hello $name
I send you this $file_name
Best regards
"""
data = {'name': 'Ingrid Bergman', 'file_name': 'letter_love.odt'}
render = app.render(template, data)
app.msgbox(render)
Encrypt decrypt
^^^^^^^^^^^^^^^
You need install library `cryptography`_
.. code-block:: python
import easymacro as app
from conf import PASSWORD
def encrypt_decrypt():
data = 'My super secret data'
token = app.encrypt(data, PASSWORD)
app.msgbox(token)
data = app.decrypt(token, PASSWORD)
app.msgbox(data)
return
Simple url open
^^^^^^^^^^^^^^^
* Get text data
.. code-block:: python
url = 'https://api.ipify.org'
data = app.url_open(url)
app.msgbox(data)
* Get json data
.. code-block:: python
url = 'https://api.ipify.org?format=json'
data = app.url_open(url, get_json=True)
app.msgbox(data)
For more complex case, you can used `requests`_ or `httpx`_
Color
^^^^^
Look colors that you can used in `web colors`_
.. code-block:: python
color_name = 'darkblue'
color = app.get_color(color_name)
app.msgbox(color)
color_rgb = (125, 200, 10)
color = app.get_color(color_rgb)
app.msgbox(color)
color_html = '#008080'
color = app.get_color(color_html)
app.msgbox(color)
.. _epoch time: https://en.wikipedia.org/wiki/Unix_time
.. _cryptography: https://github.com/pyca/cryptography
.. _requests: https://docs.python-requests.org
.. _httpx: https://www.python-httpx.org/
.. _web colors: https://en.wikipedia.org/wiki/Web_colors

View File

@ -1,21 +1,9 @@
**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.
Tools for debug
---------------
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
^^^^^^^^^^^^^^
**INFO_DEBUG**
^^^^^^^^^^^^^^
INFO_DEBUG
^^^^^^^^^^
Show info debug, show in message box.
@ -41,8 +29,8 @@ Show in shell.
return
**Log error**
^^^^^^^^^^^^^
Log error
^^^^^^^^^
Show error message in shell.
@ -56,8 +44,8 @@ Show error message in shell.
return
**Log debug**
^^^^^^^^^^^^^
Log debug
^^^^^^^^^
Show debug message in shell.
@ -71,8 +59,8 @@ Show debug message in shell.
return
**Log info**
^^^^^^^^^^^^
Log info
^^^^^^^^
Show info message in shell.
@ -86,8 +74,8 @@ Show info message in shell.
return
**Log to file**
^^^^^^^^^^^^^^^
Log to file
^^^^^^^^^^^
Save log to file, automatic add date and time.
@ -102,8 +90,8 @@ Save log to file, automatic add date and time.
**Message box**
^^^^^^^^^^^^^^^
Message box
^^^^^^^^^^^
Show any data in message box
@ -127,8 +115,8 @@ Show any data in message box
return
**Catch exceptions**
^^^^^^^^^^^^^^^^^^^^
Catch exceptions
^^^^^^^^^^^^^^^^
Sometimes, for difficult errors, you can catch exceptions.
@ -144,8 +132,8 @@ Sometimes, for difficult errors, you can catch exceptions.
And not, not used you this function in production.
**Call MRI**
^^^^^^^^^^^^
Call MRI
^^^^^^^^
`MRI`_ is the better extension for debug any object in LibreOffice, you need
install before call it.

19
doc/build/_sources/main/writer.rst.txt vendored Normal file
View File

@ -0,0 +1,19 @@
Writer
------
Remember, always import library.
.. code-block:: python
import easymacro as app
Current doc
^^^^^^^^^^^
.. code-block:: python
doc = app.active
app.msgbox(doc.type)

View File

@ -130,7 +130,7 @@ ul.search li a {
font-weight: bold;
}
ul.search li div.context {
ul.search li p.context {
color: #888;
margin: 2px 0 0 30px;
text-align: left;
@ -277,25 +277,25 @@ p.rubric {
font-weight: bold;
}
img.align-left, .figure.align-left, object.align-left {
img.align-left, figure.align-left, .figure.align-left, object.align-left {
clear: left;
float: left;
margin-right: 1em;
}
img.align-right, .figure.align-right, object.align-right {
img.align-right, figure.align-right, .figure.align-right, object.align-right {
clear: right;
float: right;
margin-left: 1em;
}
img.align-center, .figure.align-center, object.align-center {
img.align-center, figure.align-center, .figure.align-center, object.align-center {
display: block;
margin-left: auto;
margin-right: auto;
}
img.align-default, .figure.align-default {
img.align-default, figure.align-default, .figure.align-default {
display: block;
margin-left: auto;
margin-right: auto;
@ -319,7 +319,8 @@ img.align-default, .figure.align-default {
/* -- sidebars -------------------------------------------------------------- */
div.sidebar {
div.sidebar,
aside.sidebar {
margin: 0 0 0.5em 1em;
border: 1px solid #ddb;
padding: 7px;
@ -377,12 +378,14 @@ div.body p.centered {
/* -- content of sidebars/topics/admonitions -------------------------------- */
div.sidebar > :last-child,
aside.sidebar > :last-child,
div.topic > :last-child,
div.admonition > :last-child {
margin-bottom: 0;
}
div.sidebar::after,
aside.sidebar::after,
div.topic::after,
div.admonition::after,
blockquote::after {
@ -455,20 +458,22 @@ td > :last-child {
/* -- figures --------------------------------------------------------------- */
div.figure {
div.figure, figure {
margin: 0.5em;
padding: 0.5em;
}
div.figure p.caption {
div.figure p.caption, figcaption {
padding: 0.3em;
}
div.figure p.caption span.caption-number {
div.figure p.caption span.caption-number,
figcaption span.caption-number {
font-style: italic;
}
div.figure p.caption span.caption-text {
div.figure p.caption span.caption-text,
figcaption span.caption-text {
}
/* -- field list styles ----------------------------------------------------- */
@ -503,6 +508,63 @@ table.hlist td {
vertical-align: top;
}
/* -- object description styles --------------------------------------------- */
.sig {
font-family: 'Consolas', 'Menlo', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace;
}
.sig-name, code.descname {
background-color: transparent;
font-weight: bold;
}
.sig-name {
font-size: 1.1em;
}
code.descname {
font-size: 1.2em;
}
.sig-prename, code.descclassname {
background-color: transparent;
}
.optional {
font-size: 1.3em;
}
.sig-paren {
font-size: larger;
}
.sig-param.n {
font-style: italic;
}
/* C++ specific styling */
.sig-inline.c-texpr,
.sig-inline.cpp-texpr {
font-family: unset;
}
.sig.c .k, .sig.c .kt,
.sig.cpp .k, .sig.cpp .kt {
color: #0033B3;
}
.sig.c .m,
.sig.cpp .m {
color: #1750EB;
}
.sig.c .s, .sig.c .sc,
.sig.cpp .s, .sig.cpp .sc {
color: #067D17;
}
/* -- other body styles ----------------------------------------------------- */
@ -629,14 +691,6 @@ dl.glossary dt {
font-size: 1.1em;
}
.optional {
font-size: 1.3em;
}
.sig-paren {
font-size: larger;
}
.versionmodified {
font-style: italic;
}
@ -766,7 +820,11 @@ div.code-block-caption code {
table.highlighttable td.linenos,
span.linenos,
div.doctest > div.highlight span.gp { /* gp: Generic.Prompt */
user-select: none;
user-select: none;
-webkit-user-select: text; /* Safari fallback only */
-webkit-user-select: none; /* Chrome/Safari */
-moz-user-select: none; /* Firefox */
-ms-user-select: none; /* IE10+ */
}
div.code-block-caption span.caption-number {
@ -781,16 +839,6 @@ div.literal-block-wrapper {
margin: 1em 0;
}
code.descname {
background-color: transparent;
font-weight: bold;
font-size: 1.2em;
}
code.descclassname {
background-color: transparent;
}
code.xref, a code {
background-color: transparent;
font-weight: bold;

View File

@ -29,9 +29,14 @@ if (!window.console || !console.firebug) {
/**
* small helper function to urldecode strings
*
* See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent#Decoding_query_parameters_from_a_URL
*/
jQuery.urldecode = function(x) {
return decodeURIComponent(x).replace(/\+/g, ' ');
if (!x) {
return x
}
return decodeURIComponent(x.replace(/\+/g, ' '));
};
/**

View File

@ -1,7 +1,7 @@
var DOCUMENTATION_OPTIONS = {
URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'),
VERSION: '',
LANGUAGE: 'None',
LANGUAGE: 'en',
COLLAPSE_INDEX: false,
BUILDER: 'html',
FILE_SUFFIX: '.html',

View File

Before

Width:  |  Height:  |  Size: 286 B

After

Width:  |  Height:  |  Size: 286 B

View File

@ -13,7 +13,8 @@
var stopwords = ["a","and","are","as","at","be","but","by","for","if","in","into","is","it","near","no","not","of","on","or","such","that","the","their","then","there","these","they","this","to","was","will","with"];
/* Non-minified version JS is _stemmer.js if file is provided */
/* Non-minified version is copied as a separate JS file, is available */
/**
* Porter Stemmer
*/
@ -199,7 +200,6 @@ var Stemmer = function() {
var splitChars = (function() {
var result = {};
var singles = [96, 180, 187, 191, 215, 247, 749, 885, 903, 907, 909, 930, 1014, 1648,

View File

Before

Width:  |  Height:  |  Size: 90 B

After

Width:  |  Height:  |  Size: 90 B

View File

Before

Width:  |  Height:  |  Size: 90 B

After

Width:  |  Height:  |  Size: 90 B

View File

@ -1,7 +1,7 @@
pre { line-height: 125%; }
td.linenos pre { color: #000000; background-color: #f0f0f0; padding-left: 5px; padding-right: 5px; }
span.linenos { color: #000000; background-color: #f0f0f0; padding-left: 5px; padding-right: 5px; }
td.linenos pre.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight { background: #f8f8f8; }

View File

@ -248,7 +248,7 @@ var Search = {
// results left, load the summary and display it
if (results.length) {
var item = results.pop();
var listItem = $('<li style="display:none"></li>');
var listItem = $('<li></li>');
var requestUrl = "";
var linkUrl = "";
if (DOCUMENTATION_OPTIONS.BUILDER === 'dirhtml') {
@ -273,9 +273,9 @@ var Search = {
if (item[3]) {
listItem.append($('<span> (' + item[3] + ')</span>'));
Search.output.append(listItem);
listItem.slideDown(5, function() {
setTimeout(function() {
displayNextItem();
});
}, 5);
} else if (DOCUMENTATION_OPTIONS.HAS_SOURCE) {
$.ajax({url: requestUrl,
dataType: "text",
@ -285,16 +285,16 @@ var Search = {
listItem.append(Search.makeSearchSummary(data, searchterms, hlterms));
}
Search.output.append(listItem);
listItem.slideDown(5, function() {
setTimeout(function() {
displayNextItem();
});
}, 5);
}});
} else {
// no source available, just display title
Search.output.append(listItem);
listItem.slideDown(5, function() {
setTimeout(function() {
displayNextItem();
});
}, 5);
}
}
// search finished, update title and status message
@ -379,6 +379,13 @@ var Search = {
return results;
},
/**
* See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
*/
escapeRegExp : function(string) {
return string.replace(/[.*+\-?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
},
/**
* search for full-text terms in the index
*/
@ -402,13 +409,14 @@ var Search = {
];
// add support for partial matches
if (word.length > 2) {
var word_regex = this.escapeRegExp(word);
for (var w in terms) {
if (w.match(word) && !terms[word]) {
if (w.match(word_regex) && !terms[word]) {
_o.push({files: terms[w], score: Scorer.partialTerm})
}
}
for (var w in titleterms) {
if (w.match(word) && !titleterms[word]) {
if (w.match(word_regex) && !titleterms[word]) {
_o.push({files: titleterms[w], score: Scorer.partialTitle})
}
}
@ -501,7 +509,7 @@ var Search = {
var excerpt = ((start > 0) ? '...' : '') +
$.trim(text.substr(start, 240)) +
((start + 240 - text.length) ? '...' : '');
var rv = $('<div class="context"></div>').text(excerpt);
var rv = $('<p class="context"></p>').text(excerpt);
$.each(hlwords, function() {
rv = rv.highlightText(this, 'highlighted');
});

2042
doc/build/_static/underscore-1.13.1.js vendored Normal file

File diff suppressed because it is too large Load Diff

6
doc/build/_static/underscore.js vendored Normal file

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,14 +1,14 @@
<!DOCTYPE html>
<html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Index &#8212; ZAZ documentation</title>
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
<script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<link rel="stylesheet" type="text/css" href="_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="_static/alabaster.css" />
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/doctools.js"></script>
@ -59,6 +59,8 @@
<li class="toctree-l1"><a class="reference internal" href="main/intro.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="main/config.html">Configuration</a></li>
<li class="toctree-l1"><a class="reference internal" href="main/easymacro.html">Library easymacro.py</a></li>
<li class="toctree-l1"><a class="reference internal" href="main/examples.html">Examples</a></li>
<li class="toctree-l1"><a class="reference internal" href="main/apendixes.html">Apendixes</a></li>
</ul>
<div class="relations">
@ -94,7 +96,7 @@
&copy;2021, Mauricio Baeza.
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 3.4.3</a>
Powered by <a href="http://sphinx-doc.org/">Sphinx 4.0.2</a>
&amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
</div>

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,42 +0,0 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) 2021, Mauricio Baeza
# This file is distributed under the same license as the ZAZ package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: ZAZ \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-02-05 22:20-0600\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: ../../source/index.rst:9
#: ../../source/index.rst:9
msgid "Contents:"
msgstr ""
#: ../../source/index.rst:7
msgid "Welcome to ZAZ's documentation!"
msgstr ""
#: ../../source/index.rst:17
msgid "Indices and tables"
msgstr ""
#: ../../source/index.rst:19
msgid ":ref:`genindex`"
msgstr ""
#: ../../source/index.rst:20
msgid ":ref:`modindex`"
msgstr ""
#: ../../source/index.rst:21
msgid ":ref:`search`"
msgstr ""

View File

@ -1,117 +0,0 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) 2021, Mauricio Baeza
# This file is distributed under the same license as the ZAZ package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: ZAZ \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-02-05 22:20-0600\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: ../../source/main/intro.rst:3
msgid "Introduction"
msgstr ""
#: ../../source/main/intro.rst:6
msgid "Overview"
msgstr ""
#: ../../source/main/intro.rst:8
msgid "ZAZ is a script for rapid develop extensions and macros for `LibreOffice`_, in `Python`_ of course."
msgstr ""
#: ../../source/main/intro.rst:11
msgid "With ZAZ, you can create:"
msgstr ""
#: ../../source/main/intro.rst:13
msgid "Extensions for final user"
msgstr ""
#: ../../source/main/intro.rst:14
msgid "New components for used from Basic"
msgstr ""
#: ../../source/main/intro.rst:15
msgid "AddIn, new functions for Calc"
msgstr ""
#: ../../source/main/intro.rst:19
msgid "Requirements"
msgstr ""
#: ../../source/main/intro.rst:21
msgid "Python 3.7+"
msgstr ""
#: ../../source/main/intro.rst:22
msgid "LibreOffice 7.0+ with support for macros Python"
msgstr ""
#: ../../source/main/intro.rst:23
msgid "LibreOffice SDK, for new components and Add-In"
msgstr ""
#: ../../source/main/intro.rst:27
msgid "Installation"
msgstr ""
#: ../../source/main/intro.rst:29
msgid "Clone this repository (recomended) or download it."
msgstr ""
#: ../../source/main/intro.rst:31
msgid "``git clone https://git.cuates.net/elmau/zaz.git``"
msgstr ""
#: ../../source/main/intro.rst:33
msgid "Move to."
msgstr ""
#: ../../source/main/intro.rst:35
msgid "``cd zaz/source``"
msgstr ""
#: ../../source/main/intro.rst:37
msgid "Start new extension."
msgstr ""
#: ../../source/main/intro.rst:39
msgid "``./zaz.py -new -t ~/projects -n MyFirstExtension``"
msgstr ""
#: ../../source/main/intro.rst:43
msgid "My first extension"
msgstr ""
#: ../../source/main/intro.rst:45
msgid "Move to:"
msgstr ""
#: ../../source/main/intro.rst:47
msgid "``cd ~/projects/MyFirstExtension``"
msgstr ""
#: ../../source/main/intro.rst:49
msgid "Create:"
msgstr ""
#: ../../source/main/intro.rst:51
msgid "``python zaz.py -c``::"
msgstr ""
#: ../../source/main/intro.rst:60
msgid "Install and test:"
msgstr ""
#: ../../source/main/intro.rst:62
msgid "``python zaz.py -i``::"
msgstr ""

View File

@ -1,200 +0,0 @@
1.2) Tools
^^^^^^^^^^
Remember, always import library.
.. code-block:: python
import easymacro as app
**Info from PC**
^^^^^^^^^^^^^^^^
* Operate system
.. code-block:: python
app.msgbox(app.OS)
* Current user
.. code-block:: python
app.msgbox(app.USER)
* Name PC
.. code-block:: python
app.msgbox(app.PC)
* Name desktop, only GNU/Linux
.. code-block:: python
app.msgbox(app.DESKTOP)
* Language
.. code-block:: python
app.msgbox(app.LANG)
* Language with variant
.. code-block:: python
app.msgbox(app.LANGUAGE)
* Application name
.. code-block:: python
app.msgbox(app.NAME)
* Application version
.. code-block:: python
app.msgbox(app.VERSION)
* In Windows
.. code-block:: python
app.msgbox(app.IS_WIN)
**Message box**
^^^^^^^^^^^^^^^
.. code-block:: python
app.msgbox(app.IS_WIN, 'My Macro')
**Show warning**
^^^^^^^^^^^^^^^^
.. code-block:: python
message = 'Caution, this action is dangerous'
title = 'My App'
app.warning(message, title)
**Show error box**
^^^^^^^^^^^^^^^^^^
.. code-block:: python
message = 'ERROR: Contact technical support'
title = 'My App'
app.errorbox(message, title)
**Make question**
^^^^^^^^^^^^^^^^^
.. code-block:: python
message = 'Is easy Python?'
title = 'My App'
result = app.question(message, title)
app.msgbox(result)
**InputBox**
^^^^^^^^^^^^
* Normal data
.. code-block:: python
message = 'Type your name'
default = ''
title = 'My App'
result = app.inputbox(message, default, title)
app.msgbox(result)
* Private data
.. code-block:: python
message = 'Type your password'
default = ''
title = 'My App'
echochar = "*"
result = app.inputbox(message, default, title, echochar)
app.msgbox(result)
**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)
**Paths and files**
^^^^^^^^^^^^^^^^^^^
* Get info path
.. code-block:: python
path = '/home/mau/myfile.ods'
p = app.paths(path)
app.debug(p.path)
app.debug(p.file_name)
app.debug(p.name)
app.debug(p.ext)
app.debug(p.url)
Or get information in a tuple
.. code-block:: python
path = '/home/mau/myfile.ods'
p = app.paths(path)
app.debug(p.info)
* Get path home
.. code-block:: python
path = app.paths.home
app.debug(path)
* Get path documents
.. code-block:: python
path = app.paths.documents
app.debug(path)
* Get path temp
.. code-block:: python
path = app.paths.temp_dir
app.debug(path)
.. _MRI: https://github.com/hanya/MRI

View File

@ -1,8 +0,0 @@
Library easymacro.py
====================
.. include:: 00_tools.rst
.. include:: 01_tools.rst

View File

@ -1,999 +0,0 @@
// Underscore.js 1.3.1
// (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc.
// Underscore is freely distributable under the MIT license.
// Portions of Underscore are inspired or borrowed from Prototype,
// Oliver Steele's Functional, and John Resig's Micro-Templating.
// For all details and documentation:
// http://documentcloud.github.com/underscore
(function() {
// Baseline setup
// --------------
// Establish the root object, `window` in the browser, or `global` on the server.
var root = this;
// Save the previous value of the `_` variable.
var previousUnderscore = root._;
// Establish the object that gets returned to break out of a loop iteration.
var breaker = {};
// Save bytes in the minified (but not gzipped) version:
var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype;
// Create quick reference variables for speed access to core prototypes.
var slice = ArrayProto.slice,
unshift = ArrayProto.unshift,
toString = ObjProto.toString,
hasOwnProperty = ObjProto.hasOwnProperty;
// All **ECMAScript 5** native function implementations that we hope to use
// are declared here.
var
nativeForEach = ArrayProto.forEach,
nativeMap = ArrayProto.map,
nativeReduce = ArrayProto.reduce,
nativeReduceRight = ArrayProto.reduceRight,
nativeFilter = ArrayProto.filter,
nativeEvery = ArrayProto.every,
nativeSome = ArrayProto.some,
nativeIndexOf = ArrayProto.indexOf,
nativeLastIndexOf = ArrayProto.lastIndexOf,
nativeIsArray = Array.isArray,
nativeKeys = Object.keys,
nativeBind = FuncProto.bind;
// Create a safe reference to the Underscore object for use below.
var _ = function(obj) { return new wrapper(obj); };
// Export the Underscore object for **Node.js**, with
// backwards-compatibility for the old `require()` API. If we're in
// the browser, add `_` as a global object via a string identifier,
// for Closure Compiler "advanced" mode.
if (typeof exports !== 'undefined') {
if (typeof module !== 'undefined' && module.exports) {
exports = module.exports = _;
}
exports._ = _;
} else {
root['_'] = _;
}
// Current version.
_.VERSION = '1.3.1';
// Collection Functions
// --------------------
// The cornerstone, an `each` implementation, aka `forEach`.
// Handles objects with the built-in `forEach`, arrays, and raw objects.
// Delegates to **ECMAScript 5**'s native `forEach` if available.
var each = _.each = _.forEach = function(obj, iterator, context) {
if (obj == null) return;
if (nativeForEach && obj.forEach === nativeForEach) {
obj.forEach(iterator, context);
} else if (obj.length === +obj.length) {
for (var i = 0, l = obj.length; i < l; i++) {
if (i in obj && iterator.call(context, obj[i], i, obj) === breaker) return;
}
} else {
for (var key in obj) {
if (_.has(obj, key)) {
if (iterator.call(context, obj[key], key, obj) === breaker) return;
}
}
}
};
// Return the results of applying the iterator to each element.
// Delegates to **ECMAScript 5**'s native `map` if available.
_.map = _.collect = function(obj, iterator, context) {
var results = [];
if (obj == null) return results;
if (nativeMap && obj.map === nativeMap) return obj.map(iterator, context);
each(obj, function(value, index, list) {
results[results.length] = iterator.call(context, value, index, list);
});
if (obj.length === +obj.length) results.length = obj.length;
return results;
};
// **Reduce** builds up a single result from a list of values, aka `inject`,
// or `foldl`. Delegates to **ECMAScript 5**'s native `reduce` if available.
_.reduce = _.foldl = _.inject = function(obj, iterator, memo, context) {
var initial = arguments.length > 2;
if (obj == null) obj = [];
if (nativeReduce && obj.reduce === nativeReduce) {
if (context) iterator = _.bind(iterator, context);
return initial ? obj.reduce(iterator, memo) : obj.reduce(iterator);
}
each(obj, function(value, index, list) {
if (!initial) {
memo = value;
initial = true;
} else {
memo = iterator.call(context, memo, value, index, list);
}
});
if (!initial) throw new TypeError('Reduce of empty array with no initial value');
return memo;
};
// The right-associative version of reduce, also known as `foldr`.
// Delegates to **ECMAScript 5**'s native `reduceRight` if available.
_.reduceRight = _.foldr = function(obj, iterator, memo, context) {
var initial = arguments.length > 2;
if (obj == null) obj = [];
if (nativeReduceRight && obj.reduceRight === nativeReduceRight) {
if (context) iterator = _.bind(iterator, context);
return initial ? obj.reduceRight(iterator, memo) : obj.reduceRight(iterator);
}
var reversed = _.toArray(obj).reverse();
if (context && !initial) iterator = _.bind(iterator, context);
return initial ? _.reduce(reversed, iterator, memo, context) : _.reduce(reversed, iterator);
};
// Return the first value which passes a truth test. Aliased as `detect`.
_.find = _.detect = function(obj, iterator, context) {
var result;
any(obj, function(value, index, list) {
if (iterator.call(context, value, index, list)) {
result = value;
return true;
}
});
return result;
};
// Return all the elements that pass a truth test.
// Delegates to **ECMAScript 5**'s native `filter` if available.
// Aliased as `select`.
_.filter = _.select = function(obj, iterator, context) {
var results = [];
if (obj == null) return results;
if (nativeFilter && obj.filter === nativeFilter) return obj.filter(iterator, context);
each(obj, function(value, index, list) {
if (iterator.call(context, value, index, list)) results[results.length] = value;
});
return results;
};
// Return all the elements for which a truth test fails.
_.reject = function(obj, iterator, context) {
var results = [];
if (obj == null) return results;
each(obj, function(value, index, list) {
if (!iterator.call(context, value, index, list)) results[results.length] = value;
});
return results;
};
// Determine whether all of the elements match a truth test.
// Delegates to **ECMAScript 5**'s native `every` if available.
// Aliased as `all`.
_.every = _.all = function(obj, iterator, context) {
var result = true;
if (obj == null) return result;
if (nativeEvery && obj.every === nativeEvery) return obj.every(iterator, context);
each(obj, function(value, index, list) {
if (!(result = result && iterator.call(context, value, index, list))) return breaker;
});
return result;
};
// Determine if at least one element in the object matches a truth test.
// Delegates to **ECMAScript 5**'s native `some` if available.
// Aliased as `any`.
var any = _.some = _.any = function(obj, iterator, context) {
iterator || (iterator = _.identity);
var result = false;
if (obj == null) return result;
if (nativeSome && obj.some === nativeSome) return obj.some(iterator, context);
each(obj, function(value, index, list) {
if (result || (result = iterator.call(context, value, index, list))) return breaker;
});
return !!result;
};
// Determine if a given value is included in the array or object using `===`.
// Aliased as `contains`.
_.include = _.contains = function(obj, target) {
var found = false;
if (obj == null) return found;
if (nativeIndexOf && obj.indexOf === nativeIndexOf) return obj.indexOf(target) != -1;
found = any(obj, function(value) {
return value === target;
});
return found;
};
// Invoke a method (with arguments) on every item in a collection.
_.invoke = function(obj, method) {
var args = slice.call(arguments, 2);
return _.map(obj, function(value) {
return (_.isFunction(method) ? method || value : value[method]).apply(value, args);
});
};
// Convenience version of a common use case of `map`: fetching a property.
_.pluck = function(obj, key) {
return _.map(obj, function(value){ return value[key]; });
};
// Return the maximum element or (element-based computation).
_.max = function(obj, iterator, context) {
if (!iterator && _.isArray(obj)) return Math.max.apply(Math, obj);
if (!iterator && _.isEmpty(obj)) return -Infinity;
var result = {computed : -Infinity};
each(obj, function(value, index, list) {
var computed = iterator ? iterator.call(context, value, index, list) : value;
computed >= result.computed && (result = {value : value, computed : computed});
});
return result.value;
};
// Return the minimum element (or element-based computation).
_.min = function(obj, iterator, context) {
if (!iterator && _.isArray(obj)) return Math.min.apply(Math, obj);
if (!iterator && _.isEmpty(obj)) return Infinity;
var result = {computed : Infinity};
each(obj, function(value, index, list) {
var computed = iterator ? iterator.call(context, value, index, list) : value;
computed < result.computed && (result = {value : value, computed : computed});
});
return result.value;
};
// Shuffle an array.
_.shuffle = function(obj) {
var shuffled = [], rand;
each(obj, function(value, index, list) {
if (index == 0) {
shuffled[0] = value;
} else {
rand = Math.floor(Math.random() * (index + 1));
shuffled[index] = shuffled[rand];
shuffled[rand] = value;
}
});
return shuffled;
};
// Sort the object's values by a criterion produced by an iterator.
_.sortBy = function(obj, iterator, context) {
return _.pluck(_.map(obj, function(value, index, list) {
return {
value : value,
criteria : iterator.call(context, value, index, list)
};
}).sort(function(left, right) {
var a = left.criteria, b = right.criteria;
return a < b ? -1 : a > b ? 1 : 0;
}), 'value');
};
// Groups the object's values by a criterion. Pass either a string attribute
// to group by, or a function that returns the criterion.
_.groupBy = function(obj, val) {
var result = {};
var iterator = _.isFunction(val) ? val : function(obj) { return obj[val]; };
each(obj, function(value, index) {
var key = iterator(value, index);
(result[key] || (result[key] = [])).push(value);
});
return result;
};
// Use a comparator function to figure out at what index an object should
// be inserted so as to maintain order. Uses binary search.
_.sortedIndex = function(array, obj, iterator) {
iterator || (iterator = _.identity);
var low = 0, high = array.length;
while (low < high) {
var mid = (low + high) >> 1;
iterator(array[mid]) < iterator(obj) ? low = mid + 1 : high = mid;
}
return low;
};
// Safely convert anything iterable into a real, live array.
_.toArray = function(iterable) {
if (!iterable) return [];
if (iterable.toArray) return iterable.toArray();
if (_.isArray(iterable)) return slice.call(iterable);
if (_.isArguments(iterable)) return slice.call(iterable);
return _.values(iterable);
};
// Return the number of elements in an object.
_.size = function(obj) {
return _.toArray(obj).length;
};
// Array Functions
// ---------------
// Get the first element of an array. Passing **n** will return the first N
// values in the array. Aliased as `head`. The **guard** check allows it to work
// with `_.map`.
_.first = _.head = function(array, n, guard) {
return (n != null) && !guard ? slice.call(array, 0, n) : array[0];
};
// Returns everything but the last entry of the array. Especcialy useful on
// the arguments object. Passing **n** will return all the values in
// the array, excluding the last N. The **guard** check allows it to work with
// `_.map`.
_.initial = function(array, n, guard) {
return slice.call(array, 0, array.length - ((n == null) || guard ? 1 : n));
};
// Get the last element of an array. Passing **n** will return the last N
// values in the array. The **guard** check allows it to work with `_.map`.
_.last = function(array, n, guard) {
if ((n != null) && !guard) {
return slice.call(array, Math.max(array.length - n, 0));
} else {
return array[array.length - 1];
}
};
// Returns everything but the first entry of the array. Aliased as `tail`.
// Especially useful on the arguments object. Passing an **index** will return
// the rest of the values in the array from that index onward. The **guard**
// check allows it to work with `_.map`.
_.rest = _.tail = function(array, index, guard) {
return slice.call(array, (index == null) || guard ? 1 : index);
};
// Trim out all falsy values from an array.
_.compact = function(array) {
return _.filter(array, function(value){ return !!value; });
};
// Return a completely flattened version of an array.
_.flatten = function(array, shallow) {
return _.reduce(array, function(memo, value) {
if (_.isArray(value)) return memo.concat(shallow ? value : _.flatten(value));
memo[memo.length] = value;
return memo;
}, []);
};
// Return a version of the array that does not contain the specified value(s).
_.without = function(array) {
return _.difference(array, slice.call(arguments, 1));
};
// Produce a duplicate-free version of the array. If the array has already
// been sorted, you have the option of using a faster algorithm.
// Aliased as `unique`.
_.uniq = _.unique = function(array, isSorted, iterator) {
var initial = iterator ? _.map(array, iterator) : array;
var result = [];
_.reduce(initial, function(memo, el, i) {
if (0 == i || (isSorted === true ? _.last(memo) != el : !_.include(memo, el))) {
memo[memo.length] = el;
result[result.length] = array[i];
}
return memo;
}, []);
return result;
};
// Produce an array that contains the union: each distinct element from all of
// the passed-in arrays.
_.union = function() {
return _.uniq(_.flatten(arguments, true));
};
// Produce an array that contains every item shared between all the
// passed-in arrays. (Aliased as "intersect" for back-compat.)
_.intersection = _.intersect = function(array) {
var rest = slice.call(arguments, 1);
return _.filter(_.uniq(array), function(item) {
return _.every(rest, function(other) {
return _.indexOf(other, item) >= 0;
});
});
};
// Take the difference between one array and a number of other arrays.
// Only the elements present in just the first array will remain.
_.difference = function(array) {
var rest = _.flatten(slice.call(arguments, 1));
return _.filter(array, function(value){ return !_.include(rest, value); });
};
// Zip together multiple lists into a single array -- elements that share
// an index go together.
_.zip = function() {
var args = slice.call(arguments);
var length = _.max(_.pluck(args, 'length'));
var results = new Array(length);
for (var i = 0; i < length; i++) results[i] = _.pluck(args, "" + i);
return results;
};
// If the browser doesn't supply us with indexOf (I'm looking at you, **MSIE**),
// we need this function. Return the position of the first occurrence of an
// item in an array, or -1 if the item is not included in the array.
// Delegates to **ECMAScript 5**'s native `indexOf` if available.
// If the array is large and already in sort order, pass `true`
// for **isSorted** to use binary search.
_.indexOf = function(array, item, isSorted) {
if (array == null) return -1;
var i, l;
if (isSorted) {
i = _.sortedIndex(array, item);
return array[i] === item ? i : -1;
}
if (nativeIndexOf && array.indexOf === nativeIndexOf) return array.indexOf(item);
for (i = 0, l = array.length; i < l; i++) if (i in array && array[i] === item) return i;
return -1;
};
// Delegates to **ECMAScript 5**'s native `lastIndexOf` if available.
_.lastIndexOf = function(array, item) {
if (array == null) return -1;
if (nativeLastIndexOf && array.lastIndexOf === nativeLastIndexOf) return array.lastIndexOf(item);
var i = array.length;
while (i--) if (i in array && array[i] === item) return i;
return -1;
};
// Generate an integer Array containing an arithmetic progression. A port of
// the native Python `range()` function. See
// [the Python documentation](http://docs.python.org/library/functions.html#range).
_.range = function(start, stop, step) {
if (arguments.length <= 1) {
stop = start || 0;
start = 0;
}
step = arguments[2] || 1;
var len = Math.max(Math.ceil((stop - start) / step), 0);
var idx = 0;
var range = new Array(len);
while(idx < len) {
range[idx++] = start;
start += step;
}
return range;
};
// Function (ahem) Functions
// ------------------
// Reusable constructor function for prototype setting.
var ctor = function(){};
// Create a function bound to a given object (assigning `this`, and arguments,
// optionally). Binding with arguments is also known as `curry`.
// Delegates to **ECMAScript 5**'s native `Function.bind` if available.
// We check for `func.bind` first, to fail fast when `func` is undefined.
_.bind = function bind(func, context) {
var bound, args;
if (func.bind === nativeBind && nativeBind) return nativeBind.apply(func, slice.call(arguments, 1));
if (!_.isFunction(func)) throw new TypeError;
args = slice.call(arguments, 2);
return bound = function() {
if (!(this instanceof bound)) return func.apply(context, args.concat(slice.call(arguments)));
ctor.prototype = func.prototype;
var self = new ctor;
var result = func.apply(self, args.concat(slice.call(arguments)));
if (Object(result) === result) return result;
return self;
};
};
// Bind all of an object's methods to that object. Useful for ensuring that
// all callbacks defined on an object belong to it.
_.bindAll = function(obj) {
var funcs = slice.call(arguments, 1);
if (funcs.length == 0) funcs = _.functions(obj);
each(funcs, function(f) { obj[f] = _.bind(obj[f], obj); });
return obj;
};
// Memoize an expensive function by storing its results.
_.memoize = function(func, hasher) {
var memo = {};
hasher || (hasher = _.identity);
return function() {
var key = hasher.apply(this, arguments);
return _.has(memo, key) ? memo[key] : (memo[key] = func.apply(this, arguments));
};
};
// Delays a function for the given number of milliseconds, and then calls
// it with the arguments supplied.
_.delay = function(func, wait) {
var args = slice.call(arguments, 2);
return setTimeout(function(){ return func.apply(func, args); }, wait);
};
// Defers a function, scheduling it to run after the current call stack has
// cleared.
_.defer = function(func) {
return _.delay.apply(_, [func, 1].concat(slice.call(arguments, 1)));
};
// Returns a function, that, when invoked, will only be triggered at most once
// during a given window of time.
_.throttle = function(func, wait) {
var context, args, timeout, throttling, more;
var whenDone = _.debounce(function(){ more = throttling = false; }, wait);
return function() {
context = this; args = arguments;
var later = function() {
timeout = null;
if (more) func.apply(context, args);
whenDone();
};
if (!timeout) timeout = setTimeout(later, wait);
if (throttling) {
more = true;
} else {
func.apply(context, args);
}
whenDone();
throttling = true;
};
};
// Returns a function, that, as long as it continues to be invoked, will not
// be triggered. The function will be called after it stops being called for
// N milliseconds.
_.debounce = function(func, wait) {
var timeout;
return function() {
var context = this, args = arguments;
var later = function() {
timeout = null;
func.apply(context, args);
};
clearTimeout(timeout);
timeout = setTimeout(later, wait);
};
};
// Returns a function that will be executed at most one time, no matter how
// often you call it. Useful for lazy initialization.
_.once = function(func) {
var ran = false, memo;
return function() {
if (ran) return memo;
ran = true;
return memo = func.apply(this, arguments);
};
};
// Returns the first function passed as an argument to the second,
// allowing you to adjust arguments, run code before and after, and
// conditionally execute the original function.
_.wrap = function(func, wrapper) {
return function() {
var args = [func].concat(slice.call(arguments, 0));
return wrapper.apply(this, args);
};
};
// Returns a function that is the composition of a list of functions, each
// consuming the return value of the function that follows.
_.compose = function() {
var funcs = arguments;
return function() {
var args = arguments;
for (var i = funcs.length - 1; i >= 0; i--) {
args = [funcs[i].apply(this, args)];
}
return args[0];
};
};
// Returns a function that will only be executed after being called N times.
_.after = function(times, func) {
if (times <= 0) return func();
return function() {
if (--times < 1) { return func.apply(this, arguments); }
};
};
// Object Functions
// ----------------
// Retrieve the names of an object's properties.
// Delegates to **ECMAScript 5**'s native `Object.keys`
_.keys = nativeKeys || function(obj) {
if (obj !== Object(obj)) throw new TypeError('Invalid object');
var keys = [];
for (var key in obj) if (_.has(obj, key)) keys[keys.length] = key;
return keys;
};
// Retrieve the values of an object's properties.
_.values = function(obj) {
return _.map(obj, _.identity);
};
// Return a sorted list of the function names available on the object.
// Aliased as `methods`
_.functions = _.methods = function(obj) {
var names = [];
for (var key in obj) {
if (_.isFunction(obj[key])) names.push(key);
}
return names.sort();
};
// Extend a given object with all the properties in passed-in object(s).
_.extend = function(obj) {
each(slice.call(arguments, 1), function(source) {
for (var prop in source) {
obj[prop] = source[prop];
}
});
return obj;
};
// Fill in a given object with default properties.
_.defaults = function(obj) {
each(slice.call(arguments, 1), function(source) {
for (var prop in source) {
if (obj[prop] == null) obj[prop] = source[prop];
}
});
return obj;
};
// Create a (shallow-cloned) duplicate of an object.
_.clone = function(obj) {
if (!_.isObject(obj)) return obj;
return _.isArray(obj) ? obj.slice() : _.extend({}, obj);
};
// Invokes interceptor with the obj, and then returns obj.
// The primary purpose of this method is to "tap into" a method chain, in
// order to perform operations on intermediate results within the chain.
_.tap = function(obj, interceptor) {
interceptor(obj);
return obj;
};
// Internal recursive comparison function.
function eq(a, b, stack) {
// Identical objects are equal. `0 === -0`, but they aren't identical.
// See the Harmony `egal` proposal: http://wiki.ecmascript.org/doku.php?id=harmony:egal.
if (a === b) return a !== 0 || 1 / a == 1 / b;
// A strict comparison is necessary because `null == undefined`.
if (a == null || b == null) return a === b;
// Unwrap any wrapped objects.
if (a._chain) a = a._wrapped;
if (b._chain) b = b._wrapped;
// Invoke a custom `isEqual` method if one is provided.
if (a.isEqual && _.isFunction(a.isEqual)) return a.isEqual(b);
if (b.isEqual && _.isFunction(b.isEqual)) return b.isEqual(a);
// Compare `[[Class]]` names.
var className = toString.call(a);
if (className != toString.call(b)) return false;
switch (className) {
// Strings, numbers, dates, and booleans are compared by value.
case '[object String]':
// Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is
// equivalent to `new String("5")`.
return a == String(b);
case '[object Number]':
// `NaN`s are equivalent, but non-reflexive. An `egal` comparison is performed for
// other numeric values.
return a != +a ? b != +b : (a == 0 ? 1 / a == 1 / b : a == +b);
case '[object Date]':
case '[object Boolean]':
// Coerce dates and booleans to numeric primitive values. Dates are compared by their
// millisecond representations. Note that invalid dates with millisecond representations
// of `NaN` are not equivalent.
return +a == +b;
// RegExps are compared by their source patterns and flags.
case '[object RegExp]':
return a.source == b.source &&
a.global == b.global &&
a.multiline == b.multiline &&
a.ignoreCase == b.ignoreCase;
}
if (typeof a != 'object' || typeof b != 'object') return false;
// Assume equality for cyclic structures. The algorithm for detecting cyclic
// structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`.
var length = stack.length;
while (length--) {
// Linear search. Performance is inversely proportional to the number of
// unique nested structures.
if (stack[length] == a) return true;
}
// Add the first object to the stack of traversed objects.
stack.push(a);
var size = 0, result = true;
// Recursively compare objects and arrays.
if (className == '[object Array]') {
// Compare array lengths to determine if a deep comparison is necessary.
size = a.length;
result = size == b.length;
if (result) {
// Deep compare the contents, ignoring non-numeric properties.
while (size--) {
// Ensure commutative equality for sparse arrays.
if (!(result = size in a == size in b && eq(a[size], b[size], stack))) break;
}
}
} else {
// Objects with different constructors are not equivalent.
if ('constructor' in a != 'constructor' in b || a.constructor != b.constructor) return false;
// Deep compare objects.
for (var key in a) {
if (_.has(a, key)) {
// Count the expected number of properties.
size++;
// Deep compare each member.
if (!(result = _.has(b, key) && eq(a[key], b[key], stack))) break;
}
}
// Ensure that both objects contain the same number of properties.
if (result) {
for (key in b) {
if (_.has(b, key) && !(size--)) break;
}
result = !size;
}
}
// Remove the first object from the stack of traversed objects.
stack.pop();
return result;
}
// Perform a deep comparison to check if two objects are equal.
_.isEqual = function(a, b) {
return eq(a, b, []);
};
// Is a given array, string, or object empty?
// An "empty" object has no enumerable own-properties.
_.isEmpty = function(obj) {
if (_.isArray(obj) || _.isString(obj)) return obj.length === 0;
for (var key in obj) if (_.has(obj, key)) return false;
return true;
};
// Is a given value a DOM element?
_.isElement = function(obj) {
return !!(obj && obj.nodeType == 1);
};
// Is a given value an array?
// Delegates to ECMA5's native Array.isArray
_.isArray = nativeIsArray || function(obj) {
return toString.call(obj) == '[object Array]';
};
// Is a given variable an object?
_.isObject = function(obj) {
return obj === Object(obj);
};
// Is a given variable an arguments object?
_.isArguments = function(obj) {
return toString.call(obj) == '[object Arguments]';
};
if (!_.isArguments(arguments)) {
_.isArguments = function(obj) {
return !!(obj && _.has(obj, 'callee'));
};
}
// Is a given value a function?
_.isFunction = function(obj) {
return toString.call(obj) == '[object Function]';
};
// Is a given value a string?
_.isString = function(obj) {
return toString.call(obj) == '[object String]';
};
// Is a given value a number?
_.isNumber = function(obj) {
return toString.call(obj) == '[object Number]';
};
// Is the given value `NaN`?
_.isNaN = function(obj) {
// `NaN` is the only value for which `===` is not reflexive.
return obj !== obj;
};
// Is a given value a boolean?
_.isBoolean = function(obj) {
return obj === true || obj === false || toString.call(obj) == '[object Boolean]';
};
// Is a given value a date?
_.isDate = function(obj) {
return toString.call(obj) == '[object Date]';
};
// Is the given value a regular expression?
_.isRegExp = function(obj) {
return toString.call(obj) == '[object RegExp]';
};
// Is a given value equal to null?
_.isNull = function(obj) {
return obj === null;
};
// Is a given variable undefined?
_.isUndefined = function(obj) {
return obj === void 0;
};
// Has own property?
_.has = function(obj, key) {
return hasOwnProperty.call(obj, key);
};
// Utility Functions
// -----------------
// Run Underscore.js in *noConflict* mode, returning the `_` variable to its
// previous owner. Returns a reference to the Underscore object.
_.noConflict = function() {
root._ = previousUnderscore;
return this;
};
// Keep the identity function around for default iterators.
_.identity = function(value) {
return value;
};
// Run a function **n** times.
_.times = function (n, iterator, context) {
for (var i = 0; i < n; i++) iterator.call(context, i);
};
// Escape a string for HTML interpolation.
_.escape = function(string) {
return (''+string).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#x27;').replace(/\//g,'&#x2F;');
};
// Add your own custom functions to the Underscore object, ensuring that
// they're correctly added to the OOP wrapper as well.
_.mixin = function(obj) {
each(_.functions(obj), function(name){
addToWrapper(name, _[name] = obj[name]);
});
};
// Generate a unique integer id (unique within the entire client session).
// Useful for temporary DOM ids.
var idCounter = 0;
_.uniqueId = function(prefix) {
var id = idCounter++;
return prefix ? prefix + id : id;
};
// By default, Underscore uses ERB-style template delimiters, change the
// following template settings to use alternative delimiters.
_.templateSettings = {
evaluate : /<%([\s\S]+?)%>/g,
interpolate : /<%=([\s\S]+?)%>/g,
escape : /<%-([\s\S]+?)%>/g
};
// When customizing `templateSettings`, if you don't want to define an
// interpolation, evaluation or escaping regex, we need one that is
// guaranteed not to match.
var noMatch = /.^/;
// Within an interpolation, evaluation, or escaping, remove HTML escaping
// that had been previously added.
var unescape = function(code) {
return code.replace(/\\\\/g, '\\').replace(/\\'/g, "'");
};
// JavaScript micro-templating, similar to John Resig's implementation.
// Underscore templating handles arbitrary delimiters, preserves whitespace,
// and correctly escapes quotes within interpolated code.
_.template = function(str, data) {
var c = _.templateSettings;
var tmpl = 'var __p=[],print=function(){__p.push.apply(__p,arguments);};' +
'with(obj||{}){__p.push(\'' +
str.replace(/\\/g, '\\\\')
.replace(/'/g, "\\'")
.replace(c.escape || noMatch, function(match, code) {
return "',_.escape(" + unescape(code) + "),'";
})
.replace(c.interpolate || noMatch, function(match, code) {
return "'," + unescape(code) + ",'";
})
.replace(c.evaluate || noMatch, function(match, code) {
return "');" + unescape(code).replace(/[\r\n\t]/g, ' ') + ";__p.push('";
})
.replace(/\r/g, '\\r')
.replace(/\n/g, '\\n')
.replace(/\t/g, '\\t')
+ "');}return __p.join('');";
var func = new Function('obj', '_', tmpl);
if (data) return func(data, _);
return function(data) {
return func.call(this, data, _);
};
};
// Add a "chain" function, which will delegate to the wrapper.
_.chain = function(obj) {
return _(obj).chain();
};
// The OOP Wrapper
// ---------------
// If Underscore is called as a function, it returns a wrapped object that
// can be used OO-style. This wrapper holds altered versions of all the
// underscore functions. Wrapped objects may be chained.
var wrapper = function(obj) { this._wrapped = obj; };
// Expose `wrapper.prototype` as `_.prototype`
_.prototype = wrapper.prototype;
// Helper function to continue chaining intermediate results.
var result = function(obj, chain) {
return chain ? _(obj).chain() : obj;
};
// A method to easily add functions to the OOP wrapper.
var addToWrapper = function(name, func) {
wrapper.prototype[name] = function() {
var args = slice.call(arguments);
unshift.call(args, this._wrapped);
return result(func.apply(_, args), this._chain);
};
};
// Add all of the Underscore functions to the wrapper object.
_.mixin(_);
// Add all mutator Array functions to the wrapper.
each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) {
var method = ArrayProto[name];
wrapper.prototype[name] = function() {
var wrapped = this._wrapped;
method.apply(wrapped, arguments);
var length = wrapped.length;
if ((name == 'shift' || name == 'splice') && length === 0) delete wrapped[0];
return result(wrapped, this._chain);
};
});
// Add all accessor Array functions to the wrapper.
each(['concat', 'join', 'slice'], function(name) {
var method = ArrayProto[name];
wrapper.prototype[name] = function() {
return result(method.apply(this._wrapped, arguments), this._chain);
};
});
// Start chaining a wrapped Underscore object.
wrapper.prototype.chain = function() {
this._chain = true;
return this;
};
// Extracts the result from a wrapped and chained object.
wrapper.prototype.value = function() {
return this._wrapped;
};
}).call(this);

View File

@ -1,31 +0,0 @@
// Underscore.js 1.3.1
// (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc.
// Underscore is freely distributable under the MIT license.
// Portions of Underscore are inspired or borrowed from Prototype,
// Oliver Steele's Functional, and John Resig's Micro-Templating.
// For all details and documentation:
// http://documentcloud.github.com/underscore
(function(){function q(a,c,d){if(a===c)return a!==0||1/a==1/c;if(a==null||c==null)return a===c;if(a._chain)a=a._wrapped;if(c._chain)c=c._wrapped;if(a.isEqual&&b.isFunction(a.isEqual))return a.isEqual(c);if(c.isEqual&&b.isFunction(c.isEqual))return c.isEqual(a);var e=l.call(a);if(e!=l.call(c))return false;switch(e){case "[object String]":return a==String(c);case "[object Number]":return a!=+a?c!=+c:a==0?1/a==1/c:a==+c;case "[object Date]":case "[object Boolean]":return+a==+c;case "[object RegExp]":return a.source==
c.source&&a.global==c.global&&a.multiline==c.multiline&&a.ignoreCase==c.ignoreCase}if(typeof a!="object"||typeof c!="object")return false;for(var f=d.length;f--;)if(d[f]==a)return true;d.push(a);var f=0,g=true;if(e=="[object Array]"){if(f=a.length,g=f==c.length)for(;f--;)if(!(g=f in a==f in c&&q(a[f],c[f],d)))break}else{if("constructor"in a!="constructor"in c||a.constructor!=c.constructor)return false;for(var h in a)if(b.has(a,h)&&(f++,!(g=b.has(c,h)&&q(a[h],c[h],d))))break;if(g){for(h in c)if(b.has(c,
h)&&!f--)break;g=!f}}d.pop();return g}var r=this,G=r._,n={},k=Array.prototype,o=Object.prototype,i=k.slice,H=k.unshift,l=o.toString,I=o.hasOwnProperty,w=k.forEach,x=k.map,y=k.reduce,z=k.reduceRight,A=k.filter,B=k.every,C=k.some,p=k.indexOf,D=k.lastIndexOf,o=Array.isArray,J=Object.keys,s=Function.prototype.bind,b=function(a){return new m(a)};if(typeof exports!=="undefined"){if(typeof module!=="undefined"&&module.exports)exports=module.exports=b;exports._=b}else r._=b;b.VERSION="1.3.1";var j=b.each=
b.forEach=function(a,c,d){if(a!=null)if(w&&a.forEach===w)a.forEach(c,d);else if(a.length===+a.length)for(var e=0,f=a.length;e<f;e++){if(e in a&&c.call(d,a[e],e,a)===n)break}else for(e in a)if(b.has(a,e)&&c.call(d,a[e],e,a)===n)break};b.map=b.collect=function(a,c,b){var e=[];if(a==null)return e;if(x&&a.map===x)return a.map(c,b);j(a,function(a,g,h){e[e.length]=c.call(b,a,g,h)});if(a.length===+a.length)e.length=a.length;return e};b.reduce=b.foldl=b.inject=function(a,c,d,e){var f=arguments.length>2;a==
null&&(a=[]);if(y&&a.reduce===y)return e&&(c=b.bind(c,e)),f?a.reduce(c,d):a.reduce(c);j(a,function(a,b,i){f?d=c.call(e,d,a,b,i):(d=a,f=true)});if(!f)throw new TypeError("Reduce of empty array with no initial value");return d};b.reduceRight=b.foldr=function(a,c,d,e){var f=arguments.length>2;a==null&&(a=[]);if(z&&a.reduceRight===z)return e&&(c=b.bind(c,e)),f?a.reduceRight(c,d):a.reduceRight(c);var g=b.toArray(a).reverse();e&&!f&&(c=b.bind(c,e));return f?b.reduce(g,c,d,e):b.reduce(g,c)};b.find=b.detect=
function(a,c,b){var e;E(a,function(a,g,h){if(c.call(b,a,g,h))return e=a,true});return e};b.filter=b.select=function(a,c,b){var e=[];if(a==null)return e;if(A&&a.filter===A)return a.filter(c,b);j(a,function(a,g,h){c.call(b,a,g,h)&&(e[e.length]=a)});return e};b.reject=function(a,c,b){var e=[];if(a==null)return e;j(a,function(a,g,h){c.call(b,a,g,h)||(e[e.length]=a)});return e};b.every=b.all=function(a,c,b){var e=true;if(a==null)return e;if(B&&a.every===B)return a.every(c,b);j(a,function(a,g,h){if(!(e=
e&&c.call(b,a,g,h)))return n});return e};var E=b.some=b.any=function(a,c,d){c||(c=b.identity);var e=false;if(a==null)return e;if(C&&a.some===C)return a.some(c,d);j(a,function(a,b,h){if(e||(e=c.call(d,a,b,h)))return n});return!!e};b.include=b.contains=function(a,c){var b=false;if(a==null)return b;return p&&a.indexOf===p?a.indexOf(c)!=-1:b=E(a,function(a){return a===c})};b.invoke=function(a,c){var d=i.call(arguments,2);return b.map(a,function(a){return(b.isFunction(c)?c||a:a[c]).apply(a,d)})};b.pluck=
function(a,c){return b.map(a,function(a){return a[c]})};b.max=function(a,c,d){if(!c&&b.isArray(a))return Math.max.apply(Math,a);if(!c&&b.isEmpty(a))return-Infinity;var e={computed:-Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;b>=e.computed&&(e={value:a,computed:b})});return e.value};b.min=function(a,c,d){if(!c&&b.isArray(a))return Math.min.apply(Math,a);if(!c&&b.isEmpty(a))return Infinity;var e={computed:Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;b<e.computed&&(e={value:a,computed:b})});
return e.value};b.shuffle=function(a){var b=[],d;j(a,function(a,f){f==0?b[0]=a:(d=Math.floor(Math.random()*(f+1)),b[f]=b[d],b[d]=a)});return b};b.sortBy=function(a,c,d){return b.pluck(b.map(a,function(a,b,g){return{value:a,criteria:c.call(d,a,b,g)}}).sort(function(a,b){var c=a.criteria,d=b.criteria;return c<d?-1:c>d?1:0}),"value")};b.groupBy=function(a,c){var d={},e=b.isFunction(c)?c:function(a){return a[c]};j(a,function(a,b){var c=e(a,b);(d[c]||(d[c]=[])).push(a)});return d};b.sortedIndex=function(a,
c,d){d||(d=b.identity);for(var e=0,f=a.length;e<f;){var g=e+f>>1;d(a[g])<d(c)?e=g+1:f=g}return e};b.toArray=function(a){return!a?[]:a.toArray?a.toArray():b.isArray(a)?i.call(a):b.isArguments(a)?i.call(a):b.values(a)};b.size=function(a){return b.toArray(a).length};b.first=b.head=function(a,b,d){return b!=null&&!d?i.call(a,0,b):a[0]};b.initial=function(a,b,d){return i.call(a,0,a.length-(b==null||d?1:b))};b.last=function(a,b,d){return b!=null&&!d?i.call(a,Math.max(a.length-b,0)):a[a.length-1]};b.rest=
b.tail=function(a,b,d){return i.call(a,b==null||d?1:b)};b.compact=function(a){return b.filter(a,function(a){return!!a})};b.flatten=function(a,c){return b.reduce(a,function(a,e){if(b.isArray(e))return a.concat(c?e:b.flatten(e));a[a.length]=e;return a},[])};b.without=function(a){return b.difference(a,i.call(arguments,1))};b.uniq=b.unique=function(a,c,d){var d=d?b.map(a,d):a,e=[];b.reduce(d,function(d,g,h){if(0==h||(c===true?b.last(d)!=g:!b.include(d,g)))d[d.length]=g,e[e.length]=a[h];return d},[]);
return e};b.union=function(){return b.uniq(b.flatten(arguments,true))};b.intersection=b.intersect=function(a){var c=i.call(arguments,1);return b.filter(b.uniq(a),function(a){return b.every(c,function(c){return b.indexOf(c,a)>=0})})};b.difference=function(a){var c=b.flatten(i.call(arguments,1));return b.filter(a,function(a){return!b.include(c,a)})};b.zip=function(){for(var a=i.call(arguments),c=b.max(b.pluck(a,"length")),d=Array(c),e=0;e<c;e++)d[e]=b.pluck(a,""+e);return d};b.indexOf=function(a,c,
d){if(a==null)return-1;var e;if(d)return d=b.sortedIndex(a,c),a[d]===c?d:-1;if(p&&a.indexOf===p)return a.indexOf(c);for(d=0,e=a.length;d<e;d++)if(d in a&&a[d]===c)return d;return-1};b.lastIndexOf=function(a,b){if(a==null)return-1;if(D&&a.lastIndexOf===D)return a.lastIndexOf(b);for(var d=a.length;d--;)if(d in a&&a[d]===b)return d;return-1};b.range=function(a,b,d){arguments.length<=1&&(b=a||0,a=0);for(var d=arguments[2]||1,e=Math.max(Math.ceil((b-a)/d),0),f=0,g=Array(e);f<e;)g[f++]=a,a+=d;return g};
var F=function(){};b.bind=function(a,c){var d,e;if(a.bind===s&&s)return s.apply(a,i.call(arguments,1));if(!b.isFunction(a))throw new TypeError;e=i.call(arguments,2);return d=function(){if(!(this instanceof d))return a.apply(c,e.concat(i.call(arguments)));F.prototype=a.prototype;var b=new F,g=a.apply(b,e.concat(i.call(arguments)));return Object(g)===g?g:b}};b.bindAll=function(a){var c=i.call(arguments,1);c.length==0&&(c=b.functions(a));j(c,function(c){a[c]=b.bind(a[c],a)});return a};b.memoize=function(a,
c){var d={};c||(c=b.identity);return function(){var e=c.apply(this,arguments);return b.has(d,e)?d[e]:d[e]=a.apply(this,arguments)}};b.delay=function(a,b){var d=i.call(arguments,2);return setTimeout(function(){return a.apply(a,d)},b)};b.defer=function(a){return b.delay.apply(b,[a,1].concat(i.call(arguments,1)))};b.throttle=function(a,c){var d,e,f,g,h,i=b.debounce(function(){h=g=false},c);return function(){d=this;e=arguments;var b;f||(f=setTimeout(function(){f=null;h&&a.apply(d,e);i()},c));g?h=true:
a.apply(d,e);i();g=true}};b.debounce=function(a,b){var d;return function(){var e=this,f=arguments;clearTimeout(d);d=setTimeout(function(){d=null;a.apply(e,f)},b)}};b.once=function(a){var b=false,d;return function(){if(b)return d;b=true;return d=a.apply(this,arguments)}};b.wrap=function(a,b){return function(){var d=[a].concat(i.call(arguments,0));return b.apply(this,d)}};b.compose=function(){var a=arguments;return function(){for(var b=arguments,d=a.length-1;d>=0;d--)b=[a[d].apply(this,b)];return b[0]}};
b.after=function(a,b){return a<=0?b():function(){if(--a<1)return b.apply(this,arguments)}};b.keys=J||function(a){if(a!==Object(a))throw new TypeError("Invalid object");var c=[],d;for(d in a)b.has(a,d)&&(c[c.length]=d);return c};b.values=function(a){return b.map(a,b.identity)};b.functions=b.methods=function(a){var c=[],d;for(d in a)b.isFunction(a[d])&&c.push(d);return c.sort()};b.extend=function(a){j(i.call(arguments,1),function(b){for(var d in b)a[d]=b[d]});return a};b.defaults=function(a){j(i.call(arguments,
1),function(b){for(var d in b)a[d]==null&&(a[d]=b[d])});return a};b.clone=function(a){return!b.isObject(a)?a:b.isArray(a)?a.slice():b.extend({},a)};b.tap=function(a,b){b(a);return a};b.isEqual=function(a,b){return q(a,b,[])};b.isEmpty=function(a){if(b.isArray(a)||b.isString(a))return a.length===0;for(var c in a)if(b.has(a,c))return false;return true};b.isElement=function(a){return!!(a&&a.nodeType==1)};b.isArray=o||function(a){return l.call(a)=="[object Array]"};b.isObject=function(a){return a===Object(a)};
b.isArguments=function(a){return l.call(a)=="[object Arguments]"};if(!b.isArguments(arguments))b.isArguments=function(a){return!(!a||!b.has(a,"callee"))};b.isFunction=function(a){return l.call(a)=="[object Function]"};b.isString=function(a){return l.call(a)=="[object String]"};b.isNumber=function(a){return l.call(a)=="[object Number]"};b.isNaN=function(a){return a!==a};b.isBoolean=function(a){return a===true||a===false||l.call(a)=="[object Boolean]"};b.isDate=function(a){return l.call(a)=="[object Date]"};
b.isRegExp=function(a){return l.call(a)=="[object RegExp]"};b.isNull=function(a){return a===null};b.isUndefined=function(a){return a===void 0};b.has=function(a,b){return I.call(a,b)};b.noConflict=function(){r._=G;return this};b.identity=function(a){return a};b.times=function(a,b,d){for(var e=0;e<a;e++)b.call(d,e)};b.escape=function(a){return(""+a).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;").replace(/\//g,"&#x2F;")};b.mixin=function(a){j(b.functions(a),
function(c){K(c,b[c]=a[c])})};var L=0;b.uniqueId=function(a){var b=L++;return a?a+b:b};b.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var t=/.^/,u=function(a){return a.replace(/\\\\/g,"\\").replace(/\\'/g,"'")};b.template=function(a,c){var d=b.templateSettings,d="var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('"+a.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(d.escape||t,function(a,b){return"',_.escape("+
u(b)+"),'"}).replace(d.interpolate||t,function(a,b){return"',"+u(b)+",'"}).replace(d.evaluate||t,function(a,b){return"');"+u(b).replace(/[\r\n\t]/g," ")+";__p.push('"}).replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/\t/g,"\\t")+"');}return __p.join('');",e=new Function("obj","_",d);return c?e(c,b):function(a){return e.call(this,a,b)}};b.chain=function(a){return b(a).chain()};var m=function(a){this._wrapped=a};b.prototype=m.prototype;var v=function(a,c){return c?b(a).chain():a},K=function(a,c){m.prototype[a]=
function(){var a=i.call(arguments);H.call(a,this._wrapped);return v(c.apply(b,a),this._chain)}};b.mixin(b);j("pop,push,reverse,shift,sort,splice,unshift".split(","),function(a){var b=k[a];m.prototype[a]=function(){var d=this._wrapped;b.apply(d,arguments);var e=d.length;(a=="shift"||a=="splice")&&e===0&&delete d[0];return v(d,this._chain)}});j(["concat","join","slice"],function(a){var b=k[a];m.prototype[a]=function(){return v(b.apply(this._wrapped,arguments),this._chain)}});m.prototype.chain=function(){this._chain=
true;return this};m.prototype.value=function(){return this._wrapped}}).call(this);

View File

@ -1,284 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>1.2) Tools &#8212; ZAZ documentation</title>
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../_static/alabaster.css" type="text/css" />
<script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/doctools.js"></script>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="stylesheet" href="../_static/custom.css" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
</head><body>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="tools">
<h1>1.2) Tools<a class="headerlink" href="#tools" title="Permalink to this headline"></a></h1>
<p>Remember, always import library.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">easymacro</span> <span class="k">as</span> <span class="nn">app</span>
</pre></div>
</div>
</div>
<div class="section" id="info-from-pc">
<h1><strong>Info from PC</strong><a class="headerlink" href="#info-from-pc" title="Permalink to this headline"></a></h1>
<ul class="simple">
<li><p>Operate system</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">app</span><span class="o">.</span><span class="n">OS</span><span class="p">)</span>
</pre></div>
</div>
<ul class="simple">
<li><p>Current user</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">app</span><span class="o">.</span><span class="n">USER</span><span class="p">)</span>
</pre></div>
</div>
<ul class="simple">
<li><p>Name PC</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">app</span><span class="o">.</span><span class="n">PC</span><span class="p">)</span>
</pre></div>
</div>
<ul class="simple">
<li><p>Name desktop, only GNU/Linux</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">app</span><span class="o">.</span><span class="n">DESKTOP</span><span class="p">)</span>
</pre></div>
</div>
<ul class="simple">
<li><p>Language</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">app</span><span class="o">.</span><span class="n">LANG</span><span class="p">)</span>
</pre></div>
</div>
<ul class="simple">
<li><p>Language with variant</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">app</span><span class="o">.</span><span class="n">LANGUAGE</span><span class="p">)</span>
</pre></div>
</div>
<ul class="simple">
<li><p>Application name</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">app</span><span class="o">.</span><span class="n">NAME</span><span class="p">)</span>
</pre></div>
</div>
<ul class="simple">
<li><p>Application version</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">app</span><span class="o">.</span><span class="n">VERSION</span><span class="p">)</span>
</pre></div>
</div>
<ul class="simple">
<li><p>In Windows</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">app</span><span class="o">.</span><span class="n">IS_WIN</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="message-box">
<h1><strong>Message box</strong><a class="headerlink" href="#message-box" title="Permalink to this headline"></a></h1>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">app</span><span class="o">.</span><span class="n">IS_WIN</span><span class="p">,</span> <span class="s1">&#39;My Macro&#39;</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="show-warning">
<h1><strong>Show warning</strong><a class="headerlink" href="#show-warning" title="Permalink to this headline"></a></h1>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">message</span> <span class="o">=</span> <span class="s1">&#39;Caution, this action is dangerous&#39;</span>
<span class="n">title</span> <span class="o">=</span> <span class="s1">&#39;My App&#39;</span>
<span class="n">app</span><span class="o">.</span><span class="n">warning</span><span class="p">(</span><span class="n">message</span><span class="p">,</span> <span class="n">title</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="show-error-box">
<h1><strong>Show error box</strong><a class="headerlink" href="#show-error-box" title="Permalink to this headline"></a></h1>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">message</span> <span class="o">=</span> <span class="s1">&#39;ERROR: Contact technical support&#39;</span>
<span class="n">title</span> <span class="o">=</span> <span class="s1">&#39;My App&#39;</span>
<span class="n">app</span><span class="o">.</span><span class="n">errorbox</span><span class="p">(</span><span class="n">message</span><span class="p">,</span> <span class="n">title</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="make-question">
<h1><strong>Make question</strong><a class="headerlink" href="#make-question" title="Permalink to this headline"></a></h1>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">message</span> <span class="o">=</span> <span class="s1">&#39;Is easy Python?&#39;</span>
<span class="n">title</span> <span class="o">=</span> <span class="s1">&#39;My App&#39;</span>
<span class="n">result</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">question</span><span class="p">(</span><span class="n">message</span><span class="p">,</span> <span class="n">title</span><span class="p">)</span>
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">result</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="inputbox">
<h1><strong>InputBox</strong><a class="headerlink" href="#inputbox" title="Permalink to this headline"></a></h1>
<ul class="simple">
<li><p>Normal data</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">message</span> <span class="o">=</span> <span class="s1">&#39;Type your name&#39;</span>
<span class="n">default</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
<span class="n">title</span> <span class="o">=</span> <span class="s1">&#39;My App&#39;</span>
<span class="n">result</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">inputbox</span><span class="p">(</span><span class="n">message</span><span class="p">,</span> <span class="n">default</span><span class="p">,</span> <span class="n">title</span><span class="p">)</span>
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">result</span><span class="p">)</span>
</pre></div>
</div>
<ul class="simple">
<li><p>Private data</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">message</span> <span class="o">=</span> <span class="s1">&#39;Type your password&#39;</span>
<span class="n">default</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
<span class="n">title</span> <span class="o">=</span> <span class="s1">&#39;My App&#39;</span>
<span class="n">echochar</span> <span class="o">=</span> <span class="s2">&quot;*&quot;</span>
<span class="n">result</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">inputbox</span><span class="p">(</span><span class="n">message</span><span class="p">,</span> <span class="n">default</span><span class="p">,</span> <span class="n">title</span><span class="p">,</span> <span class="n">echochar</span><span class="p">)</span>
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">result</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="create-instances">
<h1><strong>Create instances</strong><a class="headerlink" href="#create-instances" title="Permalink to this headline"></a></h1>
<ul class="simple">
<li><p>Instances without context</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">toolkit</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">create_instance</span><span class="p">(</span><span class="s2">&quot;com.sun.star.awt.Toolkit&quot;</span><span class="p">)</span>
</pre></div>
</div>
<ul class="simple">
<li><p>Instances with context</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">service</span> <span class="o">=</span> <span class="s1">&#39;com.sun.star.awt.DialogProvider2&#39;</span>
<span class="n">dialog</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">create_instance</span><span class="p">(</span><span class="n">service</span><span class="p">,</span> <span class="kc">True</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="paths-and-files">
<h1><strong>Paths and files</strong><a class="headerlink" href="#paths-and-files" title="Permalink to this headline"></a></h1>
<ul class="simple">
<li><p>Get info path</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">path</span> <span class="o">=</span> <span class="s1">&#39;/home/mau/myfile.ods&#39;</span>
<span class="n">p</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">paths</span><span class="p">(</span><span class="n">path</span><span class="p">)</span>
<span class="n">app</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="n">p</span><span class="o">.</span><span class="n">path</span><span class="p">)</span>
<span class="n">app</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="n">p</span><span class="o">.</span><span class="n">file_name</span><span class="p">)</span>
<span class="n">app</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="n">p</span><span class="o">.</span><span class="n">name</span><span class="p">)</span>
<span class="n">app</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="n">p</span><span class="o">.</span><span class="n">ext</span><span class="p">)</span>
<span class="n">app</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="n">p</span><span class="o">.</span><span class="n">url</span><span class="p">)</span>
</pre></div>
</div>
<p>Or get information in a tuple</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">path</span> <span class="o">=</span> <span class="s1">&#39;/home/mau/myfile.ods&#39;</span>
<span class="n">p</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">paths</span><span class="p">(</span><span class="n">path</span><span class="p">)</span>
<span class="n">app</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="n">p</span><span class="o">.</span><span class="n">info</span><span class="p">)</span>
</pre></div>
</div>
<ul class="simple">
<li><p>Get path home</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">path</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">paths</span><span class="o">.</span><span class="n">home</span>
<span class="n">app</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="n">path</span><span class="p">)</span>
</pre></div>
</div>
<ul class="simple">
<li><p>Get path documents</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">path</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">paths</span><span class="o">.</span><span class="n">documents</span>
<span class="n">app</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="n">path</span><span class="p">)</span>
</pre></div>
</div>
<ul class="simple">
<li><p>Get path temp</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">path</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">paths</span><span class="o">.</span><span class="n">temp_dir</span>
<span class="n">app</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="n">path</span><span class="p">)</span>
</pre></div>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h1 class="logo"><a href="../index.html">ZAZ</a></h1>
<h3>Navigation</h3>
<p class="caption"><span class="caption-text">Contents:</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="intro.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="config.html">Configuration</a></li>
<li class="toctree-l1"><a class="reference internal" href="easymacro.html">Library easymacro.py</a></li>
</ul>
<div class="relations">
<h3>Related Topics</h3>
<ul>
<li><a href="../index.html">Documentation overview</a><ul>
</ul></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="../search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" />
<input type="submit" value="Go" />
</form>
</div>
</div>
<script>$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
&copy;2021, Mauricio Baeza.
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 3.4.3</a>
&amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
|
<a href="../_sources/main/01_tools.rst.txt"
rel="nofollow">Page source</a>
</div>
</body>
</html>

View File

@ -1,420 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Library easymacro.py &#8212; ZAZ documentation</title>
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../_static/alabaster.css" type="text/css" />
<script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/doctools.js"></script>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="prev" title="Configuration" href="config.html" />
<link rel="stylesheet" href="../_static/custom.css" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
</head><body>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="library-easymacro-py">
<h1>Library easymacro.py<a class="headerlink" href="#library-easymacro-py" title="Permalink to this headline"></a></h1>
<p><strong>easymacro.py</strong> its 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.</p>
<p>Probably, your will be more happy if used it. :)</p>
<p>You can used <strong>easymacro.py</strong> with any extension or directly in your macros.</p>
<div class="section" id="tools">
<h2>1) Tools<a class="headerlink" href="#tools" title="Permalink to this headline"></a></h2>
<div class="section" id="for-debug">
<h3>1.1) For debug<a class="headerlink" href="#for-debug" title="Permalink to this headline"></a></h3>
</div>
<div class="section" id="info-debug">
<h3><strong>INFO_DEBUG</strong><a class="headerlink" href="#info-debug" title="Permalink to this headline"></a></h3>
<p>Show info debug, show in message box.</p>
<p>If you have any problem in your code, you can <a class="reference external" href="https://git.cuates.net/elmau/zaz/issues">open issue</a> in this project,
always copy the information of INFO_DEBUG in your ticket.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">easymacro</span> <span class="k">as</span> <span class="nn">app</span>
<span class="k">def</span> <span class="nf">info</span><span class="p">():</span>
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">INFO_DEBUG</span><span class="p">)</span>
<span class="k">return</span>
</pre></div>
</div>
<p>Show in shell.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">easymacro</span> <span class="k">as</span> <span class="nn">app</span>
<span class="k">def</span> <span class="nf">info</span><span class="p">():</span>
<span class="n">app</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="n">INFO_DEBUG</span><span class="p">)</span>
<span class="k">return</span>
</pre></div>
</div>
</div>
<div class="section" id="log-error">
<h3><strong>Log error</strong><a class="headerlink" href="#log-error" title="Permalink to this headline"></a></h3>
<p>Show error message in shell.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">easymacro</span> <span class="k">as</span> <span class="nn">app</span>
<span class="k">def</span> <span class="nf">error</span><span class="p">():</span>
<span class="n">msg</span> <span class="o">=</span> <span class="s1">&#39;My error 500&#39;</span>
<span class="n">app</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span>
<span class="k">return</span>
</pre></div>
</div>
</div>
<div class="section" id="log-debug">
<h3><strong>Log debug</strong><a class="headerlink" href="#log-debug" title="Permalink to this headline"></a></h3>
<p>Show debug message in shell.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">easymacro</span> <span class="k">as</span> <span class="nn">app</span>
<span class="k">def</span> <span class="nf">error</span><span class="p">():</span>
<span class="n">msg</span> <span class="o">=</span> <span class="s1">&#39;Verify this data...&#39;</span>
<span class="n">app</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span>
<span class="k">return</span>
</pre></div>
</div>
</div>
<div class="section" id="log-info">
<h3><strong>Log info</strong><a class="headerlink" href="#log-info" title="Permalink to this headline"></a></h3>
<p>Show info message in shell.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">easymacro</span> <span class="k">as</span> <span class="nn">app</span>
<span class="k">def</span> <span class="nf">error</span><span class="p">():</span>
<span class="n">msg</span> <span class="o">=</span> <span class="s1">&#39;Start process...&#39;</span>
<span class="n">app</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span>
<span class="k">return</span>
</pre></div>
</div>
</div>
<div class="section" id="log-to-file">
<h3><strong>Log to file</strong><a class="headerlink" href="#log-to-file" title="Permalink to this headline"></a></h3>
<p>Save log to file, automatic add date and time.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">easymacro</span> <span class="k">as</span> <span class="nn">app</span>
<span class="k">def</span> <span class="nf">log</span><span class="p">():</span>
<span class="n">app</span><span class="o">.</span><span class="n">save_log</span><span class="p">(</span><span class="s1">&#39;/home/mau/log.txt&#39;</span><span class="p">,</span> <span class="s1">&#39;PyUNO&#39;</span><span class="p">)</span>
<span class="n">app</span><span class="o">.</span><span class="n">save_log</span><span class="p">(</span><span class="s1">&#39;/home/mau/log.txt&#39;</span><span class="p">,</span> <span class="n">app</span><span class="o">.</span><span class="n">INFO_DEBUG</span><span class="p">)</span>
<span class="k">return</span>
</pre></div>
</div>
</div>
<div class="section" id="message-box">
<h3><strong>Message box</strong><a class="headerlink" href="#message-box" title="Permalink to this headline"></a></h3>
<p>Show any data in message box</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">easymacro</span> <span class="k">as</span> <span class="nn">app</span>
<span class="k">def</span> <span class="nf">message</span><span class="p">():</span>
<span class="n">msg</span> <span class="o">=</span> <span class="s1">&#39;Please, save the planet&#39;</span>
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span>
<span class="n">msg</span> <span class="o">=</span> <span class="p">(</span><span class="s1">&#39;one&#39;</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="s1">&#39;three&#39;</span><span class="p">)</span>
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span>
<span class="n">msg</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;name&#39;</span><span class="p">:</span> <span class="s1">&#39;Teresa&#39;</span><span class="p">}</span>
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span>
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">app</span><span class="p">)</span>
<span class="k">return</span>
</pre></div>
</div>
</div>
<div class="section" id="catch-exceptions">
<h3><strong>Catch exceptions</strong><a class="headerlink" href="#catch-exceptions" title="Permalink to this headline"></a></h3>
<p>Sometimes, for difficult errors, you can catch exceptions.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">easymacro</span> <span class="k">as</span> <span class="nn">app</span>
<span class="nd">@app</span><span class="o">.</span><span class="n">catch_exception</span>
<span class="k">def</span> <span class="nf">test</span><span class="p">():</span>
<span class="n">r</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">/</span> <span class="mi">0</span>
<span class="k">return</span>
</pre></div>
</div>
<p>And not, not used you this function in production.</p>
</div>
<div class="section" id="call-mri">
<h3><strong>Call MRI</strong><a class="headerlink" href="#call-mri" title="Permalink to this headline"></a></h3>
<p><a class="reference external" href="https://github.com/hanya/MRI">MRI</a> is the better extension for debug any object in LibreOffice, you need
install before call it.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">easymacro</span> <span class="k">as</span> <span class="nn">app</span>
<span class="k">def</span> <span class="nf">error</span><span class="p">():</span>
<span class="n">obj</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">active</span>
<span class="n">app</span><span class="o">.</span><span class="n">mri</span><span class="p">(</span><span class="n">obj</span><span class="p">)</span>
<span class="k">return</span>
</pre></div>
</div>
</div>
<div class="section" id="id1">
<h3>1.2) Tools<a class="headerlink" href="#id1" title="Permalink to this headline"></a></h3>
<p>Remember, always import library.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">easymacro</span> <span class="k">as</span> <span class="nn">app</span>
</pre></div>
</div>
</div>
<div class="section" id="info-from-pc">
<h3><strong>Info from PC</strong><a class="headerlink" href="#info-from-pc" title="Permalink to this headline"></a></h3>
<ul class="simple">
<li><p>Operate system</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">app</span><span class="o">.</span><span class="n">OS</span><span class="p">)</span>
</pre></div>
</div>
<ul class="simple">
<li><p>Current user</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">app</span><span class="o">.</span><span class="n">USER</span><span class="p">)</span>
</pre></div>
</div>
<ul class="simple">
<li><p>Name PC</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">app</span><span class="o">.</span><span class="n">PC</span><span class="p">)</span>
</pre></div>
</div>
<ul class="simple">
<li><p>Name desktop, only GNU/Linux</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">app</span><span class="o">.</span><span class="n">DESKTOP</span><span class="p">)</span>
</pre></div>
</div>
<ul class="simple">
<li><p>Language</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">app</span><span class="o">.</span><span class="n">LANG</span><span class="p">)</span>
</pre></div>
</div>
<ul class="simple">
<li><p>Language with variant</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">app</span><span class="o">.</span><span class="n">LANGUAGE</span><span class="p">)</span>
</pre></div>
</div>
<ul class="simple">
<li><p>Application name</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">app</span><span class="o">.</span><span class="n">NAME</span><span class="p">)</span>
</pre></div>
</div>
<ul class="simple">
<li><p>Application version</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">app</span><span class="o">.</span><span class="n">VERSION</span><span class="p">)</span>
</pre></div>
</div>
<ul class="simple">
<li><p>In Windows</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">app</span><span class="o">.</span><span class="n">IS_WIN</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="id2">
<h3><strong>Message box</strong><a class="headerlink" href="#id2" title="Permalink to this headline"></a></h3>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">app</span><span class="o">.</span><span class="n">IS_WIN</span><span class="p">,</span> <span class="s1">&#39;My Macro&#39;</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="show-warning">
<h3><strong>Show warning</strong><a class="headerlink" href="#show-warning" title="Permalink to this headline"></a></h3>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">message</span> <span class="o">=</span> <span class="s1">&#39;Caution, this action is dangerous&#39;</span>
<span class="n">title</span> <span class="o">=</span> <span class="s1">&#39;My App&#39;</span>
<span class="n">app</span><span class="o">.</span><span class="n">warning</span><span class="p">(</span><span class="n">message</span><span class="p">,</span> <span class="n">title</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="show-error-box">
<h3><strong>Show error box</strong><a class="headerlink" href="#show-error-box" title="Permalink to this headline"></a></h3>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">message</span> <span class="o">=</span> <span class="s1">&#39;ERROR: Contact technical support&#39;</span>
<span class="n">title</span> <span class="o">=</span> <span class="s1">&#39;My App&#39;</span>
<span class="n">app</span><span class="o">.</span><span class="n">errorbox</span><span class="p">(</span><span class="n">message</span><span class="p">,</span> <span class="n">title</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="make-question">
<h3><strong>Make question</strong><a class="headerlink" href="#make-question" title="Permalink to this headline"></a></h3>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">message</span> <span class="o">=</span> <span class="s1">&#39;Is easy Python?&#39;</span>
<span class="n">title</span> <span class="o">=</span> <span class="s1">&#39;My App&#39;</span>
<span class="n">result</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">question</span><span class="p">(</span><span class="n">message</span><span class="p">,</span> <span class="n">title</span><span class="p">)</span>
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">result</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="inputbox">
<h3><strong>InputBox</strong><a class="headerlink" href="#inputbox" title="Permalink to this headline"></a></h3>
<ul class="simple">
<li><p>Normal data</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">message</span> <span class="o">=</span> <span class="s1">&#39;Type your name&#39;</span>
<span class="n">default</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
<span class="n">title</span> <span class="o">=</span> <span class="s1">&#39;My App&#39;</span>
<span class="n">result</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">inputbox</span><span class="p">(</span><span class="n">message</span><span class="p">,</span> <span class="n">default</span><span class="p">,</span> <span class="n">title</span><span class="p">)</span>
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">result</span><span class="p">)</span>
</pre></div>
</div>
<ul class="simple">
<li><p>Private data</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">message</span> <span class="o">=</span> <span class="s1">&#39;Type your password&#39;</span>
<span class="n">default</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
<span class="n">title</span> <span class="o">=</span> <span class="s1">&#39;My App&#39;</span>
<span class="n">echochar</span> <span class="o">=</span> <span class="s2">&quot;*&quot;</span>
<span class="n">result</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">inputbox</span><span class="p">(</span><span class="n">message</span><span class="p">,</span> <span class="n">default</span><span class="p">,</span> <span class="n">title</span><span class="p">,</span> <span class="n">echochar</span><span class="p">)</span>
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">result</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="create-instances">
<h3><strong>Create instances</strong><a class="headerlink" href="#create-instances" title="Permalink to this headline"></a></h3>
<ul class="simple">
<li><p>Instances without context</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">toolkit</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">create_instance</span><span class="p">(</span><span class="s2">&quot;com.sun.star.awt.Toolkit&quot;</span><span class="p">)</span>
</pre></div>
</div>
<ul class="simple">
<li><p>Instances with context</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">service</span> <span class="o">=</span> <span class="s1">&#39;com.sun.star.awt.DialogProvider2&#39;</span>
<span class="n">dialog</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">create_instance</span><span class="p">(</span><span class="n">service</span><span class="p">,</span> <span class="kc">True</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="paths-and-files">
<h3><strong>Paths and files</strong><a class="headerlink" href="#paths-and-files" title="Permalink to this headline"></a></h3>
<ul class="simple">
<li><p>Get info path</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">path</span> <span class="o">=</span> <span class="s1">&#39;/home/mau/myfile.ods&#39;</span>
<span class="n">p</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">paths</span><span class="p">(</span><span class="n">path</span><span class="p">)</span>
<span class="n">app</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="n">p</span><span class="o">.</span><span class="n">path</span><span class="p">)</span>
<span class="n">app</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="n">p</span><span class="o">.</span><span class="n">file_name</span><span class="p">)</span>
<span class="n">app</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="n">p</span><span class="o">.</span><span class="n">name</span><span class="p">)</span>
<span class="n">app</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="n">p</span><span class="o">.</span><span class="n">ext</span><span class="p">)</span>
<span class="n">app</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="n">p</span><span class="o">.</span><span class="n">url</span><span class="p">)</span>
</pre></div>
</div>
<p>Or get information in a tuple</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">path</span> <span class="o">=</span> <span class="s1">&#39;/home/mau/myfile.ods&#39;</span>
<span class="n">p</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">paths</span><span class="p">(</span><span class="n">path</span><span class="p">)</span>
<span class="n">app</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="n">p</span><span class="o">.</span><span class="n">info</span><span class="p">)</span>
</pre></div>
</div>
<ul class="simple">
<li><p>Get path home</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">path</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">paths</span><span class="o">.</span><span class="n">home</span>
<span class="n">app</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="n">path</span><span class="p">)</span>
</pre></div>
</div>
<ul class="simple">
<li><p>Get path documents</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">path</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">paths</span><span class="o">.</span><span class="n">documents</span>
<span class="n">app</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="n">path</span><span class="p">)</span>
</pre></div>
</div>
<ul class="simple">
<li><p>Get path temp</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">path</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">paths</span><span class="o">.</span><span class="n">temp_dir</span>
<span class="n">app</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="n">path</span><span class="p">)</span>
</pre></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h1 class="logo"><a href="../index.html">ZAZ</a></h1>
<h3>Navigation</h3>
<p class="caption"><span class="caption-text">Contents:</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="intro.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="config.html">Configuration</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Library easymacro.py</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#tools">1) Tools</a></li>
</ul>
</li>
</ul>
<div class="relations">
<h3>Related Topics</h3>
<ul>
<li><a href="../index.html">Documentation overview</a><ul>
<li>Previous: <a href="config.html" title="previous chapter">Configuration</a></li>
</ul></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="../search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" />
<input type="submit" value="Go" />
</form>
</div>
</div>
<script>$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
&copy;2021, Mauricio Baeza.
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 3.4.3</a>
&amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
|
<a href="../_sources/main/easymacro.rst.txt"
rel="nofollow">Page source</a>
</div>
</body>
</html>

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@ -1,14 +1,15 @@
<!DOCTYPE html>
<html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
<title>Welcome to ZAZs documentation! &#8212; ZAZ documentation</title>
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
<script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<link rel="stylesheet" type="text/css" href="_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="_static/alabaster.css" />
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/doctools.js"></script>
@ -31,7 +32,7 @@
<div class="body" role="main">
<div class="section" id="welcome-to-zaz-s-documentation">
<section id="welcome-to-zaz-s-documentation">
<h1>Welcome to ZAZs documentation!<a class="headerlink" href="#welcome-to-zaz-s-documentation" title="Permalink to this headline"></a></h1>
<div class="toctree-wrapper compound">
<p class="caption"><span class="caption-text">Contents:</span></p>
@ -48,20 +49,39 @@
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="main/easymacro.html">Library easymacro.py</a><ul>
<li class="toctree-l2"><a class="reference internal" href="main/easymacro.html#tools">1) Tools</a></li>
<li class="toctree-l2"><a class="reference internal" href="main/tools_for_debug.html">Tools for debug</a></li>
<li class="toctree-l2"><a class="reference internal" href="main/tools.html">Tools</a></li>
<li class="toctree-l2"><a class="reference internal" href="main/paths.html">Paths and files</a></li>
<li class="toctree-l2"><a class="reference internal" href="main/email.html">Email</a></li>
<li class="toctree-l2"><a class="reference internal" href="main/application.html">Application</a></li>
<li class="toctree-l2"><a class="reference internal" href="main/calc.html">Calc</a></li>
<li class="toctree-l2"><a class="reference internal" href="main/writer.html">Writer</a></li>
<li class="toctree-l2"><a class="reference internal" href="main/base.html">Base</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="main/examples.html">Examples</a><ul>
<li class="toctree-l2"><a class="reference internal" href="main/examples_app.html">For Application</a></li>
<li class="toctree-l2"><a class="reference internal" href="main/examples_calc.html">For Calc</a></li>
<li class="toctree-l2"><a class="reference internal" href="main/examples_writer.html">For Writer</a></li>
<li class="toctree-l2"><a class="reference internal" href="main/examples_draw.html">For Draw</a></li>
<li class="toctree-l2"><a class="reference internal" href="main/examples_base.html">For Base</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="main/apendixes.html">Apendixes</a><ul>
<li class="toctree-l2"><a class="reference internal" href="main/apendixes.html#get-all-filters-in-calc-sheet">Get all filters in Calc sheet</a></li>
</ul>
</li>
</ul>
</div>
</div>
<div class="section" id="indices-and-tables">
</section>
<section id="indices-and-tables">
<h1>Indices and tables<a class="headerlink" href="#indices-and-tables" title="Permalink to this headline"></a></h1>
<ul class="simple">
<li><p><a class="reference internal" href="genindex.html"><span class="std std-ref">Index</span></a></p></li>
<li><p><a class="reference internal" href="py-modindex.html"><span class="std std-ref">Module Index</span></a></p></li>
<li><p><a class="reference internal" href="search.html"><span class="std std-ref">Search Page</span></a></p></li>
</ul>
</div>
</section>
</div>
@ -85,6 +105,8 @@
<li class="toctree-l1"><a class="reference internal" href="main/intro.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="main/config.html">Configuration</a></li>
<li class="toctree-l1"><a class="reference internal" href="main/easymacro.html">Library easymacro.py</a></li>
<li class="toctree-l1"><a class="reference internal" href="main/examples.html">Examples</a></li>
<li class="toctree-l1"><a class="reference internal" href="main/apendixes.html">Apendixes</a></li>
</ul>
<div class="relations">
@ -121,7 +143,7 @@
&copy;2021, Mauricio Baeza.
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 3.4.3</a>
Powered by <a href="http://sphinx-doc.org/">Sphinx 4.0.2</a>
&amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
|

152
doc/build/main/apendixes.html vendored Normal file
View File

@ -0,0 +1,152 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
<title>Apendixes &#8212; ZAZ documentation</title>
<link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="../_static/alabaster.css" />
<script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/doctools.js"></script>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="prev" title="For Base" href="examples_base.html" />
<link rel="stylesheet" href="../_static/custom.css" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
</head><body>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<section id="apendixes">
<h1>Apendixes<a class="headerlink" href="#apendixes" title="Permalink to this headline"></a></h1>
<p>Remember, always import library.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">easymacro</span> <span class="k">as</span> <span class="nn">app</span>
</pre></div>
</div>
<section id="get-all-filters-in-calc-sheet">
<h2>Get all filters in Calc sheet<a class="headerlink" href="#get-all-filters-in-calc-sheet" title="Permalink to this headline"></a></h2>
<ul class="simple">
<li><p>Fields in filter</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="s1">&#39;Finalized&#39;</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span>
<span class="s1">&#39;UIName&#39;</span><span class="p">:</span> <span class="s1">&#39;EPS - Encapsulated PostScript&#39;</span><span class="p">,</span>
<span class="s1">&#39;UserData&#39;</span><span class="p">:</span> <span class="o">&lt;</span><span class="n">ByteSequence</span> <span class="n">instance</span> <span class="s1">&#39;b&#39;&#39;&#39;</span><span class="o">&gt;</span><span class="p">,</span>
<span class="s1">&#39;TemplateName&#39;</span><span class="p">:</span> <span class="s1">&#39;&#39;</span><span class="p">,</span>
<span class="s1">&#39;Enabled&#39;</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span>
<span class="s1">&#39;Mandatory&#39;</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span>
<span class="s1">&#39;Name&#39;</span><span class="p">:</span> <span class="s1">&#39;impress_eps_Export&#39;</span><span class="p">,</span>
<span class="s1">&#39;FilterService&#39;</span><span class="p">:</span> <span class="s1">&#39;&#39;</span><span class="p">,</span>
<span class="s1">&#39;Type&#39;</span><span class="p">:</span> <span class="s1">&#39;eps_Encapsulated_PostScript&#39;</span><span class="p">,</span>
<span class="s1">&#39;UIComponent&#39;</span><span class="p">:</span> <span class="s1">&#39;com.sun.star.svtools.SvFilterOptionsDialog&#39;</span><span class="p">,</span>
<span class="s1">&#39;Flags&#39;</span><span class="p">:</span> <span class="mi">1090</span><span class="p">,</span>
<span class="s1">&#39;FileFormatVersion&#39;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
<span class="s1">&#39;DocumentService&#39;</span><span class="p">:</span> <span class="s1">&#39;com.sun.star.presentation.PresentationDocument&#39;</span><span class="p">,</span>
<span class="s1">&#39;UINames&#39;</span><span class="p">:</span> <span class="p">{</span>
<span class="s1">&#39;en-US&#39;</span><span class="p">:</span> <span class="s1">&#39;EPS - Encapsulated PostScript&#39;</span><span class="p">,</span>
<span class="s1">&#39;es&#39;</span><span class="p">:</span> <span class="s1">&#39;EPS - PostScript encapsulado&#39;</span><span class="p">}</span>
</pre></div>
</div>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">filters</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">get_filters</span><span class="p">()</span>
<span class="n">headers</span> <span class="o">=</span> <span class="p">((</span><span class="s1">&#39;DocumentService&#39;</span><span class="p">,</span> <span class="s1">&#39;UIName&#39;</span><span class="p">,</span> <span class="s1">&#39;Name&#39;</span><span class="p">,</span> <span class="s1">&#39;Type&#39;</span><span class="p">),)</span>
<span class="n">data</span> <span class="o">=</span> <span class="p">[(</span><span class="n">f</span><span class="p">[</span><span class="s1">&#39;DocumentService&#39;</span><span class="p">],</span> <span class="n">f</span><span class="p">[</span><span class="s1">&#39;UIName&#39;</span><span class="p">],</span> <span class="n">f</span><span class="p">[</span><span class="s1">&#39;Name&#39;</span><span class="p">],</span> <span class="n">f</span><span class="p">[</span><span class="s1">&#39;Type&#39;</span><span class="p">])</span>
<span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">filters</span><span class="p">]</span>
<span class="n">doc</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">docs</span><span class="o">.</span><span class="n">new</span><span class="p">()</span>
<span class="n">doc</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="s1">&#39;A1&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">data</span> <span class="o">=</span> <span class="n">headers</span>
<span class="n">doc</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="s1">&#39;A2&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">data</span> <span class="o">=</span> <span class="n">data</span>
</pre></div>
</div>
</section>
</section>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h1 class="logo"><a href="../index.html">ZAZ</a></h1>
<h3>Navigation</h3>
<p class="caption"><span class="caption-text">Contents:</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="intro.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="config.html">Configuration</a></li>
<li class="toctree-l1"><a class="reference internal" href="easymacro.html">Library easymacro.py</a></li>
<li class="toctree-l1"><a class="reference internal" href="examples.html">Examples</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Apendixes</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#get-all-filters-in-calc-sheet">Get all filters in Calc sheet</a></li>
</ul>
</li>
</ul>
<div class="relations">
<h3>Related Topics</h3>
<ul>
<li><a href="../index.html">Documentation overview</a><ul>
<li>Previous: <a href="examples_base.html" title="previous chapter">For Base</a></li>
</ul></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="../search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" />
<input type="submit" value="Go" />
</form>
</div>
</div>
<script>$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
&copy;2021, Mauricio Baeza.
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 4.0.2</a>
&amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
|
<a href="../_sources/main/apendixes.rst.txt"
rel="nofollow">Page source</a>
</div>
</body>
</html>

560
doc/build/main/application.html vendored Normal file
View File

@ -0,0 +1,560 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
<title>Application &#8212; ZAZ documentation</title>
<link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="../_static/alabaster.css" />
<script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/doctools.js"></script>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="Calc" href="calc.html" />
<link rel="prev" title="Email" href="email.html" />
<link rel="stylesheet" href="../_static/custom.css" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
</head><body>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<section id="application">
<h1>Application<a class="headerlink" href="#application" title="Permalink to this headline"></a></h1>
<p>Remember, always import library.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">easymacro</span> <span class="k">as</span> <span class="nn">app</span>
</pre></div>
</div>
<section id="create-instances">
<h2>Create instances<a class="headerlink" href="#create-instances" title="Permalink to this headline"></a></h2>
<ul class="simple">
<li><p>Instances without context</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">toolkit</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">create_instance</span><span class="p">(</span><span class="s2">&quot;com.sun.star.awt.Toolkit&quot;</span><span class="p">)</span>
</pre></div>
</div>
<ul class="simple">
<li><p>Instances with context</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">service</span> <span class="o">=</span> <span class="s1">&#39;com.sun.star.awt.DialogProvider2&#39;</span>
<span class="n">dialog</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">create_instance</span><span class="p">(</span><span class="n">service</span><span class="p">,</span> <span class="kc">True</span><span class="p">)</span>
</pre></div>
</div>
<ul class="simple">
<li><p>Get desktop</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">desktop1</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">create_instance</span><span class="p">(</span><span class="s1">&#39;com.sun.star.frame.Desktop&#39;</span><span class="p">,</span> <span class="kc">True</span><span class="p">)</span>
<span class="c1"># ~ or</span>
<span class="n">desktop2</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">get_desktop</span><span class="p">()</span>
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">desktop1</span> <span class="o">==</span> <span class="n">desktop2</span><span class="p">)</span>
</pre></div>
</div>
</section>
<section id="current-doc">
<h2>Current doc<a class="headerlink" href="#current-doc" title="Permalink to this headline"></a></h2>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">doc</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">active</span>
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">doc</span><span class="o">.</span><span class="n">title</span><span class="p">)</span>
</pre></div>
</div>
</section>
<section id="iter-docs">
<h2>Iter docs<a class="headerlink" href="#iter-docs" title="Permalink to this headline"></a></h2>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">doc</span> <span class="ow">in</span> <span class="n">app</span><span class="o">.</span><span class="n">docs</span><span class="p">:</span>
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">doc</span><span class="o">.</span><span class="n">title</span><span class="p">)</span>
</pre></div>
</div>
</section>
<section id="count">
<h2>Count<a class="headerlink" href="#count" title="Permalink to this headline"></a></h2>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">count</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">app</span><span class="o">.</span><span class="n">docs</span><span class="p">)</span>
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">count</span><span class="p">)</span>
</pre></div>
</div>
</section>
<section id="get-by-name">
<h2>Get by name<a class="headerlink" href="#get-by-name" title="Permalink to this headline"></a></h2>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">name</span> <span class="o">=</span> <span class="s1">&#39;MyDoc.ods&#39;</span>
<span class="k">if</span> <span class="n">name</span> <span class="ow">in</span> <span class="n">app</span><span class="o">.</span><span class="n">docs</span><span class="p">:</span>
<span class="n">doc</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">docs</span><span class="p">[</span><span class="n">name</span><span class="p">]</span>
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">doc</span><span class="o">.</span><span class="n">title</span><span class="p">)</span>
</pre></div>
</div>
</section>
<section id="if-contain">
<h2>If contain<a class="headerlink" href="#if-contain" title="Permalink to this headline"></a></h2>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">result</span> <span class="o">=</span> <span class="s1">&#39;myfile.ods&#39;</span> <span class="ow">in</span> <span class="n">app</span><span class="o">.</span><span class="n">docs</span>
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">result</span><span class="p">)</span>
</pre></div>
</div>
</section>
<section id="new">
<h2>New<a class="headerlink" href="#new" title="Permalink to this headline"></a></h2>
<p>For default create new Calc document.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">doc</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">docs</span><span class="o">.</span><span class="n">new</span><span class="p">()</span>
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">doc</span><span class="o">.</span><span class="n">type</span><span class="p">)</span>
</pre></div>
</div>
<p>For new Writer document.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">doc</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">docs</span><span class="o">.</span><span class="n">new</span><span class="p">(</span><span class="s1">&#39;writer&#39;</span><span class="p">)</span>
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">doc</span><span class="o">.</span><span class="n">type</span><span class="p">)</span>
</pre></div>
</div>
<p>With arguments.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">args</span><span class="o">=</span> <span class="p">{</span><span class="s1">&#39;Hidden&#39;</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span>
<span class="n">doc</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">docs</span><span class="o">.</span><span class="n">new</span><span class="p">(</span><span class="s1">&#39;writer&#39;</span><span class="p">,</span> <span class="n">args</span><span class="p">)</span>
<span class="n">msg</span> <span class="o">=</span> <span class="sa">f</span><span class="s1">&#39;</span><span class="si">{</span><span class="n">doc</span><span class="o">.</span><span class="n">type</span><span class="si">}</span><span class="s1"> - </span><span class="si">{</span><span class="n">doc</span><span class="o">.</span><span class="n">title</span><span class="si">}</span><span class="s1">&#39;</span>
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span>
<span class="n">doc</span><span class="o">.</span><span class="n">visible</span> <span class="o">=</span> <span class="kc">True</span>
</pre></div>
</div>
<p>Other documents.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">doc</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">docs</span><span class="o">.</span><span class="n">new</span><span class="p">(</span><span class="s1">&#39;draw&#39;</span><span class="p">)</span>
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">doc</span><span class="o">.</span><span class="n">type</span><span class="p">)</span>
<span class="n">doc</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">docs</span><span class="o">.</span><span class="n">new</span><span class="p">(</span><span class="s1">&#39;impress&#39;</span><span class="p">)</span>
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">doc</span><span class="o">.</span><span class="n">type</span><span class="p">)</span>
</pre></div>
</div>
</section>
<section id="open">
<h2>Open<a class="headerlink" href="#open" title="Permalink to this headline"></a></h2>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">path</span> <span class="o">=</span> <span class="s1">&#39;/home/mau/MyDoc.ods&#39;</span>
<span class="n">doc</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">docs</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="n">path</span><span class="p">)</span>
</pre></div>
</div>
<p>While LibreOffice support format, you can open arbitrary file.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">path</span> <span class="o">=</span> <span class="s1">&#39;/home/mau/example.xlsx&#39;</span>
<span class="n">doc</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">docs</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="n">path</span><span class="p">)</span>
</pre></div>
</div>
<p>With arguments.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">path</span> <span class="o">=</span> <span class="s1">&#39;/home/mau/example.odt&#39;</span>
<span class="n">args</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;Password&#39;</span><span class="p">:</span> <span class="s1">&#39;letmein&#39;</span><span class="p">}</span>
<span class="n">doc</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">docs</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="n">args</span><span class="p">)</span>
</pre></div>
</div>
</section>
<section id="save">
<h2>Save<a class="headerlink" href="#save" title="Permalink to this headline"></a></h2>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">path</span> <span class="o">=</span> <span class="s1">&#39;/home/mau/myfile.ods&#39;</span>
<span class="n">doc</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">docs</span><span class="o">.</span><span class="n">new</span><span class="p">()</span>
<span class="n">doc</span><span class="o">.</span><span class="n">save</span><span class="p">(</span><span class="n">path</span><span class="p">)</span>
</pre></div>
</div>
<ul class="simple">
<li><p>If previously open and modify any file.</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">doc</span><span class="o">.</span><span class="n">save</span><span class="p">()</span>
</pre></div>
</div>
<ul class="simple">
<li><p>Open exists file and save with other name.</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">path</span> <span class="o">=</span> <span class="s1">&#39;/home/mau/myfile.ods&#39;</span>
<span class="n">doc</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">docs</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="n">path</span><span class="p">)</span>
<span class="n">new_path</span> <span class="o">=</span> <span class="s1">&#39;/srv/mau/other_name.ods&#39;</span>
<span class="n">doc</span><span class="o">.</span><span class="n">save</span><span class="p">(</span><span class="n">new_path</span><span class="p">)</span>
</pre></div>
</div>
</section>
<section id="close">
<h2>Close<a class="headerlink" href="#close" title="Permalink to this headline"></a></h2>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">doc</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">docs</span><span class="o">.</span><span class="n">new</span><span class="p">()</span>
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">doc</span><span class="o">.</span><span class="n">title</span><span class="p">)</span>
<span class="n">doc</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
</pre></div>
</div>
</section>
<section id="to-pdf">
<h2>To PDF<a class="headerlink" href="#to-pdf" title="Permalink to this headline"></a></h2>
<ul class="simple">
<li><p>Save in path</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">doc</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">active</span>
<span class="n">path</span> <span class="o">=</span> <span class="s1">&#39;/home/mau/test.pdf&#39;</span>
<span class="n">doc</span><span class="o">.</span><span class="n">to_pdf</span><span class="p">(</span><span class="n">path</span><span class="p">)</span>
</pre></div>
</div>
<ul class="simple">
<li><p>Save in memory</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">doc</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">active</span>
<span class="n">pdf</span> <span class="o">=</span> <span class="n">doc</span><span class="o">.</span><span class="n">to_pdf</span><span class="p">()</span>
</pre></div>
</div>
</section>
<section id="export">
<h2>Export<a class="headerlink" href="#export" title="Permalink to this headline"></a></h2>
<ul class="simple">
<li><p>Export common formats</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">doc</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">docs</span><span class="o">.</span><span class="n">new</span><span class="p">()</span>
<span class="n">path</span> <span class="o">=</span> <span class="s1">&#39;/home/mau/myfile.xlsx&#39;</span>
<span class="n">filter_name</span> <span class="o">=</span> <span class="s1">&#39;xlsx&#39;</span>
<span class="n">doc</span><span class="o">.</span><span class="n">export</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="n">filter_name</span><span class="p">)</span>
<span class="n">path</span> <span class="o">=</span> <span class="s1">&#39;/home/mau/myfile.xls&#39;</span>
<span class="n">filter_name</span> <span class="o">=</span> <span class="s1">&#39;xls&#39;</span>
<span class="n">doc</span><span class="o">.</span><span class="n">export</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="n">filter_name</span><span class="p">)</span>
<span class="n">doc</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">docs</span><span class="o">.</span><span class="n">new</span><span class="p">(</span><span class="s1">&#39;writer&#39;</span><span class="p">)</span>
<span class="n">path</span> <span class="o">=</span> <span class="s1">&#39;/home/mau/myfile.docx&#39;</span>
<span class="n">filter_name</span> <span class="o">=</span> <span class="s1">&#39;docx&#39;</span>
<span class="n">doc</span><span class="o">.</span><span class="n">export</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="n">filter_name</span><span class="p">)</span>
<span class="n">path</span> <span class="o">=</span> <span class="s1">&#39;/home/mau/myfile.doc&#39;</span>
<span class="n">filter_name</span> <span class="o">=</span> <span class="s1">&#39;doc&#39;</span>
<span class="n">doc</span><span class="o">.</span><span class="n">export</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="n">filter_name</span><span class="p">)</span>
<span class="n">path</span> <span class="o">=</span> <span class="s1">&#39;/home/mau/myfile.rtf&#39;</span>
<span class="n">filter_name</span> <span class="o">=</span> <span class="s1">&#39;rtf&#39;</span>
<span class="n">doc</span><span class="o">.</span><span class="n">export</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="n">filter_name</span><span class="p">)</span>
</pre></div>
</div>
<ul class="simple">
<li><p>For all support formats look <a class="reference external" href="apendixes.html">Apendix</a></p></li>
<li><p>Export in memory.</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">doc</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">docs</span><span class="o">.</span><span class="n">new</span><span class="p">()</span>
<span class="n">filter_name</span> <span class="o">=</span> <span class="s1">&#39;xlsx&#39;</span>
<span class="n">excel_doc</span> <span class="o">=</span> <span class="n">doc</span><span class="o">.</span><span class="n">export</span><span class="p">(</span><span class="n">filter_name</span><span class="o">=</span><span class="n">filter_name</span><span class="p">)</span>
</pre></div>
</div>
</section>
<section id="fonst">
<h2>Fonst<a class="headerlink" href="#fonst" title="Permalink to this headline"></a></h2>
<ul class="simple">
<li><p>Get all fonts</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">fonts</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">get_fonts</span><span class="p">()</span>
<span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">fonts</span><span class="p">:</span>
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s1">&#39;Name: </span><span class="si">{</span><span class="n">f</span><span class="o">.</span><span class="n">Name</span><span class="si">}</span><span class="s1"> - StyleName: </span><span class="si">{</span><span class="n">f</span><span class="o">.</span><span class="n">StyleName</span><span class="si">}</span><span class="s1">&#39;</span><span class="p">)</span>
</pre></div>
</div>
</section>
<section id="filters">
<h2>Filters<a class="headerlink" href="#filters" title="Permalink to this headline"></a></h2>
<ul class="simple">
<li><p>Get all <a class="reference external" href="https://help.libreoffice.org/latest/en-US/text/shared/guide/convertfilters.html">support filters</a></p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">filters</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">get_filters</span><span class="p">()</span>
<span class="n">ds</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">filters</span><span class="p">:</span>
<span class="n">data</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">&quot;UI Name: </span><span class="si">{</span><span class="n">f</span><span class="p">[</span><span class="s1">&#39;UIName&#39;</span><span class="p">]</span><span class="si">}</span><span class="s2"> - Name: </span><span class="si">{</span><span class="n">f</span><span class="p">[</span><span class="s1">&#39;Name&#39;</span><span class="p">]</span><span class="si">}</span><span class="s2"> - Type: </span><span class="si">{</span><span class="n">f</span><span class="p">[</span><span class="s1">&#39;Type&#39;</span><span class="p">]</span><span class="si">}</span><span class="s2">&quot;</span>
<span class="n">app</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
</pre></div>
</div>
</section>
<section id="call-dispatch">
<h2>Call dispatch<a class="headerlink" href="#call-dispatch" title="Permalink to this headline"></a></h2>
<p>You can call any <a class="reference external" href="https://wiki.documentfoundation.org/Development/DispatchCommands">dispatch command</a> used only if property or method no exists in original object or in <cite>easymacro.py</cite></p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">doc</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">active</span>
<span class="n">command</span> <span class="o">=</span> <span class="s1">&#39;.uno:Gallery&#39;</span>
<span class="n">app</span><span class="o">.</span><span class="n">call_dispatch</span><span class="p">(</span><span class="n">doc</span><span class="p">,</span> <span class="n">command</span><span class="p">)</span>
</pre></div>
</div>
</section>
<section id="properties">
<h2>Properties<a class="headerlink" href="#properties" title="Permalink to this headline"></a></h2>
<section id="obj">
<h3>obj<a class="headerlink" href="#obj" title="Permalink to this headline"></a></h3>
<ul class="simple">
<li><p>Get original object pyUNO (read only)</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">doc</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">active</span>
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="nb">type</span><span class="p">(</span><span class="n">doc</span><span class="p">))</span>
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="nb">type</span><span class="p">(</span><span class="n">doc</span><span class="o">.</span><span class="n">obj</span><span class="p">))</span>
</pre></div>
</div>
</section>
<section id="title">
<h3>title<a class="headerlink" href="#title" title="Permalink to this headline"></a></h3>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">doc</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">active</span>
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">doc</span><span class="o">.</span><span class="n">title</span><span class="p">)</span>
<span class="n">doc</span><span class="o">.</span><span class="n">title</span> <span class="o">=</span> <span class="s1">&#39;New title&#39;</span>
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">doc</span><span class="o">.</span><span class="n">title</span><span class="p">)</span>
</pre></div>
</div>
</section>
<section id="type">
<h3>type<a class="headerlink" href="#type" title="Permalink to this headline"></a></h3>
<ul class="simple">
<li><p>Get type document: calc, writer, etc. (read only)</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">doc</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">active</span>
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">doc</span><span class="o">.</span><span class="n">type</span><span class="p">)</span>
</pre></div>
</div>
</section>
<section id="uid">
<h3>uid<a class="headerlink" href="#uid" title="Permalink to this headline"></a></h3>
<ul class="simple">
<li><p>Get internal RuntimeUID form document. (read only)</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">doc</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">active</span>
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">doc</span><span class="o">.</span><span class="n">uid</span><span class="p">)</span>
</pre></div>
</div>
</section>
<section id="is-saved">
<h3>is_saved<a class="headerlink" href="#is-saved" title="Permalink to this headline"></a></h3>
<ul class="simple">
<li><p>If document is saved in this or not (read only)</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">doc</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">active</span>
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">doc</span><span class="o">.</span><span class="n">is_saved</span><span class="p">)</span>
</pre></div>
</div>
</section>
<section id="is-modified">
<h3>is_modified<a class="headerlink" href="#is-modified" title="Permalink to this headline"></a></h3>
<ul class="simple">
<li><p>If document has been modified (read only)</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">doc</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">active</span>
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">doc</span><span class="o">.</span><span class="n">is_modified</span><span class="p">)</span>
</pre></div>
</div>
</section>
<section id="is-read-only">
<h3>is_read_only<a class="headerlink" href="#is-read-only" title="Permalink to this headline"></a></h3>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">doc</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">active</span>
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">doc</span><span class="o">.</span><span class="n">is_read_only</span><span class="p">)</span>
</pre></div>
</div>
</section>
<section id="path">
<h3>path<a class="headerlink" href="#path" title="Permalink to this headline"></a></h3>
<ul class="simple">
<li><p>Get path of document. (read only)</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">doc</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">active</span>
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">doc</span><span class="o">.</span><span class="n">path</span><span class="p">)</span>
</pre></div>
</div>
</section>
<section id="dir">
<h3>dir<a class="headerlink" href="#dir" title="Permalink to this headline"></a></h3>
<ul class="simple">
<li><p>Get only directory from path saved (read only)</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">doc</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">active</span>
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">doc</span><span class="o">.</span><span class="n">dir</span><span class="p">)</span>
</pre></div>
</div>
</section>
<section id="file-name">
<h3>file_name<a class="headerlink" href="#file-name" title="Permalink to this headline"></a></h3>
<ul class="simple">
<li><p>Get only file name from path saved (read only)</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">doc</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">active</span>
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">doc</span><span class="o">.</span><span class="n">file_name</span><span class="p">)</span>
</pre></div>
</div>
</section>
<section id="name">
<h3>name<a class="headerlink" href="#name" title="Permalink to this headline"></a></h3>
<ul class="simple">
<li><p>Get only name without extension (read only)</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">doc</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">active</span>
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">doc</span><span class="o">.</span><span class="n">file_name</span><span class="p">)</span>
</pre></div>
</div>
</section>
<section id="visible">
<h3>visible<a class="headerlink" href="#visible" title="Permalink to this headline"></a></h3>
<ul class="simple">
<li><p>Hide or show document.</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">doc</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">active</span>
<span class="n">doc</span><span class="o">.</span><span class="n">visible</span> <span class="o">=</span> <span class="kc">False</span>
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">doc</span><span class="o">.</span><span class="n">visible</span><span class="p">)</span>
<span class="n">doc</span><span class="o">.</span><span class="n">visible</span> <span class="o">=</span> <span class="kc">True</span>
</pre></div>
</div>
</section>
<section id="zoom">
<h3>zoom<a class="headerlink" href="#zoom" title="Permalink to this headline"></a></h3>
<ul class="simple">
<li><p>Get or set zoom value.</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">doc</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">active</span>
<span class="n">zoom</span> <span class="o">=</span> <span class="n">doc</span><span class="o">.</span><span class="n">zoom</span>
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">zoom</span><span class="p">)</span>
<span class="n">doc</span><span class="o">.</span><span class="n">zoom</span> <span class="o">=</span> <span class="n">zoom</span> <span class="o">*</span> <span class="mi">2</span>
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">doc</span><span class="o">.</span><span class="n">zoom</span><span class="p">)</span>
<span class="n">doc</span><span class="o">.</span><span class="n">zoom</span> <span class="o">=</span> <span class="n">zoom</span>
</pre></div>
</div>
</section>
<section id="selection">
<h3>selection<a class="headerlink" href="#selection" title="Permalink to this headline"></a></h3>
<ul class="simple">
<li><p><strong>CAUTION</strong>: Selection can be many things.</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">doc</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">active</span>
<span class="n">selection</span> <span class="o">=</span> <span class="n">doc</span><span class="o">.</span><span class="n">selection</span>
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">selection</span><span class="p">)</span>
</pre></div>
</div>
</section>
<section id="status-bar">
<h3>status_bar<a class="headerlink" href="#status-bar" title="Permalink to this headline"></a></h3>
<ul class="simple">
<li><p>Get status bar, always control in other thread.</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nd">@app</span><span class="o">.</span><span class="n">run_in_thread</span>
<span class="k">def</span> <span class="nf">update_status_bar</span><span class="p">(</span><span class="n">sb</span><span class="p">,</span> <span class="n">text</span><span class="p">,</span> <span class="n">limit</span><span class="p">):</span>
<span class="n">sb</span><span class="o">.</span><span class="n">start</span><span class="p">(</span><span class="n">text</span><span class="p">,</span> <span class="n">limit</span><span class="p">)</span>
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">limit</span><span class="p">):</span>
<span class="n">sb</span><span class="o">.</span><span class="n">setValue</span><span class="p">(</span><span class="n">i</span><span class="p">)</span>
<span class="n">app</span><span class="o">.</span><span class="n">sleep</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
<span class="c1"># ~ Is important free status bar</span>
<span class="n">sb</span><span class="o">.</span><span class="n">end</span><span class="p">()</span>
<span class="k">return</span>
<span class="k">def</span> <span class="nf">main</span><span class="p">():</span>
<span class="n">doc</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">active</span>
<span class="n">update_status_bar</span><span class="p">(</span><span class="n">doc</span><span class="o">.</span><span class="n">status_bar</span><span class="p">,</span> <span class="s1">&#39;Line&#39;</span><span class="p">,</span> <span class="mi">10</span><span class="p">)</span>
<span class="k">return</span>
</pre></div>
</div>
</section>
</section>
<section id="methods">
<h2>Methods<a class="headerlink" href="#methods" title="Permalink to this headline"></a></h2>
<section id="set-focus">
<h3>set_focus<a class="headerlink" href="#set-focus" title="Permalink to this headline"></a></h3>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">name</span> <span class="o">=</span> <span class="s1">&#39;MyDoc.ods&#39;</span>
<span class="k">if</span> <span class="n">name</span> <span class="ow">in</span> <span class="n">app</span><span class="o">.</span><span class="n">docs</span><span class="p">:</span>
<span class="n">doc</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">docs</span><span class="p">[</span><span class="n">name</span><span class="p">]</span>
<span class="n">doc</span><span class="o">.</span><span class="n">set_focus</span><span class="p">()</span>
</pre></div>
</div>
</section>
<section id="copy">
<h3>copy<a class="headerlink" href="#copy" title="Permalink to this headline"></a></h3>
<ul class="simple">
<li><p>Copy current selection</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">doc</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">active</span>
<span class="n">doc</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span>
</pre></div>
</div>
</section>
<section id="paste">
<h3>paste<a class="headerlink" href="#paste" title="Permalink to this headline"></a></h3>
<ul class="simple">
<li><p>Paste any content in clipboard</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">doc</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">active</span>
<span class="n">doc</span><span class="o">.</span><span class="n">paste</span><span class="p">()</span>
</pre></div>
</div>
</section>
</section>
</section>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h1 class="logo"><a href="../index.html">ZAZ</a></h1>
<h3>Navigation</h3>
<p class="caption"><span class="caption-text">Contents:</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="intro.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="config.html">Configuration</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="easymacro.html">Library easymacro.py</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="tools_for_debug.html">Tools for debug</a></li>
<li class="toctree-l2"><a class="reference internal" href="tools.html">Tools</a></li>
<li class="toctree-l2"><a class="reference internal" href="paths.html">Paths and files</a></li>
<li class="toctree-l2"><a class="reference internal" href="email.html">Email</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">Application</a></li>
<li class="toctree-l2"><a class="reference internal" href="calc.html">Calc</a></li>
<li class="toctree-l2"><a class="reference internal" href="writer.html">Writer</a></li>
<li class="toctree-l2"><a class="reference internal" href="base.html">Base</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="examples.html">Examples</a></li>
<li class="toctree-l1"><a class="reference internal" href="apendixes.html">Apendixes</a></li>
</ul>
<div class="relations">
<h3>Related Topics</h3>
<ul>
<li><a href="../index.html">Documentation overview</a><ul>
<li><a href="easymacro.html">Library easymacro.py</a><ul>
<li>Previous: <a href="email.html" title="previous chapter">Email</a></li>
<li>Next: <a href="calc.html" title="next chapter">Calc</a></li>
</ul></li>
</ul></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="../search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" />
<input type="submit" value="Go" />
</form>
</div>
</div>
<script>$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
&copy;2021, Mauricio Baeza.
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 4.0.2</a>
&amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
|
<a href="../_sources/main/application.rst.txt"
rel="nofollow">Page source</a>
</div>
</body>
</html>

136
doc/build/main/base.html vendored Normal file
View File

@ -0,0 +1,136 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
<title>Base &#8212; ZAZ documentation</title>
<link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="../_static/alabaster.css" />
<script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/doctools.js"></script>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="Examples" href="examples.html" />
<link rel="prev" title="Writer" href="writer.html" />
<link rel="stylesheet" href="../_static/custom.css" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
</head><body>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<section id="base">
<h1>Base<a class="headerlink" href="#base" title="Permalink to this headline"></a></h1>
<p>Remember, always import library.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">easymacro</span> <span class="k">as</span> <span class="nn">app</span>
</pre></div>
</div>
<section id="new-database">
<h2>New database<a class="headerlink" href="#new-database" title="Permalink to this headline"></a></h2>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">path</span> <span class="o">=</span> <span class="s1">&#39;/home/mau/db.odb&#39;</span>
<span class="n">db</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">doc</span><span class="o">.</span><span class="n">connect</span><span class="p">(</span><span class="n">path</span><span class="p">)</span>
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">db</span><span class="o">.</span><span class="n">type</span><span class="p">)</span>
</pre></div>
</div>
</section>
</section>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h1 class="logo"><a href="../index.html">ZAZ</a></h1>
<h3>Navigation</h3>
<p class="caption"><span class="caption-text">Contents:</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="intro.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="config.html">Configuration</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="easymacro.html">Library easymacro.py</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="tools_for_debug.html">Tools for debug</a></li>
<li class="toctree-l2"><a class="reference internal" href="tools.html">Tools</a></li>
<li class="toctree-l2"><a class="reference internal" href="paths.html">Paths and files</a></li>
<li class="toctree-l2"><a class="reference internal" href="email.html">Email</a></li>
<li class="toctree-l2"><a class="reference internal" href="application.html">Application</a></li>
<li class="toctree-l2"><a class="reference internal" href="calc.html">Calc</a></li>
<li class="toctree-l2"><a class="reference internal" href="writer.html">Writer</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">Base</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="examples.html">Examples</a></li>
</ul>
<div class="relations">
<h3>Related Topics</h3>
<ul>
<li><a href="../index.html">Documentation overview</a><ul>
<li><a href="easymacro.html">Library easymacro.py</a><ul>
<li>Previous: <a href="writer.html" title="previous chapter">Writer</a></li>
<li>Next: <a href="examples.html" title="next chapter">Examples</a></li>
</ul></li>
</ul></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="../search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" />
<input type="submit" value="Go" />
</form>
</div>
</div>
<script>$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
&copy;2021, Mauricio Baeza.
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 4.0.2</a>
&amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
|
<a href="../_sources/main/base.rst.txt"
rel="nofollow">Page source</a>
</div>
</body>
</html>

185
doc/build/main/calc.html vendored Normal file
View File

@ -0,0 +1,185 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
<title>Calc &#8212; ZAZ documentation</title>
<link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="../_static/alabaster.css" />
<script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/doctools.js"></script>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="Document" href="calc_doc.html" />
<link rel="prev" title="Application" href="application.html" />
<link rel="stylesheet" href="../_static/custom.css" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
</head><body>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<section id="calc">
<h1>Calc<a class="headerlink" href="#calc" title="Permalink to this headline"></a></h1>
<p>Remember, always import library.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">easymacro</span> <span class="k">as</span> <span class="nn">app</span>
</pre></div>
</div>
<div class="toctree-wrapper compound">
<ul>
<li class="toctree-l1"><a class="reference internal" href="calc_doc.html">Document</a><ul>
<li class="toctree-l2"><a class="reference internal" href="calc_doc.html#current-doc">Current doc</a></li>
<li class="toctree-l2"><a class="reference internal" href="calc_doc.html#selection">Selection</a></li>
<li class="toctree-l2"><a class="reference internal" href="calc_doc.html#headers">Headers</a></li>
<li class="toctree-l2"><a class="reference internal" href="calc_doc.html#tabs">Tabs</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="calc_sheets.html">Sheets</a><ul>
<li class="toctree-l2"><a class="reference internal" href="calc_sheets.html#active-sheet">Active sheet</a></li>
<li class="toctree-l2"><a class="reference internal" href="calc_sheets.html#get-by-index">Get by index</a></li>
<li class="toctree-l2"><a class="reference internal" href="calc_sheets.html#get-by-name">Get by name</a></li>
<li class="toctree-l2"><a class="reference internal" href="calc_sheets.html#contains">Contains</a></li>
<li class="toctree-l2"><a class="reference internal" href="calc_sheets.html#get-tuple-with-all-names">Get tuple with all names</a></li>
<li class="toctree-l2"><a class="reference internal" href="calc_sheets.html#count">Count</a></li>
<li class="toctree-l2"><a class="reference internal" href="calc_sheets.html#new">New</a></li>
<li class="toctree-l2"><a class="reference internal" href="calc_sheets.html#move">Move</a></li>
<li class="toctree-l2"><a class="reference internal" href="calc_sheets.html#remove">Remove</a></li>
<li class="toctree-l2"><a class="reference internal" href="calc_sheets.html#copy">Copy</a></li>
<li class="toctree-l2"><a class="reference internal" href="calc_sheets.html#copy-from">Copy from</a></li>
<li class="toctree-l2"><a class="reference internal" href="calc_sheets.html#copy-to">Copy to</a></li>
<li class="toctree-l2"><a class="reference internal" href="calc_sheets.html#sort">Sort</a></li>
<li class="toctree-l2"><a class="reference internal" href="calc_sheets.html#name">Name</a></li>
<li class="toctree-l2"><a class="reference internal" href="calc_sheets.html#code-name">Code name</a></li>
<li class="toctree-l2"><a class="reference internal" href="calc_sheets.html#visible">Visible</a></li>
<li class="toctree-l2"><a class="reference internal" href="calc_sheets.html#is-protected">Is protected</a></li>
<li class="toctree-l2"><a class="reference internal" href="calc_sheets.html#set-password">Set password</a></li>
<li class="toctree-l2"><a class="reference internal" href="calc_sheets.html#remove-password">Remove password</a></li>
<li class="toctree-l2"><a class="reference internal" href="calc_sheets.html#tab-color">Tab color</a></li>
<li class="toctree-l2"><a class="reference internal" href="calc_sheets.html#document-parent">Document parent</a></li>
<li class="toctree-l2"><a class="reference internal" href="calc_sheets.html#activate">Activate</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="calc_ranges.html">Cell and ranges</a><ul>
<li class="toctree-l2"><a class="reference internal" href="calc_ranges.html#cells">Cells</a></li>
<li class="toctree-l2"><a class="reference internal" href="calc_ranges.html#ranges">Ranges</a></li>
<li class="toctree-l2"><a class="reference internal" href="calc_ranges.html#info-ranges">Info ranges</a></li>
<li class="toctree-l2"><a class="reference internal" href="calc_ranges.html#special-ranges">Special ranges</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="calc_ranges2.html">Manipulate ranges</a><ul>
<li class="toctree-l2"><a class="reference internal" href="calc_ranges2.html#select">Select</a></li>
<li class="toctree-l2"><a class="reference internal" href="calc_ranges2.html#move">Move</a></li>
<li class="toctree-l2"><a class="reference internal" href="calc_ranges2.html#insert">Insert</a></li>
<li class="toctree-l2"><a class="reference internal" href="calc_ranges2.html#delete">Delete</a></li>
<li class="toctree-l2"><a class="reference internal" href="calc_ranges2.html#copy">Copy</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="calc_data.html">Data</a><ul>
<li class="toctree-l2"><a class="reference internal" href="calc_data.html#read">Read</a></li>
<li class="toctree-l2"><a class="reference internal" href="calc_data.html#write">Write</a></li>
</ul>
</li>
</ul>
</div>
</section>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h1 class="logo"><a href="../index.html">ZAZ</a></h1>
<h3>Navigation</h3>
<p class="caption"><span class="caption-text">Contents:</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="intro.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="config.html">Configuration</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="easymacro.html">Library easymacro.py</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="tools_for_debug.html">Tools for debug</a></li>
<li class="toctree-l2"><a class="reference internal" href="tools.html">Tools</a></li>
<li class="toctree-l2"><a class="reference internal" href="paths.html">Paths and files</a></li>
<li class="toctree-l2"><a class="reference internal" href="email.html">Email</a></li>
<li class="toctree-l2"><a class="reference internal" href="application.html">Application</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">Calc</a></li>
<li class="toctree-l2"><a class="reference internal" href="writer.html">Writer</a></li>
<li class="toctree-l2"><a class="reference internal" href="base.html">Base</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="examples.html">Examples</a></li>
<li class="toctree-l1"><a class="reference internal" href="apendixes.html">Apendixes</a></li>
</ul>
<div class="relations">
<h3>Related Topics</h3>
<ul>
<li><a href="../index.html">Documentation overview</a><ul>
<li><a href="easymacro.html">Library easymacro.py</a><ul>
<li>Previous: <a href="application.html" title="previous chapter">Application</a></li>
<li>Next: <a href="calc_doc.html" title="next chapter">Document</a></li>
</ul></li>
</ul></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="../search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" />
<input type="submit" value="Go" />
</form>
</div>
</div>
<script>$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
&copy;2021, Mauricio Baeza.
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 4.0.2</a>
&amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
|
<a href="../_sources/main/calc.rst.txt"
rel="nofollow">Page source</a>
</div>
</body>
</html>

214
doc/build/main/calc_data.html vendored Normal file
View File

@ -0,0 +1,214 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
<title>Data &#8212; ZAZ documentation</title>
<link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="../_static/alabaster.css" />
<script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/doctools.js"></script>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="Writer" href="writer.html" />
<link rel="prev" title="Manipulate ranges" href="calc_ranges2.html" />
<link rel="stylesheet" href="../_static/custom.css" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
</head><body>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<section id="data">
<h1>Data<a class="headerlink" href="#data" title="Permalink to this headline"></a></h1>
<section id="read">
<h2>Read<a class="headerlink" href="#read" title="Permalink to this headline"></a></h2>
<ul class="simple">
<li><p>Get value from cell, automatic detect type and get value.</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">sheet</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">active_sheet</span>
<span class="n">cell</span> <span class="o">=</span> <span class="n">sheet</span><span class="p">[</span><span class="s1">&#39;A1&#39;</span><span class="p">]</span>
<span class="n">value</span> <span class="o">=</span> <span class="n">cell</span><span class="o">.</span><span class="n">value</span>
<span class="n">info</span> <span class="o">=</span> <span class="sa">f</span><span class="s1">&#39;Cell Type = </span><span class="si">{</span><span class="n">cell</span><span class="o">.</span><span class="n">type</span><span class="si">}</span><span class="se">\n\n</span><span class="s1">Cell Value = </span><span class="si">{</span><span class="n">cell</span><span class="o">.</span><span class="n">value</span><span class="si">}</span><span class="s1">&#39;</span>
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">info</span><span class="p">)</span>
</pre></div>
</div>
<ul class="simple">
<li><p>Get date, time and datetime like data Python.</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">sheet</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">active_sheet</span>
<span class="n">cell</span> <span class="o">=</span> <span class="n">sheet</span><span class="p">[</span><span class="s1">&#39;A1&#39;</span><span class="p">]</span>
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">cell</span><span class="o">.</span><span class="n">date</span><span class="p">)</span>
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">cell</span><span class="o">.</span><span class="n">time</span><span class="p">)</span>
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">cell</span><span class="o">.</span><span class="n">datetime</span><span class="p">)</span>
</pre></div>
</div>
<ul class="simple">
<li><p>Get values from cell range.</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">sheet</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">active_sheet</span>
<span class="n">rango</span> <span class="o">=</span> <span class="n">sheet</span><span class="p">[</span><span class="s1">&#39;A1:B5&#39;</span><span class="p">]</span>
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">rango</span><span class="o">.</span><span class="n">data</span><span class="p">)</span>
</pre></div>
</div>
<ul class="simple">
<li><p>Get formulas</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">sheet</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">active_sheet</span>
<span class="n">rango</span> <span class="o">=</span> <span class="n">sheet</span><span class="p">[</span><span class="s1">&#39;A1:B5&#39;</span><span class="p">]</span>
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">rango</span><span class="o">.</span><span class="n">formula</span><span class="p">)</span>
</pre></div>
</div>
<ul class="simple">
<li><p>Get array formula</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">sheet</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">active_sheet</span>
<span class="n">rango</span> <span class="o">=</span> <span class="n">sheet</span><span class="p">[</span><span class="s1">&#39;C10:E15&#39;</span><span class="p">]</span>
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">rango</span><span class="o">.</span><span class="n">array_formula</span><span class="p">)</span>
</pre></div>
</div>
<ul class="simple">
<li><p>Get like dictionary</p></li>
</ul>
<p>The first row in range are the keys.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">sheet</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">active_sheet</span>
<span class="n">rango</span> <span class="o">=</span> <span class="n">sheet</span><span class="p">[</span><span class="s1">&#39;A1:B5&#39;</span><span class="p">]</span>
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">rango</span><span class="o">.</span><span class="n">dict</span><span class="p">)</span>
</pre></div>
</div>
</section>
<section id="write">
<h2>Write<a class="headerlink" href="#write" title="Permalink to this headline"></a></h2>
<ul class="simple">
<li><p>Automatic detect data type.</p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">sheet</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">active_sheet</span>
<span class="c1"># ~ Set int</span>
<span class="n">sheet</span><span class="p">[</span><span class="s1">&#39;A1&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">value</span> <span class="o">=</span> <span class="mi">1</span>
<span class="c1"># ~ Set float</span>
<span class="n">sheet</span><span class="p">[</span><span class="s1">&#39;A2&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">value</span> <span class="o">=</span> <span class="mf">10.5</span>
<span class="c1"># ~ Set string</span>
<span class="n">sheet</span><span class="p">[</span><span class="s1">&#39;A3&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">value</span> <span class="o">=</span> <span class="s1">&#39;Damn World&#39;</span>
<span class="c1"># ~ Set formula</span>
<span class="n">sheet</span><span class="p">[</span><span class="s1">&#39;A4&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">value</span> <span class="o">=</span> <span class="s1">&#39;=RAND()&#39;</span>
<span class="c1"># ~ Set date</span>
<span class="n">sheet</span><span class="p">[</span><span class="s1">&#39;A5&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">value</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">today</span><span class="p">()</span>
<span class="c1"># ~ Set time</span>
<span class="n">sheet</span><span class="p">[</span><span class="s1">&#39;A6&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">value</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">now</span><span class="p">(</span><span class="kc">True</span><span class="p">)</span>
<span class="c1"># ~ Set datetime</span>
<span class="n">sheet</span><span class="p">[</span><span class="s1">&#39;A7&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">value</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">now</span><span class="p">()</span>
</pre></div>
</div>
</section>
</section>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h1 class="logo"><a href="../index.html">ZAZ</a></h1>
<h3>Navigation</h3>
<p class="caption"><span class="caption-text">Contents:</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="intro.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="config.html">Configuration</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="easymacro.html">Library easymacro.py</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="tools_for_debug.html">Tools for debug</a></li>
<li class="toctree-l2"><a class="reference internal" href="tools.html">Tools</a></li>
<li class="toctree-l2"><a class="reference internal" href="paths.html">Paths and files</a></li>
<li class="toctree-l2"><a class="reference internal" href="email.html">Email</a></li>
<li class="toctree-l2"><a class="reference internal" href="application.html">Application</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="calc.html">Calc</a></li>
<li class="toctree-l2"><a class="reference internal" href="writer.html">Writer</a></li>
<li class="toctree-l2"><a class="reference internal" href="base.html">Base</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="examples.html">Examples</a></li>
<li class="toctree-l1"><a class="reference internal" href="apendixes.html">Apendixes</a></li>
</ul>
<div class="relations">
<h3>Related Topics</h3>
<ul>
<li><a href="../index.html">Documentation overview</a><ul>
<li><a href="easymacro.html">Library easymacro.py</a><ul>
<li><a href="calc.html">Calc</a><ul>
<li>Previous: <a href="calc_ranges2.html" title="previous chapter">Manipulate ranges</a></li>
<li>Next: <a href="writer.html" title="next chapter">Writer</a></li>
</ul></li>
</ul></li>
</ul></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="../search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" />
<input type="submit" value="Go" />
</form>
</div>
</div>
<script>$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
&copy;2021, Mauricio Baeza.
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 4.0.2</a>
&amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
|
<a href="../_sources/main/calc_data.rst.txt"
rel="nofollow">Page source</a>
</div>
</body>
</html>

Some files were not shown because too many files have changed in this diff Show More