[Libreoffice-commits] core.git: 2 commits - sw/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Thu Jul 26 06:38:41 UTC 2018
sw/source/filter/ww8/ww8par.cxx | 4 ++--
sw/source/filter/ww8/ww8par.hxx | 2 +-
sw/source/filter/ww8/ww8scan.cxx | 29 +++++++++++++----------------
sw/source/filter/ww8/ww8scan.hxx | 6 +++---
4 files changed, 19 insertions(+), 22 deletions(-)
New commits:
commit 242129b92e843bb828a829e37841b2a3ef02633f
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Jul 25 16:29:52 2018 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Jul 26 08:38:23 2018 +0200
loplugin:useuniqueptr in WW8PLCFx_Fc_FKP
Change-Id: If1a8a0301a94c6303f7fe0db52fb3e5ae8c04715
Reviewed-on: https://gerrit.libreoffice.org/58021
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx
index f2b1305be557..b3787451fca1 100644
--- a/sw/source/filter/ww8/ww8scan.cxx
+++ b/sw/source/filter/ww8/ww8scan.cxx
@@ -3019,7 +3019,7 @@ private:
long mnPo;
public:
explicit SamePos(long nPo) : mnPo(nPo) {}
- bool operator()(const WW8PLCFx_Fc_FKP::WW8Fkp *pFkp)
+ bool operator()(const std::unique_ptr<WW8PLCFx_Fc_FKP::WW8Fkp>& pFkp)
{return mnPo == pFkp->GetFilePos();}
};
@@ -3079,21 +3079,20 @@ bool WW8PLCFx_Fc_FKP::NewFkp()
std::find_if(maFkpCache.begin(), maFkpCache.end(), SamePos(nPo));
if (aIter != maFkpCache.end())
{
- pFkp = *aIter;
+ pFkp = aIter->get();
pFkp->Reset(GetStartFc());
}
else
{
pFkp = new WW8Fkp(GetFIB(), pFKPStrm, pDataStrm, nPo,
pFkpSizeTab[ ePLCF ], ePLCF, GetStartFc());
- maFkpCache.push_back(pFkp);
+ maFkpCache.push_back(std::unique_ptr<WW8Fkp>(pFkp));
if (maFkpCache.size() > eMaxCache)
{
- WW8Fkp* pCachedFkp = maFkpCache.front();
+ WW8Fkp* pCachedFkp = maFkpCache.front().get();
if (!pCachedFkp->IsMustRemainCache())
{
- delete pCachedFkp;
maFkpCache.pop_front();
}
}
@@ -3113,23 +3112,21 @@ WW8PLCFx_Fc_FKP::WW8PLCFx_Fc_FKP(SvStream* pSt, SvStream* pTableSt,
long nLenStruct = (8 > rFib.m_nVersion) ? 2 : 4;
if (ePl == CHP)
{
- pPLCF = new WW8PLCF(*pTableSt, rFib.m_fcPlcfbteChpx, rFib.m_lcbPlcfbteChpx,
- nLenStruct, GetStartFc(), rFib.m_pnChpFirst, rFib.m_cpnBteChp);
+ pPLCF.reset(new WW8PLCF(*pTableSt, rFib.m_fcPlcfbteChpx, rFib.m_lcbPlcfbteChpx,
+ nLenStruct, GetStartFc(), rFib.m_pnChpFirst, rFib.m_cpnBteChp));
}
else
{
- pPLCF = new WW8PLCF(*pTableSt, rFib.m_fcPlcfbtePapx, rFib.m_lcbPlcfbtePapx,
- nLenStruct, GetStartFc(), rFib.m_pnPapFirst, rFib.m_cpnBtePap);
+ pPLCF.reset(new WW8PLCF(*pTableSt, rFib.m_fcPlcfbtePapx, rFib.m_lcbPlcfbtePapx,
+ nLenStruct, GetStartFc(), rFib.m_pnPapFirst, rFib.m_cpnBtePap));
}
}
WW8PLCFx_Fc_FKP::~WW8PLCFx_Fc_FKP()
{
- auto aEnd = maFkpCache.end();
- for (auto aIter = maFkpCache.begin(); aIter != aEnd; ++aIter)
- delete *aIter;
- delete pPLCF;
- delete pPCDAttrs;
+ maFkpCache.clear();
+ pPLCF.reset();
+ pPCDAttrs.reset();
}
sal_uInt32 WW8PLCFx_Fc_FKP::GetIdx() const
@@ -3339,8 +3336,8 @@ WW8PLCFx_Cp_FKP::WW8PLCFx_Cp_FKP( SvStream* pSt, SvStream* pTableSt,
*/
if (pPcd)
{
- pPCDAttrs = rSBase.m_pPLCFx_PCDAttrs ? new WW8PLCFx_PCDAttrs(
- *rSBase.m_pWw8Fib, pPcd.get(), &rSBase) : nullptr;
+ pPCDAttrs.reset( rSBase.m_pPLCFx_PCDAttrs ? new WW8PLCFx_PCDAttrs(
+ *rSBase.m_pWw8Fib, pPcd.get(), &rSBase) : nullptr);
}
pPieceIter = rSBase.m_pPieceIter;
diff --git a/sw/source/filter/ww8/ww8scan.hxx b/sw/source/filter/ww8/ww8scan.hxx
index 4297be8c6382..26cb6179a9c1 100644
--- a/sw/source/filter/ww8/ww8scan.hxx
+++ b/sw/source/filter/ww8/ww8scan.hxx
@@ -584,7 +584,7 @@ public:
private:
SvStream* pFKPStrm; // input file
SvStream* pDataStrm; // input file
- WW8PLCF* pPLCF;
+ std::unique_ptr<WW8PLCF> pPLCF;
protected:
WW8Fkp* pFkp;
private:
@@ -601,7 +601,7 @@ private:
== 10 : 18549 pap, 47 chp
== 5 : 18515 pap, 47 chp
*/
- std::list<WW8Fkp*> maFkpCache;
+ std::list<std::unique_ptr<WW8Fkp>> maFkpCache;
enum Limits {eMaxCache = 50000};
bool NewFkp();
@@ -611,7 +611,7 @@ private:
protected:
ePLCFT ePLCF;
- WW8PLCFx_PCDAttrs* pPCDAttrs;
+ std::unique_ptr<WW8PLCFx_PCDAttrs> pPCDAttrs;
public:
WW8PLCFx_Fc_FKP( SvStream* pSt, SvStream* pTableSt, SvStream* pDataSt,
commit c9c97b4eb050dae10cbecebb815eae84cff7dde0
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Jul 25 14:20:43 2018 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Jul 26 08:38:08 2018 +0200
loplugin:useuniqueptr in SwWW8ImplReader
Change-Id: I81473abfd71f816495fe562dd57f987df03c11ab
Reviewed-on: https://gerrit.libreoffice.org/58019
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index cff3375c1999..8492427b7315 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -5285,7 +5285,7 @@ ErrCode SwWW8ImplReader::CoreLoad(WW8Glossary const *pGloss)
m_xSBase.reset();
m_xWDop.reset();
m_xFonts.reset();
- delete m_pAtnNames;
+ m_pAtnNames.reset();
m_xSprmParser.reset();
m_xProgress.reset();
@@ -6018,7 +6018,7 @@ const OUString* SwWW8ImplReader::GetAnnotationAuthor(sal_uInt16 nIdx)
if (!m_pAtnNames && m_xWwFib->m_lcbGrpStAtnOwners)
{
// Determine authors: can be found in the TableStream
- m_pAtnNames = new std::vector<OUString>;
+ m_pAtnNames.reset(new std::vector<OUString>);
SvStream& rStrm = *m_pTableStream;
long nOldPos = rStrm.Tell();
diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx
index 8002dbf37edf..0841fbd3d9db 100644
--- a/sw/source/filter/ww8/ww8par.hxx
+++ b/sw/source/filter/ww8/ww8par.hxx
@@ -1248,7 +1248,7 @@ private:
std::unique_ptr<SwMSDffManager> m_xMSDffManager;
- std::vector<OUString>* m_pAtnNames;
+ std::unique_ptr<std::vector<OUString>> m_pAtnNames;
std::unique_ptr<WW8SmartTagData> m_pSmartTagData;
More information about the Libreoffice-commits
mailing list