Start support for insert math in writer
This commit is contained in:
parent
37fc2568da
commit
cdbb00fad4
|
@ -1,7 +1,12 @@
|
|||
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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -164,13 +164,23 @@ OBJ_RANGE = 'ScCellRangeObj'
|
|||
OBJ_RANGES = 'ScCellRangesObj'
|
||||
TYPE_RANGES = (OBJ_CELL, OBJ_RANGE)
|
||||
|
||||
OBJ_SHAPES = 'com.sun.star.drawing.SvxShapeCollection'
|
||||
OBJ_SHAPE = 'com.sun.star.comp.sc.ScShapeObj'
|
||||
OBJ_SHAPES = 'com.sun.star.drawing.SvxShapeCollection'
|
||||
OBJ_GRAPHIC = 'SwXTextGraphicObject'
|
||||
|
||||
OBJ_TEXTS = 'SwXTextRanges'
|
||||
OBJ_TEXT = 'SwXTextRange'
|
||||
|
||||
CLSID = {
|
||||
'FORMULA': '078B7ABA-54FC-457F-8551-6147e776a997',
|
||||
}
|
||||
|
||||
SERVICES = {
|
||||
'TEXT_EMBEDDED': 'com.sun.star.text.TextEmbeddedObject',
|
||||
'TEXT_TABLE': 'com.sun.star.text.TextTable',
|
||||
'GRAPHIC': 'com.sun.star.text.GraphicObject',
|
||||
}
|
||||
|
||||
|
||||
# ~ from com.sun.star.sheet.FilterOperator import EMPTY, NO_EMPTY, EQUAL, NOT_EQUAL
|
||||
class FilterOperator(IntEnum):
|
||||
|
@ -3310,11 +3320,9 @@ class LOWriterTextRange(object):
|
|||
def insert_math(self, formula,
|
||||
anchor_type=TextContentAnchorType.AS_CHARACTER,
|
||||
cursor=None, replace=False):
|
||||
CLSID = '078B7ABA-54FC-457F-8551-6147e776a997'
|
||||
service = 'com.sun.star.text.TextEmbeddedObject'
|
||||
|
||||
math = self._doc.create_instance(service)
|
||||
math.CLSID = CLSID
|
||||
math = self._doc.create_instance(SERVICES['TEXT_EMBEDDED'])
|
||||
math.CLSID = CLSID['FORMULA']
|
||||
math.AnchorType = anchor_type
|
||||
self.insert_content(math, cursor, replace)
|
||||
math.EmbeddedObject.Component.Formula = formula
|
||||
|
@ -3327,7 +3335,7 @@ class LOWriterTextRange(object):
|
|||
return self._doc.selection
|
||||
|
||||
def insert_table(self, data):
|
||||
table = self._doc.create_instance('com.sun.star.text.TextTable')
|
||||
table = self._doc.create_instance(SERVICES['TEXT_TABLE'])
|
||||
rows = len(data)
|
||||
cols = len(data[0])
|
||||
table.initialize(rows, cols)
|
||||
|
@ -3340,7 +3348,8 @@ class LOWriterTextRange(object):
|
|||
def insert_image(self, path, args={}):
|
||||
w = args.get('Width', 1000)
|
||||
h = args.get('Height', 1000)
|
||||
image = self._doc.create_instance('com.sun.star.text.GraphicObject')
|
||||
|
||||
image = self._doc.create_instance(SERVICES['GRAPHIC'])
|
||||
image.GraphicURL = _P.to_url(path)
|
||||
image.AnchorType = TextContentAnchorType.AS_CHARACTER
|
||||
image.Width = w
|
||||
|
|
Loading…
Reference in New Issue