starmath/source/visitors.cxx |   76 +++++++------------------------------------
 1 file changed, 13 insertions(+), 63 deletions(-)

New commits:
commit 7932427a39e684d78f2108d14660288a46f42df9
Author:     Julien Nabet <serval2...@yahoo.fr>
AuthorDate: Sun Jun 4 09:12:04 2023 +0200
Commit:     Julien Nabet <serval2...@yahoo.fr>
CommitDate: Sun Jun 4 09:58:57 2023 +0200

    Related tdf#155630: deduplicate in starmath/visitors (2)
    
    Change-Id: I86e629260c5f25a67627589f5b33edc939aa1dff
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152583
    Tested-by: Jenkins
    Reviewed-by: Julien Nabet <serval2...@yahoo.fr>

diff --git a/starmath/source/visitors.cxx b/starmath/source/visitors.cxx
index 92c1ef3413ec..a15a62a4b048 100644
--- a/starmath/source/visitors.cxx
+++ b/starmath/source/visitors.cxx
@@ -954,70 +954,20 @@ void SmCaretPosGraphBuildingVisitor::Visit( SmOperNode* 
pNode )
     SmSubSupNode* pSubSup = pOper->GetType( ) == SmNodeType::SubSup ? 
static_cast<SmSubSupNode*>(pOper) : nullptr;
 
     if( pSubSup ) {
-        SmNode* pChild = pSubSup->GetSubSup( LSUP );
-        if( pChild ) {
-            //Create position in front of pChild
-            SmCaretPosGraphEntry *childLeft = mpGraph->Add( SmCaretPos( 
pChild, 0 ), left );
-            //Visit pChild
-            mpRightMost = childLeft;
-            pChild->Accept( this );
-            //Set right on mpRightMost from pChild
-            mpRightMost->SetRight( bodyLeft );
-        }
-
-        pChild = pSubSup->GetSubSup( LSUB );
-        if( pChild ) {
-            //Create position in front of pChild
-            SmCaretPosGraphEntry *childLeft = mpGraph->Add( SmCaretPos( 
pChild, 0 ), left );
-            //Visit pChild
-            mpRightMost = childLeft;
-            pChild->Accept( this );
-            //Set right on mpRightMost from pChild
-            mpRightMost->SetRight( bodyLeft );
-        }
-
-        pChild = pSubSup->GetSubSup( CSUP );
-        if ( pChild ) {//TO
-            //Create position in front of pChild
-            SmCaretPosGraphEntry *childLeft = mpGraph->Add( SmCaretPos( 
pChild, 0 ), left );
-            //Visit pChild
-            mpRightMost = childLeft;
-            pChild->Accept( this );
-            //Set right on mpRightMost from pChild
-            mpRightMost->SetRight( bodyLeft );
-        }
-
-        pChild = pSubSup->GetSubSup( CSUB );
-        if( pChild ) { //FROM
-            //Create position in front of pChild
-            SmCaretPosGraphEntry *childLeft = mpGraph->Add( SmCaretPos( 
pChild, 0 ), left );
-            //Visit pChild
-            mpRightMost = childLeft;
-            pChild->Accept( this );
-            //Set right on mpRightMost from pChild
-            mpRightMost->SetRight( bodyLeft );
-        }
-
-        pChild = pSubSup->GetSubSup( RSUP );
-        if ( pChild ) {
-            //Create position in front of pChild
-            SmCaretPosGraphEntry *childLeft = mpGraph->Add( SmCaretPos( 
pChild, 0 ), left );
-            //Visit pChild
-            mpRightMost = childLeft;
-            pChild->Accept( this );
-            //Set right on mpRightMost from pChild
-            mpRightMost->SetRight( bodyLeft );
-        }
-
-        pChild = pSubSup->GetSubSup( RSUB );
-        if ( pChild ) {
+        SmNode* pChild;
+        for (SmSubSup const nodeType : { LSUP, LSUB, CSUP, CSUB, RSUP, RSUB })
+        {
+            pChild = pSubSup->GetSubSup(nodeType);
+            if( pChild )
+            {
             //Create position in front of pChild
-            SmCaretPosGraphEntry *childLeft = mpGraph->Add( SmCaretPos( 
pChild, 0 ), left );
-            //Visit pChild
-            mpRightMost = childLeft;
-            pChild->Accept( this );
-            //Set right on mpRightMost from pChild
-            mpRightMost->SetRight( bodyLeft );
+                SmCaretPosGraphEntry *childLeft = mpGraph->Add( SmCaretPos( 
pChild, 0 ), left );
+                //Visit pChild
+                mpRightMost = childLeft;
+                pChild->Accept( this );
+                //Set right on mpRightMost from pChild
+                mpRightMost->SetRight( bodyLeft );
+            }
         }
     }
 

Reply via email to