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

Jonas Finnemann Jensen jopsen at kemper.freedesktop.org
Wed Dec 8 12:17:57 PST 2010


 starmath/inc/cursor.hxx      |    3 ++-
 starmath/inc/types.hxx       |    4 +++-
 starmath/source/cursor.cxx   |    9 +++++++++
 starmath/source/view.cxx     |    2 ++
 starmath/source/visitors.cxx |   32 ++++++++++----------------------
 5 files changed, 26 insertions(+), 24 deletions(-)

New commits:
commit 0156cf56e868f1ce08ab4b8a3ac13b5302b1deb6
Author: Luke Dixon <6b8b4567 at gmail.com>
Date:   Sun Dec 5 17:09:57 2010 +0000

    Remove as many brackets as possible.

diff --git a/starmath/source/visitors.cxx b/starmath/source/visitors.cxx
index 3b9bdef..2e7e4e3 100644
--- a/starmath/source/visitors.cxx
+++ b/starmath/source/visitors.cxx
@@ -2242,39 +2242,33 @@ void SmNodeToTextVisitor::Visit( SmOperNode* pNode )
         SmNode* pChild;
         if( ( pChild = pSubSup->GetSubSup( LSUP ) ) ) {
             Separate( );
-            Append( "lsup { " );
+            Append( "lsup " );
             LineToText( pChild );
-            Append( "} ");
         }
         if( ( pChild = pSubSup->GetSubSup( LSUB ) ) ) {
             Separate( );
-            Append( "lsub { " );
+            Append( "lsub " );
             LineToText( pChild );
-            Append( "} ");
         }
         if( ( pChild = pSubSup->GetSubSup( RSUP ) ) ) {
             Separate( );
-            Append( "rsup { " );
+            Append( "rsup " );
             LineToText( pChild );
-            Append( "} ");
         }
         if( ( pChild = pSubSup->GetSubSup( RSUB ) ) ) {
             Separate( );
-            Append( "rsub { " );
+            Append( "rsub " );
             LineToText( pChild );
-            Append( "} ");
         }
         if( ( pChild = pSubSup->GetSubSup( CSUP ) ) ) {
             Separate( );
-            Append( "csup { " );
+            Append( "csup " );
             LineToText( pChild );
-            Append( "} ");
         }
         if( ( pChild = pSubSup->GetSubSup( CSUB ) ) ) {
             Separate( );
-            Append( "csub { " );
+            Append( "csub " );
             LineToText( pChild );
-            Append( "} ");
         }
     }
     LineToText( pNode->GetSubNode( 1 ) );
@@ -2380,18 +2374,15 @@ void SmNodeToTextVisitor::Visit( SmFontNode* pNode )
 
 void SmNodeToTextVisitor::Visit( SmUnHorNode* pNode )
 {
-    Append( "{" );
     SmNodeIterator it( pNode, pNode->GetSubNode( 1 )->GetToken( ).eType == TFACT );
     while( it.Next( ) ) {
         Separate( );
         it->Accept( this );
     }
-    Append( " }" );
 }
 
 void SmNodeToTextVisitor::Visit( SmBinHorNode* pNode )
 {
-    Append( "{" );
     SmNode *pLeft  = pNode->GetSubNode( 0 ),
            *pOper  = pNode->GetSubNode( 1 ),
            *pRight = pNode->GetSubNode( 2 );
@@ -2402,7 +2393,6 @@ void SmNodeToTextVisitor::Visit( SmBinHorNode* pNode )
     Separate( );
     pRight->Accept( this );
     Separate( );
-    Append( "}" );
 }
 
 void SmNodeToTextVisitor::Visit( SmBinVerNode* pNode )
@@ -2466,11 +2456,9 @@ void SmNodeToTextVisitor::Visit( SmMatrixNode* pNode )
     for ( USHORT i = 0; i < pNode->GetNumRows( ); i++ ) {
         for ( USHORT j = 0; j < pNode->GetNumCols( ); j++ ) {
             SmNode* pSubNode = pNode->GetSubNode( i * pNode->GetNumCols( ) + j );
-            Append( "{" );
             Separate( );
             pSubNode->Accept( this );
             Separate( );
-            Append( "}" );
             if( j != pNode->GetNumCols( ) - 1 )
                 Append( "#" );
         }
@@ -2478,7 +2466,7 @@ void SmNodeToTextVisitor::Visit( SmMatrixNode* pNode )
         if( i != pNode->GetNumRows( ) - 1 )
             Append( "##" );
     }
-    Append( "}" );
+    Append( "} " );
 }
 
 void SmNodeToTextVisitor::Visit( SmPlaceNode* )
@@ -2535,8 +2523,8 @@ void SmNodeToTextVisitor::Visit( SmLineNode* pNode )
 
 void SmNodeToTextVisitor::Visit( SmExpressionNode* pNode )
 {
-    USHORT nSize = pNode->GetNumSubNodes();
-    if (nSize > 1) {
+    bool bracketsNeeded = pNode->GetNumSubNodes() != 1 || pNode->GetSubNode(0)->GetType() != NEXPRESSION;
+    if (bracketsNeeded) {
         Append( "{ " );
     }
     SmNodeIterator it( pNode );
@@ -2544,7 +2532,7 @@ void SmNodeToTextVisitor::Visit( SmExpressionNode* pNode )
         it->Accept( this );
         Separate( );
     }
-    if (nSize > 1) {
+    if (bracketsNeeded) {
         Append( "} " );
     }
 }
commit cad299ad6542a170084e4125461d910483489c11
Author: Luke Dixon <6b8b4567 at gmail.com>
Date:   Sun Dec 5 17:58:45 2010 +0000

    Add the percent sign as a symbol that is inserted when % is pressed

diff --git a/starmath/inc/cursor.hxx b/starmath/inc/cursor.hxx
index 139d5c4..5c61d12 100644
--- a/starmath/inc/cursor.hxx
+++ b/starmath/inc/cursor.hxx
@@ -52,7 +52,8 @@ enum SmFormulaElement{
     CDotElement,
     EqualElement,
     LessThanElement,
-    GreaterThanElement
+    GreaterThanElement,
+    PercentElement
 };
 
 /** Bracket types that can be inserted */
diff --git a/starmath/inc/types.hxx b/starmath/inc/types.hxx
index 833c88c..d72df24 100644
--- a/starmath/inc/types.hxx
+++ b/starmath/inc/types.hxx
@@ -198,7 +198,9 @@ enum MathSymbol
     MS_SETZ         = (sal_Unicode) 0x2124,
     MS_SETQ         = (sal_Unicode) 0x211A,
     MS_SETR         = (sal_Unicode) 0x211D,
-    MS_SETC         = (sal_Unicode) 0x2102
+    MS_SETC         = (sal_Unicode) 0x2102,
+
+    MS_PERCENT      = (sal_Unicode) 0x0025
 };
 
 #endif
diff --git a/starmath/source/cursor.cxx b/starmath/source/cursor.cxx
index 94b9e38..249d6a4 100644
--- a/starmath/source/cursor.cxx
+++ b/starmath/source/cursor.cxx
@@ -1058,6 +1058,15 @@ void SmCursor::InsertElement(SmFormulaElement element){
             token.aText.AssignAscii(">");
             pNewNode = new SmMathSymbolNode(token);
         }break;
+        case PercentElement:
+        {
+            SmToken token;
+            token.eType = TTEXT;
+            token.cMathChar = MS_PERCENT;
+            token.nGroup = 0;
+            token.aText.AssignAscii("\"%\"");
+            pNewNode = new SmMathSymbolNode(token);
+        }break;
         default:
             j_assert(false, "Element unknown!");
     }
diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx
index 97a9035..810ddd7 100644
--- a/starmath/source/view.cxx
+++ b/starmath/source/view.cxx
@@ -513,6 +513,8 @@ void SmGraphicWindow::KeyInput(const KeyEvent& rKEvt)
                 rCursor.InsertBrackets(CurlyBrackets);
             }else if(code == '!') {
                 rCursor.InsertElement(FactorialElement);
+            }else if(code == '%') {
+                rCursor.InsertElement(PercentElement);
             }else{
                 if(code != 0){
                     rCursor.InsertText(code);


More information about the Libreoffice-commits mailing list