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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Jan 18 12:13:24 UTC 2019


 filter/source/msfilter/msdffimp.cxx  |   10 +++++-----
 include/filter/msfilter/msdffimp.hxx |    2 +-
 sw/source/filter/ww8/ww8par.cxx      |   13 +++++++------
 3 files changed, 13 insertions(+), 12 deletions(-)

New commits:
commit caa25f8e5f39e95fec1b32e352c841a6c0bf2fb3
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Thu Jan 17 15:51:51 2019 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Jan 18 13:12:55 2019 +0100

    pass SvxMSDffImportRec around using unique_ptr
    
    Change-Id: Ib2a93682f6d2745489e07cf04e3509146213c7ee
    Reviewed-on: https://gerrit.libreoffice.org/66571
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx
index 06deedf59392..e9e6cbfe2f24 100644
--- a/filter/source/msfilter/msdffimp.cxx
+++ b/filter/source/msfilter/msdffimp.cxx
@@ -5056,10 +5056,10 @@ SvxMSDffImportRec* SvxMSDffImportData::find(const SdrObject* pObj)
     return nullptr;
 }
 
-void SvxMSDffImportData::insert(SvxMSDffImportRec* pImpRec)
+void SvxMSDffImportData::insert(std::unique_ptr<SvxMSDffImportRec> pImpRec)
 {
-    m_ObjToRecMap[pImpRec->pObj] = pImpRec;
-    m_Records.insert(std::unique_ptr<SvxMSDffImportRec>(pImpRec));
+    m_ObjToRecMap[pImpRec->pObj] = pImpRec.get();
+    m_Records.insert(std::move(pImpRec));
 }
 
 void SvxMSDffImportData::NotifyFreeObj(SdrObject* pObj)
@@ -5576,7 +5576,7 @@ SdrObject* SvxMSDffManager::ProcessObj(SvStream& rSt,
             if( pOrgObj )
             {
                 pImpRec->pObj = pOrgObj;
-                rImportData.insert(pImpRec);
+                rImportData.insert(std::unique_ptr<SvxMSDffImportRec>(pImpRec));
                 bDeleteImpRec = false;
                 if (pImpRec == pTextImpRec)
                     bDeleteTextImpRec = false;
@@ -5587,7 +5587,7 @@ SdrObject* SvxMSDffManager::ProcessObj(SvStream& rSt,
                 // Modify ShapeId (must be unique)
                 pImpRec->nShapeId |= 0x8000000;
                 pTextImpRec->pObj = pTextObj;
-                rImportData.insert(pTextImpRec);
+                rImportData.insert(std::unique_ptr<SvxMSDffImportRec>(pTextImpRec));
                 bDeleteTextImpRec = false;
                 if (pTextImpRec == pImpRec)
                     bDeleteImpRec = false;
diff --git a/include/filter/msfilter/msdffimp.hxx b/include/filter/msfilter/msdffimp.hxx
index 4ff14484e398..f27956c0d7ef 100644
--- a/include/filter/msfilter/msdffimp.hxx
+++ b/include/filter/msfilter/msdffimp.hxx
@@ -289,7 +289,7 @@ public:
     SvxMSDffImportData( SvxMSDffImportData const & ) = delete; // MSVC2015 workaround
     virtual ~SvxMSDffImportData() override;
     bool empty() const { return m_Records.empty(); }
-    void insert(SvxMSDffImportRec* pImpRec);
+    void insert(std::unique_ptr<SvxMSDffImportRec> pImpRec);
     void unmap(const SdrObject* pObj) { m_ObjToRecMap.erase(pObj); }
     size_t size() const { return m_Records.size(); }
     SvxMSDffImportRec* find(const SdrObject* pObj);
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 18642cc06621..5b3010e90637 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -593,7 +593,7 @@ SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt,
     if( !rTextRect.IsEmpty() )
     {
         SvxMSDffImportData& rImportData = static_cast<SvxMSDffImportData&>(rData);
-        SvxMSDffImportRec* pImpRec = new SvxMSDffImportRec;
+        std::unique_ptr<SvxMSDffImportRec> pImpRec(new SvxMSDffImportRec);
 
         // fill Import Record with data
         pImpRec->nShapeId   = rObjData.nShapeId;
@@ -1066,9 +1066,10 @@ SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt,
 
         if( pImpRec->nShapeId )
         {
+            auto pImpRecTmp = pImpRec.get();
             // Complement Import Record List
             pImpRec->pObj = pObj;
-            rImportData.insert(pImpRec);
+            rImportData.insert(std::move(pImpRec));
 
             // Complement entry in Z Order List with a pointer to this Object
             // Only store objects which are not deep inside the tree
@@ -1077,12 +1078,12 @@ SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt,
                 ( (rObjData.nSpFlags & ShapeFlag::Group)
                  && (rObjData.nCalledByGroup < 2) )
               )
-                StoreShapeOrder( pImpRec->nShapeId,
-                                ( static_cast<sal_uLong>(pImpRec->aTextId.nTxBxS) << 16 )
-                                    + pImpRec->aTextId.nSequence, pObj );
+                StoreShapeOrder( pImpRecTmp->nShapeId,
+                                ( static_cast<sal_uLong>(pImpRecTmp->aTextId.nTxBxS) << 16 )
+                                    + pImpRecTmp->aTextId.nSequence, pObj );
         }
         else
-            delete pImpRec;
+            pImpRec.reset();
     }
 
     sal_uInt32 nBufferSize = GetPropertyValue( DFF_Prop_pihlShape, 0 );


More information about the Libreoffice-commits mailing list