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:
Bjoern Michaelsen
2018-05-10 10:51:42 +02:00
committed by Björn Michaelsen
parent b0a5d36c12
commit db608e8e5e
2 changed files with 38 additions and 39 deletions

View File

@@ -38,6 +38,7 @@ namespace sw { namespace mark
class SW_DLLPUBLIC IMark
: virtual public SwModify // inherited as interface
, public ::boost::totally_ordered<IMark>
, virtual public sw::BroadcasterMixin
{
protected:
IMark() = default;

View File

@@ -21,7 +21,20 @@
#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 <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 <hintids.hxx>
#include <cmdid.h>
@@ -41,7 +54,6 @@
#include <rootfrm.hxx>
#include <flyfrm.hxx>
#include <ftnidx.hxx>
#include <sfx2/linkmgr.hxx>
#include <docary.hxx>
#include <paratr.hxx>
#include <pam.hxx>
@@ -61,9 +73,6 @@
#include <cntfrm.hxx>
#include <pagefrm.hxx>
#include <doctxm.hxx>
#include <sfx2/docfilt.hxx>
#include <sfx2/docfile.hxx>
#include <sfx2/fcontnr.hxx>
#include <fmtrfmrk.hxx>
#include <txtrfmrk.hxx>
#include <unoparaframeenum.hxx>
@@ -81,9 +90,6 @@
#include <unocoll.hxx>
#include <unostyle.hxx>
#include <fmtanchr.hxx>
#include <editeng/flstitem.hxx>
#include <editeng/unolingu.hxx>
#include <svtools/ctrltool.hxx>
#include <flypos.hxx>
#include <txtftn.hxx>
#include <fmtftn.hxx>
@@ -97,9 +103,7 @@
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
#include <unoframe.hxx>
#include <fmthdft.hxx>
#include <vcl/svapp.hxx>
#include <fmtflcnt.hxx>
#include <editeng/brushitem.hxx>
#include <fmtclds.hxx>
#include <dcontact.hxx>
#include <dflyobj.hxx>
@@ -109,8 +113,6 @@
#include <algorithm>
#include <iterator>
#include <calbck.hxx>
#include <comphelper/servicehelper.hxx>
#include <cppuhelper/supportsservice.hxx>
using namespace ::com::sun::star;
@@ -679,30 +681,27 @@ uno::Any SAL_CALL SwXParagraphEnumerationImpl::nextElement()
}
class SwXTextRange::Impl
: public SwClient
: public SvtListener
{
public:
const SfxItemPropertySet& m_rPropSet;
const enum RangePosition m_eRangePosition;
SwDoc& m_rDoc;
uno::Reference<text::XText> m_xParentText;
sw::WriterMultiListener m_aMultiListener;
const ::sw::mark::IMark* m_pMark;
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,
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_rDoc(rDoc)
, m_xParentText(xParent)
, m_aMultiListener(*this)
, m_pMark(nullptr)
, m_pTableFormat(pTableFormat)
, m_pMark(nullptr)
{
m_aMultiListener.StartListening(pTableFormat);
m_pTableFormat && StartListening(pTableFormat->GetNotifier());
}
virtual ~Impl() override
@@ -718,30 +717,30 @@ public:
m_rDoc.getIDocumentMarkAccess()->deleteMark(m_pMark);
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:
// SwClient
virtual void SwClientNotify(const SwModify&, const SfxHint&) override;
virtual void Notify(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(auto pModifyChangedHint = dynamic_cast<const sw::ModifyChangedHint*>(&rHint))
if(rHint.GetId() == SfxHintId::Dying)
{
if(pModifyChangedHint->m_pNew == nullptr)
{
m_aMultiListener.EndListeningAll();
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);
EndListeningAll();
m_pTableFormat = nullptr;
m_pMark = nullptr;
}
}
@@ -788,9 +787,8 @@ void SwXTextRange::SetPositions(const SwPaM& rPam)
{
m_pImpl->Invalidate();
IDocumentMarkAccess* const pMA = m_pImpl->m_rDoc.getIDocumentMarkAccess();
m_pImpl->m_pMark = pMA->makeMark(rPam, OUString(),
IDocumentMarkAccess::MarkType::UNO_BOOKMARK, sw::mark::InsertMode::New);
m_pImpl->m_aMultiListener.StartListening(const_cast<::sw::mark::IMark*>(m_pImpl->m_pMark));
auto pMark = pMA->makeMark(rPam, OUString(), IDocumentMarkAccess::MarkType::UNO_BOOKMARK, sw::mark::InsertMode::New);
m_pImpl->SetMark(*pMark);
}
void SwXTextRange::DeleteAndInsert(