Writer. Add shapes. Change zoom
This commit is contained in:
commit
58a8970978
|
@ -1,3 +1,11 @@
|
|||
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
|
||||
|
||||
|
|
|
@ -8,7 +8,8 @@ Develop in pure Python, not need any dependence.
|
|||
* 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
|
||||
|
@ -29,8 +30,6 @@ IBAN: BE60 9671 0556 5870
|
|||
SWIFT / BIC: TRWIBEB1XXX
|
||||
```
|
||||
|
||||
* FairCoin: `fJ7emvtyGfvcMuxk1nHSnS7gmeScdcZXL5`
|
||||
* Monero: `43H43TpQKYdYcw2ZCnn2nbjDh3imNQg8RGYS4oP4p7Z8aeBHg6VpeaFfBoMzDTUUDdQBiGkiQUSydJB96m6MqiEuEeyoopQ`
|
||||
* BCH: `qztd3l00xle5tffdqvh2snvadkuau2ml0uqm4n875d`
|
||||
|
||||
* ETH: `0x61a4f614a30ff686445751ed8328b82b77ecfc69`
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -157,13 +157,13 @@ Copy
|
|||
.. code-block:: python
|
||||
|
||||
sheet = doc[0]
|
||||
doc.copy(sheet, 'OtherSheet')
|
||||
doc.copy_sheet(sheet, 'OtherSheet')
|
||||
|
||||
* By name
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
doc.copy('Sheet1', 'Sheet2')
|
||||
doc.copy_sheet('Sheet1', 'Sheet2')
|
||||
|
||||
* From sheet
|
||||
|
||||
|
|
|
@ -21,3 +21,27 @@ Automatic calculate size range.
|
|||
)
|
||||
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()
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
|
||||
For Writer
|
||||
-------------------
|
||||
----------
|
||||
|
||||
Set autostyle in table
|
||||
^^^^^^^^^^^^^^^^^^^^^^
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
|
@ -12,3 +12,13 @@ Set autostyle in table
|
|||
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)
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
<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="Data" href="calc_data.html" />
|
||||
<link rel="next" title="Manipulate ranges" href="calc_ranges2.html" />
|
||||
<link rel="prev" title="Sheets" href="calc_sheets.html" />
|
||||
|
||||
<link rel="stylesheet" href="../_static/custom.css" type="text/css" />
|
||||
|
@ -263,7 +263,7 @@
|
|||
<li><a href="easymacro.html">Library easymacro.py</a><ul>
|
||||
<li><a href="calc.html">Calc</a><ul>
|
||||
<li>Previous: <a href="calc_sheets.html" title="previous chapter">Sheets</a></li>
|
||||
<li>Next: <a href="calc_data.html" title="next chapter">Data</a></li>
|
||||
<li>Next: <a href="calc_ranges2.html" title="next chapter">Manipulate ranges</a></li>
|
||||
</ul></li>
|
||||
</ul></li>
|
||||
</ul></li>
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
<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="Data" href="calc_data.html" />
|
||||
<link rel="next" title="Cell and ranges" href="calc_ranges.html" />
|
||||
<link rel="prev" title="Document" href="calc_doc.html" />
|
||||
|
||||
<link rel="stylesheet" href="../_static/custom.css" type="text/css" />
|
||||
|
@ -174,13 +174,13 @@
|
|||
<li><p>By object</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">doc</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
|
||||
<span class="n">doc</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">sheet</span><span class="p">,</span> <span class="s1">'OtherSheet'</span><span class="p">)</span>
|
||||
<span class="n">doc</span><span class="o">.</span><span class="n">copy_sheet</span><span class="p">(</span><span class="n">sheet</span><span class="p">,</span> <span class="s1">'OtherSheet'</span><span class="p">)</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<ul class="simple">
|
||||
<li><p>By name</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">copy</span><span class="p">(</span><span class="s1">'Sheet1'</span><span class="p">,</span> <span class="s1">'Sheet2'</span><span class="p">)</span>
|
||||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">doc</span><span class="o">.</span><span class="n">copy_sheet</span><span class="p">(</span><span class="s1">'Sheet1'</span><span class="p">,</span> <span class="s1">'Sheet2'</span><span class="p">)</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<ul class="simple">
|
||||
|
@ -379,7 +379,7 @@
|
|||
<li><a href="easymacro.html">Library easymacro.py</a><ul>
|
||||
<li><a href="calc.html">Calc</a><ul>
|
||||
<li>Previous: <a href="calc_doc.html" title="previous chapter">Document</a></li>
|
||||
<li>Next: <a href="calc_data.html" title="next chapter">Data</a></li>
|
||||
<li>Next: <a href="calc_ranges.html" title="next chapter">Cell and ranges</a></li>
|
||||
</ul></li>
|
||||
</ul></li>
|
||||
</ul></li>
|
||||
|
|
|
@ -46,10 +46,13 @@
|
|||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="examples_calc.html">For Calc</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="examples_calc.html#data-to-cell">Data to cell</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="examples_calc.html#copy-visible-cells">Copy visible cells</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="examples_calc.html#merge-by-row">Merge by row</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="examples_writer.html">For Writer</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="examples_writer.html#set-autostyle-in-table">Set autostyle in table</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="examples_writer.html#insert-math-formula">Insert math formula</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="examples_draw.html">For Draw</a><ul>
|
||||
|
@ -96,6 +99,7 @@
|
|||
<li class="toctree-l2"><a class="reference internal" href="examples_base.html">For Base</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="apendixes.html">Apendixes</a></li>
|
||||
</ul>
|
||||
|
||||
<div class="relations">
|
||||
|
|
|
@ -53,6 +53,25 @@
|
|||
</pre></div>
|
||||
</div>
|
||||
</section>
|
||||
<section id="copy-visible-cells">
|
||||
<h2>Copy visible cells<a class="headerlink" href="#copy-visible-cells" 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">rangos</span> <span class="o">=</span> <span class="n">doc</span><span class="o">.</span><span class="n">active</span><span class="p">[</span><span class="s1">'A1'</span><span class="p">]</span><span class="o">.</span><span class="n">current_region</span><span class="o">.</span><span class="n">visible</span>
|
||||
<span class="n">doc</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="n">rangos</span><span class="p">)</span>
|
||||
<span class="n">doc</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span>
|
||||
|
||||
<span class="n">doc</span><span class="o">.</span><span class="n">active</span><span class="p">[</span><span class="s1">'A15'</span><span class="p">]</span><span class="o">.</span><span class="n">select</span><span class="p">()</span>
|
||||
<span class="n">doc</span><span class="o">.</span><span class="n">paste</span><span class="p">()</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</section>
|
||||
<section id="merge-by-row">
|
||||
<h2>Merge by row<a class="headerlink" href="#merge-by-row" title="Permalink to this headline">¶</a></h2>
|
||||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">rango</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">selection</span>
|
||||
<span class="n">rango</span><span class="o">.</span><span class="n">merge_by_row</span><span class="p">()</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
|
||||
|
@ -85,6 +104,7 @@
|
|||
<li class="toctree-l2"><a class="reference internal" href="examples_base.html">For Base</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="apendixes.html">Apendixes</a></li>
|
||||
</ul>
|
||||
|
||||
<div class="relations">
|
||||
|
|
|
@ -45,6 +45,14 @@
|
|||
</pre></div>
|
||||
</div>
|
||||
</section>
|
||||
<section id="insert-math-formula">
|
||||
<h2>Insert math formula<a class="headerlink" href="#insert-math-formula" title="Permalink to this headline">¶</a></h2>
|
||||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">formula</span> <span class="o">=</span> <span class="s1">'%LAMBDA_{deg","t}=1 + </span><span class="si">%a</span><span class="s1">lpha_deg SQRT {M_t over M_{(t=0)}-1}~"."'</span>
|
||||
<span class="n">text</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">selection</span>
|
||||
<span class="n">text</span><span class="o">.</span><span class="n">insert_math</span><span class="p">(</span><span class="n">formula</span><span class="p">)</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
|
||||
|
@ -77,6 +85,7 @@
|
|||
<li class="toctree-l2"><a class="reference internal" href="examples_base.html">For Base</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="apendixes.html">Apendixes</a></li>
|
||||
</ul>
|
||||
|
||||
<div class="relations">
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,3 +1,3 @@
|
|||
#!/bin/bash
|
||||
|
||||
rsync -ravz --delete build/ elmau.net:/opt/www/doc/zaz/
|
||||
rsync -ravz --delete build/ 152.89.107.109:/opt/doc.cuates.net/zaz/
|
||||
|
|
|
@ -36,3 +36,12 @@ Copy visible cells
|
|||
doc.active['A15'].select()
|
||||
doc.paste()
|
||||
|
||||
|
||||
Merge by row
|
||||
^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
rango = app.selection
|
||||
rango.merge_by_row()
|
||||
|
||||
|
|
|
@ -3223,6 +3223,7 @@ class LOWriterTextRange(object):
|
|||
self._is_paragraph = self.obj.ImplementationName == 'SwXParagraph'
|
||||
self._is_table = self.obj.ImplementationName == 'SwXTextTable'
|
||||
self._is_text = self.obj.ImplementationName == 'SwXTextPortion'
|
||||
self._is_section = not self.obj.TextSection is None
|
||||
self._parts = []
|
||||
if self._is_paragraph:
|
||||
self._parts = [LOWriterTextRange(p, doc) for p in obj]
|
||||
|
@ -3288,6 +3289,10 @@ class LOWriterTextRange(object):
|
|||
def is_text(self):
|
||||
return self._is_text
|
||||
|
||||
@property
|
||||
def is_section(self):
|
||||
return self._is_section
|
||||
|
||||
@property
|
||||
def text(self):
|
||||
return self.obj.Text
|
||||
|
@ -3296,15 +3301,63 @@ class LOWriterTextRange(object):
|
|||
def cursor(self):
|
||||
return self.text.createTextCursorByRange(self.obj)
|
||||
|
||||
@property
|
||||
def text_cursor(self):
|
||||
return self.text.createTextCursor()
|
||||
|
||||
@property
|
||||
def dp(self):
|
||||
return self._doc.dp
|
||||
|
||||
def delete(self):
|
||||
@property
|
||||
def paragraph(self):
|
||||
cursor = self.cursor
|
||||
cursor.gotoStartOfParagraph(False)
|
||||
cursor.gotoNextParagraph(True)
|
||||
cursor.String = ''
|
||||
return LOWriterTextRange(cursor, self._doc)
|
||||
|
||||
def goto_start(self):
|
||||
if self.is_section:
|
||||
rango = self.obj.TextSection.Anchor.Start
|
||||
else:
|
||||
rango = self.obj.Start
|
||||
return LOWriterTextRange(rango, self._doc)
|
||||
|
||||
def goto_end(self):
|
||||
if self.is_section:
|
||||
rango = self.obj.TextSection.Anchor.End
|
||||
else:
|
||||
rango = self.obj.End
|
||||
return LOWriterTextRange(rango, self._doc)
|
||||
|
||||
def goto_previous(self, expand=True):
|
||||
cursor = self.cursor
|
||||
cursor.gotoPreviousParagraph(expand)
|
||||
return LOWriterTextRange(cursor, self._doc)
|
||||
|
||||
def goto_next(self, expand=True):
|
||||
cursor = self.cursor
|
||||
cursor.gotoNextParagraph(expand)
|
||||
return LOWriterTextRange(cursor, self._doc)
|
||||
|
||||
def go_left(self, from_self=True, count=1, expand=False):
|
||||
cursor = self.cursor
|
||||
if not from_self:
|
||||
cursor = self.text_cursor
|
||||
cursor.gotoRange(self.obj, False)
|
||||
cursor.goLeft(count, expand)
|
||||
return LOWriterTextRange(cursor, self._doc)
|
||||
|
||||
def go_right(self, from_self=True, count=1, expand=False):
|
||||
cursor = self.cursor
|
||||
if not from_self:
|
||||
cursor = self.text_cursor
|
||||
cursor.gotoRange(self.obj, False)
|
||||
cursor.goRight(count, expand)
|
||||
return LOWriterTextRange(cursor, self._doc)
|
||||
|
||||
def delete(self):
|
||||
self.value = ''
|
||||
return
|
||||
|
||||
def offset(self):
|
||||
|
@ -3332,7 +3385,7 @@ class LOWriterTextRange(object):
|
|||
cursor = self.cursor
|
||||
for i in range(count):
|
||||
self.text.insertControlCharacter(cursor, PARAGRAPH_BREAK, False)
|
||||
return self._doc.selection
|
||||
return LOWriterTextRange(cursor, self._doc)
|
||||
|
||||
def insert_table(self, data):
|
||||
table = self._doc.create_instance(SERVICES['TEXT_TABLE'])
|
||||
|
@ -3345,6 +3398,15 @@ class LOWriterTextRange(object):
|
|||
table = LOWriterTextTable(self._doc.tables[name], self._doc)
|
||||
return table
|
||||
|
||||
def insert_shape(self, tipo, args={}):
|
||||
# ~ args['Width'] = args.get('Width', 1000)
|
||||
# ~ args['Height'] = args.get('Height', 1000)
|
||||
# ~ args['X'] = args.get('X', 0)
|
||||
# ~ args['Y'] = args.get('Y', 0)
|
||||
shape = self._doc.dp.add(tipo, args)
|
||||
# ~ shape.anchor = self.obj
|
||||
return shape
|
||||
|
||||
def insert_image(self, path, args={}):
|
||||
w = args.get('Width', 1000)
|
||||
h = args.get('Height', 1000)
|
||||
|
@ -3482,6 +3544,9 @@ class LOWriter(LODocument):
|
|||
def dp(self):
|
||||
return self.draw_page
|
||||
@property
|
||||
def shapes(self):
|
||||
return self.draw_page
|
||||
@property
|
||||
def draw_page(self):
|
||||
return LODrawPage(self.obj.DrawPage)
|
||||
|
||||
|
@ -3493,6 +3558,10 @@ class LOWriter(LODocument):
|
|||
def cursor(self):
|
||||
return self.obj.Text.createTextCursor()
|
||||
|
||||
@property
|
||||
def view_cursor(self):
|
||||
return self._cc.ViewCursor
|
||||
|
||||
@property
|
||||
def page_styles(self):
|
||||
ps = self.obj.StyleFamilies['PageStyles']
|
||||
|
@ -3510,6 +3579,13 @@ class LOWriter(LODocument):
|
|||
def replace_descriptor(self):
|
||||
return self.obj.createReplaceDescriptor()
|
||||
|
||||
@property
|
||||
def zoom(self):
|
||||
return self._cc.ViewSettings.ZoomValue
|
||||
@zoom.setter
|
||||
def zoom(self, value):
|
||||
self._cc.ViewSettings.ZoomValue = value
|
||||
|
||||
def goto_start(self):
|
||||
self.view_cursor.gotoStart(False)
|
||||
return self.selection
|
||||
|
@ -3612,6 +3688,16 @@ class LOShape(LOBaseObject):
|
|||
a = dict(Width=s.Width, Height=s.Height)
|
||||
return a
|
||||
|
||||
@property
|
||||
def position(self):
|
||||
return self.obj.Position
|
||||
@property
|
||||
def x(self):
|
||||
return self.position.X
|
||||
@property
|
||||
def y(self):
|
||||
return self.position.Y
|
||||
|
||||
@property
|
||||
def string(self):
|
||||
return self.obj.String
|
||||
|
@ -3644,7 +3730,10 @@ class LOShape(LOBaseObject):
|
|||
def anchor(self, value):
|
||||
if hasattr(value, 'obj'):
|
||||
value = value.obj
|
||||
self.obj.Anchor = value
|
||||
try:
|
||||
self.obj.Anchor = value
|
||||
except Exception as e:
|
||||
self.obj.AnchorType = value
|
||||
|
||||
@property
|
||||
def visible(self):
|
||||
|
@ -3778,8 +3867,11 @@ class LODrawPage(LOBaseObject):
|
|||
Connector
|
||||
"""
|
||||
index = self.count
|
||||
default_height = 3000
|
||||
if type_shape == 'Line':
|
||||
default_height = 0
|
||||
w = args.pop('Width', 3000)
|
||||
h = args.pop('Height', 3000)
|
||||
h = args.pop('Height', default_height)
|
||||
x = args.pop('X', 1000)
|
||||
y = args.pop('Y', 1000)
|
||||
name = args.pop('Name', f'{type_shape.lower()}{index}')
|
||||
|
@ -6707,8 +6799,12 @@ class Paths(object):
|
|||
return result
|
||||
|
||||
@classmethod
|
||||
def read(cls, path, encoding='utf-8'):
|
||||
data = Path(path).read_text(encoding=encoding)
|
||||
def read(cls, path, get_lines=False, encoding='utf-8'):
|
||||
if get_lines:
|
||||
with Path(path).open(encoding=encoding) as f:
|
||||
data = f.readlines()
|
||||
else:
|
||||
data = Path(path).read_text(encoding=encoding)
|
||||
return data
|
||||
|
||||
@classmethod
|
||||
|
|
|
@ -793,8 +793,8 @@ def main(args):
|
|||
|
||||
|
||||
def _process_command_line_arguments():
|
||||
parser = argparse.ArgumentParser(
|
||||
description='Make LibreOffice extensions')
|
||||
parser = argparse.ArgumentParser(description='Make LibreOffice extensions')
|
||||
|
||||
parser.add_argument('-new', '--new', dest='new', action='store_true',
|
||||
default=False, required=False)
|
||||
parser.add_argument('-t', '--target', dest='target', default='')
|
||||
|
@ -813,6 +813,7 @@ def _process_command_line_arguments():
|
|||
default=False, required=False)
|
||||
parser.add_argument('-oc', '--only_compress', dest='only_compress',
|
||||
action='store_true', default=False, required=False)
|
||||
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue