Add writer cursor move

This commit is contained in:
Mauricio Baeza 2021-08-29 15:43:37 -05:00
parent 33c86dcd56
commit f597411d3e
6 changed files with 72 additions and 10 deletions

View File

@ -1,3 +1,7 @@
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

View File

@ -30,9 +30,9 @@ IBAN: BE60 9671 0556 5870
SWIFT / BIC: TRWIBEB1XXX
```
* BCH: `qztd3l00xle5tffdqvh2snvadkuau2ml0uqm4n875d`
* FairCoin: `fJ7emvtyGfvcMuxk1nHSnS7gmeScdcZXL5`
* Monero: `43H43TpQKYdYcw2ZCnn2nbjDh3imNQg8RGYS4oP4p7Z8aeBHg6VpeaFfBoMzDTUUDdQBiGkiQUSydJB96m6MqiEuEeyoopQ`
* BCH: `qztd3l00xle5tffdqvh2snvadkuau2ml0uqm4n875d`
* ETH: `0x61a4f614a30ff686445751ed8328b82b77ecfc69`
* XRP: `rLSn6Z3T8uCxbcd1oxwfGQN1Fdn5CyGujK` Tag: `6643162`

View File

@ -1 +1 @@
0.16.0
0.18.0

View File

@ -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/

View File

@ -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'])
@ -6707,8 +6760,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

View File

@ -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()