Ask Your Question
0

how to change overall font family in math-formula

asked 2016-08-09 11:01:12 +0200

DanielG gravatar image

Hello,

I am using a lot of formulas in my document. Now I want to change the font the used font-family to another font-family. Is there a (simple) workaround for this, without entering in every single formula and editing one by one by one...

Thank you in advance.

Regrads

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
0

answered 2016-08-10 03:11:53 +0200

Regina gravatar image

The macros should still work. For changing font names via input, you can use something similar as below. It is not nice, because it uses several input boxes instead of a single dialog. But you might get an idea how to access the needed properties.

sub SetFontNameViaInput
dim oCurrentController as variant: oCurrentController = ThisComponent.getCurrentController()
dim oDoc as variant: oDoc=ThisComponent
if not(oCurrentController.supportsService("com.sun.star.text.TextDocumentView")) then
    msgbox("Macro works only in text documents.")
    exit sub
end if
dim oModelTextDocument as variant: oModelTextDocument = oCurrentController.Model
dim oEmbeddedObjects as variant: oEmbeddedObjects = oModelTextDocument.EmbeddedObjects
dim nIndex as long
dim nEndIndex as long: nEndIndex = oEmbeddedObjects.Count-1
dim oEmbeddedObject as variant: rem like green handle status
dim oModel as variant: rem like edit status
dim oXCOEO as variant: rem oExtendedControlOverEmbeddedObject
rem request Font names from the user
dim sVariablesFont as string
sVariablesFont = InputBox("Enter new font name for Variables."+Chr$(13)+"Enter the name without quotation  marks.","Change Formula Fonts","Liberation Serif")
dim sFunctionsFont as string
sFunctionsFont = InputBox("Enter new font name for Functions."+Chr$(13)+"Enter the name without quotation marks.","Change Formula Fonts","Liberation Serif")
dim sNumbersFont as string
sNumbersFont = InputBox("Enter new font name for Numbers."+Chr$(13)+"Enter the name without quotation marks.","Change Formula Fonts","Liberation Serif")
dim sTextFont as string
sTextFont = InputBox("Enter new font name for Text."+Chr$(13)+"Enter the name without quotation marks.","Change Formula Fonts","Liberation Serif")              
for nIndex=0 to nEndIndex
oEmbeddedObject = oEmbeddedObjects.getByIndex(nIndex)
oModel = oEmbeddedObject.Model: rem might be empty; css.comp.math.FormulaDocument
if Not(isEmpty(oModel)) then
    if oModel.supportsService("com.sun.star.formula.FormulaProperties") then
        rem It is a formula object.
        oModel.FontNameText = sTextFont
        oModel.FontNameFunctions = sFunctionsFont
        oModel.FontNameVariables = sVariablesFont
        oModel.FontNameNumbers = sNumbersFont
        oXCOEO = oEmbeddedObject.ExtendedControlOverEmbeddedObject
        oXCOEO.update()
    end if  
end if
next nIndex
end sub
edit flag offensive delete link more
0

answered 2016-08-09 22:31:37 +0200

RGB-es gravatar image

The only way to change the font on all Math object in a document is through macros. Once upon the time I found this file from Regina Henschel that contains the necessary macros, but several years have passed since I've used those tools so no idea if they still work:

http://www.rhenschel.homepage.t-onlin...

edit flag offensive delete link more

Comments

I have put several such macros into a Basic library in a document. It has been attached to the similar question on Ask

Regina gravatar imageRegina ( 2016-10-26 17:07:51 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2016-08-09 11:01:12 +0200

Seen: 664 times

Last updated: Aug 10 '16