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

Bjoern Michaelsen (via logerrit) logerrit at kemper.freedesktop.org
Thu Dec 10 08:26:32 UTC 2020


 sw/source/core/inc/flyfrms.hxx     |    8 +---
 sw/source/core/layout/flyincnt.cxx |   67 +++++++++++++++++++------------------
 2 files changed, 39 insertions(+), 36 deletions(-)

New commits:
commit 4d6f00a097e68715c63c3388b1183bf08fa8cdbb
Author:     Bjoern Michaelsen <bjoern.michaelsen at libreoffice.org>
AuthorDate: Thu Dec 10 00:09:32 2020 +0100
Commit:     Bjoern Michaelsen <bjoern.michaelsen at libreoffice.org>
CommitDate: Thu Dec 10 09:25:47 2020 +0100

    flyincnt: Modify no more
    
    Change-Id: I1500f5944a5a9504ef8c9c48c2d43da710de3fa4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107512
    Tested-by: Jenkins
    Reviewed-by: Bjoern Michaelsen <bjoern.michaelsen at libreoffice.org>

diff --git a/sw/source/core/inc/flyfrms.hxx b/sw/source/core/inc/flyfrms.hxx
index 160ca2bb85ca..a401e4abf0af 100644
--- a/sw/source/core/inc/flyfrms.hxx
+++ b/sw/source/core/inc/flyfrms.hxx
@@ -191,18 +191,16 @@ public:
 };
 
 // Flys that are bound to a character in Content
-class SwFlyInContentFrame : public SwFlyFrame
+class SwFlyInContentFrame final: public SwFlyFrame
 {
     Point m_aRef;  // relative to this point AbsPos is being calculated
 
     virtual void DestroyImpl() override;
     virtual ~SwFlyInContentFrame() override;
 
-protected:
-    virtual void NotifyBackground( SwPageFrame *pPage,
-                                   const SwRect& rRect, PrepareHint eHint) override;
+    virtual void NotifyBackground(SwPageFrame *pPage, const SwRect& rRect, PrepareHint eHint) override;
     virtual void MakeAll(vcl::RenderContext* pRenderContext) override;
-    virtual void  Modify( const SfxPoolItem*, const SfxPoolItem* ) override;
+    virtual void SwClientNotify(const SwModify&, const SfxHint&) override;
 
 public:
     // #i28701#
diff --git a/sw/source/core/layout/flyincnt.cxx b/sw/source/core/layout/flyincnt.cxx
index daeaaf314f17..be7b5722a593 100644
--- a/sw/source/core/layout/flyincnt.cxx
+++ b/sw/source/core/layout/flyincnt.cxx
@@ -90,45 +90,50 @@ void SwFlyInContentFrame::SetRefPoint( const Point& rPoint,
     }
 }
 
-void SwFlyInContentFrame::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew )
+void SwFlyInContentFrame::SwClientNotify(const SwModify&, const SfxHint& rHint)
 {
-    bool bCallPrepare = false;
-    const sal_uInt16 nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0;
-    if (RES_ATTRSET_CHG == nWhich && pNew)
+    auto pLegacy = dynamic_cast<const sw::LegacyModifyHint*>(&rHint);
+    if(!pLegacy)
+        return;
+    std::pair<std::unique_ptr<SwAttrSetChg>, std::unique_ptr<SwAttrSetChg>> aTweakedChgs;
+    std::pair<const SfxPoolItem*, const SfxPoolItem*> aSuperArgs(nullptr, nullptr);
+    switch(pLegacy->GetWhich())
     {
-        if(pOld &&
-            (SfxItemState::SET == static_cast<const SwAttrSetChg*>(pNew)->GetChgSet()->
-            GetItemState(RES_SURROUND, false) ||
-            SfxItemState::SET == static_cast<const SwAttrSetChg*>(pNew)->GetChgSet()->
-            GetItemState(RES_FRMMACRO, false)) )
+        case RES_ATTRSET_CHG:
         {
-            SwAttrSetChg aOld( *static_cast<const SwAttrSetChg*>(pOld) );
-            SwAttrSetChg aNew( *static_cast<const SwAttrSetChg*>(pNew) );
-
-            aOld.ClearItem( RES_SURROUND );
-            aNew.ClearItem( RES_SURROUND );
-            aOld.ClearItem( RES_FRMMACRO );
-            aNew.ClearItem( RES_FRMMACRO );
-            if( aNew.Count() )
+            auto pOldAttrSetChg = static_cast<const SwAttrSetChg*>(pLegacy->m_pOld);
+            auto pNewAttrSetChg = static_cast<const SwAttrSetChg*>(pLegacy->m_pNew);
+            if(pOldAttrSetChg
+                    && pNewAttrSetChg
+                    && ((SfxItemState::SET == pNewAttrSetChg->GetChgSet()->GetItemState(RES_SURROUND, false))
+                    || (SfxItemState::SET == pNewAttrSetChg->GetChgSet()->GetItemState(RES_FRMMACRO, false))))
             {
-                SwFlyFrame::Modify( &aOld, &aNew );
-                bCallPrepare = true;
-            }
-        }
-        else if( static_cast<const SwAttrSetChg*>(pNew)->GetChgSet()->Count())
-        {
-            SwFlyFrame::Modify( pOld, pNew );
-            bCallPrepare = true;
+                aTweakedChgs.second = std::make_unique<SwAttrSetChg>(*pOldAttrSetChg);
+                aTweakedChgs.second->ClearItem(RES_SURROUND);
+                aTweakedChgs.second->ClearItem(RES_FRMMACRO);
+                if(aTweakedChgs.second->Count())
+                {
+                    aTweakedChgs.first = std::make_unique<SwAttrSetChg>(*pOldAttrSetChg);
+                    aTweakedChgs.first->ClearItem(RES_SURROUND);
+                    aTweakedChgs.first->ClearItem(RES_FRMMACRO);
+                    aSuperArgs = std::pair<const SfxPoolItem*, const SfxPoolItem*>(aTweakedChgs.first.get(), aTweakedChgs.second.get());
+                }
+            } else if(pNewAttrSetChg->GetChgSet()->Count())
+                aSuperArgs = std::pair<const SfxPoolItem*, const SfxPoolItem*>(pLegacy->m_pOld, pLegacy->m_pNew);
+            break;
         }
+        case RES_SURROUND:
+        case RES_FRMMACRO:
+            break;
+        default:
+            aSuperArgs = std::pair<const SfxPoolItem*, const SfxPoolItem*>(pLegacy->m_pOld, pLegacy->m_pNew);
     }
-    else if( nWhich != RES_SURROUND && RES_FRMMACRO != nWhich )
+    if(aSuperArgs.second)
     {
-        SwFlyFrame::Modify( pOld, pNew );
-        bCallPrepare = true;
+        SwFlyFrame::Modify(aSuperArgs.first, aSuperArgs.second);
+        if(GetAnchorFrame())
+            AnchorFrame()->Prepare(PrepareHint::FlyFrameAttributesChanged, GetFormat());
     }
-
-    if ( bCallPrepare && GetAnchorFrame() )
-        AnchorFrame()->Prepare( PrepareHint::FlyFrameAttributesChanged, GetFormat() );
 }
 
 /// Here the content gets formatted initially.


More information about the Libreoffice-commits mailing list