diff options
author | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2015-06-06 03:07:35 +0200 |
---|---|---|
committer | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2015-06-08 18:58:58 +0200 |
commit | c6c2715373f4ebb79ff0b748e546bd01f0ab8a83 (patch) | |
tree | 8488cc0a82ce12b55eec898aa76a643f1f485aad | |
parent | 5cd77233d94f1a1137706421be01bfad9b1f4b59 (diff) |
use UnoCursorPointer in SwXTextTableCursor
Change-Id: Ia58e286760e52191edbe968504e3db0967ce09d3
-rw-r--r-- | sw/inc/unotbl.hxx | 11 | ||||
-rw-r--r-- | sw/source/core/unocore/unotbl.cxx | 20 |
2 files changed, 5 insertions, 26 deletions
diff --git a/sw/inc/unotbl.hxx b/sw/inc/unotbl.hxx index d4909fd89e64..f216f3201664 100644 --- a/sw/inc/unotbl.hxx +++ b/sw/inc/unotbl.hxx @@ -210,7 +210,6 @@ class SW_DLLPUBLIC SwXTextTableCursor : public SwXTextTableCursor_Base ,public SwClient ,public OTextCursorHelper { - SwDepend aCrsrDepend; const SfxItemPropertySet* m_pPropSet; public: @@ -263,7 +262,6 @@ public: //SwClient virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) SAL_OVERRIDE; - virtual void SwClientNotify(const SwModify&, const SfxHint&) SAL_OVERRIDE; // ITextCursorHelper virtual const SwPaM* GetPaM() const SAL_OVERRIDE; @@ -273,14 +271,9 @@ public: const SwUnoCrsr* GetCrsr() const; SwUnoCrsr* GetCrsr(); - std::shared_ptr<SwUnoCrsr> m_pUnoCrsr; + sw::UnoCursorPointer m_pUnoCrsr; SwFrameFormat* GetFrameFormat() const { return const_cast<SwFrameFormat*>(static_cast<const SwFrameFormat*>(GetRegisteredIn())); } - virtual ~SwXTextTableCursor() - { - if(m_pUnoCrsr) - m_pUnoCrsr->Remove(&aCrsrDepend); - } - + virtual ~SwXTextTableCursor() { }; }; struct SwRangeDescriptor diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index c2371d89079a..3f2c1ddecce1 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -1403,15 +1403,14 @@ const SwPaM* SwXTextTableCursor::GetPaM() const { return GetCrsr(); } SwPaM* SwXTextTableCursor::GetPaM() { return GetCrsr(); } const SwDoc* SwXTextTableCursor::GetDoc() const { return GetFrameFormat()->GetDoc(); } SwDoc* SwXTextTableCursor::GetDoc() { return GetFrameFormat()->GetDoc(); } -const SwUnoCrsr* SwXTextTableCursor::GetCrsr() const { return static_cast<const SwUnoCrsr*>(aCrsrDepend.GetRegisteredIn()); } -SwUnoCrsr* SwXTextTableCursor::GetCrsr() { return static_cast<SwUnoCrsr*>(aCrsrDepend.GetRegisteredIn()); } +const SwUnoCrsr* SwXTextTableCursor::GetCrsr() const { return &(*m_pUnoCrsr); } +SwUnoCrsr* SwXTextTableCursor::GetCrsr() { return &(*m_pUnoCrsr); } uno::Sequence<OUString> SwXTextTableCursor::getSupportedServiceNames() throw( uno::RuntimeException, std::exception ) { return {"com.sun.star.text.TextTableCursor"}; } SwXTextTableCursor::SwXTextTableCursor(SwFrameFormat* pFormat, SwTableBox* pBox) : SwClient(pFormat), - aCrsrDepend(this, 0), m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_TABLE_CURSOR)) { SwDoc* pDoc = pFormat->GetDoc(); @@ -1419,14 +1418,12 @@ SwXTextTableCursor::SwXTextTableCursor(SwFrameFormat* pFormat, SwTableBox* pBox) SwPosition aPos(*pSttNd); m_pUnoCrsr = pDoc->CreateUnoCrsr(aPos, true); m_pUnoCrsr->Move( fnMoveForward, fnGoNode ); - m_pUnoCrsr->Add(&aCrsrDepend); - SwUnoTableCrsr& rTableCrsr = dynamic_cast<SwUnoTableCrsr&>(*m_pUnoCrsr.get()); + SwUnoTableCrsr& rTableCrsr = dynamic_cast<SwUnoTableCrsr&>(*m_pUnoCrsr); rTableCrsr.MakeBoxSels(); } SwXTextTableCursor::SwXTextTableCursor(SwFrameFormat& rTableFormat, const SwTableCursor* pTableSelection) : SwClient(&rTableFormat), - aCrsrDepend(this, 0), m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_TABLE_CURSOR)) { m_pUnoCrsr = pTableSelection->GetDoc()->CreateUnoCrsr(*pTableSelection->GetPoint(), true); @@ -1439,7 +1436,6 @@ SwXTextTableCursor::SwXTextTableCursor(SwFrameFormat& rTableFormat, const SwTabl SwUnoTableCrsr& rTableCrsr = dynamic_cast<SwUnoTableCrsr&>(*m_pUnoCrsr); for(auto pBox : rBoxes) rTableCrsr.InsertBox(*pBox); - m_pUnoCrsr->Add(&aCrsrDepend); rTableCrsr.MakeBoxSels(); } @@ -1739,16 +1735,6 @@ void SwXTextTableCursor::removeVetoableChangeListener(const OUString& /*rPropert void SwXTextTableCursor::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) { ClientModify(this, pOld, pNew); } -void SwXTextTableCursor::SwClientNotify(const SwModify& rModify, const SfxHint& rHint) -{ - SwClient::SwClientNotify(rModify, rHint); - if(m_pUnoCrsr && typeid(rHint) == typeid(sw::DocDisposingHint)) - { - m_pUnoCrsr->Remove(&aCrsrDepend); - m_pUnoCrsr.reset(); - } -} - class SwXTextTable::Impl { private: |