Talk:Macros/Math/001/fr
Hello,
I had several problems with these macros.
I managed to correct the macro in python.
- I commented the html span element
- I add the updating of each formula that didn't work before (at least for me)
import uno
# from com.sun.star.document import OfficeDocument
FRAME_DESKTOP = 'com.sun.star.frame.Desktop'
FORMULA_PROPERTIES = 'com.sun.star.formula.FormulaProperties'
class UIFormulaCollection():
#<span lang="en" dir="ltr" class="mw-content-ltr">""" Current document formulae collection """</span>
def __init__(self):
# ctx = uno.getComponentContext() # GetDefaultContext
# smgr = ctx.getServiceManager() # GetProcessServiceManager
# desktop = smgr.createInstanceWithContext(FRAME_DESKTOP, ctx) # StarDesktop
# self.doc = desktop.CurrentComponent # ThisComponent
self.doc = XSCRIPTCONTEXT.getDocument()
self.objects = self.doc.EmbeddedObjects
self.names = self.objects.getElementNames()
def reformat(self, fontHeight=None, font=None):
for name in self.names:
element = self.objects.getByName(name).Model
if element.supportsService(FORMULA_PROPERTIES):
if font:
element.FontNameFunctions = font
element.FontNameText = font
element.FontNameNumbers = font
element.FontNameVariables = font
if fontHeight:
element.BaseFontHeight = fontHeight
embedded = self.objects.getByName(name).EmbeddedObject
embedded.update()
self.doc.reformat()
def reformatAllFormulas():
ui = UIFormulaCollection()
ui.reformat(font="Arial", fontHeight=20)
g_exportedScripts = reformatAllFormulas,