diff options
author | Michael Stahl <Michael.Stahl@cib.de> | 2018-06-05 13:41:58 +0200 |
---|---|---|
committer | Michael Stahl <Michael.Stahl@cib.de> | 2018-06-08 21:51:37 +0200 |
commit | 162fb509aee3c30b5b7bd15daf602c4f38e94242 (patch) | |
tree | 6c5a02622792a4fc2137982b4c4e1490b0d1bae3 /sw | |
parent | 9ab9a3d8075f57c3ca6a8603d26624796a51528e (diff) |
sw_redlinehide: send a hint to the SwTextFrame when Delete redline
... is created or updated; there is already a SwUpdateAttr
hint being sent from SwRangeRedline::InvalidateRange(),
but it doesn't contain any info about the redline other than the
position; add a new hint sw::RedlineDelText and send it from there in
addition to the existing one.
Change-Id: I37150b2a5ca6a0e70ea4a5788f720f8522227631
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/hints.hxx | 13 | ||||
-rw-r--r-- | sw/source/core/attr/hints.cxx | 9 | ||||
-rw-r--r-- | sw/source/core/doc/docredln.cxx | 10 | ||||
-rw-r--r-- | sw/source/core/text/txtfrm.cxx | 51 |
4 files changed, 77 insertions, 6 deletions
diff --git a/sw/inc/hints.hxx b/sw/inc/hints.hxx index 4da6408dfe99..dc31d7424756 100644 --- a/sw/inc/hints.hxx +++ b/sw/inc/hints.hxx @@ -93,6 +93,19 @@ public: SwDelText( sal_Int32 nS, sal_Int32 nL ); }; +namespace sw { + +class RedlineDelText : public SfxHint +{ +public: + sal_Int32 nStart; + sal_Int32 nLen; + + RedlineDelText(sal_Int32 nS, sal_Int32 nL); +}; + +} + class SwUpdateAttr : public SwMsgPoolItem { private: diff --git a/sw/source/core/attr/hints.cxx b/sw/source/core/attr/hints.cxx index 678db2590528..44c60ff0fd17 100644 --- a/sw/source/core/attr/hints.cxx +++ b/sw/source/core/attr/hints.cxx @@ -46,6 +46,15 @@ SwDelText::SwDelText( sal_Int32 nS, sal_Int32 nL ) { } +namespace sw { + +RedlineDelText::RedlineDelText(sal_Int32 const nS, sal_Int32 const nL) + : nStart(nS), nLen(nL) +{ +} + +} // namespace sw + SwUpdateAttr::SwUpdateAttr( sal_Int32 nS, sal_Int32 nE, sal_uInt16 nW ) : SwMsgPoolItem( RES_UPDATE_ATTR ), m_nStart( nS ), m_nEnd( nE ), m_nWhichAttr( nW ) { diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx index c5731c36c457..1e31e7150324 100644 --- a/sw/source/core/doc/docredln.cxx +++ b/sw/source/core/doc/docredln.cxx @@ -1269,12 +1269,22 @@ void SwRangeRedline::InvalidateRange() // trigger the Layout if (pNode && pNode->IsTextNode()) { SwTextNode* pNd = pNode->GetTextNode(); + SwUpdateAttr aHt( n == nSttNd ? nSttCnt : 0, n == nEndNd ? nEndCnt : pNd->GetText().getLength(), RES_FMT_CHG); pNd->ModifyNotification(&aHt, &aHt); + + // SwUpdateAttr must be handled first, otherwise indexes are off + if (GetType() == nsRedlineType_t::REDLINE_DELETE) + { + sal_Int32 const nStart(n == nSttNd ? nSttCnt : 0); + sw::RedlineDelText const hint(nStart, + (n == nEndNd ? nEndCnt : pNd->GetText().getLength()) - nStart); + pNd->CallSwClientNotify(hint); + } } } } diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx index bbfa87e52839..39a0c8262925 100644 --- a/sw/source/core/text/txtfrm.cxx +++ b/sw/source/core/text/txtfrm.cxx @@ -1543,18 +1543,30 @@ static bool isA11yRelevantAttribute(sal_uInt16 nWhich) // SwContentFrame::Modify() when appropriate. void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint) { - auto const pHint(dynamic_cast<sw::LegacyModifyHint const*>(&rHint)); - assert(pHint); // TODO this is the only type expected here for now + SfxPoolItem const* pOld(nullptr); + SfxPoolItem const* pNew(nullptr); + sw::RedlineDelText const* pRedlineDelText(nullptr); - SfxPoolItem const*const pOld(pHint->m_pOld); - SfxPoolItem const*const pNew(pHint->m_pNew); - SwTextNode const& rNode(static_cast<SwTextNode const&>(rModify)); + if (auto const pHint = dynamic_cast<sw::LegacyModifyHint const*>(&rHint)) + { + pOld = pHint->m_pOld; + pNew = pHint->m_pNew; + } + else if (auto const pHynt = dynamic_cast<sw::RedlineDelText const*>(&rHint)) + { + pRedlineDelText = pHynt; + } + else + { + assert(!"unexpected hint"); + } if (m_pMergedPara) { assert(m_pMergedPara->listener.IsListeningTo(&rModify)); } + SwTextNode const& rNode(static_cast<SwTextNode const&>(rModify)); const sal_uInt16 nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0; // modifications concerning frame attributes are processed by the base class @@ -1606,7 +1618,34 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint) bool bSetFieldsDirty = false; bool bRecalcFootnoteFlag = false; - switch( nWhich ) + if (pRedlineDelText) + { + if (m_pMergedPara) + { + sal_Int32 const nNPos = pRedlineDelText->nStart; + sal_Int32 const nNLen = pRedlineDelText->nLen; + nPos = MapModelToView(&rNode, nNPos); + // update merged before doing anything else + nLen = UpdateMergedParaForDelete(*m_pMergedPara, false, rNode, nNPos, nNLen); + const sal_Int32 m = -nNLen; + if (nLen && IsIdxInside(nPos, nLen)) + { + if (!nLen) + InvalidateSize(); + else + InvalidateRange( SwCharRange(nPos, TextFrameIndex(1)), m ); + } + lcl_SetWrong( *this, rNode, nNPos, m, true ); + if (nLen) + { + lcl_SetScriptInval( *this, nPos ); + bSetFieldsDirty = bRecalcFootnoteFlag = true; + if (HasFollow()) + lcl_ModifyOfst( this, nPos, nLen ); + } + } + } + else switch (nWhich) { case RES_LINENUMBER: { |