Page 1 of 1

[Solved] Using MathType via LibreOffice

Posted: Wed Nov 15, 2017 12:42 am
by mathone
Hi, I'm trying to make a macro that allow me to work with MathType. Actually, I succeeded to do so but have one little problem:
The equation dose not align properly, and i need manually fixing it every time via right-click -> properties (I uploaded photos that point out the specific properties I need to change).
3.png
4.png
5.png
Here the code:

Code: Select all

sub InsertMathTypeObject

dim oTargetDocument as variant
oTargetDocument = ThisComponent
dim oCurrentController as variant
oCurrentController = oTargetDocument.getCurrentController()
dim oFormula as variant
oFormula = oTargetDocument.createInstance("com.sun.star.text.TextEmbeddedObject")
oFormula.CLSID = "0002CE03-0000-0000-C000-000000000046"
oFormula.AnchorType = com.sun.star.text.TextContentAnchorType.AS_CHARACTER
oFormula.attach(oCurrentController.Selection.getByIndex(0) )
dim oXCOEO as variant: oXCOEO = oFormula.ExtendedControlOverEmbeddedObject
oXCOEO.doVerb(com.sun.star.embed.EmbedVerbs.MS_OLEVERB_PRIMARY)
end sub

the question is: how do I change these properties using the code?

thanks for your help (and sorry for my bad English) :)

Re: Using MathType via LibreOffice

Posted: Wed Nov 15, 2017 6:00 pm
by Lupp
Did you try oFormula.VertOrient = 2 The values 1, 2, and 3 should correspond to the three settings 'Top', 'Middle', and 'Bottom' from 'Alignment' in the context menu. For detailed positioning use oFormula.VertOrientPosition. With different anchoring also oFormula.HoriOrientPosition should do its duty. It did for me.

Re: Using MathType via LibreOffice

Posted: Wed Nov 15, 2017 10:05 pm
by mathone
Thank you very much! the solution was: oFormula.VertOrient = 5 (5 is CHAR_CENTER)/