summaryrefslogtreecommitdiff
path: root/starmath
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@suse.cz>2011-08-29 19:28:08 +0200
committerLuboš Luňák <l.lunak@suse.cz>2011-08-30 16:56:35 +0200
commit61b1fb0f42f51235bb0b92da30c0d4e2d6297960 (patch)
tree893dd1ab1f290270789f61d20ff1114aaa9cb8f9 /starmath
parent3c923d989fffb77a88d0e754c9a7fe7e0901c67f (diff)
more generic m:nary implementation
Diffstat (limited to 'starmath')
-rw-r--r--starmath/source/ooxml.cxx38
-rw-r--r--starmath/source/ooxml.hxx1
2 files changed, 5 insertions, 34 deletions
diff --git a/starmath/source/ooxml.cxx b/starmath/source/ooxml.cxx
index 00df7f7cc336..aec33e973146 100644
--- a/starmath/source/ooxml.cxx
+++ b/starmath/source/ooxml.cxx
@@ -427,43 +427,15 @@ void SmOoxml::HandleRoot( const SmRootNode* pNode, int nLevel )
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 )
-{
+ const SmSubSupNode* subsup = pNode->GetSubNode( 0 )->GetType() == NSUBSUP
+ ? static_cast< const SmSubSupNode* >( pNode->GetSubNode( 0 )) : NULL;
+ const SmNode* operation = subsup != NULL ? subsup->GetBody() : pNode->GetSubNode( 0 );
+ OSL_ASSERT( operation->GetType() == NMATH && static_cast< const SmTextNode* >( operation )->GetText().Len() == 1 );
+ sal_Unicode chr = Convert( static_cast< const SmTextNode* >( operation )->GetText().GetChar( 0 ));
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 )
diff --git a/starmath/source/ooxml.hxx b/starmath/source/ooxml.hxx
index 12c3a3e45af5..dbebd37f8b11 100644
--- a/starmath/source/ooxml.hxx
+++ b/starmath/source/ooxml.hxx
@@ -55,7 +55,6 @@ private:
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;