diff options
author | Luboš Luňák <l.lunak@suse.cz> | 2011-08-30 16:54:36 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@suse.cz> | 2011-08-30 16:56:38 +0200 |
commit | 3d2b643c3c9c3185bc1b7efaef466ec681a9608c (patch) | |
tree | c9bdba6cdc541485a5d9ff3b28e2cae8b5a0b4b4 /starmath | |
parent | 5425c4a08e6428c50d22bdc54a852b8a49fbc620 (diff) |
implement math vertical brace export to .docx
Diffstat (limited to 'starmath')
-rw-r--r-- | starmath/inc/node.hxx | 35 | ||||
-rw-r--r-- | starmath/source/ooxml.cxx | 42 | ||||
-rw-r--r-- | starmath/source/ooxml.hxx | 1 |
3 files changed, 75 insertions, 3 deletions
diff --git a/starmath/inc/node.hxx b/starmath/inc/node.hxx index 8b11ce5efe50..e39046308345 100644 --- a/starmath/inc/node.hxx +++ b/starmath/inc/node.hxx @@ -1064,6 +1064,13 @@ class SmVerticalBraceNode : public SmStructureNode public: inline SmVerticalBraceNode(const SmToken &rNodeToken); + SmNode* Body(); + const SmNode* Body() const; + SmMathSymbolNode* Brace(); + const SmMathSymbolNode* Brace() const; + SmNode* Script(); + const SmNode* Script() const; + virtual void Arrange(const OutputDevice &rDev, const SmFormat &rFormat); void Accept(SmVisitor* pVisitor); }; @@ -1372,6 +1379,34 @@ inline const SmMathSymbolNode* SmBraceNode::ClosingBrace() const return const_cast< SmBraceNode* >( this )->ClosingBrace(); } +inline SmNode* SmVerticalBraceNode::Body() +{ + OSL_ASSERT( GetNumSubNodes() > 0 ); + return GetSubNode( 0 ); +} +inline const SmNode* SmVerticalBraceNode::Body() const +{ + return const_cast< SmVerticalBraceNode* >( this )->Body(); +} +inline SmMathSymbolNode* SmVerticalBraceNode::Brace() +{ + OSL_ASSERT( GetNumSubNodes() > 1 && GetSubNode( 1 )->GetType() == NMATH ); + return static_cast< SmMathSymbolNode* >( GetSubNode( 1 )); +} +inline const SmMathSymbolNode* SmVerticalBraceNode::Brace() const +{ + return const_cast< SmVerticalBraceNode* >( this )->Brace(); +} +inline SmNode* SmVerticalBraceNode::Script() +{ + OSL_ASSERT( GetNumSubNodes() > 2 ); + return GetSubNode( 2 ); +} +inline const SmNode* SmVerticalBraceNode::Script() const +{ + return const_cast< SmVerticalBraceNode* >( this )->Script(); +} + #endif diff --git a/starmath/source/ooxml.cxx b/starmath/source/ooxml.cxx index 992285cfca3f..e72d5589643a 100644 --- a/starmath/source/ooxml.cxx +++ b/starmath/source/ooxml.cxx @@ -104,11 +104,9 @@ void SmOoxml::HandleNode( const SmNode* pNode, int nLevel ) case NTEXT: HandleText(pNode,nLevel); break; -#if 0 case NVERTICAL_BRACE: - HandleVerticalBrace(pNode,nLevel); + HandleVerticalBrace( static_cast< const SmVerticalBraceNode* >( pNode ), nLevel ); break; -#endif case NBRACE: HandleBrace( static_cast< const SmBraceNode* >( pNode ), nLevel ); break; @@ -598,4 +596,42 @@ void SmOoxml::HandleBrace( const SmBraceNode* pNode, int nLevel ) m_pSerializer->endElementNS( XML_m, XML_d ); } +void SmOoxml::HandleVerticalBrace( const SmVerticalBraceNode* pNode, int nLevel ) +{ + fprintf( stderr, "VERT %d\n", pNode->GetToken().eType ); + switch( pNode->GetToken().eType ) + { + case TOVERBRACE: + case TUNDERBRACE: + { + bool top = ( pNode->GetToken().eType == TOVERBRACE ); + m_pSerializer->startElementNS( XML_m, top ? XML_limUpp : XML_limLow, FSEND ); + m_pSerializer->startElementNS( XML_m, XML_e, FSEND ); + m_pSerializer->startElementNS( XML_m, XML_groupChr, FSEND ); + m_pSerializer->startElementNS( XML_m, XML_groupChrPr, FSEND ); + m_pSerializer->singleElementNS( XML_m, XML_chr, + FSNS( XML_m, XML_val ), mathSymbolToString( pNode->Brace()).getStr(), FSEND ); + // TODO not sure if pos and vertJc are correct + m_pSerializer->singleElementNS( XML_m, XML_pos, + FSNS( XML_m, XML_val ), top ? "top" : "bot", FSEND ); + m_pSerializer->singleElementNS( XML_m, XML_vertJc, FSNS( XML_m, XML_val ), top ? "bot" : "top", FSEND ); + m_pSerializer->endElementNS( XML_m, XML_groupChrPr ); + m_pSerializer->startElementNS( XML_m, XML_e, FSEND ); + HandleNode( pNode->Body(), nLevel + 1 ); + m_pSerializer->endElementNS( XML_m, XML_e ); + m_pSerializer->endElementNS( XML_m, XML_groupChr ); + m_pSerializer->endElementNS( XML_m, XML_e ); + m_pSerializer->startElementNS( XML_m, XML_lim, FSEND ); + HandleNode( pNode->Script(), nLevel + 1 ); + m_pSerializer->endElementNS( XML_m, XML_lim ); + m_pSerializer->endElementNS( XML_m, top ? XML_limUpp : XML_limLow ); + break; + } + default: + OSL_FAIL( "Unhandled vertical brace" ); + HandleAllSubNodes( pNode, nLevel ); + break; + } +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/starmath/source/ooxml.hxx b/starmath/source/ooxml.hxx index a88d7173a0ec..1bab59b7c166 100644 --- a/starmath/source/ooxml.hxx +++ b/starmath/source/ooxml.hxx @@ -59,6 +59,7 @@ private: void HandleSubSupScriptInternal( const SmSubSupNode* pNode, int nLevel, int flags ); void HandleMatrix( const SmMatrixNode* pNode, int nLevel ); void HandleBrace( const SmBraceNode* pNode, int nLevel ); + void HandleVerticalBrace( const SmVerticalBraceNode* pNode, int nLevel ); String str; const SmNode* const pTree; ::sax_fastparser::FSHelperPtr m_pSerializer; |