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 :
10 :
11 : #include "rtfexport.hxx"
12 :
13 : #include <rtl/ustring.hxx>
14 : #include <svtools/rtfkeywd.hxx>
15 : #include <filter/msfilter/rtfutil.hxx>
16 :
17 30 : SmRtfExport::SmRtfExport(const SmNode* pIn)
18 : : SmWordExportBase(pIn)
19 : , m_pBuffer(0)
20 30 : , m_nEncoding(RTL_TEXTENCODING_DONTKNOW)
21 : {
22 30 : }
23 :
24 30 : bool SmRtfExport::ConvertFromStarMath(OStringBuffer& rBuffer, rtl_TextEncoding nEncoding)
25 : {
26 30 : if (!m_pTree)
27 0 : return false;
28 30 : m_pBuffer = &rBuffer;
29 30 : m_nEncoding = nEncoding;
30 30 : m_pBuffer->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE LO_STRING_SVTOOLS_RTF_MOMATH " ");
31 30 : HandleNode(m_pTree, 0);
32 30 : m_pBuffer->append("}"); // moMath
33 30 : return true;
34 : }
35 :
36 : // NOTE: This is still work in progress and unfinished, but it already covers a good
37 : // part of the rtf math stuff.
38 :
39 5 : void SmRtfExport::HandleVerticalStack(const SmNode* pNode, int nLevel)
40 : {
41 5 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MEQARR " ");
42 5 : int size = pNode->GetNumSubNodes();
43 16 : for (int i = 0; i < size; ++i)
44 : {
45 11 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_ME " ");
46 11 : HandleNode(pNode->GetSubNode(i), nLevel + 1);
47 11 : m_pBuffer->append("}"); // me
48 : }
49 5 : m_pBuffer->append("}"); // meqArr
50 5 : }
51 :
52 265 : void SmRtfExport::HandleText(const SmNode* pNode, int /*nLevel*/)
53 : {
54 265 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MR " ");
55 :
56 265 : if (pNode->GetToken().eType == TTEXT) // literal text
57 3 : m_pBuffer->append(LO_STRING_SVTOOLS_RTF_MNOR " ");
58 :
59 265 : SmTextNode* pTemp=(SmTextNode*)pNode;
60 : SAL_INFO("starmath.rtf", "Text: " << pTemp->GetText());
61 578 : for (sal_Int32 i = 0; i < pTemp->GetText().getLength(); i++)
62 : {
63 313 : sal_uInt16 nChar = pTemp->GetText()[i];
64 313 : OUString aValue(SmTextNode::ConvertSymbolToUnicode(nChar));
65 313 : m_pBuffer->append(msfilter::rtfutil::OutString(aValue, m_nEncoding));
66 313 : }
67 :
68 265 : m_pBuffer->append("}"); // mr
69 265 : }
70 :
71 15 : void SmRtfExport::HandleFractions(const SmNode* pNode, int nLevel, const char* type)
72 : {
73 15 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MF " ");
74 15 : if (type)
75 : {
76 1 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MFPR " ");
77 1 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MTYPE " ");
78 1 : m_pBuffer->append(type);
79 1 : m_pBuffer->append("}"); // mtype
80 1 : m_pBuffer->append("}"); // mfPr
81 : }
82 : OSL_ASSERT(pNode->GetNumSubNodes() == 3);
83 15 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MNUM " ");
84 15 : HandleNode(pNode->GetSubNode(0), nLevel + 1);
85 15 : m_pBuffer->append("}"); // mnum
86 15 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MDEN " ");
87 15 : HandleNode(pNode->GetSubNode(2), nLevel + 1);
88 15 : m_pBuffer->append("}"); // mden
89 15 : m_pBuffer->append("}"); // mf
90 15 : }
91 :
92 14 : void SmRtfExport::HandleAttribute(const SmAttributNode* pNode, int nLevel)
93 : {
94 14 : switch (pNode->Attribute()->GetToken().eType)
95 : {
96 : case TCHECK:
97 : case TACUTE:
98 : case TGRAVE:
99 : case TBREVE:
100 : case TCIRCLE:
101 : case TVEC:
102 : case TTILDE:
103 : case THAT:
104 : case TDOT:
105 : case TDDOT:
106 : case TDDDOT:
107 : case TWIDETILDE:
108 : case TWIDEHAT:
109 : case TWIDEVEC:
110 : case TBAR:
111 : {
112 12 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MACC " ");
113 12 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MACCPR " ");
114 12 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MCHR " ");
115 12 : OUString aValue(pNode->Attribute()->GetToken().cMathChar);
116 12 : m_pBuffer->append(msfilter::rtfutil::OutString(aValue, m_nEncoding));
117 12 : m_pBuffer->append("}"); // mchr
118 12 : m_pBuffer->append("}"); // maccPr
119 12 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_ME " ");
120 12 : HandleNode(pNode->Body(), nLevel + 1);
121 12 : m_pBuffer->append("}"); // me
122 12 : m_pBuffer->append("}"); // macc
123 12 : break;
124 : }
125 : case TOVERLINE:
126 : case TUNDERLINE:
127 1 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MBAR " ");
128 1 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MBARPR " ");
129 1 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MPOS " ");
130 1 : m_pBuffer->append((pNode->Attribute()->GetToken().eType == TUNDERLINE) ? "bot" : "top");
131 1 : m_pBuffer->append("}"); // mpos
132 1 : m_pBuffer->append("}"); // mbarPr
133 1 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_ME " ");
134 1 : HandleNode(pNode->Body(), nLevel + 1);
135 1 : m_pBuffer->append("}"); // me
136 1 : m_pBuffer->append("}"); // mbar
137 1 : break;
138 : case TOVERSTRIKE:
139 1 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MBORDERBOX " ");
140 1 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MBORDERBOXPR " ");
141 1 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MHIDETOP " 1}");
142 1 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MHIDEBOT " 1}");
143 1 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MHIDELEFT " 1}");
144 1 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MHIDERIGHT " 1}");
145 1 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MSTRIKEH " 1}");
146 1 : m_pBuffer->append("}"); // mborderBoxPr
147 1 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_ME " ");
148 1 : HandleNode(pNode->Body(), nLevel + 1);
149 1 : m_pBuffer->append("}"); // me
150 1 : m_pBuffer->append("}"); // mborderBox
151 1 : break;
152 : default:
153 0 : HandleAllSubNodes(pNode, nLevel);
154 0 : break;
155 : }
156 14 : }
157 :
158 3 : void SmRtfExport::HandleRoot(const SmRootNode* pNode, int nLevel)
159 : {
160 3 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MRAD " ");
161 3 : if (const SmNode* argument = pNode->Argument())
162 : {
163 1 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MDEG " ");
164 1 : HandleNode(argument, nLevel + 1);
165 1 : m_pBuffer->append("}"); // mdeg
166 : }
167 : else
168 : {
169 2 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MRADPR " ");
170 2 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MDEGHIDE " 1}");
171 2 : m_pBuffer->append("}"); // mradPr
172 2 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MDEG " }"); // empty but present
173 : }
174 3 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_ME " ");
175 3 : HandleNode(pNode->Body(), nLevel + 1);
176 3 : m_pBuffer->append("}"); // me
177 3 : m_pBuffer->append("}"); // mrad
178 3 : }
179 :
180 : namespace
181 : {
182 58 : OString mathSymbolToString(const SmNode* node, rtl_TextEncoding nEncoding)
183 : {
184 : assert(node->GetType() == NMATH || node->GetType() == NMATHIDENT);
185 58 : const SmTextNode* txtnode = static_cast<const SmTextNode*>(node);
186 58 : if (txtnode->GetText().isEmpty())
187 1 : return OString();
188 : assert(txtnode->GetText().getLength() == 1);
189 57 : sal_Unicode chr = SmTextNode::ConvertSymbolToUnicode(txtnode->GetText()[0]);
190 57 : OUString aValue(chr);
191 57 : return msfilter::rtfutil::OutString(aValue, nEncoding);
192 : }
193 : }
194 :
195 9 : void SmRtfExport::HandleOperator(const SmOperNode* pNode, int nLevel)
196 : {
197 : SAL_INFO("starmath.rtf", "Operator: " << int(pNode->GetToken().eType));
198 9 : switch (pNode->GetToken().eType)
199 : {
200 : case TINT:
201 : case TINTD:
202 : case TIINT:
203 : case TIIINT:
204 : case TLINT:
205 : case TLLINT:
206 : case TLLLINT:
207 : case TPROD:
208 : case TCOPROD:
209 : case TSUM:
210 : {
211 8 : const SmSubSupNode* subsup = pNode->GetSubNode(0)->GetType() == NSUBSUP ? static_cast<const SmSubSupNode*>(pNode->GetSubNode(0)) : 0;
212 8 : const SmNode* operation = subsup ? subsup->GetBody() : pNode->GetSubNode(0);
213 8 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MNARY " ");
214 8 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MNARYPR " ");
215 8 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MCHR " ");
216 8 : m_pBuffer->append(mathSymbolToString(operation, m_nEncoding));
217 8 : m_pBuffer->append("}"); // mchr
218 8 : if (!subsup || !subsup->GetSubSup(CSUB))
219 1 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MSUBHIDE " 1}");
220 8 : if (!subsup || !subsup->GetSubSup(CSUP))
221 1 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MSUPHIDE " 1}");
222 8 : m_pBuffer->append("}"); // mnaryPr
223 8 : if (!subsup || !subsup->GetSubSup(CSUB))
224 1 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MSUB " }");
225 : else
226 : {
227 7 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MSUB " ");
228 7 : HandleNode(subsup->GetSubSup(CSUB), nLevel + 1);
229 7 : m_pBuffer->append("}"); // msub
230 : }
231 8 : if (!subsup || !subsup->GetSubSup(CSUP))
232 1 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MSUP " }");
233 : else
234 : {
235 7 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MSUP " ");
236 7 : HandleNode(subsup->GetSubSup(CSUP), nLevel + 1);
237 7 : m_pBuffer->append("}"); // msup
238 : }
239 8 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_ME " ");
240 8 : HandleNode(pNode->GetSubNode(1), nLevel + 1); // body
241 8 : m_pBuffer->append("}"); // me
242 8 : m_pBuffer->append("}"); // mnary
243 8 : break;
244 : }
245 : case TLIM:
246 1 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MFUNC " ");
247 1 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MFNAME " ");
248 1 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MLIMLOW " ");
249 1 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_ME " ");
250 1 : HandleNode(pNode->GetSymbol(), nLevel + 1);
251 1 : m_pBuffer->append("}"); // me
252 1 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MLIM " ");
253 1 : if (const SmSubSupNode* subsup = pNode->GetSubNode(0)->GetType() == NSUBSUP ? static_cast<const SmSubSupNode*>(pNode->GetSubNode(0)) : 0)
254 1 : if (subsup->GetSubSup(CSUB))
255 1 : HandleNode(subsup->GetSubSup(CSUB), nLevel + 1);
256 1 : m_pBuffer->append("}"); // mlim
257 1 : m_pBuffer->append("}"); // mlimLow
258 1 : m_pBuffer->append("}"); // mfName
259 1 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_ME " ");
260 1 : HandleNode(pNode->GetSubNode(1), nLevel + 1); // body
261 1 : m_pBuffer->append("}"); // me
262 1 : m_pBuffer->append("}"); // mfunc
263 1 : break;
264 : default:
265 : SAL_INFO("starmath.rtf", "TODO: " << OSL_THIS_FUNC << " unhandled oper type");
266 0 : break;
267 : }
268 9 : }
269 :
270 27 : void SmRtfExport::HandleSubSupScriptInternal(const SmSubSupNode* pNode, int nLevel, int flags)
271 : {
272 : // rtf supports only a certain combination of sub/super scripts, but LO can have any,
273 : // so try to merge it using several tags if necessary
274 27 : if (flags == 0) // none
275 27 : return;
276 27 : if ((flags & (1 << RSUP | 1 << RSUB)) == (1 << RSUP | 1 << RSUB))
277 : {
278 : // m:sSubSup
279 2 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MSSUBSUP " ");
280 2 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_ME " ");
281 2 : flags &= ~(1 << RSUP | 1 << RSUB);
282 2 : if (flags == 0)
283 2 : HandleNode(pNode->GetBody(), nLevel + 1);
284 : else
285 0 : HandleSubSupScriptInternal(pNode, nLevel, flags);
286 2 : m_pBuffer->append("}"); // me
287 2 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MSUB " ");
288 2 : HandleNode(pNode->GetSubSup(RSUB), nLevel + 1);
289 2 : m_pBuffer->append("}"); // msub
290 2 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MSUP " ");
291 2 : HandleNode(pNode->GetSubSup(RSUP), nLevel + 1);
292 2 : m_pBuffer->append("}"); // msup
293 2 : m_pBuffer->append("}"); // msubSup
294 : }
295 25 : else if ((flags & (1 << RSUB)) == 1 << RSUB)
296 : {
297 : // m:sSub
298 4 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MSSUB " ");
299 4 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_ME " ");
300 4 : flags &= ~(1 << RSUB);
301 4 : if (flags == 0)
302 4 : HandleNode(pNode->GetBody(), nLevel + 1);
303 : else
304 0 : HandleSubSupScriptInternal(pNode, nLevel, flags);
305 4 : m_pBuffer->append("}"); // me
306 4 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MSUB " ");
307 4 : HandleNode(pNode->GetSubSup(RSUB), nLevel + 1);
308 4 : m_pBuffer->append("}"); // msub
309 4 : m_pBuffer->append("}"); // msSub
310 : }
311 21 : else if ((flags & (1 << RSUP)) == 1 << RSUP)
312 : {
313 : // m:sSup
314 17 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MSSUP " ");
315 17 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_ME " ");
316 17 : flags &= ~(1 << RSUP);
317 17 : if (flags == 0)
318 17 : HandleNode(pNode->GetBody(), nLevel + 1);
319 : else
320 0 : HandleSubSupScriptInternal(pNode, nLevel, flags);
321 17 : m_pBuffer->append("}"); // me
322 17 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MSUP " ");
323 17 : HandleNode(pNode->GetSubSup(RSUP), nLevel + 1);
324 17 : m_pBuffer->append("}"); // msup
325 17 : m_pBuffer->append("}"); // msSup
326 : }
327 4 : else if ((flags & (1 << LSUP | 1 << LSUB)) == (1 << LSUP | 1 << LSUB))
328 : {
329 : // m:sPre
330 2 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MSPRE " ");
331 2 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MSUB " ");
332 2 : HandleNode(pNode->GetSubSup(LSUB), nLevel + 1);
333 2 : m_pBuffer->append("}"); // msub
334 2 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MSUP " ");
335 2 : HandleNode(pNode->GetSubSup(LSUP), nLevel + 1);
336 2 : m_pBuffer->append("}"); // msup
337 2 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_ME " ");
338 2 : flags &= ~(1 << LSUP | 1 << LSUB);
339 2 : if (flags == 0)
340 2 : HandleNode(pNode->GetBody(), nLevel + 1);
341 : else
342 0 : HandleSubSupScriptInternal(pNode, nLevel, flags);
343 2 : m_pBuffer->append("}"); // me
344 2 : m_pBuffer->append("}"); // msPre
345 : }
346 2 : else if ((flags & (1 << CSUB)) == (1 << CSUB))
347 : {
348 : // m:limLow looks like a good element for central superscript
349 1 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MLIMLOW " ");
350 1 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_ME " ");
351 1 : flags &= ~(1 << CSUB);
352 1 : if (flags == 0)
353 0 : HandleNode(pNode->GetBody(), nLevel + 1);
354 : else
355 1 : HandleSubSupScriptInternal(pNode, nLevel, flags);
356 1 : m_pBuffer->append("}"); // me
357 1 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MLIM " ");
358 1 : HandleNode(pNode->GetSubSup(CSUB), nLevel + 1);
359 1 : m_pBuffer->append("}"); // mlim
360 1 : m_pBuffer->append("}"); // mlimLow
361 : }
362 1 : else if ((flags & (1 << CSUP)) == (1 << CSUP))
363 : {
364 : // m:limUpp looks like a good element for central superscript
365 1 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MLIMUPP " ");
366 1 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_ME " ");
367 1 : flags &= ~(1 << CSUP);
368 1 : if (flags == 0)
369 1 : HandleNode(pNode->GetBody(), nLevel + 1);
370 : else
371 0 : HandleSubSupScriptInternal(pNode, nLevel, flags);
372 1 : m_pBuffer->append("}"); // me
373 1 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MLIM " ");
374 1 : HandleNode(pNode->GetSubSup(CSUP), nLevel + 1);
375 1 : m_pBuffer->append("}"); // mlim
376 1 : m_pBuffer->append("}"); // mlimUpp
377 : }
378 : else
379 : SAL_INFO("starmath.rtf", "TODO: " << OSL_THIS_FUNC << " unhandled subsup type");
380 : }
381 :
382 1 : void SmRtfExport::HandleMatrix(const SmMatrixNode* pNode, int nLevel)
383 : {
384 1 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MM " ");
385 3 : for (int row = 0; row < pNode->GetNumRows(); ++row)
386 : {
387 2 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MMR " ");
388 6 : for (int col = 0; col < pNode->GetNumCols(); ++col)
389 : {
390 4 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_ME " ");
391 4 : if (const SmNode* node = pNode->GetSubNode(row * pNode->GetNumCols() + col))
392 4 : HandleNode(node, nLevel + 1);
393 4 : m_pBuffer->append("}"); // me
394 : }
395 2 : m_pBuffer->append("}"); // mmr
396 : }
397 1 : m_pBuffer->append("}"); // mm
398 1 : }
399 :
400 23 : void SmRtfExport::HandleBrace(const SmBraceNode* pNode, int nLevel)
401 : {
402 23 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MD " ");
403 23 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MDPR " ");
404 23 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MBEGCHR " ");
405 23 : m_pBuffer->append(mathSymbolToString(pNode->OpeningBrace(), m_nEncoding));
406 23 : m_pBuffer->append("}"); // mbegChr
407 23 : std::vector< const SmNode* > subnodes;
408 23 : if (pNode->Body()->GetType() == NBRACEBODY)
409 : {
410 23 : const SmBracebodyNode* body = static_cast<const SmBracebodyNode*>(pNode->Body());
411 23 : bool separatorWritten = false; // assume all separators are the same
412 50 : for (int i = 0; i < body->GetNumSubNodes(); ++i)
413 : {
414 27 : const SmNode* subnode = body->GetSubNode(i);
415 27 : if (subnode->GetType() == NMATH || subnode->GetType() == NMATHIDENT)
416 : {
417 : // do not write, but write what separator it is
418 3 : const SmMathSymbolNode* math = static_cast<const SmMathSymbolNode*>(subnode);
419 3 : if (!separatorWritten)
420 : {
421 2 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MSEPCHR " ");
422 2 : m_pBuffer->append(mathSymbolToString(math, m_nEncoding));
423 2 : m_pBuffer->append("}"); // msepChr
424 2 : separatorWritten = true;
425 : }
426 : }
427 : else
428 24 : subnodes.push_back(subnode);
429 : }
430 : }
431 : else
432 0 : subnodes.push_back(pNode->Body());
433 23 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MENDCHR " ");
434 23 : m_pBuffer->append(mathSymbolToString(pNode->ClosingBrace(), m_nEncoding));
435 23 : m_pBuffer->append("}"); // mendChr
436 23 : m_pBuffer->append("}"); // mdPr
437 47 : for (unsigned int i = 0; i < subnodes.size(); ++i)
438 : {
439 24 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_ME " ");
440 24 : HandleNode(subnodes[ i ], nLevel + 1);
441 24 : m_pBuffer->append("}"); // me
442 : }
443 23 : m_pBuffer->append("}"); // md
444 23 : }
445 :
446 2 : void SmRtfExport::HandleVerticalBrace(const SmVerticalBraceNode* pNode, int nLevel)
447 : {
448 : SAL_INFO("starmath.rtf", "Vertical: " << int(pNode->GetToken().eType));
449 2 : switch (pNode->GetToken().eType)
450 : {
451 : case TOVERBRACE:
452 : case TUNDERBRACE:
453 : {
454 2 : bool top = (pNode->GetToken().eType == TOVERBRACE);
455 2 : if (top)
456 1 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MLIMUPP " ");
457 : else
458 1 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MLIMLOW " ");
459 2 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_ME " ");
460 2 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MGROUPCHR " ");
461 2 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MGROUPCHRPR " ");
462 2 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MCHR " ");
463 2 : m_pBuffer->append(mathSymbolToString(pNode->Brace(), m_nEncoding));
464 2 : m_pBuffer->append("}"); // mchr
465 : // TODO not sure if pos and vertJc are correct
466 2 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MPOS " ").append(top ? "top" : "bot").append("}");
467 2 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MVERTJC " ").append(top ? "bot" : "top").append("}");
468 2 : m_pBuffer->append("}"); // mgroupChrPr
469 2 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_ME " ");
470 2 : HandleNode(pNode->Body(), nLevel + 1);
471 2 : m_pBuffer->append("}"); // me
472 2 : m_pBuffer->append("}"); // mgroupChr
473 2 : m_pBuffer->append("}"); // me
474 2 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MLIM " ");
475 2 : HandleNode(pNode->Script(), nLevel + 1);
476 2 : m_pBuffer->append("}"); // mlim
477 2 : m_pBuffer->append("}"); // mlimUpp or mlimLow
478 2 : break;
479 : }
480 : default:
481 : SAL_INFO("starmath.rtf", "TODO: " << OSL_THIS_FUNC << " unhandled vertical brace type");
482 0 : break;
483 : }
484 2 : }
485 :
486 0 : void SmRtfExport::HandleBlank()
487 : {
488 0 : m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MR " ");
489 0 : m_pBuffer->append(" ");
490 0 : m_pBuffer->append("}"); // mr
491 0 : }
492 :
493 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|