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

Bjoern Michaelsen bjoern.michaelsen at canonical.com
Tue Feb 14 15:44:49 UTC 2017


 sw/inc/frmfmt.hxx                   |   14 +++++++++-----
 sw/source/core/draw/dcontact.cxx    |   11 -----------
 sw/source/core/layout/atrfrm.cxx    |   16 ++++++++++++++--
 sw/source/core/layout/fly.cxx       |   19 +++++++------------
 sw/source/core/unocore/unoframe.cxx |   19 ++++++++-----------
 sw/source/filter/ww8/ww8graf.cxx    |   17 ++++++++---------
 6 files changed, 46 insertions(+), 50 deletions(-)

New commits:
commit 837545feb63f31095d69d006aeda520637c3bc8c
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Sat Feb 11 05:03:07 2017 +0100

    DYING_FLYFRAMEFORMAT not needed anymore
    
    Change-Id: Id9ded246752903f692c0f8254a258fada299d9bf
    Reviewed-on: https://gerrit.libreoffice.org/34142
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Björn Michaelsen <bjoern.michaelsen at canonical.com>

diff --git a/sw/inc/frmfmt.hxx b/sw/inc/frmfmt.hxx
index 6daa2ad..9d40d96 100644
--- a/sw/inc/frmfmt.hxx
+++ b/sw/inc/frmfmt.hxx
@@ -262,7 +262,6 @@ namespace sw
 {
     enum class DrawFrameFormatHintId {
         DYING,
-        DYING_FLYFRAMEFORMAT, /* possibly can be merged with DYING, if all client handle it and handle it the same */
         PREPPASTING,
         PREP_INSERT_FLY,
         PREP_DELETE_FLY,
diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx
index b0e2e9a..9a4c78e 100644
--- a/sw/source/core/draw/dcontact.cxx
+++ b/sw/source/core/draw/dcontact.cxx
@@ -594,17 +594,6 @@ void SwFlyDrawContact::SwClientNotify(const SwModify& rMod, const SfxHint& rHint
     {
         pKillDrawHint->m_rpContact = this;
     }
-    else if (auto pDrawFrameFormatHint = dynamic_cast<const sw::DrawFrameFormatHint*>(&rHint))
-    {
-        switch(pDrawFrameFormatHint->m_eId)
-        {
-            case sw::DrawFrameFormatHintId::DYING_FLYFRAMEFORMAT:
-                dynamic_cast<SwFlyFrameFormat*>(const_cast<SwModify*>(&rMod))->ClearContact();
-                break;
-            default:
-                ;
-        }
-    }
 }
 
 // SwDrawContact
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index aff63bd..01c5923 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -2889,8 +2889,6 @@ SwFlyFrameFormat::~SwFlyFrameFormat()
         {
             SwFrame::DestroyFrame(pLast);
         } while( nullptr != ( pLast = aIter.Next() ));
-
-    CallSwClientNotify(sw::DrawFrameFormatHint(sw::DrawFrameFormatHintId::DYING_FLYFRAMEFORMAT));
 }
 
 /// Creates the Frames if the format describes a paragraph-bound frame.
commit 4ae93f7d3b063d13ff757884444a468212227ef9
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Sat Feb 11 02:43:52 2017 +0100

    give SwFlyDrawContact a clear owner: SwFlyFrameFormat
    
    Change-Id: Ida24ef9ae65ae8658645496369673d886e0935cc
    Reviewed-on: https://gerrit.libreoffice.org/34141
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Björn Michaelsen <bjoern.michaelsen at canonical.com>

diff --git a/sw/inc/frmfmt.hxx b/sw/inc/frmfmt.hxx
index b55ca5d..6daa2ad 100644
--- a/sw/inc/frmfmt.hxx
+++ b/sw/inc/frmfmt.hxx
@@ -174,11 +174,15 @@ public:
 
 // The FlyFrame-Format
 
+class SdrModel;
+class SwFlyDrawContact;
+
 class SW_DLLPUBLIC SwFlyFrameFormat: public SwFrameFormat
 {
     friend class SwDoc;
     OUString msTitle;
     OUString msDesc;
+    std::unique_ptr<SwFlyDrawContact> m_pContact;
 
     /** Both not existent.
        it stores the previous position of Prt rectangle from RequestObjectResize
@@ -190,12 +194,13 @@ class SW_DLLPUBLIC SwFlyFrameFormat: public SwFrameFormat
     SwFlyFrameFormat &operator=( const SwFlyFrameFormat &rCpy ) = delete;
 
 protected:
-    SwFlyFrameFormat( SwAttrPool& rPool, const OUString &rFormatNm,
-                    SwFrameFormat *pDrvdFrame )
-        : SwFrameFormat( rPool, rFormatNm, pDrvdFrame, RES_FLYFRMFMT )
-    {}
+    SwFlyFrameFormat(SwAttrPool& rPool, const OUString& rFormatNm, SwFrameFormat* pDrvdFrame);
 
 public:
+    SwFlyDrawContact* GetContact()
+        { return m_pContact.get(); };
+    void InitContact(SdrModel* pSdrModel);
+    void ClearContact();
     virtual ~SwFlyFrameFormat() override;
 
     /// Creates the views.
diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx
index 6d2c08b..b0e2e9a 100644
--- a/sw/source/core/draw/dcontact.cxx
+++ b/sw/source/core/draw/dcontact.cxx
@@ -599,7 +599,7 @@ void SwFlyDrawContact::SwClientNotify(const SwModify& rMod, const SfxHint& rHint
         switch(pDrawFrameFormatHint->m_eId)
         {
             case sw::DrawFrameFormatHintId::DYING_FLYFRAMEFORMAT:
-                delete this;
+                dynamic_cast<SwFlyFrameFormat*>(const_cast<SwModify*>(&rMod))->ClearContact();
                 break;
             default:
                 ;
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index 1b420b7..aff63bd 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -2866,6 +2866,20 @@ void SwFrameFormats::dumpAsXml(xmlTextWriterPtr pWriter, const char* pName) cons
 
 IMPL_FIXEDMEMPOOL_NEWDEL( SwFlyFrameFormat )
 
+SwFlyFrameFormat::SwFlyFrameFormat(SwAttrPool& rPool, const OUString& rFormatNm, SwFrameFormat* pDrvdFrame)
+    : SwFrameFormat(rPool, rFormatNm, pDrvdFrame, RES_FLYFRMFMT)
+    , m_pContact(nullptr)
+{}
+
+void SwFlyFrameFormat::InitContact(SdrModel* pSdrModel)
+{
+    m_pContact = std::unique_ptr<SwFlyDrawContact>(new SwFlyDrawContact(this, pSdrModel));
+}
+void SwFlyFrameFormat::ClearContact()
+{
+    m_pContact.reset(nullptr);
+}
+
 SwFlyFrameFormat::~SwFlyFrameFormat()
 {
     SwIterator<SwFlyFrame,SwFormat> aIter( *this );
diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx
index 55f1ac2..6e8cf94 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -397,25 +397,21 @@ void SwFlyFrame::InitDrawObj()
     // need to create a new Ref, else we create the Contact now.
 
     IDocumentDrawModelAccess& rIDDMA = GetFormat()->getIDocumentDrawModelAccess();
-    SwFlyDrawContact *pContact = SwIterator<SwFlyDrawContact,SwFormat>( *GetFormat() ).First();
-    if ( !pContact )
+    if(!GetFormat()->GetContact())
     {
         // #i52858# - method name changed
-        pContact = new SwFlyDrawContact( GetFormat(),
-                                          rIDDMA.GetOrCreateDrawModel() );
+        GetFormat()->InitContact(rIDDMA.GetOrCreateDrawModel());
     }
-    OSL_ENSURE( pContact, "InitDrawObj failed" );
+    OSL_ENSURE(GetFormat()->GetContact(), "InitDrawObj failed");
     // OD 2004-03-22 #i26791#
-    SetDrawObj( *(CreateNewRef( pContact )) );
+    SetDrawObj( *(CreateNewRef( GetFormat()->GetContact() )) );
 
     // Set the right Layer
     // OD 2004-01-19 #110582#
-    SdrLayerID nHeavenId = rIDDMA.GetHeavenId();
-    SdrLayerID nHellId = rIDDMA.GetHellId();
     // OD 2004-03-22 #i26791#
-    GetVirtDrawObj()->SetLayer( GetFormat()->GetOpaque().GetValue()
-                                ? nHeavenId
-                                : nHellId );
+    GetVirtDrawObj()->SetLayer(GetFormat()->GetOpaque().GetValue()
+        ? rIDDMA.GetHeavenId()
+        : rIDDMA.GetHellId());
 }
 
 void SwFlyFrame::FinitDrawObj()
@@ -459,7 +455,6 @@ void SwFlyFrame::FinitDrawObj()
         pContact->GetMaster()->SetUserCall(nullptr);
     GetVirtDrawObj()->SetUserCall(nullptr); // Else calls delete of the ContactObj
     delete GetVirtDrawObj();            // Deregisters itself at the Master
-    delete pContact;                  // Destroys the Master itself
 }
 
 void SwFlyFrame::ChainFrames( SwFlyFrame *pMaster, SwFlyFrame *pFollow )
diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx
index 4101171..580522e 100644
--- a/sw/source/core/unocore/unoframe.cxx
+++ b/sw/source/core/unocore/unoframe.cxx
@@ -1360,23 +1360,20 @@ void SwXFrame::SetSelection(SwPaM& rCopySource)
 SdrObject *SwXFrame::GetOrCreateSdrObject(SwFlyFrameFormat &rFormat)
 {
     SdrObject* pObject = rFormat.FindSdrObject();
-    if( !pObject )
+    if(!pObject)
     {
-        SwDoc *pDoc = rFormat.GetDoc();
+        SwDoc* pDoc = rFormat.GetDoc();
         // #i52858# - method name changed
         SwDrawModel* pDrawModel = pDoc->getIDocumentDrawModelAccess().GetOrCreateDrawModel();
-        SwFlyDrawContact* pContactObject
-                    = new SwFlyDrawContact( &rFormat, pDrawModel );
-        pObject = pContactObject->GetMaster();
+        rFormat.InitContact(pDrawModel);
+        pObject = rFormat.GetContact()->GetMaster();
 
         const ::SwFormatSurround& rSurround = rFormat.GetSurround();
-        pObject->SetLayer(
-            ( SURROUND_THROUGHT == rSurround.GetSurround() &&
-              !rFormat.GetOpaque().GetValue() ) ? pDoc->getIDocumentDrawModelAccess().GetHellId()
-                                             : pDoc->getIDocumentDrawModelAccess().GetHeavenId() );
-        pDrawModel->GetPage(0)->InsertObject( pObject );
+        pObject->SetLayer((SURROUND_THROUGHT == rSurround.GetSurround() && !rFormat.GetOpaque().GetValue())
+                ? pDoc->getIDocumentDrawModelAccess().GetHellId()
+                : pDoc->getIDocumentDrawModelAccess().GetHeavenId());
+        pDrawModel->GetPage(0)->InsertObject(pObject);
     }
-
     return pObject;
 }
 
diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx
index 3bd7449..279960f 100644
--- a/sw/source/filter/ww8/ww8graf.cxx
+++ b/sw/source/filter/ww8/ww8graf.cxx
@@ -2131,19 +2131,18 @@ SwWW8ImplReader::SetAttributesAtGrfNode(SvxMSDffImportRec const*const pRecord,
     }
 }
 
-SdrObject* SwWW8ImplReader::CreateContactObject(SwFrameFormat* pFlyFormat)
+SdrObject* SwWW8ImplReader::CreateContactObject(SwFrameFormat* pFormat)
 {
-    if (pFlyFormat)
+    if(pFormat)
     {
-        SdrObject* pNewObject = m_bNewDoc ? nullptr : pFlyFormat->FindRealSdrObject();
+        SdrObject* pNewObject = m_bNewDoc ? nullptr : pFormat->FindRealSdrObject();
         if (!pNewObject)
-            pNewObject = pFlyFormat->FindSdrObject();
-        if (!pNewObject && dynamic_cast< const SwFlyFrameFormat *>( pFlyFormat ) !=  nullptr)
+            pNewObject = pFormat->FindSdrObject();
+        SwFlyFrameFormat* pFlyFormat(nullptr);
+        if (!pNewObject && (pFlyFormat = dynamic_cast<SwFlyFrameFormat*>(pFormat)))
         {
-            SwFlyDrawContact* pContactObject
-                = new SwFlyDrawContact(static_cast<SwFlyFrameFormat*>(pFlyFormat),
-                m_pDrawModel);
-            pNewObject = pContactObject->GetMaster();
+            pFlyFormat->InitContact(m_pDrawModel);
+            pNewObject = pFlyFormat->GetContact()->GetMaster();
         }
         return pNewObject;
     }


More information about the Libreoffice-commits mailing list