diff options
author | Luboš Luňák <l.lunak@suse.cz> | 2011-08-17 15:56:07 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@suse.cz> | 2011-08-18 15:33:49 +0200 |
commit | 4ded3c11bb25368f92aaee623d3e8ca004719d9d (patch) | |
tree | e0e295d18a005f21198ba498edd8a3fb38e63589 | |
parent | c070a4d86a43984152ce44ff1d39a21ee5f9818f (diff) |
implement root support for ooxml math export
-rw-r--r-- | starmath/inc/node.hxx | 39 | ||||
-rw-r--r-- | starmath/source/ooxml.cxx | 26 | ||||
-rw-r--r-- | starmath/source/ooxml.hxx | 1 |
3 files changed, 63 insertions, 3 deletions
diff --git a/starmath/inc/node.hxx b/starmath/inc/node.hxx index 202cf2e4b538..6098322505b8 100644 --- a/starmath/inc/node.hxx +++ b/starmath/inc/node.hxx @@ -764,7 +764,7 @@ public: * 0: Argument (optional)<BR> * 1: Symbol (instance of SmRootSymbolNode)<BR> * 2: Body<BR> - * Where argument is optinal and may be NULL. + * Where argument is optional and may be NULL. */ class SmRootNode : public SmStructureNode { @@ -783,6 +783,13 @@ public: virtual void Arrange(const OutputDevice &rDev, const SmFormat &rFormat); void CreateTextFromNode(String &rText); void Accept(SmVisitor* pVisitor); + + SmNode* Argument(); + const SmNode* Argument() const; + SmRootSymbolNode* Symbol(); + const SmRootSymbolNode* Symbol() const; + SmNode* Body(); + const SmNode* Body() const; }; @@ -1221,6 +1228,36 @@ public: //////////////////////////////////////////////////////////////////////////////// + +inline SmNode* SmRootNode::Argument() +{ + OSL_ASSERT( GetNumSubNodes() > 0 ); + return GetSubNode( 0 ); +} +inline const SmNode* SmRootNode::Argument() const +{ + return const_cast< SmRootNode* >( this )->Argument(); +} +inline SmRootSymbolNode* SmRootNode::Symbol() +{ + OSL_ASSERT( GetSubNode( 0 )->GetType() == NROOTSYMBOL ); + return static_cast< SmRootSymbolNode* >( GetSubNode( 1 )); +} +inline const SmRootSymbolNode* SmRootNode::Symbol() const +{ + return const_cast< SmRootNode* >( this )->Symbol(); +} +inline SmNode* SmRootNode::Body() +{ + OSL_ASSERT( GetNumSubNodes() > 2 ); + return GetSubNode( 2 ); +} +inline const SmNode* SmRootNode::Body() const +{ + return const_cast< SmRootNode* >( this )->Body(); +} + + #endif diff --git a/starmath/source/ooxml.cxx b/starmath/source/ooxml.cxx index ae5d2f2efd1c..b5cb6c810aee 100644 --- a/starmath/source/ooxml.cxx +++ b/starmath/source/ooxml.cxx @@ -120,10 +120,10 @@ void SmOoxml::HandleNode(SmNode *pNode,int nLevel) case NBINVER: HandleFractions(pNode,nLevel); break; -#if 0 case NROOT: - HandleRoot(pNode,nLevel); + HandleRoot( static_cast< SmRootNode* >( pNode ),nLevel); break; +#if 0 case NSPECIAL: { SmTextNode *pText=(SmTextNode *)pNode; @@ -458,4 +458,26 @@ void SmOoxml::HandleBinaryOperation(SmNode *pNode,int nLevel) } } +void SmOoxml::HandleRoot(SmRootNode *pNode,int nLevel) +{ + m_pSerializer->startElementNS( XML_m, XML_rad, FSEND ); + if( SmNode* argument = pNode->Argument()) + { + m_pSerializer->startElementNS( XML_m, XML_deg, FSEND ); + HandleAllSubNodes( argument, nLevel ); + m_pSerializer->endElementNS( XML_m, XML_deg ); + } + else + { + m_pSerializer->startElementNS( XML_m, XML_radPr, FSEND ); + m_pSerializer->singleElementNS( XML_m, XML_degHide, FSNS( XML_m, XML_val ), "1", FSEND ); + m_pSerializer->endElementNS( XML_m, XML_radPr ); + m_pSerializer->singleElementNS( XML_m, XML_deg, FSEND ); // empty but present + } + m_pSerializer->startElementNS( XML_m, XML_e, FSEND ); + HandleAllSubNodes( pNode->Body(), nLevel ); + m_pSerializer->endElementNS( XML_m, XML_e ); + m_pSerializer->endElementNS( XML_m, XML_rad ); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/starmath/source/ooxml.hxx b/starmath/source/ooxml.hxx index 5b9aaff1fe9b..d6a987617f58 100644 --- a/starmath/source/ooxml.hxx +++ b/starmath/source/ooxml.hxx @@ -51,6 +51,7 @@ private: void HandleMath(SmNode *pNode,int nLevel); void HandleFractions( SmNode *pNode,int nLevel, const char* type = NULL ); void HandleBinaryOperation(SmNode *pNode,int nLevel); + void HandleRoot(SmRootNode *pNode,int nLevel); String str; SmNode *pTree; ::sax_fastparser::FSHelperPtr m_pSerializer; |