summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-01-17 11:28:27 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-01-17 15:27:33 +0200
commitdd8f5e22356349345c35932fcc6b75dee503f834 (patch)
treedc576336d8e2f4bb24d2b73b5eb067ea75b63cf7
parent492ccb76d75cbce976f5a4886cbe5eec3d132898 (diff)
use rtl::Reference in ScDPDimensions/ScDPHierarchies/ScDPLevels
instead of manual acquire/release Change-Id: Id0dfa1c42e12a680ed6a6144b73d03c8f45e9f3d
-rw-r--r--sc/inc/dptabsrc.hxx6
-rw-r--r--sc/source/core/data/dptabsrc.cxx35
2 files changed, 13 insertions, 28 deletions
diff --git a/sc/inc/dptabsrc.hxx b/sc/inc/dptabsrc.hxx
index 26e949a813b7..6a3547626548 100644
--- a/sc/inc/dptabsrc.hxx
+++ b/sc/inc/dptabsrc.hxx
@@ -261,7 +261,7 @@ class ScDPDimensions : public cppu::WeakImplHelper<
private:
ScDPSource* pSource;
long nDimCount;
- ScDPDimension** ppDims;
+ rtl::Reference<ScDPDimension>* ppDims;
public:
ScDPDimensions( ScDPSource* pSrc );
@@ -415,7 +415,7 @@ private:
// date columns have 3 hierarchies (flat/quarter/week), other columns only one
// #i52547# don't offer the incomplete date hierarchy implementation
static const long nHierCount = 1;
- ScDPHierarchy** ppHiers;
+ rtl::Reference<ScDPHierarchy>* ppHiers;
public:
ScDPHierarchies( ScDPSource* pSrc, long nD );
@@ -492,7 +492,7 @@ private:
long nDim;
long nHier;
long nLevCount;
- ScDPLevel** ppLevs;
+ rtl::Reference<ScDPLevel>* ppLevs;
public:
ScDPLevels( ScDPSource* pSrc, long nD, long nH );
diff --git a/sc/source/core/data/dptabsrc.cxx b/sc/source/core/data/dptabsrc.cxx
index f741943f76e3..d7825f056d91 100644
--- a/sc/source/core/data/dptabsrc.cxx
+++ b/sc/source/core/data/dptabsrc.cxx
@@ -1212,9 +1212,6 @@ ScDPDimensions::~ScDPDimensions()
if (ppDims)
{
- for (long i=0; i<nDimCount; i++)
- if ( ppDims[i] )
- ppDims[i]->release(); // ref-counted
delete[] ppDims;
}
}
@@ -1227,15 +1224,12 @@ void ScDPDimensions::CountChanged()
{
long i;
long nCopy = std::min( nNewCount, nDimCount );
- ScDPDimension** ppNew = new ScDPDimension*[nNewCount];
+ rtl::Reference<ScDPDimension>* ppNew = new rtl::Reference<ScDPDimension>[nNewCount];
for (i=0; i<nCopy; i++) // copy existing dims
ppNew[i] = ppDims[i];
for (i=nCopy; i<nNewCount; i++) // clear additional pointers
ppNew[i] = nullptr;
- for (i=nCopy; i<nDimCount; i++) // delete old dims if count is decreased
- if ( ppDims[i] )
- ppDims[i]->release(); // ref-counted
delete[] ppDims;
ppDims = ppNew;
@@ -1307,17 +1301,16 @@ ScDPDimension* ScDPDimensions::getByIndex(long nIndex) const
{
if ( !ppDims )
{
- const_cast<ScDPDimensions*>(this)->ppDims = new ScDPDimension*[nDimCount];
+ const_cast<ScDPDimensions*>(this)->ppDims = new rtl::Reference<ScDPDimension>[nDimCount];
for (long i=0; i<nDimCount; i++)
ppDims[i] = nullptr;
}
- if ( !ppDims[nIndex] )
+ if ( !ppDims[nIndex].is() )
{
ppDims[nIndex] = new ScDPDimension( pSource, nIndex );
- ppDims[nIndex]->acquire(); // ref-counted
}
- return ppDims[nIndex];
+ return ppDims[nIndex].get();
}
return nullptr; //TODO: exception?
@@ -1690,9 +1683,6 @@ ScDPHierarchies::~ScDPHierarchies()
if (ppHiers)
{
- for (long i=0; i<nHierCount; i++)
- if ( ppHiers[i] )
- ppHiers[i]->release(); // ref-counted
delete[] ppHiers;
}
}
@@ -1761,17 +1751,16 @@ ScDPHierarchy* ScDPHierarchies::getByIndex(long nIndex) const
{
if ( !ppHiers )
{
- const_cast<ScDPHierarchies*>(this)->ppHiers = new ScDPHierarchy*[nHierCount];
+ const_cast<ScDPHierarchies*>(this)->ppHiers = new rtl::Reference<ScDPHierarchy>[nHierCount];
for (long i=0; i<nHierCount; i++)
ppHiers[i] = nullptr;
}
- if ( !ppHiers[nIndex] )
+ if ( !ppHiers[nIndex].is() )
{
ppHiers[nIndex] = new ScDPHierarchy( pSource, nDim, nIndex );
- ppHiers[nIndex]->acquire(); // ref-counted
}
- return ppHiers[nIndex];
+ return ppHiers[nIndex].get();
}
return nullptr; //TODO: exception?
@@ -1864,9 +1853,6 @@ ScDPLevels::~ScDPLevels()
if (ppLevs)
{
- for (long i=0; i<nLevCount; i++)
- if ( ppLevs[i] )
- ppLevs[i]->release(); // ref-counted
delete[] ppLevs;
}
}
@@ -1932,17 +1918,16 @@ ScDPLevel* ScDPLevels::getByIndex(long nIndex) const
{
if ( !ppLevs )
{
- const_cast<ScDPLevels*>(this)->ppLevs = new ScDPLevel*[nLevCount];
+ const_cast<ScDPLevels*>(this)->ppLevs = new rtl::Reference<ScDPLevel>[nLevCount];
for (long i=0; i<nLevCount; i++)
ppLevs[i] = nullptr;
}
- if ( !ppLevs[nIndex] )
+ if ( !ppLevs[nIndex].is() )
{
ppLevs[nIndex] = new ScDPLevel( pSource, nDim, nHier, nIndex );
- ppLevs[nIndex]->acquire(); // ref-counted
}
- return ppLevs[nIndex];
+ return ppLevs[nIndex].get();
}
return nullptr; //TODO: exception?