summaryrefslogtreecommitdiff
path: root/starmath
diff options
context:
space:
mode:
authorJulien Nabet <serval2412@yahoo.fr>2023-06-04 09:12:04 +0200
committerJulien Nabet <serval2412@yahoo.fr>2023-06-04 09:58:57 +0200
commit7932427a39e684d78f2108d14660288a46f42df9 (patch)
treeefba7012df2b568e6d304dfafbb17433c32dc3b8 /starmath
parente0c7d7bc511c90e820adaaebb14ca8175364371d (diff)
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 <serval2412@yahoo.fr>
Diffstat (limited to 'starmath')
-rw-r--r--starmath/source/visitors.cxx76
1 files changed, 13 insertions, 63 deletions
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 );
+ }
}
}