diff options
author | Takeshi Abe <tabe@fixedpoint.jp> | 2014-11-19 22:22:13 +0900 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-11-20 09:18:49 +0000 |
commit | e05a6419a6c77b7cd11c67688f544df40cfc7c33 (patch) | |
tree | aaad805a3e8f497a63da895d363cda9cc05ba37b /starmath | |
parent | 924b378a79e04d3b8b5ca2a06eadacee5a00997b (diff) |
fix memory leaks caused with SmNodeStack
SmNodeStack now frees its own pointers after use.
Change-Id: Ie43eb887810a3424109708c956ccbdf97fc5a2e5
Reviewed-on: https://gerrit.libreoffice.org/12970
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'starmath')
-rw-r--r-- | starmath/inc/node.hxx | 11 | ||||
-rw-r--r-- | starmath/source/mathmlimport.cxx | 93 | ||||
-rw-r--r-- | starmath/source/parse.cxx | 103 |
3 files changed, 101 insertions, 106 deletions
diff --git a/starmath/inc/node.hxx b/starmath/inc/node.hxx index 48590a937517..28acdebdb304 100644 --- a/starmath/inc/node.hxx +++ b/starmath/inc/node.hxx @@ -23,13 +23,13 @@ #include <vector> #include <ostream> #include <stdio.h> -#include <stack> #include "types.hxx" #include "token.hxx" #include "error.hxx" #include "rect.hxx" #include "format.hxx" +#include <boost/ptr_container/ptr_deque.hpp> #define ATTR_BOLD 0x0001 @@ -60,18 +60,17 @@ class SmNode; class SmStructureNode; typedef boost::shared_ptr<SmNode> SmNodePointer; -typedef std::stack< SmNode* > SmNodeStack; +typedef boost::ptr_deque<SmNode> SmNodeStack; typedef std::vector< SmNode * > SmNodeArray; typedef std::vector< SmStructureNode * > SmStructureNodeArray; template < typename T > -T* popOrZero( ::std::stack<T*> & rStack ) +T* popOrZero( boost::ptr_deque<T> & rStack ) { if (rStack.empty()) return 0; - T* pTmp = rStack.top(); - rStack.pop(); - return pTmp; + auto pTmp = rStack.pop_front(); + return pTmp.release(); } enum SmScaleMode { SCALE_NONE, SCALE_WIDTH, SCALE_HEIGHT }; diff --git a/starmath/source/mathmlimport.cxx b/starmath/source/mathmlimport.cxx index 425538acbae9..9d284559ea39 100644 --- a/starmath/source/mathmlimport.cxx +++ b/starmath/source/mathmlimport.cxx @@ -692,7 +692,7 @@ void SmXMLContext_Helper::ApplyAttrs() SmStructureNode *pFontNode = static_cast<SmStructureNode *> (new SmFontNode(aToken)); pFontNode->SetSubNodes(0,popOrZero(rNodeStack)); - rNodeStack.push(pFontNode); + rNodeStack.push_front(pFontNode); } if (nIsItalic != -1) { @@ -703,7 +703,7 @@ void SmXMLContext_Helper::ApplyAttrs() SmStructureNode *pFontNode = static_cast<SmStructureNode *> (new SmFontNode(aToken)); pFontNode->SetSubNodes(0,popOrZero(rNodeStack)); - rNodeStack.push(pFontNode); + rNodeStack.push_front(pFontNode); } if (nFontSize != 0.0) { @@ -724,7 +724,7 @@ void SmXMLContext_Helper::ApplyAttrs() pFontNode->SetSizeParameter(Fraction(nFontSize),FNTSIZ_ABSOLUT); pFontNode->SetSubNodes(0,popOrZero(rNodeStack)); - rNodeStack.push(pFontNode); + rNodeStack.push_front(pFontNode); } if (!sFontFamily.isEmpty()) { @@ -741,7 +741,7 @@ void SmXMLContext_Helper::ApplyAttrs() aToken.aText = sFontFamily; SmFontNode *pFontNode = new SmFontNode(aToken); pFontNode->SetSubNodes(0,popOrZero(rNodeStack)); - rNodeStack.push(pFontNode); + rNodeStack.push_front(pFontNode); } if (!sColor.isEmpty()) { @@ -755,7 +755,7 @@ void SmXMLContext_Helper::ApplyAttrs() aToken.eType = static_cast<SmTokenType>(tok); SmFontNode *pFontNode = new SmFontNode(aToken); pFontNode->SetSubNodes(0,popOrZero(rNodeStack)); - rNodeStack.push(pFontNode); + rNodeStack.push_front(pFontNode); } } @@ -954,7 +954,7 @@ void SmXMLPhantomContext_Impl::EndElement() (new SmFontNode(aToken)); SmNodeStack &rNodeStack = GetSmImport().GetNodeStack(); pPhantom->SetSubNodes(0,popOrZero(rNodeStack)); - rNodeStack.push(pPhantom); + rNodeStack.push_front(pPhantom); } @@ -1036,8 +1036,8 @@ void SmXMLFencedContext_Impl::EndElement() aRelationArray.resize(i); while (rNodeStack.size() > nElementCount) { - aRelationArray[--i] = rNodeStack.top(); - rNodeStack.pop(); + auto pNode = rNodeStack.pop_front(); + aRelationArray[--i] = pNode.release(); if (i > 1 && rNodeStack.size() > 1) aRelationArray[--i] = new SmGlyphSpecialNode(aToken); } @@ -1049,7 +1049,7 @@ void SmXMLFencedContext_Impl::EndElement() pSNode->SetSubNodes(pLeft,pBody,pRight); pSNode->SetScaleMode(SCALE_HEIGHT); - GetSmImport().GetNodeStack().push(pSNode); + GetSmImport().GetNodeStack().push_front(pSNode); } @@ -1077,8 +1077,7 @@ void SmXMLErrorContext_Impl::EndElement() SmNodeStack &rNodeStack = GetSmImport().GetNodeStack(); while (rNodeStack.size() > nElementCount) { - delete rNodeStack.top(); - rNodeStack.pop(); + rNodeStack.pop_front(); } } @@ -1111,7 +1110,7 @@ void SmXMLNumberContext_Impl::TCharacters(const OUString &rChars) void SmXMLNumberContext_Impl::EndElement() { - GetSmImport().GetNodeStack().push(new SmTextNode(aToken,FNT_NUMBER)); + GetSmImport().GetNodeStack().push_front(new SmTextNode(aToken,FNT_NUMBER)); } @@ -1190,7 +1189,7 @@ void SmXMLTextContext_Impl::TCharacters(const OUString &rChars) void SmXMLTextContext_Impl::EndElement() { - GetSmImport().GetNodeStack().push(new SmTextNode(aToken,FNT_TEXT)); + GetSmImport().GetNodeStack().push_front(new SmTextNode(aToken,FNT_TEXT)); } @@ -1232,7 +1231,7 @@ void SmXMLStringContext_Impl::TCharacters(const OUString &rChars) void SmXMLStringContext_Impl::EndElement() { - GetSmImport().GetNodeStack().push(new SmTextNode(aToken,FNT_FIXED)); + GetSmImport().GetNodeStack().push_front(new SmTextNode(aToken,FNT_FIXED)); } @@ -1291,7 +1290,7 @@ void SmXMLIdentifierContext_Impl::EndElement() aStyleHelper.bFontNodeNeeded=false; if (aStyleHelper.bFontNodeNeeded) aStyleHelper.ApplyAttrs(); - GetSmImport().GetNodeStack().push(pNode); + GetSmImport().GetNodeStack().push_front(pNode); } void SmXMLIdentifierContext_Impl::TCharacters(const OUString &rChars) @@ -1335,7 +1334,7 @@ void SmXMLOperatorContext_Impl::EndElement() //to scale the operator to the height of the expression itself if (bIsStretchy) pNode->SetScaleMode(SCALE_HEIGHT); - GetSmImport().GetNodeStack().push(pNode); + GetSmImport().GetNodeStack().push_front(pNode); } @@ -1390,7 +1389,7 @@ void SmXMLSpaceContext_Impl::StartElement( aToken.nLevel = 5; SmBlankNode *pBlank = new SmBlankNode(aToken); pBlank->IncreaseBy(aToken); - GetSmImport().GetNodeStack().push(pBlank); + GetSmImport().GetNodeStack().push_front(pBlank); } @@ -1435,7 +1434,7 @@ void SmXMLSubContext_Impl::GenericEndElement(SmTokenType eType, SmSubSup eSubSup aSubNodes[eSubSup+1] = popOrZero(rNodeStack); aSubNodes[0] = popOrZero(rNodeStack); pNode->SetSubNodes(aSubNodes); - rNodeStack.push(pNode); + rNodeStack.push_front(pNode); } @@ -1496,7 +1495,7 @@ void SmXMLSubSupContext_Impl::GenericEndElement(SmTokenType eType, aSubNodes[aSub+1] = popOrZero(rNodeStack); aSubNodes[0] = popOrZero(rNodeStack); pNode->SetSubNodes(aSubNodes); - rNodeStack.push(pNode); + rNodeStack.push_front(pNode); } @@ -1554,7 +1553,7 @@ void SmXMLUnderContext_Impl::HandleAccent() aSubNodes[1] = popOrZero(rNodeStack); pNode->SetSubNodes(aSubNodes); pNode->SetScaleMode(SCALE_WIDTH); - rNodeStack.push(pNode); + rNodeStack.push_front(pNode); } @@ -1620,7 +1619,7 @@ void SmXMLOverContext_Impl::HandleAccent() aSubNodes[1] = popOrZero(rNodeStack); pNode->SetSubNodes(aSubNodes); pNode->SetScaleMode(SCALE_WIDTH); - rNodeStack.push(pNode); + rNodeStack.push_front(pNode); } @@ -1679,7 +1678,7 @@ void SmXMLNoneContext_Impl::EndElement(void) aToken.aText = ""; aToken.nLevel = 5; aToken.eType = TIDENT; - GetSmImport().GetNodeStack().push( + GetSmImport().GetNodeStack().push_front( new SmTextNode(aToken,FNT_VARIABLE)); } @@ -2144,19 +2143,19 @@ void SmXMLDocContext_Impl::EndElement() SmToken aDummy; SmStructureNode *pSNode = new SmLineNode(aDummy); pSNode->SetSubNodes(ContextArray); - rNodeStack.push(pSNode); + rNodeStack.push_front(pSNode); SmNodeArray LineArray; sal_uLong n = rNodeStack.size(); LineArray.resize(n); for (sal_uLong j = 0; j < n; j++) { - LineArray[n - (j + 1)] = rNodeStack.top(); - rNodeStack.pop(); + auto pNode = rNodeStack.pop_front(); + LineArray[n - (j + 1)] = pNode.release(); } SmStructureNode *pSNode2 = new SmTableNode(aDummy); pSNode2->SetSubNodes(LineArray); - rNodeStack.push(pSNode2); + rNodeStack.push_front(pSNode2); } void SmXMLFracContext_Impl::EndElement() @@ -2175,7 +2174,7 @@ void SmXMLFracContext_Impl::EndElement() SmNode *pSecond = popOrZero(rNodeStack); SmNode *pFirst = popOrZero(rNodeStack); pSNode->SetSubNodes(pFirst,pOper,pSecond); - rNodeStack.push(pSNode); + rNodeStack.push_front(pSNode); } void SmXMLRootContext_Impl::EndElement() @@ -2195,7 +2194,7 @@ void SmXMLRootContext_Impl::EndElement() SmNode *pIndex = popOrZero(rNodeStack); SmNode *pBase = popOrZero(rNodeStack); pSNode->SetSubNodes(pIndex,pOper,pBase); - rNodeStack.push(pSNode); + rNodeStack.push_front(pSNode); } void SmXMLSqrtContext_Impl::EndElement() @@ -2215,7 +2214,7 @@ void SmXMLSqrtContext_Impl::EndElement() SmNode *pOper = new SmRootSymbolNode(aToken); SmNodeStack &rNodeStack = GetSmImport().GetNodeStack(); pSNode->SetSubNodes(0,pOper,popOrZero(rNodeStack)); - rNodeStack.push(pSNode); + rNodeStack.push_front(pSNode); } void SmXMLRowContext_Impl::EndElement() @@ -2230,8 +2229,8 @@ void SmXMLRowContext_Impl::EndElement() aRelationArray.resize(nSize); for (sal_uLong j=nSize;j > 0;j--) { - aRelationArray[j-1] = rNodeStack.top(); - rNodeStack.pop(); + auto pNode = rNodeStack.pop_front(); + aRelationArray[j-1] = pNode.release(); } //If the first or last element is an operator with stretchyness @@ -2291,7 +2290,7 @@ void SmXMLRowContext_Impl::EndElement() pSNode->SetSubNodes(pLeft,pBody,pRight); pSNode->SetScaleMode(SCALE_HEIGHT); - rNodeStack.push(pSNode); + rNodeStack.push_front(pSNode); return; } } @@ -2308,7 +2307,7 @@ void SmXMLRowContext_Impl::EndElement() SmToken aDummy; SmStructureNode *pSNode = new SmExpressionNode(aDummy); pSNode->SetSubNodes(aRelationArray); - rNodeStack.push(pSNode); + rNodeStack.push_front(pSNode); } @@ -2435,8 +2434,8 @@ void SmXMLMultiScriptsContext_Impl::ProcessSubSupPairs(bool bIsPrescript) SmNodeStack aReverseStack; for (sal_uLong i = 0; i < nCount + 1; i++) { - aReverseStack.push(rNodeStack.top()); - rNodeStack.pop(); + auto pNode = rNodeStack.pop_front(); + aReverseStack.push_front(pNode.release()); } SmSubSup eSub = bIsPrescript ? LSUB : RSUB; @@ -2465,17 +2464,18 @@ void SmXMLMultiScriptsContext_Impl::ProcessSubSupPairs(bool bIsPrescript) aSubNodes[eSup+1] = pScriptNode; pNode->SetSubNodes(aSubNodes); - aReverseStack.push(pNode); + aReverseStack.push_front(pNode); } - rNodeStack.push(popOrZero(aReverseStack)); + assert(!aReverseStack.empty()); + auto pNode = aReverseStack.pop_front(); + rNodeStack.push_front(pNode.release()); } else { // Ignore odd number of elements. for (sal_uLong i = 0; i < nCount; i++) { - delete rNodeStack.top(); - rNodeStack.pop(); + rNodeStack.pop_front(); } } } @@ -2494,8 +2494,8 @@ void SmXMLTableContext_Impl::EndElement() SmStructureNode *pArray; for (sal_uLong i=nRows;i > 0;i--) { - pArray = (SmStructureNode *)rNodeStack.top(); - rNodeStack.pop(); + auto pNode = rNodeStack.pop_front(); + pArray = (SmStructureNode *)pNode.release(); if (pArray->GetNumSubNodes() == 0) { //This is a little tricky, it is possible that there was @@ -2516,14 +2516,14 @@ void SmXMLTableContext_Impl::EndElement() if (pArray->GetNumSubNodes() > nCols) nCols = pArray->GetNumSubNodes(); - aReverseStack.push(pArray); + aReverseStack.push_front(pArray); } aExpressionArray.resize(nCols*nRows); sal_uLong j=0; while ( !aReverseStack.empty() ) { - pArray = (SmStructureNode *)aReverseStack.top(); - aReverseStack.pop(); + auto pNode = aReverseStack.pop_front(); + pArray = (SmStructureNode *)pNode.release(); for (sal_uInt16 i=0;i<pArray->GetNumSubNodes();i++) aExpressionArray[j++] = pArray->GetSubNode(i); } @@ -2535,7 +2535,7 @@ void SmXMLTableContext_Impl::EndElement() SmMatrixNode *pSNode = new SmMatrixNode(aToken); pSNode->SetSubNodes(aExpressionArray); pSNode->SetRowCol(static_cast<sal_uInt16>(nRows),nCols); - rNodeStack.push(pSNode); + rNodeStack.push_front(pSNode); } SvXMLImportContext *SmXMLTableRowContext_Impl::CreateChildContext( @@ -2599,8 +2599,7 @@ void SmXMLActionContext_Impl::EndElement() SmNodeStack &rNodeStack = GetSmImport().GetNodeStack(); for (sal_uLong i=rNodeStack.size()-nElementCount;i > 1;i--) { - delete rNodeStack.top(); - rNodeStack.pop(); + rNodeStack.pop_front(); } } diff --git a/starmath/source/parse.cxx b/starmath/source/parse.cxx index 4683c37c3029..4898cf89da9d 100644 --- a/starmath/source/parse.cxx +++ b/starmath/source/parse.cxx @@ -961,13 +961,13 @@ void SmParser::Table() for (sal_uLong i = 0; i < n; i++) { - LineArray[n - (i + 1)] = m_aNodeStack.top(); - m_aNodeStack.pop(); + auto pNode = m_aNodeStack.pop_front(); + LineArray[n - (i + 1)] = pNode.release(); } SmStructureNode *pSNode = new SmTableNode(m_aCurToken); pSNode->SetSubNodes(LineArray); - m_aNodeStack.push(pSNode); + m_aNodeStack.push_front(pSNode); } @@ -996,7 +996,7 @@ void SmParser::Align() if (pSNode) { pSNode->SetSubNodes(popOrZero(m_aNodeStack), 0); - m_aNodeStack.push(pSNode); + m_aNodeStack.push_front(pSNode); } } @@ -1036,7 +1036,7 @@ void SmParser::Line() SmStructureNode *pSNode = new SmLineNode(m_aCurToken); pSNode->SetSubNodes(ExpressionArray); - m_aNodeStack.push(pSNode); + m_aNodeStack.push_front(pSNode); } @@ -1045,12 +1045,11 @@ void SmParser::Expression() bool bUseExtraSpaces = true; if (!m_aNodeStack.empty()) { - SmNode *pNode = m_aNodeStack.top(); - m_aNodeStack.pop(); + auto pNode = m_aNodeStack.pop_front(); if (pNode->GetToken().eType == TNOSPACE) bUseExtraSpaces = false; else - m_aNodeStack.push(pNode); // push the node from above again (now to be used as argument to this current 'nospace' node) + m_aNodeStack.push_front(pNode.release()); // push the node from above again (now to be used as argument to this current 'nospace' node) } sal_uInt16 n = 0; @@ -1073,12 +1072,12 @@ void SmParser::Expression() SmExpressionNode *pSNode = new SmExpressionNode(m_aCurToken); pSNode->SetSubNodes(RelationArray); pSNode->SetUseExtraSpaces(bUseExtraSpaces); - m_aNodeStack.push(pSNode); + m_aNodeStack.push_front(pSNode); } else { // This expression has only one node so just push this node. - m_aNodeStack.push(RelationArray[0]); + m_aNodeStack.push_front(RelationArray[0]); } } @@ -1097,7 +1096,7 @@ void SmParser::Relation() Sum(); pSNode->SetSubNodes(pFirst, pSecond, popOrZero(m_aNodeStack)); - m_aNodeStack.push(pSNode); + m_aNodeStack.push_front(pSNode); } } @@ -1116,7 +1115,7 @@ void SmParser::Sum() Product(); pSNode->SetSubNodes(pFirst, pSecond, popOrZero(m_aNodeStack)); - m_aNodeStack.push(pSNode); + m_aNodeStack.push_front(pSNode); } } @@ -1193,7 +1192,7 @@ void SmParser::Product() { pSNode->SetSubNodes(pFirst, pOper, popOrZero(m_aNodeStack)); } - m_aNodeStack.push(pSNode); + m_aNodeStack.push_front(pSNode); } } @@ -1262,14 +1261,14 @@ void SmParser::SubSup(sal_uLong nActiveGroup) } pNode->SetSubNodes(aSubNodes); - m_aNodeStack.push(pNode); + m_aNodeStack.push_front(pNode); } void SmParser::OpSubSup() { // push operator symbol - m_aNodeStack.push(new SmMathSymbolNode(m_aCurToken)); + m_aNodeStack.push_front(new SmMathSymbolNode(m_aCurToken)); // skip operator token NextToken(); // get sub- supscripts if any @@ -1305,7 +1304,7 @@ void SmParser::Blank() pBlankNode->Clear(); } - m_aNodeStack.push(pBlankNode); + m_aNodeStack.push_front(pBlankNode); } @@ -1323,12 +1322,12 @@ void SmParser::Term(bool bGroupNumberIdent) bool bNoSpace = m_aCurToken.eType == TNOSPACE; if (bNoSpace) // push 'no space' node and continue to parse expression { - m_aNodeStack.push(new SmExpressionNode(m_aCurToken)); + m_aNodeStack.push_front(new SmExpressionNode(m_aCurToken)); NextToken(); } if (m_aCurToken.eType != TLGROUP) { - m_aNodeStack.pop(); // get rid of the 'no space' node pushed above + m_aNodeStack.pop_front(); // get rid of the 'no space' node pushed above Term(false); } else @@ -1339,10 +1338,10 @@ void SmParser::Term(bool bGroupNumberIdent) if (m_aCurToken.eType == TRGROUP) { if (bNoSpace) // get rid of the 'no space' node pushed above - m_aNodeStack.pop(); + m_aNodeStack.pop_front(); SmStructureNode *pSNode = new SmExpressionNode(m_aCurToken); pSNode->SetSubNodes(NULL, NULL); - m_aNodeStack.push(pSNode); + m_aNodeStack.push_front(pSNode); NextToken(); } @@ -1368,17 +1367,17 @@ void SmParser::Term(bool bGroupNumberIdent) break; case TTEXT : - m_aNodeStack.push(new SmTextNode(m_aCurToken, FNT_TEXT)); + m_aNodeStack.push_front(new SmTextNode(m_aCurToken, FNT_TEXT)); NextToken(); break; case TCHARACTER : - m_aNodeStack.push(new SmTextNode(m_aCurToken, FNT_VARIABLE)); + m_aNodeStack.push_front(new SmTextNode(m_aCurToken, FNT_VARIABLE)); NextToken(); break; case TIDENT : case TNUMBER : { - m_aNodeStack.push(new SmTextNode(m_aCurToken, + m_aNodeStack.push_front(new SmTextNode(m_aCurToken, m_aCurToken.eType == TNUMBER ? FNT_NUMBER : FNT_VARIABLE)); @@ -1415,7 +1414,7 @@ void SmParser::Term(bool bGroupNumberIdent) moveToNextToken = false; break; } - m_aNodeStack.push(new SmTextNode(m_aCurToken, + m_aNodeStack.push_front(new SmTextNode(m_aCurToken, m_aCurToken.eType == TNUMBER ? FNT_NUMBER : @@ -1436,7 +1435,7 @@ void SmParser::Term(bool bGroupNumberIdent) } SmExpressionNode* pNode = new SmExpressionNode(SmToken()); pNode->SetSubNodes(nodeArray); - m_aNodeStack.push(pNode); + m_aNodeStack.push_front(pNode); } } break; @@ -1461,7 +1460,7 @@ void SmParser::Term(bool bGroupNumberIdent) case TDOTSLOW : case TDOTSUP : case TDOTSVERT : - m_aNodeStack.push(new SmMathSymbolNode(m_aCurToken)); + m_aNodeStack.push_front(new SmMathSymbolNode(m_aCurToken)); NextToken(); break; @@ -1479,12 +1478,12 @@ void SmParser::Term(bool bGroupNumberIdent) case TWP : case TEMPTYSET : case TINFINITY : - m_aNodeStack.push(new SmMathIdentifierNode(m_aCurToken)); + m_aNodeStack.push_front(new SmMathIdentifierNode(m_aCurToken)); NextToken(); break; case TPLACE: - m_aNodeStack.push(new SmPlaceNode(m_aCurToken)); + m_aNodeStack.push_front(new SmPlaceNode(m_aCurToken)); NextToken(); break; @@ -1546,7 +1545,7 @@ void SmParser::Term(bool bGroupNumberIdent) pFirstNode = aArray[n - 1]; n--; } - m_aNodeStack.push(pFirstNode); + m_aNodeStack.push_front(pFirstNode); } else if (TokenInGroup(TGFUNCTION)) { @@ -1590,7 +1589,7 @@ void SmParser::Escape() } SmNode *pNode = new SmMathSymbolNode(m_aCurToken); - m_aNodeStack.push(pNode); + m_aNodeStack.push_front(pNode); NextToken(); } @@ -1612,7 +1611,7 @@ void SmParser::Operator() Power(); pSNode->SetSubNodes(pOperator, popOrZero(m_aNodeStack)); - m_aNodeStack.push(pSNode); + m_aNodeStack.push_front(pSNode); } } @@ -1665,7 +1664,7 @@ void SmParser::Oper() default : assert(false && "unknown case"); } - m_aNodeStack.push(pNode); + m_aNodeStack.push_front(pNode); NextToken(); } @@ -1765,7 +1764,7 @@ void SmParser::UnOper() pSNode->SetSubNodes(pOper, pArg); } - m_aNodeStack.push(pSNode); + m_aNodeStack.push_front(pSNode); } @@ -1801,7 +1800,7 @@ void SmParser::Attribut() pSNode->SetSubNodes(pAttr, 0); pSNode->SetScaleMode(eScaleMode); - m_aNodeStack.push(pSNode); + m_aNodeStack.push_front(pSNode); } @@ -1816,7 +1815,7 @@ void SmParser::FontAttribut() case TBOLD : case TNBOLD : case TPHANTOM : - m_aNodeStack.push(new SmFontNode(m_aCurToken)); + m_aNodeStack.push_front(new SmFontNode(m_aCurToken)); NextToken(); break; @@ -1855,7 +1854,7 @@ void SmParser::Color() Error(PE_COLOR_EXPECTED); } while (m_aCurToken.eType == TCOLOR); - m_aNodeStack.push(new SmFontNode(aToken)); + m_aNodeStack.push_front(new SmFontNode(aToken)); } @@ -1876,7 +1875,7 @@ void SmParser::Font() Error(PE_FONT_EXPECTED); } while (m_aCurToken.eType == TFONT); - m_aNodeStack.push(new SmFontNode(aToken)); + m_aNodeStack.push_front(new SmFontNode(aToken)); } @@ -1967,7 +1966,7 @@ void SmParser::FontSize() NextToken(); pFontNode->SetSizeParameter(aValue, Type); - m_aNodeStack.push(pFontNode); + m_aNodeStack.push_front(pFontNode); } @@ -2057,7 +2056,7 @@ void SmParser::Brace() OSL_ENSURE(pRight, "Sm: NULL pointer"); pSNode->SetSubNodes(pLeft, pBody, pRight); pSNode->SetScaleMode(eScaleMode); - m_aNodeStack.push(pSNode); + m_aNodeStack.push_front(pSNode); } else { delete pSNode; @@ -2083,7 +2082,7 @@ void SmParser::Bracebody(bool bIsLeftRight) { if (m_aCurToken.eType == TMLINE) { - m_aNodeStack.push(new SmMathSymbolNode(m_aCurToken)); + m_aNodeStack.push_front(new SmMathSymbolNode(m_aCurToken)); NextToken(); nNum++; } @@ -2102,7 +2101,7 @@ void SmParser::Bracebody(bool bIsLeftRight) { if (m_aCurToken.eType == TMLINE) { - m_aNodeStack.push(new SmMathSymbolNode(m_aCurToken)); + m_aNodeStack.push_front(new SmMathSymbolNode(m_aCurToken)); NextToken(); nNum++; } @@ -2125,7 +2124,7 @@ void SmParser::Bracebody(bool bIsLeftRight) pBody->SetSubNodes(aNodes); pBody->SetScaleMode(bIsLeftRight ? SCALE_HEIGHT : SCALE_NONE); - m_aNodeStack.push(pBody); + m_aNodeStack.push_front(pBody); } @@ -2156,7 +2155,7 @@ void SmParser::Function() case TLN : case TLOG : case TEXP : - m_aNodeStack.push(new SmTextNode(m_aCurToken, FNT_FUNCTION)); + m_aNodeStack.push_front(new SmTextNode(m_aCurToken, FNT_FUNCTION)); NextToken(); break; @@ -2184,7 +2183,7 @@ void SmParser::Binom() } pSNode->SetSubNodes(ExpressionArray); - m_aNodeStack.push(pSNode); + m_aNodeStack.push_front(pSNode); } @@ -2222,7 +2221,7 @@ void SmParser::Stack() aTok.eType = TSTACK; SmStructureNode *pSNode = new SmTableNode(aTok); pSNode->SetSubNodes(ExpressionArray); - m_aNodeStack.push(pSNode); + m_aNodeStack.push_front(pSNode); } else Error(PE_LGROUP_EXPECTED); @@ -2285,7 +2284,7 @@ void SmParser::Matrix() SmMatrixNode *pMNode = new SmMatrixNode(m_aCurToken); pMNode->SetSubNodes(ExpressionArray); pMNode->SetRowCol(r, c); - m_aNodeStack.push(pMNode); + m_aNodeStack.push_front(pMNode); } else Error(PE_LGROUP_EXPECTED); @@ -2331,14 +2330,14 @@ void SmParser::Special() if (!aSymbolName.isEmpty()) AddToUsedSymbols( aSymbolName ); - m_aNodeStack.push(new SmSpecialNode(m_aCurToken)); + m_aNodeStack.push_front(new SmSpecialNode(m_aCurToken)); NextToken(); } void SmParser::GlyphSpecial() { - m_aNodeStack.push(new SmGlyphSpecialNode(m_aCurToken)); + m_aNodeStack.push_front(new SmGlyphSpecialNode(m_aCurToken)); NextToken(); } @@ -2352,7 +2351,7 @@ void SmParser::Error(SmParseError eError) //! put a structure node on the stack (instead of the error node itself) //! because sometimes such a node is expected in order to attach some //! subnodes - m_aNodeStack.push(pSNode); + m_aNodeStack.push_front(pSNode); AddError(eError, pSNode); @@ -2388,8 +2387,7 @@ SmNode *SmParser::Parse(const OUString &rBuffer) m_aErrDescList.clear(); - while ( !m_aNodeStack.empty() ) - m_aNodeStack.pop(); + m_aNodeStack.clear(); SetLanguage( Application::GetSettings().GetUILanguageTag().getLanguageType() ); NextToken(); @@ -2410,8 +2408,7 @@ SmNode *SmParser::ParseExpression(const OUString &rBuffer) m_aErrDescList.clear(); - while ( !m_aNodeStack.empty() ) - m_aNodeStack.pop(); + m_aNodeStack.clear(); SetLanguage( Application::GetSettings().GetUILanguageTag().getLanguageType() ); NextToken(); |