[Solved] Using MathType via LibreOffice

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
mathone
Posts: 2
Joined: Wed Nov 15, 2017 12:22 am

[Solved] Using MathType via LibreOffice

Post 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) :)
Last edited by Hagar Delest on Fri Nov 24, 2017 9:37 am, edited 1 time in total.
Reason: tagged solved
LibreOffice 5.1 on Windows 10
OpenOffice 3.1 on Windows Vista / NeoOffice 2.2.3 with MacOS 10.4 / OpenOffice 2.4 on Ubuntu 9.04
User avatar
Lupp
Volunteer
Posts: 3542
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: Using MathType via LibreOffice

Post 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.
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
mathone
Posts: 2
Joined: Wed Nov 15, 2017 12:22 am

Re: Using MathType via LibreOffice

Post by mathone »

Thank you very much! the solution was: oFormula.VertOrient = 5 (5 is CHAR_CENTER)/
LibreOffice 5.1 on Windows 10
OpenOffice 3.1 on Windows Vista / NeoOffice 2.2.3 with MacOS 10.4 / OpenOffice 2.4 on Ubuntu 9.04
Post Reply