Start support for insert math in writer
This commit is contained in:
parent
5e2236db54
commit
37fc2568da
|
@ -4,9 +4,9 @@ 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/)
|
||||
|
||||
|
|
|
@ -83,7 +83,6 @@ from com.sun.star.table.CellContentType import EMPTY, VALUE, TEXT, FORMULA
|
|||
from com.sun.star.util import Time, Date, DateTime
|
||||
|
||||
from com.sun.star.text.ControlCharacter import PARAGRAPH_BREAK
|
||||
from com.sun.star.text.TextContentAnchorType import AS_CHARACTER
|
||||
|
||||
from com.sun.star.lang import Locale
|
||||
from com.sun.star.lang import XEventListener
|
||||
|
@ -230,6 +229,12 @@ class FormButtonType():
|
|||
FBT = FormButtonType
|
||||
|
||||
|
||||
class TextContentAnchorType():
|
||||
from com.sun.star.text.TextContentAnchorType \
|
||||
import AT_PARAGRAPH, AS_CHARACTER, AT_PAGE, AT_FRAME, AT_CHARACTER
|
||||
TCAT = TextContentAnchorType
|
||||
|
||||
|
||||
OS = platform.system()
|
||||
IS_WIN = OS == 'Windows'
|
||||
IS_MAC = OS == 'Darwin'
|
||||
|
@ -3302,6 +3307,19 @@ class LOWriterTextRange(object):
|
|||
self.text.insertTextContent(cursor, data, replace)
|
||||
return
|
||||
|
||||
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.AnchorType = anchor_type
|
||||
self.insert_content(math, cursor, replace)
|
||||
math.EmbeddedObject.Component.Formula = formula
|
||||
return math
|
||||
|
||||
def new_line(self, count=1):
|
||||
cursor = self.cursor
|
||||
for i in range(count):
|
||||
|
@ -3324,7 +3342,7 @@ class LOWriterTextRange(object):
|
|||
h = args.get('Height', 1000)
|
||||
image = self._doc.create_instance('com.sun.star.text.GraphicObject')
|
||||
image.GraphicURL = _P.to_url(path)
|
||||
image.AnchorType = AS_CHARACTER
|
||||
image.AnchorType = TextContentAnchorType.AS_CHARACTER
|
||||
image.Width = w
|
||||
image.Height = h
|
||||
self.insert_content(image)
|
||||
|
|
Loading…
Reference in New Issue