I came back to this thread because I had posted some code being rather complicated on the one hand, but not exactly addressing the question on the other hand.
Reconsidered the answer is “Yes, that can be done by user code in a rather simple way.”.
- One linitation is that font sizes (height) in Writer can have fractional values while Math only allows for the type
Small
for which I once more don’t know a clear specification.
- A second flaw is that it’s complicated to implement a restriction to an arbitrary selection of formulas. I only implemented ALL.
- A third point is the open question what “their environment” is supposed to mean. I took the CharHeight property of the TextParagraph the hosting frame of the equation is anchored
to
or in
.
An example containing the needed code should show if it is usable for a specific purpose. Call the macro writerHarmonizeAllMathFormulaBaseFontHeightsWithSurroundingText
The example file:
anotherExampleSourceWithCode.odt (47.3 KB)
The code (Basic):
Sub writerHarmonizeAllMathFormulaBaseFontHeightsWithSurroundingText()
drawPage = ThisComponent.DrawPage
writerHarmonizeMathFormulaBaseFontHeightsWithSurroundingTextForElementContainer(drawPage)
End Sub
Sub writerHarmonizeMathFormulaBaseFontHeightsWithSurroundingTextForElementContainer(pShapeContainer As Object)
For Each element In pShapeContainer
If element.supportsService("com.sun.star.text.TextEmbeddedObject") Then
tp = element.Anchor.TextParagraph
newBaseFontHeight = CInt(Int(tp.CharHeight + 0.5))
REM Type of target property is "Small"
trySetMathBaseFontHeight(element, newBaseFontHeight)
EndIf
Next element
fail:
End Sub
Sub trySetMathBaseFontHeight(pHost, pNewBaseFontHeight)
'On Local Error Goto fail
mathComp= pHost.Component
mathComp.BaseFontHeight = pNewBaseFontHeight
pHost.ExtendedControlOverEmbeddedObject.Update()
fail:
End Sub
Please @Lupp, forgive me for taking the liberty to reformat your code - ajlittoz
There’s a faint chance if you tell me why.
I had used the tool Preformatted text
. The editor showed a closing angle bracket at the start of every line then, and I thought this was OK.
(It’s my personal style to not indent every line inside the definition of a routine, but only to separate any Sub or Function from others by one or two empty lines. .
Internal constructs are emphasized by indenting additional 2 spaces per order of nesting then.)