[Libreoffice-commits] core.git: 2 commits - lotuswordpro/inc lotuswordpro/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Wed Sep 26 06:59:09 UTC 2018
lotuswordpro/inc/xfilter/xfindex.hxx | 3 +-
lotuswordpro/source/filter/lwptblformula.cxx | 30 +++++++------------------
lotuswordpro/source/filter/lwptblformula.hxx | 4 +--
lotuswordpro/source/filter/xfilter/xfindex.cxx | 6 -----
4 files changed, 13 insertions(+), 30 deletions(-)
New commits:
commit 7f8167d04d6191a0f3a590a9c646689312d63547
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Tue Sep 25 15:20:30 2018 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Sep 26 08:58:56 2018 +0200
loplugin:useuniqueptr in LwpFormulaInfo
Change-Id: I73fbad626ab1d37448ea12052a2fbafab5656fc7
Reviewed-on: https://gerrit.libreoffice.org/60971
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/lotuswordpro/source/filter/lwptblformula.cxx b/lotuswordpro/source/filter/lwptblformula.cxx
index 342893431021..4b8f56de0379 100644
--- a/lotuswordpro/source/filter/lwptblformula.cxx
+++ b/lotuswordpro/source/filter/lwptblformula.cxx
@@ -212,8 +212,8 @@ void LwpFormulaInfo::ReadExpression()
if (m_aStack.size() >= 2)
{//binary operator
LwpFormulaOp* pOp = new LwpFormulaOp(TokenType);
- pOp->AddArg(m_aStack.back()); m_aStack.pop_back();
- pOp->AddArg(m_aStack.back()); m_aStack.pop_back();
+ 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);
}
break;
@@ -221,7 +221,7 @@ void LwpFormulaInfo::ReadExpression()
if (!m_aStack.empty())
{
LwpFormulaUnaryOp* pOp = new LwpFormulaUnaryOp(TokenType);
- pOp->AddArg(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);
}
break;
@@ -293,7 +293,7 @@ void LwpFormulaInfo::ReadArguments(LwpFormulaFunc& aFunc)
if (bArgument && !m_aStack.empty())
{
- aFunc.AddArg(m_aStack.back());
+ aFunc.AddArg(std::unique_ptr<LwpFormulaArg>(m_aStack.back()));
m_aStack.pop_back();
}
}
@@ -415,16 +415,10 @@ LwpFormulaFunc::LwpFormulaFunc(sal_uInt16 nTokenType)
LwpFormulaFunc::~LwpFormulaFunc()
{
- while(m_aArgs.size()>0)
- {
- LwpFormulaArg* pArg = m_aArgs.back();
- m_aArgs.pop_back();
- delete pArg;pArg=nullptr;
- }
}
-void LwpFormulaFunc::AddArg(LwpFormulaArg* pArg)
+void LwpFormulaFunc::AddArg(std::unique_ptr<LwpFormulaArg> pArg)
{
- m_aArgs.push_back(pArg);
+ m_aArgs.push_back(std::move(pArg));
}
/**
* Convert the functions to a string, which is a argument of other formula
@@ -475,16 +469,12 @@ OUString LwpFormulaOp::ToString(LwpTableLayout* pCellsMap)
OUString aFormula;
if (2==m_aArgs.size())
{
- std::vector<LwpFormulaArg*>::iterator aItr = m_aArgs.end();
- --aItr;
-
- aFormula += (*aItr)->ToArgString(pCellsMap) + " ";
+ aFormula += m_aArgs[1]->ToArgString(pCellsMap) + " ";
OUString aFuncName = LwpFormulaTools::GetName(m_nTokenType);
aFormula += aFuncName + " ";
- --aItr;
- aFormula += (*aItr)->ToArgString(pCellsMap);
+ aFormula += m_aArgs[0]->ToArgString(pCellsMap);
}
else
{
@@ -503,9 +493,7 @@ OUString LwpFormulaUnaryOp::ToString(LwpTableLayout* pCellsMap)
{
OUString aFuncName = LwpFormulaTools::GetName(m_nTokenType);
aFormula += aFuncName;
-
- std::vector<LwpFormulaArg*>::iterator aItr = m_aArgs.begin();
- aFormula += (*aItr)->ToArgString(pCellsMap);
+ aFormula += m_aArgs[0]->ToArgString(pCellsMap);
}
else
{
diff --git a/lotuswordpro/source/filter/lwptblformula.hxx b/lotuswordpro/source/filter/lwptblformula.hxx
index d3135abb29f7..2320c18fa736 100644
--- a/lotuswordpro/source/filter/lwptblformula.hxx
+++ b/lotuswordpro/source/filter/lwptblformula.hxx
@@ -167,13 +167,13 @@ public:
explicit LwpFormulaFunc(sal_uInt16 nTokenType);
virtual ~LwpFormulaFunc() override;
- void AddArg(LwpFormulaArg* pArg);
+ void AddArg(std::unique_ptr<LwpFormulaArg> pArg);
virtual OUString ToString(LwpTableLayout* pCellsMap) override;
OUString ToArgString(LwpTableLayout* pCellsMap) override;
protected:
- std::vector<LwpFormulaArg*> m_aArgs;
+ std::vector<std::unique_ptr<LwpFormulaArg>> m_aArgs;
sal_uInt16 m_nTokenType;
};
commit 791683498651a6edb017df7d211d1a014afa0899
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Tue Sep 25 15:15:08 2018 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Sep 26 08:58:46 2018 +0200
loplugin:useuniqueptr in XFIndex
but actually this object should be held by rtl::Reference
Change-Id: Iabf068bd909201af5df6f987c6dcdb64679fefbd
Reviewed-on: https://gerrit.libreoffice.org/60970
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/lotuswordpro/inc/xfilter/xfindex.hxx b/lotuswordpro/inc/xfilter/xfindex.hxx
index 4fb0aa127e41..ace8353be3f6 100644
--- a/lotuswordpro/inc/xfilter/xfindex.hxx
+++ b/lotuswordpro/inc/xfilter/xfindex.hxx
@@ -65,6 +65,7 @@
#include <xfilter/xfcontent.hxx>
#include <xfilter/xfcontentcontainer.hxx>
#include <xfilter/xftabstop.hxx>
+#include <rtl/ref.hxx>
class XFIndex;
class XFIndexTemplate;
@@ -168,7 +169,7 @@ private:
bool m_bProtect;
bool m_bSeparator;
- std::vector<XFIndexTemplate *> m_aTemplates; // template entry + style
+ std::vector<rtl::Reference<XFIndexTemplate>> m_aTemplates; // template entry + style
#define MAX_TOC_LEVEL 10
std::vector<OUString> m_aTOCSource[MAX_TOC_LEVEL+1];
diff --git a/lotuswordpro/source/filter/xfilter/xfindex.cxx b/lotuswordpro/source/filter/xfilter/xfindex.cxx
index 74411f1d5a6c..8ef69ef6b70f 100644
--- a/lotuswordpro/source/filter/xfilter/xfindex.cxx
+++ b/lotuswordpro/source/filter/xfilter/xfindex.cxx
@@ -68,12 +68,6 @@ XFIndex::XFIndex()
XFIndex::~XFIndex()
{
- while(m_aTemplates.size()>0)
- {
- XFIndexTemplate * pTemplate = m_aTemplates.back();
- m_aTemplates.pop_back();
- delete pTemplate;
- }
}
void XFIndex::AddTemplate(const OUString& level, const OUString& style, XFIndexTemplate* templ)
More information about the Libreoffice-commits
mailing list