unwrap SwDelChr to plain SfxHint

Change-Id: Ief37a8025181b6cc8a6e484e2726d8a8d92f57ea
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140567
Tested-by: Jenkins
Reviewed-by: Bjoern Michaelsen <bjoern.michaelsen@libreoffice.org>
This commit is contained in:
Bjoern Michaelsen
2022-09-25 11:34:10 +02:00
parent b0cab94446
commit eb1294a607
8 changed files with 45 additions and 46 deletions

View File

@@ -1592,8 +1592,6 @@ include/svl/typedwhich.hxx:31
TypedWhichId::TypedWhichId(TypedWhichId<type-parameter-?-?>,typename enable_if<std::is_base_of_v<SwContrastGrf, derived_type>, int>::type) TypedWhichId::TypedWhichId(TypedWhichId<type-parameter-?-?>,typename enable_if<std::is_base_of_v<SwContrastGrf, derived_type>, int>::type)
include/svl/typedwhich.hxx:31 include/svl/typedwhich.hxx:31
TypedWhichId::TypedWhichId(TypedWhichId<type-parameter-?-?>,typename enable_if<std::is_base_of_v<SwCropGrf, derived_type>, int>::type) TypedWhichId::TypedWhichId(TypedWhichId<type-parameter-?-?>,typename enable_if<std::is_base_of_v<SwCropGrf, derived_type>, int>::type)
include/svl/typedwhich.hxx:31
TypedWhichId::TypedWhichId(TypedWhichId<type-parameter-?-?>,typename enable_if<std::is_base_of_v<SwDelChr, derived_type>, int>::type)
include/svl/typedwhich.hxx:31 include/svl/typedwhich.hxx:31
TypedWhichId::TypedWhichId(TypedWhichId<type-parameter-?-?>,typename enable_if<std::is_base_of_v<SwDocDisplayItem, derived_type>, int>::type) TypedWhichId::TypedWhichId(TypedWhichId<type-parameter-?-?>,typename enable_if<std::is_base_of_v<SwDocDisplayItem, derived_type>, int>::type)
include/svl/typedwhich.hxx:31 include/svl/typedwhich.hxx:31

View File

@@ -142,6 +142,7 @@ enum class SfxHintId {
SwNameChanged, // this can possibly be replaced by the generic NameChanged above SwNameChanged, // this can possibly be replaced by the generic NameChanged above
SwInsertText, SwInsertText,
SwDeleteText, SwDeleteText,
SwDeleteChar,
ThisIsAnSdrHint ThisIsAnSdrHint
}; };

View File

@@ -434,7 +434,6 @@
// class SwMsgPoolItem : public SfxPoolItem // class SwMsgPoolItem : public SfxPoolItem
// class SwPtrMsgPoolItem : public SwMsgPoolItem // class SwPtrMsgPoolItem : public SwMsgPoolItem
// class SwFormatChg: public SwMsgPoolItem // class SwFormatChg: public SwMsgPoolItem
// class SwDelChr: public SwMsgPoolItem
// class SwUpdateAttr : public SwMsgPoolItem // class SwUpdateAttr : public SwMsgPoolItem
// class SwRefMarkFieldUpdate : public SwMsgPoolItem // class SwRefMarkFieldUpdate : public SwMsgPoolItem
// class SwDocPosUpdate : public SwMsgPoolItem // class SwDocPosUpdate : public SwMsgPoolItem

View File

@@ -133,7 +133,6 @@ class SwTableBoxNumFormat;
class SwTextGridItem; class SwTextGridItem;
class SwTransparencyGrf; class SwTransparencyGrf;
class SwFormatRuby; class SwFormatRuby;
class SwDelChr;
class SwRefMarkFieldUpdate; class SwRefMarkFieldUpdate;
class SwTableFormulaUpdate; class SwTableFormulaUpdate;
class SwAutoFormatGetDocNode; class SwAutoFormatGetDocNode;
@@ -422,7 +421,6 @@ constexpr sal_uInt16 RES_MSG_BEGIN(RES_FMT_END);
constexpr TypedWhichId<SwPtrMsgPoolItem> RES_OBJECTDYING(RES_MSG_BEGIN); // 161 constexpr TypedWhichId<SwPtrMsgPoolItem> RES_OBJECTDYING(RES_MSG_BEGIN); // 161
constexpr TypedWhichId<SwFormatChg> RES_FMT_CHG(162); constexpr TypedWhichId<SwFormatChg> RES_FMT_CHG(162);
constexpr TypedWhichId<SwAttrSetChg> RES_ATTRSET_CHG(163); constexpr TypedWhichId<SwAttrSetChg> RES_ATTRSET_CHG(163);
constexpr TypedWhichId<SwDelChr> RES_DEL_CHR(165);
constexpr TypedWhichId<SwUpdateAttr> RES_UPDATE_ATTR(167); constexpr TypedWhichId<SwUpdateAttr> RES_UPDATE_ATTR(167);
constexpr TypedWhichId<SwRefMarkFieldUpdate> RES_REFMARKFLD_UPDATE(168); constexpr TypedWhichId<SwRefMarkFieldUpdate> RES_REFMARKFLD_UPDATE(168);
constexpr TypedWhichId<SwDocPosUpdate> RES_DOCPOS_UPDATE(169); constexpr TypedWhichId<SwDocPosUpdate> RES_DOCPOS_UPDATE(169);

View File

@@ -76,13 +76,6 @@ public:
SwFormatChg( SwFormat *pFormat ); SwFormatChg( SwFormat *pFormat );
}; };
class SwDelChr final : public SwMsgPoolItem
{
public:
sal_Int32 nPos;
SwDelChr( sal_Int32 nP );
};
namespace sw { namespace sw {
@@ -119,6 +112,14 @@ public:
DeleteText( sal_Int32 nS, sal_Int32 nL ); DeleteText( sal_Int32 nS, sal_Int32 nL );
}; };
class DeleteChar final : public SfxHint
{
public:
const sal_Int32 m_nPos;
DeleteChar( const sal_Int32 nPos );
};
/// new delete redline is created /// new delete redline is created
class RedlineDelText final : public SfxHint class RedlineDelText final : public SfxHint
{ {

View File

@@ -33,11 +33,6 @@ SwFormatChg::SwFormatChg( SwFormat* pFormat )
} }
SwDelChr::SwDelChr( sal_Int32 nP )
: SwMsgPoolItem( RES_DEL_CHR ), nPos( nP )
{
}
namespace sw { namespace sw {
@@ -59,6 +54,11 @@ DeleteText::DeleteText( const sal_Int32 nS, const sal_Int32 nL )
{ {
} }
DeleteChar::DeleteChar( const sal_Int32 nPos )
: SfxHint( SfxHintId::SwDeleteChar ), m_nPos( nPos )
{
}
RedlineDelText::RedlineDelText(sal_Int32 const nS, sal_Int32 const nL) RedlineDelText::RedlineDelText(sal_Int32 const nS, sal_Int32 const nL)
: nStart(nS), nLen(nL) : nStart(nS), nLen(nL)
{ {

View File

@@ -1977,6 +1977,7 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint)
sw::MoveText const* pMoveText(nullptr); sw::MoveText const* pMoveText(nullptr);
sw::InsertText const* pInsertText(nullptr); sw::InsertText const* pInsertText(nullptr);
sw::DeleteText const* pDeleteText(nullptr); sw::DeleteText const* pDeleteText(nullptr);
sw::DeleteChar const* pDeleteChar(nullptr);
sw::RedlineDelText const* pRedlineDelText(nullptr); sw::RedlineDelText const* pRedlineDelText(nullptr);
sw::RedlineUnDelText const* pRedlineUnDelText(nullptr); sw::RedlineUnDelText const* pRedlineUnDelText(nullptr);
@@ -1996,6 +1997,10 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint)
{ {
pDeleteText = static_cast<const sw::DeleteText*>(&rHint); pDeleteText = static_cast<const sw::DeleteText*>(&rHint);
} }
else if (rHint.GetId() == SfxHintId::SwDeleteChar)
{
pDeleteChar = static_cast<const sw::DeleteChar*>(&rHint);
}
else if (auto const pHt = dynamic_cast<sw::MoveText const*>(&rHint)) else if (auto const pHt = dynamic_cast<sw::MoveText const*>(&rHint))
{ {
pMoveText = pHt; pMoveText = pHt;
@@ -2211,6 +2216,26 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint)
lcl_ModifyOfst(*this, nPos, nLen, &o3tl::operator-<sal_Int32, Tag_TextFrameIndex>); lcl_ModifyOfst(*this, nPos, nLen, &o3tl::operator-<sal_Int32, Tag_TextFrameIndex>);
} }
} }
else if (pDeleteChar)
{
nPos = MapModelToView(&rNode, pDeleteChar->m_nPos);
if (m_pMergedPara)
{
nLen = UpdateMergedParaForDelete(*m_pMergedPara, true, rNode, pDeleteChar->m_nPos, 1);
}
else
{
nLen = TextFrameIndex(1);
}
lcl_SetWrong( *this, rNode, pDeleteChar->m_nPos, -1, true );
if (nLen)
{
InvalidateRange( SwCharRange(nPos, nLen), -1 );
lcl_SetScriptInval( *this, nPos );
bSetFieldsDirty = bRecalcFootnoteFlag = true;
lcl_ModifyOfst(*this, nPos, nLen, &o3tl::operator-<sal_Int32, Tag_TextFrameIndex>);
}
}
else switch (nWhich) else switch (nWhich)
{ {
case RES_LINENUMBER: case RES_LINENUMBER:
@@ -2219,28 +2244,6 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint)
InvalidateLineNum(); InvalidateLineNum();
} }
break; break;
case RES_DEL_CHR:
{
sal_Int32 const nNPos = static_cast<const SwDelChr*>(pNew)->nPos;
nPos = MapModelToView(&rNode, nNPos);
if (m_pMergedPara)
{
nLen = UpdateMergedParaForDelete(*m_pMergedPara, true, rNode, nNPos, 1);
}
else
{
nLen = TextFrameIndex(1);
}
lcl_SetWrong( *this, rNode, nNPos, -1, true );
if (nLen)
{
InvalidateRange( SwCharRange(nPos, nLen), -1 );
lcl_SetScriptInval( *this, nPos );
bSetFieldsDirty = bRecalcFootnoteFlag = true;
lcl_ModifyOfst(*this, nPos, nLen, &o3tl::operator-<sal_Int32, Tag_TextFrameIndex>);
}
}
break;
case RES_UPDATE_ATTR: case RES_UPDATE_ATTR:
{ {
const SwUpdateAttr* pNewUpdate = static_cast<const SwUpdateAttr*>(pNew); const SwUpdateAttr* pNewUpdate = static_cast<const SwUpdateAttr*>(pNew);

View File

@@ -2819,14 +2819,13 @@ void SwTextNode::EraseText(const SwContentIndex &rIdx, const sal_Int32 nCount,
Update(rIdx, nCnt, UpdateMode::Negative); Update(rIdx, nCnt, UpdateMode::Negative);
if( 1 == nCnt ) if(1 == nCnt)
{ {
SwDelChr aHint( nStartIdx ); const auto aHint = sw::DeleteChar(nStartIdx);
CallSwClientNotify(sw::LegacyModifyHint(nullptr, &aHint)); CallSwClientNotify(aHint);
} } else {
else const auto aHint = sw::DeleteText(nStartIdx, nCnt);
{ CallSwClientNotify(aHint);
CallSwClientNotify(sw::DeleteText(nStartIdx, nCnt));
} }
OSL_ENSURE(rIdx.GetIndex() == nStartIdx, "huh? start index has changed?"); OSL_ENSURE(rIdx.GetIndex() == nStartIdx, "huh? start index has changed?");