1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
11 #include "ooxmlexport.hxx"
13 #include <oox/token/tokens.hxx>
14 #include <rtl/ustring.hxx>
17 using namespace oox::core
;
19 SmOoxmlExport::SmOoxmlExport( const SmNode
* pIn
, OoxmlVersion v
)
20 : SmWordExportBase( pIn
)
25 bool SmOoxmlExport::ConvertFromStarMath( ::sax_fastparser::FSHelperPtr serializer
)
29 m_pSerializer
= serializer
;
30 m_pSerializer
->startElementNS( XML_m
, XML_oMath
,
31 FSNS( XML_xmlns
, XML_m
), "http://schemas.openxmlformats.org/officeDocument/2006/math", FSEND
);
32 HandleNode( m_pTree
, 0 );
33 m_pSerializer
->endElementNS( XML_m
, XML_oMath
);
37 // NOTE: This is still work in progress and unfinished, but it already covers a good
38 // part of the ooxml math stuff.
40 void SmOoxmlExport::HandleVerticalStack( const SmNode
* pNode
, int nLevel
)
42 m_pSerializer
->startElementNS( XML_m
, XML_eqArr
, FSEND
);
43 int size
= pNode
->GetNumSubNodes();
48 m_pSerializer
->startElementNS( XML_m
, XML_e
, FSEND
);
49 HandleNode( pNode
->GetSubNode( i
), nLevel
+ 1 );
50 m_pSerializer
->endElementNS( XML_m
, XML_e
);
52 m_pSerializer
->endElementNS( XML_m
, XML_eqArr
);
55 void SmOoxmlExport::HandleText( const SmNode
* pNode
, int /*nLevel*/)
57 m_pSerializer
->startElementNS( XML_m
, XML_r
, FSEND
);
59 if( pNode
->GetToken().eType
== TTEXT
) // literal text (in quotes)
61 m_pSerializer
->startElementNS( XML_m
, XML_rPr
, FSEND
);
62 m_pSerializer
->singleElementNS( XML_m
, XML_lit
, FSEND
);
63 m_pSerializer
->singleElementNS( XML_m
, XML_nor
, FSEND
);
64 m_pSerializer
->endElementNS( XML_m
, XML_rPr
);
66 if( version
== ECMA_DIALECT
)
67 { // HACK: MSOffice2007 does not import characters properly unless this font is explicitly given
68 m_pSerializer
->startElementNS( XML_w
, XML_rPr
, FSEND
);
69 m_pSerializer
->singleElementNS( XML_w
, XML_rFonts
, FSNS( XML_w
, XML_ascii
), "Cambria Math",
70 FSNS( XML_w
, XML_hAnsi
), "Cambria Math", FSEND
);
71 m_pSerializer
->endElementNS( XML_w
, XML_rPr
);
73 m_pSerializer
->startElementNS( XML_m
, XML_t
, FSNS( XML_xml
, XML_space
), "preserve", FSEND
);
74 SmTextNode
* pTemp
=(SmTextNode
* )pNode
;
75 SAL_INFO( "starmath.ooxml", "Text:" << OUStringToOString( pTemp
->GetText(), RTL_TEXTENCODING_UTF8
).getStr());
76 for(sal_Int32 i
=0;i
<pTemp
->GetText().getLength();i
++)
79 if ((nPendingAttributes
) &&
80 (i
== ((pTemp
->GetText().getLength()+1)/2)-1))
82 *pS
<< sal_uInt8(0x22); //char, with attributes right
86 *pS
<< sal_uInt8(CHAR
);
88 sal_uInt8 nFace
= 0x1;
89 if (pNode
->GetFont().GetItalic() == ITALIC_NORMAL
)
91 else if (pNode
->GetFont().GetWeight() == WEIGHT_BOLD
)
93 *pS
<< sal_uInt8(nFace
+128); //typeface
95 sal_uInt16 nChar
= pTemp
->GetText()[i
];
96 m_pSerializer
->writeEscaped( OUString( SmTextNode::ConvertSymbolToUnicode(nChar
)));
99 //Mathtype can only have these sort of character
100 //attributes on a single character, starmath can put them
101 //anywhere, when the entity involved is a text run this is
102 //a large effort to place the character attribute on the
103 //central mathtype character so that it does pretty much
104 //what the user probably has in mind. The attributes
105 //filled in here are dummy ones which are replaced in the
106 //ATTRIBUT handler if a suitable location for the
107 //attributes was found here. Unfortunately it is
108 //possible for starmath to place character attributes on
109 //entities which cannot occur in mathtype e.g. a Summation
110 //symbol so these attributes may be lost
111 if ((nPendingAttributes
) &&
112 (i
== ((pTemp
->GetText().getLength()+1)/2)-1))
114 *pS
<< sal_uInt8(EMBEL
);
115 while (nPendingAttributes
)
118 //wedge the attributes in here and clear
120 nPendingAttributes
--;
122 nInsertion
=pS
->Tell();
123 *pS
<< sal_uInt8(END
); //end embel
124 *pS
<< sal_uInt8(END
); //end embel
128 m_pSerializer
->endElementNS( XML_m
, XML_t
);
129 m_pSerializer
->endElementNS( XML_m
, XML_r
);
132 void SmOoxmlExport::HandleFractions( const SmNode
* pNode
, int nLevel
, const char* type
)
134 m_pSerializer
->startElementNS( XML_m
, XML_f
, FSEND
);
137 m_pSerializer
->startElementNS( XML_m
, XML_fPr
, FSEND
);
138 m_pSerializer
->singleElementNS( XML_m
, XML_type
, FSNS( XML_m
, XML_val
), type
, FSEND
);
139 m_pSerializer
->endElementNS( XML_m
, XML_fPr
);
141 OSL_ASSERT( pNode
->GetNumSubNodes() == 3 );
142 m_pSerializer
->startElementNS( XML_m
, XML_num
, FSEND
);
143 HandleNode( pNode
->GetSubNode( 0 ), nLevel
+ 1 );
144 m_pSerializer
->endElementNS( XML_m
, XML_num
);
145 m_pSerializer
->startElementNS( XML_m
, XML_den
, FSEND
);
146 HandleNode( pNode
->GetSubNode( 2 ), nLevel
+ 1 );
147 m_pSerializer
->endElementNS( XML_m
, XML_den
);
148 m_pSerializer
->endElementNS( XML_m
, XML_f
);
151 void SmOoxmlExport::HandleAttribute( const SmAttributNode
* pNode
, int nLevel
)
153 switch( pNode
->Attribute()->GetToken().eType
)
171 m_pSerializer
->startElementNS( XML_m
, XML_acc
, FSEND
);
172 m_pSerializer
->startElementNS( XML_m
, XML_accPr
, FSEND
);
173 OString value
= OUStringToOString(
174 OUString( pNode
->Attribute()->GetToken().cMathChar
), RTL_TEXTENCODING_UTF8
);
175 m_pSerializer
->singleElementNS( XML_m
, XML_chr
, FSNS( XML_m
, XML_val
), value
.getStr(), FSEND
);
176 m_pSerializer
->endElementNS( XML_m
, XML_accPr
);
177 m_pSerializer
->startElementNS( XML_m
, XML_e
, FSEND
);
178 HandleNode( pNode
->Body(), nLevel
+ 1 );
179 m_pSerializer
->endElementNS( XML_m
, XML_e
);
180 m_pSerializer
->endElementNS( XML_m
, XML_acc
);
185 m_pSerializer
->startElementNS( XML_m
, XML_bar
, FSEND
);
186 m_pSerializer
->startElementNS( XML_m
, XML_barPr
, FSEND
);
187 m_pSerializer
->singleElementNS( XML_m
, XML_pos
, FSNS( XML_m
, XML_val
),
188 ( pNode
->Attribute()->GetToken().eType
== TUNDERLINE
) ? "bot" : "top", FSEND
);
189 m_pSerializer
->endElementNS( XML_m
, XML_barPr
);
190 m_pSerializer
->startElementNS( XML_m
, XML_e
, FSEND
);
191 HandleNode( pNode
->Body(), nLevel
+ 1 );
192 m_pSerializer
->endElementNS( XML_m
, XML_e
);
193 m_pSerializer
->endElementNS( XML_m
, XML_bar
);
196 m_pSerializer
->startElementNS( XML_m
, XML_borderBox
, FSEND
);
197 m_pSerializer
->startElementNS( XML_m
, XML_borderBoxPr
, FSEND
);
198 m_pSerializer
->singleElementNS( XML_m
, XML_hideTop
, FSNS( XML_m
, XML_val
), "1", FSEND
);
199 m_pSerializer
->singleElementNS( XML_m
, XML_hideBot
, FSNS( XML_m
, XML_val
), "1", FSEND
);
200 m_pSerializer
->singleElementNS( XML_m
, XML_hideLeft
, FSNS( XML_m
, XML_val
), "1", FSEND
);
201 m_pSerializer
->singleElementNS( XML_m
, XML_hideRight
, FSNS( XML_m
, XML_val
), "1", FSEND
);
202 m_pSerializer
->singleElementNS( XML_m
, XML_strikeH
, FSNS( XML_m
, XML_val
), "1", FSEND
);
203 m_pSerializer
->endElementNS( XML_m
, XML_borderBoxPr
);
204 m_pSerializer
->startElementNS( XML_m
, XML_e
, FSEND
);
205 HandleNode( pNode
->Body(), nLevel
+ 1 );
206 m_pSerializer
->endElementNS( XML_m
, XML_e
);
207 m_pSerializer
->endElementNS( XML_m
, XML_borderBox
);
210 HandleAllSubNodes( pNode
, nLevel
);
215 void SmOoxmlExport::HandleRoot( const SmRootNode
* pNode
, int nLevel
)
217 m_pSerializer
->startElementNS( XML_m
, XML_rad
, FSEND
);
218 if( const SmNode
* argument
= pNode
->Argument())
220 m_pSerializer
->startElementNS( XML_m
, XML_deg
, FSEND
);
221 HandleNode( argument
, nLevel
+ 1 );
222 m_pSerializer
->endElementNS( XML_m
, XML_deg
);
226 m_pSerializer
->startElementNS( XML_m
, XML_radPr
, FSEND
);
227 m_pSerializer
->singleElementNS( XML_m
, XML_degHide
, FSNS( XML_m
, XML_val
), "1", FSEND
);
228 m_pSerializer
->endElementNS( XML_m
, XML_radPr
);
229 m_pSerializer
->singleElementNS( XML_m
, XML_deg
, FSEND
); // empty but present
231 m_pSerializer
->startElementNS( XML_m
, XML_e
, FSEND
);
232 HandleNode( pNode
->Body(), nLevel
+ 1 );
233 m_pSerializer
->endElementNS( XML_m
, XML_e
);
234 m_pSerializer
->endElementNS( XML_m
, XML_rad
);
237 static OString
mathSymbolToString( const SmNode
* node
)
239 assert( node
->GetType() == NMATH
);
240 const SmTextNode
* txtnode
= static_cast< const SmTextNode
* >( node
);
241 assert( txtnode
->GetText().getLength() == 1 );
242 sal_Unicode chr
= SmTextNode::ConvertSymbolToUnicode( txtnode
->GetText()[0] );
243 return OUStringToOString( OUString( chr
), RTL_TEXTENCODING_UTF8
);
246 void SmOoxmlExport::HandleOperator( const SmOperNode
* pNode
, int nLevel
)
248 SAL_INFO( "starmath.ooxml", "Operator: " << int( pNode
->GetToken().eType
));
249 switch( pNode
->GetToken().eType
)
261 const SmSubSupNode
* subsup
= pNode
->GetSubNode( 0 )->GetType() == NSUBSUP
262 ? static_cast< const SmSubSupNode
* >( pNode
->GetSubNode( 0 )) : NULL
;
263 const SmNode
* operation
= subsup
!= NULL
? subsup
->GetBody() : pNode
->GetSubNode( 0 );
264 m_pSerializer
->startElementNS( XML_m
, XML_nary
, FSEND
);
265 m_pSerializer
->startElementNS( XML_m
, XML_naryPr
, FSEND
);
266 m_pSerializer
->singleElementNS( XML_m
, XML_chr
,
267 FSNS( XML_m
, XML_val
), mathSymbolToString( operation
).getStr(), FSEND
);
268 if( subsup
== NULL
|| subsup
->GetSubSup( CSUB
) == NULL
)
269 m_pSerializer
->singleElementNS( XML_m
, XML_subHide
, FSNS( XML_m
, XML_val
), "1", FSEND
);
270 if( subsup
== NULL
|| subsup
->GetSubSup( CSUP
) == NULL
)
271 m_pSerializer
->singleElementNS( XML_m
, XML_supHide
, FSNS( XML_m
, XML_val
), "1", FSEND
);
272 m_pSerializer
->endElementNS( XML_m
, XML_naryPr
);
273 if( subsup
== NULL
|| subsup
->GetSubSup( CSUB
) == NULL
)
274 m_pSerializer
->singleElementNS( XML_m
, XML_sub
, FSEND
);
277 m_pSerializer
->startElementNS( XML_m
, XML_sub
, FSEND
);
278 HandleNode( subsup
->GetSubSup( CSUB
), nLevel
+ 1 );
279 m_pSerializer
->endElementNS( XML_m
, XML_sub
);
281 if( subsup
== NULL
|| subsup
->GetSubSup( CSUP
) == NULL
)
282 m_pSerializer
->singleElementNS( XML_m
, XML_sup
, FSEND
);
285 m_pSerializer
->startElementNS( XML_m
, XML_sup
, FSEND
);
286 HandleNode( subsup
->GetSubSup( CSUP
), nLevel
+ 1 );
287 m_pSerializer
->endElementNS( XML_m
, XML_sup
);
289 m_pSerializer
->startElementNS( XML_m
, XML_e
, FSEND
);
290 HandleNode( pNode
->GetSubNode( 1 ), nLevel
+ 1 ); // body
291 m_pSerializer
->endElementNS( XML_m
, XML_e
);
292 m_pSerializer
->endElementNS( XML_m
, XML_nary
);
296 m_pSerializer
->startElementNS( XML_m
, XML_func
, FSEND
);
297 m_pSerializer
->startElementNS( XML_m
, XML_fName
, FSEND
);
298 m_pSerializer
->startElementNS( XML_m
, XML_limLow
, FSEND
);
299 m_pSerializer
->startElementNS( XML_m
, XML_e
, FSEND
);
300 HandleNode( pNode
->GetSymbol(), nLevel
+ 1 );
301 m_pSerializer
->endElementNS( XML_m
, XML_e
);
302 m_pSerializer
->startElementNS( XML_m
, XML_lim
, FSEND
);
303 if( const SmSubSupNode
* subsup
= pNode
->GetSubNode( 0 )->GetType() == NSUBSUP
304 ? static_cast< const SmSubSupNode
* >( pNode
->GetSubNode( 0 )) : NULL
)
306 if( subsup
->GetSubSup( CSUB
) != NULL
)
307 HandleNode( subsup
->GetSubSup( CSUB
), nLevel
+ 1 );
309 m_pSerializer
->endElementNS( XML_m
, XML_lim
);
310 m_pSerializer
->endElementNS( XML_m
, XML_limLow
);
311 m_pSerializer
->endElementNS( XML_m
, XML_fName
);
312 m_pSerializer
->startElementNS( XML_m
, XML_e
, FSEND
);
313 HandleNode( pNode
->GetSubNode( 1 ), nLevel
+ 1 ); // body
314 m_pSerializer
->endElementNS( XML_m
, XML_e
);
315 m_pSerializer
->endElementNS( XML_m
, XML_func
);
318 OSL_FAIL( "Unhandled operation" );
319 HandleAllSubNodes( pNode
, nLevel
);
324 void SmOoxmlExport::HandleSubSupScriptInternal( const SmSubSupNode
* pNode
, int nLevel
, int flags
)
326 // docx supports only a certain combination of sub/super scripts, but LO can have any,
327 // so try to merge it using several tags if necessary
328 if( flags
== 0 ) // none
330 if(( flags
& ( 1 << RSUP
| 1 << RSUB
)) == ( 1 << RSUP
| 1 << RSUB
))
332 m_pSerializer
->startElementNS( XML_m
, XML_sSubSup
, FSEND
);
333 m_pSerializer
->startElementNS( XML_m
, XML_e
, FSEND
);
334 flags
&= ~( 1 << RSUP
| 1 << RSUB
);
336 HandleNode( pNode
->GetBody(), nLevel
+ 1 );
338 HandleSubSupScriptInternal( pNode
, nLevel
, flags
);
339 m_pSerializer
->endElementNS( XML_m
, XML_e
);
340 m_pSerializer
->startElementNS( XML_m
, XML_sub
, FSEND
);
341 HandleNode( pNode
->GetSubSup( RSUB
), nLevel
+ 1 );
342 m_pSerializer
->endElementNS( XML_m
, XML_sub
);
343 m_pSerializer
->startElementNS( XML_m
, XML_sup
, FSEND
);
344 HandleNode( pNode
->GetSubSup( RSUP
), nLevel
+ 1 );
345 m_pSerializer
->endElementNS( XML_m
, XML_sup
);
346 m_pSerializer
->endElementNS( XML_m
, XML_sSubSup
);
348 else if(( flags
& ( 1 << RSUB
)) == 1 << RSUB
)
350 m_pSerializer
->startElementNS( XML_m
, XML_sSub
, FSEND
);
351 m_pSerializer
->startElementNS( XML_m
, XML_e
, FSEND
);
352 flags
&= ~( 1 << RSUB
);
354 HandleNode( pNode
->GetBody(), nLevel
+ 1 );
356 HandleSubSupScriptInternal( pNode
, nLevel
, flags
);
357 m_pSerializer
->endElementNS( XML_m
, XML_e
);
358 m_pSerializer
->startElementNS( XML_m
, XML_sub
, FSEND
);
359 HandleNode( pNode
->GetSubSup( RSUB
), nLevel
+ 1 );
360 m_pSerializer
->endElementNS( XML_m
, XML_sub
);
361 m_pSerializer
->endElementNS( XML_m
, XML_sSub
);
363 else if(( flags
& ( 1 << RSUP
)) == 1 << RSUP
)
365 m_pSerializer
->startElementNS( XML_m
, XML_sSup
, FSEND
);
366 m_pSerializer
->startElementNS( XML_m
, XML_e
, FSEND
);
367 flags
&= ~( 1 << RSUP
);
369 HandleNode( pNode
->GetBody(), nLevel
+ 1 );
371 HandleSubSupScriptInternal( pNode
, nLevel
, flags
);
372 m_pSerializer
->endElementNS( XML_m
, XML_e
);
373 m_pSerializer
->startElementNS( XML_m
, XML_sup
, FSEND
);
374 HandleNode( pNode
->GetSubSup( RSUP
), nLevel
+ 1 );
375 m_pSerializer
->endElementNS( XML_m
, XML_sup
);
376 m_pSerializer
->endElementNS( XML_m
, XML_sSup
);
378 else if(( flags
& ( 1 << LSUP
| 1 << LSUB
)) == ( 1 << LSUP
| 1 << LSUB
))
380 m_pSerializer
->startElementNS( XML_m
, XML_sPre
, FSEND
);
381 m_pSerializer
->startElementNS( XML_m
, XML_sub
, FSEND
);
382 HandleNode( pNode
->GetSubSup( LSUB
), nLevel
+ 1 );
383 m_pSerializer
->endElementNS( XML_m
, XML_sub
);
384 m_pSerializer
->startElementNS( XML_m
, XML_sup
, FSEND
);
385 HandleNode( pNode
->GetSubSup( LSUP
), nLevel
+ 1 );
386 m_pSerializer
->endElementNS( XML_m
, XML_sup
);
387 m_pSerializer
->startElementNS( XML_m
, XML_e
, FSEND
);
388 flags
&= ~( 1 << LSUP
| 1 << LSUB
);
390 HandleNode( pNode
->GetBody(), nLevel
+ 1 );
392 HandleSubSupScriptInternal( pNode
, nLevel
, flags
);
393 m_pSerializer
->endElementNS( XML_m
, XML_e
);
394 m_pSerializer
->endElementNS( XML_m
, XML_sPre
);
396 else if(( flags
& ( 1 << CSUB
)) == ( 1 << CSUB
))
397 { // m:limLow looks like a good element for central superscript
398 m_pSerializer
->startElementNS( XML_m
, XML_limLow
, FSEND
);
399 m_pSerializer
->startElementNS( XML_m
, XML_e
, FSEND
);
400 flags
&= ~( 1 << CSUB
);
402 HandleNode( pNode
->GetBody(), nLevel
+ 1 );
404 HandleSubSupScriptInternal( pNode
, nLevel
, flags
);
405 m_pSerializer
->endElementNS( XML_m
, XML_e
);
406 m_pSerializer
->startElementNS( XML_m
, XML_lim
, FSEND
);
407 HandleNode( pNode
->GetSubSup( CSUB
), nLevel
+ 1 );
408 m_pSerializer
->endElementNS( XML_m
, XML_lim
);
409 m_pSerializer
->endElementNS( XML_m
, XML_limLow
);
411 else if(( flags
& ( 1 << CSUP
)) == ( 1 << CSUP
))
412 { // m:limUpp looks like a good element for central superscript
413 m_pSerializer
->startElementNS( XML_m
, XML_limUpp
, FSEND
);
414 m_pSerializer
->startElementNS( XML_m
, XML_e
, FSEND
);
415 flags
&= ~( 1 << CSUP
);
417 HandleNode( pNode
->GetBody(), nLevel
+ 1 );
419 HandleSubSupScriptInternal( pNode
, nLevel
, flags
);
420 m_pSerializer
->endElementNS( XML_m
, XML_e
);
421 m_pSerializer
->startElementNS( XML_m
, XML_lim
, FSEND
);
422 HandleNode( pNode
->GetSubSup( CSUP
), nLevel
+ 1 );
423 m_pSerializer
->endElementNS( XML_m
, XML_lim
);
424 m_pSerializer
->endElementNS( XML_m
, XML_limUpp
);
428 OSL_FAIL( "Unhandled sub/sup combination" );
429 // TODO do not do anything, this should be probably an assert()
430 // HandleAllSubNodes( pNode, nLevel );
434 void SmOoxmlExport::HandleMatrix( const SmMatrixNode
* pNode
, int nLevel
)
436 m_pSerializer
->startElementNS( XML_m
, XML_m
, FSEND
);
437 for( int row
= 0; row
< pNode
->GetNumRows(); ++row
)
439 m_pSerializer
->startElementNS( XML_m
, XML_mr
, FSEND
);
440 for( int col
= 0; col
< pNode
->GetNumCols(); ++col
)
442 m_pSerializer
->startElementNS( XML_m
, XML_e
, FSEND
);
443 if( const SmNode
* node
= pNode
->GetSubNode( row
* pNode
->GetNumCols() + col
))
444 HandleNode( node
, nLevel
+ 1 );
445 m_pSerializer
->endElementNS( XML_m
, XML_e
);
447 m_pSerializer
->endElementNS( XML_m
, XML_mr
);
449 m_pSerializer
->endElementNS( XML_m
, XML_m
);
452 void SmOoxmlExport::HandleBrace( const SmBraceNode
* pNode
, int nLevel
)
454 m_pSerializer
->startElementNS( XML_m
, XML_d
, FSEND
);
455 m_pSerializer
->startElementNS( XML_m
, XML_dPr
, FSEND
);
456 m_pSerializer
->singleElementNS( XML_m
, XML_begChr
,
457 FSNS( XML_m
, XML_val
), mathSymbolToString( pNode
->OpeningBrace()).getStr(), FSEND
);
458 std::vector
< const SmNode
* > subnodes
;
459 if( pNode
->Body()->GetType() == NBRACEBODY
)
461 const SmBracebodyNode
* body
= static_cast< const SmBracebodyNode
* >( pNode
->Body());
462 bool separatorWritten
= false; // assume all separators are the same
463 for( int i
= 0; i
< body
->GetNumSubNodes(); ++i
)
465 const SmNode
* subnode
= body
->GetSubNode( i
);
466 if( subnode
->GetType() == NMATH
)
467 { // do not write, but write what separator it is
468 const SmMathSymbolNode
* math
= static_cast< const SmMathSymbolNode
* >( subnode
);
469 if( !separatorWritten
)
471 m_pSerializer
->singleElementNS( XML_m
, XML_sepChr
,
472 FSNS( XML_m
, XML_val
), mathSymbolToString( math
).getStr(), FSEND
);
473 separatorWritten
= true;
477 subnodes
.push_back( subnode
);
481 subnodes
.push_back( pNode
->Body());
482 m_pSerializer
->singleElementNS( XML_m
, XML_endChr
,
483 FSNS( XML_m
, XML_val
), mathSymbolToString( pNode
->ClosingBrace()).getStr(), FSEND
);
484 m_pSerializer
->endElementNS( XML_m
, XML_dPr
);
485 for( unsigned int i
= 0; i
< subnodes
.size(); ++i
)
487 m_pSerializer
->startElementNS( XML_m
, XML_e
, FSEND
);
488 HandleNode( subnodes
[ i
], nLevel
+ 1 );
489 m_pSerializer
->endElementNS( XML_m
, XML_e
);
491 m_pSerializer
->endElementNS( XML_m
, XML_d
);
494 void SmOoxmlExport::HandleVerticalBrace( const SmVerticalBraceNode
* pNode
, int nLevel
)
496 SAL_INFO( "starmath.ooxml", "Vertical: " << int( pNode
->GetToken().eType
));
497 switch( pNode
->GetToken().eType
)
502 bool top
= ( pNode
->GetToken().eType
== TOVERBRACE
);
503 m_pSerializer
->startElementNS( XML_m
, top
? XML_limUpp
: XML_limLow
, FSEND
);
504 m_pSerializer
->startElementNS( XML_m
, XML_e
, FSEND
);
505 m_pSerializer
->startElementNS( XML_m
, XML_groupChr
, FSEND
);
506 m_pSerializer
->startElementNS( XML_m
, XML_groupChrPr
, FSEND
);
507 m_pSerializer
->singleElementNS( XML_m
, XML_chr
,
508 FSNS( XML_m
, XML_val
), mathSymbolToString( pNode
->Brace()).getStr(), FSEND
);
509 // TODO not sure if pos and vertJc are correct
510 m_pSerializer
->singleElementNS( XML_m
, XML_pos
,
511 FSNS( XML_m
, XML_val
), top
? "top" : "bot", FSEND
);
512 m_pSerializer
->singleElementNS( XML_m
, XML_vertJc
, FSNS( XML_m
, XML_val
), top
? "bot" : "top", FSEND
);
513 m_pSerializer
->endElementNS( XML_m
, XML_groupChrPr
);
514 m_pSerializer
->startElementNS( XML_m
, XML_e
, FSEND
);
515 HandleNode( pNode
->Body(), nLevel
+ 1 );
516 m_pSerializer
->endElementNS( XML_m
, XML_e
);
517 m_pSerializer
->endElementNS( XML_m
, XML_groupChr
);
518 m_pSerializer
->endElementNS( XML_m
, XML_e
);
519 m_pSerializer
->startElementNS( XML_m
, XML_lim
, FSEND
);
520 HandleNode( pNode
->Script(), nLevel
+ 1 );
521 m_pSerializer
->endElementNS( XML_m
, XML_lim
);
522 m_pSerializer
->endElementNS( XML_m
, top
? XML_limUpp
: XML_limLow
);
526 OSL_FAIL( "Unhandled vertical brace" );
527 HandleAllSubNodes( pNode
, nLevel
);
532 void SmOoxmlExport::HandleBlank()
534 m_pSerializer
->startElementNS( XML_m
, XML_r
, FSEND
);
535 m_pSerializer
->startElementNS( XML_m
, XML_t
, FSNS( XML_xml
, XML_space
), "preserve", FSEND
);
536 m_pSerializer
->write( " " );
537 m_pSerializer
->endElementNS( XML_m
, XML_t
);
538 m_pSerializer
->endElementNS( XML_m
, XML_r
);
541 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */