[Libreoffice-commits] core.git: sw/source

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Wed Apr 21 06:36:41 UTC 2021


 sw/source/core/inc/frame.hxx    |   17 ++++++++++++++++-
 sw/source/core/layout/wsfrm.cxx |   39 ++++++++++++++++++++-------------------
 2 files changed, 36 insertions(+), 20 deletions(-)

New commits:
commit f2bbe8bbd543b931352cd4a7626ee2196f6f917d
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Tue Apr 20 21:01:34 2021 +0200
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Wed Apr 21 08:35:50 2021 +0200

    Introduce SwFrameInvFlags to replace magic numbers in SwFrame::SwClientNotify()
    
    SwFrame::UpdateAttrFrame() is not yet updated to produce these.
    
    Change-Id: Ibe822139858cbb39a9ecc14e9631dde8ba369871
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114350
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

diff --git a/sw/source/core/inc/frame.hxx b/sw/source/core/inc/frame.hxx
index 5a797f20feac..02efa581ba7f 100644
--- a/sw/source/core/inc/frame.hxx
+++ b/sw/source/core/inc/frame.hxx
@@ -288,6 +288,21 @@ public:
     void transform(const basegfx::B2DHomMatrix& aTransform);
 };
 
+enum class SwFrameInvFlags : sal_uInt8
+{
+    NONE = 0x00,
+    InvalidatePrt = 0x01,
+    InvalidateSize = 0x02,
+    InvalidatePos = 0x04,
+    SetCompletePaint = 0x08,
+    NextInvalidatePos = 0x10,
+    NextSetCompletePaint = 0x20,
+};
+
+namespace o3tl {
+    template<> struct typed_flags<SwFrameInvFlags> : is_typed_flags<SwFrameInvFlags, 0x003f> {};
+}
+
 /**
  * Base class of the Writer layout elements.
  *
@@ -385,7 +400,7 @@ class SW_DLLPUBLIC SwFrame : public SwFrameAreaDefinition, public SwClient, publ
     */
     SwContentFrame* FindPrevCnt_();
 
-    void UpdateAttrFrame( const SfxPoolItem*, const SfxPoolItem*, sal_uInt8 & );
+    void UpdateAttrFrame( const SfxPoolItem*, const SfxPoolItem*, SwFrameInvFlags & );
     SwFrame* GetIndNext_();
     void SetDirFlags( bool bVert );
 
diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx
index 631d728ba4bd..579ed1f5df47 100644
--- a/sw/source/core/layout/wsfrm.cxx
+++ b/sw/source/core/layout/wsfrm.cxx
@@ -478,7 +478,7 @@ void SwFrame::SwClientNotify(const SwModify&, const SfxHint& rHint)
     auto pLegacy = dynamic_cast<const sw::LegacyModifyHint*>(&rHint);
     if(!pLegacy)
         return;
-    sal_uInt8 nInvFlags = 0;
+    SwFrameInvFlags eInvFlags = SwFrameInvFlags::NONE;
 
     if(pLegacy->m_pOld && pLegacy->m_pNew && RES_ATTRSET_CHG == pLegacy->m_pNew->Which())
     {
@@ -488,44 +488,45 @@ void SwFrame::SwClientNotify(const SwModify&, const SfxHint& rHint)
         const SfxPoolItem* pOItem = aOIter.GetCurItem();
         do
         {
-            UpdateAttrFrame(pOItem, pNItem, nInvFlags);
+            UpdateAttrFrame(pOItem, pNItem, eInvFlags);
             pNItem = aNIter.NextItem();
             pOItem = aOIter.NextItem();
         } while (pNItem);
     }
     else
-        UpdateAttrFrame(pLegacy->m_pOld, pLegacy->m_pNew, nInvFlags);
+        UpdateAttrFrame(pLegacy->m_pOld, pLegacy->m_pNew, eInvFlags);
 
-    if(nInvFlags == 0)
+    if(eInvFlags == SwFrameInvFlags::NONE)
         return;
 
     SwPageFrame* pPage = FindPageFrame();
     InvalidatePage(pPage);
-    if(nInvFlags & 0x01)
+    if(eInvFlags & SwFrameInvFlags::InvalidatePrt)
     {
         InvalidatePrt_();
         if(!GetPrev() && IsTabFrame() && IsInSct())
             FindSctFrame()->InvalidatePrt_();
     }
-    if(nInvFlags & 0x02)
+    if(eInvFlags & SwFrameInvFlags::InvalidateSize)
         InvalidateSize_();
-    if(nInvFlags & 0x04)
+    if(eInvFlags & SwFrameInvFlags::InvalidatePos)
         InvalidatePos_();
-    if(nInvFlags & 0x08)
+    if(eInvFlags & SwFrameInvFlags::SetCompletePaint)
         SetCompletePaint();
     SwFrame *pNxt;
-    if(nInvFlags & 0x30 && nullptr != (pNxt = GetNext()))
+    if (eInvFlags & (SwFrameInvFlags::NextInvalidatePos | SwFrameInvFlags::NextSetCompletePaint)
+        && nullptr != (pNxt = GetNext()))
     {
         pNxt->InvalidatePage(pPage);
-        if(nInvFlags & 0x10)
+        if(eInvFlags & SwFrameInvFlags::NextInvalidatePos)
             pNxt->InvalidatePos_();
-        if(nInvFlags & 0x20)
+        if(eInvFlags & SwFrameInvFlags::NextSetCompletePaint)
             pNxt->SetCompletePaint();
     }
 }
 
 void SwFrame::UpdateAttrFrame( const SfxPoolItem *pOld, const SfxPoolItem *pNew,
-                         sal_uInt8 &rInvFlags )
+                         SwFrameInvFlags &rInvFlags )
 {
     sal_uInt16 nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0;
     switch( nWhich )
@@ -537,29 +538,29 @@ void SwFrame::UpdateAttrFrame( const SfxPoolItem *pOld, const SfxPoolItem *pNew,
         case RES_LR_SPACE:
         case RES_UL_SPACE:
         case RES_RTL_GUTTER:
-            rInvFlags |= 0x0B;
+            rInvFlags |= static_cast<SwFrameInvFlags>(0x0B);
             break;
 
         case RES_HEADER_FOOTER_EAT_SPACING:
-            rInvFlags |= 0x03;
+            rInvFlags |= static_cast<SwFrameInvFlags>(0x03);
             break;
 
         case RES_BACKGROUND:
         case RES_BACKGROUND_FULL_SIZE:
-            rInvFlags |= 0x28;
+            rInvFlags |= static_cast<SwFrameInvFlags>(0x28);
             break;
 
         case RES_KEEP:
-            rInvFlags |= 0x04;
+            rInvFlags |= static_cast<SwFrameInvFlags>(0x04);
             break;
 
         case RES_FRM_SIZE:
             ReinitializeFrameSizeAttrFlags();
-            rInvFlags |= 0x13;
+            rInvFlags |= static_cast<SwFrameInvFlags>(0x13);
             break;
 
         case RES_FMT_CHG:
-            rInvFlags |= 0x0F;
+            rInvFlags |= static_cast<SwFrameInvFlags>(0x0F);
             break;
 
         case RES_ROW_SPLIT:
@@ -585,7 +586,7 @@ void SwFrame::UpdateAttrFrame( const SfxPoolItem *pOld, const SfxPoolItem *pNew,
             // the new FillStyle has to do the same as previous RES_BACKGROUND
             if(nWhich >= XATTR_FILL_FIRST && nWhich <= XATTR_FILL_LAST)
             {
-                rInvFlags |= 0x28;
+                rInvFlags |= static_cast<SwFrameInvFlags>(0x28);
             }
             /* do Nothing */;
     }


More information about the Libreoffice-commits mailing list