I am writing a converter from XML & MathML to an MS Word document.
I use MFC and Word automation, so there is no problem writing text as follows:
_Application app; COleVariant vtOpt(DISP_E_PARAMNOTFOUND, VT_ERROR), vtTrue((short)TRUE), vtFalse((short)FALSE); app.CreateDispatch("Word.Application",NULL); Documents docs = app.GetDocuments(); _Document doc = docs.Add (vtOpt, vtOpt, vtOpt, vtOpt); Range range = doc.Range (vtOpt, vtOpt); range.InsertAfter (_T("Hello Word!"));
Now the problem is transforming the MathML equations into built-in MathType objects. One possible way that I found was to write equations in TeX, and then programmatically call MTCommand_TeXToggle (found in the MathType 6.5 library for Word) a macro that replaces TeX with MathType OLE objects. But then I have to convert MathML to TeX or otherwise, which is not so simple.
I know that a MathType OLE object must accept raw MathML data, but when I try to create and OLE access to objects programmatically:
InlineShapes shapes = doc.GetInlineShapes (); InlineShape control = shapes.AddOLEObject (COleVariant("Equation.DSMT4"), vtOpt, vtFalse, vtFalse, vtOpt, vtOpt, vtOpt, vtOpt); OLEFormat fm = control.GetOLEFormat (); COleDispatchDriver drv = fm.GetObject();
In the end, I donβt have a reasonable interface to feed it with MathML data. So the question is: 1) Is there a way to take control of an OLE object and send it some MathML data? Or 2) Is there a way to get an MS Word VB macro that converts a selection from MathML to MathType of an OLE object?
Thanks in advance, Nick Stanch