Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is there a way to quickly change the font of all equations in a document? Maybe there's a built-in style for them or something...

I don't want to set a default style for new ones, but to change existing one's.

share|improve this question

2 Answers 2

up vote 2 down vote accepted

I don't believe there is a built-in style for the formulas. However, you can have a macro iterate over all formulas and change the style. The French OpenOffice.org FAQ has an example of such a macro:

Sub Main
    embeddedObjects = ThisComponent.getEmbeddedObjects()
    elementNames = embeddedObjects.getElementNames()
    for i=0 to UBOUND(elementNames)
        element = embeddedObjects.getByName(elementNames(i)).Model
        if (not isNull(element)) then
            if (element.supportsService("com.sun.star.formula.FormulaProperties")) then
                element.BaseFontHeight = 14
                element.FontNameVariables= "Arial"
                element.FontNameFunctions = "Arial"     
                element.FontNameNumbers= "Arial"        
                element.FontNameText= "Arial"       
            endif
        endif
    next i
    ThisComponent.reformat()
End Sub
share|improve this answer
    
This doesn't work, because after the first iteration it cannot determine the model of the element. I use LibreOffice 3.4.4. –  KovBal Dec 17 '11 at 13:06
    
There must be a special kind of object in your document. I've added a check to see if the object has the Model property, hoping this might fix that problem. –  Brecht Machiels Dec 18 '11 at 22:44
    
This version is working, thanks! –  KovBal Dec 28 '11 at 15:35

For LibreOffice, I had to make some changes in the macro in order to get an automatic update of the formula. I took a look at this topic in the OpenOffice forums next to the present one.

Here is the macro I have used:

REM  *****  BASIC  *****
Sub ReformatFormules
    embeddedObjects = ThisComponent.getEmbeddedObjects()
    elementNames = embeddedObjects.getElementNames()
    for i=0 to UBOUND(elementNames)
        element = embeddedObjects.getByName(elementNames(i)).Model
        oXEO = embeddedObjects.getByName(elementNames(i)).ExtendedControlOverEmbeddedObject
        iCurrentState = oXEO.currentState
        oXEO.changeState(com.sun.star.embed.EmbedStates.UI_ACTIVE)
        if (not isNull(element)) then
            if (element.supportsService("com.sun.star.formula.FormulaProperties")) then
                element.BaseFontHeight = 10
                element.FontNameVariables= "Times New Roman"
                element.FontVariablesIsItalic=1
                element.FontNameFunctions = "Times New Roman"     
                element.FontNameNumbers= "Times New Roman"        
                element.FontNameText= "Times New Roman"       
            endif
        endif
    next i
End Sub
share|improve this answer
    
I found that this one works better, since it will "click" into the object and resize the object. –  Allen Aug 15 '13 at 8:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.