diff options
author | Bjoern Michaelsen <bjoern.michaelsen@libreoffice.org> | 2022-09-24 19:28:17 +0200 |
---|---|---|
committer | Bjoern Michaelsen <bjoern.michaelsen@libreoffice.org> | 2022-09-25 10:42:33 +0200 |
commit | eea9f1ee27db98617871b9ecf80e9b3a62a4e723 (patch) | |
tree | 31c586cc335f2e32557016ccb5033b03fbe4cc40 /sw/source/core | |
parent | 79152891824581ad765dc8518150027c417bb9a2 (diff) |
unwrap SwInsText to a plain SfxHint
- also add some constnesss and move some things to private
Change-Id: I67a45e1326361b5a8f7e320b3525e74e93b1ef12
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140556
Tested-by: Jenkins
Reviewed-by: Bjoern Michaelsen <bjoern.michaelsen@libreoffice.org>
Diffstat (limited to 'sw/source/core')
-rw-r--r-- | sw/source/core/attr/hints.cxx | 17 | ||||
-rw-r--r-- | sw/source/core/doc/docbm.cxx | 6 | ||||
-rw-r--r-- | sw/source/core/inc/txtfrm.hxx | 4 | ||||
-rw-r--r-- | sw/source/core/text/txtfrm.cxx | 94 | ||||
-rw-r--r-- | sw/source/core/txtnode/ndtxt.cxx | 21 | ||||
-rw-r--r-- | sw/source/core/txtnode/txtedt.cxx | 7 |
6 files changed, 78 insertions, 71 deletions
diff --git a/sw/source/core/attr/hints.cxx b/sw/source/core/attr/hints.cxx index bc686196a254..76a5113eed46 100644 --- a/sw/source/core/attr/hints.cxx +++ b/sw/source/core/attr/hints.cxx @@ -32,13 +32,6 @@ SwFormatChg::SwFormatChg( SwFormat* pFormat ) { } -SwInsText::SwInsText(sal_Int32 const nP, sal_Int32 const nL, bool const isInFMCommand, bool const isInFMResult) - : SwMsgPoolItem( RES_INS_TXT ) - , nPos( nP ), nLen( nL ) - , isInsideFieldmarkCommand(isInFMCommand) - , isInsideFieldmarkResult(isInFMResult) -{ -} SwDelChr::SwDelChr( sal_Int32 nP ) : SwMsgPoolItem( RES_DEL_CHR ), nPos( nP ) @@ -53,7 +46,15 @@ MoveText::MoveText(SwTextNode *const pD, sal_Int32 const nD, sal_Int32 const nS, { } -DeleteText::DeleteText( sal_Int32 nS, sal_Int32 nL ) +InsertText::InsertText(const sal_Int32 nP, const sal_Int32 nL, const bool isInFMCommand, const bool isInFMResult) + : SfxHint( SfxHintId::SwInsertText ) + , nPos( nP ), nLen( nL ) + , isInsideFieldmarkCommand(isInFMCommand) + , isInsideFieldmarkResult(isInFMResult) +{ +} + +DeleteText::DeleteText( const sal_Int32 nS, const sal_Int32 nL ) : SfxHint( SfxHintId::SwDeleteText ), nStart( nS ), nLen( nL ) { } diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx index 2347a68638b6..76a684282e7c 100644 --- a/sw/source/core/doc/docbm.cxx +++ b/sw/source/core/doc/docbm.cxx @@ -688,7 +688,7 @@ namespace sw::mark && (eType == IDocumentMarkAccess::MarkType::TEXT_FIELDMARK || eType == IDocumentMarkAccess::MarkType::DATE_FIELDMARK)) { - // due to SwInsText notifications everything is visible now - tell + // due to sw::InsertText notifications everything is visible now - tell // layout to hide as appropriate // note: we don't know how many layouts there are and which // parts they hide, so just notify the entire fieldmark, it @@ -1994,7 +1994,7 @@ void DelBookmarks( namespace sw { -SwInsText MakeSwInsText(SwTextNode & rNode, sal_Int32 const nPos, sal_Int32 const nLen) +InsertText MakeInsertText(SwTextNode& rNode, const sal_Int32 nPos, const sal_Int32 nLen) { SwCursor cursor(SwPosition(rNode, nPos), nullptr); bool isInsideFieldmarkCommand(false); @@ -2015,7 +2015,7 @@ SwInsText MakeSwInsText(SwTextNode & rNode, sal_Int32 const nPos, sal_Int32 cons break; } } - return SwInsText(nPos, nLen, isInsideFieldmarkCommand, isInsideFieldmarkResult); + return InsertText(nPos, nLen, isInsideFieldmarkCommand, isInsideFieldmarkResult); } } // namespace sw diff --git a/sw/source/core/inc/txtfrm.hxx b/sw/source/core/inc/txtfrm.hxx index b0c2771d1d2e..f75de95ae0ae 100644 --- a/sw/source/core/inc/txtfrm.hxx +++ b/sw/source/core/inc/txtfrm.hxx @@ -31,7 +31,6 @@ namespace com::sun::star::linguistic2 { class XHyphenatedWord; } namespace sw::mark { class IMark; } class SwCharRange; -class SwInsText; class SwTextNode; class SwTextAttrEnd; class SwTextFormatter; @@ -99,6 +98,7 @@ struct Extent }; struct MergedPara; +class InsertText; std::pair<SwTextNode*, sal_Int32> MapViewToModel(MergedPara const&, TextFrameIndex nIndex); TextFrameIndex MapModelToView(MergedPara const&, SwTextNode const* pNode, sal_Int32 nIndex); @@ -149,7 +149,7 @@ bool IsMarkHintHidden(SwRootFrame const& rLayout, void RecreateStartTextFrames(SwTextNode & rNode); -auto MakeSwInsText(SwTextNode & rNode, sal_Int32 nPos, sal_Int32 nLen) -> SwInsText; +sw::InsertText MakeInsertText(SwTextNode& rNode, const sal_Int32 nPos, const sal_Int32 nLen); /** * Decides if rTextNode has a numbering which has layout-level values (e.g. Arabic, but not diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx index 9eaad2150aac..1de6c91cc633 100644 --- a/sw/source/core/text/txtfrm.cxx +++ b/sw/source/core/text/txtfrm.cxx @@ -1934,7 +1934,7 @@ void UpdateMergedParaForMove(sw::MergedPara & rMerged, // assert(nDeleted == it.second - it.first); if(nDeleted) { - // InvalidateRange/lcl_SetScriptInval was called sufficiently for SwInsText + // InvalidateRange/lcl_SetScriptInval was called sufficiently for InsertText lcl_SetWrong(rTextFrame, rDestNode, nStart, it.first - it.second, false); TextFrameIndex const nIndex(sw::MapModelToView(rMerged, &rDestNode, nStart)); lcl_ModifyOfst(rTextFrame, nIndex, nDeleted, &o3tl::operator-<sal_Int32, Tag_TextFrameIndex>); @@ -1975,6 +1975,7 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint) SfxPoolItem const* pOld(nullptr); SfxPoolItem const* pNew(nullptr); sw::MoveText const* pMoveText(nullptr); + sw::InsertText const* pInsertText(nullptr); sw::DeleteText const* pDeleteText(nullptr); sw::RedlineDelText const* pRedlineDelText(nullptr); sw::RedlineUnDelText const* pRedlineUnDelText(nullptr); @@ -1987,6 +1988,10 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint) pNew = pHint->m_pNew; nWhich = pHint->GetWhich(); } + else if (rHint.GetId() == SfxHintId::SwInsertText) + { + pInsertText = static_cast<const sw::InsertText*>(&rHint); + } else if (rHint.GetId() == SfxHintId::SwDeleteText) { pDeleteText = static_cast<const sw::DeleteText*>(&rHint); @@ -2137,6 +2142,48 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint) // assert(!m_pMergedPara || !getRootFrame()->IsHideRedlines() || !pMoveText->pDestNode->getLayoutFrame(getRootFrame())); } } + else if (pInsertText) + { + nPos = MapModelToView(&rNode, pInsertText->nPos); + // unlike redlines, inserting into fieldmark must be explicitly handled + bool isHidden(false); + switch (getRootFrame()->GetFieldmarkMode()) + { + case sw::FieldmarkMode::ShowCommand: + isHidden = pInsertText->isInsideFieldmarkResult; + break; + case sw::FieldmarkMode::ShowResult: + isHidden = pInsertText->isInsideFieldmarkCommand; + break; + case sw::FieldmarkMode::ShowBoth: // just to avoid the warning + break; + } + if (!isHidden) + { + nLen = TextFrameIndex(pInsertText->nLen); + if (m_pMergedPara) + { + UpdateMergedParaForInsert(*m_pMergedPara, true, rNode, pInsertText->nPos, pInsertText->nLen); + } + if( IsIdxInside( nPos, nLen ) ) + { + if( !nLen ) + { + // Refresh NumPortions even when line is empty! + if( nPos ) + InvalidateSize(); + else + Prepare(); + } + else + InvalidateRange_( SwCharRange( nPos, nLen ), pInsertText->nLen ); + } + lcl_SetScriptInval( *this, nPos ); + bSetFieldsDirty = true; + lcl_ModifyOfst(*this, nPos, nLen, &o3tl::operator+<sal_Int32, Tag_TextFrameIndex>); + } + lcl_SetWrong( *this, rNode, pInsertText->nPos, pInsertText->nLen, true ); + } else if (pDeleteText) { nPos = MapModelToView(&rNode, pDeleteText->nStart); @@ -2172,51 +2219,6 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint) InvalidateLineNum(); } break; - case RES_INS_TXT: - { - sal_Int32 const nNPos = static_cast<const SwInsText*>(pNew)->nPos; - sal_Int32 const nNLen = static_cast<const SwInsText*>(pNew)->nLen; - nPos = MapModelToView(&rNode, nNPos); - // unlike redlines, inserting into fieldmark must be explicitly handled - bool isHidden(false); - switch (getRootFrame()->GetFieldmarkMode()) - { - case sw::FieldmarkMode::ShowCommand: - isHidden = static_cast<const SwInsText*>(pNew)->isInsideFieldmarkResult; - break; - case sw::FieldmarkMode::ShowResult: - isHidden = static_cast<const SwInsText*>(pNew)->isInsideFieldmarkCommand; - break; - case sw::FieldmarkMode::ShowBoth: // just to avoid the warning - break; - } - if (!isHidden) - { - nLen = TextFrameIndex(nNLen); - if (m_pMergedPara) - { - UpdateMergedParaForInsert(*m_pMergedPara, true, rNode, nNPos, nNLen); - } - if( IsIdxInside( nPos, nLen ) ) - { - if( !nLen ) - { - // Refresh NumPortions even when line is empty! - if( nPos ) - InvalidateSize(); - else - Prepare(); - } - else - InvalidateRange_( SwCharRange( nPos, nLen ), nNLen ); - } - lcl_SetScriptInval( *this, nPos ); - bSetFieldsDirty = true; - lcl_ModifyOfst(*this, nPos, nLen, &o3tl::operator+<sal_Int32, Tag_TextFrameIndex>); - } - lcl_SetWrong( *this, rNode, nNPos, nNLen, true ); - } - break; case RES_DEL_CHR: { sal_Int32 const nNPos = static_cast<const SwDelChr*>(pNew)->nPos; diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index 9e64257d3e3e..d232e3beca7b 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -2374,8 +2374,8 @@ OUString SwTextNode::InsertText( const OUString & rStr, const SwContentIndex & r if ( HasWriterListeners() ) { // send this before messing with hints, which will send RES_UPDATE_ATTR - SwInsText const aHint(sw::MakeSwInsText(*this, aPos, nLen)); - CallSwClientNotify(sw::LegacyModifyHint(nullptr, &aHint)); + auto aInsHint = sw::MakeInsertText(*this, aPos, nLen); + CallSwClientNotify(aInsHint); } if ( HasHints() ) @@ -2586,11 +2586,12 @@ void SwTextNode::CutImpl( SwTextNode * const pDest, const SwContentIndex & rDest // notify frames - before moving hints, because footnotes // want to find their anchor text frame in the follow chain // (also ignore fieldmarks, the caller will recreate frames) - SwInsText const aInsHint(nDestStart, nLen, false, false); - pDest->TriggerNodeUpdate(sw::LegacyModifyHint(nullptr, &aInsHint)); + const sw::InsertText aInsHint(nDestStart, nLen, false, false); + pDest->HandleNonLegacyHint(aInsHint); const sw::MoveText aMoveHint(pDest, nDestStart, nTextStartIdx, nLen); CallSwClientNotify(aMoveHint); - HandleDeleteText(sw::DeleteText(nTextStartIdx, nLen)); + const sw::DeleteText aDelText(nTextStartIdx, nLen); + HandleNonLegacyHint(aDelText); // 2. move attributes // Iterate over attribute array until the start of the attribute @@ -3831,12 +3832,13 @@ void SwTextNode::ReplaceText( const SwContentIndex& rStart, const sal_Int32 nDel } SetIgnoreDontExpand( bOldExpFlg ); - CallSwClientNotify(sw::DeleteText(nStartPos, nDelLen)); + auto aDelHint = sw::DeleteText(nStartPos, nDelLen); + CallSwClientNotify(aDelHint); if (sInserted.getLength()) { - SwInsText const aHint(sw::MakeSwInsText(*this, nStartPos, sInserted.getLength())); - CallSwClientNotify(sw::LegacyModifyHint(nullptr, &aHint)); + auto aInsHint = sw::MakeInsertText(*this, nStartPos, sInserted.getLength()); + CallSwClientNotify(aInsHint); } } @@ -5381,8 +5383,9 @@ bool SwTextNode::IsInContent() const return !GetDoc().IsInHeaderFooter( *this ); } -void SwTextNode::HandleDeleteText(const sw::DeleteText& rHint) +void SwTextNode::HandleNonLegacyHint(const SfxHint& rHint) { + assert(!dynamic_cast<const sw::LegacyModifyHint*>(&rHint)); sw::TextNodeNotificationSuppressor(*this); CallSwClientNotify(rHint); diff --git a/sw/source/core/txtnode/txtedt.cxx b/sw/source/core/txtnode/txtedt.cxx index 97ae80b3d34e..30ea67277ab8 100644 --- a/sw/source/core/txtnode/txtedt.cxx +++ b/sw/source/core/txtnode/txtedt.cxx @@ -2014,10 +2014,11 @@ void SwTextNode::ReplaceTextOnly( sal_Int32 nPos, sal_Int32 nLen, Update(SwContentIndex(this, nMyOff), nLen - nMyOff, UpdateMode::Negative); // notify the layout! - CallSwClientNotify(sw::DeleteText(nPos, nTLen)); + const auto aDelHint = sw::DeleteText(nPos, nTLen); + CallSwClientNotify(aDelHint); - SwInsText const aHint(sw::MakeSwInsText(*this, nPos, nTLen)); - CallSwClientNotify(sw::LegacyModifyHint(nullptr, &aHint)); + const auto aInsHint = sw::MakeInsertText(*this, nPos, nTLen); + CallSwClientNotify(aInsHint); } // the return values allows us to see if we did the heavy- |