dont use SwClient/SwModify in unocore: TextRange
Change-Id: Ib87647671776e9c6ef5a9c5a7b75a638452b4555 Reviewed-on: https://gerrit.libreoffice.org/54605 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Björn Michaelsen <bjoern.michaelsen@libreoffice.org>
This commit is contained in:
committed by
Björn Michaelsen
parent
b0a5d36c12
commit
db608e8e5e
@@ -38,6 +38,7 @@ namespace sw { namespace mark
|
|||||||
class SW_DLLPUBLIC IMark
|
class SW_DLLPUBLIC IMark
|
||||||
: virtual public SwModify // inherited as interface
|
: virtual public SwModify // inherited as interface
|
||||||
, public ::boost::totally_ordered<IMark>
|
, public ::boost::totally_ordered<IMark>
|
||||||
|
, virtual public sw::BroadcasterMixin
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
IMark() = default;
|
IMark() = default;
|
||||||
|
@@ -21,7 +21,20 @@
|
|||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
#include <comphelper/servicehelper.hxx>
|
||||||
|
#include <cppuhelper/supportsservice.hxx>
|
||||||
|
#include <editeng/brushitem.hxx>
|
||||||
|
#include <editeng/flstitem.hxx>
|
||||||
|
#include <editeng/unolingu.hxx>
|
||||||
#include <rtl/ustrbuf.hxx>
|
#include <rtl/ustrbuf.hxx>
|
||||||
|
#include <svl/listener.hxx>
|
||||||
|
#include <sfx2/docfile.hxx>
|
||||||
|
#include <sfx2/docfilt.hxx>
|
||||||
|
#include <sfx2/fcontnr.hxx>
|
||||||
|
#include <sfx2/linkmgr.hxx>
|
||||||
|
#include <svtools/ctrltool.hxx>
|
||||||
|
#include <vcl/svapp.hxx>
|
||||||
|
|
||||||
#include <swtypes.hxx>
|
#include <swtypes.hxx>
|
||||||
#include <hintids.hxx>
|
#include <hintids.hxx>
|
||||||
#include <cmdid.h>
|
#include <cmdid.h>
|
||||||
@@ -41,7 +54,6 @@
|
|||||||
#include <rootfrm.hxx>
|
#include <rootfrm.hxx>
|
||||||
#include <flyfrm.hxx>
|
#include <flyfrm.hxx>
|
||||||
#include <ftnidx.hxx>
|
#include <ftnidx.hxx>
|
||||||
#include <sfx2/linkmgr.hxx>
|
|
||||||
#include <docary.hxx>
|
#include <docary.hxx>
|
||||||
#include <paratr.hxx>
|
#include <paratr.hxx>
|
||||||
#include <pam.hxx>
|
#include <pam.hxx>
|
||||||
@@ -61,9 +73,6 @@
|
|||||||
#include <cntfrm.hxx>
|
#include <cntfrm.hxx>
|
||||||
#include <pagefrm.hxx>
|
#include <pagefrm.hxx>
|
||||||
#include <doctxm.hxx>
|
#include <doctxm.hxx>
|
||||||
#include <sfx2/docfilt.hxx>
|
|
||||||
#include <sfx2/docfile.hxx>
|
|
||||||
#include <sfx2/fcontnr.hxx>
|
|
||||||
#include <fmtrfmrk.hxx>
|
#include <fmtrfmrk.hxx>
|
||||||
#include <txtrfmrk.hxx>
|
#include <txtrfmrk.hxx>
|
||||||
#include <unoparaframeenum.hxx>
|
#include <unoparaframeenum.hxx>
|
||||||
@@ -81,9 +90,6 @@
|
|||||||
#include <unocoll.hxx>
|
#include <unocoll.hxx>
|
||||||
#include <unostyle.hxx>
|
#include <unostyle.hxx>
|
||||||
#include <fmtanchr.hxx>
|
#include <fmtanchr.hxx>
|
||||||
#include <editeng/flstitem.hxx>
|
|
||||||
#include <editeng/unolingu.hxx>
|
|
||||||
#include <svtools/ctrltool.hxx>
|
|
||||||
#include <flypos.hxx>
|
#include <flypos.hxx>
|
||||||
#include <txtftn.hxx>
|
#include <txtftn.hxx>
|
||||||
#include <fmtftn.hxx>
|
#include <fmtftn.hxx>
|
||||||
@@ -97,9 +103,7 @@
|
|||||||
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
|
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
|
||||||
#include <unoframe.hxx>
|
#include <unoframe.hxx>
|
||||||
#include <fmthdft.hxx>
|
#include <fmthdft.hxx>
|
||||||
#include <vcl/svapp.hxx>
|
|
||||||
#include <fmtflcnt.hxx>
|
#include <fmtflcnt.hxx>
|
||||||
#include <editeng/brushitem.hxx>
|
|
||||||
#include <fmtclds.hxx>
|
#include <fmtclds.hxx>
|
||||||
#include <dcontact.hxx>
|
#include <dcontact.hxx>
|
||||||
#include <dflyobj.hxx>
|
#include <dflyobj.hxx>
|
||||||
@@ -109,8 +113,6 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <calbck.hxx>
|
#include <calbck.hxx>
|
||||||
#include <comphelper/servicehelper.hxx>
|
|
||||||
#include <cppuhelper/supportsservice.hxx>
|
|
||||||
|
|
||||||
using namespace ::com::sun::star;
|
using namespace ::com::sun::star;
|
||||||
|
|
||||||
@@ -679,30 +681,27 @@ uno::Any SAL_CALL SwXParagraphEnumerationImpl::nextElement()
|
|||||||
}
|
}
|
||||||
|
|
||||||
class SwXTextRange::Impl
|
class SwXTextRange::Impl
|
||||||
: public SwClient
|
: public SvtListener
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
const SfxItemPropertySet& m_rPropSet;
|
const SfxItemPropertySet& m_rPropSet;
|
||||||
const enum RangePosition m_eRangePosition;
|
const enum RangePosition m_eRangePosition;
|
||||||
SwDoc& m_rDoc;
|
SwDoc& m_rDoc;
|
||||||
uno::Reference<text::XText> m_xParentText;
|
uno::Reference<text::XText> m_xParentText;
|
||||||
sw::WriterMultiListener m_aMultiListener;
|
|
||||||
const ::sw::mark::IMark* m_pMark;
|
|
||||||
const SwFrameFormat* m_pTableFormat;
|
const SwFrameFormat* m_pTableFormat;
|
||||||
|
const ::sw::mark::IMark* m_pMark;
|
||||||
|
|
||||||
Impl(SwDoc & rDoc, const enum RangePosition eRange,
|
Impl(SwDoc& rDoc, const enum RangePosition eRange,
|
||||||
SwFrameFormat* const pTableFormat,
|
SwFrameFormat* const pTableFormat,
|
||||||
const uno::Reference<text::XText>& xParent = nullptr)
|
const uno::Reference<text::XText>& xParent = nullptr)
|
||||||
: SwClient()
|
: m_rPropSet(*aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR))
|
||||||
, m_rPropSet(*aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR))
|
|
||||||
, m_eRangePosition(eRange)
|
, m_eRangePosition(eRange)
|
||||||
, m_rDoc(rDoc)
|
, m_rDoc(rDoc)
|
||||||
, m_xParentText(xParent)
|
, m_xParentText(xParent)
|
||||||
, m_aMultiListener(*this)
|
|
||||||
, m_pMark(nullptr)
|
|
||||||
, m_pTableFormat(pTableFormat)
|
, m_pTableFormat(pTableFormat)
|
||||||
|
, m_pMark(nullptr)
|
||||||
{
|
{
|
||||||
m_aMultiListener.StartListening(pTableFormat);
|
m_pTableFormat && StartListening(pTableFormat->GetNotifier());
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~Impl() override
|
virtual ~Impl() override
|
||||||
@@ -718,30 +717,30 @@ public:
|
|||||||
m_rDoc.getIDocumentMarkAccess()->deleteMark(m_pMark);
|
m_rDoc.getIDocumentMarkAccess()->deleteMark(m_pMark);
|
||||||
m_pMark = nullptr;
|
m_pMark = nullptr;
|
||||||
}
|
}
|
||||||
|
m_pTableFormat = nullptr;
|
||||||
|
EndListeningAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
const ::sw::mark::IMark * GetBookmark() const { return m_pMark; }
|
const ::sw::mark::IMark* GetBookmark() const { return m_pMark; }
|
||||||
|
void SetMark(::sw::mark::IMark& rMark)
|
||||||
|
{
|
||||||
|
EndListeningAll();
|
||||||
|
m_pTableFormat = nullptr;
|
||||||
|
m_pMark = &rMark;
|
||||||
|
StartListening(rMark.GetNotifier());
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// SwClient
|
virtual void Notify(const SfxHint&) override;
|
||||||
virtual void SwClientNotify(const SwModify&, const SfxHint&) override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void SwXTextRange::Impl::SwClientNotify(const SwModify& rModify, const SfxHint& rHint)
|
void SwXTextRange::Impl::Notify(const SfxHint& rHint)
|
||||||
{
|
{
|
||||||
assert(!GetRegisteredIn()); // we should only listen with the WriterMultiListener from now on
|
if(rHint.GetId() == SfxHintId::Dying)
|
||||||
if(auto pModifyChangedHint = dynamic_cast<const sw::ModifyChangedHint*>(&rHint))
|
|
||||||
{
|
{
|
||||||
if(pModifyChangedHint->m_pNew == nullptr)
|
EndListeningAll();
|
||||||
{
|
m_pTableFormat = nullptr;
|
||||||
m_aMultiListener.EndListeningAll();
|
m_pMark = nullptr;
|
||||||
m_pMark = nullptr;
|
|
||||||
m_pTableFormat = nullptr;
|
|
||||||
}
|
|
||||||
else if(&rModify == m_pMark)
|
|
||||||
m_pMark = dynamic_cast<const ::sw::mark::IMark*>(pModifyChangedHint->m_pNew);
|
|
||||||
else if(&rModify == m_pTableFormat)
|
|
||||||
m_pTableFormat = dynamic_cast<const SwFrameFormat*>(pModifyChangedHint->m_pNew);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -788,9 +787,8 @@ void SwXTextRange::SetPositions(const SwPaM& rPam)
|
|||||||
{
|
{
|
||||||
m_pImpl->Invalidate();
|
m_pImpl->Invalidate();
|
||||||
IDocumentMarkAccess* const pMA = m_pImpl->m_rDoc.getIDocumentMarkAccess();
|
IDocumentMarkAccess* const pMA = m_pImpl->m_rDoc.getIDocumentMarkAccess();
|
||||||
m_pImpl->m_pMark = pMA->makeMark(rPam, OUString(),
|
auto pMark = pMA->makeMark(rPam, OUString(), IDocumentMarkAccess::MarkType::UNO_BOOKMARK, sw::mark::InsertMode::New);
|
||||||
IDocumentMarkAccess::MarkType::UNO_BOOKMARK, sw::mark::InsertMode::New);
|
m_pImpl->SetMark(*pMark);
|
||||||
m_pImpl->m_aMultiListener.StartListening(const_cast<::sw::mark::IMark*>(m_pImpl->m_pMark));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SwXTextRange::DeleteAndInsert(
|
void SwXTextRange::DeleteAndInsert(
|
||||||
|
Reference in New Issue
Block a user