use UnoCursorPointer in SwXTextRanges
Change-Id: Iabcb98f664739aaae0d92b4f2a6b0e50bdcbc09b
This commit is contained in:
@@ -107,6 +107,9 @@ namespace sw
|
|||||||
class UnoCursorPointer : public SwClient
|
class UnoCursorPointer : public SwClient
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
UnoCursorPointer()
|
||||||
|
: m_pCursor(nullptr)
|
||||||
|
{}
|
||||||
UnoCursorPointer(std::shared_ptr<SwUnoCrsr> pCursor)
|
UnoCursorPointer(std::shared_ptr<SwUnoCrsr> pCursor)
|
||||||
: m_pCursor(pCursor)
|
: m_pCursor(pCursor)
|
||||||
{
|
{
|
||||||
|
@@ -1467,56 +1467,26 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
|
|||||||
}
|
}
|
||||||
|
|
||||||
class SwXTextRanges::Impl
|
class SwXTextRanges::Impl
|
||||||
: public SwClient
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
::std::vector< uno::Reference< text::XTextRange > > m_Ranges;
|
::std::vector< uno::Reference< text::XTextRange > > m_Ranges;
|
||||||
std::shared_ptr<SwUnoCrsr> m_pUnoCursor;
|
sw::UnoCursorPointer m_pUnoCursor;
|
||||||
|
|
||||||
explicit Impl(SwPaM *const pPaM)
|
explicit Impl(SwPaM *const pPaM)
|
||||||
{
|
{
|
||||||
if (pPaM)
|
if (pPaM)
|
||||||
{
|
{
|
||||||
m_pUnoCursor = pPaM->GetDoc()->CreateUnoCrsr(*pPaM->GetPoint());
|
m_pUnoCursor.reset(pPaM->GetDoc()->CreateUnoCrsr(*pPaM->GetPoint()));
|
||||||
m_pUnoCursor->Add(this);
|
|
||||||
::sw::DeepCopyPaM(*pPaM, *GetCursor());
|
::sw::DeepCopyPaM(*pPaM, *GetCursor());
|
||||||
}
|
}
|
||||||
MakeRanges();
|
MakeRanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~Impl() {
|
SwUnoCrsr* GetCursor()
|
||||||
if(m_pUnoCursor)
|
{ return &(*m_pUnoCursor); }
|
||||||
m_pUnoCursor->Remove(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
SwUnoCrsr * GetCursor() {
|
|
||||||
return static_cast<SwUnoCrsr*>(
|
|
||||||
GetRegisteredIn());
|
|
||||||
}
|
|
||||||
|
|
||||||
void MakeRanges();
|
void MakeRanges();
|
||||||
|
|
||||||
protected:
|
|
||||||
// SwClient
|
|
||||||
virtual void Modify( const SfxPoolItem *pOld, const SfxPoolItem *pNew) SAL_OVERRIDE;
|
|
||||||
virtual void SwClientNotify(const SwModify& rModify, const SfxHint& rHint) SAL_OVERRIDE;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void SwXTextRanges::Impl::Modify( const SfxPoolItem *pOld, const SfxPoolItem *pNew)
|
|
||||||
{
|
|
||||||
ClientModify(this, pOld, pNew);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SwXTextRanges::Impl::SwClientNotify(const SwModify& rModify, const SfxHint& rHint)
|
|
||||||
{
|
|
||||||
SwClient::SwClientNotify(rModify, rHint);
|
|
||||||
if(m_pUnoCursor && typeid(rHint) == typeid(sw::DocDisposingHint))
|
|
||||||
{
|
|
||||||
m_pUnoCursor->Remove(this);
|
|
||||||
m_pUnoCursor.reset();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void SwXTextRanges::Impl::MakeRanges()
|
void SwXTextRanges::Impl::MakeRanges()
|
||||||
{
|
{
|
||||||
if (GetCursor())
|
if (GetCursor())
|
||||||
|
Reference in New Issue
Block a user