summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2016-05-23 13:53:42 +0200
committerNoel Grandin <noelgrandin@gmail.com>2016-05-24 06:54:06 +0000
commit111de438ea3e512a541281dc0716cc728ea8d152 (patch)
tree2c9ca866e79ed0cfc9299e553a87239345c515a6 /sc
parentd3f21849ec8580fdb59a1f0b35453657f4050e0f (diff)
remove some manual ref-counting
triggered when I noticed a class doing acquire() in the constructor and then release() in the destructor. found mostly by git grep -n -B5 -e '->release()' Change-Id: Ie1abeaed75c1f861df185e3bde680272dbadc97f Reviewed-on: https://gerrit.libreoffice.org/25363 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/datauno.hxx6
-rw-r--r--sc/inc/dptabsrc.hxx6
-rw-r--r--sc/source/core/data/dptabsrc.cxx35
-rw-r--r--sc/source/ui/drawfunc/drtxtob.cxx16
-rw-r--r--sc/source/ui/inc/drtxtob.hxx2
-rw-r--r--sc/source/ui/inc/editsh.hxx2
-rw-r--r--sc/source/ui/unoobj/datauno.cxx46
-rw-r--r--sc/source/ui/view/editsh.cxx16
8 files changed, 47 insertions, 82 deletions
diff --git a/sc/inc/datauno.hxx b/sc/inc/datauno.hxx
index cbaebc7514a9..cb33562bf0b2 100644
--- a/sc/inc/datauno.hxx
+++ b/sc/inc/datauno.hxx
@@ -222,7 +222,7 @@ public:
class ScRangeSubTotalDescriptor : public ScSubTotalDescriptorBase
{
private:
- ScDatabaseRangeObj* pParent;
+ css::uno::Reference<ScDatabaseRangeObj> mxParent;
public:
ScRangeSubTotalDescriptor(ScDatabaseRangeObj* pPar);
@@ -435,7 +435,7 @@ public:
class ScRangeFilterDescriptor : public ScFilterDescriptorBase
{
private:
- ScDatabaseRangeObj* pParent;
+ css::uno::Reference<ScDatabaseRangeObj> mxParent;
public:
ScRangeFilterDescriptor(ScDocShell* pDocSh, ScDatabaseRangeObj* pPar);
@@ -451,7 +451,7 @@ public:
class ScDataPilotFilterDescriptor : public ScFilterDescriptorBase
{
private:
- ScDataPilotDescriptorBase* pParent;
+ css::uno::Reference<ScDataPilotDescriptorBase> mxParent;
public:
ScDataPilotFilterDescriptor(ScDocShell* pDocSh, ScDataPilotDescriptorBase* pPar);
diff --git a/sc/inc/dptabsrc.hxx b/sc/inc/dptabsrc.hxx
index 035ba282ef9d..bfc9e2924f3f 100644
--- a/sc/inc/dptabsrc.hxx
+++ b/sc/inc/dptabsrc.hxx
@@ -307,7 +307,7 @@ class ScDPDimension : public cppu::WeakImplHelper<
{
ScDPSource* pSource;
long nDim; // dimension index (== column ID)
- ScDPHierarchies* pHierarchies;
+ css::uno::Reference<ScDPHierarchies> mxHierarchies;
long nUsedHier;
sal_uInt16 nFunction; // enum GeneralFunction
OUString aName; // if empty, take from source
@@ -459,7 +459,7 @@ private:
ScDPSource* pSource;
long nDim;
long nHier;
- ScDPLevels* pLevels;
+ css::uno::Reference<ScDPLevels> mxLevels;
public:
ScDPHierarchy( ScDPSource* pSrc, long nD, long nH );
@@ -539,7 +539,7 @@ private:
long nDim;
long nHier;
long nLev;
- ScDPMembers* pMembers;
+ css::uno::Reference<ScDPMembers> mxMembers;
css::uno::Sequence<css::sheet::GeneralFunction> aSubTotals;
css::sheet::DataPilotFieldSortInfo aSortInfo; // stored user settings
css::sheet::DataPilotFieldAutoShowInfo aAutoShowInfo; // stored user settings
diff --git a/sc/source/core/data/dptabsrc.cxx b/sc/source/core/data/dptabsrc.cxx
index c652cf2af303..ce48a82446cb 100644
--- a/sc/source/core/data/dptabsrc.cxx
+++ b/sc/source/core/data/dptabsrc.cxx
@@ -1333,7 +1333,6 @@ ScDPDimension* ScDPDimensions::getByIndex(long nIndex) const
ScDPDimension::ScDPDimension( ScDPSource* pSrc, long nD ) :
pSource( pSrc ),
nDim( nD ),
- pHierarchies( nullptr ),
nUsedHier( 0 ),
nFunction( SUBTOTAL_FUNC_SUM ), // sum is default
mpLayoutName(nullptr),
@@ -1350,20 +1349,16 @@ ScDPDimension::~ScDPDimension()
{
//TODO: release pSource
- if ( pHierarchies )
- pHierarchies->release(); // ref-counted
-
delete pSelectedData;
}
ScDPHierarchies* ScDPDimension::GetHierarchiesObject()
{
- if (!pHierarchies)
+ if (!mxHierarchies.is())
{
- pHierarchies = new ScDPHierarchies( pSource, nDim );
- pHierarchies->acquire(); // ref-counted
+ mxHierarchies = new ScDPHierarchies( pSource, nDim );
}
- return pHierarchies;
+ return mxHierarchies.get();
}
const OUString* ScDPDimension::GetLayoutName() const
@@ -1790,8 +1785,7 @@ ScDPHierarchy* ScDPHierarchies::getByIndex(long nIndex) const
ScDPHierarchy::ScDPHierarchy( ScDPSource* pSrc, long nD, long nH ) :
pSource( pSrc ),
nDim( nD ),
- nHier( nH ),
- pLevels( nullptr )
+ nHier( nH )
{
//TODO: hold pSource
}
@@ -1799,19 +1793,15 @@ ScDPHierarchy::ScDPHierarchy( ScDPSource* pSrc, long nD, long nH ) :
ScDPHierarchy::~ScDPHierarchy()
{
//TODO: release pSource
-
- if (pLevels)
- pLevels->release(); // ref-counted
}
ScDPLevels* ScDPHierarchy::GetLevelsObject()
{
- if (!pLevels)
+ if (!mxLevels.is())
{
- pLevels = new ScDPLevels( pSource, nDim, nHier );
- pLevels->acquire(); // ref-counted
+ mxLevels = new ScDPLevels( pSource, nDim, nHier );
}
- return pLevels;
+ return mxLevels.get();
}
uno::Reference<container::XNameAccess> SAL_CALL ScDPHierarchy::getLevels()
@@ -1997,7 +1987,6 @@ ScDPLevel::ScDPLevel( ScDPSource* pSrc, long nD, long nH, long nL ) :
nDim( nD ),
nHier( nH ),
nLev( nL ),
- pMembers( nullptr ),
aSortInfo( EMPTY_OUSTRING, true, sheet::DataPilotFieldSortMode::NAME ), // default: sort by name
nSortMeasure( 0 ),
nAutoMeasure( 0 ),
@@ -2012,9 +2001,6 @@ ScDPLevel::ScDPLevel( ScDPSource* pSrc, long nD, long nH, long nL ) :
ScDPLevel::~ScDPLevel()
{
//TODO: release pSource
-
- if ( pMembers )
- pMembers->release(); // ref-counted
}
void ScDPLevel::EvaluateSortOrder()
@@ -2081,12 +2067,11 @@ void ScDPLevel::SetEnableLayout(bool bSet)
ScDPMembers* ScDPLevel::GetMembersObject()
{
- if (!pMembers)
+ if (!mxMembers.is())
{
- pMembers = new ScDPMembers( pSource, nDim, nHier, nLev );
- pMembers->acquire(); // ref-counted
+ mxMembers = new ScDPMembers( pSource, nDim, nHier, nLev );
}
- return pMembers;
+ return mxMembers.get();
}
uno::Reference<container::XNameAccess> SAL_CALL ScDPLevel::getMembers() throw(uno::RuntimeException, std::exception)
diff --git a/sc/source/ui/drawfunc/drtxtob.cxx b/sc/source/ui/drawfunc/drtxtob.cxx
index ee4d1ec01480..2709e613240b 100644
--- a/sc/source/ui/drawfunc/drtxtob.cxx
+++ b/sc/source/ui/drawfunc/drtxtob.cxx
@@ -113,7 +113,6 @@ void ScDrawTextObjectBar::StateDisableItems( SfxItemSet &rSet )
ScDrawTextObjectBar::ScDrawTextObjectBar(ScViewData* pData) :
SfxShell(pData->GetViewShell()),
pViewData(pData),
- pClipEvtLstnr(nullptr),
bPastePossible(false)
{
SetPool( pViewData->GetScDrawView()->GetDefaultAttr().GetPool() );
@@ -133,15 +132,13 @@ ScDrawTextObjectBar::ScDrawTextObjectBar(ScViewData* pData) :
ScDrawTextObjectBar::~ScDrawTextObjectBar()
{
- if ( pClipEvtLstnr )
+ if ( mxClipEvtLstnr.is() )
{
- pClipEvtLstnr->AddRemoveListener( pViewData->GetActiveWin(), false );
+ mxClipEvtLstnr->AddRemoveListener( pViewData->GetActiveWin(), false );
// The listener may just now be waiting for the SolarMutex and call the link
// afterwards, in spite of RemoveListener. So the link has to be reset, too.
- pClipEvtLstnr->ClearCallbackLink();
-
- pClipEvtLstnr->release();
+ mxClipEvtLstnr->ClearCallbackLink();
}
}
@@ -492,13 +489,12 @@ void ScDrawTextObjectBar::GetClipState( SfxItemSet& rSet )
return;
}
- if ( !pClipEvtLstnr )
+ if ( !mxClipEvtLstnr.is() )
{
// create listener
- pClipEvtLstnr = new TransferableClipboardListener( LINK( this, ScDrawTextObjectBar, ClipboardChanged ) );
- pClipEvtLstnr->acquire();
+ mxClipEvtLstnr = new TransferableClipboardListener( LINK( this, ScDrawTextObjectBar, ClipboardChanged ) );
vcl::Window* pWin = pViewData->GetActiveWin();
- pClipEvtLstnr->AddRemoveListener( pWin, true );
+ mxClipEvtLstnr->AddRemoveListener( pWin, true );
// get initial state
TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pViewData->GetActiveWin() ) );
diff --git a/sc/source/ui/inc/drtxtob.hxx b/sc/source/ui/inc/drtxtob.hxx
index 09c1d94d4bfa..7b40147ddff4 100644
--- a/sc/source/ui/inc/drtxtob.hxx
+++ b/sc/source/ui/inc/drtxtob.hxx
@@ -35,7 +35,7 @@ class TransferableClipboardListener;
class ScDrawTextObjectBar : public SfxShell
{
ScViewData* pViewData;
- TransferableClipboardListener* pClipEvtLstnr;
+ css::uno::Reference<TransferableClipboardListener> mxClipEvtLstnr;
bool bPastePossible;
DECL_LINK_TYPED( ClipboardChanged, TransferableDataHelper*, void );
diff --git a/sc/source/ui/inc/editsh.hxx b/sc/source/ui/inc/editsh.hxx
index 85d5fdfc1ccf..77b3e8b24480 100644
--- a/sc/source/ui/inc/editsh.hxx
+++ b/sc/source/ui/inc/editsh.hxx
@@ -39,7 +39,7 @@ class ScEditShell : public SfxShell
private:
EditView* pEditView;
ScViewData* pViewData;
- TransferableClipboardListener* pClipEvtLstnr;
+ css::uno::Reference<TransferableClipboardListener> mxClipEvtLstnr;
bool bPastePossible;
bool bIsInsertMode;
diff --git a/sc/source/ui/unoobj/datauno.cxx b/sc/source/ui/unoobj/datauno.cxx
index 2772aa2cb536..9c03c5c1e7bd 100644
--- a/sc/source/ui/unoobj/datauno.cxx
+++ b/sc/source/ui/unoobj/datauno.cxx
@@ -806,28 +806,24 @@ void ScSubTotalDescriptor::SetParam( const ScSubTotalParam& rNew )
}
ScRangeSubTotalDescriptor::ScRangeSubTotalDescriptor(ScDatabaseRangeObj* pPar) :
- pParent(pPar)
+ mxParent(pPar)
{
- if (pParent)
- pParent->acquire();
}
ScRangeSubTotalDescriptor::~ScRangeSubTotalDescriptor()
{
- if (pParent)
- pParent->release();
}
void ScRangeSubTotalDescriptor::GetData( ScSubTotalParam& rParam ) const
{
- if (pParent)
- pParent->GetSubTotalParam( rParam );
+ if (mxParent.is())
+ mxParent->GetSubTotalParam( rParam );
}
void ScRangeSubTotalDescriptor::PutData( const ScSubTotalParam& rParam )
{
- if (pParent)
- pParent->SetSubTotalParam( rParam );
+ if (mxParent.is())
+ mxParent->SetSubTotalParam( rParam );
}
ScConsolidationDescriptor::ScConsolidationDescriptor()
@@ -1544,49 +1540,41 @@ void ScFilterDescriptor::SetParam( const ScQueryParam& rNew )
ScRangeFilterDescriptor::ScRangeFilterDescriptor(ScDocShell* pDocShell, ScDatabaseRangeObj* pPar) :
ScFilterDescriptorBase(pDocShell),
- pParent(pPar)
+ mxParent(pPar)
{
- if (pParent)
- pParent->acquire();
}
ScRangeFilterDescriptor::~ScRangeFilterDescriptor()
{
- if (pParent)
- pParent->release();
}
void ScRangeFilterDescriptor::GetData( ScQueryParam& rParam ) const
{
- if (pParent)
- pParent->GetQueryParam( rParam );
+ if (mxParent.is())
+ mxParent->GetQueryParam( rParam );
}
void ScRangeFilterDescriptor::PutData( const ScQueryParam& rParam )
{
- if (pParent)
- pParent->SetQueryParam( rParam );
+ if (mxParent.is())
+ mxParent->SetQueryParam( rParam );
}
ScDataPilotFilterDescriptor::ScDataPilotFilterDescriptor(ScDocShell* pDocShell, ScDataPilotDescriptorBase* pPar) :
ScFilterDescriptorBase(pDocShell),
- pParent(pPar)
+ mxParent(pPar)
{
- if (pParent)
- pParent->acquire();
}
ScDataPilotFilterDescriptor::~ScDataPilotFilterDescriptor()
{
- if (pParent)
- pParent->release();
}
void ScDataPilotFilterDescriptor::GetData( ScQueryParam& rParam ) const
{
- if (pParent)
+ if (mxParent.is())
{
- ScDPObject* pDPObj = pParent->GetDPObject();
+ ScDPObject* pDPObj = mxParent->GetDPObject();
if (pDPObj && pDPObj->IsSheetData())
rParam = pDPObj->GetSheetDesc()->GetQueryParam();
}
@@ -1594,17 +1582,17 @@ void ScDataPilotFilterDescriptor::GetData( ScQueryParam& rParam ) const
void ScDataPilotFilterDescriptor::PutData( const ScQueryParam& rParam )
{
- if (pParent)
+ if (mxParent.is())
{
- ScDPObject* pDPObj = pParent->GetDPObject();
+ ScDPObject* pDPObj = mxParent->GetDPObject();
if (pDPObj)
{
- ScSheetSourceDesc aSheetDesc(&pParent->GetDocShell()->GetDocument());
+ ScSheetSourceDesc aSheetDesc(&mxParent->GetDocShell()->GetDocument());
if (pDPObj->IsSheetData())
aSheetDesc = *pDPObj->GetSheetDesc();
aSheetDesc.SetQueryParam(rParam);
pDPObj->SetSheetDesc(aSheetDesc);
- pParent->SetDPObject(pDPObj);
+ mxParent->SetDPObject(pDPObj);
}
}
}
diff --git a/sc/source/ui/view/editsh.cxx b/sc/source/ui/view/editsh.cxx
index 92f211e13d71..622989308f44 100644
--- a/sc/source/ui/view/editsh.cxx
+++ b/sc/source/ui/view/editsh.cxx
@@ -93,7 +93,6 @@ void ScEditShell::InitInterface_Impl()
ScEditShell::ScEditShell(EditView* pView, ScViewData* pData) :
pEditView (pView),
pViewData (pData),
- pClipEvtLstnr (nullptr),
bPastePossible (false),
bIsInsertMode (true)
{
@@ -105,15 +104,13 @@ ScEditShell::ScEditShell(EditView* pView, ScViewData* pData) :
ScEditShell::~ScEditShell()
{
- if ( pClipEvtLstnr )
+ if ( mxClipEvtLstnr.is() )
{
- pClipEvtLstnr->AddRemoveListener( pViewData->GetActiveWin(), false );
+ mxClipEvtLstnr->AddRemoveListener( pViewData->GetActiveWin(), false );
// The listener may just now be waiting for the SolarMutex and call the link
// afterwards, in spite of RemoveListener. So the link has to be reset, too.
- pClipEvtLstnr->ClearCallbackLink();
-
- pClipEvtLstnr->release();
+ mxClipEvtLstnr->ClearCallbackLink();
}
}
@@ -809,13 +806,12 @@ IMPL_LINK_TYPED( ScEditShell, ClipboardChanged, TransferableDataHelper*, pDataHe
void ScEditShell::GetClipState( SfxItemSet& rSet )
{
- if ( !pClipEvtLstnr )
+ if ( !mxClipEvtLstnr.is() )
{
// create listener
- pClipEvtLstnr = new TransferableClipboardListener( LINK( this, ScEditShell, ClipboardChanged ) );
- pClipEvtLstnr->acquire();
+ mxClipEvtLstnr = new TransferableClipboardListener( LINK( this, ScEditShell, ClipboardChanged ) );
vcl::Window* pWin = pViewData->GetActiveWin();
- pClipEvtLstnr->AddRemoveListener( pWin, true );
+ mxClipEvtLstnr->AddRemoveListener( pWin, true );
// get initial state
TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pViewData->GetActiveWin() ) );