From eeadfca73794593b07829b4ffa36c97dff59660c Mon Sep 17 00:00:00 2001 From: Takeshi Abe Date: Sat, 25 Mar 2017 16:27:19 +0900 Subject: starmath: Hold error nodes as subnodes of SmBracebodyNode so that the resulting tree aligns them in a straightforward way. Change-Id: Ica86be557c5d462425f5e88930dbdec29947e5d7 Reviewed-on: https://gerrit.libreoffice.org/35882 Tested-by: Jenkins Reviewed-by: Takeshi Abe --- starmath/source/parse.cxx | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) (limited to 'starmath') diff --git a/starmath/source/parse.cxx b/starmath/source/parse.cxx index bbfa2e0f67e7..182e2498a07d 100644 --- a/starmath/source/parse.cxx +++ b/starmath/source/parse.cxx @@ -1962,8 +1962,7 @@ SmStructureNode *SmParser::DoBrace() SmBracebodyNode *SmParser::DoBracebody(bool bIsLeftRight) { auto pBody = o3tl::make_unique(m_aCurToken); - sal_uInt16 nNum = 0; - + SmNodeArray aNodes; // get body if any if (bIsLeftRight) { @@ -1971,17 +1970,14 @@ SmBracebodyNode *SmParser::DoBracebody(bool bIsLeftRight) { if (m_aCurToken.eType == TMLINE) { - m_aNodeStack.push_front(o3tl::make_unique(m_aCurToken)); + aNodes.push_back(new SmMathSymbolNode(m_aCurToken)); NextToken(); - nNum++; } else if (m_aCurToken.eType != TRIGHT) { - m_aNodeStack.emplace_front(DoAlign()); - nNum++; - + aNodes.push_back(DoAlign()); if (m_aCurToken.eType != TMLINE && m_aCurToken.eType != TRIGHT) - Error(SmParseError::RightExpected); + aNodes.push_back(DoError(SmParseError::RightExpected)); } } while (m_aCurToken.eType != TEND && m_aCurToken.eType != TRIGHT); } @@ -1991,28 +1987,18 @@ SmBracebodyNode *SmParser::DoBracebody(bool bIsLeftRight) { if (m_aCurToken.eType == TMLINE) { - m_aNodeStack.push_front(o3tl::make_unique(m_aCurToken)); + aNodes.push_back(new SmMathSymbolNode(m_aCurToken)); NextToken(); - nNum++; } else if (!TokenInGroup(TG::RBrace)) { - m_aNodeStack.emplace_front(DoAlign()); - nNum++; - + aNodes.push_back(DoAlign()); if (m_aCurToken.eType != TMLINE && !TokenInGroup(TG::RBrace)) - Error(SmParseError::RbraceExpected); + aNodes.push_back(DoError(SmParseError::RbraceExpected)); } } while (m_aCurToken.eType != TEND && !TokenInGroup(TG::RBrace)); } - // build argument vector in parsing order - SmNodeArray aNodes(nNum); - for (auto rIt = aNodes.rbegin(), rEnd = aNodes.rend(); rIt != rEnd; ++rIt) - { - *rIt = popOrZero(m_aNodeStack); - } - pBody->SetSubNodes(aNodes); pBody->SetScaleMode(bIsLeftRight ? SCALE_HEIGHT : SCALE_NONE); return pBody.release(); -- cgit