[Libreoffice-commits] core.git: sc/inc sc/source
Noel Grandin
noel.grandin at collabora.co.uk
Wed Jun 13 11:29:35 UTC 2018
sc/inc/dptabres.hxx | 4 ++--
sc/source/core/data/dptabres.cxx | 25 ++++++++++++-------------
2 files changed, 14 insertions(+), 15 deletions(-)
New commits:
commit 7535eaf646605a14050a2f670d54b3fe8b8296a0
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Wed Jun 13 11:30:01 2018 +0200
loplugin:useuniqueptr in ScDPResultData
Change-Id: I5cef91c2cdb13e33ad19597cd722e77e7c7796c9
Reviewed-on: https://gerrit.libreoffice.org/55745
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sc/inc/dptabres.hxx b/sc/inc/dptabres.hxx
index bdd64a140432..5b4956787fac 100644
--- a/sc/inc/dptabres.hxx
+++ b/sc/inc/dptabres.hxx
@@ -292,7 +292,7 @@ class ScDPResultData
bool bDataAtRow:1;
//! add "displayed values" settings
- mutable std::vector<ResultMembers*> maDimMembers;
+ mutable std::vector<std::unique_ptr<ResultMembers>> maDimMembers;
public:
ScDPResultData( ScDPSource& rSrc );
~ScDPResultData();
@@ -328,7 +328,7 @@ public:
bool HasCommonElement( SCROW nFirstDataId, long nFirstIndex,
const ScDPItemData& rSecondData, long nSecondIndex ) const;
- ResultMembers* GetDimResultMembers(long nDim, const ScDPDimension* pDim, ScDPLevel* pLevel) const;
+ ResultMembers& GetDimResultMembers(long nDim, const ScDPDimension* pDim, ScDPLevel* pLevel) const;
const ScDPSource& GetSource() const { return mrSource;}
};
diff --git a/sc/source/core/data/dptabres.cxx b/sc/source/core/data/dptabres.cxx
index c309a350bf59..df38649bcfcc 100644
--- a/sc/source/core/data/dptabres.cxx
+++ b/sc/source/core/data/dptabres.cxx
@@ -758,7 +758,6 @@ ScDPResultData::ScDPResultData( ScDPSource& rSrc ) :
ScDPResultData::~ScDPResultData()
{
- std::for_each(maDimMembers.begin(), maDimMembers.end(), std::default_delete<ResultMembers>());
}
void ScDPResultData::SetMeasureData(
@@ -909,15 +908,15 @@ bool ScDPResultData::HasCommonElement( SCROW nFirstDataId, long nFirstIndex,
return false;
}
-ResultMembers* ScDPResultData::GetDimResultMembers(long nDim, const ScDPDimension* pDim, ScDPLevel* pLevel) const
+ResultMembers& ScDPResultData::GetDimResultMembers(long nDim, const ScDPDimension* pDim, ScDPLevel* pLevel) const
{
if (nDim < static_cast<long>(maDimMembers.size()) && maDimMembers[nDim])
- return maDimMembers[nDim];
+ return *maDimMembers[nDim];
if (nDim >= static_cast<long>(maDimMembers.size()))
- maDimMembers.resize(nDim+1, nullptr);
+ maDimMembers.resize(nDim+1);
- ResultMembers* pResultMembers = new ResultMembers();
+ std::unique_ptr<ResultMembers> pResultMembers(new ResultMembers());
// global order is used to initialize aMembers, so it doesn't have to be looked at later
const ScMemberSortOrder& rGlobalOrder = pLevel->GetGlobalOrder();
@@ -934,8 +933,8 @@ ResultMembers* ScDPResultData::GetDimResultMembers(long nDim, const ScDPDimensio
}
}
- maDimMembers[nDim] = pResultMembers;
- return maDimMembers[nDim];
+ maDimMembers[nDim] = std::move(pResultMembers);
+ return *maDimMembers[nDim];
}
ScDPResultMember::ScDPResultMember(
@@ -2902,12 +2901,12 @@ void ScDPResultDimension::LateInitFrom(
if ( !bLateInitAllMembers )
{
- ResultMembers* pMembers = pResultData->GetDimResultMembers(nDimSource, pThisDim, pThisLevel);
- bLateInitAllMembers = pMembers->IsHasHideDetailsMembers();
+ ResultMembers& rMembers = pResultData->GetDimResultMembers(nDimSource, pThisDim, pThisLevel);
+ bLateInitAllMembers = rMembers.IsHasHideDetailsMembers();
- SAL_INFO("sc.core", aDimensionName << (pMembers->IsHasHideDetailsMembers() ? " HasHideDetailsMembers" : ""));
+ SAL_INFO("sc.core", aDimensionName << (rMembers.IsHasHideDetailsMembers() ? " HasHideDetailsMembers" : ""));
- pMembers->SetHasHideDetailsMembers( false );
+ rMembers.SetHasHideDetailsMembers( false );
}
bool bNewAllMembers = (!rParams.IsRow()) || nPos == 0 || bLateInitAllMembers;
@@ -4011,7 +4010,7 @@ void ScDPResultDimension::InitWithMembers(
long nDimSource = pThisDim->GetDimension(); //TODO: check GetSourceDim?
// create all members at the first call (preserve order)
- ResultMembers* pMembers = pResultData->GetDimResultMembers(nDimSource, pThisDim, pThisLevel);
+ ResultMembers& rMembers = pResultData->GetDimResultMembers(nDimSource, pThisDim, pThisLevel);
ScDPGroupCompare aCompare( pResultData, rInitState, nDimSource );
// initialize only specific member (or all if "show empty" flag is set)
ScDPResultMember* pResultMember = nullptr;
@@ -4022,7 +4021,7 @@ void ScDPResultDimension::InitWithMembers(
if ( pResultMember == nullptr )
{ //only insert found item
- ScDPParentDimData* pMemberData = pMembers->FindMember( nDataID );
+ ScDPParentDimData* pMemberData = rMembers.FindMember( nDataID );
if ( pMemberData && aCompare.IsIncluded( *( pMemberData->mpMemberDesc ) ) )
pResultMember = InsertMember( pMemberData );
}
More information about the Libreoffice-commits
mailing list