Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : :
21 : : #include <mathtype.hxx>
22 : : #include <osl/diagnose.h>
23 : : #include <sfx2/docfile.hxx>
24 : :
25 : : #define APPEND(str,ascii) str.AppendAscii(RTL_CONSTASCII_STRINGPARAM(ascii))
26 : :
27 : 0 : void MathType::Init()
28 : : {
29 : : //These are the default MathType sizes
30 : 0 : aSizeTable[0]=12;
31 : 0 : aSizeTable[1]=8;
32 : 0 : aSizeTable[2]=6;
33 : 0 : aSizeTable[3]=24;
34 : 0 : aSizeTable[4]=10;
35 : 0 : aSizeTable[5]=12;
36 : 0 : aSizeTable[6]=12;
37 : :
38 : : /*
39 : : These are the default MathType italic/bold settings If mathtype is changed
40 : : from its defaults, there is nothing we can do, as this information is not
41 : : stored in the document
42 : : */
43 : 0 : MathTypeFont aFont;
44 [ # # ]: 0 : for(sal_uInt8 i=1;i<=11;i++)
45 : : {
46 : 0 : aFont.nTface = i+128;
47 [ # # # ]: 0 : switch (i)
48 : : {
49 : : default:
50 : 0 : aFont.nStyle=0;
51 : 0 : break;
52 : : case 3:
53 : : case 4:
54 : 0 : aFont.nStyle=1;
55 : 0 : break;
56 : : case 7:
57 : 0 : aFont.nStyle=2;
58 : 0 : break;
59 : : }
60 [ # # ]: 0 : aUserStyles.insert(aFont);
61 : : }
62 : 0 : }
63 : :
64 : :
65 : : /*ToDo replace with table rather than switch, returns
66 : : sal_True in the case that the char is just a char, and
67 : : sal_False if the character is an operator which must not be
68 : : placed inside the quote sequence designed to protect
69 : : against being parsed as a keyword
70 : :
71 : : General solution required to force starmath to handle
72 : : unicode math chars the way it handles its own math
73 : : chars rathar than handle them as text as it will do
74 : : for the default case below, i.e. incorrect spacing
75 : : between math symbols and ordinary text e.g. 1=2 rather
76 : : than 1 = 2
77 : : */
78 : 0 : sal_Bool MathType::LookupChar(sal_Unicode nChar,String &rRet,sal_uInt8 nVersion,
79 : : sal_uInt8 nTypeFace)
80 : : {
81 : 0 : bool bRet=false;
82 : 0 : const char *pC = NULL;
83 [ # # # # : 0 : switch(nChar)
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # ]
84 : : {
85 : : case 0x0000:
86 : 0 : pC = " none ";
87 : 0 : break;
88 : : case 0x00ac:
89 : 0 : pC = " neg ";
90 : 0 : break;
91 : : case 0x00b1:
92 : 0 : pC = " +- ";
93 : 0 : break;
94 : : case '(':
95 : 0 : pC = " \\( ";
96 : 0 : break;
97 : : case ')':
98 : 0 : pC = " \\) ";
99 : 0 : break;
100 : : case '[':
101 : 0 : pC = " \\[ ";
102 : 0 : break;
103 : : case ']':
104 : 0 : pC = " \\] ";
105 : 0 : break;
106 : : case '.':
107 : 0 : pC = " \".\" ";
108 : 0 : break;
109 : : case 0xae:
110 [ # # ][ # # ]: 0 : if ((nVersion < 3) && (nTypeFace == 0x86))
111 : 0 : pC = " rightarrow ";
112 : : else
113 : : {
114 : 0 : rRet.Append(nChar);
115 : 0 : bRet=true;
116 : : }
117 : 0 : break;
118 : : case 0x00fb:
119 [ # # ][ # # ]: 0 : if ((nVersion < 3) && (nTypeFace == 0x81))
120 : 0 : nChar = 0xDF;
121 : 0 : rRet.Append(nChar);
122 : 0 : bRet=true;
123 : 0 : break;
124 : : case 'a':
125 [ # # ][ # # ]: 0 : if ((nVersion < 3) && (nTypeFace == 0x84))
126 : 0 : nChar = 0x3b1;
127 : 0 : rRet.Append(nChar);
128 : 0 : bRet=true;
129 : 0 : break;
130 : : case 'b':
131 [ # # ][ # # ]: 0 : if ((nVersion < 3) && (nTypeFace == 0x84))
132 : 0 : nChar = 0x3b2;
133 : 0 : rRet.Append(nChar);
134 : 0 : bRet=true;
135 : 0 : break;
136 : : case 'l':
137 [ # # ][ # # ]: 0 : if ((nVersion < 3) && (nTypeFace == 0x84))
138 : 0 : nChar = 0x3bb;
139 : 0 : rRet.Append(nChar);
140 : 0 : bRet=true;
141 : 0 : break;
142 : : case 'n':
143 [ # # ][ # # ]: 0 : if ((nVersion < 3) && (nTypeFace == 0x84))
144 : 0 : nChar = 0x3bd;
145 : 0 : rRet.Append(nChar);
146 : 0 : bRet=true;
147 : 0 : break;
148 : : case 'r':
149 [ # # ][ # # ]: 0 : if ((nVersion < 3) && (nTypeFace == 0x84))
150 : 0 : nChar = 0x3c1;
151 : 0 : rRet.Append(nChar);
152 : 0 : bRet=true;
153 : 0 : break;
154 : : case 'D':
155 [ # # ][ # # ]: 0 : if ((nVersion < 3) && (nTypeFace == 0x84))
156 : 0 : nChar = 0x394;
157 : 0 : rRet.Append(nChar);
158 : 0 : bRet=true;
159 : 0 : break;
160 : : case 0xa9:
161 [ # # ][ # # ]: 0 : if ((nVersion < 3) && (nTypeFace == 0x82))
162 : 0 : nChar = '\'';
163 : 0 : rRet.Append(nChar);
164 : 0 : bRet=true;
165 : 0 : break;
166 : : case 0x00f1:
167 [ # # ][ # # ]: 0 : if ((nVersion < 3) && (nTypeFace == 0x86))
168 : 0 : pC = " \\rangle ";
169 : : else
170 : : {
171 : 0 : rRet.Append(nChar);
172 : 0 : bRet=true;
173 : : }
174 : 0 : break;
175 : : case 0x00a3:
176 [ # # ][ # # ]: 0 : if ((nVersion < 3) && (nTypeFace == 0x86))
177 : 0 : pC = " <= ";
178 : : else
179 : : {
180 : 0 : rRet.Append(nChar);
181 : 0 : bRet=true;
182 : : }
183 : 0 : break;
184 : : case 0x00de:
185 [ # # ][ # # ]: 0 : if ((nVersion < 3) && (nTypeFace == 0x86))
186 : 0 : pC = " drarrow ";
187 : : else
188 : : {
189 : 0 : rRet.Append(nChar);
190 : 0 : bRet=true;
191 : : }
192 : 0 : break;
193 : : case 0x0057:
194 [ # # ][ # # ]: 0 : if ((nVersion < 3) && (nTypeFace == 0x85))
195 : 0 : pC = " %OMEGA ";
196 : : else
197 : : {
198 : 0 : rRet.Append(nChar);
199 : 0 : bRet=true;
200 : : }
201 : 0 : break;
202 : : case 0x007b:
203 : 0 : pC = " lbrace ";
204 : 0 : break;
205 : : case 0x007c:
206 : 0 : pC = " \\lline ";
207 : 0 : break;
208 : : case 0x007d:
209 : 0 : pC = " rbrace ";
210 : 0 : break;
211 : : case 0x007e:
212 : 0 : pC = " \"~\" ";
213 : 0 : break;
214 : : case 0x2224:
215 : 0 : pC = " ndivides ";
216 : 0 : break;
217 : : case 0x2225:
218 : 0 : pC = " parallel ";
219 : 0 : break;
220 : : case 0x00d7:
221 [ # # ]: 0 : if (nVersion < 3)
222 : 0 : pC = " cdot ";
223 : : else
224 : 0 : pC = " times ";
225 : 0 : break;
226 : : case 0x00f7:
227 : 0 : pC = " div ";
228 : 0 : break;
229 : : case 0x019b:
230 : 0 : pC = " lambdabar ";
231 : 0 : break;
232 : : case 0x2026:
233 : 0 : pC = " dotslow ";
234 : 0 : break;
235 : : case 0x2022:
236 : 0 : pC = " cdot ";
237 : 0 : break;
238 : : case 0x2102:
239 : 0 : pC = " setC ";
240 : 0 : break;
241 : : case 0x210f:
242 : 0 : pC = " hbar ";
243 : 0 : break;
244 : : case 0x2111:
245 : 0 : pC = " Im ";
246 : 0 : break;
247 : : case 0x2115:
248 : 0 : pC = " setN ";
249 : 0 : break;
250 : : case 0x2118:
251 : 0 : pC = " wp ";
252 : 0 : break;
253 : : case 0x211a:
254 : 0 : pC = " setQ ";
255 : 0 : break;
256 : : case 0x211c:
257 : 0 : pC = " Re ";
258 : 0 : break;
259 : : case 0x211d:
260 : 0 : pC = " setR ";
261 : 0 : break;
262 : : case 0x2124:
263 : 0 : pC = " setZ ";
264 : 0 : break;
265 : : case 0x2135:
266 : 0 : pC = " aleph ";
267 : 0 : break;
268 : : case 0x2190:
269 : 0 : pC = " leftarrow ";
270 : 0 : break;
271 : : case 0x2191:
272 : 0 : pC = " uparrow ";
273 : 0 : break;
274 : : case 0x2192:
275 : 0 : pC = " rightarrow ";
276 : 0 : break;
277 : : case 0x0362:
278 : 0 : pC = " widevec ";
279 : 0 : break;
280 : : case 0x2193:
281 : 0 : pC = " downarrow ";
282 : 0 : break;
283 : : case 0x21d0:
284 : 0 : pC = " dlarrow ";
285 : 0 : break;
286 : : case 0x21d2:
287 : 0 : pC = " drarrow ";
288 : 0 : break;
289 : : case 0x21d4:
290 : 0 : pC = " dlrarrow ";
291 : 0 : break;
292 : : case 0x2200:
293 : 0 : pC = " forall ";
294 : 0 : break;
295 : : case 0x2202:
296 : 0 : pC = " partial ";
297 : 0 : break;
298 : : case 0x2203:
299 : 0 : pC = " exists ";
300 : 0 : break;
301 : : case 0x2204:
302 : 0 : pC = " notexists ";
303 : 0 : break;
304 : : case 0x2205:
305 : 0 : pC = " emptyset ";
306 : 0 : break;
307 : : case 0x2207:
308 : 0 : pC = " nabla ";
309 : 0 : break;
310 : : case 0x2208:
311 : 0 : pC = " in ";
312 : 0 : break;
313 : : case 0x2209:
314 : 0 : pC = " notin ";
315 : 0 : break;
316 : : case 0x220d:
317 : 0 : pC = " owns ";
318 : 0 : break;
319 : : case 0x220f:
320 : 0 : pC = " prod ";
321 : 0 : break;
322 : : case 0x2210:
323 : 0 : pC = " coprod ";
324 : 0 : break;
325 : : case 0x2211:
326 : 0 : pC = " sum ";
327 : 0 : break;
328 : : case 0x2212:
329 : 0 : pC = " - ";
330 : 0 : break;
331 : : case 0x2213:
332 : 0 : pC = " -+ ";
333 : 0 : break;
334 : : case 0x2217:
335 : 0 : pC = " * ";
336 : 0 : break;
337 : : case 0x2218:
338 : 0 : pC = " circ ";
339 : 0 : break;
340 : : case 0x221d:
341 : 0 : pC = " prop ";
342 : 0 : break;
343 : : case 0x221e:
344 : 0 : pC = " infinity ";
345 : 0 : break;
346 : : case 0x2227:
347 : 0 : pC = " and ";
348 : 0 : break;
349 : : case 0x2228:
350 : 0 : pC = " or ";
351 : 0 : break;
352 : : case 0x2229:
353 : 0 : pC = " intersection ";
354 : 0 : break;
355 : : case 0x222a:
356 : 0 : pC = " union ";
357 : 0 : break;
358 : : case 0x222b:
359 : 0 : pC = " int ";
360 : 0 : break;
361 : : case 0x222c:
362 : 0 : pC = " iint ";
363 : 0 : break;
364 : : case 0x222d:
365 : 0 : pC = " iiint ";
366 : 0 : break;
367 : : case 0x222e:
368 : 0 : pC = " lint ";
369 : 0 : break;
370 : : case 0x222f:
371 : 0 : pC = " llint ";
372 : 0 : break;
373 : : case 0x2230:
374 : 0 : pC = " lllint ";
375 : 0 : break;
376 : : case 0x2245:
377 : 0 : pC = " simeq ";
378 : 0 : break;
379 : : case 0x2248:
380 : 0 : pC = " approx ";
381 : 0 : break;
382 : : case 0x2260:
383 : 0 : pC = " <> ";
384 : 0 : break;
385 : : case 0x2261:
386 : 0 : pC = " equiv ";
387 : 0 : break;
388 : : case 0x2264:
389 : 0 : pC = " <= ";
390 : 0 : break;
391 : : case 0x2265:
392 : 0 : pC = " >= ";
393 : 0 : break;
394 : :
395 : : case 0x227A:
396 : 0 : pC = " prec ";
397 : 0 : break;
398 : : case 0x227B:
399 : 0 : pC = " succ ";
400 : 0 : break;
401 : : case 0x227C:
402 : 0 : pC = " preccurlyeq ";
403 : 0 : break;
404 : : case 0x227D:
405 : 0 : pC = " succcurlyeq ";
406 : 0 : break;
407 : : case 0x227E:
408 : 0 : pC = " precsim ";
409 : 0 : break;
410 : : case 0x227F:
411 : 0 : pC = " succsim ";
412 : 0 : break;
413 : : case 0x2280:
414 : 0 : pC = " nprec ";
415 : 0 : break;
416 : : case 0x2281:
417 : 0 : pC = " nsucc ";
418 : 0 : break;
419 : :
420 : : case 0x2282:
421 : 0 : pC = " subset ";
422 : 0 : break;
423 : : case 0x2283:
424 : 0 : pC = " supset ";
425 : 0 : break;
426 : : case 0x2284:
427 : 0 : pC = " nsubset ";
428 : 0 : break;
429 : : case 0x2285:
430 : 0 : pC = " nsupset ";
431 : 0 : break;
432 : : case 0x2286:
433 : 0 : pC = " subseteq ";
434 : 0 : break;
435 : : case 0x2287:
436 : 0 : pC = " supseteq ";
437 : 0 : break;
438 : : case 0x2288:
439 : 0 : pC = " nsubseteq ";
440 : 0 : break;
441 : : case 0x2289:
442 : 0 : pC = " nsupseteq ";
443 : 0 : break;
444 : : case 0x22b2:
445 : : case 0x22b3:
446 : 0 : rRet += ' ';
447 : 0 : rRet.Append(nChar);
448 : 0 : rRet += ' ';
449 : 0 : break;
450 : : case 0x22a5:
451 : 0 : pC = " ortho ";
452 : 0 : break;
453 : : case 0x22c5:
454 : 0 : pC = " cdot ";
455 : 0 : break;
456 : : case 0x22ee:
457 : 0 : pC = " dotsvert ";
458 : 0 : break;
459 : : case 0x22ef:
460 : 0 : pC = " dotsaxis ";
461 : 0 : break;
462 : : case 0x22f0:
463 : 0 : pC = " dotsup ";
464 : 0 : break;
465 : : case 0x22f1:
466 : 0 : pC = " dotsdown ";
467 : 0 : break;
468 : : case 0x2329:
469 : 0 : pC = " langle ";
470 : 0 : break;
471 : : case 0x232a:
472 : 0 : pC = " rangle ";
473 : 0 : break;
474 : : case 0x301a:
475 : 0 : pC = " ldbracket ";
476 : 0 : break;
477 : : case 0x301b:
478 : 0 : pC = " rdbracket ";
479 : 0 : break;
480 : : case 0xe083:
481 : 0 : rRet.Append('+');
482 : 0 : bRet=true;
483 : 0 : break;
484 : : case '^':
485 : : case 0xe091:
486 : 0 : pC = " widehat ";
487 : 0 : break;
488 : : case 0xe096:
489 : 0 : pC = " widetilde ";
490 : 0 : break;
491 : : case 0xe098:
492 : 0 : pC = " widevec ";
493 : 0 : break;
494 : : case 0xE421:
495 : 0 : pC = " geslant ";
496 : 0 : break;
497 : : case 0xE425:
498 : 0 : pC = " leslant ";
499 : 0 : break;
500 : : case 0xeb01: //no space
501 : : case 0xeb08: //normal space
502 : 0 : bRet=true;
503 : 0 : break;
504 : : case 0xef04: //tiny space
505 : : case 0xef05: //tiny space
506 : : case 0xeb02: //small space
507 : : case 0xeb04: //medium space
508 : 0 : rRet.Append('`');
509 : 0 : break;
510 : : case 0xeb05: //large space
511 : 0 : rRet.Append('~');
512 : 0 : break;
513 : : case 0x3a9:
514 : 0 : pC = " %OMEGA ";
515 : 0 : break;
516 : : default:
517 : 0 : rRet.Append(nChar);
518 : 0 : bRet=true;
519 : 0 : break;
520 : : }
521 [ # # ]: 0 : if (pC)
522 : 0 : rRet.AppendAscii(pC);
523 : 0 : return bRet;
524 : : }
525 : :
526 : 0 : void MathTypeFont::AppendStyleToText(String &rRet)
527 : : {
528 : 0 : const char *pC = NULL;
529 [ # # # # ]: 0 : switch (nStyle)
530 : : {
531 : : default:
532 : : case 0:
533 : 0 : break;
534 : : case 1:
535 : 0 : pC = " ital ";
536 : 0 : break;
537 : : case 2:
538 : 0 : pC = " bold ";
539 : 0 : break;
540 : : case 3:
541 : 0 : pC = " bold italic";
542 : 0 : break;
543 : : }
544 [ # # ]: 0 : if (pC)
545 : 0 : rRet.AppendAscii(pC);
546 : 0 : }
547 : :
548 : 0 : void MathType::TypeFaceToString(String &rTxt,sal_uInt8 nFace)
549 : : {
550 : 0 : MathTypeFont aFont(nFace);
551 [ # # ]: 0 : MathTypeFontSet::iterator aItr = aUserStyles.find(aFont);
552 [ # # ]: 0 : if (aItr != aUserStyles.end())
553 : 0 : aFont.nStyle = aItr->nStyle;
554 [ # # ]: 0 : aFont.AppendStyleToText(rTxt);
555 : 0 : }
556 : :
557 : 0 : int MathType::Parse(SotStorage *pStor)
558 : : {
559 : : SvStorageStreamRef xSrc = pStor->OpenSotStream(
560 : : rtl::OUString("Equation Native"),
561 [ # # ][ # # ]: 0 : STREAM_STD_READ | STREAM_NOCREATE);
[ # # ]
562 [ # # ][ # # ]: 0 : if ( (!xSrc.Is()) || (SVSTREAM_OK != xSrc->GetError()))
[ # # ]
563 : 0 : return 0;
564 : 0 : pS = &xSrc;
565 [ # # ]: 0 : pS->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
566 : :
567 : 0 : EQNOLEFILEHDR aHdr;
568 [ # # ]: 0 : aHdr.Read(pS);
569 [ # # ]: 0 : *pS >> nVersion;
570 [ # # ]: 0 : *pS >> nPlatform;
571 [ # # ]: 0 : *pS >> nProduct;
572 [ # # ]: 0 : *pS >> nProdVersion;
573 [ # # ]: 0 : *pS >> nProdSubVersion;
574 : :
575 [ # # ]: 0 : if (nVersion > 3) // allow only supported versions of MathType to be parsed
576 : 0 : return 0;
577 : :
578 : : #ifdef STANDALONE
579 : : *pOut << "Format Version is " << int(nVersion) << endl;
580 : : *pOut << "Generating Platform is " << (nPlatform ? "Windows"
581 : : : "Mac") << endl;
582 : : *pOut << "Generating Product is " << (nPlatform ? "Equation Editor"
583 : : : "Equation Editor") << endl;
584 : : *pOut << "Prod Version is " << int(nProdVersion) << "." <<
585 : : int(nProdSubVersion) << endl << endl;
586 : : #endif
587 : :
588 [ # # ]: 0 : int nRet = HandleRecords();
589 : : //little crude hack to close ocassionally open expressions
590 : : //a sophisticated system to determine what expressions are
591 : : //opened is required, but this is as much work as rewriting
592 : : //starmaths internals.
593 [ # # ]: 0 : APPEND(rRet,"{}");
594 : :
595 : : #if OSL_DEBUG_LEVEL > 1
596 : : # ifdef CAOLAN
597 : : //sanity check
598 : :
599 : : //sigh, theres no point! MathType (in some bizarre subvarient) pads
600 : : //the end of the formula with ENDs (0)'s
601 : : sal_uLong nEnd = pS->Tell();
602 : : OSL_ENSURE(nEnd == pS->Seek(STREAM_SEEK_TO_END),
603 : : "Possibly unfully parsed formula");
604 : : # endif
605 : : #endif
606 [ # # ]: 0 : return nRet;
607 : : }
608 : :
609 : 0 : static void lcl_PrependDummyTerm(String &rRet, xub_StrLen &rTextStart)
610 : : {
611 [ # # ]: 0 : if ((rRet.GetChar(rTextStart) == '=') &&
[ # # # # ]
[ # # ]
612 : : ((rTextStart == 0) ||
613 : 0 : (rRet.GetChar(rTextStart-1) == '{'))
614 : : )
615 : : {
616 : 0 : rRet.InsertAscii(" {}",rTextStart);
617 : 0 : rTextStart+=3;
618 : : }
619 : 0 : }
620 : :
621 : 0 : static void lcl_AppendDummyTerm(String &rRet)
622 : : {
623 : 0 : bool bOk=false;
624 [ # # ]: 0 : for(int nI=rRet.Len()-1;nI >= 0; nI--)
625 : : {
626 : 0 : xub_StrLen nIdx = sal::static_int_cast< xub_StrLen >(nI);
627 : 0 : sal_Unicode nChar = rRet.GetChar(nIdx);
628 [ # # ]: 0 : if (nChar == ' ')
629 : 0 : continue;
630 [ # # ]: 0 : if (rRet.GetChar(nIdx) != '{')
631 : 0 : bOk=true;
632 : 0 : break;
633 : : }
634 [ # # ]: 0 : if (!bOk) //No term, use dummy
635 : 0 : APPEND(rRet," {}");
636 : 0 : }
637 : :
638 : 0 : void MathType::HandleNudge()
639 : : {
640 : : sal_uInt8 nXNudge;
641 [ # # ]: 0 : *pS >> nXNudge;
642 : : sal_uInt8 nYNudge;
643 [ # # ]: 0 : *pS >> nYNudge;
644 [ # # ][ # # ]: 0 : if (nXNudge == 128 && nYNudge == 128)
645 : : {
646 : : sal_uInt16 nXLongNudge;
647 : : sal_uInt16 nYLongNudge;
648 [ # # ]: 0 : *pS >> nXLongNudge;
649 [ # # ]: 0 : *pS >> nYLongNudge;
650 : : }
651 : 0 : }
652 : : /*Fabously complicated as many tokens have to be reordered and generally
653 : : *moved around from mathtypes paradigm to starmaths.*/
654 : 0 : int MathType::HandleRecords(int nLevel,sal_uInt8 nSelector,
655 : : sal_uInt8 nVariation, int nMatrixRows,int nMatrixCols)
656 : : {
657 : : sal_uInt8 nTag,nRecord;
658 : : sal_uInt8 nTabType,nTabStops;
659 : : sal_uInt16 nTabOffset;
660 : 0 : int i,nRet=1,newline=0;
661 : 0 : bool bSilent=false;
662 : 0 : int nPart=0;
663 : 0 : rtl::OUString sPush,sMainTerm;
664 : 0 : int nSetSize=0,nSetAlign=0;
665 : 0 : int nCurRow=0,nCurCol=0;
666 : 0 : bool bOpenString=false;
667 : 0 : xub_StrLen nTextStart = 0;
668 : 0 : xub_StrLen nSubSupStartPos = 0;
669 : 0 : xub_StrLen nLastTemplateBracket=STRING_NOTFOUND;
670 : :
671 [ # # # # ]: 0 : do
[ # # ]
672 : : {
673 [ # # ]: 0 : *pS >> nTag;
674 : 0 : nRecord = nTag&0x0F;
675 : :
676 : : /*MathType strings can of course include words which
677 : : *are StarMath keywords, the simplest solution is
678 : : to escape strings of greater than len 1 with double
679 : : quotes to avoid scanning the TokenTable for matches
680 : :
681 : : Unfortunately it may turn out that the string gets
682 : : split during the handling of a character emblishment
683 : : so this special case must be handled in the
684 : : character handler case 2:
685 : : */
686 [ # # ][ # # ]: 0 : if ((nRecord == CHAR) && (!bIsSilent) && (!bOpenString))
[ # # ]
687 : : {
688 : 0 : bOpenString=true;
689 : 0 : nTextStart = rRet.Len();
690 : : }
691 [ # # ][ # # ]: 0 : else if ((nRecord != CHAR) && (bOpenString))
692 : : {
693 : 0 : bOpenString=false;
694 [ # # ]: 0 : if ((rRet.Len() - nTextStart) > 1)
695 : : {
696 [ # # ]: 0 : String aStr;
697 [ # # ]: 0 : TypeFaceToString(aStr,nTypeFace);
698 [ # # ]: 0 : aStr += '\"';
699 [ # # ]: 0 : rRet.Insert(aStr,nTextStart);
700 [ # # ][ # # ]: 0 : rRet += '\"';
701 : : }
702 : : else
703 : : {
704 [ # # ]: 0 : if (nRecord == END)
705 : : {
706 : 0 : sal_Unicode cChar = 0;
707 : 0 : xub_StrLen nI = rRet.Len()-1;
708 [ # # ][ # # ]: 0 : while (nI && ((cChar = rRet.GetChar(nI)) == ' '))
[ # # ]
709 : 0 : --nI;
710 [ # # ][ # # ]: 0 : if ((cChar == '=') || (cChar == '+') || (cChar == '-'))
[ # # ]
711 [ # # ]: 0 : APPEND(rRet,"{}");
712 : : }
713 : : }
714 : : }
715 : :
716 [ # # # # : 0 : switch(nRecord)
# # # # #
# # ]
717 : : {
718 : : case LINE:
719 : : {
720 [ # # ]: 0 : if (xfLMOVE(nTag))
721 [ # # ]: 0 : HandleNudge();
722 : :
723 [ # # ]: 0 : if (newline>0)
724 [ # # ]: 0 : APPEND(rRet,"\nnewline\n");
725 [ # # ]: 0 : if (!(xfNULL(nTag)))
726 : : {
727 [ # # # # : 0 : switch (nSelector)
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # ]
728 : : {
729 : : case 0x0:
730 [ # # ]: 0 : if (nVariation==0)
731 [ # # ]: 0 : APPEND(rRet," langle ");
732 [ # # ]: 0 : else if (nVariation==1)
733 [ # # ]: 0 : APPEND(rRet," \\langle ");
734 : 0 : break;
735 : : case 0x1:
736 [ # # ]: 0 : if (nVariation==0)
737 [ # # ]: 0 : APPEND(rRet," left (");
738 [ # # ]: 0 : else if (nVariation==1)
739 [ # # ]: 0 : APPEND(rRet,"\\(");
740 : 0 : break;
741 : : case 0x2:
742 [ # # ][ # # ]: 0 : if ((nVariation==0) || (nVariation==1))
743 [ # # ]: 0 : APPEND(rRet," left lbrace ");
744 : : else
745 [ # # ]: 0 : APPEND(rRet," left none ");
746 : 0 : break;
747 : : case 0x3:
748 [ # # ]: 0 : if (nVariation==0)
749 [ # # ]: 0 : APPEND(rRet," left [");
750 [ # # ]: 0 : else if (nVariation==1)
751 [ # # ]: 0 : APPEND(rRet,"\\[");
752 : 0 : break;
753 : : case 0x8:
754 : : case 0xb:
755 [ # # ]: 0 : APPEND(rRet," \\[");
756 : 0 : break;
757 : : case 0x4:
758 [ # # ]: 0 : if (nVariation==0)
759 [ # # ]: 0 : APPEND(rRet," lline ");
760 [ # # ]: 0 : else if (nVariation==1)
761 [ # # ]: 0 : APPEND(rRet," \\lline ");
762 : 0 : break;
763 : : case 0x5:
764 [ # # ]: 0 : if (nVariation==0)
765 [ # # ]: 0 : APPEND(rRet," ldline ");
766 [ # # ]: 0 : else if (nVariation==1)
767 [ # # ]: 0 : APPEND(rRet," \\ldline ");
768 : 0 : break;
769 : : case 0x6:
770 [ # # ][ # # ]: 0 : if (nVariation == 0 || nVariation == 1)
771 [ # # ]: 0 : APPEND(rRet," left lfloor ");
772 [ # # ]: 0 : else if (nVariation==1)
773 [ # # ]: 0 : APPEND(rRet," left none ");
774 : 0 : break;
775 : : case 0x7:
776 [ # # ]: 0 : if (nVariation==0)
777 [ # # ]: 0 : APPEND(rRet," lceil ");
778 [ # # ]: 0 : else if (nVariation==1)
779 [ # # ]: 0 : APPEND(rRet," \\lceil ");
780 : 0 : break;
781 : : case 0x9:
782 : : case 0xa:
783 [ # # ]: 0 : APPEND(rRet," \\]");
784 : 0 : break;
785 : : case 0xc:
786 [ # # ]: 0 : APPEND(rRet," \\(");
787 : 0 : break;
788 : : case 0xd:
789 [ # # ]: 0 : if (nPart == 0)
790 : : {
791 [ # # ]: 0 : if (nVariation == 0)
792 [ # # ]: 0 : APPEND(rRet," sqrt");
793 : : else
794 : : {
795 [ # # ]: 0 : APPEND(rRet," nroot");
796 [ # # ]: 0 : sPush = rRet;
797 [ # # ]: 0 : rRet.Erase();
798 : : }
799 : : }
800 [ # # ]: 0 : APPEND(rRet," {");
801 : 0 : break;
802 : : case 0xe:
803 [ # # ]: 0 : if (nPart == 0)
804 [ # # ]: 0 : APPEND(rRet," { ");
805 : :
806 : :
807 [ # # ]: 0 : if (nPart == 1)
808 [ # # ]: 0 : APPEND(rRet," over ");
809 [ # # ]: 0 : APPEND(rRet," {");
810 : 0 : break;
811 : : case 0xf:
812 : 0 : nSubSupStartPos = rRet.Len();
813 [ # # ][ # # ]: 0 : if ((nVariation == 0) ||
[ # # ]
814 : : ((nVariation == 2) && (nPart==1)))
815 : : {
816 [ # # ]: 0 : lcl_AppendDummyTerm(rRet);
817 [ # # ]: 0 : APPEND(rRet," rSup");
818 : : }
819 [ # # ][ # # ]: 0 : else if ((nVariation == 1) ||
[ # # ]
820 : : ((nVariation == 2) && (nPart==0)))
821 : : {
822 [ # # ]: 0 : lcl_AppendDummyTerm(rRet);
823 [ # # ]: 0 : APPEND(rRet," rSub");
824 : : }
825 [ # # ]: 0 : APPEND(rRet," {");
826 : 0 : break;
827 : : case 0x10:
828 [ # # ]: 0 : if (nVariation == 0)
829 [ # # ]: 0 : APPEND(rRet," {underline ");
830 [ # # ]: 0 : else if (nVariation == 1)
831 [ # # ]: 0 : APPEND(rRet," {underline underline ");
832 [ # # ]: 0 : APPEND(rRet," {");
833 : 0 : break;
834 : : case 0x11:
835 [ # # ]: 0 : if (nVariation == 0)
836 [ # # ]: 0 : APPEND(rRet," {overline ");
837 [ # # ]: 0 : else if (nVariation == 1)
838 [ # # ]: 0 : APPEND(rRet," {overline overline ");
839 [ # # ]: 0 : APPEND(rRet," {");
840 : 0 : break;
841 : : case 0x12:
842 [ # # ]: 0 : if (nPart == 0)
843 : : {
844 [ # # ]: 0 : if (nVariation == 0)
845 [ # # ]: 0 : APPEND(rRet," widevec ");//left arrow above
846 [ # # ]: 0 : else if (nVariation == 1)
847 [ # # ]: 0 : APPEND(rRet," widevec ");//left arrow below
848 [ # # ]: 0 : APPEND(rRet," {");
849 : : }
850 : 0 : break;
851 : : case 0x13:
852 [ # # ]: 0 : if (nPart == 0)
853 : : {
854 [ # # ]: 0 : if (nVariation == 0)
855 [ # # ]: 0 : APPEND(rRet," widevec ");//right arrow above
856 [ # # ]: 0 : else if (nVariation == 1)
857 [ # # ]: 0 : APPEND(rRet," widevec ");//right arrow below
858 [ # # ]: 0 : APPEND(rRet," {");
859 : : }
860 : 0 : break;
861 : : case 0x14:
862 [ # # ]: 0 : if (nPart == 0)
863 : : {
864 [ # # ]: 0 : if (nVariation == 0)
865 [ # # ]: 0 : APPEND(rRet," widevec ");//double arrow above
866 [ # # ]: 0 : else if (nVariation == 1)
867 [ # # ]: 0 : APPEND(rRet," widevec ");//double arrow below
868 [ # # ]: 0 : APPEND(rRet," {");
869 : : }
870 : 0 : break;
871 : : case 0x15:
872 [ # # ]: 0 : if (nPart == 0)
873 : : {
874 [ # # ][ # # ]: 0 : if ((nVariation == 3) || (nVariation == 4))
875 [ # # ]: 0 : APPEND(rRet," lInt");
876 : : else
877 [ # # ]: 0 : APPEND(rRet," Int");
878 [ # # ][ # # ]: 0 : if ( (nVariation != 0) && (nVariation != 3))
879 : : {
880 [ # # ]: 0 : sPush = rRet;
881 [ # # ]: 0 : rRet.Erase();
882 : : }
883 : : }
884 [ # # ][ # # ]: 0 : if (((nVariation == 1) ||
[ # # ]
885 : : (nVariation == 4)) && (nPart==1))
886 [ # # ]: 0 : APPEND(rRet," rSub");
887 [ # # ][ # # ]: 0 : else if ((nVariation == 2) && (nPart==2))
888 [ # # ]: 0 : APPEND(rRet," rSup");
889 [ # # ][ # # ]: 0 : else if ((nVariation == 2) && (nPart==1))
890 [ # # ]: 0 : APPEND(rRet," rSub");
891 [ # # ]: 0 : APPEND(rRet," {");
892 : 0 : break;
893 : : case 0x16:
894 [ # # ]: 0 : if (nPart == 0)
895 : : {
896 [ # # ][ # # ]: 0 : if ((nVariation == 2) || (nVariation == 3))
897 [ # # ]: 0 : APPEND(rRet," llInt");
898 : : else
899 [ # # ]: 0 : APPEND(rRet," iInt");
900 [ # # ][ # # ]: 0 : if ( (nVariation != 0) && (nVariation != 2))
901 : : {
902 [ # # ]: 0 : sPush = rRet;
903 [ # # ]: 0 : rRet.Erase();
904 : : }
905 : : }
906 [ # # ][ # # ]: 0 : if (((nVariation == 1) ||
[ # # ]
907 : : (nVariation == 3)) && (nPart==1))
908 [ # # ]: 0 : APPEND(rRet," rSub");
909 [ # # ]: 0 : APPEND(rRet," {");
910 : 0 : break;
911 : : case 0x17:
912 [ # # ]: 0 : if (nPart == 0)
913 : : {
914 [ # # ][ # # ]: 0 : if ((nVariation == 2) || (nVariation == 3))
915 [ # # ]: 0 : APPEND(rRet," lllInt");
916 : : else
917 [ # # ]: 0 : APPEND(rRet," iiInt");
918 [ # # ][ # # ]: 0 : if ( (nVariation != 0) && (nVariation != 2))
919 : : {
920 [ # # ]: 0 : sPush = rRet;
921 [ # # ]: 0 : rRet.Erase();
922 : : }
923 : : }
924 [ # # ][ # # ]: 0 : if (((nVariation == 1) ||
[ # # ]
925 : : (nVariation == 3)) && (nPart==1))
926 [ # # ]: 0 : APPEND(rRet," rSub");
927 [ # # ]: 0 : APPEND(rRet," {");
928 : 0 : break;
929 : : case 0x18:
930 [ # # ]: 0 : if (nPart == 0)
931 : : {
932 [ # # ]: 0 : if (nVariation == 2)
933 [ # # ]: 0 : APPEND(rRet," lInt");
934 : : else
935 [ # # ]: 0 : APPEND(rRet," Int");
936 [ # # ]: 0 : sPush = rRet;
937 [ # # ]: 0 : rRet.Erase();
938 : : }
939 [ # # ][ # # ]: 0 : if (((nVariation == 1) ||
[ # # ]
940 : : (nVariation == 2)) && (nPart==1))
941 [ # # ]: 0 : APPEND(rRet," cSub");
942 [ # # ][ # # ]: 0 : else if ((nVariation == 0) && (nPart==2))
943 [ # # ]: 0 : APPEND(rRet," cSup");
944 [ # # ][ # # ]: 0 : else if ((nVariation == 0) && (nPart==1))
945 [ # # ]: 0 : APPEND(rRet," cSub");
946 [ # # ]: 0 : APPEND(rRet," {");
947 : 0 : break;
948 : : case 0x19:
949 [ # # ]: 0 : if (nPart == 0)
950 : : {
951 [ # # ]: 0 : if (nVariation == 0)
952 [ # # ]: 0 : APPEND(rRet," llInt");
953 : : else
954 [ # # ]: 0 : APPEND(rRet," iInt");
955 [ # # ]: 0 : sPush = rRet;
956 [ # # ]: 0 : rRet.Erase();
957 : : }
958 [ # # ]: 0 : if (nPart==1)
959 [ # # ]: 0 : APPEND(rRet," cSub");
960 [ # # ]: 0 : APPEND(rRet," {");
961 : 0 : break;
962 : : case 0x1a:
963 [ # # ]: 0 : if (nPart == 0)
964 : : {
965 [ # # ]: 0 : if (nVariation == 0)
966 [ # # ]: 0 : APPEND(rRet," lllInt");
967 : : else
968 [ # # ]: 0 : APPEND(rRet," iiInt");
969 [ # # ]: 0 : sPush = rRet;
970 [ # # ]: 0 : rRet.Erase();
971 : : }
972 [ # # ]: 0 : if (nPart==1)
973 [ # # ]: 0 : APPEND(rRet," cSub");
974 [ # # ]: 0 : APPEND(rRet," {");
975 : 0 : break;
976 : : case 0x1b:
977 : : case 0x1c:
978 [ # # ]: 0 : APPEND(rRet," {");
979 : 0 : break;
980 : : case 0x1d:
981 [ # # ]: 0 : if (nPart == 0)
982 : : {
983 [ # # ]: 0 : APPEND(rRet," Sum");
984 [ # # ]: 0 : if (nVariation != 2)
985 : : {
986 [ # # ]: 0 : sPush = rRet;
987 [ # # ]: 0 : rRet.Erase();
988 : : }
989 : : }
990 [ # # ][ # # ]: 0 : if ((nVariation == 0) && (nPart==1))
991 [ # # ]: 0 : APPEND(rRet," cSub");
992 [ # # ][ # # ]: 0 : else if ((nVariation == 1) && (nPart==2))
993 [ # # ]: 0 : APPEND(rRet," cSup");
994 [ # # ][ # # ]: 0 : else if ((nVariation == 1) && (nPart==1))
995 [ # # ]: 0 : APPEND(rRet," cSub");
996 [ # # ]: 0 : APPEND(rRet," {");
997 : 0 : break;
998 : : case 0x1e:
999 [ # # ]: 0 : if (nPart == 0)
1000 : : {
1001 [ # # ]: 0 : APPEND(rRet," Sum");
1002 [ # # ]: 0 : sPush = rRet;
1003 [ # # ]: 0 : rRet.Erase();
1004 : : }
1005 [ # # ][ # # ]: 0 : if ((nVariation == 0) && (nPart==1))
1006 [ # # ]: 0 : APPEND(rRet," rSub");
1007 [ # # ][ # # ]: 0 : else if ((nVariation == 1) && (nPart==2))
1008 [ # # ]: 0 : APPEND(rRet," rSup");
1009 [ # # ][ # # ]: 0 : else if ((nVariation == 1) && (nPart==1))
1010 [ # # ]: 0 : APPEND(rRet," rSub");
1011 [ # # ]: 0 : APPEND(rRet," {");
1012 : 0 : break;
1013 : : case 0x1f:
1014 [ # # ]: 0 : if (nPart == 0)
1015 : : {
1016 [ # # ]: 0 : APPEND(rRet," Prod");
1017 [ # # ]: 0 : if (nVariation != 2)
1018 : : {
1019 [ # # ]: 0 : sPush = rRet;
1020 [ # # ]: 0 : rRet.Erase();
1021 : : }
1022 : : }
1023 [ # # ][ # # ]: 0 : if ((nVariation == 0) && (nPart==1))
1024 [ # # ]: 0 : APPEND(rRet," cSub");
1025 [ # # ][ # # ]: 0 : else if ((nVariation == 1) && (nPart==2))
1026 [ # # ]: 0 : APPEND(rRet," cSup");
1027 [ # # ][ # # ]: 0 : else if ((nVariation == 1) && (nPart==1))
1028 [ # # ]: 0 : APPEND(rRet," cSub");
1029 [ # # ]: 0 : APPEND(rRet," {");
1030 : 0 : break;
1031 : : case 0x20:
1032 [ # # ]: 0 : if (nPart == 0)
1033 : : {
1034 [ # # ]: 0 : APPEND(rRet," Prod");
1035 [ # # ]: 0 : sPush = rRet;
1036 [ # # ]: 0 : rRet.Erase();
1037 : : }
1038 [ # # ][ # # ]: 0 : if ((nVariation == 0) && (nPart==1))
1039 [ # # ]: 0 : APPEND(rRet," rSub");
1040 [ # # ][ # # ]: 0 : else if ((nVariation == 1) && (nPart==2))
1041 [ # # ]: 0 : APPEND(rRet," rSup");
1042 [ # # ][ # # ]: 0 : else if ((nVariation == 1) && (nPart==1))
1043 [ # # ]: 0 : APPEND(rRet," rSub");
1044 [ # # ]: 0 : APPEND(rRet," {");
1045 : 0 : break;
1046 : : case 0x21:
1047 [ # # ]: 0 : if (nPart == 0)
1048 : : {
1049 [ # # ]: 0 : APPEND(rRet," coProd");
1050 [ # # ]: 0 : if (nVariation != 2)
1051 : : {
1052 [ # # ]: 0 : sPush = rRet;
1053 [ # # ]: 0 : rRet.Erase();
1054 : : }
1055 : : }
1056 [ # # ][ # # ]: 0 : if ((nVariation == 0) && (nPart==1))
1057 [ # # ]: 0 : APPEND(rRet," cSub");
1058 [ # # ][ # # ]: 0 : else if ((nVariation == 1) && (nPart==2))
1059 [ # # ]: 0 : APPEND(rRet," cSup");
1060 [ # # ][ # # ]: 0 : else if ((nVariation == 1) && (nPart==1))
1061 [ # # ]: 0 : APPEND(rRet," cSub");
1062 [ # # ]: 0 : APPEND(rRet," {");
1063 : 0 : break;
1064 : : case 0x22:
1065 [ # # ]: 0 : if (nPart == 0)
1066 : : {
1067 [ # # ]: 0 : APPEND(rRet," coProd");
1068 [ # # ]: 0 : sPush = rRet;
1069 [ # # ]: 0 : rRet.Erase();
1070 : : }
1071 [ # # ][ # # ]: 0 : if ((nVariation == 0) && (nPart==1))
1072 [ # # ]: 0 : APPEND(rRet," rSub");
1073 [ # # ][ # # ]: 0 : else if ((nVariation == 1) && (nPart==2))
1074 [ # # ]: 0 : APPEND(rRet," rSup");
1075 [ # # ][ # # ]: 0 : else if ((nVariation == 1) && (nPart==1))
1076 [ # # ]: 0 : APPEND(rRet," rSub");
1077 [ # # ]: 0 : APPEND(rRet," {");
1078 : 0 : break;
1079 : : case 0x23:
1080 [ # # ]: 0 : if (nPart == 0)
1081 : : {
1082 [ # # ]: 0 : APPEND(rRet," union"); //union
1083 [ # # ]: 0 : if (nVariation != 2)
1084 : : {
1085 [ # # ]: 0 : sPush = rRet;
1086 [ # # ]: 0 : rRet.Erase();
1087 : : }
1088 : : }
1089 [ # # ][ # # ]: 0 : if ((nVariation == 0) && (nPart==1))
1090 [ # # ]: 0 : APPEND(rRet," cSub");
1091 [ # # ][ # # ]: 0 : else if ((nVariation == 1) && (nPart==2))
1092 [ # # ]: 0 : APPEND(rRet," cSup");
1093 [ # # ][ # # ]: 0 : else if ((nVariation == 1) && (nPart==1))
1094 [ # # ]: 0 : APPEND(rRet," cSub");
1095 [ # # ]: 0 : APPEND(rRet," {");
1096 : 0 : break;
1097 : : case 0x24:
1098 [ # # ]: 0 : if (nPart == 0)
1099 : : {
1100 [ # # ]: 0 : APPEND(rRet," union"); //union
1101 [ # # ]: 0 : sPush = rRet;
1102 [ # # ]: 0 : rRet.Erase();
1103 : : }
1104 [ # # ][ # # ]: 0 : if ((nVariation == 0) && (nPart==1))
1105 [ # # ]: 0 : APPEND(rRet," rSub");
1106 [ # # ][ # # ]: 0 : else if ((nVariation == 1) && (nPart==2))
1107 [ # # ]: 0 : APPEND(rRet," rSup");
1108 [ # # ][ # # ]: 0 : else if ((nVariation == 1) && (nPart==1))
1109 [ # # ]: 0 : APPEND(rRet," rSub");
1110 [ # # ]: 0 : APPEND(rRet," {");
1111 : 0 : break;
1112 : : case 0x25:
1113 [ # # ]: 0 : if (nPart == 0)
1114 : : {
1115 [ # # ]: 0 : APPEND(rRet," intersect"); //intersect
1116 [ # # ]: 0 : if (nVariation != 2)
1117 : : {
1118 [ # # ]: 0 : sPush = rRet;
1119 [ # # ]: 0 : rRet.Erase();
1120 : : }
1121 : : }
1122 [ # # ][ # # ]: 0 : if ((nVariation == 0) && (nPart==1))
1123 [ # # ]: 0 : APPEND(rRet," cSub");
1124 [ # # ][ # # ]: 0 : else if ((nVariation == 1) && (nPart==2))
1125 [ # # ]: 0 : APPEND(rRet," cSup");
1126 [ # # ][ # # ]: 0 : else if ((nVariation == 1) && (nPart==1))
1127 [ # # ]: 0 : APPEND(rRet," cSub");
1128 [ # # ]: 0 : APPEND(rRet," {");
1129 : 0 : break;
1130 : : case 0x26:
1131 [ # # ]: 0 : if (nPart == 0)
1132 : : {
1133 [ # # ]: 0 : APPEND(rRet," intersect"); //intersect
1134 [ # # ]: 0 : sPush = rRet;
1135 [ # # ]: 0 : rRet.Erase();
1136 : : }
1137 [ # # ][ # # ]: 0 : if ((nVariation == 0) && (nPart==1))
1138 [ # # ]: 0 : APPEND(rRet," rSub");
1139 [ # # ][ # # ]: 0 : else if ((nVariation == 1) && (nPart==2))
1140 [ # # ]: 0 : APPEND(rRet," rSup");
1141 [ # # ][ # # ]: 0 : else if ((nVariation == 1) && (nPart==1))
1142 [ # # ]: 0 : APPEND(rRet," rSub");
1143 [ # # ]: 0 : APPEND(rRet," {");
1144 : 0 : break;
1145 : : case 0x27:
1146 [ # # ][ # # ]: 0 : if ((nVariation == 0) && (nPart==1))
1147 [ # # ]: 0 : APPEND(rRet," cSup");
1148 [ # # ][ # # ]: 0 : else if ((nVariation == 1) && (nPart==1))
1149 [ # # ]: 0 : APPEND(rRet," cSub");
1150 [ # # ][ # # ]: 0 : else if ((nVariation == 2) && (nPart==1))
1151 [ # # ]: 0 : APPEND(rRet," cSub");
1152 [ # # ][ # # ]: 0 : else if ((nVariation == 2) && (nPart==2))
1153 [ # # ]: 0 : APPEND(rRet," cSup");
1154 [ # # ]: 0 : APPEND(rRet," {");
1155 : 0 : break;
1156 : : case 0x28:
1157 [ # # ]: 0 : if (nVariation == 0)
1158 : : {
1159 [ # # ]: 0 : if (nPart == 0)
1160 : : {
1161 [ # # ]: 0 : sPush = rRet;
1162 [ # # ]: 0 : rRet.Erase();
1163 : : }
1164 : : }
1165 [ # # ]: 0 : APPEND(rRet," {");
1166 [ # # ]: 0 : if (nVariation == 0)
1167 : : {
1168 [ # # ]: 0 : if (nPart == 1)
1169 [ # # ]: 0 : APPEND(rRet,"alignr ");
1170 : : }
1171 [ # # ]: 0 : if (nPart == 0)
1172 [ # # ]: 0 : APPEND(rRet,"\\lline ");
1173 [ # # ]: 0 : if (nVariation == 1)
1174 [ # # ]: 0 : APPEND(rRet,"overline ");
1175 : 0 : break;
1176 : : case 0x29:
1177 [ # # ]: 0 : APPEND(rRet," {");
1178 : 0 : break;
1179 : : case 0x2a:
1180 [ # # ]: 0 : if (nPart == 0)
1181 : : {
1182 [ # # ]: 0 : sPush = rRet;
1183 [ # # ]: 0 : rRet.Erase();
1184 : : }
1185 [ # # ][ # # ]: 0 : if ((nVariation == 0) && (nPart==0))
1186 [ # # ]: 0 : APPEND(rRet," rSup");
1187 [ # # ][ # # ]: 0 : else if ((nVariation == 2) && (nPart==1))
1188 [ # # ]: 0 : APPEND(rRet," rSup");
1189 [ # # ][ # # ]: 0 : else if ((nVariation == 1) && (nPart==0))
1190 [ # # ]: 0 : APPEND(rRet," rSub");
1191 [ # # ][ # # ]: 0 : else if ((nVariation == 2) && (nPart==0))
1192 [ # # ]: 0 : APPEND(rRet," rSub");
1193 [ # # ]: 0 : APPEND(rRet," {");
1194 : 0 : break;
1195 : : case 0x2b:
1196 [ # # ]: 0 : if (nPart == 0)
1197 : : {
1198 [ # # ]: 0 : sPush = rRet;
1199 [ # # ]: 0 : rRet.Erase();
1200 : : }
1201 [ # # ][ # # ]: 0 : if ((nVariation == 0) && (nPart==0))
1202 [ # # ]: 0 : APPEND(rRet," cSup");
1203 [ # # ][ # # ]: 0 : else if ((nVariation == 2) && (nPart==1))
1204 [ # # ]: 0 : APPEND(rRet," cSup");
1205 [ # # ][ # # ]: 0 : else if ((nVariation == 1) && (nPart==0))
1206 [ # # ]: 0 : APPEND(rRet," cSub");
1207 [ # # ][ # # ]: 0 : else if ((nVariation == 2) && (nPart==0))
1208 [ # # ]: 0 : APPEND(rRet," cSub");
1209 [ # # ]: 0 : APPEND(rRet," {");
1210 : 0 : break;
1211 : : case 0x2c:
1212 [ # # ]: 0 : if (nPart == 0)
1213 [ # # ]: 0 : APPEND(rRet,"\"\"");
1214 [ # # ][ # # ]: 0 : if ((nVariation == 0)
[ # # ]
1215 : : || ((nVariation == 2) && (nPart==1)))
1216 [ # # ]: 0 : APPEND(rRet," lSup");
1217 [ # # ][ # # ]: 0 : else if ((nVariation == 1)
[ # # ]
1218 : : || ((nVariation == 2) && (nPart==0)))
1219 [ # # ]: 0 : APPEND(rRet," lSub");
1220 [ # # ]: 0 : APPEND(rRet," {");
1221 : 0 : break;
1222 : : case 0x2d:
1223 [ # # ]: 0 : if (nVariation==0)
1224 : : {
1225 [ # # ]: 0 : if (nPart == 0)
1226 [ # # ]: 0 : APPEND(rRet," langle ");
1227 : : }
1228 [ # # ]: 0 : else if (nVariation==1)
1229 : : {
1230 [ # # ]: 0 : APPEND(rRet," \\langle ");
1231 : 0 : newline--;
1232 : : }
1233 [ # # ]: 0 : else if (nVariation==2)
1234 : : {
1235 [ # # ]: 0 : APPEND(rRet," \\lline ");
1236 : 0 : newline--;
1237 : : }
1238 : 0 : break;
1239 : : case 0x2e:
1240 [ # # ]: 0 : if (nVariation == 0)
1241 [ # # ]: 0 : APPEND(rRet," widevec ");//left below
1242 [ # # ]: 0 : else if (nVariation == 1)
1243 [ # # ]: 0 : APPEND(rRet," widevec ");//right below
1244 [ # # ]: 0 : else if (nVariation == 2)
1245 [ # # ]: 0 : APPEND(rRet," widevec ");//double headed below
1246 [ # # ]: 0 : APPEND(rRet," {");
1247 : 0 : break;
1248 : : case 0x2f:
1249 [ # # ]: 0 : if (nVariation == 0)
1250 [ # # ]: 0 : APPEND(rRet," widevec ");//left above
1251 [ # # ]: 0 : else if (nVariation == 1)
1252 [ # # ]: 0 : APPEND(rRet," widevec ");//right above
1253 [ # # ]: 0 : else if (nVariation == 2)
1254 [ # # ]: 0 : APPEND(rRet," widevec ");//double headed above
1255 [ # # ]: 0 : APPEND(rRet," {");
1256 : 0 : break;
1257 : : default:
1258 : 0 : break;
1259 : : }
1260 : 0 : sal_Int16 nOldCurSize=nCurSize;
1261 : 0 : xub_StrLen nSizeStartPos = rRet.Len();
1262 [ # # ]: 0 : HandleSize(nLSize,nDSize,nSetSize);
1263 [ # # ]: 0 : nRet = HandleRecords(nLevel+1);
1264 [ # # ]: 0 : while (nSetSize)
1265 : : {
1266 : 0 : bool bOk=false;
1267 [ # # ]: 0 : xub_StrLen nI = rRet.SearchBackward('{');
1268 [ # # ]: 0 : if (nI != STRING_NOTFOUND)
1269 : : {
1270 [ # # ]: 0 : for(nI=nI+1;nI<rRet.Len();nI++)
1271 [ # # ]: 0 : if (rRet.GetChar(nI) != ' ')
1272 : : {
1273 : 0 : bOk=true;
1274 : 0 : break;
1275 : : }
1276 : : }
1277 : : else
1278 : 0 : bOk=true;
1279 : :
1280 [ # # ]: 0 : if (bOk)
1281 [ # # ]: 0 : APPEND(rRet,"} ");
1282 : : else
1283 [ # # ]: 0 : rRet.Erase(nSizeStartPos);
1284 : 0 : nSetSize--;
1285 : 0 : nCurSize=nOldCurSize;
1286 : : }
1287 : :
1288 : :
1289 : : HandleMatrixSeperator(nMatrixRows,nMatrixCols,
1290 [ # # ]: 0 : nCurCol,nCurRow);
1291 : :
1292 [ # # # # : 0 : switch (nSelector)
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # ]
1293 : : {
1294 : : case 0x0:
1295 [ # # ]: 0 : if (nVariation==0)
1296 [ # # ]: 0 : APPEND(rRet," rangle ");
1297 [ # # ]: 0 : else if (nVariation==2)
1298 [ # # ]: 0 : APPEND(rRet," \\rangle ");
1299 : 0 : break;
1300 : : case 0x1:
1301 [ # # ]: 0 : if (nVariation==0)
1302 [ # # ]: 0 : APPEND(rRet," right )");
1303 [ # # ]: 0 : else if (nVariation==2)
1304 [ # # ]: 0 : APPEND(rRet,"\\)");
1305 : 0 : break;
1306 : : case 0x2:
1307 [ # # ][ # # ]: 0 : if ((nVariation==0) || (nVariation==2))
1308 [ # # ]: 0 : APPEND(rRet," right rbrace ");
1309 : : else
1310 [ # # ]: 0 : APPEND(rRet," right none ");
1311 : 0 : break;
1312 : : case 0x3:
1313 [ # # ]: 0 : if (nVariation==0)
1314 [ # # ]: 0 : APPEND(rRet," right ]");
1315 [ # # ]: 0 : else if (nVariation==2)
1316 [ # # ]: 0 : APPEND(rRet,"\\]");
1317 : 0 : break;
1318 : : case 0x4:
1319 [ # # ]: 0 : if (nVariation==0)
1320 [ # # ]: 0 : APPEND(rRet," rline ");
1321 [ # # ]: 0 : else if (nVariation==2)
1322 [ # # ]: 0 : APPEND(rRet," \\rline ");
1323 : 0 : break;
1324 : : case 0x5:
1325 [ # # ]: 0 : if (nVariation==0)
1326 [ # # ]: 0 : APPEND(rRet," rdline ");
1327 [ # # ]: 0 : else if (nVariation==2)
1328 [ # # ]: 0 : APPEND(rRet," \\rdline ");
1329 : 0 : break;
1330 : : case 0x6:
1331 [ # # ][ # # ]: 0 : if (nVariation == 0 || nVariation == 2)
1332 [ # # ]: 0 : APPEND(rRet," right rfloor ");
1333 [ # # ]: 0 : else if (nVariation==2)
1334 [ # # ]: 0 : APPEND(rRet," right none ");
1335 : 0 : break;
1336 : : case 0x7:
1337 [ # # ]: 0 : if (nVariation==0)
1338 [ # # ]: 0 : APPEND(rRet," rceil ");
1339 [ # # ]: 0 : else if (nVariation==2)
1340 [ # # ]: 0 : APPEND(rRet," \\rceil ");
1341 : 0 : break;
1342 : : case 0x8:
1343 : : case 0xa:
1344 [ # # ]: 0 : APPEND(rRet,"\\[");
1345 : 0 : break;
1346 : : case 0x9:
1347 : : case 0xc:
1348 [ # # ]: 0 : APPEND(rRet,"\\]");
1349 : 0 : break;
1350 : : case 0xd:
1351 [ # # ]: 0 : APPEND(rRet,"} ");
1352 [ # # ]: 0 : if (nVariation == 1)
1353 : : {
1354 [ # # ]: 0 : if (nPart == 0)
1355 : : {
1356 : 0 : newline--;
1357 [ # # ]: 0 : sMainTerm = rRet;
1358 [ # # ]: 0 : rRet.Erase();
1359 : : }
1360 : : else
1361 : : {
1362 [ # # ]: 0 : sPush += rRet;
1363 [ # # ]: 0 : rRet = sPush;
1364 [ # # ]: 0 : rRet += sMainTerm;
1365 : : }
1366 : : }
1367 : : else
1368 : : {
1369 [ # # ]: 0 : if (nPart == 0)
1370 : 0 : newline--;
1371 : : }
1372 : 0 : nPart++;
1373 : 0 : break;
1374 : : case 0xb:
1375 [ # # ]: 0 : APPEND(rRet,"\\)");
1376 : 0 : break;
1377 : : case 0xe:
1378 [ # # ]: 0 : APPEND(rRet,"} ");
1379 [ # # ]: 0 : if (nPart == 0)
1380 : 0 : newline--;
1381 : : else
1382 [ # # ]: 0 : APPEND(rRet,"} ");
1383 : 0 : nPart++;
1384 : 0 : break;
1385 : : case 0xf:
1386 : : {
1387 [ # # ][ # # ]: 0 : if ((nPart == 0) &&
[ # # ]
1388 : : ((nVariation == 2) || (nVariation == 1)))
1389 : 0 : newline--;
1390 : :
1391 : 0 : bool bOk=false;
1392 [ # # ]: 0 : xub_StrLen nI = rRet.SearchBackward('{');
1393 [ # # ]: 0 : if (nI != STRING_NOTFOUND)
1394 : : {
1395 [ # # ]: 0 : for(nI=nI+1;nI<rRet.Len();nI++)
1396 [ # # ]: 0 : if (rRet.GetChar(nI) != ' ')
1397 : : {
1398 : 0 : bOk=true;
1399 : 0 : break;
1400 : : }
1401 : : }
1402 : : else
1403 : 0 : bOk=true;
1404 : :
1405 [ # # ]: 0 : if (bOk)
1406 [ # # ]: 0 : APPEND(rRet,"} ");
1407 : : else
1408 [ # # ]: 0 : rRet.Erase(nSubSupStartPos);
1409 : 0 : nPart++;
1410 : : }
1411 : 0 : break;
1412 : : case 0x2c:
1413 [ # # ][ # # ]: 0 : if ((nPart == 0) &&
[ # # ]
1414 : : ((nVariation == 2) || (nVariation == 1)))
1415 : 0 : newline--;
1416 [ # # ]: 0 : APPEND(rRet,"} ");
1417 : 0 : nPart++;
1418 : 0 : break;
1419 : : case 0x2e:
1420 : : case 0x2f:
1421 [ # # ]: 0 : APPEND(rRet,"} ");
1422 : 0 : break;
1423 : : case 0x10:
1424 : : case 0x11:
1425 [ # # ]: 0 : APPEND(rRet,"}} ");
1426 : 0 : break;
1427 : : case 0x12:
1428 : : case 0x13:
1429 : : case 0x14:
1430 [ # # ]: 0 : if (nPart == 0)
1431 : : {
1432 : 0 : newline--;
1433 [ # # ]: 0 : APPEND(rRet,"} ");
1434 : : }
1435 : 0 : nPart++;
1436 : 0 : break;
1437 : : case 0x1b:
1438 [ # # ]: 0 : APPEND(rRet,"} ");
1439 [ # # ]: 0 : if (nPart == 0)
1440 : : {
1441 : 0 : newline--;
1442 [ # # ]: 0 : APPEND(rRet,"overbrace");
1443 : : }
1444 : 0 : nPart++;
1445 : 0 : break;
1446 : : case 0x1c:
1447 [ # # ]: 0 : APPEND(rRet,"} ");
1448 [ # # ]: 0 : if (nPart == 0)
1449 : : {
1450 : 0 : newline--;
1451 [ # # ]: 0 : APPEND(rRet,"underbrace");
1452 : : }
1453 : 0 : nPart++;
1454 : 0 : break;
1455 : : case 0x27:
1456 [ # # ]: 0 : if (nPart==0)
1457 : 0 : newline--;
1458 [ # # ][ # # ]: 0 : else if ((nPart==1) &&
[ # # ]
1459 : : ((nVariation == 2) || (nVariation == 1)))
1460 : 0 : newline--;
1461 [ # # ]: 0 : APPEND(rRet,"} ");
1462 : 0 : nPart++;
1463 : 0 : break;
1464 : : case 0x28:
1465 [ # # ]: 0 : APPEND(rRet,"} ");
1466 [ # # ]: 0 : if (nVariation == 0)
1467 : : {
1468 [ # # ]: 0 : if (nPart == 0)
1469 : : {
1470 [ # # ]: 0 : sMainTerm = rRet;
1471 [ # # ]: 0 : rRet.Erase();
1472 : : }
1473 : : else
1474 : : {
1475 [ # # ]: 0 : sPush += rRet;
1476 [ # # ]: 0 : rRet = sPush;
1477 [ # # ]: 0 : APPEND(rRet," over ");
1478 [ # # ]: 0 : rRet += sMainTerm;
1479 : : }
1480 : : }
1481 [ # # ]: 0 : if (nPart == 0)
1482 : 0 : newline--;
1483 : 0 : nPart++;
1484 : 0 : break;
1485 : : case 0x29:
1486 [ # # ]: 0 : APPEND(rRet,"} ");
1487 [ # # ]: 0 : if (nPart == 0)
1488 : : {
1489 : 0 : newline--;
1490 [ # # ]: 0 : switch (nVariation)
1491 : : {
1492 : : case 1:
1493 [ # # ]: 0 : APPEND(rRet,"slash");
1494 : 0 : break;
1495 : : default:
1496 [ # # ]: 0 : APPEND(rRet,"wideslash");
1497 : 0 : break;
1498 : : }
1499 : : }
1500 : 0 : nPart++;
1501 : 0 : break;
1502 : : case 0x1d:
1503 : : case 0x1e:
1504 : : case 0x1f:
1505 : : case 0x20:
1506 : : case 0x21:
1507 : : case 0x22:
1508 : : case 0x23:
1509 : : case 0x24:
1510 : : case 0x25:
1511 : : case 0x26:
1512 [ # # ]: 0 : APPEND(rRet,"} ");
1513 [ # # ]: 0 : if (nPart == 0)
1514 : : {
1515 [ # # ]: 0 : if (nVariation != 2)
1516 : : {
1517 [ # # ]: 0 : sMainTerm = rRet;
1518 [ # # ]: 0 : rRet.Erase();
1519 : : }
1520 : 0 : newline--;
1521 : : }
1522 [ # # ][ # # ]: 0 : else if ((nPart == 1) && (nVariation == 0))
1523 : : {
1524 [ # # ]: 0 : sPush += rRet;
1525 [ # # ]: 0 : rRet = sPush;
1526 [ # # ]: 0 : rRet += sMainTerm;
1527 : 0 : newline--;
1528 : : }
1529 [ # # ][ # # ]: 0 : else if ((nPart == 1) && (nVariation == 1))
1530 : 0 : newline--;
1531 [ # # ][ # # ]: 0 : else if ((nPart == 2) && (nVariation == 1))
1532 : : {
1533 [ # # ]: 0 : sPush += rRet;
1534 [ # # ]: 0 : rRet = sPush;
1535 [ # # ]: 0 : rRet += sMainTerm;
1536 : 0 : newline--;
1537 : : }
1538 : 0 : nPart++;
1539 : 0 : break;
1540 : : case 0x15:
1541 [ # # ]: 0 : APPEND(rRet,"} ");
1542 [ # # ]: 0 : if (nPart == 0)
1543 : : {
1544 [ # # ][ # # ]: 0 : if ((nVariation != 0) && (nVariation != 3))
1545 : : {
1546 [ # # ]: 0 : sMainTerm = rRet;
1547 [ # # ]: 0 : rRet.Erase();
1548 : : }
1549 : 0 : newline--;
1550 : : }
1551 [ # # ][ # # ]: 0 : else if ((nPart == 1) &&
[ # # ]
1552 : : ((nVariation == 1) || (nVariation==4)))
1553 : : {
1554 [ # # ]: 0 : sPush += rRet;
1555 [ # # ]: 0 : rRet = sPush;
1556 [ # # ]: 0 : rRet += sMainTerm;
1557 : 0 : newline--;
1558 : : }
1559 [ # # ][ # # ]: 0 : else if ((nPart == 1) && (nVariation == 2))
1560 : 0 : newline--;
1561 [ # # ][ # # ]: 0 : else if ((nPart == 2) && (nVariation == 2))
1562 : : {
1563 [ # # ]: 0 : sPush += rRet;
1564 [ # # ]: 0 : rRet = sPush;
1565 [ # # ]: 0 : rRet += sMainTerm;
1566 : 0 : newline--;
1567 : : }
1568 : 0 : nPart++;
1569 : 0 : break;
1570 : : case 0x16:
1571 : : case 0x17:
1572 [ # # ]: 0 : APPEND(rRet,"} ");
1573 [ # # ]: 0 : if (nPart == 0)
1574 : : {
1575 [ # # ][ # # ]: 0 : if ((nVariation != 0) && (nVariation != 2))
1576 : : {
1577 [ # # ]: 0 : sMainTerm = rRet;
1578 [ # # ]: 0 : rRet.Erase();
1579 : : }
1580 : 0 : newline--;
1581 : : }
1582 [ # # ][ # # ]: 0 : else if ((nPart == 1) &&
[ # # ]
1583 : : ((nVariation == 1) || (nVariation==3)))
1584 : : {
1585 [ # # ]: 0 : sPush += rRet;
1586 [ # # ]: 0 : rRet = sPush;
1587 [ # # ]: 0 : rRet += sMainTerm;
1588 : 0 : newline--;
1589 : : }
1590 : 0 : nPart++;
1591 : 0 : break;
1592 : : case 0x18:
1593 [ # # ]: 0 : APPEND(rRet,"} ");
1594 [ # # ]: 0 : if (nPart == 0)
1595 : : {
1596 [ # # ]: 0 : sMainTerm = rRet;
1597 [ # # ]: 0 : rRet.Erase();
1598 : 0 : newline--;
1599 : : }
1600 [ # # ][ # # ]: 0 : else if ((nPart == 1) &&
[ # # ]
1601 : : ((nVariation == 1) || (nVariation==2)))
1602 : : {
1603 [ # # ]: 0 : sPush += rRet;
1604 [ # # ]: 0 : rRet = sPush;
1605 [ # # ]: 0 : rRet += sMainTerm;
1606 : 0 : newline--;
1607 : : }
1608 [ # # ][ # # ]: 0 : else if ((nPart == 1) && (nVariation == 0))
1609 : 0 : newline--;
1610 [ # # ][ # # ]: 0 : else if ((nPart == 2) && (nVariation == 0))
1611 : : {
1612 [ # # ]: 0 : sPush += rRet;
1613 [ # # ]: 0 : rRet = sPush;
1614 [ # # ]: 0 : rRet += sMainTerm;
1615 : 0 : newline--;
1616 : : }
1617 : 0 : nPart++;
1618 : 0 : break;
1619 : : case 0x19:
1620 : : case 0x1a:
1621 [ # # ]: 0 : APPEND(rRet,"} ");
1622 [ # # ]: 0 : if (nPart == 0)
1623 : : {
1624 [ # # ]: 0 : sMainTerm = rRet;
1625 [ # # ]: 0 : rRet.Erase();
1626 : 0 : newline--;
1627 : : }
1628 [ # # ]: 0 : else if (nPart == 1)
1629 : : {
1630 [ # # ]: 0 : sPush += rRet;
1631 [ # # ]: 0 : rRet = sPush;
1632 [ # # ]: 0 : rRet += sMainTerm;
1633 : 0 : newline--;
1634 : : }
1635 : 0 : nPart++;
1636 : 0 : break;
1637 : : case 0x2a:
1638 : : case 0x2b:
1639 [ # # ]: 0 : APPEND(rRet,"} ");
1640 : :
1641 [ # # ][ # # ]: 0 : if ((nPart == 0) &&
[ # # ]
1642 : : ((nVariation == 0) || (nVariation == 1)))
1643 : : {
1644 [ # # ]: 0 : sMainTerm = rRet;
1645 [ # # ]: 0 : rRet.Erase();
1646 : 0 : newline--;
1647 : : }
1648 [ # # ][ # # ]: 0 : else if ((nPart == 0) && (nVariation == 2))
1649 : 0 : newline--;
1650 [ # # ][ # # ]: 0 : else if ((nPart == 1) && (nVariation == 2))
1651 : : {
1652 [ # # ]: 0 : sMainTerm = rRet;
1653 [ # # ]: 0 : rRet.Erase();
1654 : 0 : newline--;
1655 : : }
1656 [ # # ][ # # ]: 0 : else if ((nPart == 2) || ((((nPart == 1) &&
[ # # ][ # # ]
1657 : : (nVariation == 0)) || (nVariation == 1))))
1658 : : {
1659 [ # # ]: 0 : sPush+=rRet;
1660 [ # # ]: 0 : rRet = sPush;
1661 [ # # ]: 0 : rRet += sMainTerm;
1662 : : }
1663 : 0 : nPart++;
1664 : 0 : break;
1665 : : case 0x2d:
1666 [ # # ]: 0 : if (nVariation==0)
1667 : : {
1668 [ # # ]: 0 : if (nPart == 0)
1669 : : {
1670 : 0 : newline--; //there is another term to arrive
1671 [ # # ]: 0 : APPEND(rRet," mline ");
1672 : : }
1673 : : else
1674 [ # # ]: 0 : APPEND(rRet," rangle ");
1675 : : }
1676 [ # # ]: 0 : else if (nVariation==1)
1677 [ # # ]: 0 : APPEND(rRet," \\lline ");
1678 [ # # ]: 0 : else if (nVariation==2)
1679 [ # # ]: 0 : APPEND(rRet," \\rangle ");
1680 : 0 : nPart++;
1681 : 0 : break;
1682 : : default:
1683 : 0 : break;
1684 : : }
1685 : 0 : bSilent = true; //Skip the optional brackets and/or
1686 : : //symbols that follow some of these
1687 : : //records. Foo Data.
1688 : :
1689 : : /*In matrices and piles we cannot seperate equation
1690 : : *lines with the newline keyword*/
1691 [ # # ]: 0 : if (nMatrixCols==0)
1692 : 0 : newline++;
1693 : : }
1694 : : }
1695 : 0 : break;
1696 : : case CHAR:
1697 [ # # ]: 0 : if (xfLMOVE(nTag))
1698 [ # # ]: 0 : HandleNudge();
1699 : : nRet = HandleChar(nTextStart,nSetSize,nLevel,nTag,nSelector,
1700 [ # # ]: 0 : nVariation,bSilent);
1701 : 0 : break;
1702 : : case TMPL:
1703 [ # # ]: 0 : if (xfLMOVE(nTag))
1704 [ # # ]: 0 : HandleNudge();
1705 : : nRet = HandleTemplate(nLevel,nSelector,nVariation,
1706 [ # # ]: 0 : nLastTemplateBracket);
1707 : 0 : break;
1708 : : case PILE:
1709 [ # # ]: 0 : if (xfLMOVE(nTag))
1710 [ # # ]: 0 : HandleNudge();
1711 [ # # ]: 0 : nRet = HandlePile(nSetAlign,nLevel,nSelector,nVariation);
1712 [ # # ]: 0 : HandleMatrixSeperator(nMatrixRows,nMatrixCols,nCurCol,nCurRow);
1713 : 0 : break;
1714 : : case MATRIX:
1715 [ # # ]: 0 : if (xfLMOVE(nTag))
1716 [ # # ]: 0 : HandleNudge();
1717 [ # # ]: 0 : nRet = HandleMatrix(nLevel,nSelector,nVariation);
1718 [ # # ]: 0 : HandleMatrixSeperator(nMatrixRows,nMatrixCols,nCurCol,nCurRow);
1719 : 0 : break;
1720 : : case EMBEL:
1721 [ # # ]: 0 : if (xfLMOVE(nTag))
1722 [ # # ]: 0 : HandleNudge();
1723 [ # # ]: 0 : HandleEmblishments();
1724 : 0 : break;
1725 : : case RULER:
1726 [ # # ]: 0 : *pS >> nTabStops;
1727 [ # # ]: 0 : for (i=0;i<nTabStops;i++)
1728 : : {
1729 [ # # ]: 0 : *pS >> nTabType;
1730 [ # # ]: 0 : *pS >> nTabOffset;
1731 : : }
1732 : : OSL_FAIL("Not seen in the wild Equation Ruler Field");
1733 : 0 : break;
1734 : : case FONT:
1735 : : {
1736 : 0 : MathTypeFont aFont;
1737 [ # # ]: 0 : *pS >> aFont.nTface;
1738 : : /*
1739 : : The typeface number is the negative (which makes it
1740 : : positive) of the typeface value (unbiased) that appears in
1741 : : CHAR records that might follow a given FONT record
1742 : : */
1743 : 0 : aFont.nTface = 128-aFont.nTface;
1744 [ # # ]: 0 : *pS >> aFont.nStyle;
1745 [ # # ]: 0 : aUserStyles.insert(aFont);
1746 [ # # ]: 0 : std::vector<sal_Char> aSeq;
1747 : 0 : while(1)
1748 : : {
1749 : 0 : sal_Char nChar8(0);
1750 [ # # ]: 0 : *pS >> nChar8;
1751 [ # # ]: 0 : if (nChar8 == 0)
1752 : : break;
1753 [ # # ]: 0 : aSeq.push_back(nChar8);
1754 : 0 : }
1755 : : // Do nothing to the font name now in aSeq!?
1756 : : }
1757 : 0 : break;
1758 : : case SIZE:
1759 [ # # ]: 0 : HandleSetSize();
1760 : 0 : break;
1761 : : case 10:
1762 : : case 11:
1763 : : case 12:
1764 : : case 13:
1765 : : case 14:
1766 : 0 : nLSize=nRecord-10;
1767 : 0 : break;
1768 : : case END:
1769 : : default:
1770 : 0 : break;
1771 : : }
1772 : : }
1773 : 0 : while (nRecord != END && !pS->IsEof());
1774 [ # # ]: 0 : while (nSetSize)
1775 : : {
1776 [ # # ]: 0 : rRet += '}';
1777 : 0 : nSetSize--;
1778 : : }
1779 : 0 : return nRet;
1780 : : }
1781 : :
1782 : : /*Simply determine if we are at the end of a record or the end of a line,
1783 : : *with fiddley logic to see if we are in a matrix or a pile or neither
1784 : :
1785 : : Note we cannot tell until after the event that this is the last entry
1786 : : of a pile, so we must strip the last seperator of a pile after this
1787 : : is detected in the PILE handler
1788 : : */
1789 : 0 : void MathType::HandleMatrixSeperator(int nMatrixRows,int nMatrixCols,
1790 : : int &rCurCol,int &rCurRow)
1791 : : {
1792 [ # # ]: 0 : if (nMatrixRows!=0)
1793 : : {
1794 [ # # ]: 0 : if (rCurCol == nMatrixCols-1)
1795 : : {
1796 [ # # ]: 0 : if (rCurRow != nMatrixRows-1)
1797 : 0 : APPEND(rRet," {} ##\n");
1798 [ # # ]: 0 : if (nMatrixRows!=-1)
1799 : : {
1800 : 0 : rCurCol=0;
1801 : 0 : rCurRow++;
1802 : : }
1803 : : }
1804 : : else
1805 : : {
1806 : 0 : APPEND(rRet," {} # ");
1807 [ # # ]: 0 : if (nMatrixRows!=-1)
1808 : 0 : rCurCol++;
1809 : : else
1810 : 0 : rRet += '\n';
1811 : : }
1812 : : }
1813 : 0 : }
1814 : :
1815 : : /* set the alignment of the following term, but starmath currently
1816 : : * cannot handle vertical alignment */
1817 : 0 : void MathType::HandleAlign(sal_uInt8 nHorAlign, sal_uInt8 /*nVAlign*/, int &rSetAlign)
1818 : : {
1819 [ # # # ]: 0 : switch(nHorAlign)
1820 : : {
1821 : : case 1:
1822 : : default:
1823 : 0 : APPEND(rRet,"alignl {");
1824 : 0 : break;
1825 : : case 2:
1826 : 0 : APPEND(rRet,"alignc {");
1827 : 0 : break;
1828 : : case 3:
1829 : 0 : APPEND(rRet,"alignr {");
1830 : 0 : break;
1831 : : }
1832 : 0 : rSetAlign++;
1833 : 0 : }
1834 : :
1835 : : /* set size of text, complexity due to overuse of signedness as a flag
1836 : : * indicator by mathtype file format*/
1837 : 0 : sal_Bool MathType::HandleSize(sal_Int16 nLstSize,sal_Int16 nDefSize, int &rSetSize)
1838 : : {
1839 : 0 : bool bRet=false;
1840 [ # # ]: 0 : if (nLstSize < 0)
1841 : : {
1842 [ # # ][ # # ]: 0 : if ((-nLstSize/32 != nDefaultSize) && (-nLstSize/32 != nCurSize))
1843 : : {
1844 [ # # ]: 0 : if (rSetSize)
1845 : : {
1846 : 0 : rSetSize--;
1847 : 0 : rRet += '}';
1848 : 0 : bRet=true;
1849 : : }
1850 [ # # ]: 0 : if (-nLstSize/32 != nLastSize)
1851 : : {
1852 : 0 : nLastSize = nCurSize;
1853 : 0 : APPEND(rRet," size ");
1854 [ # # ]: 0 : rRet += String::CreateFromInt32(-nLstSize/32);
1855 : 0 : rRet += '{';
1856 : 0 : bRet=true;
1857 : 0 : rSetSize++;
1858 : : }
1859 : 0 : nCurSize = -nLstSize/32;
1860 : : }
1861 : : }
1862 : : else
1863 : : {
1864 : : /*sizetable should theoreticaly be filled with the default sizes
1865 : : *of the various font groupings matching starmaths equivalents
1866 : : in aTypeFaces, and a test would be done to see if the new font
1867 : : size would be the same as what starmath would have chosen for
1868 : : itself anyway in which case the size setting could be ignored*/
1869 : 0 : nLstSize = aSizeTable[nLstSize];
1870 : 0 : nLstSize = nLstSize + nDefSize;
1871 [ # # ]: 0 : if (nLstSize != nCurSize)
1872 : : {
1873 [ # # ]: 0 : if (rSetSize)
1874 : : {
1875 : 0 : rSetSize--;
1876 : 0 : rRet += '}';
1877 : 0 : bRet=true;
1878 : : }
1879 [ # # ]: 0 : if (nLstSize != nLastSize)
1880 : : {
1881 : 0 : nLastSize = nCurSize;
1882 : 0 : APPEND(rRet," size ");
1883 [ # # ]: 0 : rRet += String::CreateFromInt32(nLstSize);
1884 : 0 : rRet += '{';
1885 : 0 : bRet=true;
1886 : 0 : rSetSize++;
1887 : : }
1888 : 0 : nCurSize = nLstSize;
1889 : : }
1890 : : }
1891 : 0 : return bRet;
1892 : : }
1893 : :
1894 : 0 : int MathType::ConvertFromStarMath( SfxMedium& rMedium )
1895 : : {
1896 [ # # ]: 0 : if (!pTree)
1897 : 0 : return 0;
1898 : :
1899 : 0 : SvStream *pStream = rMedium.GetOutStream();
1900 [ # # ]: 0 : if ( pStream )
1901 : : {
1902 [ # # ][ # # ]: 0 : SvStorageRef pStor = new SotStorage( pStream, false );
1903 : :
1904 : : SvGlobalName aGName(0x0002ce02L, 0x0000, 0x0000,0xc0,0x00,
1905 [ # # ]: 0 : 0x00,0x00,0x00,0x00,0x00,0x46 );
1906 [ # # ][ # # ]: 0 : pStor->SetClass( aGName, 0, rtl::OUString("Microsoft Equation 3.0"));
[ # # ]
1907 : :
1908 : : static sal_uInt8 const aCompObj[] = {
1909 : : 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1910 : : 0xFF, 0xFF, 0xFF, 0xFF, 0x02, 0xCE, 0x02, 0x00,
1911 : : 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00,
1912 : : 0x00, 0x00, 0x00, 0x46, 0x17, 0x00, 0x00, 0x00,
1913 : : 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1914 : : 0x74, 0x20, 0x45, 0x71, 0x75, 0x61, 0x74, 0x69,
1915 : : 0x6F, 0x6E, 0x20, 0x33, 0x2E, 0x30, 0x00, 0x0C,
1916 : : 0x00, 0x00, 0x00, 0x44, 0x53, 0x20, 0x45, 0x71,
1917 : : 0x75, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x00, 0x0B,
1918 : : 0x00, 0x00, 0x00, 0x45, 0x71, 0x75, 0x61, 0x74,
1919 : : 0x69, 0x6F, 0x6E, 0x2E, 0x33, 0x00, 0xF4, 0x39,
1920 : : 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1921 : : 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1922 : : };
1923 [ # # ][ # # ]: 0 : SvStorageStreamRef xStor( pStor->OpenSotStream(rtl::OUString("\1CompObj")));
[ # # ]
1924 [ # # ]: 0 : xStor->Write(aCompObj,sizeof(aCompObj));
1925 : :
1926 : : static sal_uInt8 const aOle[] = {
1927 : : 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
1928 : : 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1929 : : 0x00, 0x00, 0x00, 0x00
1930 : : };
1931 [ # # ][ # # ]: 0 : SvStorageStreamRef xStor2( pStor->OpenSotStream(rtl::OUString("\1Ole")));
[ # # ]
1932 [ # # ]: 0 : xStor2->Write(aOle,sizeof(aOle));
1933 [ # # ]: 0 : xStor.Clear();
1934 [ # # ]: 0 : xStor2.Clear();
1935 : :
1936 [ # # ][ # # ]: 0 : SvStorageStreamRef xSrc = pStor->OpenSotStream(rtl::OUString("Equation Native"));
[ # # ]
1937 [ # # ][ # # ]: 0 : if ( (!xSrc.Is()) || (SVSTREAM_OK != xSrc->GetError()))
[ # # ]
1938 : 0 : return 0;
1939 : :
1940 : 0 : pS = &xSrc;
1941 [ # # ]: 0 : pS->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
1942 : :
1943 [ # # ]: 0 : pS->SeekRel(EQNOLEFILEHDR_SIZE); //Skip 28byte Header and fill it in later
1944 [ # # ]: 0 : *pS << sal_uInt8(0x03);
1945 [ # # ]: 0 : *pS << sal_uInt8(0x01);
1946 [ # # ]: 0 : *pS << sal_uInt8(0x01);
1947 [ # # ]: 0 : *pS << sal_uInt8(0x03);
1948 [ # # ]: 0 : *pS << sal_uInt8(0x00);
1949 : 0 : sal_uInt32 nSize = pS->Tell();
1950 : 0 : nPendingAttributes=0;
1951 : :
1952 [ # # ]: 0 : HandleNodes(pTree);
1953 [ # # ]: 0 : *pS << sal_uInt8(END);
1954 : :
1955 : 0 : nSize = pS->Tell()-nSize;
1956 [ # # ]: 0 : pS->Seek(0);
1957 : 0 : EQNOLEFILEHDR aHdr(nSize+4+1);
1958 [ # # ]: 0 : aHdr.Write(pS);
1959 : :
1960 [ # # ][ # # ]: 0 : pStor->Commit();
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
1961 : : }
1962 : :
1963 : 0 : return 1;
1964 : : }
1965 : :
1966 : :
1967 : 0 : sal_uInt8 MathType::HandleNodes(SmNode *pNode,int nLevel)
1968 : : {
1969 : 0 : bool bRet=false;
1970 [ # # # # : 0 : switch(pNode->GetType())
# # # # #
# # # # #
# # # ]
1971 : : {
1972 : : case NATTRIBUT:
1973 : 0 : HandleAttributes(pNode,nLevel);
1974 : 0 : break;
1975 : : case NTEXT:
1976 : 0 : HandleText(pNode,nLevel);
1977 : 0 : break;
1978 : : case NVERTICAL_BRACE:
1979 : 0 : HandleVerticalBrace(pNode,nLevel);
1980 : 0 : break;
1981 : : case NBRACE:
1982 : 0 : HandleBrace(pNode,nLevel);
1983 : 0 : break;
1984 : : case NOPER:
1985 : 0 : HandleOperator(pNode,nLevel);
1986 : 0 : break;
1987 : : case NBINVER:
1988 : 0 : HandleFractions(pNode,nLevel);
1989 : 0 : break;
1990 : : case NROOT:
1991 : 0 : HandleRoot(pNode,nLevel);
1992 : 0 : break;
1993 : : case NSPECIAL:
1994 : : {
1995 : 0 : SmTextNode *pText=(SmTextNode *)pNode;
1996 : : //if the token str and the result text are the same then this
1997 : : //is to be seen as text, else assume its a mathchar
1998 [ # # ]: 0 : if (pText->GetText() == pText->GetToken().aText)
1999 : 0 : HandleText(pText,nLevel);
2000 : : else
2001 : 0 : HandleMath(pText,nLevel);
2002 : : }
2003 : 0 : break;
2004 : : case NMATH:
2005 : 0 : HandleMath(pNode,nLevel);
2006 : 0 : break;
2007 : : case NSUBSUP:
2008 : 0 : HandleSubSupScript(pNode,nLevel);
2009 : 0 : break;
2010 : : case NEXPRESSION:
2011 : : {
2012 : 0 : sal_uInt16 nSize = pNode->GetNumSubNodes();
2013 [ # # ]: 0 : for (sal_uInt16 i = 0; i < nSize; i++)
2014 [ # # ]: 0 : if (SmNode *pTemp = pNode->GetSubNode(i))
2015 : 0 : HandleNodes(pTemp,nLevel+1);
2016 : : }
2017 : 0 : break;
2018 : : case NTABLE:
2019 : : //Root Node, PILE equivalent, i.e. vertical stack
2020 : 0 : HandleTable(pNode,nLevel);
2021 : 0 : break;
2022 : : case NMATRIX:
2023 : 0 : HandleSmMatrix((SmMatrixNode *)pNode,nLevel);
2024 : 0 : break;
2025 : : case NLINE:
2026 : : {
2027 : 0 : *pS << sal_uInt8(0x0a);
2028 : 0 : *pS << sal_uInt8(LINE);
2029 : 0 : sal_uInt16 nSize = pNode->GetNumSubNodes();
2030 [ # # ]: 0 : for (sal_uInt16 i = 0; i < nSize; i++)
2031 [ # # ]: 0 : if (SmNode *pTemp = pNode->GetSubNode(i))
2032 : 0 : HandleNodes(pTemp,nLevel+1);
2033 : 0 : *pS << sal_uInt8(END);
2034 : : }
2035 : 0 : break;
2036 : : case NALIGN:
2037 : 0 : HandleMAlign(pNode,nLevel);
2038 : 0 : break;
2039 : : case NBLANK:
2040 : 0 : *pS << sal_uInt8(CHAR);
2041 : 0 : *pS << sal_uInt8(0x98);
2042 [ # # ]: 0 : if (pNode->GetToken().eType == TSBLANK)
2043 : 0 : *pS << sal_uInt16(0xEB04);
2044 : : else
2045 : 0 : *pS << sal_uInt16(0xEB05);
2046 : 0 : break;
2047 : : default:
2048 : : {
2049 : 0 : sal_uInt16 nSize = pNode->GetNumSubNodes();
2050 [ # # ]: 0 : for (sal_uInt16 i = 0; i < nSize; i++)
2051 [ # # ]: 0 : if (SmNode *pTemp = pNode->GetSubNode(i))
2052 : 0 : HandleNodes(pTemp,nLevel+1);
2053 : : }
2054 : 0 : break;
2055 : : }
2056 : 0 : return bRet;
2057 : : }
2058 : :
2059 : :
2060 : 0 : int MathType::StartTemplate(sal_uInt16 nSelector,sal_uInt16 nVariation)
2061 : : {
2062 : 0 : int nOldPending=nPendingAttributes;
2063 : 0 : *pS << sal_uInt8(TMPL); //Template
2064 : 0 : *pS << sal_uInt8(nSelector); //selector
2065 : 0 : *pS << sal_uInt8(nVariation); //variation
2066 : 0 : *pS << sal_uInt8(0x00); //options
2067 : 0 : *pS << sal_uInt8(LINE);
2068 : : //theres just no way we can now handle any character
2069 : : //attributes (from mathtypes perspective) centered
2070 : : //over an expression but above template attribute
2071 : : //such as widevec and similiar constructs
2072 : : //we have to drop them
2073 : 0 : nPendingAttributes=0;
2074 : 0 : return nOldPending;
2075 : : }
2076 : :
2077 : 0 : void MathType::EndTemplate(int nOldPendingAttributes)
2078 : : {
2079 : 0 : *pS << sal_uInt8(END); //end line
2080 : 0 : *pS << sal_uInt8(END); //end template
2081 : 0 : nPendingAttributes=nOldPendingAttributes;
2082 : 0 : }
2083 : :
2084 : :
2085 : 0 : void MathType::HandleSmMatrix(SmMatrixNode *pMatrix,int nLevel)
2086 : : {
2087 : 0 : *pS << sal_uInt8(MATRIX);
2088 : 0 : *pS << sal_uInt8(0x00); //vAlign ?
2089 : 0 : *pS << sal_uInt8(0x00); //h_just
2090 : 0 : *pS << sal_uInt8(0x00); //v_just
2091 : 0 : *pS << sal_uInt8(pMatrix->GetNumRows()); //v_just
2092 : 0 : *pS << sal_uInt8(pMatrix->GetNumCols()); //v_just
2093 : 0 : int nBytes=(pMatrix->GetNumRows()+1)*2/8;
2094 [ # # ]: 0 : if (((pMatrix->GetNumRows()+1)*2)%8)
2095 : 0 : nBytes++;
2096 [ # # ]: 0 : for (sal_uInt16 j = 0; j < nBytes; j++)
2097 : 0 : *pS << sal_uInt8(0x00); //row_parts
2098 : 0 : nBytes=(pMatrix->GetNumCols()+1)*2/8;
2099 [ # # ]: 0 : if (((pMatrix->GetNumCols()+1)*2)%8)
2100 : 0 : nBytes++;
2101 [ # # ]: 0 : for (sal_uInt16 k = 0; k < nBytes; k++)
2102 : 0 : *pS << sal_uInt8(0x00); //col_parts
2103 : 0 : sal_uInt16 nSize = pMatrix->GetNumSubNodes();
2104 [ # # ]: 0 : for (sal_uInt16 i = 0; i < nSize; i++)
2105 [ # # ]: 0 : if (SmNode *pTemp = pMatrix->GetSubNode(i))
2106 : : {
2107 : 0 : *pS << sal_uInt8(LINE); //line
2108 : 0 : HandleNodes(pTemp,nLevel+1);
2109 : 0 : *pS << sal_uInt8(END); //end line
2110 : : }
2111 : 0 : *pS << sal_uInt8(END);
2112 : 0 : }
2113 : :
2114 : :
2115 : : //Root Node, PILE equivalent, i.e. vertical stack
2116 : 0 : void MathType::HandleTable(SmNode *pNode,int nLevel)
2117 : : {
2118 : 0 : sal_uInt16 nSize = pNode->GetNumSubNodes();
2119 : : //The root of the starmath is a table, if
2120 : : //we convert this them each iteration of
2121 : : //conversion from starmath to mathtype will
2122 : : //add an extra unnecessary level to the
2123 : : //mathtype output stack which would grow
2124 : : //without bound in a multi step conversion
2125 : :
2126 [ # # ]: 0 : if (nLevel == 0)
2127 : 0 : *pS << sal_uInt8(0x0A); //initial size
2128 : :
2129 [ # # ][ # # ]: 0 : if ( nLevel || (nSize >1))
2130 : : {
2131 : 0 : *pS << sal_uInt8(PILE);
2132 : 0 : *pS << sal_uInt8(nHAlign); //vAlign ?
2133 : 0 : *pS << sal_uInt8(0x01); //hAlign
2134 : : }
2135 : :
2136 [ # # ]: 0 : for (sal_uInt16 i = 0; i < nSize; i++)
2137 [ # # ]: 0 : if (SmNode *pTemp = pNode->GetSubNode(i))
2138 : : {
2139 : 0 : *pS << sal_uInt8(LINE);
2140 : 0 : HandleNodes(pTemp,nLevel+1);
2141 : 0 : *pS << sal_uInt8(END);
2142 : : }
2143 [ # # ][ # # ]: 0 : if (nLevel || (nSize>1))
2144 : 0 : *pS << sal_uInt8(END);
2145 : 0 : }
2146 : :
2147 : :
2148 : 0 : void MathType::HandleRoot(SmNode *pNode,int nLevel)
2149 : : {
2150 : : SmNode *pTemp;
2151 : 0 : *pS << sal_uInt8(TMPL); //Template
2152 : 0 : *pS << sal_uInt8(0x0D); //selector
2153 [ # # ]: 0 : if (pNode->GetSubNode(0))
2154 : 0 : *pS << sal_uInt8(0x01); //variation
2155 : : else
2156 : 0 : *pS << sal_uInt8(0x00); //variation
2157 : 0 : *pS << sal_uInt8(0x00); //options
2158 : :
2159 [ # # ]: 0 : if (NULL != (pTemp = pNode->GetSubNode(2)))
2160 : : {
2161 : 0 : *pS << sal_uInt8(LINE); //line
2162 : 0 : HandleNodes(pTemp,nLevel+1);
2163 : 0 : *pS << sal_uInt8(END);
2164 : : }
2165 : :
2166 [ # # ]: 0 : if (NULL != (pTemp = pNode->GetSubNode(0)))
2167 : : {
2168 : 0 : *pS << sal_uInt8(LINE); //line
2169 : 0 : HandleNodes(pTemp,nLevel+1);
2170 : 0 : *pS << sal_uInt8(END);
2171 : : }
2172 : : else
2173 : 0 : *pS << sal_uInt8(LINE|0x10); //dummy line
2174 : :
2175 : :
2176 : :
2177 : 0 : *pS << sal_uInt8(END);
2178 : 0 : }
2179 : :
2180 : 0 : sal_uInt8 MathType::HandleCScript(SmNode *pNode,SmNode *pContent,int nLevel,
2181 : : sal_uLong *pPos,sal_Bool bTest)
2182 : : {
2183 : 0 : sal_uInt8 nVariation2=0xff;
2184 : :
2185 [ # # ][ # # ]: 0 : if (bTest && pNode->GetSubNode(CSUP+1))
[ # # ]
2186 : : {
2187 : 0 : nVariation2=0;
2188 [ # # ]: 0 : if (pNode->GetSubNode(CSUB+1))
2189 : 0 : nVariation2=2;
2190 : : }
2191 [ # # ]: 0 : else if (pNode->GetSubNode(CSUB+1))
2192 : 0 : nVariation2=1;
2193 : :
2194 [ # # ]: 0 : if (nVariation2!=0xff)
2195 : : {
2196 [ # # ]: 0 : if (pPos)
2197 : 0 : *pPos = pS->Tell();
2198 : 0 : *pS << sal_uInt8(TMPL); //Template
2199 : 0 : *pS << sal_uInt8(0x2B); //selector
2200 : 0 : *pS << nVariation2;
2201 : 0 : *pS << sal_uInt8(0x00); //options
2202 : :
2203 [ # # ]: 0 : if (pContent)
2204 : : {
2205 : 0 : *pS << sal_uInt8(LINE); //line
2206 : 0 : HandleNodes(pContent,nLevel+1);
2207 : 0 : *pS << sal_uInt8(END); //line
2208 : : }
2209 : : else
2210 : 0 : *pS << sal_uInt8(LINE|0x10);
2211 : :
2212 : 0 : *pS << sal_uInt8(0x0B);
2213 : :
2214 : : SmNode *pTemp;
2215 [ # # ]: 0 : if (NULL != (pTemp = pNode->GetSubNode(CSUB+1)))
2216 : : {
2217 : 0 : *pS << sal_uInt8(LINE); //line
2218 : 0 : HandleNodes(pTemp,nLevel+1);
2219 : 0 : *pS << sal_uInt8(END); //line
2220 : : }
2221 : : else
2222 : 0 : *pS << sal_uInt8(LINE|0x10);
2223 [ # # ][ # # ]: 0 : if (bTest && NULL != (pTemp = pNode->GetSubNode(CSUP+1)))
[ # # ]
2224 : : {
2225 : 0 : *pS << sal_uInt8(LINE); //line
2226 : 0 : HandleNodes(pTemp,nLevel+1);
2227 : 0 : *pS << sal_uInt8(END); //line
2228 : : }
2229 : : else
2230 : 0 : *pS << sal_uInt8(LINE|0x10);
2231 : : }
2232 : 0 : return nVariation2;
2233 : : }
2234 : :
2235 : :
2236 : :
2237 : : /*
2238 : : Sub and Sup scripts and another problem area, StarMath
2239 : : can have all possible options used at the same time, whereas
2240 : : Mathtype cannot. The ordering of the nodes for each system
2241 : : is quite different as well leading to some complexity
2242 : : */
2243 : 0 : void MathType::HandleSubSupScript(SmNode *pNode,int nLevel)
2244 : : {
2245 : : SmNode *pTemp;
2246 : :
2247 : 0 : sal_uInt8 nVariation=0xff;
2248 [ # # ]: 0 : if (pNode->GetSubNode(LSUP+1))
2249 : : {
2250 : 0 : nVariation=0;
2251 [ # # ]: 0 : if (pNode->GetSubNode(LSUB+1))
2252 : 0 : nVariation=2;
2253 : : }
2254 [ # # ]: 0 : else if (NULL != (pTemp = pNode->GetSubNode(LSUB+1)))
2255 : 0 : nVariation=1;
2256 : :
2257 [ # # ]: 0 : if (nVariation!=0xff)
2258 : : {
2259 : 0 : *pS << sal_uInt8(TMPL); //Template
2260 : 0 : *pS << sal_uInt8(0x2c); //selector
2261 : 0 : *pS << nVariation;
2262 : 0 : *pS << sal_uInt8(0x00); //options
2263 : 0 : *pS << sal_uInt8(0x0B);
2264 : :
2265 [ # # ]: 0 : if (NULL != (pTemp = pNode->GetSubNode(LSUB+1)))
2266 : : {
2267 : 0 : *pS << sal_uInt8(LINE); //line
2268 : 0 : HandleNodes(pTemp,nLevel+1);
2269 : 0 : *pS << sal_uInt8(END); //line
2270 : : }
2271 : : else
2272 : 0 : *pS << sal_uInt8(LINE|0x10);
2273 [ # # ]: 0 : if (NULL != (pTemp = pNode->GetSubNode(LSUP+1)))
2274 : : {
2275 : 0 : *pS << sal_uInt8(LINE); //line
2276 : 0 : HandleNodes(pTemp,nLevel+1);
2277 : 0 : *pS << sal_uInt8(END); //line
2278 : : }
2279 : : else
2280 : 0 : *pS << sal_uInt8(LINE|0x10);
2281 : 0 : *pS << sal_uInt8(END);
2282 : 0 : nVariation=0xff;
2283 : : }
2284 : :
2285 : :
2286 : 0 : sal_uInt8 nVariation2=HandleCScript(pNode,NULL,nLevel);
2287 : :
2288 [ # # ]: 0 : if (NULL != (pTemp = pNode->GetSubNode(0)))
2289 : : {
2290 : 0 : HandleNodes(pTemp,nLevel+1);
2291 : : }
2292 : :
2293 [ # # ]: 0 : if (nVariation2 != 0xff)
2294 : 0 : *pS << sal_uInt8(END);
2295 : :
2296 [ # # ]: 0 : if (NULL != (pNode->GetSubNode(RSUP+1)))
2297 : : {
2298 : 0 : nVariation=0;
2299 [ # # ]: 0 : if (pNode->GetSubNode(RSUB+1))
2300 : 0 : nVariation=2;
2301 : : }
2302 [ # # ]: 0 : else if (NULL != (pTemp = pNode->GetSubNode(RSUB+1)))
2303 : 0 : nVariation=1;
2304 : :
2305 [ # # ]: 0 : if (nVariation!=0xff)
2306 : : {
2307 : 0 : *pS << sal_uInt8(TMPL); //Template
2308 : 0 : *pS << sal_uInt8(0x0F); //selector
2309 : 0 : *pS << nVariation;
2310 : 0 : *pS << sal_uInt8(0x00); //options
2311 : 0 : *pS << sal_uInt8(0x0B);
2312 : :
2313 [ # # ]: 0 : if (NULL != (pTemp = pNode->GetSubNode(RSUB+1)))
2314 : : {
2315 : 0 : *pS << sal_uInt8(LINE); //line
2316 : 0 : HandleNodes(pTemp,nLevel+1);
2317 : 0 : *pS << sal_uInt8(END); //line
2318 : : }
2319 : : else
2320 : 0 : *pS << sal_uInt8(LINE|0x10);
2321 [ # # ]: 0 : if (NULL != (pTemp = pNode->GetSubNode(RSUP+1)))
2322 : : {
2323 : 0 : *pS << sal_uInt8(LINE); //line
2324 : 0 : HandleNodes(pTemp,nLevel+1);
2325 : 0 : *pS << sal_uInt8(END); //line
2326 : : }
2327 : : else
2328 : 0 : *pS << sal_uInt8(LINE|0x10);
2329 : 0 : *pS << sal_uInt8(END); //line
2330 : : }
2331 : :
2332 : : //After subscript mathtype will keep the size of
2333 : : //normal text at the subscript size, sigh.
2334 : 0 : *pS << sal_uInt8(0x0A);
2335 : 0 : }
2336 : :
2337 : :
2338 : 0 : void MathType::HandleFractions(SmNode *pNode,int nLevel)
2339 : : {
2340 : : SmNode *pTemp;
2341 : 0 : *pS << sal_uInt8(TMPL); //Template
2342 : 0 : *pS << sal_uInt8(0x0E); //selector
2343 : 0 : *pS << sal_uInt8(0x00); //variation
2344 : 0 : *pS << sal_uInt8(0x00); //options
2345 : :
2346 : 0 : *pS << sal_uInt8(0x0A);
2347 : 0 : *pS << sal_uInt8(LINE); //line
2348 [ # # ]: 0 : if (NULL != (pTemp = pNode->GetSubNode(0)))
2349 : 0 : HandleNodes(pTemp,nLevel+1);
2350 : 0 : *pS << sal_uInt8(END);
2351 : :
2352 : 0 : *pS << sal_uInt8(0x0A);
2353 : 0 : *pS << sal_uInt8(LINE); //line
2354 [ # # ]: 0 : if (NULL != (pTemp = pNode->GetSubNode(2)))
2355 : 0 : HandleNodes(pTemp,nLevel+1);
2356 : 0 : *pS << sal_uInt8(END);
2357 : :
2358 : 0 : *pS << sal_uInt8(END);
2359 : 0 : }
2360 : :
2361 : :
2362 : 0 : void MathType::HandleBrace(SmNode *pNode,int nLevel)
2363 : : {
2364 : : SmNode *pTemp;
2365 : 0 : SmNode *pLeft=pNode->GetSubNode(0);
2366 : 0 : SmNode *pRight=pNode->GetSubNode(2);
2367 : :
2368 : 0 : *pS << sal_uInt8(TMPL); //Template
2369 : 0 : bIsReInterpBrace=0;
2370 : 0 : sal_uInt8 nBSpec=0x10;
2371 : 0 : sal_uLong nLoc = pS->Tell();
2372 [ # # ]: 0 : if (pLeft)
2373 : : {
2374 [ # # # # : 0 : switch (pLeft->GetToken().eType)
# # # ]
2375 : : {
2376 : : case TLANGLE:
2377 : 0 : *pS << sal_uInt8(tmANGLE); //selector
2378 : 0 : *pS << sal_uInt8(0x00); //variation
2379 : 0 : *pS << sal_uInt8(0x00); //options
2380 : 0 : break;
2381 : : case TLBRACE:
2382 : 0 : *pS << sal_uInt8(tmBRACE); //selector
2383 : 0 : *pS << sal_uInt8(0x00); //variation
2384 : 0 : *pS << sal_uInt8(0x00); //options
2385 : 0 : nBSpec+=3;
2386 : 0 : break;
2387 : : case TLBRACKET:
2388 : 0 : *pS << sal_uInt8(tmBRACK); //selector
2389 : 0 : *pS << sal_uInt8(0x00); //variation
2390 : 0 : *pS << sal_uInt8(0x00); //options
2391 : 0 : nBSpec+=3;
2392 : 0 : break;
2393 : : case TLFLOOR:
2394 : 0 : *pS << sal_uInt8(tmFLOOR); //selector
2395 : 0 : *pS << sal_uInt8(0x00); //variation
2396 : 0 : *pS << sal_uInt8(0x00); //options
2397 : 0 : break;
2398 : : case TLLINE:
2399 : 0 : *pS << sal_uInt8(tmBAR); //selector
2400 : 0 : *pS << sal_uInt8(0x00); //variation
2401 : 0 : *pS << sal_uInt8(0x00); //options
2402 : 0 : nBSpec+=3;
2403 : 0 : break;
2404 : : case TLDLINE:
2405 : 0 : *pS << sal_uInt8(tmDBAR); //selector
2406 : 0 : *pS << sal_uInt8(0x00); //variation
2407 : 0 : *pS << sal_uInt8(0x00); //options
2408 : 0 : break;
2409 : : default:
2410 : 0 : *pS << sal_uInt8(tmPAREN); //selector
2411 : 0 : *pS << sal_uInt8(0x00); //variation
2412 : 0 : *pS << sal_uInt8(0x00); //options
2413 : 0 : nBSpec+=3;
2414 : 0 : break;
2415 : : }
2416 : : }
2417 : :
2418 [ # # ]: 0 : if (NULL != (pTemp = pNode->GetSubNode(1)))
2419 : : {
2420 : 0 : *pS << sal_uInt8(LINE); //line
2421 : 0 : HandleNodes(pTemp,nLevel+1);
2422 : 0 : *pS << sal_uInt8(END); //options
2423 : : }
2424 : 0 : nSpec=nBSpec;
2425 [ # # ]: 0 : if (pLeft)
2426 : 0 : HandleNodes(pLeft,nLevel+1);
2427 [ # # ]: 0 : if (bIsReInterpBrace)
2428 : : {
2429 : 0 : sal_uLong nLoc2 = pS->Tell();
2430 : 0 : pS->Seek(nLoc);
2431 : 0 : *pS << sal_uInt8(0x2D);
2432 : 0 : pS->Seek(nLoc2);
2433 : 0 : *pS << sal_uInt8(CHAR);
2434 : 0 : *pS << sal_uInt8(0x96);
2435 : 0 : *pS << sal_uInt16(0xEC07);
2436 : 0 : bIsReInterpBrace=0;
2437 : : }
2438 [ # # ]: 0 : if (pRight)
2439 : 0 : HandleNodes(pRight,nLevel+1);
2440 : 0 : nSpec=0x0;
2441 : 0 : *pS << sal_uInt8(END);
2442 : 0 : }
2443 : :
2444 : :
2445 : 0 : void MathType::HandleVerticalBrace(SmNode *pNode,int nLevel)
2446 : : {
2447 : : SmNode *pTemp;
2448 : 0 : *pS << sal_uInt8(TMPL); //Template
2449 [ # # ]: 0 : if (pNode->GetToken().eType == TUNDERBRACE)
2450 : 0 : *pS << sal_uInt8(tmLHBRACE); //selector
2451 : : else
2452 : 0 : *pS << sal_uInt8(tmUHBRACE); //selector
2453 : 0 : *pS << sal_uInt8(0x01); //variation
2454 : 0 : *pS << sal_uInt8(0x00); //options
2455 : :
2456 [ # # ]: 0 : if (NULL != (pTemp = pNode->GetSubNode(0)))
2457 : : {
2458 : 0 : *pS << sal_uInt8(LINE); //line
2459 : 0 : HandleNodes(pTemp,nLevel+1);
2460 : 0 : *pS << sal_uInt8(END); //options
2461 : : }
2462 : :
2463 [ # # ]: 0 : if (NULL != (pTemp = pNode->GetSubNode(2)))
2464 : : {
2465 : 0 : *pS << sal_uInt8(LINE); //line
2466 : 0 : HandleNodes(pTemp,nLevel+1);
2467 : 0 : *pS << sal_uInt8(END); //options
2468 : : }
2469 : 0 : *pS << sal_uInt8(END);
2470 : 0 : }
2471 : :
2472 : 0 : void MathType::HandleOperator(SmNode *pNode,int nLevel)
2473 : : {
2474 [ # # ][ # # ]: 0 : if (HandleLim(pNode,nLevel))
2475 : 0 : return;
2476 : :
2477 : : sal_uLong nPos;
2478 : : sal_uInt8 nVariation;
2479 : :
2480 [ # # ]: 0 : switch (pNode->GetToken().eType)
2481 : : {
2482 : : case TIINT:
2483 : : case TIIINT:
2484 : : case TLINT:
2485 : : case TLLINT:
2486 : : case TLLLINT:
2487 : 0 : nVariation=HandleCScript(pNode->GetSubNode(0),
2488 [ # # ][ # # ]: 0 : pNode->GetSubNode(1),nLevel,&nPos,0);
[ # # ]
2489 : 0 : break;
2490 : : default:
2491 : 0 : nVariation=HandleCScript(pNode->GetSubNode(0),
2492 [ # # ][ # # ]: 0 : pNode->GetSubNode(1),nLevel,&nPos);
[ # # ]
2493 : 0 : break;
2494 : : }
2495 : :
2496 : 0 : sal_uInt8 nOldVariation=nVariation;
2497 : 0 : sal_uInt8 nIntVariation=nVariation;
2498 : :
2499 : 0 : sal_uLong nPos2=0;
2500 [ # # ]: 0 : if (nVariation != 0xff)
2501 : : {
2502 : 0 : nPos2 = pS->Tell();
2503 [ # # ]: 0 : pS->Seek(nPos);
2504 [ # # ]: 0 : if (nVariation == 2)
2505 : : {
2506 : 0 : nIntVariation=0;
2507 : 0 : nVariation = 1;
2508 : : }
2509 [ # # ]: 0 : else if (nVariation == 0)
2510 : 0 : nVariation = 1;
2511 [ # # ]: 0 : else if (nVariation == 1)
2512 : 0 : nVariation = 0;
2513 : : }
2514 : : else
2515 : : {
2516 : 0 : nVariation = 2;
2517 : 0 : nIntVariation=0;
2518 : : }
2519 [ # # ]: 0 : *pS << sal_uInt8(TMPL);
2520 [ # # # # : 0 : switch(pNode->GetToken().eType)
# # # #
# ]
2521 : : {
2522 : : case TINT:
2523 [ # # ]: 0 : if (nOldVariation != 0xff)
2524 [ # # ]: 0 : *pS << sal_uInt8(0x18); //selector
2525 : : else
2526 [ # # ]: 0 : *pS << sal_uInt8(0x15); //selector
2527 [ # # ]: 0 : *pS << nIntVariation; //variation
2528 : 0 : break;
2529 : : case TIINT:
2530 [ # # ]: 0 : if (nOldVariation != 0xff)
2531 : : {
2532 [ # # ]: 0 : *pS << sal_uInt8(0x19);
2533 [ # # ]: 0 : *pS << sal_uInt8(0x01);
2534 : : }
2535 : : else
2536 : : {
2537 [ # # ]: 0 : *pS << sal_uInt8(0x16);
2538 [ # # ]: 0 : *pS << sal_uInt8(0x00);
2539 : : }
2540 : 0 : break;
2541 : : case TIIINT:
2542 [ # # ]: 0 : if (nOldVariation != 0xff)
2543 : : {
2544 [ # # ]: 0 : *pS << sal_uInt8(0x1a);
2545 [ # # ]: 0 : *pS << sal_uInt8(0x01);
2546 : : }
2547 : : else
2548 : : {
2549 [ # # ]: 0 : *pS << sal_uInt8(0x17);
2550 [ # # ]: 0 : *pS << sal_uInt8(0x00);
2551 : : }
2552 : 0 : break;
2553 : : case TLINT:
2554 [ # # ]: 0 : if (nOldVariation != 0xff)
2555 : : {
2556 [ # # ]: 0 : *pS << sal_uInt8(0x18);
2557 [ # # ]: 0 : *pS << sal_uInt8(0x02);
2558 : : }
2559 : : else
2560 : : {
2561 [ # # ]: 0 : *pS << sal_uInt8(0x15);
2562 [ # # ]: 0 : *pS << sal_uInt8(0x03);
2563 : : }
2564 : 0 : break;
2565 : : case TLLINT:
2566 [ # # ]: 0 : if (nOldVariation != 0xff)
2567 : : {
2568 [ # # ]: 0 : *pS << sal_uInt8(0x19);
2569 [ # # ]: 0 : *pS << sal_uInt8(0x00);
2570 : : }
2571 : : else
2572 : : {
2573 [ # # ]: 0 : *pS << sal_uInt8(0x16);
2574 [ # # ]: 0 : *pS << sal_uInt8(0x02);
2575 : : }
2576 : 0 : break;
2577 : : case TLLLINT:
2578 [ # # ]: 0 : if (nOldVariation != 0xff)
2579 : : {
2580 [ # # ]: 0 : *pS << sal_uInt8(0x1a);
2581 [ # # ]: 0 : *pS << sal_uInt8(0x00);
2582 : : }
2583 : : else
2584 : : {
2585 [ # # ]: 0 : *pS << sal_uInt8(0x17);
2586 [ # # ]: 0 : *pS << sal_uInt8(0x02);
2587 : : }
2588 : 0 : break;
2589 : : case TSUM:
2590 : : default:
2591 [ # # ]: 0 : *pS << sal_uInt8(0x1d);
2592 [ # # ]: 0 : *pS << nVariation;
2593 : 0 : break;
2594 : : case TPROD:
2595 [ # # ]: 0 : *pS << sal_uInt8(0x1f);
2596 [ # # ]: 0 : *pS << nVariation;
2597 : 0 : break;
2598 : : case TCOPROD:
2599 [ # # ]: 0 : *pS << sal_uInt8(0x21);
2600 [ # # ]: 0 : *pS << nVariation;
2601 : 0 : break;
2602 : : }
2603 [ # # ]: 0 : *pS << sal_uInt8(0x00); //options
2604 : :
2605 [ # # ]: 0 : if (nPos2)
2606 [ # # ]: 0 : pS->Seek(nPos2);
2607 : : else
2608 : : {
2609 [ # # ]: 0 : *pS << sal_uInt8(LINE); //line
2610 [ # # ][ # # ]: 0 : HandleNodes(pNode->GetSubNode(1),nLevel+1);
2611 [ # # ]: 0 : *pS << sal_uInt8(END); //line
2612 [ # # ]: 0 : *pS << sal_uInt8(LINE|0x10);
2613 [ # # ]: 0 : *pS << sal_uInt8(LINE|0x10);
2614 : : }
2615 : :
2616 : :
2617 [ # # ]: 0 : *pS << sal_uInt8(0x0D);
2618 [ # # # # : 0 : switch(pNode->GetToken().eType)
# # ]
2619 : : {
2620 : : case TSUM:
2621 : : default:
2622 [ # # ]: 0 : *pS << sal_uInt8(CHAR);
2623 [ # # ]: 0 : *pS << sal_uInt8(0x86);
2624 [ # # ]: 0 : *pS << sal_uInt16(0x2211);
2625 : 0 : break;
2626 : : case TPROD:
2627 [ # # ]: 0 : *pS << sal_uInt8(CHAR);
2628 [ # # ]: 0 : *pS << sal_uInt8(0x86);
2629 [ # # ]: 0 : *pS << sal_uInt16(0x220F);
2630 : 0 : break;
2631 : : case TCOPROD:
2632 [ # # ]: 0 : *pS << sal_uInt8(CHAR);
2633 [ # # ]: 0 : *pS << sal_uInt8(0x8B);
2634 [ # # ]: 0 : *pS << sal_uInt16(0x2210);
2635 : 0 : break;
2636 : : case TIIINT:
2637 : : case TLLLINT:
2638 [ # # ]: 0 : *pS << sal_uInt8(CHAR);
2639 [ # # ]: 0 : *pS << sal_uInt8(0x86);
2640 [ # # ]: 0 : *pS << sal_uInt16(0x222B);
2641 : : case TIINT:
2642 : : case TLLINT:
2643 [ # # ]: 0 : *pS << sal_uInt8(CHAR);
2644 [ # # ]: 0 : *pS << sal_uInt8(0x86);
2645 [ # # ]: 0 : *pS << sal_uInt16(0x222B);
2646 : : case TINT:
2647 : : case TLINT:
2648 [ # # ]: 0 : *pS << sal_uInt8(CHAR);
2649 [ # # ]: 0 : *pS << sal_uInt8(0x86);
2650 [ # # ]: 0 : *pS << sal_uInt16(0x222B);
2651 : 0 : break;
2652 : : }
2653 [ # # ]: 0 : *pS << sal_uInt8(END);
2654 [ # # ]: 0 : *pS << sal_uInt8(0x0A);
2655 : : }
2656 : :
2657 : :
2658 : 0 : int MathType::HandlePile(int &rSetAlign,int nLevel,sal_uInt8 nSelector,
2659 : : sal_uInt8 nVariation)
2660 : : {
2661 : 0 : *pS >> nHAlign;
2662 : 0 : *pS >> nVAlign;
2663 : :
2664 : 0 : HandleAlign(nHAlign,nVAlign,rSetAlign);
2665 : :
2666 : 0 : APPEND(rRet," stack {\n");
2667 : 0 : int nRet = HandleRecords(nLevel+1,nSelector,nVariation,-1,-1);
2668 : 0 : rRet.Erase(rRet.Len()-3,2);
2669 : 0 : APPEND(rRet,"} ");
2670 : :
2671 [ # # ]: 0 : while (rSetAlign)
2672 : : {
2673 : 0 : APPEND(rRet,"} ");
2674 : 0 : rSetAlign--;
2675 : : }
2676 : 0 : return nRet;
2677 : : }
2678 : :
2679 : 0 : int MathType::HandleMatrix(int nLevel,sal_uInt8 nSelector,
2680 : : sal_uInt8 nVariation)
2681 : : {
2682 : : sal_uInt8 nH_just,nV_just,nRows,nCols;
2683 [ # # ]: 0 : *pS >> nVAlign;
2684 [ # # ]: 0 : *pS >> nH_just;
2685 [ # # ]: 0 : *pS >> nV_just;
2686 [ # # ]: 0 : *pS >> nRows;
2687 [ # # ]: 0 : *pS >> nCols;
2688 : 0 : int nBytes = ((nRows+1)*2)/8;
2689 [ # # ]: 0 : if (((nRows+1)*2)%8)
2690 : 0 : nBytes++;
2691 [ # # ]: 0 : pS->SeekRel(nBytes);
2692 : 0 : nBytes = ((nCols+1)*2)/8;
2693 [ # # ]: 0 : if (((nCols+1)*2)%8)
2694 : 0 : nBytes++;
2695 [ # # ]: 0 : pS->SeekRel(nBytes);
2696 [ # # ]: 0 : APPEND(rRet," matrix {\n");
2697 [ # # ]: 0 : int nRet = HandleRecords(nLevel+1,nSelector,nVariation,nRows,nCols);
2698 : :
2699 [ # # ]: 0 : xub_StrLen nI = rRet.SearchBackward('#');
2700 [ # # ][ # # ]: 0 : if ((nI != STRING_NOTFOUND) && (nI > 0))
2701 [ # # ]: 0 : if (rRet.GetChar(nI-1) != '#') //missing column
2702 [ # # ]: 0 : APPEND(rRet,"{}");
2703 : :
2704 [ # # ]: 0 : APPEND(rRet,"\n} ");
2705 : 0 : return nRet;
2706 : : }
2707 : :
2708 : 0 : int MathType::HandleTemplate(int nLevel,sal_uInt8 &rSelector,
2709 : : sal_uInt8 &rVariation, xub_StrLen &rLastTemplateBracket)
2710 : : {
2711 : : sal_uInt8 nOption; //This appears utterly unused
2712 [ # # ]: 0 : *pS >> rSelector;
2713 [ # # ]: 0 : *pS >> rVariation;
2714 [ # # ]: 0 : *pS >> nOption;
2715 : : OSL_ENSURE(rSelector < 48,"Selector out of range");
2716 [ # # ][ # # ]: 0 : if ((rSelector >= 21) && (rSelector <=26))
2717 : : {
2718 : : OSL_ENSURE(nOption < 2,"Option out of range");
2719 : : }
2720 : 0 : else if (/*(rSelector >= 0) &&*/ (rSelector <=12))
2721 : : {
2722 : : OSL_ENSURE(nOption < 3,"Option out of range");
2723 : : }
2724 : :
2725 : : //For the (broken) case where one subscript template ends, and there is
2726 : : //another one after it, mathtype handles it as if the second one was
2727 : : //inside the first one and renders it as sub of sub
2728 : 0 : bool bRemove=false;
2729 [ # # ][ # # ]: 0 : if ( (rSelector == 0xf) && (rLastTemplateBracket != STRING_NOTFOUND) )
2730 : : {
2731 : 0 : bRemove=true;
2732 [ # # ]: 0 : for (xub_StrLen nI = rLastTemplateBracket+1; nI < rRet.Len(); nI++ )
2733 [ # # ]: 0 : if (rRet.GetChar(nI) != ' ')
2734 : : {
2735 : 0 : bRemove=false;
2736 : 0 : break;
2737 : : }
2738 : : }
2739 : :
2740 : : //suborderlist
2741 [ # # ]: 0 : int nRet = HandleRecords(nLevel+1,rSelector,rVariation);
2742 : :
2743 [ # # ]: 0 : if (bRemove)
2744 : : {
2745 [ # # ]: 0 : rRet.Erase(rLastTemplateBracket,1);
2746 [ # # ]: 0 : APPEND(rRet,"} ");
2747 : 0 : rLastTemplateBracket = STRING_NOTFOUND;
2748 : : }
2749 [ # # ]: 0 : if (rSelector == 0xf)
2750 [ # # ]: 0 : rLastTemplateBracket = rRet.SearchBackward('}');
2751 : : else
2752 : 0 : rLastTemplateBracket = STRING_NOTFOUND;
2753 : :
2754 : 0 : rSelector = sal::static_int_cast< sal_uInt8 >(-1);
2755 : 0 : return nRet;
2756 : : }
2757 : :
2758 : 0 : void MathType::HandleEmblishments()
2759 : : {
2760 : : sal_uInt8 nEmbel;
2761 [ # # ]: 0 : do
2762 : : {
2763 [ # # ]: 0 : *pS >> nEmbel;
2764 [ # # # # : 0 : switch (nEmbel)
# # # # #
# # # #
# ]
2765 : : {
2766 : : case 0x02:
2767 [ # # ]: 0 : APPEND(rRet," dot ");
2768 : 0 : break;
2769 : : case 0x03:
2770 [ # # ]: 0 : APPEND(rRet," ddot ");
2771 : 0 : break;
2772 : : case 0x04:
2773 [ # # ]: 0 : APPEND(rRet," dddot ");
2774 : 0 : break;
2775 : : case 0x05:
2776 [ # # ]: 0 : if (nPostSup == 0)
2777 : : {
2778 [ # # ]: 0 : APPEND(sPost," sup {}");
2779 : 0 : nPostSup = sPost.Len();
2780 : : }
2781 [ # # ]: 0 : sPost.InsertAscii(" ' ",nPostSup-1);
2782 : 0 : nPostSup += 3;
2783 : 0 : break;
2784 : : case 0x06:
2785 [ # # ]: 0 : if (nPostSup == 0)
2786 : : {
2787 [ # # ]: 0 : APPEND(sPost," sup {}");
2788 : 0 : nPostSup = sPost.Len();
2789 : : }
2790 [ # # ]: 0 : sPost.InsertAscii(" '' ",nPostSup-1);
2791 : 0 : nPostSup += 4;
2792 : 0 : break;
2793 : : case 0x07:
2794 [ # # ]: 0 : if (nPostlSup == 0)
2795 : : {
2796 [ # # ]: 0 : APPEND(sPost," lsup {}");
2797 : 0 : nPostlSup = sPost.Len();
2798 : : }
2799 [ # # ]: 0 : sPost.InsertAscii(" ' ",nPostlSup-1);
2800 : 0 : nPostlSup += 3;
2801 : 0 : break;
2802 : : case 0x08:
2803 [ # # ]: 0 : APPEND(rRet," tilde ");
2804 : 0 : break;
2805 : : case 0x09:
2806 [ # # ]: 0 : APPEND(rRet," hat ");
2807 : 0 : break;
2808 : : case 0x0b:
2809 [ # # ]: 0 : APPEND(rRet," vec ");
2810 : 0 : break;
2811 : : case 0x10:
2812 [ # # ]: 0 : APPEND(rRet," overstrike ");
2813 : 0 : break;
2814 : : case 0x11:
2815 [ # # ]: 0 : APPEND(rRet," bar ");
2816 : 0 : break;
2817 : : case 0x12:
2818 [ # # ]: 0 : if (nPostSup == 0)
2819 : : {
2820 [ # # ]: 0 : APPEND(sPost," sup {}");
2821 : 0 : nPostSup = sPost.Len();
2822 : : }
2823 [ # # ]: 0 : sPost.InsertAscii(" ''' ",nPostSup-1);
2824 : 0 : nPostSup += 5;
2825 : 0 : break;
2826 : : case 0x14:
2827 [ # # ]: 0 : APPEND(rRet," breve ");
2828 : 0 : break;
2829 : : default:
2830 : : OSL_ENSURE(nEmbel < 21,"Embel out of range");
2831 : 0 : break;
2832 : : }
2833 [ # # ]: 0 : if (nVersion < 3)
2834 : 0 : break;
2835 : : }while (nEmbel);
2836 : 0 : }
2837 : :
2838 : 0 : void MathType::HandleSetSize()
2839 : : {
2840 : : sal_uInt8 nTemp;
2841 [ # # ]: 0 : *pS >> nTemp;
2842 [ # # # ]: 0 : switch (nTemp)
2843 : : {
2844 : : case 101:
2845 [ # # ]: 0 : *pS >> nLSize;
2846 : 0 : nLSize = -nLSize;
2847 : 0 : break;
2848 : : case 100:
2849 [ # # ]: 0 : *pS >> nTemp;
2850 : 0 : nLSize = nTemp;
2851 [ # # ]: 0 : *pS >> nDSize;
2852 : 0 : break;
2853 : : default:
2854 : 0 : nLSize = nTemp;
2855 [ # # ]: 0 : *pS >> nTemp;
2856 : 0 : nDSize = nTemp-128;
2857 : 0 : break;
2858 : : }
2859 : 0 : }
2860 : :
2861 : 0 : int MathType::HandleChar(xub_StrLen &rTextStart,int &rSetSize,int nLevel,
2862 : : sal_uInt8 nTag,sal_uInt8 nSelector,sal_uInt8 nVariation, sal_Bool bSilent)
2863 : : {
2864 : : sal_Unicode nChar;
2865 : 0 : int nRet=1;
2866 : :
2867 : 0 : if (xfAUTO(nTag))
2868 : : {
2869 : : //This is a candidate for function recognition, whatever
2870 : : //that is!
2871 : : }
2872 : :
2873 : 0 : sal_uInt8 nOldTypeFace = nTypeFace;
2874 [ # # ]: 0 : *pS >> nTypeFace;
2875 [ # # ]: 0 : if (nVersion < 3)
2876 : : {
2877 : : sal_uInt8 nChar8;
2878 [ # # ]: 0 : *pS >> nChar8;
2879 : 0 : nChar = nChar8;
2880 : : }
2881 : : else
2882 [ # # ]: 0 : *pS >> nChar;
2883 : :
2884 : : /*
2885 : : bad character, old mathtype < 3 has these
2886 : : */
2887 [ # # ]: 0 : if (nChar < 0x20)
2888 : 0 : return nRet;
2889 : :
2890 [ # # ]: 0 : if (xfEMBELL(nTag))
2891 : : {
2892 : : //A bit tricky, the character emblishments for
2893 : : //mathtype can all be listed after eachother, in
2894 : : //starmath some must go before the character and some
2895 : : //must go after. In addition some of the emblishments
2896 : : //may repeated and in starmath some of these groups
2897 : : //must be gathered together. sPost is the portion that
2898 : : //follows the char and nPostSup and nPostlSup are the
2899 : : //indexes at which this class of emblishment is
2900 : : //collated together
2901 [ # # ]: 0 : sPost.Erase();
2902 : 0 : nPostSup = nPostlSup = 0;
2903 : 0 : int nOriglen=rRet.Len()-rTextStart;
2904 [ # # ]: 0 : APPEND(rRet," {"); // #i24340# make what would be "vec {A}_n" become "{vec {A}}_n"
2905 [ # # ][ # # ]: 0 : if ((!bSilent) && ((nOriglen) > 1))
2906 [ # # ]: 0 : rRet += '\"';
2907 [ # # ]: 0 : nRet = HandleRecords(nLevel+1,nSelector,nVariation);
2908 [ # # ]: 0 : if (!bSilent)
2909 : : {
2910 [ # # ]: 0 : if (nOriglen > 1)
2911 : : {
2912 [ # # ]: 0 : String aStr;
2913 [ # # ]: 0 : TypeFaceToString(aStr,nOldTypeFace);
2914 [ # # ]: 0 : aStr += '\"';
2915 [ # # ]: 0 : rRet.Insert(aStr,rTextStart);
2916 : :
2917 [ # # ]: 0 : aStr.Erase();
2918 [ # # ]: 0 : TypeFaceToString(aStr,nTypeFace);
2919 [ # # ]: 0 : rRet.Append(aStr);
2920 [ # # ][ # # ]: 0 : rRet += '{';
2921 : : }
2922 : : else
2923 [ # # ]: 0 : APPEND(rRet," {");
2924 : 0 : rTextStart = rRet.Len();
2925 : : }
2926 : : }
2927 : :
2928 [ # # ]: 0 : if (!bSilent)
2929 : : {
2930 : 0 : xub_StrLen nOldLen = rRet.Len();
2931 [ # # ][ # # ]: 0 : if (
[ # # ]
2932 [ # # ]: 0 : HandleSize(nLSize,nDSize,rSetSize) ||
2933 : : (nOldTypeFace != nTypeFace)
2934 : : )
2935 : : {
2936 [ # # ]: 0 : if ((nOldLen - rTextStart) > 1)
2937 : : {
2938 [ # # ]: 0 : rRet.InsertAscii("\"",nOldLen);
2939 [ # # ]: 0 : String aStr;
2940 [ # # ]: 0 : TypeFaceToString(aStr,nOldTypeFace);
2941 [ # # ]: 0 : aStr += '\"';
2942 [ # # ][ # # ]: 0 : rRet.Insert(aStr,rTextStart);
2943 : : }
2944 : 0 : rTextStart = rRet.Len();
2945 : : }
2946 : 0 : nOldLen = rRet.Len();
2947 [ # # ][ # # ]: 0 : if (!LookupChar(nChar,rRet,nVersion,nTypeFace))
2948 : : {
2949 [ # # ]: 0 : if (nOldLen - rTextStart > 1)
2950 : : {
2951 [ # # ]: 0 : rRet.InsertAscii("\"",nOldLen);
2952 [ # # ]: 0 : String aStr;
2953 [ # # ]: 0 : TypeFaceToString(aStr,nOldTypeFace);
2954 [ # # ]: 0 : aStr += '\"';
2955 [ # # ][ # # ]: 0 : rRet.Insert(aStr,rTextStart);
2956 : : }
2957 : 0 : rTextStart = rRet.Len();
2958 : : }
2959 [ # # ]: 0 : lcl_PrependDummyTerm(rRet, rTextStart);
2960 : : }
2961 : :
2962 [ # # ][ # # ]: 0 : if ((xfEMBELL(nTag)) && (!bSilent))
[ # # ]
2963 : : {
2964 [ # # ]: 0 : rRet += '}'; // #i24340# make what would be "vec {A}_n" become "{vec {A}}_n"
2965 [ # # ]: 0 : rRet += '}';
2966 [ # # ]: 0 : rRet += sPost;
2967 : 0 : rTextStart = rRet.Len();
2968 : : }
2969 : 0 : return nRet;
2970 : : }
2971 : :
2972 : 0 : sal_Bool MathType::HandleLim(SmNode *pNode,int nLevel)
2973 : : {
2974 : 0 : bool bRet=false;
2975 : : //Special case for the "lim" option in StarMath
2976 [ # # # # : 0 : if ((pNode->GetToken().eType == TLIM)
# # ][ # # ]
2977 : 0 : || (pNode->GetToken().eType == TLIMSUP)
2978 : 0 : || (pNode->GetToken().eType == TLIMINF)
2979 : : )
2980 : : {
2981 [ # # ]: 0 : if (pNode->GetSubNode(1))
2982 : : {
2983 : 0 : sal_uInt8 nVariation2=HandleCScript(pNode->GetSubNode(0),NULL,
2984 : 0 : nLevel);
2985 : :
2986 : 0 : *pS << sal_uInt8(0x0A);
2987 : 0 : *pS << sal_uInt8(LINE); //line
2988 : 0 : *pS << sal_uInt8(CHAR|0x10);
2989 : 0 : *pS << sal_uInt8(0x82);
2990 : 0 : *pS << sal_uInt16('l');
2991 : 0 : *pS << sal_uInt8(CHAR|0x10);
2992 : 0 : *pS << sal_uInt8(0x82);
2993 : 0 : *pS << sal_uInt16('i');
2994 : 0 : *pS << sal_uInt8(CHAR|0x10);
2995 : 0 : *pS << sal_uInt8(0x82);
2996 : 0 : *pS << sal_uInt16('m');
2997 : :
2998 [ # # ]: 0 : if (pNode->GetToken().eType == TLIMSUP)
2999 : : {
3000 : 0 : *pS << sal_uInt8(CHAR); //some space
3001 : 0 : *pS << sal_uInt8(0x98);
3002 : 0 : *pS << sal_uInt16(0xEB04);
3003 : :
3004 : 0 : *pS << sal_uInt8(CHAR|0x10);
3005 : 0 : *pS << sal_uInt8(0x82);
3006 : 0 : *pS << sal_uInt16('s');
3007 : 0 : *pS << sal_uInt8(CHAR|0x10);
3008 : 0 : *pS << sal_uInt8(0x82);
3009 : 0 : *pS << sal_uInt16('u');
3010 : 0 : *pS << sal_uInt8(CHAR|0x10);
3011 : 0 : *pS << sal_uInt8(0x82);
3012 : 0 : *pS << sal_uInt16('p');
3013 : : }
3014 [ # # ]: 0 : else if (pNode->GetToken().eType == TLIMINF)
3015 : : {
3016 : 0 : *pS << sal_uInt8(CHAR); //some space
3017 : 0 : *pS << sal_uInt8(0x98);
3018 : 0 : *pS << sal_uInt16(0xEB04);
3019 : :
3020 : 0 : *pS << sal_uInt8(CHAR|0x10);
3021 : 0 : *pS << sal_uInt8(0x82);
3022 : 0 : *pS << sal_uInt16('i');
3023 : 0 : *pS << sal_uInt8(CHAR|0x10);
3024 : 0 : *pS << sal_uInt8(0x82);
3025 : 0 : *pS << sal_uInt16('n');
3026 : 0 : *pS << sal_uInt8(CHAR|0x10);
3027 : 0 : *pS << sal_uInt8(0x82);
3028 : 0 : *pS << sal_uInt16('f');
3029 : : }
3030 : :
3031 : :
3032 : 0 : *pS << sal_uInt8(CHAR); //some space
3033 : 0 : *pS << sal_uInt8(0x98);
3034 : 0 : *pS << sal_uInt16(0xEB04);
3035 : :
3036 [ # # ]: 0 : if (nVariation2 != 0xff)
3037 : : {
3038 : 0 : *pS << sal_uInt8(END);
3039 : 0 : *pS << sal_uInt8(END);
3040 : : }
3041 : 0 : HandleNodes(pNode->GetSubNode(1),nLevel+1);
3042 : : //*pS << sal_uInt8(END); //options
3043 : 0 : bRet = true;
3044 : : }
3045 : : }
3046 : 0 : return bRet;
3047 : : }
3048 : :
3049 : 0 : void MathType::HandleMAlign(SmNode *pNode,int nLevel)
3050 : : {
3051 : 0 : sal_uInt8 nPushedHAlign=nHAlign;
3052 [ # # # ]: 0 : switch(pNode->GetToken().eType)
3053 : : {
3054 : : case TALIGNC:
3055 : 0 : nHAlign=2;
3056 : 0 : break;
3057 : : case TALIGNR:
3058 : 0 : nHAlign=3;
3059 : 0 : break;
3060 : : default:
3061 : 0 : nHAlign=1;
3062 : 0 : break;
3063 : : }
3064 : 0 : sal_uInt16 nSize = pNode->GetNumSubNodes();
3065 [ # # ]: 0 : for (sal_uInt16 i = 0; i < nSize; i++)
3066 [ # # ]: 0 : if (SmNode *pTemp = pNode->GetSubNode(i))
3067 : 0 : HandleNodes(pTemp,nLevel+1);
3068 : 0 : nHAlign=nPushedHAlign;
3069 : 0 : }
3070 : :
3071 : 0 : void MathType::HandleMath(SmNode *pNode, int /*nLevel*/)
3072 : : {
3073 [ # # ]: 0 : if (pNode->GetToken().eType == TMLINE)
3074 : : {
3075 : 0 : *pS << sal_uInt8(END);
3076 : 0 : *pS << sal_uInt8(LINE);
3077 : 0 : bIsReInterpBrace=1;
3078 : 0 : return;
3079 : : }
3080 : 0 : SmMathSymbolNode *pTemp=(SmMathSymbolNode *)pNode;
3081 [ # # ]: 0 : for(xub_StrLen i=0;i<pTemp->GetText().Len();i++)
3082 : : {
3083 : 0 : sal_Unicode nArse = SmTextNode::ConvertSymbolToUnicode(pTemp->GetText().GetChar(i));
3084 [ # # ][ # # ]: 0 : if ((nArse == 0x2224) || (nArse == 0x2288) || (nArse == 0x2285) ||
[ # # ][ # # ]
3085 : : (nArse == 0x2289))
3086 : : {
3087 : 0 : *pS << sal_uInt8(CHAR|0x20);
3088 : : }
3089 [ # # # # ]: 0 : else if ((nPendingAttributes) &&
[ # # ]
3090 : 0 : (i == ((pTemp->GetText().Len()+1)/2)-1))
3091 : : {
3092 : 0 : *pS << sal_uInt8(0x22);
3093 : : }
3094 : : else
3095 : 0 : *pS << sal_uInt8(CHAR); //char without formula recognition
3096 : : //The typeface seems to be MTEXTRA for unicode characters,
3097 : : //though how to determine when mathtype chooses one over
3098 : : //the other is unknown. This should do the trick
3099 : : //nevertheless.
3100 : : sal_uInt8 nBias;
3101 [ # # ][ # # ]: 0 : if ( (nArse == 0x2213) || (nArse == 0x2218) ||
[ # # ][ # # ]
[ # # ]
3102 : : (nArse == 0x210F) || (
3103 : : (nArse >= 0x22EE) && (nArse <= 0x22FF)
3104 : : ))
3105 : : {
3106 : 0 : nBias = 0xB; //typeface
3107 : : }
3108 [ # # ][ # # ]: 0 : else if ((nArse > 0x2000) || (nArse == 0x00D7))
3109 : 0 : nBias = 0x6; //typeface
3110 [ # # ]: 0 : else if (nArse == 0x3d1)
3111 : 0 : nBias = 0x4;
3112 [ # # ][ # # ]: 0 : else if ((nArse > 0xFF) && ((nArse < 0x393) || (nArse > 0x3c9)))
[ # # ]
3113 : 0 : nBias = 0xB; //typeface
3114 [ # # ][ # # ]: 0 : else if ((nArse == 0x2F) || (nArse == 0x2225))
3115 : 0 : nBias = 0x2; //typeface
3116 : : else
3117 : 0 : nBias = 0x3; //typeface
3118 : :
3119 : 0 : *pS << sal_uInt8(nSpec+nBias+128); //typeface
3120 : :
3121 [ # # ]: 0 : if (nArse == 0x2224)
3122 : : {
3123 : 0 : *pS << sal_uInt16(0x7C);
3124 : 0 : *pS << sal_uInt8(EMBEL);
3125 : 0 : *pS << sal_uInt8(0x0A);
3126 : 0 : *pS << sal_uInt8(END); //end embel
3127 : 0 : *pS << sal_uInt8(END); //end embel
3128 : : }
3129 [ # # ]: 0 : else if (nArse == 0x2225)
3130 : 0 : *pS << sal_uInt16(0xEC09);
3131 [ # # ]: 0 : else if (nArse == 0xE421)
3132 : 0 : *pS << sal_uInt16(0x2265);
3133 [ # # ]: 0 : else if (nArse == 0x230A)
3134 : 0 : *pS << sal_uInt16(0xF8F0);
3135 [ # # ]: 0 : else if (nArse == 0x230B)
3136 : 0 : *pS << sal_uInt16(0xF8FB);
3137 [ # # ]: 0 : else if (nArse == 0xE425)
3138 : 0 : *pS << sal_uInt16(0x2264);
3139 [ # # ]: 0 : else if (nArse == 0x226A)
3140 : : {
3141 : 0 : *pS << sal_uInt16(0x3C);
3142 : 0 : *pS << sal_uInt8(CHAR);
3143 : 0 : *pS << sal_uInt8(0x98);
3144 : 0 : *pS << sal_uInt16(0xEB01);
3145 : 0 : *pS << sal_uInt8(CHAR);
3146 : 0 : *pS << sal_uInt8(0x86);
3147 : 0 : *pS << sal_uInt16(0x3c);
3148 : : }
3149 [ # # ]: 0 : else if (nArse == 0x2288)
3150 : : {
3151 : 0 : *pS << sal_uInt16(0x2286);
3152 : 0 : *pS << sal_uInt8(EMBEL);
3153 : 0 : *pS << sal_uInt8(0x0A);
3154 : 0 : *pS << sal_uInt8(END); //end embel
3155 : 0 : *pS << sal_uInt8(END); //end embel
3156 : : }
3157 [ # # ]: 0 : else if (nArse == 0x2289)
3158 : : {
3159 : 0 : *pS << sal_uInt16(0x2287);
3160 : 0 : *pS << sal_uInt8(EMBEL);
3161 : 0 : *pS << sal_uInt8(0x0A);
3162 : 0 : *pS << sal_uInt8(END); //end embel
3163 : 0 : *pS << sal_uInt8(END); //end embel
3164 : : }
3165 [ # # ]: 0 : else if (nArse == 0x2285)
3166 : : {
3167 : 0 : *pS << sal_uInt16(0x2283);
3168 : 0 : *pS << sal_uInt8(EMBEL);
3169 : 0 : *pS << sal_uInt8(0x0A);
3170 : 0 : *pS << sal_uInt8(END); //end embel
3171 : 0 : *pS << sal_uInt8(END); //end embel
3172 : : }
3173 : : else
3174 : 0 : *pS << nArse;
3175 : : }
3176 : 0 : nPendingAttributes = 0;
3177 : : }
3178 : :
3179 : 0 : void MathType::HandleAttributes(SmNode *pNode,int nLevel)
3180 : : {
3181 : 0 : int nOldPending = 0;
3182 : 0 : SmNode *pTemp = 0;
3183 : 0 : SmTextNode *pIsText = 0;
3184 : :
3185 [ # # ]: 0 : if (NULL != (pTemp = pNode->GetSubNode(0)))
3186 : : {
3187 : 0 : pIsText = (SmTextNode *)pNode->GetSubNode(1);
3188 : :
3189 [ # # # # : 0 : switch (pTemp->GetToken().eType)
# ]
3190 : : {
3191 : : case TWIDEVEC:
3192 : : //theres just no way we can now handle any character
3193 : : //attributes (from mathtypes perspective) centered
3194 : : //over an expression but above template attributes
3195 : : //such as widevec and similiar constructs
3196 : : //we have to drop them
3197 : 0 : nOldPending = StartTemplate(0x2f,0x01);
3198 : 0 : break;
3199 : : case TCHECK: //Not Exportable
3200 : : case TACUTE: //Not Exportable
3201 : : case TGRAVE: //Not Exportable
3202 : : case TCIRCLE: //Not Exportable
3203 : : case TWIDETILDE: //Not Exportable
3204 : : case TWIDEHAT: //Not Exportable
3205 : 0 : break;
3206 : : case TUNDERLINE:
3207 : 0 : nOldPending = StartTemplate(0x10);
3208 : 0 : break;
3209 : : case TOVERLINE: //If the next node is not text
3210 : : //or text with more than one char
3211 [ # # # # ]: 0 : if ((pIsText->GetToken().eType != TTEXT) ||
[ # # ]
3212 : 0 : (pIsText->GetText().Len() > 1))
3213 : 0 : nOldPending = StartTemplate(0x11);
3214 : 0 : break;
3215 : : default:
3216 : 0 : nPendingAttributes++;
3217 : 0 : break;
3218 : : }
3219 : : }
3220 : :
3221 [ # # ]: 0 : if (pIsText)
3222 : 0 : HandleNodes(pIsText,nLevel+1);
3223 : :
3224 [ # # # ]: 0 : switch (pTemp->GetToken().eType)
3225 : : {
3226 : : case TWIDEVEC:
3227 : : case TUNDERLINE:
3228 : 0 : EndTemplate(nOldPending);
3229 : 0 : break;
3230 : : case TOVERLINE:
3231 [ # # # # ]: 0 : if ((pIsText->GetToken().eType != TTEXT) ||
[ # # ]
3232 : 0 : (pIsText->GetText().Len() > 1))
3233 : 0 : EndTemplate(nOldPending);
3234 : 0 : break;
3235 : : default:
3236 : 0 : break;
3237 : : }
3238 : :
3239 : : //if there was no suitable place to put the attribute,
3240 : : //then we have to just give up on it
3241 [ # # ]: 0 : if (nPendingAttributes)
3242 : 0 : nPendingAttributes--;
3243 : : else
3244 : : {
3245 [ # # ][ # # ]: 0 : if ((nInsertion != 0) && NULL != (pTemp = pNode->GetSubNode(0)))
[ # # ]
3246 : : {
3247 : 0 : sal_uLong nPos = pS->Tell();
3248 : 0 : nInsertion--;
3249 : 0 : pS->Seek(nInsertion);
3250 [ # # # # : 0 : switch(pTemp->GetToken().eType)
# # # # #
# # # # ]
3251 : : {
3252 : : case TACUTE: //Not Exportable
3253 : : case TGRAVE: //Not Exportable
3254 : : case TCIRCLE: //Not Exportable
3255 : 0 : break;
3256 : : case TCDOT:
3257 : 0 : *pS << sal_uInt8(2);
3258 : 0 : break;
3259 : : case TDDOT:
3260 : 0 : *pS << sal_uInt8(3);
3261 : 0 : break;
3262 : : case TDDDOT:
3263 : 0 : *pS << sal_uInt8(4);
3264 : 0 : break;
3265 : : case TTILDE:
3266 : 0 : *pS << sal_uInt8(8);
3267 : 0 : break;
3268 : : case THAT:
3269 : 0 : *pS << sal_uInt8(9);
3270 : 0 : break;
3271 : : case TVEC:
3272 : 0 : *pS << sal_uInt8(11);
3273 : 0 : break;
3274 : : case TOVERSTRIKE:
3275 : 0 : *pS << sal_uInt8(16);
3276 : 0 : break;
3277 : : case TOVERLINE:
3278 [ # # # # ]: 0 : if ((pIsText->GetToken().eType == TTEXT) &&
[ # # ]
3279 : 0 : (pIsText->GetText().Len() == 1))
3280 : 0 : *pS << sal_uInt8(17);
3281 : 0 : break;
3282 : : case TBREVE:
3283 : 0 : *pS << sal_uInt8(20);
3284 : 0 : break;
3285 : : case TWIDEVEC:
3286 : : case TUNDERLINE:
3287 : : case TWIDETILDE:
3288 : : case TWIDEHAT:
3289 : 0 : break;
3290 : : case TBAR:
3291 : 0 : *pS << sal_uInt8(17);
3292 : 0 : break;
3293 : : default:
3294 : 0 : *pS << sal_uInt8(0x2);
3295 : 0 : break;
3296 : : }
3297 : 0 : pS->Seek(nPos);
3298 : : }
3299 : : }
3300 : 0 : }
3301 : :
3302 : 0 : void MathType::HandleText(SmNode *pNode, int /*nLevel*/)
3303 : : {
3304 : 0 : SmTextNode *pTemp=(SmTextNode *)pNode;
3305 [ # # ]: 0 : for(xub_StrLen i=0;i<pTemp->GetText().Len();i++)
3306 : : {
3307 [ # # # # ]: 0 : if ((nPendingAttributes) &&
[ # # ]
3308 : 0 : (i == ((pTemp->GetText().Len()+1)/2)-1))
3309 : : {
3310 : 0 : *pS << sal_uInt8(0x22); //char, with attributes right
3311 : : //after the character
3312 : : }
3313 : : else
3314 : 0 : *pS << sal_uInt8(CHAR);
3315 : :
3316 : 0 : sal_uInt8 nFace = 0x1;
3317 [ # # ]: 0 : if (pNode->GetFont().GetItalic() == ITALIC_NORMAL)
3318 : 0 : nFace = 0x3;
3319 [ # # ]: 0 : else if (pNode->GetFont().GetWeight() == WEIGHT_BOLD)
3320 : 0 : nFace = 0x7;
3321 : 0 : *pS << sal_uInt8(nFace+128); //typeface
3322 : 0 : sal_uInt16 nChar = pTemp->GetText().GetChar(i);
3323 : 0 : *pS << SmTextNode::ConvertSymbolToUnicode(nChar);
3324 : :
3325 : : //Mathtype can only have these sort of character
3326 : : //attributes on a single character, starmath can put them
3327 : : //anywhere, when the entity involved is a text run this is
3328 : : //a large effort to place the character attribute on the
3329 : : //central mathtype character so that it does pretty much
3330 : : //what the user probably has in mind. The attributes
3331 : : //filled in here are dummy ones which are replaced in the
3332 : : //ATTRIBUT handler if a suitable location for the
3333 : : //attributes was found here. Unfortunately it is
3334 : : //possible for starmath to place character attributes on
3335 : : //entities which cannot occur in mathtype e.g. a Summation
3336 : : //symbol so these attributes may be lost
3337 [ # # ]: 0 : if ((nPendingAttributes) &&
[ # # # # ]
3338 : 0 : (i == ((pTemp->GetText().Len()+1)/2)-1))
3339 : : {
3340 : 0 : *pS << sal_uInt8(EMBEL);
3341 [ # # ]: 0 : while (nPendingAttributes)
3342 : : {
3343 : 0 : *pS << sal_uInt8(2);
3344 : : //wedge the attributes in here and clear
3345 : : //the pending stack
3346 : 0 : nPendingAttributes--;
3347 : : }
3348 : 0 : nInsertion=pS->Tell();
3349 : 0 : *pS << sal_uInt8(END); //end embel
3350 : 0 : *pS << sal_uInt8(END); //end embel
3351 : : }
3352 : : }
3353 : 0 : }
3354 : :
3355 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|