[Libreoffice-commits] .: 7 commits - starmath/inc starmath/source

Lubos Lunak llunak at kemper.freedesktop.org
Thu Sep 1 05:15:14 PDT 2011


 starmath/inc/node.hxx     |   24 -------
 starmath/source/ooxml.cxx |  151 ++++++++++++++++++++++++++++++++++------------
 2 files changed, 112 insertions(+), 63 deletions(-)

New commits:
commit b34011ae33e9d73482e24babbd07ce46eea298e2
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Wed Aug 31 17:07:54 2011 +0200

    disable debug output

diff --git a/starmath/source/ooxml.cxx b/starmath/source/ooxml.cxx
index 0bccd3a..f083ca7 100644
--- a/starmath/source/ooxml.cxx
+++ b/starmath/source/ooxml.cxx
@@ -328,7 +328,7 @@ void SmOoxml::HandleFractions( const SmNode* pNode, int nLevel, const char* type
 void SmOoxml::HandleUnaryOperation( const SmUnHorNode* pNode, int nLevel )
 {
     // update HandleMath() when adding new items
-    fprintf(stderr,"UNARY %d\n", pNode->GetToken().eType );
+//    fprintf(stderr,"UNARY %d\n", pNode->GetToken().eType );
     switch( pNode->GetToken().eType )
     {
         default:
@@ -461,7 +461,7 @@ static rtl::OString mathSymbolToString( const SmNode* node )
 
 void SmOoxml::HandleOperator( const SmOperNode* pNode, int nLevel )
 {
-    fprintf( stderr, "OPER %d\n", pNode->GetToken().eType );
+//    fprintf( stderr, "OPER %d\n", pNode->GetToken().eType );
     switch( pNode->GetToken().eType )
     {
         case TINT:
@@ -671,7 +671,7 @@ void SmOoxml::HandleBrace( const SmBraceNode* pNode, int nLevel )
 
 void SmOoxml::HandleVerticalBrace( const SmVerticalBraceNode* pNode, int nLevel )
 {
-    fprintf( stderr, "VERT %d\n", pNode->GetToken().eType );
+//    fprintf( stderr, "VERT %d\n", pNode->GetToken().eType );
     switch( pNode->GetToken().eType )
     {
         case TOVERBRACE:
commit cd9934dec168c1cb8411b4a6e583841bf7afe7d3
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Wed Aug 31 17:04:22 2011 +0200

    support TPROD, TCOPROD for .docx math export

diff --git a/starmath/source/ooxml.cxx b/starmath/source/ooxml.cxx
index 56036fb..0bccd3a 100644
--- a/starmath/source/ooxml.cxx
+++ b/starmath/source/ooxml.cxx
@@ -470,6 +470,8 @@ void SmOoxml::HandleOperator( const SmOperNode* pNode, int nLevel )
         case TLINT:
         case TLLINT:
         case TLLLINT:
+        case TPROD:
+        case TCOPROD:
         {
             const SmSubSupNode* subsup = pNode->GetSubNode( 0 )->GetType() == NSUBSUP
                 ? static_cast< const SmSubSupNode* >( pNode->GetSubNode( 0 )) : NULL;
commit a3b2fdcde2c577495b88941e56d4cd2aa82034dc
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Wed Aug 31 17:02:17 2011 +0200

    revert accessors for SmUnHorNode, factorial has it the other way around

diff --git a/starmath/inc/node.hxx b/starmath/inc/node.hxx
index e390463..07aca32 100644
--- a/starmath/inc/node.hxx
+++ b/starmath/inc/node.hxx
@@ -750,11 +750,6 @@ public:
 
     virtual void Arrange(const OutputDevice &rDev, const SmFormat &rFormat);
     void Accept(SmVisitor* pVisitor);
-
-    SmMathSymbolNode* Symbol();
-    const SmMathSymbolNode* Symbol() const;
-    SmNode* Operand();
-    const SmNode* Operand() const;
 };
 
 
@@ -1285,25 +1280,6 @@ inline const SmNode* SmRootNode::Body() const
     return const_cast< SmRootNode* >( this )->Body();
 }
 
-inline SmMathSymbolNode* SmUnHorNode::Symbol()
-{
-    OSL_ASSERT( GetNumSubNodes() > 0 && GetSubNode( 0 )->GetType() == NMATH );
-    return static_cast< SmMathSymbolNode* >( GetSubNode( 0 ));
-}
-inline const SmMathSymbolNode* SmUnHorNode::Symbol() const
-{
-    return const_cast< SmUnHorNode* >( this )->Symbol();
-}
-inline SmNode* SmUnHorNode::Operand()
-{
-    OSL_ASSERT( GetNumSubNodes() > 1 );
-    return GetSubNode( 1 );
-}
-inline const SmNode* SmUnHorNode::Operand() const
-{
-    return const_cast< SmUnHorNode* >( this )->Operand();
-}
-
 inline SmMathSymbolNode* SmBinHorNode::Symbol()
 {
     OSL_ASSERT( GetNumSubNodes() > 1 && GetSubNode( 1 )->GetType() == NMATH );
diff --git a/starmath/source/ooxml.cxx b/starmath/source/ooxml.cxx
index 7f06d71..56036fb 100644
--- a/starmath/source/ooxml.cxx
+++ b/starmath/source/ooxml.cxx
@@ -328,8 +328,8 @@ void SmOoxml::HandleFractions( const SmNode* pNode, int nLevel, const char* type
 void SmOoxml::HandleUnaryOperation( const SmUnHorNode* pNode, int nLevel )
 {
     // update HandleMath() when adding new items
-//    fprintf(stderr,"UNARY %d\n", pNode->Symbol()->GetToken().eType );
-    switch( pNode->Symbol()->GetToken().eType )
+    fprintf(stderr,"UNARY %d\n", pNode->GetToken().eType );
+    switch( pNode->GetToken().eType )
     {
         default:
             HandleAllSubNodes( pNode, nLevel );
commit cd0f9f31a2eb400e4b028eaddbf9b16d94ad5572
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Wed Aug 31 16:32:51 2011 +0200

    implement support for limits to .docx math export

diff --git a/starmath/source/ooxml.cxx b/starmath/source/ooxml.cxx
index e5fd6e3..7f06d71 100644
--- a/starmath/source/ooxml.cxx
+++ b/starmath/source/ooxml.cxx
@@ -462,38 +462,76 @@ static rtl::OString mathSymbolToString( const SmNode* node )
 void SmOoxml::HandleOperator( const SmOperNode* pNode, int nLevel )
 {
     fprintf( stderr, "OPER %d\n", pNode->GetToken().eType );
-    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 );
-    m_pSerializer->startElementNS( XML_m, XML_nary, FSEND );
-    m_pSerializer->startElementNS( XML_m, XML_naryPr, FSEND );
-    m_pSerializer->singleElementNS( XML_m, XML_chr,
-        FSNS( XML_m, XML_val ), mathSymbolToString( operation ).getStr(), FSEND );
-    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
+    switch( pNode->GetToken().eType )
     {
-        m_pSerializer->startElementNS( XML_m, XML_sup, FSEND );
-        HandleNode( subsup->GetSubSup( CSUP ), nLevel + 1 );
-        m_pSerializer->endElementNS( XML_m, XML_sup );
+        case TINT:
+        case TIINT:
+        case TIIINT:
+        case TLINT:
+        case TLLINT:
+        case TLLLINT:
+        {
+            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 );
+            m_pSerializer->startElementNS( XML_m, XML_nary, FSEND );
+            m_pSerializer->startElementNS( XML_m, XML_naryPr, FSEND );
+            m_pSerializer->singleElementNS( XML_m, XML_chr,
+                FSNS( XML_m, XML_val ), mathSymbolToString( operation ).getStr(), FSEND );
+            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 );
+            break;
+        }
+        case TLIM:
+            m_pSerializer->startElementNS( XML_m, XML_func, FSEND );
+            m_pSerializer->startElementNS( XML_m, XML_fName, FSEND );
+            m_pSerializer->startElementNS( XML_m, XML_limLow, FSEND );
+            m_pSerializer->startElementNS( XML_m, XML_e, FSEND );
+            HandleNode( pNode->GetSymbol(), nLevel + 1 );
+            m_pSerializer->endElementNS( XML_m, XML_e );
+            m_pSerializer->startElementNS( XML_m, XML_lim, FSEND );
+            if( const SmSubSupNode* subsup = pNode->GetSubNode( 0 )->GetType() == NSUBSUP
+                ? static_cast< const SmSubSupNode* >( pNode->GetSubNode( 0 )) : NULL )
+            {
+                if( subsup->GetSubSup( CSUB ) != NULL )
+                    HandleNode( subsup->GetSubSup( CSUB ), nLevel + 1 );
+            }
+            m_pSerializer->endElementNS( XML_m, XML_lim );
+            m_pSerializer->endElementNS( XML_m, XML_limLow );
+            m_pSerializer->endElementNS( XML_m, XML_fName );
+            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_func );
+            break;
+        default:
+            OSL_FAIL( "Unhandled operation" );
+            HandleAllSubNodes( pNode, nLevel );
+            break;
     }
-    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 )
commit 9ff870f1cbfbcb822a03ff7073bba1d54f9756ab
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Wed Aug 31 16:16:34 2011 +0200

    fix incorrect tag name: m:char -> m:chr

diff --git a/starmath/source/ooxml.cxx b/starmath/source/ooxml.cxx
index f4ad597..e5fd6e3 100644
--- a/starmath/source/ooxml.cxx
+++ b/starmath/source/ooxml.cxx
@@ -467,7 +467,7 @@ void SmOoxml::HandleOperator( const SmOperNode* pNode, int nLevel )
     const SmNode* operation = subsup != NULL ? subsup->GetBody() : pNode->GetSubNode( 0 );
     m_pSerializer->startElementNS( XML_m, XML_nary, FSEND );
     m_pSerializer->startElementNS( XML_m, XML_naryPr, FSEND );
-    m_pSerializer->singleElementNS( XML_m, XML_char,
+    m_pSerializer->singleElementNS( XML_m, XML_chr,
         FSNS( XML_m, XML_val ), mathSymbolToString( operation ).getStr(), FSEND );
     if( subsup == NULL || subsup->GetSubSup( CSUB ) == NULL )
         m_pSerializer->singleElementNS( XML_m, XML_subHide, FSNS( XML_m, XML_val ), "1", FSEND );
commit 42c1d4066424ae4fcaeada9dfb6d36e4b768af4b
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Wed Aug 31 12:01:29 2011 +0200

    more work on math accents export to .docx

diff --git a/starmath/source/ooxml.cxx b/starmath/source/ooxml.cxx
index 1a0e35c..f4ad597 100644
--- a/starmath/source/ooxml.cxx
+++ b/starmath/source/ooxml.cxx
@@ -355,12 +355,20 @@ void SmOoxml::HandleAttribute( const SmAttributNode* pNode, int nLevel )
 {
     switch( pNode->Attribute()->GetToken().eType )
     {
-        case TCHECK: // TODO check these all are really accents
+        case TCHECK:
         case TACUTE:
         case TGRAVE:
+        case TBREVE:
         case TCIRCLE:
+        case TVEC:
+        case TTILDE:
+        case THAT:
+        case TDOT:
+        case TDDOT:
+        case TDDDOT:
         case TWIDETILDE:
         case TWIDEHAT:
+        case TWIDEVEC:
         {
             m_pSerializer->startElementNS( XML_m, XML_acc, FSEND );
             m_pSerializer->startElementNS( XML_m, XML_accPr, FSEND );
@@ -374,6 +382,33 @@ void SmOoxml::HandleAttribute( const SmAttributNode* pNode, int nLevel )
             m_pSerializer->endElementNS( XML_m, XML_acc );
             break;
         }
+        case TBAR:
+        case TOVERLINE:
+        case TUNDERLINE:
+            m_pSerializer->startElementNS( XML_m, XML_bar, FSEND );
+            m_pSerializer->startElementNS( XML_m, XML_barPr, FSEND );
+            m_pSerializer->singleElementNS( XML_m, XML_pos, FSNS( XML_m, XML_val ),
+                ( pNode->Attribute()->GetToken().eType == TUNDERLINE ) ? "bot" : "top", FSEND );
+            m_pSerializer->endElementNS( XML_m, XML_barPr );
+            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_bar );
+            break;
+        case TOVERSTRIKE:
+            m_pSerializer->startElementNS( XML_m, XML_borderBox, FSEND );
+            m_pSerializer->startElementNS( XML_m, XML_borderBoxPr, FSEND );
+            m_pSerializer->singleElementNS( XML_m, XML_hideTop, FSNS( XML_m, XML_val ), "1", FSEND );
+            m_pSerializer->singleElementNS( XML_m, XML_hideBot, FSNS( XML_m, XML_val ), "1", FSEND );
+            m_pSerializer->singleElementNS( XML_m, XML_hideLeft, FSNS( XML_m, XML_val ), "1", FSEND );
+            m_pSerializer->singleElementNS( XML_m, XML_hideRight, FSNS( XML_m, XML_val ), "1", FSEND );
+            m_pSerializer->singleElementNS( XML_m, XML_strikeH, FSNS( XML_m, XML_val ), "1", FSEND );
+            m_pSerializer->endElementNS( XML_m, XML_borderBoxPr );
+            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_borderBox );
+            break;
         default:
             HandleAllSubNodes( pNode, nLevel );
             break;
commit 9c1da5eac9adadcac08c6397c2075c18016b0e5a
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Tue Aug 30 17:55:21 2011 +0200

    enable NSPECIAL handling for math .docx export
    
    I'm not quite sure what it does, but mathtype export has it this
    way and it doesn't look like it can hurt.

diff --git a/starmath/source/ooxml.cxx b/starmath/source/ooxml.cxx
index e72d558..1a0e35c 100644
--- a/starmath/source/ooxml.cxx
+++ b/starmath/source/ooxml.cxx
@@ -125,9 +125,8 @@ void SmOoxml::HandleNode( const SmNode* pNode, int nLevel )
         case NROOT:
             HandleRoot( static_cast< const SmRootNode* >( pNode ), nLevel );
             break;
-#if 0
         case NSPECIAL:
-            {
+        {
             const SmTextNode* pText= static_cast< const SmTextNode* >( pNode );
             //if the token str and the result text are the same then this
             //is to be seen as text, else assume its a mathchar
@@ -135,9 +134,8 @@ void SmOoxml::HandleNode( const SmNode* pNode, int nLevel )
                 HandleText(pText,nLevel);
             else
                 HandleMath(pText,nLevel);
-            }
             break;
-#endif
+        }
         case NMATH:
             HandleMath(pNode,nLevel);
             break;


More information about the Libreoffice-commits mailing list