summaryrefslogtreecommitdiff
path: root/starmath
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@suse.cz>2011-08-16 17:53:37 +0200
committerLuboš Luňák <l.lunak@suse.cz>2011-08-18 15:33:47 +0200
commitce5626277bc55c17db8322b81be1c5f2d1ad02f6 (patch)
tree661c339621cf3a4f65a03fbeb18e9926dc9ce752 /starmath
parent438b5717ab783d13ba8249c0c11d87896a5ee49b (diff)
implement x/y properly for ooxml math
Diffstat (limited to 'starmath')
-rw-r--r--starmath/source/ooxml.cxx33
-rw-r--r--starmath/source/ooxml.hxx3
2 files changed, 34 insertions, 2 deletions
diff --git a/starmath/source/ooxml.cxx b/starmath/source/ooxml.cxx
index 4e0198eeb7d4..395d84d0f3c7 100644
--- a/starmath/source/ooxml.cxx
+++ b/starmath/source/ooxml.cxx
@@ -114,6 +114,9 @@ void SmOoxml::HandleNodes(SmNode *pNode,int nLevel)
HandleOperator(pNode,nLevel);
break;
#endif
+ case NBINHOR:
+ HandleBinaryOperation(pNode,nLevel);
+ break;
case NBINVER:
HandleFractions(pNode,nLevel);
break;
@@ -295,6 +298,9 @@ void SmOoxml::HandleText(SmNode *pNode, int /*nLevel*/)
void SmOoxml::HandleMath(SmNode *pNode,int nLevel)
{
+ fprintf(stderr,"MATH %d\n", pNode->GetToken().eType);
+ // these are handled elsewhere, e.g. when handling BINHOR
+ OSL_ASSERT( pNode->GetToken().eType != TDIVIDEBY );
HandleText( pNode, nLevel );
// TODO at least some items (e.g. y/2 need to handled as ooxml and not as plain text symbols)
#if 0
@@ -405,9 +411,15 @@ void SmOoxml::HandleMath(SmNode *pNode,int nLevel)
#endif
}
-void SmOoxml::HandleFractions(SmNode *pNode,int nLevel)
+void SmOoxml::HandleFractions(SmNode *pNode,int nLevel, const char* type)
{
m_pSerializer->startElementNS( XML_m, XML_f, FSEND );
+ if( type != NULL )
+ {
+ m_pSerializer->startElementNS( XML_m, XML_fPr, FSEND );
+ m_pSerializer->singleElementNS( XML_m, XML_type, FSNS( XML_m, XML_val ), type, FSEND );
+ m_pSerializer->endElementNS( XML_m, XML_fPr );
+ }
m_pSerializer->startElementNS( XML_m, XML_num, FSEND );
if( SmNode* num = pNode->GetSubNode( 0 ))
HandleNodes( num, nLevel + 1 );
@@ -419,4 +431,23 @@ void SmOoxml::HandleFractions(SmNode *pNode,int nLevel)
m_pSerializer->endElementNS( XML_m, XML_f );
}
+void SmOoxml::HandleBinaryOperation(SmNode *pNode,int nLevel)
+{
+ // update OSL_ASSERT in HandleMath() when adding new items
+ switch( pNode->GetToken().eType )
+ {
+ case TDIVIDEBY:
+ return HandleFractions( pNode, nLevel, "lin" );
+ default:
+ {
+ for( int i = 0;
+ i < pNode->GetNumSubNodes();
+ ++i )
+ if( SmNode *pTemp = pNode->GetSubNode( i ))
+ HandleNodes( pTemp, nLevel + 1 );
+ break;
+ }
+ }
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/starmath/source/ooxml.hxx b/starmath/source/ooxml.hxx
index 1cdf55d9c9b2..ba659ff4e432 100644
--- a/starmath/source/ooxml.hxx
+++ b/starmath/source/ooxml.hxx
@@ -47,7 +47,8 @@ private:
void HandleTable(SmNode *pNode,int nLevel);
void HandleText(SmNode *pNode,int nLevel);
void HandleMath(SmNode *pNode,int nLevel);
- void HandleFractions(SmNode *pNode,int nLevel);
+ void HandleFractions( SmNode *pNode,int nLevel, const char* type = NULL );
+ void HandleBinaryOperation(SmNode *pNode,int nLevel);
String str;
SmNode *pTree;
::sax_fastparser::FSHelperPtr m_pSerializer;