include/svl/hint.hxx           |    6 ++++++
 sw/inc/hints.hxx               |    7 ++++---
 sw/source/core/attr/hints.cxx  |   15 ---------------
 sw/source/core/text/txtfrm.cxx |   12 ++++++------
 4 files changed, 16 insertions(+), 24 deletions(-)

New commits:
commit 91dbd5ca9fa2e689dcdbc5be4a60c8b65cbefc9f
Author:     Noel Grandin <[email protected]>
AuthorDate: Wed May 29 19:26:44 2024 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Thu May 30 09:18:33 2024 +0200

    avoid some dynamic_cast in SwTextFrame
    
    Change-Id: Ib73063871472727f27b552b1074d9d3872269b44
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168231
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <[email protected]>

diff --git a/include/svl/hint.hxx b/include/svl/hint.hxx
index b802f786312b..3dd3db1763ea 100644
--- a/include/svl/hint.hxx
+++ b/include/svl/hint.hxx
@@ -163,6 +163,9 @@ enum class SfxHintId {
     SwModifyChanged,
     SwAttr,
     SwDocumentDying,
+    SwRedlineDelText,
+    SwRedlineUnDelText,
+    SwMoveText,
 
     ThisIsAnSdrHint,
     ThisIsAnSfxEventHint
@@ -257,6 +260,9 @@ inline std::basic_ostream<charT, traits> & operator <<(
     case SfxHintId::SwModifyChanged: return stream << "SwModifyChanged";
     case SfxHintId::SwAttr: return stream << "SwAttr";
     case SfxHintId::SwDocumentDying: return stream << "SwDocumentDying";
+    case SfxHintId::SwRedlineDelText: return stream << "SwRedlineDelText";
+    case SfxHintId::SwRedlineUnDelText: return stream << "SwRedlineUnDelText";
+    case SfxHintId::SwMoveText: return stream << "SwMoveText";
     case SfxHintId::ThisIsAnSdrHint: return stream << "SdrHint";
     default: return stream << "unk(" << std::to_string(int(id)) << ")";
     }
diff --git a/sw/inc/hints.hxx b/sw/inc/hints.hxx
index 15836add1988..a05d63dfe135 100644
--- a/sw/inc/hints.hxx
+++ b/sw/inc/hints.hxx
@@ -92,7 +92,8 @@ public:
     sal_Int32 nSourceStart;
     sal_Int32 nLen;
 
-    MoveText(SwTextNode *pD, sal_Int32 nD, sal_Int32 nS, sal_Int32 nL);
+    MoveText(SwTextNode *pD, sal_Int32 nD, sal_Int32 nS, sal_Int32 nL)
+        : SfxHint(SfxHintId::SwMoveText), pDestNode(pD), nDestStart(nD), 
nSourceStart(nS), nLen(nL) {}
 };
 
 class InsertText final : public SfxHint
@@ -130,7 +131,7 @@ public:
     sal_Int32 nStart;
     sal_Int32 nLen;
 
-    RedlineDelText(sal_Int32 nS, sal_Int32 nL);
+    RedlineDelText(sal_Int32 nS, sal_Int32 nL) : 
SfxHint(SfxHintId::SwRedlineDelText), nStart(nS), nLen(nL) {}
 };
 
 /// delete redline is removed
@@ -140,7 +141,7 @@ public:
     sal_Int32 nStart;
     sal_Int32 nLen;
 
-    RedlineUnDelText(sal_Int32 nS, sal_Int32 nL);
+    RedlineUnDelText(sal_Int32 nS, sal_Int32 nL) : 
SfxHint(SfxHintId::SwRedlineUnDelText), nStart(nS), nLen(nL) {}
 };
 
 /** DocPosUpdate is sent to signal that only the frames from or to a specified 
document-global position
diff --git a/sw/source/core/attr/hints.cxx b/sw/source/core/attr/hints.cxx
index 0190d415daff..b1036be3b2e8 100644
--- a/sw/source/core/attr/hints.cxx
+++ b/sw/source/core/attr/hints.cxx
@@ -37,11 +37,6 @@ SwFormatChg::SwFormatChg( SwFormat* pFormat )
 
 namespace sw {
 
-MoveText::MoveText(SwTextNode *const pD, sal_Int32 const nD, sal_Int32 const 
nS, sal_Int32 const nL)
-    : pDestNode(pD), nDestStart(nD), nSourceStart(nS), nLen(nL)
-{
-}
-
 InsertText::InsertText(const sal_Int32 nP, const sal_Int32 nL, const bool 
isInFMCommand, const bool isInFMResult)
     : SfxHint( SfxHintId::SwInsertText )
     , nPos( nP ), nLen( nL )
@@ -60,16 +55,6 @@ DeleteChar::DeleteChar( const sal_Int32 nPos )
 {
 }
 
-RedlineDelText::RedlineDelText(sal_Int32 const nS, sal_Int32 const nL)
-    : nStart(nS), nLen(nL)
-{
-}
-
-RedlineUnDelText::RedlineUnDelText(sal_Int32 const nS, sal_Int32 const nL)
-    : nStart(nS), nLen(nL)
-{
-}
-
 VirtPageNumHint::VirtPageNumHint(const SwPageFrame* pPg):
     SfxHint(SfxHintId::SwVirtPageNumHint),
     m_pPage(nullptr),
diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx
index 8e5a1a904b80..179099eda623 100644
--- a/sw/source/core/text/txtfrm.cxx
+++ b/sw/source/core/text/txtfrm.cxx
@@ -2159,17 +2159,17 @@ void SwTextFrame::SwClientNotify(SwModify const& 
rModify, SfxHint const& rHint)
             pPage->UpdateVirtPageNumInfo(rVirtPageNumHint, this);
         return;
     }
-    else if (auto const pHt = dynamic_cast<sw::MoveText const*>(&rHint))
+    else if (rHint.GetId() == SfxHintId::SwMoveText)
     {
-        pMoveText = pHt;
+        pMoveText = static_cast<sw::MoveText const*>(&rHint);
     }
-    else if (auto const pHynt = dynamic_cast<sw::RedlineDelText 
const*>(&rHint))
+    else if (rHint.GetId() == SfxHintId::SwRedlineDelText)
     {
-        pRedlineDelText = pHynt;
+        pRedlineDelText = static_cast<sw::RedlineDelText const*>(&rHint);
     }
-    else if (auto const pHnt = dynamic_cast<sw::RedlineUnDelText 
const*>(&rHint))
+    else if (rHint.GetId() == SfxHintId::SwRedlineUnDelText)
     {
-        pRedlineUnDelText = pHnt;
+        pRedlineUnDelText = static_cast<sw::RedlineUnDelText const*>(&rHint);
     }
     else
     {

Reply via email to