[Solved] Using MathType via LibreOffice

Keyboard macros or custom scripts

[Solved] Using MathType via LibreOffice

Postby mathone » Wed Nov 15, 2017 12:42 am

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   Expand viewCollapse view
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
mathone
 
Posts: 2
Joined: Wed Nov 15, 2017 12:22 am

Re: Using MathType via LibreOffice

Postby Lupp » Wed Nov 15, 2017 6:00 pm

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 5.4.2 and older versions, PortableOpenOffice 4.1.3 and older, StarOffice 5.2
---
Maybe we might! (Create a powerful UFO: United Free Office)
Lupp from München
User avatar
Lupp
Volunteer
 
Posts: 1523
Joined: Sat May 31, 2014 7:05 pm

Re: Using MathType via LibreOffice

Postby mathone » Wed Nov 15, 2017 10:05 pm

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
mathone
 
Posts: 2
Joined: Wed Nov 15, 2017 12:22 am


Return to OpenOffice Basic, Python, BeanShell, JavaScript

Who is online

Users browsing this forum: No registered users and 4 guests