├── ConvertEquations
├── Backup
│ ├── ConvertEquations.sln
│ ├── ConvertEquations
│ │ ├── ClassDiagram1.cd
│ │ ├── ConvertEquations.csproj
│ │ └── Program.cs
│ └── MTSDKDN
│ │ ├── MTSDKDN.csproj
│ │ ├── MTSDKDN.csproj.user
│ │ ├── MathTypeSDK.cs
│ │ └── Properties
│ │ └── AssemblyInfo.cs
├── ConvertEquations.sln
├── ConvertEquations.suo
├── ConvertEquations
│ ├── ClassDiagram1.cd
│ ├── Common.cs
│ ├── ConvertEquations.csproj
│ ├── ConvertEquations.csproj.user
│ ├── Data
│ │ ├── Base64MTEF.txt
│ │ ├── Equation1.wmf
│ │ ├── Equation2.gif
│ │ ├── Equation3.eps
│ │ ├── MathML.txt
│ │ ├── MathML1.txt
│ │ ├── MathML2.txt
│ │ ├── MathML3.txt
│ │ ├── MathML4.txt
│ │ ├── MathML5.txt
│ │ ├── MathML6.txt
│ │ ├── MathML7.txt
│ │ ├── MathML8.txt
│ │ ├── MathML9.txt
│ │ └── TeX.txt
│ ├── MathTypeSDK.cs
│ ├── Program.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── app.config
│ ├── bin
│ │ └── Debug
│ │ │ ├── ConvertEquations.exe
│ │ │ ├── ConvertEquations.exe.config
│ │ │ ├── ConvertEquations.pdb
│ │ │ ├── ConvertEquations.vshost.exe
│ │ │ ├── ConvertEquations.vshost.exe.config
│ │ │ ├── ConvertEquations.vshost.exe.manifest
│ │ │ ├── MT6.dll
│ │ │ ├── MTSDKDN.dll
│ │ │ └── MTSDKDN.pdb
│ └── obj
│ │ └── Debug
│ │ ├── CSCA4C7.tmp
│ │ ├── ConvertEquations.csproj.FileListAbsolute.txt
│ │ ├── ConvertEquations.csproj.ResolveComReference.cache
│ │ ├── ConvertEquations.csprojResolveAssemblyReference.cache
│ │ ├── ConvertEquations.exe
│ │ ├── ConvertEquations.pdb
│ │ ├── DesignTimeResolveAssemblyReferencesInput.cache
│ │ └── ResolveAssemblyReference.cache
├── UpgradeLog.XML
└── _UpgradeReport_Files
│ ├── UpgradeReport.css
│ ├── UpgradeReport.xslt
│ ├── UpgradeReport_Minus.gif
│ └── UpgradeReport_Plus.gif
├── LICENSE
├── MTSDKDN
├── MTSDKDN.sln
├── MTSDKDN
│ ├── MTSDKDN.csproj
│ ├── MTSDKDN.csproj.user
│ ├── MathTypeSDK.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── bin
│ │ └── Debug
│ │ │ ├── MTSDKDN.dll
│ │ │ └── MTSDKDN.pdb
│ └── obj
│ │ └── Debug
│ │ ├── DesignTimeResolveAssemblyReferencesInput.cache
│ │ ├── MTSDKDN.csproj.FileListAbsolute.txt
│ │ ├── MTSDKDN.dll
│ │ └── MTSDKDN.pdb
└── TypeLib
│ ├── CreateMtsdkdnTypelib.bat
│ └── MTSDKDN.odl
├── README.md
└── doc
├── effect.gif
└── image
├── MTSDKDN.png
├── mathml转word系统架构.png
└── mathtypePast.png
/ConvertEquations/Backup/ConvertEquations.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 10.00
3 | # Visual Studio 2008
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConvertEquations", "ConvertEquations\ConvertEquations.csproj", "{9FA59BF2-54BC-4DE6-8725-C9D4D732A712}"
5 | EndProject
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MTSDKDN", "..\MTSDKDN\MTSDKDN\MTSDKDN.csproj", "{CCC50A71-DA40-4703-A638-3A045BD216ED}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {9FA59BF2-54BC-4DE6-8725-C9D4D732A712}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {9FA59BF2-54BC-4DE6-8725-C9D4D732A712}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {9FA59BF2-54BC-4DE6-8725-C9D4D732A712}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {9FA59BF2-54BC-4DE6-8725-C9D4D732A712}.Release|Any CPU.Build.0 = Release|Any CPU
18 | {CCC50A71-DA40-4703-A638-3A045BD216ED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19 | {CCC50A71-DA40-4703-A638-3A045BD216ED}.Debug|Any CPU.Build.0 = Debug|Any CPU
20 | {CCC50A71-DA40-4703-A638-3A045BD216ED}.Release|Any CPU.ActiveCfg = Release|Any CPU
21 | {CCC50A71-DA40-4703-A638-3A045BD216ED}.Release|Any CPU.Build.0 = Release|Any CPU
22 | EndGlobalSection
23 | GlobalSection(SolutionProperties) = preSolution
24 | HideSolutionNode = FALSE
25 | EndGlobalSection
26 | EndGlobal
27 |
--------------------------------------------------------------------------------
/ConvertEquations/Backup/ConvertEquations/ClassDiagram1.cd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAACABAAAAA=
7 | Program.cs
8 |
9 |
10 |
11 |
12 |
13 | AQCAAAAAAIIAAAEAAAAAAIAAAAAQAAAAAAIACAABAAg=
14 | Program.cs
15 |
16 |
17 |
18 |
19 |
20 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAg=
21 | Program.cs
22 |
23 |
24 |
25 |
26 |
27 | AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAA=
28 | Program.cs
29 |
30 |
31 |
32 |
33 |
34 | AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAA=
35 | Program.cs
36 |
37 |
38 |
39 |
40 |
41 | AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAA=
42 | Program.cs
43 |
44 |
45 |
46 |
47 |
48 | AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAg=
49 | Program.cs
50 |
51 |
52 |
53 |
54 |
55 | ARCAAAAAAIAAAAFACCCAAIABQAAAAAAIAAIACAABAAg=
56 | Program.cs
57 |
58 |
59 |
60 |
61 |
62 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
63 | Program.cs
64 |
65 |
66 |
67 |
68 |
69 | AAAAAAAAAAAAAABEACAAAAAAAAAAAAAAAAAAAAAAAAA=
70 | Program.cs
71 |
72 |
73 |
74 |
75 |
76 | AAAAAAAAAAAAAABEACAAAAAAAAAAAAAAAAAAAAAAAAA=
77 | Program.cs
78 |
79 |
80 |
81 |
82 |
83 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
84 | Program.cs
85 |
86 |
87 |
88 |
89 |
90 | AAAAAAAAAAAAAABEACAAAAAAAAAAAAAAAAAAAAAAAAA=
91 | Program.cs
92 |
93 |
94 |
95 |
96 |
97 | AAAAAAEAIoAAAABEACAAAAAAAgAAAAAAgAAJAAAAAIA=
98 | Program.cs
99 |
100 |
101 |
102 |
103 |
104 | AAAAAQAAAAAAAABEACAAAAAAAAAAAgAAAAAAAAAAAAA=
105 | Program.cs
106 |
107 |
108 |
109 |
110 |
111 | AAAAAAAAAAAAAABEACAAAAAAAAAAAAAAAAAAAAAAAAA=
112 | Program.cs
113 |
114 |
115 |
116 |
117 |
118 | AAAAAAAAAAAAAAAAAIAAAAQAAAACAIAhAAAAAAAAAAA=
119 | Program.cs
120 |
121 |
122 |
123 |
124 |
125 | AAAAAQAQAAAAACAAAAAAEAgAAAlAACAAAAAUBAACgAA=
126 | Program.cs
127 |
128 |
129 |
130 |
131 |
132 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAg=
133 | Program.cs
134 |
135 |
136 |
137 |
138 |
139 | AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAA=
140 | Program.cs
141 |
142 |
143 |
144 |
--------------------------------------------------------------------------------
/ConvertEquations/Backup/ConvertEquations/ConvertEquations.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | Debug
4 | AnyCPU
5 | 9.0.30729
6 | 2.0
7 | {9FA59BF2-54BC-4DE6-8725-C9D4D732A712}
8 | Exe
9 | Properties
10 | ConvertEquations
11 | ConvertEquations
12 |
13 |
14 |
15 |
16 | 2.0
17 |
18 |
19 | true
20 | full
21 | false
22 | bin\Debug\
23 | DEBUG;TRACE
24 | prompt
25 | 4
26 | x86
27 |
28 |
29 | pdbonly
30 | true
31 | bin\Release\
32 | TRACE
33 | prompt
34 | 4
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 | {CCC50A71-DA40-4703-A638-3A045BD216ED}
53 | MTSDKDN
54 |
55 |
56 |
57 |
58 |
59 |
60 |
67 |
--------------------------------------------------------------------------------
/ConvertEquations/Backup/ConvertEquations/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using System.IO;
5 | using System.Runtime.InteropServices;
6 | using System.Reflection;
7 | using System.Runtime.InteropServices.ComTypes;
8 | using System.Windows.Forms;
9 | using System.Drawing;
10 | using System.Drawing.Imaging;
11 | using MTSDKDN;
12 |
13 | using IDataObject = System.Runtime.InteropServices.ComTypes.IDataObject;
14 |
15 | namespace ConvertEquations
16 | {
17 | /////////////////////////////////////////////
18 | /// SDK
19 | /////////////////////////////////////////////
20 | #region MTSDK class
21 | class MTSDK
22 | {
23 | // c-tor
24 | public MTSDK() { }
25 |
26 | // vars
27 | protected bool m_bDidInit = false;
28 |
29 | // init
30 | public bool Init()
31 | {
32 | if (!m_bDidInit)
33 | {
34 | Int32 result = MathTypeSDK.Instance.MTAPIConnectMgn(MTApiStartValues.mtinitLAUNCH_AS_NEEDED, 30);
35 | if (result == MathTypeReturnValue.mtOK)
36 | {
37 | m_bDidInit = true;
38 | return true;
39 | }
40 | else
41 | return false;
42 | }
43 | return true;
44 | }
45 |
46 | // de-init
47 | public bool DeInit()
48 | {
49 | if (m_bDidInit)
50 | {
51 | m_bDidInit = false;
52 | MathTypeSDK.Instance.MTAPIDisconnectMgn();
53 | }
54 | return true;
55 | }
56 |
57 | }
58 | #endregion
59 |
60 | /////////////////////////////////////////////
61 | /// Output Equation Classes
62 | /////////////////////////////////////////////
63 | #region EquationOutput Classes
64 | abstract class EquationOutput
65 | {
66 | // c-tor
67 | public EquationOutput(string strOutTrans)
68 | {
69 | if (!string.IsNullOrEmpty(strOutTrans))
70 | this.strOutTrans = strOutTrans;
71 | else
72 | this.strOutTrans = string.Empty;
73 | }
74 |
75 | protected EquationOutput() { }
76 |
77 | // properties
78 | protected short m_iType;
79 | public short iType
80 | {
81 | get { return m_iType; }
82 | protected set { m_iType = value; }
83 | }
84 |
85 | protected short m_iFormat;
86 | public short iFormat
87 | {
88 | get { return m_iFormat; }
89 | protected set { m_iFormat = value; }
90 | }
91 |
92 | private string m_strFileName;
93 | public string strFileName
94 | {
95 | get { return m_strFileName; }
96 | set { m_strFileName = value; }
97 | }
98 |
99 | private string m_strEquation;
100 | public string strEquation
101 | {
102 | get { return m_strEquation; }
103 | set { m_strEquation = value; }
104 | }
105 |
106 | // output translator
107 | protected string m_strOutTrans;
108 | public string strOutTrans
109 | {
110 | get { return m_strOutTrans; }
111 | set { m_strOutTrans = value; }
112 | }
113 |
114 | // save equation to its destination
115 | abstract public bool Put();
116 | }
117 |
118 | abstract class EquationOutputClipboard : EquationOutput
119 | {
120 | public EquationOutputClipboard(string strOutTrans)
121 | : base(strOutTrans)
122 | {
123 | strFileName = string.Empty;
124 | iType = MTXFormEqn.mtxfmCLIPBOARD;
125 | }
126 |
127 | public EquationOutputClipboard()
128 | : base()
129 | {
130 | strFileName = string.Empty;
131 | iType = MTXFormEqn.mtxfmCLIPBOARD;
132 | }
133 |
134 | public override bool Put() { return true; }
135 | }
136 |
137 | class EquationOutputClipboardText : EquationOutputClipboard
138 | {
139 | public EquationOutputClipboardText(string strOutTrans)
140 | : base(strOutTrans)
141 | {
142 | iFormat = MTXFormEqn.mtxfmTEXT;
143 | }
144 |
145 | public EquationOutputClipboardText()
146 | : base()
147 | {
148 | iFormat = MTXFormEqn.mtxfmTEXT;
149 | }
150 |
151 | public override string ToString() { return "Clipboard Text"; }
152 | }
153 |
154 | abstract class EquationOutputFile : EquationOutput
155 | {
156 | public EquationOutputFile(string strFileName, string strOutTrans)
157 | : base(strOutTrans)
158 | {
159 | this.strFileName = strFileName;
160 | iType = MTXFormEqn.mtxfmFILE;
161 | }
162 |
163 | protected EquationOutputFile(string strFileName)
164 | : base()
165 | {
166 | this.strFileName = strFileName;
167 | iType = MTXFormEqn.mtxfmFILE;
168 | }
169 |
170 | public override bool Put() { return true; }
171 | }
172 |
173 | class EquationOutputFileGIF : EquationOutputFile
174 | {
175 | public EquationOutputFileGIF(string strFileName)
176 | : base(strFileName)
177 | {
178 | iFormat = MTXFormEqn.mtxfmGIF;
179 | }
180 |
181 | public override string ToString() { return "GIF file"; }
182 | }
183 |
184 | class EquationOutputFileWMF : EquationOutputFile
185 | {
186 | public EquationOutputFileWMF(string strFileName)
187 | : base(strFileName)
188 | {
189 | iFormat = MTXFormEqn.mtxfmPICT;
190 | }
191 |
192 | public override string ToString() { return "WMF file"; }
193 | }
194 |
195 | class EquationOutputFileEPS : EquationOutputFile
196 | {
197 | public EquationOutputFileEPS(string strFileName)
198 | : base(strFileName)
199 | {
200 | iFormat = MTXFormEqn.mtxfmEPS_NONE;
201 | }
202 |
203 | public override string ToString() { return "EPS file"; }
204 | }
205 |
206 | class EquationOutputFileText : EquationOutputFile
207 | {
208 | public EquationOutputFileText(string strFileName, string strOutTrans)
209 | : base(strFileName, strOutTrans)
210 | {
211 | iType = MTXFormEqn.mtxfmLOCAL; // override base class as the convert function cannot directly write text files
212 | iFormat = MTXFormEqn.mtxfmTEXT;
213 | }
214 |
215 | public override bool Put()
216 | {
217 | try
218 | {
219 | FileStream stream = new FileStream(strFileName, FileMode.OpenOrCreate, FileAccess.Write);
220 | StreamWriter writer = new StreamWriter(stream);
221 | writer.WriteLine(strEquation);
222 | writer.Close();
223 | stream.Close();
224 | return true;
225 | }
226 | catch (Exception e)
227 | {
228 | Console.WriteLine(e.Message);
229 | return false;
230 | }
231 | }
232 |
233 | public override string ToString() { return "Text file"; }
234 | }
235 | #endregion
236 |
237 | /////////////////////////////////////////////
238 | /// Input Equation Classes
239 | /////////////////////////////////////////////
240 | #region EquationInput Classes
241 | abstract class EquationInput
242 | {
243 | // c-tor
244 | public EquationInput(string strInTrans)
245 | {
246 | if (!string.IsNullOrEmpty(strInTrans))
247 | this.strInTrans = strInTrans;
248 | else
249 | this.strInTrans = string.Empty;
250 | }
251 |
252 | protected short m_iType;
253 | public short iType
254 | {
255 | get { return m_iType; }
256 | protected set { m_iType = value; }
257 | }
258 |
259 | protected short m_iFormat;
260 | public short iFormat
261 | {
262 | get { return m_iFormat; }
263 | protected set { m_iFormat = value; }
264 | }
265 |
266 | // the equation as a string
267 | protected string m_strEquation;
268 | public string strEquation
269 | {
270 | get { return m_strEquation; }
271 | set { m_strEquation = value; }
272 | }
273 |
274 | // the equation as a byte array
275 | protected byte[] m_bEquation;
276 | public byte[] bEquation
277 | {
278 | get { return m_bEquation; }
279 | set { m_bEquation = value; }
280 | }
281 |
282 | // MTEF byte array
283 | protected byte[] m_bMTEF;
284 | public byte[] bMTEF
285 | {
286 | get { return m_bMTEF; }
287 | set { m_bMTEF = value; }
288 | }
289 |
290 | // MTEF byte array length
291 | protected int m_iMTEF_Length;
292 | public int iMTEF_Length
293 | {
294 | get { return m_iMTEF_Length; }
295 | set { m_iMTEF_Length = value; }
296 | }
297 |
298 | // MTEF string
299 | protected string m_strMTEF;
300 | public string strMTEF
301 | {
302 | get { return m_strMTEF; }
303 | set { m_strMTEF = value; }
304 | }
305 |
306 | // input translator
307 | protected string m_strInTrans;
308 | public string strInTrans
309 | {
310 | get { return m_strInTrans; }
311 | set { m_strInTrans = value; }
312 | }
313 |
314 | // the source equation file
315 | protected string m_strFileName;
316 | public string strFileName
317 | {
318 | get { return m_strFileName; }
319 | set { m_strFileName = value; }
320 | }
321 |
322 | protected MTSDK sdk = new MTSDK();
323 |
324 | // get the equation from the source
325 | abstract public bool Get();
326 |
327 | // get binary MTEF
328 | abstract public bool GetMTEF();
329 | }
330 |
331 | abstract class EquationInputClipboard : EquationInput
332 | {
333 | public EquationInputClipboard(string strInTrans)
334 | : base(strInTrans)
335 | {
336 | iType = MTXFormEqn.mtxfmCLIPBOARD;
337 | }
338 | }
339 |
340 | class EquationInputClipboardText : EquationInputClipboard
341 | {
342 | public EquationInputClipboardText(string strInTrans)
343 | : base(strInTrans)
344 | {
345 | iFormat = MTXFormEqn.mtxfmTEXT;
346 | }
347 |
348 | public override bool Get() { return true; }
349 | public override bool GetMTEF() { return true; }
350 | public override string ToString() { return "Clipboard text"; }
351 | }
352 |
353 | class EquationInputClipboardEmbeddedObject : EquationInputClipboard
354 | {
355 | public EquationInputClipboardEmbeddedObject()
356 | : base(ClipboardFormats.cfEmbeddedObj)
357 | {
358 | iFormat = MTXFormEqn.mtxfmMTEF;
359 | }
360 |
361 | public override bool Get() { return true; }
362 | public override bool GetMTEF() { return true; }
363 | public override string ToString() { return "Clipboard Embedded Object"; }
364 | }
365 |
366 | abstract class EquationInputFile : EquationInput
367 | {
368 | public EquationInputFile(string strFileName, string strInTrans)
369 | : base(strInTrans)
370 | {
371 | this.strFileName = strFileName;
372 | iType = MTXFormEqn.mtxfmLOCAL;
373 | }
374 | }
375 |
376 | class EquationInputFileText : EquationInputFile
377 | {
378 | public EquationInputFileText(string strFileName, string strInTrans)
379 | : base(strFileName, strInTrans)
380 | {
381 | iFormat = MTXFormEqn.mtxfmMTEF;
382 | }
383 |
384 | public override string ToString() { return "Text file"; }
385 |
386 | override public bool Get()
387 | {
388 | try
389 | {
390 | strEquation = System.IO.File.ReadAllText(strFileName);
391 | return true;
392 | }
393 | catch (Exception e)
394 | {
395 | Console.WriteLine(e.Message);
396 | return false;
397 | }
398 | }
399 |
400 | override public bool GetMTEF()
401 | {
402 | bool bReturn = false;
403 |
404 | if (!sdk.Init())
405 | return bReturn;
406 |
407 | IDataObject dataObject = MathTypeSDK.getIDataObject();
408 |
409 | if (dataObject == null)
410 | {
411 | sdk.DeInit();
412 | return bReturn;
413 | }
414 |
415 | FORMATETC formatEtc = new FORMATETC();
416 | STGMEDIUM stgMedium = new STGMEDIUM();
417 |
418 | try
419 | {
420 | // Setup the formatting information to use for the conversion.
421 | formatEtc.cfFormat = (Int16)DataFormats.GetFormat(strInTrans).Id;
422 | formatEtc.dwAspect = DVASPECT.DVASPECT_CONTENT;
423 | formatEtc.lindex = -1;
424 | formatEtc.ptd = (IntPtr)0;
425 | formatEtc.tymed = TYMED.TYMED_HGLOBAL;
426 |
427 | // Setup the MathML content to convert
428 | stgMedium.unionmember = Marshal.StringToHGlobalAuto(strEquation);
429 | stgMedium.tymed = TYMED.TYMED_HGLOBAL;
430 | stgMedium.pUnkForRelease = 0;
431 |
432 | // Perform the conversion
433 | dataObject.SetData(ref formatEtc, ref stgMedium, false);
434 |
435 | // Set the format for the output
436 | formatEtc.cfFormat = (Int16)DataFormats.GetFormat("MathType EF").Id;
437 | formatEtc.dwAspect = DVASPECT.DVASPECT_CONTENT;
438 | formatEtc.lindex = -1;
439 | formatEtc.ptd = (IntPtr)0;
440 | formatEtc.tymed = TYMED.TYMED_ISTORAGE;
441 |
442 | // Create a blank data structure to hold the converted result.
443 | stgMedium = new STGMEDIUM();
444 | stgMedium.tymed = TYMED.TYMED_NULL;
445 | stgMedium.pUnkForRelease = 0;
446 |
447 | // Get the conversion result in MTEF format
448 | dataObject.GetData(ref formatEtc, out stgMedium);
449 | }
450 | catch (COMException e)
451 | {
452 | Console.WriteLine("MathML conversion to MathType threw an exception: " + Environment.NewLine + e.ToString());
453 | sdk.DeInit();
454 | return bReturn;
455 | }
456 |
457 | // The pointer now becomes a Handle reference.
458 | HandleRef handleRef = new HandleRef(null, stgMedium.unionmember);
459 |
460 | try
461 | {
462 | // Lock in the handle to get the pointer to the data
463 | IntPtr ptrToHandle = MathTypeSDK.GlobalLock(handleRef);
464 |
465 | // Get the size of the memory block
466 | m_iMTEF_Length = MathTypeSDK.GlobalSize(handleRef);
467 |
468 | // New an array of bytes and Marshal the data across.
469 | m_bMTEF = new byte[m_iMTEF_Length];
470 | Marshal.Copy(ptrToHandle, m_bMTEF, 0, m_iMTEF_Length);
471 | m_strMTEF = System.Text.ASCIIEncoding.ASCII.GetString(m_bMTEF);
472 | bReturn = true;
473 | }
474 | catch (Exception e)
475 | {
476 | Console.WriteLine("Generation of image from MathType failed: " + Environment.NewLine + e.ToString());
477 | }
478 | finally
479 | {
480 | MathTypeSDK.GlobalUnlock(handleRef);
481 | }
482 |
483 | sdk.DeInit();
484 | return bReturn;
485 | }
486 | }
487 |
488 | class EquationInputFileWMF2 : EquationInputFile
489 | {
490 | public EquationInputFileWMF2(string strFileName) : base(strFileName, "")
491 | {
492 | iFormat = MTXFormEqn.mtxfmEPS_WMF;
493 | iType = MTXFormEqn.mtxfmFILE;
494 | }
495 |
496 | public override bool Get() { return true; }
497 |
498 | public override bool GetMTEF() { return true; }
499 | }
500 |
501 | class EquationInputFileWMF : EquationInputFile
502 | {
503 | public EquationInputFileWMF(string strFileName)
504 | : base(strFileName, "")
505 | {
506 | iFormat = MTXFormEqn.mtxfmMTEF;
507 | }
508 |
509 | public override bool Get() { return true; }
510 |
511 | public override string ToString() { return "WMF file"; }
512 |
513 | public override bool GetMTEF()
514 | {
515 | Play();
516 | if (!Succeeded())
517 | return false;
518 | return true;
519 | }
520 |
521 | protected class WmfForm : Form
522 | {
523 | public WmfForm() { }
524 | }
525 | protected WmfForm wf = new WmfForm();
526 |
527 | [StructLayout(LayoutKind.Sequential, Pack = 1)]
528 | protected struct wmfHeader
529 | {
530 | public Int16 iComment;
531 | public Int16 ix1;
532 | [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 8)]
533 | public string strSig;
534 | public Int16 iVer;
535 | public Int32 iTotalLen;
536 | public Int32 iDataLen;
537 | };
538 | protected wmfHeader m_wmfHeader;
539 |
540 | protected Metafile m_metafile;
541 | protected const string m_strSig = "AppsMFC";
542 | protected bool m_succeeded = false;
543 |
544 | protected void Play()
545 | {
546 | try
547 | {
548 | m_succeeded = false;
549 | Graphics.EnumerateMetafileProc metafileDelegate;
550 | Point destPoint;
551 | m_metafile = new Metafile(strFileName);
552 | metafileDelegate = new Graphics.EnumerateMetafileProc(MetafileCallback);
553 | destPoint = new Point(20, 10);
554 | Graphics graphics = wf.CreateGraphics();
555 | graphics.EnumerateMetafile(m_metafile, destPoint, metafileDelegate);
556 | }
557 | catch (Exception e)
558 | {
559 | Console.WriteLine(e.Message);
560 | }
561 | }
562 |
563 | protected bool Succeeded() { return m_succeeded; }
564 |
565 | protected bool MetafileCallback(
566 | EmfPlusRecordType recordType,
567 | int flags,
568 | int dataSize,
569 | IntPtr data,
570 | PlayRecordCallback callbackData)
571 | {
572 | byte[] dataArray = null;
573 | if (data != IntPtr.Zero)
574 | {
575 | dataArray = new byte[dataSize];
576 | Marshal.Copy(data, dataArray, 0, dataSize);
577 | if (recordType == EmfPlusRecordType.WmfEscape && dataSize >= Marshal.SizeOf(m_wmfHeader) && !m_succeeded)
578 | {
579 | m_wmfHeader = (wmfHeader)RawDeserialize(dataArray, 0, m_wmfHeader.GetType());
580 | if (m_wmfHeader.strSig.Equals(m_strSig, StringComparison.CurrentCultureIgnoreCase))
581 | {
582 | System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
583 | string strCompanyInfo = enc.GetString(dataArray, Marshal.SizeOf(m_wmfHeader), m_wmfHeader.iDataLen);
584 | int iNull = strCompanyInfo.IndexOf('\0');
585 | if (iNull >= 0)
586 | {
587 | int mtefStart = Marshal.SizeOf(m_wmfHeader) + iNull + 1;
588 | iMTEF_Length = m_wmfHeader.iDataLen;
589 | bMTEF = new byte[iMTEF_Length];
590 | Array.Copy(dataArray, mtefStart, bMTEF, 0, iMTEF_Length);
591 | m_succeeded = true;
592 | }
593 | }
594 | }
595 | }
596 |
597 | m_metafile.PlayRecord(recordType, flags, dataSize, dataArray);
598 |
599 | return true;
600 | }
601 |
602 | protected static object RawDeserialize(byte[] rawData, int position, Type anyType)
603 | {
604 | int rawsize = Marshal.SizeOf(anyType);
605 | if (rawsize > rawData.Length)
606 | return null;
607 | IntPtr buffer = Marshal.AllocHGlobal(rawsize);
608 | Marshal.Copy(rawData, position, buffer, rawsize);
609 | object retobj = Marshal.PtrToStructure(buffer, anyType);
610 | Marshal.FreeHGlobal(buffer);
611 | return retobj;
612 | }
613 | }
614 |
615 | class EquationInputFileGIF : EquationInputFile
616 | {
617 | public EquationInputFileGIF(string strFileName)
618 | : base(strFileName, "")
619 | {
620 | iFormat = MTXFormEqn.mtxfmMTEF;
621 | }
622 |
623 | public override string ToString() { return "GIF file"; }
624 |
625 | override public bool Get()
626 | {
627 | try
628 | {
629 | FileStream stream = new FileStream(strFileName, FileMode.Open, FileAccess.Read);
630 | BinaryReader reader = new BinaryReader(stream);
631 | int iArrayLength = (Int32)stream.Length;
632 | bEquation = reader.ReadBytes(iArrayLength);
633 | reader.Close();
634 | stream.Close();
635 | return true;
636 | }
637 | catch (Exception e)
638 | {
639 | Console.WriteLine(e.Message);
640 | return false;
641 | }
642 | }
643 |
644 | byte[] signature = { 0x21, 0xFF, 0x0B, 0x4d, 0x61, 0x74, 0x68, 0x54, 0x79, 0x70, 0x65, 0x30, 0x30, 0x31 };
645 |
646 | /*
647 | extracting MTEF from GIF files is described in the MathType SDK documentation, by default installed here:
648 | file:///C:/Program%20Files/MathTypeSDK/SDK/docs/MTEFstorage.htm#GIF%20Image%20Files
649 | */
650 | public override bool GetMTEF()
651 | {
652 | try
653 | {
654 | // search for signature
655 | int iSigStart = 0;
656 | while ((iSigStart = Array.IndexOf(bEquation, signature[0], iSigStart)) >= 0)
657 | {
658 | if (CompareArrays(bEquation, iSigStart, bEquation.Length, signature, 0, signature.Length))
659 | {
660 | // signature found
661 | int iIndex = iSigStart + signature.Length; // source array index
662 | iMTEF_Length = 0; // destination array index
663 | byte bLen; // current block length
664 |
665 | try
666 | {
667 | // copy MTEF blocks
668 | while ((bLen = (byte)bEquation.GetValue(iIndex)) > 0)
669 | {
670 | // resize destination array
671 | Array.Resize(ref m_bMTEF, iMTEF_Length + bLen);
672 | // copy from source to destination array
673 | Array.Copy(bEquation, iIndex + 1, bMTEF, iMTEF_Length, bLen);
674 | // track length of destination array
675 | iMTEF_Length += bLen;
676 | // point to next block in source array
677 | iIndex += bLen + 1;
678 | }
679 | }
680 | catch (Exception e)
681 | {
682 | Console.WriteLine(e.Message);
683 | return false;
684 | }
685 | return true;
686 | }
687 | iSigStart++;
688 | }
689 |
690 | return false;
691 | }
692 | catch (Exception e)
693 | {
694 | Console.WriteLine(e.Message);
695 | return false;
696 | }
697 | }
698 |
699 | protected bool CompareArrays(Array left, int leftStart, int leftLen, Array right, int rightStart, int rightLen)
700 | {
701 | int leftCompareNum = leftLen - leftStart;
702 | int rightCompareNum = rightLen - rightStart;
703 | int compareNum = leftCompareNum > rightCompareNum ? rightCompareNum : leftCompareNum;
704 |
705 | for (int x = 0; x < compareNum; x++)
706 | {
707 | if ((byte)left.GetValue(leftStart + x) != (byte)right.GetValue(rightStart + x))
708 | return false;
709 | }
710 | return true;
711 | }
712 | }
713 |
714 | class EquationInputFileEPS : EquationInputFile
715 | {
716 | public EquationInputFileEPS(string strFileName)
717 | : base(strFileName, "")
718 | {
719 | iFormat = MTXFormEqn.mtxfmTEXT;
720 | }
721 |
722 | public override string ToString() { return "EPS file"; }
723 |
724 | public override bool Get()
725 | {
726 | try
727 | {
728 | strEquation = System.IO.File.ReadAllText(strFileName);
729 | return true;
730 | }
731 | catch (Exception e)
732 | {
733 | Console.WriteLine(e.Message);
734 | return false;
735 | }
736 | }
737 |
738 | public override bool GetMTEF()
739 | {
740 | /*
741 | extracting MTEF from EPS files is described in the MathType SDK documentation, by default installed here:
742 | file:///C:/Program%20Files/MathTypeSDK/SDK/docs/MTEFstorage.htm#Translator%20Output
743 | */
744 | const string strSig1 = "MathType";
745 | const string strSig2 = "MTEF";
746 | int iSig1Start = 0;
747 | while ((iSig1Start = strEquation.IndexOf(strSig1, iSig1Start)) >= 0)
748 | {
749 | int iSig2Start = strEquation.IndexOf(strSig2, iSig1Start + 1);
750 | int iDelimStart = iSig1Start + strSig1.Length;
751 | int iDelimLen = iSig2Start - iDelimStart;
752 | if (iSig2Start < 0 || iDelimLen != 1)
753 | {
754 | iSig1Start++;
755 | continue;
756 | }
757 | string strDelim = strEquation.Substring(iDelimStart, iDelimLen);
758 | int id1 = strEquation.IndexOf(strDelim, iSig1Start);
759 | int id2 = strEquation.IndexOf(strDelim, id1 + 1);
760 | int id3 = strEquation.IndexOf(strDelim, id2 + 1);
761 | int id4 = strEquation.IndexOf(strDelim, id3 + 1);
762 | int id5 = strEquation.IndexOf(strDelim, id4 + 1);
763 | int id6 = strEquation.IndexOf(strDelim, id5 + 1);
764 | m_strMTEF = strEquation.Substring(iSig1Start, id6 - iSig1Start + 1);
765 | bMTEF = System.Text.Encoding.ASCII.GetBytes(m_strMTEF);
766 | iMTEF_Length = bMTEF.Length;
767 | return true;
768 | }
769 | return false;
770 | }
771 | }
772 | #endregion
773 |
774 | /////////////////////////////////////////////
775 | /// ConvertEquation Classes
776 | /////////////////////////////////////////////
777 | #region ConvertEquation Class
778 | class ConvertEquation
779 | {
780 | protected EquationInput m_ei;
781 | protected EquationOutput m_eo;
782 | protected MTSDK m_sdk = new MTSDK();
783 |
784 | // c-tor
785 | public ConvertEquation() { }
786 |
787 | // convert
788 | virtual public bool Convert(EquationInput ei, EquationOutput eo)
789 | {
790 | m_ei = ei;
791 | m_eo = eo;
792 | return Convert();
793 | }
794 |
795 | virtual protected bool Convert()
796 | {
797 | bool bReturn = false;
798 |
799 | Console.WriteLine("Converting {0} to {1}", m_ei.ToString(), m_eo.ToString());
800 |
801 | Console.WriteLine("Get equation: {0}", m_ei.strFileName);
802 | if (m_ei.Get())
803 | {
804 | Console.WriteLine("Get MTEF");
805 | if (m_ei.GetMTEF())
806 | {
807 | Console.WriteLine("Convert Equation");
808 | if (ConvertToOutput())
809 | {
810 | Console.WriteLine("Write equation: {0}", m_eo.strFileName);
811 | if (m_eo.Put())
812 | bReturn = true;
813 | }
814 | }
815 | }
816 |
817 | Console.WriteLine("Convert success: {0}\r\n", bReturn.ToString());
818 | return bReturn;
819 | }
820 |
821 | protected bool SetTranslator()
822 | {
823 | if (string.IsNullOrEmpty(m_eo.strOutTrans))
824 | return true;
825 |
826 | Int32 stat = MathTypeSDK.Instance.MTXFormSetTranslatorMgn(
827 | MTXFormSetTranslator.mtxfmTRANSL_INC_NAME + MTXFormSetTranslator.mtxfmTRANSL_INC_DATA,
828 | m_eo.strOutTrans);
829 | return stat == MathTypeReturnValue.mtOK;
830 | }
831 |
832 | protected bool ConvertToOutput()
833 | {
834 | bool bResult = false;
835 | try
836 | {
837 | if (!m_sdk.Init())
838 | return false;
839 |
840 | if (MathTypeSDK.Instance.MTXFormResetMgn() == MathTypeReturnValue.mtOK &&
841 | SetTranslator())
842 | {
843 | Int32 stat = 0;
844 | Int32 iBufferLength = 5000;
845 | StringBuilder strDest = new StringBuilder(iBufferLength);
846 | MTAPI_DIMS dims = new MTAPI_DIMS();
847 |
848 | // convert
849 | stat = MathTypeSDK.Instance.MTXFormEqnMgn(
850 | m_ei.iType,
851 | m_ei.iFormat,
852 | m_ei.bMTEF,
853 | m_ei.iMTEF_Length,
854 | m_eo.iType,
855 | m_eo.iFormat,
856 | strDest,
857 | iBufferLength,
858 | m_eo.strFileName,
859 | ref dims);
860 |
861 | // save equation
862 | if (stat == MathTypeReturnValue.mtOK)
863 | {
864 | m_eo.strEquation = strDest.ToString();
865 | bResult = true;
866 | }
867 | }
868 |
869 | m_sdk.DeInit();
870 | }
871 | catch (Exception e)
872 | {
873 | Console.WriteLine(e.Message);
874 | }
875 | return bResult;
876 | }
877 | }
878 | #endregion
879 |
880 | /////////////////////////////////////////////
881 | /// Program Class
882 | /////////////////////////////////////////////
883 | #region Program Class
884 | class Program
885 | {
886 | public string GetInputFolder(string strFile)
887 | {
888 | FileInfo fi = new FileInfo(Application.ExecutablePath);
889 | string strRet = System.IO.Path.Combine(fi.Directory.Parent.Parent.FullName, "Data");
890 | return System.IO.Path.Combine(strRet, strFile);
891 | }
892 |
893 | protected int iFileNum = 0;
894 | public string GetOutputFile(string strExt)
895 | {
896 | string strRet = Path.GetTempPath();
897 | string strFileName;
898 | strFileName = string.Format("Output{0}.{1}", iFileNum++, strExt);
899 | return System.IO.Path.Combine(strRet, strFileName);
900 | }
901 |
902 | public void MessagePause(string strMessage)
903 | {
904 | Console.WriteLine(strMessage);
905 | Console.ReadKey(true);
906 | }
907 |
908 | public void ClipboardToClipboard(Program p, ConvertEquation ce)
909 | {
910 | // copy MML text to clipboard
911 | p.MessagePause("Copy MathML to the clipboard, then press any key");
912 |
913 | // clipboard MML to clipboard
914 | ce.Convert(new EquationInputClipboardText(ClipboardFormats.cfMML),
915 | new EquationOutputClipboardText());
916 | p.MessagePause("Inspect the clipboard, then press any key");
917 |
918 | // copy Base 64 MTEF text to clipboard
919 | p.MessagePause("Copy Base 64 MTEF to the clipboard, then press any key");
920 |
921 | // clipboard Base 64 MTEF text to clipboard
922 | ce.Convert(new EquationInputClipboardText(ClipboardFormats.cfMML),
923 | new EquationOutputClipboardText());
924 | p.MessagePause("Inspect the clipboard, then press any key");
925 |
926 | // copy MathType equation to the clipboard from within Microsoft Word
927 | p.MessagePause("From MS Word, copy a MathType equation to the clipboard, then press any key");
928 |
929 | // clipboard Embedded Object to EPS file
930 | ce.Convert(new EquationInputClipboardEmbeddedObject(),
931 | new EquationOutputClipboardText());
932 | p.MessagePause("Inspect the clipboard, then press any key");
933 | }
934 |
935 | public void ClipboardToFile(Program p, ConvertEquation ce)
936 | {
937 | // copy MML text to the clipboard
938 | p.MessagePause("Copy MathML to the clipboard, then press any key");
939 |
940 | // clipboard MML to EPS file
941 | ce.Convert(new EquationInputClipboardText(ClipboardFormats.cfMML),
942 | new EquationOutputFileEPS(p.GetOutputFile("eps")));
943 |
944 | // clipboard MML to GIF file
945 | ce.Convert(new EquationInputClipboardText(ClipboardFormats.cfMML),
946 | new EquationOutputFileGIF(p.GetOutputFile("gif")));
947 |
948 | // clipboard MML to WMF file
949 | ce.Convert(new EquationInputClipboardText(ClipboardFormats.cfMML),
950 | new EquationOutputFileWMF(p.GetOutputFile("wmf")));
951 |
952 | // copy Base 64 MTEF text to the clipboard
953 | p.MessagePause("Copy Base 64 MTEF to the clipboard, then press any key");
954 |
955 | // clipboard Base 64 MTEF text to EPS
956 | ce.Convert(new EquationInputClipboardText(ClipboardFormats.cfMML),
957 | new EquationOutputFileEPS(p.GetOutputFile("eps")));
958 |
959 | // clipboard Base 64 MTEF text to GIF
960 | ce.Convert(new EquationInputClipboardText(ClipboardFormats.cfMML),
961 | new EquationOutputFileGIF(p.GetOutputFile("gif")));
962 |
963 | // clipboard Base 64 MTEF text to WMF
964 | ce.Convert(new EquationInputClipboardText(ClipboardFormats.cfMML),
965 | new EquationOutputFileWMF(p.GetOutputFile("wmf")));
966 |
967 | // copy MathType equation to the clipboard from within Microsoft Word
968 | p.MessagePause("From MS Word, copy a MathType equation to the clipboard, then press any key");
969 |
970 | // clipboard Embedded Object to EPS file
971 | ce.Convert(new EquationInputClipboardEmbeddedObject(),
972 | new EquationOutputFileEPS(p.GetOutputFile("eps")));
973 |
974 | // clipboard Embedded Object to GIF file
975 | ce.Convert(new EquationInputClipboardEmbeddedObject(),
976 | new EquationOutputFileGIF(p.GetOutputFile("gif")));
977 |
978 | // clipboard Embedded Object to WMF file
979 | ce.Convert(new EquationInputClipboardEmbeddedObject(),
980 | new EquationOutputFileWMF(p.GetOutputFile("wmf")));
981 | }
982 |
983 | public void ClipboardToLocal(Program p, ConvertEquation ce)
984 | {
985 | // copy MML text to the clipboard
986 | p.MessagePause("Copy MathML to the clipboard, then press any key");
987 |
988 | // clipboard MML to MML text file
989 | ce.Convert(new EquationInputClipboardText(ClipboardFormats.cfMML),
990 | new EquationOutputFileText(p.GetOutputFile("txt"), "MathML2 (m namespace).tdl"));
991 |
992 | // clipboard MML to Base 64 MTEF text file
993 | ce.Convert(new EquationInputClipboardText(ClipboardFormats.cfMML),
994 | new EquationOutputFileText(p.GetOutputFile("txt"), "")); // specifying no translator outputs MTEF
995 |
996 | // copy Base 64 MTEF text to clipboard
997 | p.MessagePause("Copy Base 64 MTEF to the clipboard, then press any key");
998 |
999 | // clipboard Base 64 MTEF text to TeX text file
1000 | ce.Convert(new EquationInputClipboardText(ClipboardFormats.cfMML),
1001 | new EquationOutputFileText(p.GetOutputFile("txt"), "Texvc.tdl"));
1002 |
1003 | // clipboard Base 64 MTEF text to Base 64 MTEF text file
1004 | ce.Convert(new EquationInputClipboardText(ClipboardFormats.cfMML),
1005 | new EquationOutputFileText(p.GetOutputFile("txt"), "")); // specifying no translator outputs MTEF
1006 |
1007 | // copy MathType equation to the clipboard from within Microsoft Word
1008 | p.MessagePause("From MS Word, copy a MathType equation to the clipboard, then press any key");
1009 |
1010 | // clipboard Embedded Object to TeX text file
1011 | ce.Convert(new EquationInputClipboardEmbeddedObject(),
1012 | new EquationOutputFileText(p.GetOutputFile("txt"), "Texvc.tdl"));
1013 |
1014 | // clipboard Embedded Object to base64 MTEF text file
1015 | ce.Convert(new EquationInputClipboardEmbeddedObject(),
1016 | new EquationOutputFileText(p.GetOutputFile("txt"), "")); // specifying no translator outputs MTEF
1017 | }
1018 |
1019 | public void FileToClipboard(Program p, ConvertEquation ce)
1020 | {
1021 | // break after each of the following to inspect the clipboard
1022 | // EPS file to clipboard text
1023 | ce.Convert(new EquationInputFileEPS(p.GetInputFolder("Equation3.eps")),
1024 | new EquationOutputClipboardText());
1025 | p.MessagePause("Inspect the clipboard, then press any key");
1026 |
1027 | // GIF file to clipboard text
1028 | ce.Convert(new EquationInputFileGIF(p.GetInputFolder("Equation2.gif")),
1029 | new EquationOutputClipboardText());
1030 | p.MessagePause("Inspect the clipboard, then press any key");
1031 |
1032 | // WMF file to clipboard text
1033 | ce.Convert(new EquationInputFileWMF(p.GetInputFolder("Equation1.wmf")),
1034 | new EquationOutputClipboardText());
1035 | p.MessagePause("Inspect the clipboard, then press any key");
1036 | }
1037 |
1038 | public void FileToFile(Program p, ConvertEquation ce)
1039 | {
1040 | // WMF file to EPS file
1041 | ce.Convert(new EquationInputFileWMF(p.GetInputFolder("Equation1.wmf")),
1042 | new EquationOutputFileEPS(p.GetOutputFile("eps")));
1043 |
1044 | // WMF file to GIF file
1045 | ce.Convert(new EquationInputFileWMF(p.GetInputFolder("Equation1.wmf")),
1046 | new EquationOutputFileGIF(p.GetOutputFile("gif")));
1047 |
1048 | // WMF file to WMF file
1049 | ce.Convert(new EquationInputFileWMF(p.GetInputFolder("Equation1.wmf")),
1050 | new EquationOutputFileWMF(p.GetOutputFile("wmf")));
1051 |
1052 | // GIF file to EPS file
1053 | ce.Convert(new EquationInputFileGIF(p.GetInputFolder("Equation2.gif")),
1054 | new EquationOutputFileEPS(p.GetOutputFile("eps")));
1055 |
1056 | // GIF file to GIF file
1057 | ce.Convert(new EquationInputFileGIF(p.GetInputFolder("Equation2.gif")),
1058 | new EquationOutputFileGIF(p.GetOutputFile("gif")));
1059 |
1060 | // GIF file to WMF file
1061 | ce.Convert(new EquationInputFileGIF(p.GetInputFolder("Equation2.gif")),
1062 | new EquationOutputFileWMF(p.GetOutputFile("wmf")));
1063 |
1064 | // EPS file to EPS file
1065 | ce.Convert(new EquationInputFileEPS(p.GetInputFolder("Equation3.eps")),
1066 | new EquationOutputFileEPS(p.GetOutputFile("eps")));
1067 |
1068 | // EPS file to GIF file
1069 | ce.Convert(new EquationInputFileEPS(p.GetInputFolder("Equation3.eps")),
1070 | new EquationOutputFileGIF(p.GetOutputFile("gif")));
1071 |
1072 | // EPS file to WMF file
1073 | ce.Convert(new EquationInputFileEPS(p.GetInputFolder("Equation3.eps")),
1074 | new EquationOutputFileWMF(p.GetOutputFile("wmf")));
1075 | }
1076 |
1077 | public void FileToLocal(Program p, ConvertEquation ce)
1078 | {
1079 | // WMF file to MML text file
1080 | ce.Convert(new EquationInputFileWMF(p.GetInputFolder("Equation1.wmf")),
1081 | new EquationOutputFileText(p.GetOutputFile("txt"), "MathML2 (m namespace).tdl"));
1082 |
1083 | // WMF file to TeX text file
1084 | ce.Convert(new EquationInputFileWMF(p.GetInputFolder("Equation1.wmf")),
1085 | new EquationOutputFileText(p.GetOutputFile("txt"), "Texvc.tdl"));
1086 |
1087 | // WMF file to base64 MTEF text file
1088 | ce.Convert(new EquationInputFileWMF(p.GetInputFolder("Equation1.wmf")),
1089 | new EquationOutputFileText(p.GetOutputFile("txt"), "")); // specifying no translator outputs MTEF
1090 |
1091 | // GIF file to MML text file
1092 | ce.Convert(new EquationInputFileGIF(p.GetInputFolder("Equation2.gif")),
1093 | new EquationOutputFileText(p.GetOutputFile("txt"), "MathML2 (m namespace).tdl"));
1094 |
1095 | // GIF file to base64 MTEF text file
1096 | ce.Convert(new EquationInputFileGIF(p.GetInputFolder("Equation2.gif")),
1097 | new EquationOutputFileText(p.GetOutputFile("txt"), "")); // specifying no translator outputs MTEF
1098 |
1099 | // EPS file to MML text file
1100 | ce.Convert(new EquationInputFileEPS(p.GetInputFolder("Equation3.eps")),
1101 | new EquationOutputFileText(p.GetOutputFile("txt"), "MathML2 (m namespace).tdl"));
1102 |
1103 | // EPS file to base64 MTEF text file
1104 | ce.Convert(new EquationInputFileEPS(p.GetInputFolder("Equation3.eps")),
1105 | new EquationOutputFileText(p.GetOutputFile("txt"), "")); // specifying no translator outputs MTEF
1106 | }
1107 |
1108 | public void LocalToClipboard(Program p, ConvertEquation ce)
1109 | {
1110 | // MML in a text file to clipboard text
1111 | ce.Convert(new EquationInputFileText(p.GetInputFolder("MathML.txt"), ClipboardFormats.cfMML),
1112 | new EquationOutputClipboardText());
1113 | p.MessagePause("Inspect the clipboard, then press any key");
1114 |
1115 | // Base 64 MTEF in a text file to clipboard
1116 | ce.Convert(new EquationInputFileText(p.GetInputFolder("Base64MTEF.txt"), ClipboardFormats.cfMML),
1117 | new EquationOutputClipboardText());
1118 | p.MessagePause("Inspect the clipboard, then press any key");
1119 | }
1120 |
1121 | public void LocalToFile(Program p, ConvertEquation ce)
1122 | {
1123 | // TeX in a text file to EPS
1124 | ce.Convert(new EquationInputFileText(p.GetInputFolder("TeX.txt"), ClipboardFormats.cfTeX),
1125 | new EquationOutputFileEPS(p.GetOutputFile("eps")));
1126 |
1127 | // MML in a text file to GIF
1128 | ce.Convert(new EquationInputFileText(p.GetInputFolder("MathML.txt"), ClipboardFormats.cfMML),
1129 | new EquationOutputFileGIF(p.GetOutputFile("gif")));
1130 |
1131 | // TeX in a text file to GIF
1132 | ce.Convert(new EquationInputFileText(p.GetInputFolder("TeX.txt"), ClipboardFormats.cfTeX),
1133 | new EquationOutputFileGIF(p.GetOutputFile("gif")));
1134 |
1135 | // MML in a text file to WMF
1136 | ce.Convert(new EquationInputFileText(p.GetInputFolder("MathML.txt"), ClipboardFormats.cfMML),
1137 | new EquationOutputFileWMF(p.GetOutputFile("wmf")));
1138 |
1139 | // Base 64 MTEF in a text file to EPS
1140 | ce.Convert(new EquationInputFileText(p.GetInputFolder("Base64MTEF.txt"), ClipboardFormats.cfMML),
1141 | new EquationOutputFileEPS(p.GetOutputFile("eps")));
1142 |
1143 | // Base 64 MTEF in a text file to GIF
1144 | ce.Convert(new EquationInputFileText(p.GetInputFolder("Base64MTEF.txt"), ClipboardFormats.cfMML),
1145 | new EquationOutputFileGIF(p.GetOutputFile("gif")));
1146 |
1147 | // Base 64 MTEF in a text file to WMF
1148 | ce.Convert(new EquationInputFileText(p.GetInputFolder("Base64MTEF.txt"), ClipboardFormats.cfMML),
1149 | new EquationOutputFileWMF(p.GetOutputFile("wmf")));
1150 | }
1151 |
1152 | public void LocalToLocal(Program p, ConvertEquation ce)
1153 | {
1154 | // TeX in a text file to MML text file
1155 | ce.Convert(new EquationInputFileText(p.GetInputFolder("TeX.txt"), ClipboardFormats.cfTeX),
1156 | new EquationOutputFileText(p.GetOutputFile("txt"), "MathML2 (m namespace).tdl"));
1157 |
1158 | // TeX in a text file to Base 64 MTEF in a text file
1159 | ce.Convert(new EquationInputFileText(p.GetInputFolder("TeX.txt"), ClipboardFormats.cfTeX),
1160 | new EquationOutputFileText(p.GetOutputFile("txt"), "")); // specifying no translator outputs MTEF
1161 |
1162 | // Base 64 MTEF in a text file to MML text file
1163 | ce.Convert(new EquationInputFileText(p.GetInputFolder("Base64MTEF.txt"), ClipboardFormats.cfMML),
1164 | new EquationOutputFileText(p.GetOutputFile("txt"), "MathML2 (m namespace).tdl"));
1165 |
1166 | // Base 64 MTEF in a text file to Base 64 MTEF in a text file
1167 | ce.Convert(new EquationInputFileText(p.GetInputFolder("Base64MTEF.txt"), ClipboardFormats.cfMML),
1168 | new EquationOutputFileText(p.GetOutputFile("txt"), "")); // specifying no translator outputs MTEF
1169 | }
1170 |
1171 | public void Temp(ConvertEquation ce)
1172 | {
1173 | ce.Convert(new EquationInputFileWMF(@"C:\Temp\Object1.wmf"),
1174 | new EquationOutputFileText(@"C:\Temp\temp.txt", "MathML2 (m namespace).tdl"));
1175 |
1176 | ce.Convert(new EquationInputFileWMF(@"C:\Temp\FromMT.wmf"),
1177 | new EquationOutputFileText(@"C:\Temp\temp.txt", "MathML2 (m namespace).tdl"));
1178 | }
1179 |
1180 | static void Main(string[] args)
1181 | {
1182 | Program p = new Program();
1183 | ConvertEquation ce = new ConvertEquation();
1184 |
1185 | /*
1186 | * These routines:
1187 | * ClipboardToClipboard
1188 | * FileToClipboard
1189 | * LocalToClipboard
1190 | * Place the following types on the clipboard:
1191 | * MathType EF
1192 | * MathML Presentation
1193 | * MathML
1194 | * application/mathml+xml
1195 | * CF_METAFILEPICT
1196 | * MathType Macro PICT
1197 | * Embed Source
1198 | * Object Descriptor
1199 | */
1200 |
1201 | //p.ClipboardToClipboard(p, ce);
1202 | //p.ClipboardToFile(p, ce);
1203 | //p.ClipboardToLocal(p, ce);
1204 |
1205 | //p.FileToClipboard(p, ce);
1206 | //p.FileToFile(p, ce);
1207 | //p.FileToLocal(p, ce);
1208 |
1209 | //p.LocalToClipboard(p, ce);
1210 | //p.LocalToFile(p, ce);
1211 | //p.LocalToLocal(p, ce);
1212 | //p.Temp(ce);
1213 | }
1214 | }
1215 | #endregion
1216 | }
1217 |
1218 | #region MTXFormEqn Doc
1219 | /*
1220 | SHORT src, // [in] Equation data source, either
1221 | // mtxfmPREVIOUS => data from previous result
1222 | // mtxfmCLIPBOARD => data on clipboard
1223 | // mtxfmLOCAL => data passed (i.e. in srcData)
1224 | SHORT srcFmt, // [in] Equation source data format (mtxfmXXX, see next)
1225 | // Note: srcFmt, srcData, and srcDataLen are used only
1226 | // if src is mtfxmLOCAL
1227 | LPCVOID srcData, // [in] Depends on data source (src)
1228 | // mtxfmMTEF => ptr to MTEF-binary (BYTE *)
1229 | // mtxfmPICT => ptr to pict (MTAPI_PICT *)
1230 | // mtxfmTEXT => ptr to text (CHAR *), either MTEF-text or plain text
1231 | LONG srcDataLen, // [in] # of bytes in srcData
1232 | *
1233 | * ///////////////////////////////
1234 | *
1235 | SHORT dst, // [in] Equation data destination, either
1236 | // mtxfmCLIPBOARD => transformed data placed on clipboard
1237 | // mtxfmLOCAL => transformed data in dstData
1238 | // mtxfmFILE => transformed data in the file specified by dstPath
1239 | SHORT dstFmt, // [in] Equation data format (mtxfmXXX, see next)
1240 | // Note: dstFmt, dstData, and dstDataLen are used only
1241 | // if dst is mtfxmLOCAL (data placed on the clipboard
1242 | // is either an OLE object or translator text)
1243 | LPVOID dstData, // [out] Depends on data destination (dstFmt)
1244 | // mtxfmMTEF => ptr to MTEF-binary (BYTE *)
1245 | // mtxfmHMTEF => ptr to handle to MTEF-binary (HANDLE *)
1246 | // mtxfmPICT => ptr to pict data (MTAPI_PICT *)
1247 | // mtxfmTEXT => ptr to translated text or, if no translator, MTEF-text (CHAR *)
1248 | // mtxfmHTEXT => ptr to handle to translated text or, if no translator, MTEF-text (HANDLE *)
1249 | // Note: If translator specified dst must be either
1250 | // mtxfmTEXT or mtxfmHTEXT for the translation to be performed
1251 | LONG dstDataLen, // [in] # of bytes in dstData (used for mtxfmLOCAL only)
1252 | LPCSTR dstPath, // [in] destination pathname (used if dst == mtxfmFILE only, may be NULL if not used)
1253 | *
1254 | * ///////////////////////////////
1255 | *
1256 | MTAPI_DIMS *dims // [out] pict dimensions, may be NULL (valid only for
1257 | // dst = mtxfmPICT)
1258 | */
1259 | #endregion
1260 |
--------------------------------------------------------------------------------
/ConvertEquations/Backup/MTSDKDN/MTSDKDN.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | Debug
4 | AnyCPU
5 | 8.0.50727
6 | 2.0
7 | {CCC50A71-DA40-4703-A638-3A045BD216ED}
8 | Library
9 | Properties
10 | MTSDKDN
11 | MTSDKDN
12 |
13 |
14 | 2.0
15 |
16 |
17 |
18 |
19 | true
20 | full
21 | false
22 | bin\Debug\
23 | DEBUG;TRACE
24 | prompt
25 | 4
26 |
27 |
28 | pdbonly
29 | true
30 | bin\Release\
31 | TRACE
32 | prompt
33 | 4
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
53 |
--------------------------------------------------------------------------------
/ConvertEquations/Backup/MTSDKDN/MTSDKDN.csproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 | false
4 |
5 |
--------------------------------------------------------------------------------
/ConvertEquations/Backup/MTSDKDN/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // AssemblyInfo.cs --- Copyright (c) 2008-2010 by Design Science, Inc.
2 | // Purpose:
3 | // $Header: /MathType/Windows/SDK/DotNET/MTSDKDN/MTSDKDN/Properties/AssemblyInfo.cs 3 1/19/10 2:02p Jimm $
4 |
5 | using System.Reflection;
6 | using System.Runtime.CompilerServices;
7 | using System.Runtime.InteropServices;
8 |
9 | // General Information about an assembly is controlled through the following
10 | // set of attributes. Change these attribute values to modify the information
11 | // associated with an assembly.
12 | [assembly: AssemblyTitle("MTSDKDN")]
13 | [assembly: AssemblyDescription("DotNET assembly wrapper for the MathType SDK")]
14 | [assembly: AssemblyConfiguration("")]
15 | [assembly: AssemblyCompany("Design Science Inc.")]
16 | [assembly: AssemblyProduct("MTSDKDN")]
17 | [assembly: AssemblyCopyright("Copyright © 2008")]
18 | [assembly: AssemblyTrademark("")]
19 | [assembly: AssemblyCulture("")]
20 |
21 | // Setting ComVisible to false makes the types in this assembly not visible
22 | // to COM components. If you need to access a type in this assembly from
23 | // COM, set the ComVisible attribute to true on that type.
24 | [assembly: ComVisible(false)]
25 |
26 | // The following GUID is for the ID of the typelib if this project is exposed to COM
27 | [assembly: Guid("d054586a-5e64-4f4f-80d0-bb7a674d7dd4")]
28 |
29 | // Version information for an assembly consists of the following four values:
30 | //
31 | // Major Version
32 | // Minor Version
33 | // Build Number
34 | // Revision
35 | //
36 | // You can specify all the values or you can default the Revision and Build Numbers
37 | // by using the '*' as shown below:
38 | [assembly: AssemblyVersion("1.0.0.0")]
39 | [assembly: AssemblyFileVersion("1.0.0.0")]
40 |
--------------------------------------------------------------------------------
/ConvertEquations/ConvertEquations.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 11.00
3 | # Visual Studio 2010
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConvertEquations", "ConvertEquations\ConvertEquations.csproj", "{9FA59BF2-54BC-4DE6-8725-C9D4D732A712}"
5 | EndProject
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MTSDKDN", "..\MTSDKDN\MTSDKDN\MTSDKDN.csproj", "{CCC50A71-DA40-4703-A638-3A045BD216ED}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {9FA59BF2-54BC-4DE6-8725-C9D4D732A712}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {9FA59BF2-54BC-4DE6-8725-C9D4D732A712}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {9FA59BF2-54BC-4DE6-8725-C9D4D732A712}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {9FA59BF2-54BC-4DE6-8725-C9D4D732A712}.Release|Any CPU.Build.0 = Release|Any CPU
18 | {CCC50A71-DA40-4703-A638-3A045BD216ED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19 | {CCC50A71-DA40-4703-A638-3A045BD216ED}.Debug|Any CPU.Build.0 = Debug|Any CPU
20 | {CCC50A71-DA40-4703-A638-3A045BD216ED}.Release|Any CPU.ActiveCfg = Release|Any CPU
21 | {CCC50A71-DA40-4703-A638-3A045BD216ED}.Release|Any CPU.Build.0 = Release|Any CPU
22 | EndGlobalSection
23 | GlobalSection(SolutionProperties) = preSolution
24 | HideSolutionNode = FALSE
25 | EndGlobalSection
26 | EndGlobal
27 |
--------------------------------------------------------------------------------
/ConvertEquations/ConvertEquations.suo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scalad/MathML2MathTypeEquation/0419df197a27dbace7de647bcbf21690a3ef1d5c/ConvertEquations/ConvertEquations.suo
--------------------------------------------------------------------------------
/ConvertEquations/ConvertEquations/ClassDiagram1.cd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAACABAAAAA=
7 | MathTypeSDK.cs
8 |
9 |
10 |
11 |
12 |
13 | AQCAAAAAAIIAAAEAAAAAAIAAAAAQAAAAAAIACAABAAg=
14 | MathTypeSDK.cs
15 |
16 |
17 |
18 |
19 |
20 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAg=
21 | Program.cs
22 |
23 |
24 |
25 |
26 |
27 | AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAA=
28 | Program.cs
29 |
30 |
31 |
32 |
33 |
34 | AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAA=
35 | Program.cs
36 |
37 |
38 |
39 |
40 |
41 | AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAA=
42 | Program.cs
43 |
44 |
45 |
46 |
47 |
48 | AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAg=
49 | Program.cs
50 |
51 |
52 |
53 |
54 |
55 | ARCAAAAAAIAAAAFACCCAAIABQAAAAAAIAAIACAABAAg=
56 | MathTypeSDK.cs
57 |
58 |
59 |
60 |
61 |
62 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
63 | Program.cs
64 |
65 |
66 |
67 |
68 |
69 | AAAAAAAAAAAAAABEACAAAAAAAAAAAAAAAAAAAAAAAAA=
70 | Program.cs
71 |
72 |
73 |
74 |
75 |
76 | AAAAAAAAAAAAAABEACAAAAAAAAAAAAAAAAAAAAAAAAA=
77 | Program.cs
78 |
79 |
80 |
81 |
82 |
83 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
84 | MathTypeSDK.cs
85 |
86 |
87 |
88 |
89 |
90 | AAAAAAAAAAAAAABEACAAAAAAAAAAAAAAAAAAAAAAAAA=
91 | MathTypeSDK.cs
92 |
93 |
94 |
95 |
96 |
97 | AAAAAAEAIoAAAABEACAAAAAAAgAAAAAAgAAJAAAAAIA=
98 | Program.cs
99 |
100 |
101 |
102 |
103 |
104 | AAAAAQAAAAAAAABEACAAAAAAAAAAAgAAAAAAAAAAAAA=
105 | Program.cs
106 |
107 |
108 |
109 |
110 |
111 | AAAAAAAAAAAAAABEACAAAAAAAAAAAAAAAAAAAAAAAAA=
112 | Program.cs
113 |
114 |
115 |
116 |
117 |
118 | AAAAAAAAAAAAAAAAAIAAAAQAAAACAIAhAAAAAAAAAAA=
119 | MathTypeSDK.cs
120 |
121 |
122 |
123 |
124 |
125 | AAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAABAACAAA=
126 | Program.cs
127 |
128 |
129 |
130 |
131 |
132 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAg=
133 | MathTypeSDK.cs
134 |
135 |
136 |
137 |
138 |
139 | AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAA=
140 | MathTypeSDK.cs
141 |
142 |
143 |
144 |
--------------------------------------------------------------------------------
/ConvertEquations/ConvertEquations/Common.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.IO;
6 | using System.Windows.Forms;
7 | using System.Text.RegularExpressions;
8 | using System.Runtime.InteropServices;
9 | using Word = Microsoft.Office.Interop.Word;
10 | using System.Collections;
11 |
12 | namespace ConvertEquations
13 | {
14 | ///
15 | /// MathML处理
16 | ///
17 | class MathML
18 | {
19 |
20 | public static Hashtable equations = new Hashtable();
21 |
22 | ///
23 | /// MathType不可识别的字符映射关系
24 | ///
25 | static MathML()
26 | {
27 | equations.Add("∆", "Δ");
28 | equations.Add("<", "<");
29 | equations.Add(">", ">");
30 | equations.Add("⪈", "≩");
31 | equations.Add("⪇", "≨");
32 | equations.Add("≢", "≠");
33 | equations.Add("⊝", "⊖");
34 | equations.Add("·", "⋅");
35 | equations.Add("⋅", "⋅");
36 | equations.Add(" ", "");
37 | equations.Add("¡Î", "∥");//||
38 | }
39 |
40 | //预处理mathml
41 | public static string preproccessMathml(string mathml)
42 | {
43 | string replaceHtml = mathml;
44 | foreach (DictionaryEntry de in equations)
45 | {
46 | string tmp = replaceHtml.Replace(de.Key.ToString(), de.Value.ToString());
47 | replaceHtml = tmp;
48 | }
49 | return replaceHtml;
50 | }
51 | }
52 |
53 | ///
54 | /// Word操作工具类
55 | ///
56 | class WordUtils
57 | {
58 | public static object nothing = System.Reflection.Missing.Value;
59 |
60 | ///
61 | /// 向左移动moveCount个光标
62 | ///
63 | ///
64 | ///
65 | public static void moveLeft(Word.Document document, int moveCount)
66 | {
67 | if (moveCount <= 0) return;
68 | object moveUnit = Microsoft.Office.Interop.Word.WdUnits.wdWord;
69 | object moveExtend = Microsoft.Office.Interop.Word.WdMovementType.wdExtend;
70 | document.Application.Selection.MoveLeft(ref moveUnit, moveCount, ref nothing);
71 | }
72 | }
73 |
74 | ///
75 | /// Global and static variables
76 | ///
77 | class Common
78 | {
79 | //Filter the src in the html img tag
80 | public static string HTML_IMG = @"
]*?\bsrc[\s\t\r\n]*=[\s\t\r\n]*[""']?[\s\t\r\n]*(?[^\s\t\r\n""'<>]*)[^<>]*?/?[\s\t\r\n]*>";
81 | }
82 |
83 | ///
84 | /// HTML translator util
85 | ///
86 | class HTMLUtils
87 | {
88 | // 将HTML代码复制到Windows剪贴板,并保证中
89 | [DllImport("user32.dll")]
90 | static extern bool OpenClipboard(IntPtr hWndNewOwner);
91 | [DllImport("user32.dll")]
92 | static extern bool EmptyClipboard();
93 | [DllImport("user32.dll")]
94 | static extern IntPtr SetClipboardData(uint uFormat, IntPtr hMem);
95 | [DllImport("user32.dll")]
96 | static extern bool CloseClipboard();
97 | [DllImport("user32.dll", SetLastError = true)]
98 | static extern uint RegisterClipboardFormatA(string lpszFormat);
99 |
100 | [DllImport("kernel32.dll", SetLastError = true)]
101 | static extern IntPtr GlobalLock(IntPtr hMem);
102 | [DllImport("kernel32.dll", SetLastError = true)]
103 | static extern uint GlobalSize(IntPtr hMem);
104 | [DllImport("kernel32.dll", SetLastError = true)]
105 | static extern IntPtr GlobalUnlock(IntPtr hMem);
106 |
107 | ///
108 | /// copy the html into clipboard
109 | ///
110 | ///
111 | ///
112 | static public bool CopyHTMLToClipboard(string html)
113 | {
114 | uint CF_HTML = RegisterClipboardFormatA("HTML Format");
115 | bool bResult = false;
116 | if (OpenClipboard(IntPtr.Zero))
117 | {
118 | if (EmptyClipboard())
119 | {
120 | byte[] bs = System.Text.Encoding.UTF8.GetBytes(html);
121 |
122 | int size = Marshal.SizeOf(typeof(byte)) * bs.Length;
123 |
124 | IntPtr ptr = Marshal.AllocHGlobal(size);
125 | Marshal.Copy(bs, 0, ptr, bs.Length);
126 |
127 | IntPtr hRes = SetClipboardData(CF_HTML, ptr);
128 | CloseClipboard();
129 | }
130 | }
131 | return bResult;
132 | }
133 |
134 | //将HTML代码按照Windows剪贴板格进行格式化
135 | public static string HtmlClipboardData(string html)
136 | {
137 | StringBuilder sb = new StringBuilder();
138 | Encoding encoding = Encoding.UTF8; //Encoding.GetEncoding(936);
139 | string Header = @"Version: 1.0
140 | StartHTML: {0:000000}
141 | EndHTML: {1:000000}
142 | StartFragment: {2:000000}
143 | EndFragment: {3:000000}
144 | ";
145 | string HtmlPrefix = @"
146 |
147 |
148 |
149 |
150 |
151 |
152 | ";
153 | HtmlPrefix = string.Format(HtmlPrefix, "gb2312");
154 |
155 | string HtmlSuffix = @"";
156 |
157 | // Get lengths of chunks
158 | int HeaderLength = encoding.GetByteCount(Header);
159 | HeaderLength -= 16; // extra formatting characters {0:000000}
160 | int PrefixLength = encoding.GetByteCount(HtmlPrefix);
161 | int HtmlLength = encoding.GetByteCount(html);
162 | int SuffixLength = encoding.GetByteCount(HtmlSuffix);
163 |
164 | // Determine locations of chunks
165 | int StartHtml = HeaderLength;
166 | int StartFragment = StartHtml + PrefixLength;
167 | int EndFragment = StartFragment + HtmlLength;
168 | int EndHtml = EndFragment + SuffixLength;
169 |
170 | // Build the data
171 | sb.AppendFormat(Header, StartHtml, EndHtml, StartFragment, EndFragment);
172 | sb.Append(HtmlPrefix);
173 | sb.Append(html);
174 | sb.Append(HtmlSuffix);
175 |
176 | //Console.WriteLine(sb.ToString());
177 | return sb.ToString();
178 | }
179 | }
180 |
181 | ///
182 | /// System Code
183 | ///
184 | sealed class ResultCode
185 | {
186 | public static string SUCCESS = "转换成功";
187 | public static string WORD_ERROR = "Word错误";
188 | public static string WORD_SAVE_ERROR = "Word存储错误";
189 | public static string EXCEL_ERROR = "Excel错误";
190 | public static string EXCEL_READ_ERROR = "Excel读取错误";
191 | public static string FILE_PATH_ERROR = "文件位置错误";
192 | }
193 |
194 | ///
195 | /// System Utils
196 | ///
197 | class Utils
198 | {
199 | ///
200 | /// delete download file
201 | ///
202 | /// file full path collections
203 | public static void deleteFile(List names)
204 | {
205 | if (names == null || names.Count <= 0)
206 | {
207 | return;
208 | }
209 | else
210 | {
211 | foreach (string name in names)
212 | {
213 | if (File.Exists(name))
214 | {
215 | FileInfo info = new FileInfo(name);
216 | if (info.Attributes.ToString().IndexOf("ReadOnly") != -1)
217 | info.Attributes = FileAttributes.Normal;
218 | File.Delete(name);
219 | }
220 | }
221 | }
222 | }
223 |
224 | ///
225 | /// kill a process
226 | ///
227 | ///
228 | public static void killAllProcess(string processName)
229 | {
230 | System.Diagnostics.Process[] myPs;
231 | myPs = System.Diagnostics.Process.GetProcesses();
232 | foreach (System.Diagnostics.Process p in myPs)
233 | {
234 | if (p.Id != 0)
235 | {
236 | try
237 | {
238 | if (p.Modules != null)
239 | if (p.Modules.Count > 0)
240 | {
241 | System.Diagnostics.ProcessModule pm = p.Modules[0];
242 | if (pm.ModuleName.ToLower() == processName)
243 | p.Kill();
244 | }
245 | }
246 | catch
247 | { }
248 | }
249 | }
250 | }
251 |
252 | //filter html tag
253 | public static string NoHTML(string Htmlstring)
254 | {
255 | //delete the script
256 | Htmlstring = Regex.Replace(Htmlstring, @"", "",RegexOptions.IgnoreCase);
257 | Htmlstring = Regex.Replace(Htmlstring, @"<(.[^>]*)>", "", RegexOptions.IgnoreCase);
258 | Htmlstring = Regex.Replace(Htmlstring, @"([\r\n])[\s]+", "", RegexOptions.IgnoreCase);
259 | Htmlstring = Regex.Replace(Htmlstring, @"–>", "", RegexOptions.IgnoreCase);
260 | Htmlstring = Regex.Replace(Htmlstring, @"",RegexOptions.IgnoreCase);
265 | Htmlstring = Regex.Replace(Htmlstring, @"&(nbsp|#160);", " ",RegexOptions.IgnoreCase);
266 | Htmlstring = Regex.Replace(Htmlstring, @"&(iexcl|#161);", "\xa1", RegexOptions.IgnoreCase);
267 | Htmlstring = Regex.Replace(Htmlstring, @"&(cent|#162);", "\xa2", RegexOptions.IgnoreCase);
268 | Htmlstring = Regex.Replace(Htmlstring, @"&(pound|#163);", "\xa3", RegexOptions.IgnoreCase);
269 | Htmlstring = Regex.Replace(Htmlstring, @"&(copy|#169);", "\xa9", RegexOptions.IgnoreCase);
270 | Htmlstring = Regex.Replace(Htmlstring, @"(\d+);", "", RegexOptions.IgnoreCase);
271 | Htmlstring.Replace("<", "");
272 | Htmlstring.Replace(">", "");
273 | Htmlstring.Replace("\r\n", "");
274 | return Htmlstring;
275 | }
276 |
277 | public static string GetInputFolder(string strFile)
278 | {
279 | FileInfo fi = new FileInfo(Application.ExecutablePath);
280 | string strRet = System.IO.Path.Combine(fi.Directory.Parent.Parent.FullName, "Data");
281 | return System.IO.Path.Combine(strRet, strFile);
282 | }
283 | }
284 |
285 | }
286 |
--------------------------------------------------------------------------------
/ConvertEquations/ConvertEquations/ConvertEquations.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | 9.0.30729
7 | 2.0
8 | {9FA59BF2-54BC-4DE6-8725-C9D4D732A712}
9 | Exe
10 | Properties
11 | ConvertEquations
12 | ConvertEquations
13 |
14 |
15 |
16 |
17 | 3.5
18 | v4.0
19 |
20 | false
21 | publish\
22 | true
23 | Disk
24 | false
25 | Foreground
26 | 7
27 | Days
28 | false
29 | false
30 | true
31 | 0
32 | 1.0.0.%2a
33 | false
34 | true
35 |
36 |
37 | true
38 | full
39 | false
40 | bin\Debug\
41 | DEBUG;TRACE
42 | prompt
43 | 4
44 | x86
45 |
46 |
47 | pdbonly
48 | true
49 | bin\Release\
50 | TRACE
51 | prompt
52 | 4
53 |
54 |
55 |
56 | True
57 |
58 |
59 | True
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 | Designer
79 |
80 |
81 | Designer
82 |
83 |
84 |
85 |
86 | {CCC50A71-DA40-4703-A638-3A045BD216ED}
87 | MTSDKDN
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 | False
96 | .NET Framework 3.5 SP1 Client Profile
97 | false
98 |
99 |
100 | False
101 | .NET Framework 3.5 SP1
102 | true
103 |
104 |
105 | False
106 | Windows Installer 3.1
107 | true
108 |
109 |
110 |
111 |
112 | {0002E157-0000-0000-C000-000000000046}
113 | 5
114 | 3
115 | 0
116 | primary
117 | False
118 | True
119 |
120 |
121 |
122 |
129 |
--------------------------------------------------------------------------------
/ConvertEquations/ConvertEquations/ConvertEquations.csproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | publish\
5 |
6 |
7 |
8 |
9 |
10 | zh-CN
11 | false
12 |
13 |
--------------------------------------------------------------------------------
/ConvertEquations/ConvertEquations/Data/Base64MTEF.txt:
--------------------------------------------------------------------------------
1 | %MathType!MTEF!1!1!+-
2 | %feaagyart1ev2aaatCvAUfeBSjuyZL2yd9gzLbvyNv2CaerbuL
3 | %wBLnhiov2DGi1BTfMBaeXatLxBI9gBaerbd9wDYLwzYbItLDha
4 | %rqqtubsr4rNCHbGeaGqiVu0Je9sqqrpepC0xbbL8F4rqqrFfpe
5 | %ea0xe9Lq-Jc9vqaqpepm0xbba9pwe9Q8fs0-yqaqpepae9pg0F
6 | %irpepeKkFr0xfr-xfr-xb9adbaqaaeGaciGaaiaabeqaamaaba
7 | %abaaGcbaWaaSaaaeaacaWGUbGaaiyiaaqaaiaadkhacaGGHaWa
8 | %aeWaaeaacaWGUbGaeyOeI0IaamOCaaGaayjkaiaawMcaaiaacg
9 | %caaaaaaa!3E3C!
10 |
11 |
--------------------------------------------------------------------------------
/ConvertEquations/ConvertEquations/Data/Equation1.wmf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scalad/MathML2MathTypeEquation/0419df197a27dbace7de647bcbf21690a3ef1d5c/ConvertEquations/ConvertEquations/Data/Equation1.wmf
--------------------------------------------------------------------------------
/ConvertEquations/ConvertEquations/Data/Equation2.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scalad/MathML2MathTypeEquation/0419df197a27dbace7de647bcbf21690a3ef1d5c/ConvertEquations/ConvertEquations/Data/Equation2.gif
--------------------------------------------------------------------------------
/ConvertEquations/ConvertEquations/Data/Equation3.eps:
--------------------------------------------------------------------------------
1 | %!PS-Adobe-3.0 EPSF-3.0
2 | %%BoundingBox: 0 0 39 16
3 | %%Creator: MathType
4 | %%Title: Input3.eps
5 | %%CreationDate: 01/13/10
6 | %%DocumentFonts: Symbol
7 | %%+ TimesNewRomanPS-ItalicMT
8 | %%+ TimesNewRomanPSMT
9 | %%DocumentNeededFonts: Symbol
10 | %%+ TimesNewRomanPS-ItalicMT
11 | %%+ TimesNewRomanPSMT
12 | %%DocumentProcessColors: Black
13 | %%Baseline: 3
14 | %%Dimensions: H=0.222, W=0.542
15 | %%EndComments
16 | %MathType!MTEF!1!1!+-
17 | %feaagyart1ev2aaatCvAUfeBSjuyZL2yd9gzLbvyNv2CaerbuL
18 | %wBLnhiov2DGi1BTfMBaeXatLxBI9gBaerbd9wDYLwzYbItLDha
19 | %rqqtubsr4rNCHbGeaGqiVu0Je9sqqrpepC0xbbL8F4rqqrFfpe
20 | %ea0xe9Lq-Jc9vqaqpepm0xbba9pwe9Q8fs0-yqaqpepae9pg0F
21 | %irpepeKkFr0xfr-xfr-xb9adbaqaaeGaciGaaiaabeqaamaaba
22 | %abaaGcbaGaamyzaiabg2da9iaad2gacaWGJbWaaWbaaSqabeaa
23 | %caaIYaaaaaaa!3AA6!
24 | %MathType!MathML!1!1!+-
25 | %!
31 | /MTsave save def 50 dict begin
32 | /bdef {bind def} bind def
33 | /xdef {exch def} bdef
34 | /rndpos { transform round exch round exch itransform } bdef
35 | /rndvec { dtransform round exch round exch idtransform } bdef
36 | /rnddist { 0 rndvec pop } bdef
37 | /rndmvto { rndpos moveto } bdef
38 | /rndlnto { rndpos lineto } bdef
39 | 64 -437 .03125 -.03125 scale translate
40 | /fs 0 def
41 | /sf {exch dup /fs xdef dup neg matrix scale makefont setfont} bdef
42 | /f1 {findfont dup /cf xdef sf} bdef
43 | /ns {cf sf} bdef
44 | /sh {rndmvto show} bdef
45 | 0 setgray
46 | 384 /TimesNewRomanPS-ItalicMT f1
47 | (e) -12 341 sh
48 | (m) 546 341 sh
49 | (c) 822 341 sh
50 | 384 /Symbol f1
51 | (=) 246 341 sh
52 | 222 /TimesNewRomanPSMT f1
53 | (2) 1011 169 sh
54 | end MTsave restore
55 |
--------------------------------------------------------------------------------
/ConvertEquations/ConvertEquations/Data/MathML.txt:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/ConvertEquations/ConvertEquations/Data/MathML1.txt:
--------------------------------------------------------------------------------
1 |
21 |
58 |
107 |
146 |
153 |
226 |
318 |
--------------------------------------------------------------------------------
/ConvertEquations/ConvertEquations/Data/MathML2.txt:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/ConvertEquations/ConvertEquations/Data/MathML3.txt:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/ConvertEquations/ConvertEquations/Data/MathML4.txt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/ConvertEquations/ConvertEquations/Data/MathML5.txt:
--------------------------------------------------------------------------------
1 | 解:A.碳酸钠晶体的分子式为,将53.0g碳酸钠晶体完全溶解于适量水中,所得溶液中含有数为,A错误;
B.常温常压下 所含的分子数为,B正确;
C.一个铵根离子含有10个电子, 中所含的电子数为,C错误;
D.氧气和臭氧都是由氧原子构成的,16g氧气和16g臭氧所含的原子数均为,D正确.
2 |
--------------------------------------------------------------------------------
/ConvertEquations/ConvertEquations/Data/MathML6.txt:
--------------------------------------------------------------------------------
1 | 解:(1)设此人加速运动过程中的加速度大小为 ,匀速运动的速度为 ,从静止到加速至最大速度所用时间为 ,加速的位移大小为 ,从B点返回A点过程中匀速运动的时间为 ,A、B两地间的距离为L,
由运动学方程可得:
,
可得
(2)设此人从A点运动到B点过程中匀速运动的时间为 ;减速过程中的加速度大小为 ,减速运动位移大小为 ,时间为 ,由运动学方程可得:
,
可得
则 ,
所以
2 |
--------------------------------------------------------------------------------
/ConvertEquations/ConvertEquations/Data/MathML7.txt:
--------------------------------------------------------------------------------
1 | 解:A.碳酸钠晶体的分子式为,将53.0g碳酸钠晶体完全溶解于适量水中,所得溶液中含有数为,A错误;
B.常温常压下 所含的分子数为,B正确;
C.一个铵根离子含有10个电子, 中所含的电子数为,C错误;
D.氧气和臭氧都是由氧原子构成的,16g氧气和16g臭氧所含的原子数均为,D正确.
2 |
--------------------------------------------------------------------------------
/ConvertEquations/ConvertEquations/Data/MathML8.txt:
--------------------------------------------------------------------------------
1 | (1)证明:∵BC=CD,即△BCD为等腰三角形,又AC平分∠BCD,故
∵平面PAC⊥ 平面ABCD,平面PAC 平面ABCD=AC, 平面PAC,
平面PAC,
(2)解:如图,记BD交AC于点O,作PE AC于点E,则PE 平面ABCD,
又 又
2 |
--------------------------------------------------------------------------------
/ConvertEquations/ConvertEquations/Data/MathML9.txt:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/ConvertEquations/ConvertEquations/Data/TeX.txt:
--------------------------------------------------------------------------------
1 | $$\sqrt {{a^2} + {b^2}} *3$$
2 |
--------------------------------------------------------------------------------
/ConvertEquations/ConvertEquations/MathTypeSDK.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 | using System.IO;
4 | using System.Runtime.InteropServices;
5 | using System.Runtime.InteropServices.ComTypes;
6 | using System.Windows.Forms;
7 | using System.Drawing.Imaging;
8 | using MTSDKDN;
9 | using IDataObject = System.Runtime.InteropServices.ComTypes.IDataObject;
10 |
11 | namespace ConvertEquations
12 | {
13 | /// SDK
14 | #region MTSDK class
15 | class MTSDK
16 | {
17 | // c-tor
18 | public MTSDK() { }
19 |
20 | // vars
21 | protected static bool m_bDidInit = false;
22 |
23 | // init
24 | public bool Init()
25 | {
26 | try
27 | {
28 | if (!m_bDidInit)
29 | {
30 | Int32 result = MathTypeSDK.Instance.MTAPIConnectMgn(MTApiStartValues.mtinitLAUNCH_AS_NEEDED, 30);
31 | if (result == MathTypeReturnValue.mtOK)
32 | {
33 | m_bDidInit = true;
34 | return true;
35 | }
36 | }
37 | }
38 | catch (Exception ex)
39 | {
40 | Console.WriteLine(ex);
41 | m_bDidInit = false;
42 | }
43 | return true;
44 | }
45 |
46 | // de-init
47 | public bool DeInit()
48 | {
49 | if (m_bDidInit)
50 | {
51 | m_bDidInit = false;
52 | MathTypeSDK.Instance.MTAPIDisconnectMgn();
53 | }
54 | return true;
55 | }
56 |
57 | }
58 | #endregion
59 |
60 | /// Output Equation Classes
61 | #region EquationOutput Classes
62 | abstract class EquationOutput
63 | {
64 | // c-tor
65 | public EquationOutput(string strOutTrans)
66 | {
67 | if (!string.IsNullOrEmpty(strOutTrans))
68 | this.strOutTrans = strOutTrans;
69 | else
70 | this.strOutTrans = string.Empty;
71 | }
72 |
73 | protected EquationOutput() { }
74 |
75 | // properties
76 | protected short m_iType;
77 | public short iType
78 | {
79 | get { return m_iType; }
80 | protected set { m_iType = value; }
81 | }
82 |
83 | protected short m_iFormat;
84 | public short iFormat
85 | {
86 | get { return m_iFormat; }
87 | protected set { m_iFormat = value; }
88 | }
89 |
90 | private string m_strFileName;
91 | public string strFileName
92 | {
93 | get { return m_strFileName; }
94 | set { m_strFileName = value; }
95 | }
96 |
97 | private string m_strEquation;
98 | public string strEquation
99 | {
100 | get { return m_strEquation; }
101 | set { m_strEquation = value; }
102 | }
103 |
104 | // output translator
105 | protected string m_strOutTrans;
106 | public string strOutTrans
107 | {
108 | get { return m_strOutTrans; }
109 | set { m_strOutTrans = value; }
110 | }
111 |
112 | // save equation to its destination
113 | abstract public bool Put();
114 | }
115 |
116 | abstract class EquationOutputClipboard : EquationOutput
117 | {
118 | public EquationOutputClipboard(string strOutTrans)
119 | : base(strOutTrans)
120 | {
121 | strFileName = string.Empty;
122 | iType = MTXFormEqn.mtxfmCLIPBOARD;
123 | }
124 |
125 | public EquationOutputClipboard()
126 | : base()
127 | {
128 | strFileName = string.Empty;
129 | iType = MTXFormEqn.mtxfmCLIPBOARD;
130 | }
131 |
132 | public override bool Put() { return true; }
133 | }
134 |
135 | class EquationOutputClipboardText : EquationOutputClipboard
136 | {
137 | public EquationOutputClipboardText(string strOutTrans)
138 | : base(strOutTrans)
139 | {
140 | iFormat = MTXFormEqn.mtxfmTEXT;
141 | }
142 |
143 | public EquationOutputClipboardText()
144 | : base()
145 | {
146 | iFormat = MTXFormEqn.mtxfmTEXT;
147 | }
148 |
149 | public override string ToString() { return "Clipboard Text"; }
150 | }
151 |
152 | #endregion
153 |
154 | /// Input Equation Classes
155 | #region EquationInput Classes
156 | abstract class EquationInput
157 | {
158 | // c-tor
159 | public EquationInput(string strInTrans)
160 | {
161 | if (!string.IsNullOrEmpty(strInTrans))
162 | this.strInTrans = strInTrans;
163 | else
164 | this.strInTrans = string.Empty;
165 | }
166 |
167 | protected short m_iType;
168 | public short iType
169 | {
170 | get { return m_iType; }
171 | protected set { m_iType = value; }
172 | }
173 |
174 | protected short m_iFormat;
175 | public short iFormat
176 | {
177 | get { return m_iFormat; }
178 | protected set { m_iFormat = value; }
179 | }
180 |
181 | // the equation as a string
182 | protected string m_strEquation;
183 | public string strEquation
184 | {
185 | get { return m_strEquation; }
186 | set { m_strEquation = value; }
187 | }
188 |
189 | // the equation as a byte array
190 | protected byte[] m_bEquation;
191 | public byte[] bEquation
192 | {
193 | get { return m_bEquation; }
194 | set { m_bEquation = value; }
195 | }
196 |
197 | // MTEF byte array
198 | protected byte[] m_bMTEF;
199 | public byte[] bMTEF
200 | {
201 | get { return m_bMTEF; }
202 | set { m_bMTEF = value; }
203 | }
204 |
205 | // MTEF byte array length
206 | protected int m_iMTEF_Length;
207 | public int iMTEF_Length
208 | {
209 | get { return m_iMTEF_Length; }
210 | set { m_iMTEF_Length = value; }
211 | }
212 |
213 | // MTEF string
214 | protected string m_strMTEF;
215 | public string strMTEF
216 | {
217 | get { return m_strMTEF; }
218 | set { m_strMTEF = value; }
219 | }
220 |
221 | // input translator
222 | protected string m_strInTrans;
223 | public string strInTrans
224 | {
225 | get { return m_strInTrans; }
226 | set { m_strInTrans = value; }
227 | }
228 |
229 | // the source equation file
230 | protected string m_strFileName;
231 | public string strFileName
232 | {
233 | get { return m_strFileName; }
234 | set { m_strFileName = value; }
235 | }
236 |
237 | protected MTSDK sdk = new MTSDK();
238 |
239 | // get the equation from the source
240 | abstract public bool Get();
241 |
242 | // get binary MTEF
243 | abstract public bool GetMTEF();
244 | }
245 |
246 | abstract class EquationInputFile : EquationInput
247 | {
248 | public EquationInputFile(string text, string strInTrans)
249 | : base(strInTrans)
250 | {
251 | this.strFileName = text;
252 | iType = MTXFormEqn.mtxfmLOCAL;
253 | }
254 | }
255 |
256 | class EquationInputFileText : EquationInputFile
257 | {
258 | public EquationInputFileText(string text, string strInTrans)
259 | : base(text, strInTrans)
260 | {
261 | iFormat = MTXFormEqn.mtxfmMTEF;
262 | }
263 |
264 | public override string ToString() { return "Text file"; }
265 |
266 | override public bool Get()
267 | {
268 | try
269 | {
270 | strEquation = strFileName;
271 | return true;
272 | }
273 | catch (Exception e)
274 | {
275 | Console.WriteLine(e.Message);
276 | return false;
277 | }
278 | }
279 |
280 | override public bool GetMTEF()
281 | {
282 | bool bReturn = false;
283 |
284 | if (!sdk.Init())
285 | return bReturn;
286 |
287 | IDataObject dataObject = MathTypeSDK.getIDataObject();
288 |
289 | if (dataObject == null)
290 | {
291 | sdk.DeInit();
292 | return bReturn;
293 | }
294 |
295 | FORMATETC formatEtc = new FORMATETC();
296 | STGMEDIUM stgMedium = new STGMEDIUM();
297 |
298 | try
299 | {
300 | // Setup the formatting information to use for the conversion.
301 | formatEtc.cfFormat = (Int16)DataFormats.GetFormat(strInTrans).Id;
302 | formatEtc.dwAspect = DVASPECT.DVASPECT_CONTENT;
303 | formatEtc.lindex = -1;
304 | formatEtc.ptd = (IntPtr)0;
305 | formatEtc.tymed = TYMED.TYMED_HGLOBAL;
306 |
307 | // Setup the MathML content to convert
308 | stgMedium.unionmember = Marshal.StringToHGlobalAuto(strEquation);
309 | stgMedium.tymed = TYMED.TYMED_HGLOBAL;
310 | stgMedium.pUnkForRelease = 0;
311 |
312 | // Perform the conversion
313 | dataObject.SetData(ref formatEtc, ref stgMedium, false);
314 |
315 | // Set the format for the output
316 | formatEtc.cfFormat = (Int16)DataFormats.GetFormat("MathType EF").Id;
317 | formatEtc.dwAspect = DVASPECT.DVASPECT_CONTENT;
318 | formatEtc.lindex = -1;
319 | formatEtc.ptd = (IntPtr)0;
320 | formatEtc.tymed = TYMED.TYMED_ISTORAGE;
321 |
322 | // Create a blank data structure to hold the converted result.
323 | stgMedium = new STGMEDIUM();
324 | stgMedium.tymed = TYMED.TYMED_NULL;
325 | stgMedium.pUnkForRelease = 0;
326 |
327 | // Get the conversion result in MTEF format
328 | dataObject.GetData(ref formatEtc, out stgMedium);
329 | }
330 | catch (COMException e)
331 | {
332 | Console.WriteLine("MathML conversion to MathType threw an exception: " + Environment.NewLine + e.ToString());
333 | sdk.DeInit();
334 | return bReturn;
335 | }
336 |
337 | // The pointer now becomes a Handle reference.
338 | HandleRef handleRef = new HandleRef(null, stgMedium.unionmember);
339 |
340 | try
341 | {
342 | // Lock in the handle to get the pointer to the data
343 | IntPtr ptrToHandle = MathTypeSDK.GlobalLock(handleRef);
344 |
345 | // Get the size of the memory block
346 | m_iMTEF_Length = MathTypeSDK.GlobalSize(handleRef);
347 |
348 | // New an array of bytes and Marshal the data across.
349 | m_bMTEF = new byte[m_iMTEF_Length];
350 | Marshal.Copy(ptrToHandle, m_bMTEF, 0, m_iMTEF_Length);
351 | m_strMTEF = System.Text.ASCIIEncoding.ASCII.GetString(m_bMTEF);
352 | bReturn = true;
353 | }
354 | catch (Exception e)
355 | {
356 | Console.WriteLine("Generation of image from MathType failed: " + Environment.NewLine + e.ToString());
357 | }
358 | finally
359 | {
360 | MathTypeSDK.GlobalUnlock(handleRef);
361 | }
362 |
363 | sdk.DeInit();
364 | return bReturn;
365 | }
366 | }
367 |
368 | #endregion
369 |
370 | /// ConvertEquation Classes
371 | class ConvertEquation
372 | {
373 | protected EquationInput m_ei;
374 | protected EquationOutput m_eo;
375 | protected MTSDK m_sdk = new MTSDK();
376 |
377 | // c-tor
378 | public ConvertEquation() { }
379 |
380 | // convert
381 | virtual public bool Convert(EquationInput ei, EquationOutput eo)
382 | {
383 | m_ei = ei;
384 | m_eo = eo;
385 | return Convert();
386 | }
387 |
388 | virtual protected bool Convert()
389 | {
390 | bool bReturn = false;
391 |
392 | if (m_ei.Get())
393 | {
394 | if (m_ei.GetMTEF())
395 | {
396 | if (ConvertToOutput())
397 | {
398 | if (m_eo.Put())
399 | bReturn = true;
400 | }
401 | }
402 | }
403 |
404 | Console.WriteLine("Convert success: {0}\r\n", bReturn.ToString());
405 | return bReturn;
406 | }
407 |
408 | protected bool SetTranslator()
409 | {
410 | if (string.IsNullOrEmpty(m_eo.strOutTrans))
411 | return true;
412 |
413 | Int32 stat = MathTypeSDK.Instance.MTXFormSetTranslatorMgn(
414 | MTXFormSetTranslator.mtxfmTRANSL_INC_NAME + MTXFormSetTranslator.mtxfmTRANSL_INC_DATA,
415 | m_eo.strOutTrans);
416 | return stat == MathTypeReturnValue.mtOK;
417 | }
418 |
419 | protected bool ConvertToOutput()
420 | {
421 | bool bResult = false;
422 | try
423 | {
424 | if (!m_sdk.Init())
425 | return false;
426 | if (MathTypeSDK.Instance.MTXFormResetMgn() == MathTypeReturnValue.mtOK && SetTranslator())
427 | {
428 | Int32 stat = 0;
429 | Int32 iBufferLength = 5000;
430 | StringBuilder strDest = new StringBuilder(iBufferLength);
431 | MTAPI_DIMS dims = new MTAPI_DIMS();
432 |
433 | // convert
434 | stat = MathTypeSDK.Instance.MTXFormEqnMgn(
435 | m_ei.iType,
436 | m_ei.iFormat,
437 | m_ei.bMTEF,
438 | m_ei.iMTEF_Length,
439 | m_eo.iType,
440 | m_eo.iFormat,
441 | strDest,
442 | iBufferLength,
443 | m_eo.strFileName,
444 | ref dims);
445 | // save equation
446 | if (stat == MathTypeReturnValue.mtOK)
447 | {
448 | m_eo.strEquation = strDest.ToString();
449 | bResult = true;
450 | }
451 | }
452 |
453 | m_sdk.DeInit();
454 | }
455 | catch (Exception e)
456 | {
457 | Console.WriteLine(e.Message);
458 | }
459 | return bResult;
460 | }
461 | }
462 | }
463 |
--------------------------------------------------------------------------------
/ConvertEquations/ConvertEquations/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Data;
3 | using System.IO;
4 | using Microsoft.Office.Interop;
5 | using System.Runtime.InteropServices;
6 | using System.Windows.Forms;
7 | using MTSDKDN;
8 | using Word = Microsoft.Office.Interop.Word;
9 | using Excel = Microsoft.Office.Interop.Excel;
10 | using IDataObject = System.Runtime.InteropServices.ComTypes.IDataObject;
11 | using System.Text.RegularExpressions;
12 | using System.Linq.Expressions;
13 | using System.Collections.Generic;
14 | using System.Net;
15 |
16 | namespace ConvertEquations
17 | {
18 | class Program
19 | {
20 | //用于作为函数的默认参数
21 | public static object nothing = System.Reflection.Missing.Value;
22 |
23 | public static WebClient webClient = new WebClient();
24 |
25 | //微软提供的可调用的API入口
26 | [DllImport("shell32.dll ")]
27 | public static extern int ShellExecute(IntPtr hwnd, String lpszOp, String lpszFile, String lpszParams, String lpszDir, int FsShowCmd);
28 |
29 | //主程序入口,必须以单线程方式启动
30 | [STAThread]
31 | static void Main(string[] args)
32 | {
33 | Console.Write("请先选择excel文件,是否继续?enter");
34 | int read = Console.Read();
35 | if (read != 0)
36 | {
37 | Program program = new Program();
38 | OpenFileDialog fileDialog = new OpenFileDialog();
39 | fileDialog.Multiselect = true;
40 | fileDialog.Title = "请选择需要转换的Excel文件";
41 | fileDialog.Filter = "所有文件(*.xlsx)|*.*";
42 | string file = "";
43 | if (fileDialog.ShowDialog() == DialogResult.OK)
44 | {
45 | file = fileDialog.FileName;
46 | Console.WriteLine("已选择文件:" + file);
47 | }
48 | if (file.EndsWith(".xlsx") || file.EndsWith(".xls"))
49 | {
50 | string savepath = System.Configuration.ConfigurationManager.AppSettings["savepath"];
51 | Console.WriteLine("正在读取Excel...");
52 | program.MathML2MathTypeWord(program, new ConvertEquation(), savepath, file);
53 | }
54 | else
55 | {
56 | MessageBox.Show("请选择正确的excel文件");
57 | Application.Exit();
58 | return;
59 | }
60 |
61 | }
62 | else
63 | {
64 | Application.Exit();
65 | return;
66 | }
67 | }
68 |
69 | ///
70 | /// convert mathml to mathtype equation type into word
71 | ///
72 | ///
73 | ///
74 | /// the file where to save
75 | /// the input file name
76 | ///
77 | public string MathML2MathTypeWord(Program p, ConvertEquation ce, string savepath, string file)
78 | {
79 | Utils.killAllProcess("winword.exe");
80 | Utils.killAllProcess("mathtype.exe");
81 | Utils.killAllProcess("excel.exe");
82 |
83 | object name = file.Substring(0, file.LastIndexOf(".")) + ".doc";
84 |
85 | //create document
86 | Word.Application newapp = new Word.Application();
87 | //create a word document
88 | Word.Document newdoc = newapp.Documents.Add(ref nothing, ref nothing, ref nothing, ref nothing);
89 | //是否显示word程序界面
90 | newapp.Visible = false;
91 |
92 | Excel.Workbook workbook = null;
93 | Excel.Worksheet worksheet = null;
94 |
95 | Excel.Application excel = new Excel.Application();//lauch excel application
96 | if (excel == null)
97 | {
98 | return ResultCode.EXCEL_READ_ERROR;
99 | }
100 | excel.Visible = false;
101 | excel.UserControl = true;
102 | // 以只读的形式打开EXCEL文件
103 | workbook = excel.Application.Workbooks.Open(file, nothing, true, nothing, nothing, nothing,nothing, nothing, nothing, true, nothing, nothing, nothing, nothing, nothing);
104 | //取得第一个工作薄
105 | worksheet = (Excel.Worksheet)workbook.Worksheets.get_Item(1);
106 | //取得总记录行数 (包括标题列)
107 | int iRowCount = worksheet.UsedRange.Rows.Count;
108 | int iColCount = worksheet.UsedRange.Columns.Count;
109 | //生成列头
110 | List titles = new List();
111 | for (int i = 0; i < iColCount; i++)
112 | {
113 | var txt = ((Excel.Range)worksheet.Cells[1, i + 1]).Text.ToString();
114 | titles.Add(txt.ToString()+ ": ");
115 |
116 | }
117 | Console.WriteLine("Excel读取完成...");
118 | //生成行数据
119 | Excel.Range range;
120 | //从第二行开始
121 | int rowIdx = 2;
122 | int count = 0;
123 | object anchor = null;
124 | List imgs = new List();
125 | for (int iRow = rowIdx; iRow <= iRowCount; iRow++)
126 | {
127 | for (int iCol = 1; iCol <= iColCount; iCol++)
128 | {
129 | //插入列头
130 | newapp.Selection.Font.Color = Word.WdColor.wdColorBlue;
131 | newapp.Selection.TypeText(titles[iCol - 1]);
132 | //得到单元格内容
133 | range = (Excel.Range)worksheet.Cells[iRow, iCol];
134 | string d = range.Text.ToString();
135 | string[] oneLevelData = d.Split(new string[] { "
229 |
230 |
231 |
232 |
233 |
--------------------------------------------------------------------------------
/ConvertEquations/_UpgradeReport_Files/UpgradeReport_Minus.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scalad/MathML2MathTypeEquation/0419df197a27dbace7de647bcbf21690a3ef1d5c/ConvertEquations/_UpgradeReport_Files/UpgradeReport_Minus.gif
--------------------------------------------------------------------------------
/ConvertEquations/_UpgradeReport_Files/UpgradeReport_Plus.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scalad/MathML2MathTypeEquation/0419df197a27dbace7de647bcbf21690a3ef1d5c/ConvertEquations/_UpgradeReport_Files/UpgradeReport_Plus.gif
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 王培坤
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/MTSDKDN/MTSDKDN.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 10.00
3 | # Visual Studio 2008
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MTSDKDN", "MTSDKDN\MTSDKDN.csproj", "{CCC50A71-DA40-4703-A638-3A045BD216ED}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|Any CPU = Debug|Any CPU
9 | Release|Any CPU = Release|Any CPU
10 | EndGlobalSection
11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
12 | {CCC50A71-DA40-4703-A638-3A045BD216ED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
13 | {CCC50A71-DA40-4703-A638-3A045BD216ED}.Debug|Any CPU.Build.0 = Debug|Any CPU
14 | {CCC50A71-DA40-4703-A638-3A045BD216ED}.Release|Any CPU.ActiveCfg = Release|Any CPU
15 | {CCC50A71-DA40-4703-A638-3A045BD216ED}.Release|Any CPU.Build.0 = Release|Any CPU
16 | EndGlobalSection
17 | GlobalSection(SolutionProperties) = preSolution
18 | HideSolutionNode = FALSE
19 | EndGlobalSection
20 | EndGlobal
21 |
--------------------------------------------------------------------------------
/MTSDKDN/MTSDKDN/MTSDKDN.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | 8.0.50727
7 | 2.0
8 | {CCC50A71-DA40-4703-A638-3A045BD216ED}
9 | Library
10 | Properties
11 | MTSDKDN
12 | MTSDKDN
13 |
14 |
15 | 3.5
16 |
17 |
18 | v4.0
19 |
20 | false
21 | publish\
22 | true
23 | Disk
24 | false
25 | Foreground
26 | 7
27 | Days
28 | false
29 | false
30 | true
31 | 0
32 | 1.0.0.%2a
33 | false
34 | true
35 |
36 |
37 | true
38 | full
39 | false
40 | bin\Debug\
41 | DEBUG;TRACE
42 | prompt
43 | 4
44 | AllRules.ruleset
45 |
46 |
47 | pdbonly
48 | true
49 | bin\Release\
50 | TRACE
51 | prompt
52 | 4
53 | AllRules.ruleset
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 | False
68 | .NET Framework 3.5 SP1 Client Profile
69 | false
70 |
71 |
72 | False
73 | .NET Framework 3.5 SP1
74 | true
75 |
76 |
77 | False
78 | Windows Installer 3.1
79 | true
80 |
81 |
82 |
83 |
90 |
--------------------------------------------------------------------------------
/MTSDKDN/MTSDKDN/MTSDKDN.csproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | false
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | zh-CN
14 | false
15 |
16 |
--------------------------------------------------------------------------------
/MTSDKDN/MTSDKDN/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // AssemblyInfo.cs --- Copyright (c) 2008-2010 by Design Science, Inc.
2 | // Purpose:
3 | // $Header: /MathType/Windows/SDK/DotNET/MTSDKDN/MTSDKDN/Properties/AssemblyInfo.cs 3 1/19/10 2:02p Jimm $
4 |
5 | using System.Reflection;
6 | using System.Runtime.CompilerServices;
7 | using System.Runtime.InteropServices;
8 |
9 | // General Information about an assembly is controlled through the following
10 | // set of attributes. Change these attribute values to modify the information
11 | // associated with an assembly.
12 | [assembly: AssemblyTitle("MTSDKDN")]
13 | [assembly: AssemblyDescription("DotNET assembly wrapper for the MathType SDK")]
14 | [assembly: AssemblyConfiguration("")]
15 | [assembly: AssemblyCompany("Design Science Inc.")]
16 | [assembly: AssemblyProduct("MTSDKDN")]
17 | [assembly: AssemblyCopyright("Copyright © 2008")]
18 | [assembly: AssemblyTrademark("")]
19 | [assembly: AssemblyCulture("")]
20 |
21 | // Setting ComVisible to false makes the types in this assembly not visible
22 | // to COM components. If you need to access a type in this assembly from
23 | // COM, set the ComVisible attribute to true on that type.
24 | [assembly: ComVisible(false)]
25 |
26 | // The following GUID is for the ID of the typelib if this project is exposed to COM
27 | [assembly: Guid("d054586a-5e64-4f4f-80d0-bb7a674d7dd4")]
28 |
29 | // Version information for an assembly consists of the following four values:
30 | //
31 | // Major Version
32 | // Minor Version
33 | // Build Number
34 | // Revision
35 | //
36 | // You can specify all the values or you can default the Revision and Build Numbers
37 | // by using the '*' as shown below:
38 | [assembly: AssemblyVersion("1.0.0.0")]
39 | [assembly: AssemblyFileVersion("1.0.0.0")]
40 |
--------------------------------------------------------------------------------
/MTSDKDN/MTSDKDN/bin/Debug/MTSDKDN.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scalad/MathML2MathTypeEquation/0419df197a27dbace7de647bcbf21690a3ef1d5c/MTSDKDN/MTSDKDN/bin/Debug/MTSDKDN.dll
--------------------------------------------------------------------------------
/MTSDKDN/MTSDKDN/bin/Debug/MTSDKDN.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scalad/MathML2MathTypeEquation/0419df197a27dbace7de647bcbf21690a3ef1d5c/MTSDKDN/MTSDKDN/bin/Debug/MTSDKDN.pdb
--------------------------------------------------------------------------------
/MTSDKDN/MTSDKDN/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scalad/MathML2MathTypeEquation/0419df197a27dbace7de647bcbf21690a3ef1d5c/MTSDKDN/MTSDKDN/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
--------------------------------------------------------------------------------
/MTSDKDN/MTSDKDN/obj/Debug/MTSDKDN.csproj.FileListAbsolute.txt:
--------------------------------------------------------------------------------
1 | C:\Users\Administrator\Desktop\mathTypeSDK\DotNET\MTSDKDN\MTSDKDN\bin\Debug\MTSDKDN.dll
2 | C:\Users\Administrator\Desktop\mathTypeSDK\DotNET\MTSDKDN\MTSDKDN\bin\Debug\MTSDKDN.pdb
3 | C:\Users\Administrator\Desktop\mathTypeSDK\DotNET\MTSDKDN\MTSDKDN\obj\Debug\MTSDKDN.dll
4 | C:\Users\Administrator\Desktop\mathTypeSDK\DotNET\MTSDKDN\MTSDKDN\obj\Debug\MTSDKDN.pdb
5 | C:\Users\Administrator\Desktop\DotNET\MTSDKDN\MTSDKDN\bin\Debug\MTSDKDN.dll
6 | C:\Users\Administrator\Desktop\DotNET\MTSDKDN\MTSDKDN\bin\Debug\MTSDKDN.pdb
7 | C:\Users\Administrator\Desktop\DotNET\MTSDKDN\MTSDKDN\obj\Debug\ResolveAssemblyReference.cache
8 | C:\Users\Administrator\Desktop\DotNET\MTSDKDN\MTSDKDN\obj\Debug\MTSDKDN.dll
9 | C:\Users\Administrator\Desktop\DotNET\MTSDKDN\MTSDKDN\obj\Debug\MTSDKDN.pdb
10 | E:\github\MathML2MathTypeEquation\MTSDKDN\MTSDKDN\bin\Debug\MTSDKDN.dll
11 | E:\github\MathML2MathTypeEquation\MTSDKDN\MTSDKDN\bin\Debug\MTSDKDN.pdb
12 | E:\github\MathML2MathTypeEquation\MTSDKDN\MTSDKDN\obj\Debug\ResolveAssemblyReference.cache
13 | E:\github\MathML2MathTypeEquation\MTSDKDN\MTSDKDN\obj\Debug\MTSDKDN.dll
14 | E:\github\MathML2MathTypeEquation\MTSDKDN\MTSDKDN\obj\Debug\MTSDKDN.pdb
15 |
--------------------------------------------------------------------------------
/MTSDKDN/MTSDKDN/obj/Debug/MTSDKDN.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scalad/MathML2MathTypeEquation/0419df197a27dbace7de647bcbf21690a3ef1d5c/MTSDKDN/MTSDKDN/obj/Debug/MTSDKDN.dll
--------------------------------------------------------------------------------
/MTSDKDN/MTSDKDN/obj/Debug/MTSDKDN.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scalad/MathML2MathTypeEquation/0419df197a27dbace7de647bcbf21690a3ef1d5c/MTSDKDN/MTSDKDN/obj/Debug/MTSDKDN.pdb
--------------------------------------------------------------------------------
/MTSDKDN/TypeLib/CreateMtsdkdnTypelib.bat:
--------------------------------------------------------------------------------
1 | @rem CreateMtsdkdnTypelib.bat --- Copyright (c) 2008-2010 by Design Science, Inc.
2 | @rem Purpose:
3 | @rem $Header: /MathType/Windows/SDK/DotNET/MTSDKDN/TypeLib/CreateMtsdkdnTypelib.bat 4 3/30/10 8:43a Jimm $
4 |
5 | "C:\Program Files\Microsoft SDK\Bin\mktyplib.exe" MTSDKDN.odl /nocpp /tlb MTSDKDN.tlb
6 |
7 | @pause
8 |
--------------------------------------------------------------------------------
/MTSDKDN/TypeLib/MTSDKDN.odl:
--------------------------------------------------------------------------------
1 | [
2 | uuid(0002CE85-0000-0000-C000-000000000046),
3 | helpstring("Design Science Inc. SDK Utilities"),
4 | lcid(0x0),
5 | version(1.0)
6 | ]
7 | library DesignScience_SDKUtilities
8 | {
9 | importlib("stdole2.tlb");
10 | importlib("stdole32.tlb");
11 |
12 | typedef struct tagMTAPI_PICT
13 | {
14 | LONG _mm;
15 | LONG _xExt;
16 | LONG _yExt;
17 | LONG _hMF;
18 | } MTAPI_PICT;
19 |
20 | typedef struct tagRECT
21 | {
22 | LONG _left;
23 | LONG _top;
24 | LONG _right;
25 | LONG _bottom;
26 | } RECT;
27 |
28 | typedef struct tagMTAPI_DIMS
29 | {
30 | int _baseline;
31 | RECT _bounds;
32 | } MTAPI_DIMS;
33 |
34 | typedef enum tagMathTypeReturnValue
35 | {
36 | mtOK = 0,
37 | mtNOT_FOUND = -1,
38 | mtCANT_RUN = -2,
39 | mtBAD_VERSION = -3,
40 | mtIN_USE = -4,
41 | mtNOT_RUNNING = -5,
42 | mtRUN_TIMEOUT = -6,
43 | mtNOT_EQUATION = -7,
44 | mtFILE_NOT_FOUND = -8,
45 | mtMEMORY = -9,
46 | mtBAD_FILE = -10,
47 | mtDATA_NOT_FOUND = -11,
48 | mtTOO_MANY_SESSIONS = -12,
49 | mtSUBSTITUTION_ERROR = -13,
50 | mtTRANSLATOR_ERROR = -14,
51 | mtPREFERENCE_ERROR = -15,
52 | mtBAD_PATH = -16,
53 | mtFILE_ACCESS = -17,
54 | mtFILE_WRITE_ERROR = -18,
55 | mtBAD_DATA = -19,
56 | mtERROR = -9999
57 | } MathTypeReturnValue;
58 |
59 | typedef enum tagMTXFormSetTranslator
60 | {
61 | mtxfmTRANSL_INC_NONE = 0,
62 | mtxfmTRANSL_INC_NAME = 1,
63 | mtxfmTRANSL_INC_DATA = 2,
64 | mtxfmTRANSL_INC_MTDEFAULT = 4,
65 | mtxfmTRANSL_INC_CLIPBOARD_EXTRA = 8
66 | } MTXFormSetTranslator;
67 |
68 | typedef enum tagMTTranslatorInfo
69 | {
70 | mttrnCOUNT = 1,
71 | mttrnMAX_NAME = 2,
72 | mttrnMAX_DESC = 3,
73 | mttrnMAX_FILE = 4,
74 | mttrnOPTIONS = 5
75 | } MTTranslatorInfo;
76 |
77 | typedef enum tagMTXTranslatorPreference
78 | {
79 | mtxfmPREF_EXISTING = 1,
80 | mtxfmPREF_MTDEFAULT = 2,
81 | mtxfmPREF_USER = 3,
82 | mtxfmPREF_LAST = 3
83 | } MTXTranslatorPreference;
84 |
85 | typedef enum tagMTXFormStatus
86 | {
87 | mtxfmSTAT_ACTUAL_LEN = -1,
88 | mtxfmSTAT_TRANSL = -2,
89 | mtxfmSTAT_PREF = -3
90 | } MTXFormStatus;
91 |
92 | typedef enum tagMTXFormEqn
93 | {
94 | mtxfmPREVIOUS = -1,
95 | mtxfmCLIPBOARD = -2,
96 | mtxfmLOCAL = -3,
97 | mtxfmFILE = -4,
98 | mtxfmMTEF = 4,
99 | mtxfmHMTEF = 5,
100 | mtxfmPICT = 6,
101 | mtxfmTEXT = 7,
102 | mtxfmHTEXT = 8,
103 | mtxfmGIF = 9,
104 | mtxfmEPS_NONE = 10,
105 | mtxfmEPS_WMF = 11,
106 | mtxfmEPS_TIFF = 12
107 | } MTXFormEqn;
108 |
109 | typedef enum tagMTPreferences
110 | {
111 | mtprfMODE_NEXT_EQN = 1,
112 | mtprfMODE_MTDEFAULT = 2,
113 | mtprfMODE_INLINE = 4
114 | } MTPreferences;
115 |
116 | typedef enum tagMTXFormSubValues
117 | {
118 | mtxfmSUBST_ALL = 0,
119 | mtxfmSUBST_ONE = 1,
120 | mtxfmVAR_SUB_BAD = -1,
121 | mtxfmVAR_SUB_PLAIN_TEXT = 0,
122 | mtxfmVAR_SUB_MTEF_TEXT = 1,
123 | mtxfmVAR_SUB_MTEF_BINARY = 2,
124 | mtxfmVAR_SUB_DELETE = 3,
125 | mtxfmVAR_SUB_MAX = 4,
126 | mtxfmSTYLE_FIRST = 1,
127 | mtxfmSTYLE_TEXT = 1,
128 | mtxfmSTYLE_FUNCTION = 2,
129 | mtxfmSTYLE_VARIABLE = 3,
130 | mtxfmSTYLE_LCGREEK = 4,
131 | mtxfmSTYLE_UCGREEK = 5,
132 | mtxfmSTYLE_SYMBOL = 6,
133 | mtxfmSTYLE_VECTOR = 7,
134 | mtxfmSTYLE_NUMBER = 8,
135 | mtxfmSTYLE_LAST = 8
136 | } MTXFormSubValues;
137 |
138 | typedef enum tagMTApiStartValues
139 | {
140 | mtinitLAUNCH_AS_NEEDED = 0,
141 | mtinitLAUNCH_NOW = 1
142 | } MTApiStartValues;
143 |
144 | typedef enum tagMTClipboardEqnTypes
145 | {
146 | mtOLE_EQUATION = 1,
147 | mtWMF_EQUATION = 2,
148 | mtMAC_PICT_EQUATION = 4,
149 | mtOLE2_EQUATION = 8
150 | } MTClipboardEqnTypes;
151 |
152 | typedef enum tagMTURLTypes
153 | {
154 | mturlMATHTYPE_HOME = 1,
155 | mturlMATHTYPE_SUPPORT = 2,
156 | mturlMATHTYPE_FEEDBACK = 3,
157 | mturlMATHTYPE_ORDER = 4,
158 | mturlMATHTYPE_FUTURE = 5,
159 | mturlMATHTYPE_REGISTER = 6
160 | } MTURLTypes;
161 |
162 | typedef enum tagMTDimensionValues
163 | {
164 | mtdimFIRST = 1,
165 | mtdimWIDTH = 1,
166 | mtdimHEIGHT = 2,
167 | mtdimBASELINE = 3,
168 | mtdimHORIZ_POS_TYPE = 4,
169 | mtdimHORIZ_POS = 5,
170 | mtdimLast = 5
171 | } MTDimensionValues;
172 |
173 | [dllname("MT6.dll")]
174 | module ClipboardFormats
175 | {
176 | const LPSTR cfNative = "Native";
177 | const LPSTR cfOwnerLink = "OwnerLink";
178 | const LPSTR cfRTF = "Rich Text Format";
179 | const LPSTR cfMTEF = "MathType EF";
180 | const LPSTR cfMacPICT = "Mac PICT";
181 | const LPSTR cfEmbedSrc = "Embed Source";
182 | const LPSTR cfObjDesc = "Object Descriptor";
183 | const LPSTR cfEmbeddedObj = "Embedded Object";
184 | const LPSTR cfMTMacro = "MathType Macro";
185 | const LPSTR cfHTML = "HTML Format";
186 | const LPSTR cfMTMacroPict = "MathType Macro PICT";
187 | const LPSTR cfMMLPres = "MathML Presentation";
188 | const LPSTR cfMML = "MathML";
189 | const LPSTR cfMMLXML = "application/mathml+xml";
190 | const LPSTR cfTeX = "TeX Input Language";
191 | };
192 |
193 | [dllname("MT6.dll")]
194 | module MTSDKFunctions
195 | {
196 | [entry ("MTAPIConnect")]
197 | int __stdcall MTAPIConnect([in] short mtStart, [in] short timeout);
198 |
199 | [entry ("MTAPIVersion")]
200 | int __stdcall MTAPIVersion([in] short apiversion);
201 |
202 | [entry ("MTAPIDisconnect")]
203 | int __stdcall MTAPIDisconnect();
204 |
205 | [entry ("MTEquationOnClipboard")]
206 | int __stdcall MTEquationOnClipboard();
207 |
208 | [entry ("MTClearClipboard")]
209 | int __stdcall MTClearClipboard();
210 |
211 | [entry ("MTGetLastDimension")]
212 | int __stdcall MTGetLastDimension([in] short dimIndex);
213 |
214 | [entry ("MTOpenFileDialog")]
215 | int __stdcall MTOpenFileDialog([in] short fileType, [in] BSTR title, [in] BSTR dir, [in] BSTR * file, [in] short fileLen);
216 |
217 | [entry ("MTGetPrefsFromClipboard")]
218 | int __stdcall MTGetPrefsFromClipboard([in, out] BSTR * prefs, [in] short prefsLen);
219 |
220 | [entry ("MTGetPrefsFromFile")]
221 | int __stdcall MTGetPrefsFromFile([in] BSTR prefFile, [in, out] BSTR * prefs, [in] short prefsLen);
222 |
223 | [entry ("MTConvertPrefsToUIForm")]
224 | int __stdcall MTConvertPrefsToUIForm([in] BSTR inPrefs, [in, out] BSTR * outPrefs, [in] short outPrefsLen);
225 |
226 | [entry ("MTGetPrefsMTDefault")]
227 | int __stdcall MTGetPrefsMTDefault([in, out] BSTR * prefs, [in] short prefsLen);
228 |
229 | [entry ("MTSetMTPrefs")]
230 | int __stdcall MTSetMTPrefs([in] short mode, [in] BSTR prefs, [in] short timeout);
231 |
232 | [entry ("MTGetTranslatorsInfo")]
233 | int __stdcall MTGetTranslatorsInfo([in] short infoIndex);
234 |
235 | [entry ("MTEnumTranslators")]
236 | int __stdcall MTEnumTranslators([in] short index, [in, out] BSTR * transName, [in] short transNameLen, [in, out] BSTR * transDesc, [in] short transDescLen, [in, out] BSTR * transFile, [in] short transFileLen);
237 |
238 | [entry ("MTXFormReset")]
239 | int __stdcall MTXFormReset();
240 |
241 | [entry ("MTXFormAddVarSub")]
242 | int __stdcall MTXFormAddVarSub([in] short options, [in] short findType, [in] BSTR find, [in] int findLen, [in] short replaceType, [in] BSTR replace, [in] int replaceLen, [in] short replaceStyle);
243 |
244 | [entry ("MTXFormSetTranslator")]
245 | int __stdcall MTXFormSetTranslator([in] short options, [in] BSTR transName);
246 |
247 | [entry ("MTXFormSetPrefs")]
248 | int __stdcall MTXFormSetPrefs([in] short prefType, [in] BSTR prefStr);
249 |
250 | [entry ("MTXFormEqn")]
251 | int __stdcall MTXFormEqn([in] short src, [in] short srcFmt, [in] int * srcData, [in] int srcDataLen, [in] short dst, [in] short dstFmt, [in] int * dstData, [in] int dstDataLen, [in] BSTR dstPath, [in] MTAPI_DIMS * dims);
252 |
253 | [entry ("MTXFormGetStatus")]
254 | int __stdcall MTXFormGetStatus([in] short index);
255 |
256 | [entry ("MTPreviewDialog")]
257 | int __stdcall MTPreviewDialog([in] int * parent, [in] BSTR title, [in] BSTR prefs, [in] BSTR closeBtnText, [in] BSTR helpBtnText, [in] int helpID, [in] BSTR helpFile);
258 |
259 | [entry ("MTShowAboutBox")]
260 | int __stdcall MTShowAboutBox();
261 |
262 | [entry ("MTGetURL")]
263 | int __stdcall MTGetURL([in] short whichURL, [in] short bGoToURL, [in, out] BSTR * strURL, [in] int sizeURL);
264 | }
265 |
266 | typedef enum tagTYMED
267 | {
268 | TYMED_HGLOBAL = 1,
269 | TYMED_FILE = 2,
270 | TYMED_ISTREAM = 4,
271 | TYMED_ISTORAGE = 8,
272 | TYMED_GDI = 16,
273 | TYMED_MFPICT = 32,
274 | TYMED_ENHMF = 64,
275 | TYMED_NULL = 0
276 | } TYMED;
277 |
278 | typedef enum tagDVASPECT
279 | {
280 | DVASPECT_CONTENT = 1,
281 | DVASPECT_THUMBNAIL = 2,
282 | DVASPECT_ICON = 4,
283 | DVASPECT_DOCPRINT = 8
284 | } DVASPECT;
285 |
286 | typedef enum tagDATADIR
287 | {
288 | DATADIR_GET = 1,
289 | DATADIR_SET = 2
290 | } DATADIR;
291 |
292 | typedef struct tagFORMATETC
293 | {
294 | short cfFormat;
295 | LONG pDVTARGETDEVICE;
296 | DVASPECT dwAspect;
297 | LONG lindex;
298 | TYMED tymed;
299 | } FORMATETC;
300 |
301 | typedef struct tagSTGMEDIUM
302 | {
303 | TYMED tymed;
304 | LONG Data;
305 | LONG pUnkForRelease;
306 | } STGMEDIUM;
307 |
308 | typedef struct tagSTATDATA
309 | {
310 | FORMATETC formatetc;
311 | LONG advf;
312 | LONG pAdvSink;
313 | LONG dwConnection;
314 | } STATDATA;
315 |
316 | [
317 | uuid(00000103-0000-0000-C000-000000000046),
318 | odl
319 | ]
320 | interface IEnumFORMATETC : IUnknown
321 | {
322 | LONG __stdcall Next([in] LONG celt, [out] FORMATETC *rgelt);
323 | HRESULT __stdcall Skip([in] LONG celt);
324 | HRESULT __stdcall Reset(void);
325 | IEnumFORMATETC * __stdcall Clone(void);
326 | };
327 |
328 | [
329 | uuid(0000010e-0000-0000-C000-000000000046),
330 | odl
331 | ]
332 | interface IDataObject : IUnknown
333 | {
334 | HRESULT __stdcall GetData([in] FORMATETC *pformatetcIn, [out] STGMEDIUM *pmedium);
335 | HRESULT __stdcall GetDataHere([in] FORMATETC *pformatetc, [in, out] STGMEDIUM *pmedium);
336 | HRESULT __stdcall QueryGetData([in] FORMATETC *pformatetc);
337 | HRESULT __stdcall GetCanonicalFormatEtc([in] FORMATETC *pformatectIn, [out] FORMATETC *pformatetcOut);
338 | HRESULT __stdcall SetData([in] FORMATETC *pformatetc, [in] STGMEDIUM *pmedium, [in] LONG fRelease);
339 | IEnumFORMATETC * __stdcall EnumFormatEtc([in] DATADIR dwDirection);
340 | HRESULT __stdcall DAdvise([in]FORMATETC *pformatetc, [in]LONG advf, [in] LONG pAdvSink, [out] LONG *pdwConnection);
341 | HRESULT __stdcall DUnadvise([in] LONG dwConnection);
342 | HRESULT __stdcall EnumDAdvise([out] LONG * pIEnumAdvise);
343 | };
344 |
345 | typedef enum tagGMEM_CONSTANTS
346 | {
347 | GMEM_FIXED = 0x0000,
348 | GMEM_MOVEABLE = 0x0002,
349 | GMEM_NOCOMPACT = 0x0010,
350 | GMEM_NODISCARD = 0x0020,
351 | GMEM_ZEROINIT = 0x0040,
352 | GMEM_MODIFY = 0x0080,
353 | GMEM_DISCARDABLE = 0x0100,
354 | GMEM_NOT_BANKED = 0x1000,
355 | GMEM_SHARE = 0x2000,
356 | GMEM_DDESHARE = 0x2000,
357 | GMEM_NOTIFY = 0x4000,
358 | GMEM_LOWER = 0x1000,
359 | GMEM_VALID_FLAGS = 0x7F72,
360 | GMEM_INVALID_HANDLE = 0x8000,
361 | } GMEM_CONSTANTS;
362 |
363 | [dllname("ole32.dll")]
364 | module OLEFunctions
365 | {
366 | [entry("ReleaseStgMedium")]
367 | void ReleaseStgMedium([in] STGMEDIUM * pmedium);
368 | };
369 |
370 | [dllname("user32.dll")]
371 | module User32Functions
372 | {
373 | [entry("GetForegroundWindow")]
374 | LONG __stdcall GetForegroundWindow();
375 |
376 | [entry("SetForegroundWindow")]
377 | LONG __stdcall SetForegroundWindow([in] LONG hwnd);
378 |
379 | [entry("RegisterClipboardFormatW")]
380 | LONG __stdcall RegisterClipboardFormat([in] BSTR lpString);
381 | };
382 |
383 | [dllname("kernel32.dll")]
384 | module Kernel32Functions
385 | {
386 | [entry("GetTickCount")]
387 | LONG __stdcall GetTickCount();
388 |
389 | [entry("GlobalFree")]
390 | LONG __stdcall GlobalFree([in] LONG hMem);
391 |
392 | [entry("GlobalAlloc")]
393 | LONG __stdcall GlobalAlloc([in] LONG wFlags, [in] LONG dwBytes);
394 |
395 | [entry("GlobalLock")]
396 | LONG __stdcall GlobalLock([in] LONG hMem);
397 |
398 | [entry("GlobalSize")]
399 | LONG __stdcall GlobalSize([in] LONG hMem);
400 |
401 | [entry("GlobalUnlock")]
402 | LONG __stdcall GlobalUnlock([in] LONG hMem);
403 |
404 | [entry("RtlMoveMemory")]
405 | HRESULT __stdcall CopyMemory([in] void* dest, [in] void* src, [in] LONG cbCopy );
406 |
407 | [entry("GetLocaleInfoA")]
408 | LONG __stdcall GetLocaleInfo([in] LONG Locale, [in] LONG LCType, [out] BSTR * lpLCData, [in] LONG cchData );
409 | };
410 | }
411 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## MathML2MathTypeEquation ##
2 |
3 | ### Support ###
4 | * MathML公式类使用MathType公式进行转换
5 | * HTML格式导出Word(支持表格、图片、排序标签、转义字符等)
6 |
7 | ### Required ###
8 | * Office2003+(Word And Excel) Best of 2007
9 | * .Net Frameword4.0+
10 | * MathType6.9+[关于MathType6.9破解](http://pan.baidu.com/s/1nuDCh4H)
11 |
12 | ### Operation ###
13 | 
14 |
15 | ### About MathType SDK ###
16 | 关于MathTypeSDK可以在[官网下载](https://www.dessci.com/en/reference/sdk/),上文中的MTSDKDN就是来自于该SDK在.NET平台上的一套SDK.
17 |
18 | MathType SDK是针对MathType工具用VB完成的一套开发工具包,它允许开发人员改造、扩展、修改或者创建命令等,并且官方文档中提供了.NET平台上SDK的实现,你可以很方便的使用C#调用它们。如下图是.NET平台上公式支持的输入输出的格式:
19 |
20 | 
21 |
22 | EquationInput(公式输入)、EquationOutput(公式输出)和MTSDK(MathType连接、释放)作为ConverttEquation的成员变量,ConverttEquation初始化时首先完成了MTSDK对象的初始化。MTSDK包含了两个方法,Init()和DeInit(),用来连接MathType服务和释放服务。而后调用ConvertEquation中的Convert方法完成它们两个所支持的文件格式的转换.
23 |
24 | 目前采用的方式是使用EquationInputFileText类从磁盘文件中读入MathML数据类型的数据,然后使用EquationOutputClipboardText输出到系统的剪切板中,从剪切板中获取到该公式的对象并写入到Word文档中,当文件读取并转换完成后,生成Wrod文档并保存.
25 |
26 | ### Introduce ###
27 |
28 | 这篇文章主要介绍怎么使用[MathType](https://www.dessci.com/en/reference/sdk/)把[MathML](https://zh.wikipedia.org/wiki/%E6%95%B0%E5%AD%A6%E7%BD%AE%E6%A0%87%E8%AF%AD%E8%A8%80)转换MathType类型的公式对象并嵌入到Word中。
29 |
30 | 最近,这里有个需求是需要转换一大批的MathML文件到Word文档中,如果使用[Open-XML-SDK](https://github.com/OfficeDev/Open-XML-SDK)是非常容易实现的,你可以参考[https://github.com/scalad/MathML2Word](https://github.com/scalad/MathML2Word),但是,最重要的是这不是想要的结果,因为经过Open-XML-SDK的转换,这个公式的类型变成了[OMML(Office Math Markup Language)](https://en.wikipedia.org/wiki/Mathematical_markup_language)格式的,什么是OMML呢?
31 |
32 | 我们知道,微软的Word包含了公式编辑器,其实它是一个缩小版本的MathType,这个从上世纪word出现时已经开始了。直到2007年,word才允许使用[图形用户界面](https://en.wikipedia.org/wiki/Graphical_user_interface)输入公式,并且转换为像MATHML格式的标记语言。随着微软发布了[Microsoft Office 2007](https://en.wikipedia.org/wiki/Microsoft_Office_2007) 和[Office Open XML file formats](https://en.wikipedia.org/wiki/Office_Open_XML_file_formats),微软引进了一个使用新的格式的公式编辑器,即所谓的`Office Math Markup Language(OMML)`,OMML与原来的公式编辑器存在着兼容性问题,因此很多学术官网都拒绝使用Microsoft Office写的文档.
33 |
34 | Mathtype公式编辑器是基于宏或是VB编出来的,实际上,在Office2007之前的版本中,微软一直使用的是MathType提供的缩小版本的MathType公式编辑器,想要使用完整公式编辑器的还需要用户到MathType去买(没错,在长达15年的时间里,所有Office都自带MathType的缩小版),直到2007之后,微软才开发出属于自己的一套公式编辑器,它的公式类型是OMML(Office Math Markup Language).
35 |
36 | ### System Architecture ###
37 | 
38 |
39 | ### Question ###
40 | 1、特殊公式映射转换
41 |
42 | ```C#
43 | static MathML()
44 | {
45 | equations.Add("∆", "Δ");
46 | equations.Add("<", "<");
47 | equations.Add(">", ">");
48 | equations.Add("⪈", "≩");
49 | equations.Add("⪇", "≨");
50 | equations.Add("≢", "≠");
51 | equations.Add("⊝", "⊖");
52 | equations.Add("·", "⋅");
53 | equations.Add("⋅", "⋅");
54 | equations.Add(" ", "");
55 | equations.Add("¡Î", "∥");//||
56 | }
57 | ```
58 | 由于原来的数据是经过[MathJax](https://github.com/mathjax/MathJax)转换而来,因此,该平台上有的图标或者是公式在MathType上是无法转换,也就是说MathType无法识别这些图标,所以我们需要把这些不能识别的公式进行映射替换,替换为MathType可以识别的Unicode编码.
59 |
60 | 2、关于MathType弹出缺少字体的对话框
61 | 因为在上面的字符映射上可能使用了不同字体的Unicode编码,很有可能导致这个问题:
62 | MathType需要一个新版的MT Extra(TrueType)字体,请重新安装MathType(用CD或下载安装)以便获取正确的字体
63 |
64 | 这时,一些符号就无法使用。下面介绍解决以上问题的办法。
65 |
66 | 1,进入文件夹X:\Windows\Fonts(X为系统盘盘符,一般是C),如果有MT Extra(TrueType)字体或者快捷方式,则将其删除。
67 |
68 | 2,进入MathType安装目录的\Fonts\TrueType\文件夹,将里面的mtextra.ttf字体复制至文件夹X:\Windows\Fonts(粘贴时可能会有安装字体的提示)。
69 |
70 | ### 关于MathML转换 ###
71 |
72 | 所谓的MaTHML,它也是基于XML的一种可扩展标记语言,如下面一个例子:
73 |
74 | ```xml
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 | (
83 |
84 |
85 |
86 |
87 |
88 | 2×
89 |
90 | −1+
91 | 3
92 |
93 | i
94 | 2
95 |
96 |
97 |
98 |
99 |
100 | )
101 | 3
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | [
110 |
111 |
112 |
113 |
114 |
115 |
116 | (
117 |
118 |
119 |
120 |
121 |
122 | 1+i
123 |
124 |
125 |
126 | )
127 | 2
128 |
129 |
130 |
131 |
132 | ]
133 | 3
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 | ```
149 | 你可以把这段MathML复制到记事本后再复制出来,然后再粘贴到Word文档中,如果你没有安装MathType工具,并且你Word版本是07或者07以上的版本的话,那么Word会使用一个转换文件——MML2OMML.xsl(这个文件是office自带的,位于目录:%ProgramFiles%\Microsoft Office\Office12\之下),将你的公式转换为OMML格式的公式,而如果你Word安装了MathType插件的话,你再粘贴文本时它会弹出一个选择MathType类型或者OMML类型让你选择:
150 |
151 | 
--------------------------------------------------------------------------------
/doc/effect.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scalad/MathML2MathTypeEquation/0419df197a27dbace7de647bcbf21690a3ef1d5c/doc/effect.gif
--------------------------------------------------------------------------------
/doc/image/MTSDKDN.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scalad/MathML2MathTypeEquation/0419df197a27dbace7de647bcbf21690a3ef1d5c/doc/image/MTSDKDN.png
--------------------------------------------------------------------------------
/doc/image/mathml转word系统架构.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scalad/MathML2MathTypeEquation/0419df197a27dbace7de647bcbf21690a3ef1d5c/doc/image/mathml转word系统架构.png
--------------------------------------------------------------------------------
/doc/image/mathtypePast.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scalad/MathML2MathTypeEquation/0419df197a27dbace7de647bcbf21690a3ef1d5c/doc/image/mathtypePast.png
--------------------------------------------------------------------------------