compilerplugins/clang/unusedmethods.results | 2 include/svl/hint.hxx | 1 svl/source/items/poolitem.cxx | 1 sw/inc/hintids.hxx | 2 sw/inc/hints.hxx | 27 ++++---- sw/inc/ndtxt.hxx | 3 sw/source/core/attr/hints.cxx | 17 ++--- sw/source/core/doc/docbm.cxx | 6 - sw/source/core/inc/txtfrm.hxx | 4 - sw/source/core/text/txtfrm.cxx | 94 ++++++++++++++-------------- sw/source/core/txtnode/ndtxt.cxx | 21 +++--- sw/source/core/txtnode/txtedt.cxx | 7 +- 12 files changed, 94 insertions(+), 91 deletions(-)
New commits: commit eea9f1ee27db98617871b9ecf80e9b3a62a4e723 Author: Bjoern Michaelsen <bjoern.michael...@libreoffice.org> AuthorDate: Sat Sep 24 19:28:17 2022 +0200 Commit: Bjoern Michaelsen <bjoern.michael...@libreoffice.org> CommitDate: Sun Sep 25 10:42:33 2022 +0200 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.michael...@libreoffice.org> diff --git a/compilerplugins/clang/unusedmethods.results b/compilerplugins/clang/unusedmethods.results index 2624f69422ef..be732177c36b 100644 --- a/compilerplugins/clang/unusedmethods.results +++ b/compilerplugins/clang/unusedmethods.results @@ -1696,8 +1696,6 @@ include/svl/typedwhich.hxx:31 TypedWhichId::TypedWhichId(TypedWhichId<type-parameter-?-?>,typename enable_if<std::is_base_of_v<SwGrfFormatColl, derived_type>, int>::type) include/svl/typedwhich.hxx:31 TypedWhichId::TypedWhichId(TypedWhichId<type-parameter-?-?>,typename enable_if<std::is_base_of_v<SwHeaderAndFooterEatSpacingItem, derived_type>, int>::type) -include/svl/typedwhich.hxx:31 - TypedWhichId::TypedWhichId(TypedWhichId<type-parameter-?-?>,typename enable_if<std::is_base_of_v<SwInsText, derived_type>, int>::type) include/svl/typedwhich.hxx:31 TypedWhichId::TypedWhichId(TypedWhichId<type-parameter-?-?>,typename enable_if<std::is_base_of_v<SwInvertGrf, derived_type>, int>::type) include/svl/typedwhich.hxx:31 diff --git a/include/svl/hint.hxx b/include/svl/hint.hxx index b22e9c789f3f..4b4677cd768d 100644 --- a/include/svl/hint.hxx +++ b/include/svl/hint.hxx @@ -140,6 +140,7 @@ enum class SfxHintId { SwGatherRefFields, SwGatherFields, SwNameChanged, // this can possibly be replaced by the generic NameChanged above + SwInsertText, SwDeleteText, ThisIsAnSdrHint diff --git a/svl/source/items/poolitem.cxx b/svl/source/items/poolitem.cxx index 5aada9d9d08b..32dfebb51747 100644 --- a/svl/source/items/poolitem.cxx +++ b/svl/source/items/poolitem.cxx @@ -434,7 +434,6 @@ // class SwMsgPoolItem : public SfxPoolItem // class SwPtrMsgPoolItem : public SwMsgPoolItem // class SwFormatChg: public SwMsgPoolItem -// class SwInsText: public SwMsgPoolItem // class SwDelChr: public SwMsgPoolItem // class SwUpdateAttr : public SwMsgPoolItem // class SwRefMarkFieldUpdate : public SwMsgPoolItem diff --git a/sw/inc/hintids.hxx b/sw/inc/hintids.hxx index a2529f935d00..afe2df275aaa 100644 --- a/sw/inc/hintids.hxx +++ b/sw/inc/hintids.hxx @@ -133,7 +133,6 @@ class SwTableBoxNumFormat; class SwTextGridItem; class SwTransparencyGrf; class SwFormatRuby; -class SwInsText; class SwDelChr; class SwRefMarkFieldUpdate; class SwTableFormulaUpdate; @@ -423,7 +422,6 @@ constexpr sal_uInt16 RES_MSG_BEGIN(RES_FMT_END); constexpr TypedWhichId<SwPtrMsgPoolItem> RES_OBJECTDYING(RES_MSG_BEGIN); // 161 constexpr TypedWhichId<SwFormatChg> RES_FMT_CHG(162); constexpr TypedWhichId<SwAttrSetChg> RES_ATTRSET_CHG(163); -constexpr TypedWhichId<SwInsText> RES_INS_TXT(164); constexpr TypedWhichId<SwDelChr> RES_DEL_CHR(165); constexpr TypedWhichId<SwUpdateAttr> RES_UPDATE_ATTR(167); constexpr TypedWhichId<SwRefMarkFieldUpdate> RES_REFMARKFLD_UPDATE(168); diff --git a/sw/inc/hints.hxx b/sw/inc/hints.hxx index 63c25b90b4e0..78952b288193 100644 --- a/sw/inc/hints.hxx +++ b/sw/inc/hints.hxx @@ -76,17 +76,6 @@ public: SwFormatChg( SwFormat *pFormat ); }; -class SwInsText final : public SwMsgPoolItem -{ -public: - sal_Int32 nPos; - sal_Int32 nLen; - bool isInsideFieldmarkCommand; - bool isInsideFieldmarkResult; - - SwInsText(sal_Int32 nP, sal_Int32 nL, bool isInFMCommand, bool isInFMResult); -}; - class SwDelChr final : public SwMsgPoolItem { public: @@ -110,14 +99,26 @@ public: MoveText(SwTextNode *pD, sal_Int32 nD, sal_Int32 nS, sal_Int32 nL); }; +class InsertText final : public SfxHint +{ +public: + const sal_Int32 nPos; + const sal_Int32 nLen; + const bool isInsideFieldmarkCommand; + const bool isInsideFieldmarkResult; + + InsertText(sal_Int32 nP, sal_Int32 nL, bool isInFMCommand, bool isInFMResult); +}; + class DeleteText final : public SfxHint { public: - sal_Int32 nStart; - sal_Int32 nLen; + const sal_Int32 nStart; + const sal_Int32 nLen; DeleteText( sal_Int32 nS, sal_Int32 nL ); }; + /// new delete redline is created class RedlineDelText final : public SfxHint { diff --git a/sw/inc/ndtxt.hxx b/sw/inc/ndtxt.hxx index 3a2b4d65e41d..12b823a52f7c 100644 --- a/sw/inc/ndtxt.hxx +++ b/sw/inc/ndtxt.hxx @@ -70,7 +70,6 @@ class SwField; namespace sw { class TextNodeNotificationSuppressor; - class DeleteText; namespace mark { enum class RestoreMode; } } @@ -184,6 +183,7 @@ class SW_DLLPUBLIC SwTextNode final const SwTextInputField* GetOverlappingInputField( const SwTextAttr& rTextAttr ) const; void DelFrames_TextNodePart(); + void HandleNonLegacyHint(const SfxHint&); public: enum class WrongState { TODO, PENDING, DONE }; @@ -221,7 +221,6 @@ public: public: using SwContentNode::GetAttr; - void HandleDeleteText(const sw::DeleteText&); /// for hanging TextFormatCollections somewhere else (Outline-Numbering!) void TriggerNodeUpdate(const sw::LegacyModifyHint&); 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-