diff options
author | Michael Stahl <mstahl@redhat.com> | 2016-02-05 12:44:50 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2016-02-05 14:42:39 +0100 |
commit | 94db2ac39d7335fa6358588c887cef998b14b5d6 (patch) | |
tree | c2cc0e8ed34806dddf6cab9a5e7739240e777c72 /sw | |
parent | 042b36467e3e358268a483464d7e3af5689d045d (diff) |
sw: move SwTextTable's SwClient to SwTextTable::Impl
Change-Id: If86bf825a714be00d678d50e80adddaced48c3e2
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/unotbl.hxx | 13 | ||||
-rw-r--r-- | sw/source/core/unocore/unotbl.cxx | 58 | ||||
-rw-r--r-- | sw/source/filter/xml/xmltble.cxx | 4 | ||||
-rw-r--r-- | sw/source/filter/xml/xmltbli.cxx | 4 |
4 files changed, 47 insertions, 32 deletions
diff --git a/sw/inc/unotbl.hxx b/sw/inc/unotbl.hxx index 8ebe688a3b22..0fde2c6d2116 100644 --- a/sw/inc/unotbl.hxx +++ b/sw/inc/unotbl.hxx @@ -298,8 +298,7 @@ class SwXTextTable : public cppu::WeakImplHelper css::util::XSortable, css::lang::XUnoTunnel, css::sheet::XCellRangeData ->, - public SwClient +> { private: class Impl; @@ -318,10 +317,10 @@ private: bool m_bFirstRowAsLabel; bool m_bFirstColumnAsLabel; -protected: - virtual ~SwXTextTable(); + SwXTextTable(); SwXTextTable(SwFrameFormat& rFrameFormat); + virtual ~SwXTextTable(); public: static css::uno::Reference<css::text::XTextTable> @@ -329,6 +328,8 @@ public: SW_DLLPUBLIC static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId(); + SW_DLLPUBLIC SwFrameFormat* GetFrameFormat(); + //XUnoTunnel virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) throw(css::uno::RuntimeException, std::exception) override; @@ -428,10 +429,6 @@ public: const OUString& sTLName, const OUString& sBRName, SwRangeDescriptor& rDesc); - //SwClient - virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) override; - - SwFrameFormat* GetFrameFormat() const { return const_cast<SwFrameFormat*>(static_cast<const SwFrameFormat*>(GetRegisteredIn())); } SW_DLLPUBLIC static void GetCellPosition(const OUString& rCellName, sal_Int32& o_rColumn, sal_Int32& o_rRow); }; diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index d61e6910be6f..cb741b19c7f3 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -136,14 +136,14 @@ namespace #define UNO_TABLE_COLUMN_SUM 10000 -static void lcl_SendChartEvent(::cppu::OWeakObject & rSource, +static void lcl_SendChartEvent(uno::Reference<uno::XInterface> const& xSource, ::cppu::OInterfaceContainerHelper & rListeners) { if (!rListeners.getLength()) return; //TODO: find appropriate settings of the Event chart::ChartDataChangeEvent event; - event.Source = & rSource; + event.Source = xSource; event.Type = chart::ChartDataChangeType_ALL; event.StartColumn = 0; event.EndColumn = 1; @@ -176,17 +176,23 @@ static void lcl_SendChartEvent(::cppu::OWeakObject & rSource, return lcl_SendChartEvent(&rSource, rListeners); } -static void lcl_SendChartEvent(::cppu::OWeakObject & rSource, +static void lcl_SendChartEvent(uno::Reference<uno::XInterface> const& xSource, ::cppu::OMultiTypeInterfaceContainerHelper & rListeners) { ::cppu::OInterfaceContainerHelper *const pContainer(rListeners.getContainer( cppu::UnoType<chart::XChartDataChangeEventListener>::get())); if (pContainer) { - lcl_SendChartEvent(rSource, *pContainer); + lcl_SendChartEvent(xSource, *pContainer); } } +static void lcl_SendChartEvent(::cppu::OWeakObject & rSource, + ::cppu::OMultiTypeInterfaceContainerHelper & rListeners) +{ + return lcl_SendChartEvent(&rSource, rListeners); +} + static bool lcl_LineToSvxLine(const table::BorderLine& rLine, SvxBorderLine& rSvxLine) { rSvxLine.SetColor(Color(rLine.Color)); @@ -1795,6 +1801,7 @@ void SwXTextTableCursor::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNe { ClientModify(this, pOld, pNew); } class SwXTextTable::Impl + : public SwClient { private: ::osl::Mutex m_Mutex; // just for OInterfaceContainerHelper2 @@ -1803,7 +1810,11 @@ public: uno::WeakReference<uno::XInterface> m_wThis; ::cppu::OMultiTypeInterfaceContainerHelper m_Listeners; - Impl() : m_Listeners(m_Mutex) { } + Impl(SwFrameFormat *const pFrameFormat) + : SwClient(pFrameFormat) + , m_Listeners(m_Mutex) + { + } // note: lock mutex before calling this to avoid concurrent update static std::pair<sal_uInt16, sal_uInt16> ThrowIfComplex(SwXTextTable &rThis) @@ -1817,6 +1828,10 @@ public: } return std::make_pair(nRowCount, nColCount); } + + // SwClient + virtual void Modify(const SfxPoolItem *pOld, const SfxPoolItem *pNew) override; + }; class SwTableProperties_Impl @@ -1987,7 +2002,7 @@ sal_Int64 SAL_CALL SwXTextTable::getSomething( const uno::Sequence< sal_Int8 >& SwXTextTable::SwXTextTable() - : m_pImpl(new Impl) + : m_pImpl(new Impl(nullptr)) , m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_TABLE)), pTableProps(new SwTableProperties_Impl), @@ -1999,8 +2014,7 @@ SwXTextTable::SwXTextTable() { } SwXTextTable::SwXTextTable(SwFrameFormat& rFrameFormat) - : SwClient( &rFrameFormat ) - , m_pImpl(new Impl) + : m_pImpl(new Impl(&rFrameFormat)) , m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_TABLE)), pTableProps(nullptr), @@ -2015,8 +2029,6 @@ SwXTextTable::~SwXTextTable() { SolarMutexGuard aGuard; delete pTableProps; - if(GetRegisteredIn()) - GetRegisteredIn()->Remove(this); } uno::Reference<text::XTextTable> SwXTextTable::CreateXTextTable(SwFrameFormat* const pFrameFormat) @@ -2035,6 +2047,11 @@ uno::Reference<text::XTextTable> SwXTextTable::CreateXTextTable(SwFrameFormat* c return xTable; } +SwFrameFormat* SwXTextTable::GetFrameFormat() +{ + return const_cast<SwFrameFormat*>(static_cast<const SwFrameFormat*>(m_pImpl->GetRegisteredIn())); +} + void SwXTextTable::initialize(sal_Int32 nR, sal_Int32 nC) throw( uno::RuntimeException, std::exception ) { if(!bIsDescriptor || nR <= 0 || nC <= 0 || nR >= USHRT_MAX || nC >= USHRT_MAX ) @@ -2157,7 +2174,7 @@ void SwXTextTable::attachToRange(const uno::Reference< text::XTextRange > & xTex SwFrameFormat* pTableFormat(pTable->GetFrameFormat()); lcl_FormatTable(pTableFormat); - pTableFormat->Add(this); + pTableFormat->Add(m_pImpl.get()); if(!m_sTableName.isEmpty()) { sal_uInt16 nIndex = 1; @@ -3107,26 +3124,27 @@ sal_uInt16 SwXTextTable::getColumnCount() return nRet; } -void SwXTextTable::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) +void SwXTextTable::Impl::Modify( + SfxPoolItem const*const pOld, SfxPoolItem const*const pNew) { if(pOld && pOld->Which() == RES_REMOVE_UNO_OBJECT && static_cast<void*>(GetRegisteredIn()) == static_cast<const SwPtrMsgPoolItem *>(pOld)->pObject ) GetRegisteredIn()->Remove(this); else ClientModify(this, pOld, pNew); - if(!GetRegisteredIn()) + uno::Reference<uno::XInterface> const xThis(m_wThis); + if (!xThis.is()) + { // fdo#72695: if UNO object is already dead, don't revive it with event + return; + } + if (!GetRegisteredIn()) { - uno::Reference<uno::XInterface> const xThis(m_pImpl->m_wThis); - if (!xThis.is()) - { // fdo#72695: if UNO object is already dead, don't revive it with event - return; - } lang::EventObject const ev(xThis); - m_pImpl->m_Listeners.disposeAndClear(ev); + m_Listeners.disposeAndClear(ev); } else { - lcl_SendChartEvent(*this, m_pImpl->m_Listeners); + lcl_SendChartEvent(xThis.get(), m_Listeners); } } diff --git a/sw/source/filter/xml/xmltble.cxx b/sw/source/filter/xml/xmltble.cxx index 3e81a9018787..1b4a1802746f 100644 --- a/sw/source/filter/xml/xmltble.cxx +++ b/sw/source/filter/xml/xmltble.cxx @@ -1156,7 +1156,7 @@ void SwXMLTextParagraphExport::exportTable( OSL_ENSURE( xTextTable.is(), "text table missing" ); if( xTextTable.is() ) { - const SwXTextTable *pXTable = nullptr; + SwXTextTable *pXTable = nullptr; Reference<XUnoTunnel> xTableTunnel( rTextContent, UNO_QUERY); if( xTableTunnel.is() ) { @@ -1166,7 +1166,7 @@ void SwXMLTextParagraphExport::exportTable( } if( pXTable ) { - SwFrameFormat *pFormat = pXTable->GetFrameFormat(); + SwFrameFormat *const pFormat = pXTable->GetFrameFormat(); OSL_ENSURE( pFormat, "table format missing" ); const SwTable *pTable = SwTable::FindTable( pFormat ); OSL_ENSURE( pTable, "table missing" ); diff --git a/sw/source/filter/xml/xmltbli.cxx b/sw/source/filter/xml/xmltbli.cxx index eda3db88f092..66c59eba6b9a 100644 --- a/sw/source/filter/xml/xmltbli.cxx +++ b/sw/source/filter/xml/xmltbli.cxx @@ -1343,7 +1343,7 @@ SwXMLTableContext::SwXMLTableContext( SwXMLImport& rImport, } Reference< XTextTable > xTable; - const SwXTextTable *pXTable = nullptr; + SwXTextTable *pXTable = nullptr; Reference<XMultiServiceFactory> xFactory( GetImport().GetModel(), UNO_QUERY ); OSL_ENSURE( xFactory.is(), "factory missing" ); @@ -1396,7 +1396,7 @@ SwXMLTableContext::SwXMLTableContext( SwXMLImport& rImport, } if( pXTable ) { - SwFrameFormat *pTableFrameFormat = pXTable->GetFrameFormat(); + SwFrameFormat *const pTableFrameFormat = pXTable->GetFrameFormat(); OSL_ENSURE( pTableFrameFormat, "table format missing" ); SwTable *pTable = SwTable::FindTable( pTableFrameFormat ); OSL_ENSURE( pTable, "table missing" ); |