starmath/source/visitors.cxx | 75 ++++++------------------------------------- 1 file changed, 12 insertions(+), 63 deletions(-)
New commits: commit befc6ac8e20863c913da0fd0bac2fa26bab1b025 Author: Julien Nabet <[email protected]> AuthorDate: Sat Jun 3 21:58:59 2023 +0200 Commit: Julien Nabet <[email protected]> CommitDate: Sun Jun 4 07:48:17 2023 +0200 Related tdf#155630: deduplicate in starmath/visitors Change-Id: I331ce6d2e24e395a1c85789cdc4bd1f973287027 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152580 Tested-by: Jenkins Reviewed-by: Julien Nabet <[email protected]> diff --git a/starmath/source/visitors.cxx b/starmath/source/visitors.cxx index 42257925d38e..92c1ef3413ec 100644 --- a/starmath/source/visitors.cxx +++ b/starmath/source/visitors.cxx @@ -871,71 +871,20 @@ void SmCaretPosGraphBuildingVisitor::Visit( SmSubSupNode* pNode ) bodyRight->SetRight( right ); right->SetLeft( bodyRight ); - //If there's an LSUP - SmNode* pChild = pNode->GetSubSup( LSUP ); - if( pChild ){ - SmCaretPosGraphEntry *cLeft; //Child left - cLeft = mpGraph->Add( SmCaretPos( pChild, 0 ), left ); - - mpRightMost = cLeft; - pChild->Accept( this ); - - mpRightMost->SetRight( bodyLeft ); - } - //If there's an LSUB - pChild = pNode->GetSubSup( LSUB ); - if( pChild ){ - SmCaretPosGraphEntry *cLeft; //Child left - cLeft = mpGraph->Add( SmCaretPos( pChild, 0 ), left ); - - mpRightMost = cLeft; - pChild->Accept( this ); - - mpRightMost->SetRight( bodyLeft ); - } - //If there's a CSUP - pChild = pNode->GetSubSup( CSUP ); - if( pChild ){ - SmCaretPosGraphEntry *cLeft; //Child left - cLeft = mpGraph->Add( SmCaretPos( pChild, 0 ), left ); - - mpRightMost = cLeft; - pChild->Accept( this ); - - mpRightMost->SetRight( right ); - } - //If there's a CSUB - pChild = pNode->GetSubSup( CSUB ); - if( pChild ){ - SmCaretPosGraphEntry *cLeft; //Child left - cLeft = mpGraph->Add( SmCaretPos( pChild, 0 ), left ); - - mpRightMost = cLeft; - pChild->Accept( this ); - - mpRightMost->SetRight( right ); - } - //If there's an RSUP - pChild = pNode->GetSubSup( RSUP ); - if( pChild ){ - SmCaretPosGraphEntry *cLeft; //Child left - cLeft = mpGraph->Add( SmCaretPos( pChild, 0 ), bodyRight ); - - mpRightMost = cLeft; - pChild->Accept( this ); - - mpRightMost->SetRight( right ); - } - //If there's an RSUB - pChild = pNode->GetSubSup( RSUB ); - if( pChild ){ - SmCaretPosGraphEntry *cLeft; //Child left - cLeft = mpGraph->Add( SmCaretPos( pChild, 0 ), bodyRight ); + SmNode* pChild; + for (SmSubSup const nodeType : { LSUP, LSUB, CSUP, CSUB, RSUP, RSUB }) + { + pChild = pNode->GetSubSup(nodeType); + if( pChild ) + { + SmCaretPosGraphEntry *cLeft; //Child left + cLeft = mpGraph->Add( SmCaretPos( pChild, 0 ), ((nodeType == RSUP) || (nodeType == RSUB))?bodyRight:left ); - mpRightMost = cLeft; - pChild->Accept( this ); + mpRightMost = cLeft; + pChild->Accept( this ); - mpRightMost->SetRight( right ); + mpRightMost->SetRight( ((nodeType == LSUP) || (nodeType == LSUB))?bodyLeft:right ); + } } //Set return parameters
