use UnoCursorPointer in SwXCellRange and SwChartDataSequence
Change-Id: I23d75d094c2b2dd8d234b608556a8b2339b7f166
This commit is contained in:
@@ -50,12 +50,12 @@
|
||||
|
||||
#include <calbck.hxx>
|
||||
#include <frmfmt.hxx>
|
||||
#include <unocrsr.hxx>
|
||||
|
||||
class SfxItemPropertySet;
|
||||
class SwDoc;
|
||||
class SwTable;
|
||||
class SwTableBox;
|
||||
class SwUnoCrsr;
|
||||
struct SwRangeDescriptor;
|
||||
class SwSelBoxes;
|
||||
class SwFrameFormat;
|
||||
@@ -265,8 +265,7 @@ class SwChartDataSequence :
|
||||
::com::sun::star::uno::Reference< com::sun::star::chart2::data::XDataProvider > xDataProvider;
|
||||
SwChartDataProvider * pDataProvider;
|
||||
|
||||
std::shared_ptr<SwUnoCrsr> pTableCrsr; // cursor spanned over cells to use
|
||||
SwDepend aCursorDepend; //the cursor is removed after the doc has been removed
|
||||
sw::UnoCursorPointer pTableCrsr; // cursor spanned over cells to use
|
||||
|
||||
const SfxItemPropertySet* _pPropSet;
|
||||
|
||||
@@ -278,7 +277,6 @@ class SwChartDataSequence :
|
||||
protected:
|
||||
//SwClient
|
||||
virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) SAL_OVERRIDE;
|
||||
virtual void SwClientNotify(const SwModify&, const SfxHint&) SAL_OVERRIDE;
|
||||
|
||||
public:
|
||||
SwChartDataSequence( SwChartDataProvider &rProvider,
|
||||
|
@@ -44,7 +44,6 @@
|
||||
#include <tuple>
|
||||
#include <unocrsr.hxx>
|
||||
|
||||
class SwUnoCrsr;
|
||||
class SwTable;
|
||||
class SwTableBox;
|
||||
class SwTableLine;
|
||||
@@ -456,14 +455,13 @@ class SwXCellRange : public cppu::WeakImplHelper
|
||||
>,
|
||||
public SwClient
|
||||
{
|
||||
SwDepend aCursorDepend; //the cursor is removed after the doc has been removed
|
||||
::osl::Mutex m_Mutex;
|
||||
::cppu::OInterfaceContainerHelper m_ChartListeners;
|
||||
|
||||
SwRangeDescriptor aRgDesc;
|
||||
const SfxItemPropertySet* m_pPropSet;
|
||||
|
||||
std::shared_ptr<SwUnoCrsr> m_pTableCrsr;
|
||||
sw::UnoCursorPointer m_pTableCrsr;
|
||||
|
||||
bool m_bFirstRowAsLabel;
|
||||
bool m_bFirstColumnAsLabel;
|
||||
@@ -472,14 +470,10 @@ class SwXCellRange : public cppu::WeakImplHelper
|
||||
void setLabelDescriptions(const css::uno::Sequence<OUString>& rDesc, bool bRow);
|
||||
|
||||
public:
|
||||
SwXCellRange(std::shared_ptr<SwUnoCrsr> pCrsr, SwFrameFormat& rFrameFormat, SwRangeDescriptor& rDesc);
|
||||
SwXCellRange(sw::UnoCursorPointer pCrsr, SwFrameFormat& rFrameFormat, SwRangeDescriptor& rDesc);
|
||||
void SetLabels(bool bFirstRowAsLabel, bool bFirstColumnAsLabel)
|
||||
{ m_bFirstRowAsLabel = bFirstRowAsLabel, m_bFirstColumnAsLabel = bFirstColumnAsLabel; }
|
||||
virtual ~SwXCellRange()
|
||||
{
|
||||
if(m_pTableCrsr)
|
||||
m_pTableCrsr->Remove(&aCursorDepend);
|
||||
}
|
||||
virtual ~SwXCellRange() {};
|
||||
std::vector< css::uno::Reference< css::table::XCell > > getCells();
|
||||
|
||||
TYPEINFO_OVERRIDE();
|
||||
@@ -547,7 +541,6 @@ public:
|
||||
|
||||
//SwClient
|
||||
virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) SAL_OVERRIDE;
|
||||
virtual void SwClientNotify(const SwModify&, const SfxHint&) SAL_OVERRIDE;
|
||||
|
||||
SwFrameFormat* GetFrameFormat() const { return const_cast<SwFrameFormat*>(static_cast<const SwFrameFormat*>(GetRegisteredIn())); }
|
||||
sal_uInt16 getRowCount();
|
||||
|
@@ -1900,7 +1900,6 @@ SwChartDataSequence::SwChartDataSequence(
|
||||
xDataProvider( &rProvider ),
|
||||
pDataProvider( &rProvider ),
|
||||
pTableCrsr( pTableCursor ),
|
||||
aCursorDepend( this, pTableCursor.get() ),
|
||||
_pPropSet( aSwMapProvider.GetPropertySet( PROPERTY_MAP_CHART2_DATA_SEQUENCE ) )
|
||||
{
|
||||
bDisposed = false;
|
||||
@@ -1931,7 +1930,7 @@ SwChartDataSequence::SwChartDataSequence(
|
||||
#if OSL_DEBUG_LEVEL > 0
|
||||
// check if it can properly convert into a SwUnoTableCrsr
|
||||
// which is required for some functions
|
||||
SwUnoTableCrsr* pUnoTableCrsr = dynamic_cast<SwUnoTableCrsr*>(pTableCrsr.get());
|
||||
SwUnoTableCrsr* pUnoTableCrsr = dynamic_cast<SwUnoTableCrsr*>(&(*pTableCrsr));
|
||||
OSL_ENSURE(pUnoTableCrsr, "SwChartDataSequence: cursor not SwUnoTableCrsr");
|
||||
(void) pUnoTableCrsr;
|
||||
#endif
|
||||
@@ -1947,8 +1946,7 @@ SwChartDataSequence::SwChartDataSequence( const SwChartDataSequence &rObj ) :
|
||||
aColLabelText( SW_RES(STR_CHART2_COL_LABEL_TEXT) ),
|
||||
xDataProvider( rObj.pDataProvider ),
|
||||
pDataProvider( rObj.pDataProvider ),
|
||||
pTableCrsr( dynamic_cast<SwUnoTableCrsr&>(*rObj.pTableCrsr.get()).Clone() ),
|
||||
aCursorDepend( this, pTableCrsr.get() ),
|
||||
pTableCrsr( rObj.pTableCrsr ),
|
||||
_pPropSet( rObj._pPropSet )
|
||||
{
|
||||
bDisposed = false;
|
||||
@@ -1979,7 +1977,7 @@ SwChartDataSequence::SwChartDataSequence( const SwChartDataSequence &rObj ) :
|
||||
#if OSL_DEBUG_LEVEL > 0
|
||||
// check if it can properly convert into a SwUnoTableCrsr
|
||||
// which is required for some functions
|
||||
SwUnoTableCrsr* pUnoTableCrsr = dynamic_cast<SwUnoTableCrsr*>(pTableCrsr.get());
|
||||
SwUnoTableCrsr* pUnoTableCrsr = dynamic_cast<SwUnoTableCrsr*>(&(*pTableCrsr));
|
||||
OSL_ENSURE(pUnoTableCrsr, "SwChartDataSequence: cursor not SwUnoTableCrsr");
|
||||
(void) pUnoTableCrsr;
|
||||
#endif
|
||||
@@ -2028,11 +2026,7 @@ uno::Sequence< uno::Any > SAL_CALL SwChartDataSequence::getData()
|
||||
SwRangeDescriptor aDesc;
|
||||
if (FillRangeDescriptor( aDesc, GetCellRangeName( *pTableFormat, *pTableCrsr ) ))
|
||||
{
|
||||
//!! make copy of pTableCrsr (SwUnoCrsr )
|
||||
// keep original cursor and make copy of it that gets handed
|
||||
// over to the SwXCellRange object which takes ownership and
|
||||
// thus will destroy the copy later.
|
||||
SwXCellRange aRange( dynamic_cast<SwUnoTableCrsr&>(*pTableCrsr.get()).Clone(), *pTableFormat, aDesc );
|
||||
SwXCellRange aRange(pTableCrsr, *pTableFormat, aDesc );
|
||||
aRange.GetDataSequence( &aRes, 0, 0 );
|
||||
}
|
||||
}
|
||||
@@ -2188,11 +2182,7 @@ uno::Sequence< OUString > SAL_CALL SwChartDataSequence::getTextualData()
|
||||
SwRangeDescriptor aDesc;
|
||||
if (FillRangeDescriptor( aDesc, GetCellRangeName( *pTableFormat, *pTableCrsr ) ))
|
||||
{
|
||||
//!! make copy of pTableCrsr (SwUnoCrsr )
|
||||
// keep original cursor and make copy of it that gets handed
|
||||
// over to the SwXCellRange object which takes ownership and
|
||||
// thus will destroy the copy later.
|
||||
SwXCellRange aRange( dynamic_cast<SwUnoTableCrsr&>(*pTableCrsr.get()).Clone(), *pTableFormat, aDesc );
|
||||
SwXCellRange aRange(pTableCrsr, *pTableFormat, aDesc );
|
||||
aRange.GetDataSequence( 0, &aRes, 0 );
|
||||
}
|
||||
}
|
||||
@@ -2217,11 +2207,7 @@ uno::Sequence< double > SAL_CALL SwChartDataSequence::getNumericalData()
|
||||
SwRangeDescriptor aDesc;
|
||||
if (FillRangeDescriptor( aDesc, GetCellRangeName( *pTableFormat, *pTableCrsr ) ))
|
||||
{
|
||||
//!! make copy of pTableCrsr (SwUnoCrsr )
|
||||
// keep original cursor and make copy of it that gets handed
|
||||
// over to the SwXCellRange object which takes ownership and
|
||||
// thus will destroy the copy later.
|
||||
SwXCellRange aRange( dynamic_cast<SwUnoTableCrsr&>(*pTableCrsr.get()).Clone(), *pTableFormat, aDesc );
|
||||
SwXCellRange aRange(pTableCrsr, *pTableFormat, aDesc );
|
||||
|
||||
// get numerical values and make an effort to return the
|
||||
// numerical value for text formatted cells
|
||||
@@ -2345,9 +2331,9 @@ void SwChartDataSequence::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pN
|
||||
ClientModify(this, pOld, pNew );
|
||||
|
||||
// table was deleted or cursor was deleted
|
||||
if(!GetRegisteredIn() || !aCursorDepend.GetRegisteredIn())
|
||||
if(!GetRegisteredIn() || !pTableCrsr)
|
||||
{
|
||||
pTableCrsr.reset();
|
||||
pTableCrsr.reset(nullptr);
|
||||
dispose();
|
||||
}
|
||||
else
|
||||
@@ -2356,16 +2342,6 @@ void SwChartDataSequence::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pN
|
||||
}
|
||||
}
|
||||
|
||||
void SwChartDataSequence::SwClientNotify(const SwModify& rModify, const SfxHint& rHint)
|
||||
{
|
||||
SwClient::SwClientNotify(rModify, rHint);
|
||||
if(typeid(rHint) == typeid(sw::DocDisposingHint))
|
||||
{
|
||||
pTableCrsr.reset();
|
||||
dispose();
|
||||
}
|
||||
}
|
||||
|
||||
sal_Bool SAL_CALL SwChartDataSequence::isModified( )
|
||||
throw (uno::RuntimeException, std::exception)
|
||||
{
|
||||
@@ -2463,7 +2439,7 @@ void SAL_CALL SwChartDataSequence::dispose( )
|
||||
if (pLclRegisteredIn && pLclRegisteredIn->HasWriterListeners())
|
||||
{
|
||||
pLclRegisteredIn->Remove(this);
|
||||
pTableCrsr = nullptr;
|
||||
pTableCrsr.reset(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2629,7 +2605,7 @@ void SwChartDataSequence::FillRangeDesc( SwRangeDescriptor &rRangeDesc ) const
|
||||
bool SwChartDataSequence::ExtendTo( bool bExtendCol,
|
||||
sal_Int32 nFirstNew, sal_Int32 nCount )
|
||||
{
|
||||
SwUnoTableCrsr* pUnoTableCrsr = dynamic_cast<SwUnoTableCrsr*>(pTableCrsr.get());
|
||||
SwUnoTableCrsr* pUnoTableCrsr = dynamic_cast<SwUnoTableCrsr*>(&(*pTableCrsr));
|
||||
if (!pUnoTableCrsr)
|
||||
return false;
|
||||
|
||||
|
@@ -3138,10 +3138,9 @@ uno::Sequence<OUString> SwXCellRange::getSupportedServiceNames() throw( uno::Run
|
||||
"com.sun.star.style.ParagraphPropertiesComplex" };
|
||||
}
|
||||
|
||||
SwXCellRange::SwXCellRange(std::shared_ptr<SwUnoCrsr> pCrsr, SwFrameFormat& rFrameFormat,
|
||||
SwXCellRange::SwXCellRange(sw::UnoCursorPointer pCrsr, SwFrameFormat& rFrameFormat,
|
||||
SwRangeDescriptor& rDesc)
|
||||
: SwClient(&rFrameFormat)
|
||||
, aCursorDepend(this, nullptr)
|
||||
, m_ChartListeners(m_Mutex)
|
||||
, aRgDesc(rDesc)
|
||||
, m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TABLE_RANGE))
|
||||
@@ -3149,7 +3148,6 @@ SwXCellRange::SwXCellRange(std::shared_ptr<SwUnoCrsr> pCrsr, SwFrameFormat& rFra
|
||||
, m_bFirstRowAsLabel(false)
|
||||
, m_bFirstColumnAsLabel(false)
|
||||
{
|
||||
m_pTableCrsr->Add(&aCursorDepend);
|
||||
aRgDesc.Normalize();
|
||||
}
|
||||
|
||||
@@ -3450,7 +3448,7 @@ uno::Any SwXCellRange::getPropertyValue(const OUString& rPropertyName)
|
||||
RES_UNKNOWNATR_CONTAINER, RES_UNKNOWNATR_CONTAINER,
|
||||
0L);
|
||||
// first look at the attributes of the cursor
|
||||
SwUnoTableCrsr* pCrsr = dynamic_cast<SwUnoTableCrsr*>(m_pTableCrsr.get());
|
||||
SwUnoTableCrsr* pCrsr = dynamic_cast<SwUnoTableCrsr*>(&(*m_pTableCrsr));
|
||||
SwUnoCursorHelper::GetCrsrAttr(pCrsr->GetSelRing(), aSet);
|
||||
m_pPropSet->getPropertyValue(*pEntry, aSet, aRet);
|
||||
}
|
||||
@@ -3865,21 +3863,15 @@ sal_uInt16 SwXCellRange::getRowCount()
|
||||
const SwUnoCrsr* SwXCellRange::GetTableCrsr() const
|
||||
{
|
||||
SwFrameFormat* pFormat = GetFrameFormat();
|
||||
return pFormat ? m_pTableCrsr.get() : nullptr;
|
||||
return pFormat ? &(*m_pTableCrsr) : nullptr;
|
||||
}
|
||||
|
||||
void SwXCellRange::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
|
||||
{
|
||||
ClientModify(this, pOld, pNew );
|
||||
if(!GetRegisteredIn() || !aCursorDepend.GetRegisteredIn())
|
||||
if(!GetRegisteredIn() || !m_pTableCrsr)
|
||||
{
|
||||
/*
|
||||
* Not sure if this will cause a memory leak - this pTableCrsr
|
||||
* is deleted in SwDoc and segfaults here when deleted again
|
||||
* if(!aCursorDepend.GetRegisteredIn())
|
||||
delete pTableCrsr;
|
||||
*/
|
||||
m_pTableCrsr.reset();
|
||||
m_pTableCrsr.reset(nullptr);
|
||||
lang::EventObject const ev(static_cast< ::cppu::OWeakObject&>(*this));
|
||||
m_ChartListeners.disposeAndClear(ev);
|
||||
}
|
||||
@@ -3889,17 +3881,6 @@ void SwXCellRange::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
|
||||
}
|
||||
}
|
||||
|
||||
void SwXCellRange::SwClientNotify(const SwModify& rModify, const SfxHint& rHint)
|
||||
{
|
||||
//assert(m_pTblCrsr->m_bSaneOwnership);
|
||||
SwClient::SwClientNotify(rModify, rHint);
|
||||
if(m_pTableCrsr && typeid(rHint) == typeid(sw::DocDisposingHint))
|
||||
{
|
||||
m_pTableCrsr->Remove(&aCursorDepend);
|
||||
m_pTableCrsr.reset();
|
||||
}
|
||||
}
|
||||
|
||||
// SwXTableRows
|
||||
|
||||
OUString SwXTableRows::getImplementationName() throw( uno::RuntimeException, std::exception )
|
||||
|
Reference in New Issue
Block a user