summaryrefslogtreecommitdiff
path: root/lotuswordpro
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-09-25 15:25:04 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-09-26 09:00:21 +0200
commit1140eccc9f620de227efe381980ea06e0b455aed (patch)
tree3ffe9be8af050598a5204618ae9f39822ff8c714 /lotuswordpro
parentfd84276cf31182c80fc07c88537f9524c4d80e8c (diff)
loplugin:useuniqueptr in LwpFormulaInfo
Change-Id: Iac1f025f1311ef05fd48581d5bee9875163f4f2b Reviewed-on: https://gerrit.libreoffice.org/60972 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'lotuswordpro')
-rw-r--r--lotuswordpro/source/filter/lwptblformula.cxx42
-rw-r--r--lotuswordpro/source/filter/lwptblformula.hxx2
2 files changed, 18 insertions, 26 deletions
diff --git a/lotuswordpro/source/filter/lwptblformula.cxx b/lotuswordpro/source/filter/lwptblformula.cxx
index 4b8f56de0379..f539d16cf47d 100644
--- a/lotuswordpro/source/filter/lwptblformula.cxx
+++ b/lotuswordpro/source/filter/lwptblformula.cxx
@@ -67,6 +67,7 @@
#include <osl/thread.h>
#include <rtl/ustrbuf.hxx>
#include <sal/log.hxx>
+#include <o3tl/make_unique.hxx>
#include <memory>
LwpFormulaArg::~LwpFormulaArg()
@@ -81,19 +82,13 @@ LwpFormulaArg::~LwpFormulaArg()
LwpFormulaInfo::~LwpFormulaInfo()
{
- while(m_aStack.size()>0)
- {
- LwpFormulaArg* pArg=m_aStack.back();
- m_aStack.pop_back();
- delete pArg; pArg=nullptr;
- }
}
void LwpFormulaInfo::ReadConst()
{
double Constant = m_pObjStrm->QuickReadDouble();
- m_aStack.push_back( new LwpFormulaConst(Constant) );
+ m_aStack.push_back( o3tl::make_unique<LwpFormulaConst>(Constant) );
}
/**
@@ -112,7 +107,7 @@ void LwpFormulaInfo::ReadText()
aText += OUString(pBuf.get(), nStrLen, osl_getThreadTextEncoding());
aText += "\"";
- m_aStack.push_back(new LwpFormulaText(aText));
+ m_aStack.push_back(o3tl::make_unique<LwpFormulaText>(aText));
}
void LwpFormulaInfo::ReadCellID()
@@ -123,26 +118,24 @@ void LwpFormulaInfo::ReadCellID()
RowSpecifier.QuickRead(m_pObjStrm.get());
ColumnSpecifier.QuickRead(m_pObjStrm.get());
- m_aStack.push_back( new LwpFormulaCellAddr(ColumnSpecifier.ColumnID(cColumn),
+ m_aStack.push_back( o3tl::make_unique<LwpFormulaCellAddr>(ColumnSpecifier.ColumnID(cColumn),
RowSpecifier.RowID(m_nFormulaRow)) );
}
void LwpFormulaInfo::ReadCellRange()
{
ReadCellID( ); // start
- LwpFormulaCellAddr* pStartCellAddr = static_cast<LwpFormulaCellAddr*>(m_aStack.back());
+ std::unique_ptr<LwpFormulaCellAddr> pStartCellAddr( static_cast<LwpFormulaCellAddr*>(m_aStack.back().release()));
m_aStack.pop_back();
ReadCellID(); // end
- LwpFormulaCellAddr* pEndCellAddr = static_cast<LwpFormulaCellAddr*>(m_aStack.back());
+ std::unique_ptr<LwpFormulaCellAddr> pEndCellAddr(static_cast<LwpFormulaCellAddr*>(m_aStack.back().release()));
m_aStack.pop_back();
- m_aStack.push_back( new LwpFormulaCellRangeAddr(pStartCellAddr->GetCol(),
+ m_aStack.push_back( o3tl::make_unique<LwpFormulaCellRangeAddr>(pStartCellAddr->GetCol(),
pStartCellAddr->GetRow(),
pEndCellAddr->GetCol(),
pEndCellAddr->GetRow()) );
- delete pStartCellAddr;
- delete pEndCellAddr;
}
/**
@@ -190,7 +183,7 @@ void LwpFormulaInfo::ReadExpression()
{
std::unique_ptr<LwpFormulaFunc> xFunc(new LwpFormulaFunc(TokenType));
ReadArguments(*xFunc);
- m_aStack.push_back(xFunc.release());
+ m_aStack.push_back(std::move(xFunc));
}
break;
@@ -211,18 +204,18 @@ void LwpFormulaInfo::ReadExpression()
if (m_aStack.size() >= 2)
{//binary operator
- LwpFormulaOp* pOp = new LwpFormulaOp(TokenType);
- pOp->AddArg(std::unique_ptr<LwpFormulaArg>(m_aStack.back())); m_aStack.pop_back();
- pOp->AddArg(std::unique_ptr<LwpFormulaArg>(m_aStack.back())); m_aStack.pop_back();
- m_aStack.push_back(pOp);
+ std::unique_ptr<LwpFormulaOp> pOp(new LwpFormulaOp(TokenType));
+ pOp->AddArg(std::move(m_aStack.back())); m_aStack.pop_back();
+ pOp->AddArg(std::move(m_aStack.back())); m_aStack.pop_back();
+ m_aStack.push_back(std::move(pOp));
}
break;
case TK_UNARY_MINUS:
if (!m_aStack.empty())
{
- LwpFormulaUnaryOp* pOp = new LwpFormulaUnaryOp(TokenType);
- pOp->AddArg(std::unique_ptr<LwpFormulaArg>(m_aStack.back())); m_aStack.pop_back();
- m_aStack.push_back(pOp);
+ std::unique_ptr<LwpFormulaUnaryOp> pOp(new LwpFormulaUnaryOp(TokenType));
+ pOp->AddArg(std::move(m_aStack.back())); m_aStack.pop_back();
+ m_aStack.push_back(std::move(pOp));
}
break;
default:
@@ -293,7 +286,7 @@ void LwpFormulaInfo::ReadArguments(LwpFormulaFunc& aFunc)
if (bArgument && !m_aStack.empty())
{
- aFunc.AddArg(std::unique_ptr<LwpFormulaArg>(m_aStack.back()));
+ aFunc.AddArg(std::move(m_aStack.back()));
m_aStack.pop_back();
}
}
@@ -333,8 +326,7 @@ OUString LwpFormulaInfo::Convert(LwpTableLayout* pCellsMap)
{
if(1==m_aStack.size())
{
- LwpFormulaArg* pFormula = m_aStack.back();
- aFormula = pFormula->ToString(pCellsMap);
+ aFormula = m_aStack[0]->ToString(pCellsMap);
}
else
{
diff --git a/lotuswordpro/source/filter/lwptblformula.hxx b/lotuswordpro/source/filter/lwptblformula.hxx
index 2320c18fa736..8c4a8979a7db 100644
--- a/lotuswordpro/source/filter/lwptblformula.hxx
+++ b/lotuswordpro/source/filter/lwptblformula.hxx
@@ -209,7 +209,7 @@ private:
void ReadConst();
void MarkUnsupported(sal_uInt16 TokenType);
- std::vector<LwpFormulaArg*> m_aStack;
+ std::vector<std::unique_ptr<LwpFormulaArg>> m_aStack;
sal_uInt16 m_nFormulaRow;
};