summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2016-05-24 11:02:42 +0200
committerNoel Grandin <noel@peralex.com>2016-05-24 11:02:42 +0200
commit95d20a3799998b9816bd2e8aebdbc96c61cead3e (patch)
tree8206ecc848631432cb8b027d5e780483734f808a /sc
parent3caf31b05d7bbf3d50a1bbda6c8b95982cb5c2b5 (diff)
Revert "remove some manual ref-counting"
until I have a better understanding of the UNO reference counting. This reverts commit 111de438ea3e512a541281dc0716cc728ea8d152.
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, 82 insertions, 47 deletions
diff --git a/sc/inc/datauno.hxx b/sc/inc/datauno.hxx
index cb33562bf0b2..cbaebc7514a9 100644
--- a/sc/inc/datauno.hxx
+++ b/sc/inc/datauno.hxx
@@ -222,7 +222,7 @@ public:
class ScRangeSubTotalDescriptor : public ScSubTotalDescriptorBase
{
private:
- css::uno::Reference<ScDatabaseRangeObj> mxParent;
+ ScDatabaseRangeObj* pParent;
public:
ScRangeSubTotalDescriptor(ScDatabaseRangeObj* pPar);
@@ -435,7 +435,7 @@ public:
class ScRangeFilterDescriptor : public ScFilterDescriptorBase
{
private:
- css::uno::Reference<ScDatabaseRangeObj> mxParent;
+ ScDatabaseRangeObj* pParent;
public:
ScRangeFilterDescriptor(ScDocShell* pDocSh, ScDatabaseRangeObj* pPar);
@@ -451,7 +451,7 @@ public:
class ScDataPilotFilterDescriptor : public ScFilterDescriptorBase
{
private:
- css::uno::Reference<ScDataPilotDescriptorBase> mxParent;
+ ScDataPilotDescriptorBase* pParent;
public:
ScDataPilotFilterDescriptor(ScDocShell* pDocSh, ScDataPilotDescriptorBase* pPar);
diff --git a/sc/inc/dptabsrc.hxx b/sc/inc/dptabsrc.hxx
index bfc9e2924f3f..035ba282ef9d 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)
- css::uno::Reference<ScDPHierarchies> mxHierarchies;
+ ScDPHierarchies* pHierarchies;
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;
- css::uno::Reference<ScDPLevels> mxLevels;
+ ScDPLevels* pLevels;
public:
ScDPHierarchy( ScDPSource* pSrc, long nD, long nH );
@@ -539,7 +539,7 @@ private:
long nDim;
long nHier;
long nLev;
- css::uno::Reference<ScDPMembers> mxMembers;
+ ScDPMembers* pMembers;
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 ce48a82446cb..c652cf2af303 100644
--- a/sc/source/core/data/dptabsrc.cxx
+++ b/sc/source/core/data/dptabsrc.cxx
@@ -1333,6 +1333,7 @@ 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),
@@ -1349,16 +1350,20 @@ ScDPDimension::~ScDPDimension()
{
//TODO: release pSource
+ if ( pHierarchies )
+ pHierarchies->release(); // ref-counted
+
delete pSelectedData;
}
ScDPHierarchies* ScDPDimension::GetHierarchiesObject()
{
- if (!mxHierarchies.is())
+ if (!pHierarchies)
{
- mxHierarchies = new ScDPHierarchies( pSource, nDim );
+ pHierarchies = new ScDPHierarchies( pSource, nDim );
+ pHierarchies->acquire(); // ref-counted
}
- return mxHierarchies.get();
+ return pHierarchies;
}
const OUString* ScDPDimension::GetLayoutName() const
@@ -1785,7 +1790,8 @@ ScDPHierarchy* ScDPHierarchies::getByIndex(long nIndex) const
ScDPHierarchy::ScDPHierarchy( ScDPSource* pSrc, long nD, long nH ) :
pSource( pSrc ),
nDim( nD ),
- nHier( nH )
+ nHier( nH ),
+ pLevels( nullptr )
{
//TODO: hold pSource
}
@@ -1793,15 +1799,19 @@ ScDPHierarchy::ScDPHierarchy( ScDPSource* pSrc, long nD, long nH ) :
ScDPHierarchy::~ScDPHierarchy()
{
//TODO: release pSource
+
+ if (pLevels)
+ pLevels->release(); // ref-counted
}
ScDPLevels* ScDPHierarchy::GetLevelsObject()
{
- if (!mxLevels.is())
+ if (!pLevels)
{
- mxLevels = new ScDPLevels( pSource, nDim, nHier );
+ pLevels = new ScDPLevels( pSource, nDim, nHier );
+ pLevels->acquire(); // ref-counted
}
- return mxLevels.get();
+ return pLevels;
}
uno::Reference<container::XNameAccess> SAL_CALL ScDPHierarchy::getLevels()
@@ -1987,6 +1997,7 @@ 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 ),
@@ -2001,6 +2012,9 @@ ScDPLevel::ScDPLevel( ScDPSource* pSrc, long nD, long nH, long nL ) :
ScDPLevel::~ScDPLevel()
{
//TODO: release pSource
+
+ if ( pMembers )
+ pMembers->release(); // ref-counted
}
void ScDPLevel::EvaluateSortOrder()
@@ -2067,11 +2081,12 @@ void ScDPLevel::SetEnableLayout(bool bSet)
ScDPMembers* ScDPLevel::GetMembersObject()
{
- if (!mxMembers.is())
+ if (!pMembers)
{
- mxMembers = new ScDPMembers( pSource, nDim, nHier, nLev );
+ pMembers = new ScDPMembers( pSource, nDim, nHier, nLev );
+ pMembers->acquire(); // ref-counted
}
- return mxMembers.get();
+ return pMembers;
}
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 2709e613240b..ee4d1ec01480 100644
--- a/sc/source/ui/drawfunc/drtxtob.cxx
+++ b/sc/source/ui/drawfunc/drtxtob.cxx
@@ -113,6 +113,7 @@ void ScDrawTextObjectBar::StateDisableItems( SfxItemSet &rSet )
ScDrawTextObjectBar::ScDrawTextObjectBar(ScViewData* pData) :
SfxShell(pData->GetViewShell()),
pViewData(pData),
+ pClipEvtLstnr(nullptr),
bPastePossible(false)
{
SetPool( pViewData->GetScDrawView()->GetDefaultAttr().GetPool() );
@@ -132,13 +133,15 @@ ScDrawTextObjectBar::ScDrawTextObjectBar(ScViewData* pData) :
ScDrawTextObjectBar::~ScDrawTextObjectBar()
{
- if ( mxClipEvtLstnr.is() )
+ if ( pClipEvtLstnr )
{
- mxClipEvtLstnr->AddRemoveListener( pViewData->GetActiveWin(), false );
+ pClipEvtLstnr->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.
- mxClipEvtLstnr->ClearCallbackLink();
+ pClipEvtLstnr->ClearCallbackLink();
+
+ pClipEvtLstnr->release();
}
}
@@ -489,12 +492,13 @@ void ScDrawTextObjectBar::GetClipState( SfxItemSet& rSet )
return;
}
- if ( !mxClipEvtLstnr.is() )
+ if ( !pClipEvtLstnr )
{
// create listener
- mxClipEvtLstnr = new TransferableClipboardListener( LINK( this, ScDrawTextObjectBar, ClipboardChanged ) );
+ pClipEvtLstnr = new TransferableClipboardListener( LINK( this, ScDrawTextObjectBar, ClipboardChanged ) );
+ pClipEvtLstnr->acquire();
vcl::Window* pWin = pViewData->GetActiveWin();
- mxClipEvtLstnr->AddRemoveListener( pWin, true );
+ pClipEvtLstnr->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 7b40147ddff4..09c1d94d4bfa 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;
- css::uno::Reference<TransferableClipboardListener> mxClipEvtLstnr;
+ TransferableClipboardListener* pClipEvtLstnr;
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 77b3e8b24480..85d5fdfc1ccf 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;
- css::uno::Reference<TransferableClipboardListener> mxClipEvtLstnr;
+ TransferableClipboardListener* pClipEvtLstnr;
bool bPastePossible;
bool bIsInsertMode;
diff --git a/sc/source/ui/unoobj/datauno.cxx b/sc/source/ui/unoobj/datauno.cxx
index 9c03c5c1e7bd..2772aa2cb536 100644
--- a/sc/source/ui/unoobj/datauno.cxx
+++ b/sc/source/ui/unoobj/datauno.cxx
@@ -806,24 +806,28 @@ void ScSubTotalDescriptor::SetParam( const ScSubTotalParam& rNew )
}
ScRangeSubTotalDescriptor::ScRangeSubTotalDescriptor(ScDatabaseRangeObj* pPar) :
- mxParent(pPar)
+ pParent(pPar)
{
+ if (pParent)
+ pParent->acquire();
}
ScRangeSubTotalDescriptor::~ScRangeSubTotalDescriptor()
{
+ if (pParent)
+ pParent->release();
}
void ScRangeSubTotalDescriptor::GetData( ScSubTotalParam& rParam ) const
{
- if (mxParent.is())
- mxParent->GetSubTotalParam( rParam );
+ if (pParent)
+ pParent->GetSubTotalParam( rParam );
}
void ScRangeSubTotalDescriptor::PutData( const ScSubTotalParam& rParam )
{
- if (mxParent.is())
- mxParent->SetSubTotalParam( rParam );
+ if (pParent)
+ pParent->SetSubTotalParam( rParam );
}
ScConsolidationDescriptor::ScConsolidationDescriptor()
@@ -1540,41 +1544,49 @@ void ScFilterDescriptor::SetParam( const ScQueryParam& rNew )
ScRangeFilterDescriptor::ScRangeFilterDescriptor(ScDocShell* pDocShell, ScDatabaseRangeObj* pPar) :
ScFilterDescriptorBase(pDocShell),
- mxParent(pPar)
+ pParent(pPar)
{
+ if (pParent)
+ pParent->acquire();
}
ScRangeFilterDescriptor::~ScRangeFilterDescriptor()
{
+ if (pParent)
+ pParent->release();
}
void ScRangeFilterDescriptor::GetData( ScQueryParam& rParam ) const
{
- if (mxParent.is())
- mxParent->GetQueryParam( rParam );
+ if (pParent)
+ pParent->GetQueryParam( rParam );
}
void ScRangeFilterDescriptor::PutData( const ScQueryParam& rParam )
{
- if (mxParent.is())
- mxParent->SetQueryParam( rParam );
+ if (pParent)
+ pParent->SetQueryParam( rParam );
}
ScDataPilotFilterDescriptor::ScDataPilotFilterDescriptor(ScDocShell* pDocShell, ScDataPilotDescriptorBase* pPar) :
ScFilterDescriptorBase(pDocShell),
- mxParent(pPar)
+ pParent(pPar)
{
+ if (pParent)
+ pParent->acquire();
}
ScDataPilotFilterDescriptor::~ScDataPilotFilterDescriptor()
{
+ if (pParent)
+ pParent->release();
}
void ScDataPilotFilterDescriptor::GetData( ScQueryParam& rParam ) const
{
- if (mxParent.is())
+ if (pParent)
{
- ScDPObject* pDPObj = mxParent->GetDPObject();
+ ScDPObject* pDPObj = pParent->GetDPObject();
if (pDPObj && pDPObj->IsSheetData())
rParam = pDPObj->GetSheetDesc()->GetQueryParam();
}
@@ -1582,17 +1594,17 @@ void ScDataPilotFilterDescriptor::GetData( ScQueryParam& rParam ) const
void ScDataPilotFilterDescriptor::PutData( const ScQueryParam& rParam )
{
- if (mxParent.is())
+ if (pParent)
{
- ScDPObject* pDPObj = mxParent->GetDPObject();
+ ScDPObject* pDPObj = pParent->GetDPObject();
if (pDPObj)
{
- ScSheetSourceDesc aSheetDesc(&mxParent->GetDocShell()->GetDocument());
+ ScSheetSourceDesc aSheetDesc(&pParent->GetDocShell()->GetDocument());
if (pDPObj->IsSheetData())
aSheetDesc = *pDPObj->GetSheetDesc();
aSheetDesc.SetQueryParam(rParam);
pDPObj->SetSheetDesc(aSheetDesc);
- mxParent->SetDPObject(pDPObj);
+ pParent->SetDPObject(pDPObj);
}
}
}
diff --git a/sc/source/ui/view/editsh.cxx b/sc/source/ui/view/editsh.cxx
index 622989308f44..92f211e13d71 100644
--- a/sc/source/ui/view/editsh.cxx
+++ b/sc/source/ui/view/editsh.cxx
@@ -93,6 +93,7 @@ void ScEditShell::InitInterface_Impl()
ScEditShell::ScEditShell(EditView* pView, ScViewData* pData) :
pEditView (pView),
pViewData (pData),
+ pClipEvtLstnr (nullptr),
bPastePossible (false),
bIsInsertMode (true)
{
@@ -104,13 +105,15 @@ ScEditShell::ScEditShell(EditView* pView, ScViewData* pData) :
ScEditShell::~ScEditShell()
{
- if ( mxClipEvtLstnr.is() )
+ if ( pClipEvtLstnr )
{
- mxClipEvtLstnr->AddRemoveListener( pViewData->GetActiveWin(), false );
+ pClipEvtLstnr->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.
- mxClipEvtLstnr->ClearCallbackLink();
+ pClipEvtLstnr->ClearCallbackLink();
+
+ pClipEvtLstnr->release();
}
}
@@ -806,12 +809,13 @@ IMPL_LINK_TYPED( ScEditShell, ClipboardChanged, TransferableDataHelper*, pDataHe
void ScEditShell::GetClipState( SfxItemSet& rSet )
{
- if ( !mxClipEvtLstnr.is() )
+ if ( !pClipEvtLstnr )
{
// create listener
- mxClipEvtLstnr = new TransferableClipboardListener( LINK( this, ScEditShell, ClipboardChanged ) );
+ pClipEvtLstnr = new TransferableClipboardListener( LINK( this, ScEditShell, ClipboardChanged ) );
+ pClipEvtLstnr->acquire();
vcl::Window* pWin = pViewData->GetActiveWin();
- mxClipEvtLstnr->AddRemoveListener( pWin, true );
+ pClipEvtLstnr->AddRemoveListener( pWin, true );
// get initial state
TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pViewData->GetActiveWin() ) );