diff options
author | Luboš Luňák <l.lunak@suse.cz> | 2011-08-29 18:20:11 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@suse.cz> | 2011-08-30 16:56:35 +0200 |
commit | 3c923d989fffb77a88d0e754c9a7fe7e0901c67f (patch) | |
tree | 71fa03a5a88f1b4b19a0b7177bfeefef3772f139 /starmath | |
parent | f7d71e379edf2c29d53182458342d7a5ce1446d6 (diff) |
implement math .docx support for integrals and limits
Diffstat (limited to 'starmath')
-rw-r--r-- | starmath/source/ooxml.cxx | 71 | ||||
-rw-r--r-- | starmath/source/ooxml.hxx | 6 |
2 files changed, 73 insertions, 4 deletions
diff --git a/starmath/source/ooxml.cxx b/starmath/source/ooxml.cxx index aea6e09c64be..00df7f7cc336 100644 --- a/starmath/source/ooxml.cxx +++ b/starmath/source/ooxml.cxx @@ -111,10 +111,10 @@ void SmOoxml::HandleNode( const SmNode* pNode, int nLevel ) case NBRACE: HandleBrace(pNode,nLevel); break; +#endif case NOPER: - HandleOperator(pNode,nLevel); + HandleOperator( static_cast< const SmOperNode* >( pNode ), nLevel ); break; -#endif case NUNHOR: HandleUnaryOperation( static_cast< const SmUnHorNode* >( pNode ), nLevel ); break; @@ -424,6 +424,73 @@ void SmOoxml::HandleRoot( const SmRootNode* pNode, int nLevel ) m_pSerializer->endElementNS( XML_m, XML_rad ); } +void SmOoxml::HandleOperator( const SmOperNode* pNode, int nLevel ) +{ + fprintf( stderr, "OPER %d\n", pNode->GetToken().eType ); + switch( pNode->GetToken().eType ) + { + case TINT: + HandleOperatorNary( pNode, nLevel, sal_Unicode( 0x222b )); + break; + case TIINT: + HandleOperatorNary( pNode, nLevel, sal_Unicode( 0x222c )); + break; + case TIIINT: + HandleOperatorNary( pNode, nLevel, sal_Unicode( 0x222d )); + break; + case TLINT: + HandleOperatorNary( pNode, nLevel, sal_Unicode( 0x222e )); + break; + case TLLINT: + HandleOperatorNary( pNode, nLevel, sal_Unicode( 0x222f )); + break; + case TLLLINT: + HandleOperatorNary( pNode, nLevel, sal_Unicode( 0x2230 )); + break; + default: + OSL_FAIL( "Operator not handled explicitly" ); + HandleAllSubNodes( pNode, nLevel ); + break; + } +} + +void SmOoxml::HandleOperatorNary( const SmOperNode* pNode, int nLevel, sal_Unicode chr ) +{ + m_pSerializer->startElementNS( XML_m, XML_nary, FSEND ); + m_pSerializer->startElementNS( XML_m, XML_naryPr, FSEND ); + rtl::OString chrValue = rtl::OUStringToOString( rtl::OUString( chr ), RTL_TEXTENCODING_UTF8 ); + m_pSerializer->singleElementNS( XML_m, XML_char, FSNS( XML_m, XML_val ), chrValue.getStr(), FSEND ); + const SmSubSupNode* subsup = pNode->GetSubNode( 0 )->GetType() == NSUBSUP + ? static_cast< const SmSubSupNode* >( pNode->GetSubNode( 0 )) : NULL; +// GetSubNode( 0 ) is otherwise generally ignored, as it should be just SmMathSymbolNode for the operation, +// and we have 'chr' already + if( subsup == NULL || subsup->GetSubSup( CSUB ) == NULL ) + m_pSerializer->singleElementNS( XML_m, XML_subHide, FSNS( XML_m, XML_val ), "1", FSEND ); + if( subsup == NULL || subsup->GetSubSup( CSUP ) == NULL ) + m_pSerializer->singleElementNS( XML_m, XML_supHide, FSNS( XML_m, XML_val ), "1", FSEND ); + m_pSerializer->endElementNS( XML_m, XML_naryPr ); + if( subsup == NULL || subsup->GetSubSup( CSUB ) == NULL ) + m_pSerializer->singleElementNS( XML_m, XML_sub, FSEND ); + else + { + m_pSerializer->startElementNS( XML_m, XML_sub, FSEND ); + HandleNode( subsup->GetSubSup( CSUB ), nLevel + 1 ); + m_pSerializer->endElementNS( XML_m, XML_sub ); + } + if( subsup == NULL || subsup->GetSubSup( CSUP ) == NULL ) + m_pSerializer->singleElementNS( XML_m, XML_sup, FSEND ); + else + { + m_pSerializer->startElementNS( XML_m, XML_sup, FSEND ); + HandleNode( subsup->GetSubSup( CSUP ), nLevel + 1 ); + m_pSerializer->endElementNS( XML_m, XML_sup ); + } + m_pSerializer->startElementNS( XML_m, XML_e, FSEND ); + HandleNode( pNode->GetSubNode( 1 ), nLevel + 1 ); // body + m_pSerializer->endElementNS( XML_m, XML_e ); + m_pSerializer->endElementNS( XML_m, XML_nary ); +} + void SmOoxml::HandleSubSupScript( const SmSubSupNode* pNode, int nLevel ) { // set flags to a bitfield of which sub/sup items exists diff --git a/starmath/source/ooxml.hxx b/starmath/source/ooxml.hxx index 7246a8c78fa3..12c3a3e45af5 100644 --- a/starmath/source/ooxml.hxx +++ b/starmath/source/ooxml.hxx @@ -52,8 +52,10 @@ private: void HandleFractions( const SmNode* pNode, int nLevel, const char* type = NULL ); void HandleUnaryOperation( const SmUnHorNode* pNode, int nLevel ); void HandleBinaryOperation( const SmBinHorNode* pNode, int nLevel ); - void HandleRoot( const SmRootNode* pNode,int nLevel ); - void HandleAttribute( const SmAttributNode* pNode,int nLevel ); + void HandleRoot( const SmRootNode* pNode, int nLevel ); + void HandleAttribute( const SmAttributNode* pNode, int nLevel ); + void HandleOperator( const SmOperNode* pNode, int nLevel ); + void HandleOperatorNary( const SmOperNode* pNode, int nLevel, sal_Unicode chr ); void HandleSubSupScript( const SmSubSupNode* pNode, int nLevel ); void HandleSubSupScriptInternal( const SmSubSupNode* pNode, int nLevel, int flags ); String str; |