summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjoern Michaelsen <bjoern.michaelsen@canonical.com>2015-05-22 17:42:53 +0200
committerBjoern Michaelsen <bjoern.michaelsen@canonical.com>2015-05-26 00:51:11 +0200
commit9ebb551c85909952f8837c174c0e10400170df49 (patch)
treec8d125ee5522592c0d3da7ebbeeb64612adf8328
parent50356872b9421303b9c7b4a3135b3cdcc3a0af50 (diff)
new unocrsrs for SwXTextPortion
Change-Id: If2cb4ca0b650e0f5188350763e4b5bbbb4a0dbb8
-rw-r--r--sw/source/core/inc/unoport.hxx3
-rw-r--r--sw/source/core/unocore/unoport.cxx27
2 files changed, 19 insertions, 11 deletions
diff --git a/sw/source/core/inc/unoport.hxx b/sw/source/core/inc/unoport.hxx
index 46a275a87165..4e6609725953 100644
--- a/sw/source/core/inc/unoport.hxx
+++ b/sw/source/core/inc/unoport.hxx
@@ -114,6 +114,7 @@ private:
::std::unique_ptr< ::com::sun::star::uno::Any > m_pRubyStyle;
::std::unique_ptr< ::com::sun::star::uno::Any > m_pRubyAdjust;
::std::unique_ptr< ::com::sun::star::uno::Any > m_pRubyIsAbove;
+ std::shared_ptr<SwUnoCrsr> m_pUnoCursor;
const SwDepend m_FrameDepend;
SwFrameFormat * m_pFrameFormat;
@@ -150,6 +151,8 @@ protected:
//SwClient
virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) SAL_OVERRIDE;
+ virtual void SwClientNotify(const SwModify& rModify, const SfxHint& rHint) SAL_OVERRIDE;
+
public:
SwXTextPortion(const SwUnoCrsr* pPortionCrsr, ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > const& rParent, SwTextPortionType eType );
diff --git a/sw/source/core/unocore/unoport.cxx b/sw/source/core/unocore/unoport.cxx
index 54db6433298a..502a9dd9389c 100644
--- a/sw/source/core/unocore/unoport.cxx
+++ b/sw/source/core/unocore/unoport.cxx
@@ -63,14 +63,13 @@ public:
void SwXTextPortion::init(const SwUnoCrsr* pPortionCursor)
{
- SwUnoCrsr* pUnoCursor =
- pPortionCursor->GetDoc()->CreateUnoCrsr(*pPortionCursor->GetPoint());
+ m_pUnoCursor = pPortionCursor->GetDoc()->CreateUnoCrsr2(*pPortionCursor->GetPoint());
if (pPortionCursor->HasMark())
{
- pUnoCursor->SetMark();
- *pUnoCursor->GetMark() = *pPortionCursor->GetMark();
+ m_pUnoCursor->SetMark();
+ *m_pUnoCursor->GetMark() = *pPortionCursor->GetMark();
}
- pUnoCursor->Add(this);
+ m_pUnoCursor->Add(this);
}
SwXTextPortion::SwXTextPortion(
@@ -138,12 +137,7 @@ SwXTextPortion::SwXTextPortion(
}
}
-SwXTextPortion::~SwXTextPortion()
-{
- SolarMutexGuard aGuard;
- SwUnoCrsr* pUnoCrsr = GetCursor();
- delete pUnoCrsr;
-}
+SwXTextPortion::~SwXTextPortion() {};
uno::Reference< text::XText > SwXTextPortion::getText()
throw( uno::RuntimeException, std::exception )
@@ -932,4 +926,15 @@ void SwXTextPortion::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
}
}
+void SwXTextPortion::SwClientNotify(const SwModify& rModify, const SfxHint& rHint)
+{
+ SwClient::SwClientNotify(rModify, rHint);
+ if(m_pUnoCursor && typeid(rHint) == typeid(sw::DocDisposingHint))
+ {
+ assert(m_pUnoCursor->m_bSaneOwnership);
+ m_pUnoCursor->Remove(this);
+ m_pUnoCursor.reset();
+ }
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */