I already had some help in the past to turn and now i have a script that can turn all fonts in math formulas to bold, or change their font size to a specified value.
Here’s the sample code
REM ***** BASIC *****
Sub changeFormulas_Bold_10pt()
doc = ThisComponent
sNames = Array("BaseFontHeight", "FontMathIsBold", "FontFixedIsBold", "FontFunctionsIsBold", "FontNumbersIsBold", "FontSansIsBold", "FontSerifIsBold", "FontTextIsBold", "FontVariablesIsBold")
values = Array(10, True, True, True, True, True, True, True, True)
changeFormulaProperties doc, sNames, values
End Sub
Sub changeFormulas_Regular_12pt()
doc = ThisComponent
sNames = Array("BaseFontHeight", "FontMathIsBold", "FontFixedIsBold", "FontFunctionsIsBold", "FontNumbersIsBold", "FontSansIsBold", "FontSerifIsBold", "FontTextIsBold", "FontVariablesIsBold")
values = Array(12, False, False, False, False, False, False, False, False)
changeFormulaProperties doc, sNames, values
End Sub
Sub changeFormulaProperties(doc, sNames, values)
if doc.supportsService("com.sun.star.formula.FormulaProperties") Then
doc.setPropertyValues(sNames, values)
elseif HasUnoInterfaces(doc, "com.sun.star.drawing.XDrawPageSupplier") Then
obj = doc.getDrawPage()
loopDrawPage obj, sNames, values
elseif HasUnoInterfaces(doc, "com.sun.star.drawing.XDrawPagesSupplier") Then
REM Draw, Impress, Calc
obj = doc.getDrawPages()
loopDrawPages obj, sNames, values
endif
End Sub
Sub loopDrawPages(oDrawPages, sNames, values)
for nDP = 0 to oDrawPages.getCount()-1
oDP = oDrawPages.getByIndex(nDP)
loopDrawPage oDP, sNames, values
next nDP
End Sub
Sub loopDrawPage(oDP, sNames, values)
for nShape = 0 to oDP.getCount()-1
oShape = oDP.getByIndex(nShape)
REM recurse grouped controls:
if oShape.supportsService("com.sun.star.drawing.GroupShape") then loopDrawPage oShape, sNames, values
on error resume next
setShapeModelProperties oShape, sNames, values
next nShape
End Sub
Sub setShapeModelProperties(oShape, sNames, values)
oModel = oShape.Model
sImplementationName = oModel.ImplementationName
if sImplementationName = "com.sun.star.comp.Math.FormulaDocument" then
oModel.setPropertyValues(sNames, values)
endif
End Sub
Wouldn’t it just take a few changes in this formula to make it change font types to the desired one?
As I mentioned earlier, I already had AI assistance, the script they produced amounted to being less than useless. They all had fundamental “basic runtime errors”. I could give them the error back in an attempt to fix it. The error would change a few times and ultimately stabilize at something unfixable.