sw/source/core/layout/objectformatter.cxx |   52 ++++++------------------------
 1 file changed, 11 insertions(+), 41 deletions(-)

New commits:
commit a0f996703ec37c1403eeda27144bebfa1986aea5
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Thu Aug 16 11:38:54 2018 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Fri Aug 17 08:23:16 2018 +0200

    loplugin:useuniqueptr in SwPageNumAndTypeOfAnchors
    
    it's a small struct, so just store it inline in the std::vector
    
    Change-Id: Ib53c903bf960097ea395e7d54ea7b80fa027ea7b
    Reviewed-on: https://gerrit.libreoffice.org/59227
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sw/source/core/layout/objectformatter.cxx 
b/sw/source/core/layout/objectformatter.cxx
index a0621956e730..892ac6a99693 100644
--- a/sw/source/core/layout/objectformatter.cxx
+++ b/sw/source/core/layout/objectformatter.cxx
@@ -44,86 +44,56 @@ class SwPageNumAndTypeOfAnchors
             bool mbAnchoredAtMaster;
         };
 
-        std::vector< tEntry* > maObjList;
+        std::vector< tEntry > maObjList;
 
     public:
         SwPageNumAndTypeOfAnchors()
         {
         }
-        ~SwPageNumAndTypeOfAnchors()
-        {
-            for ( std::vector< tEntry* >::iterator aIter = maObjList.begin();
-                  aIter != maObjList.end(); ++aIter )
-            {
-                delete *aIter;
-            }
-            maObjList.clear();
-        }
 
         void Collect( SwAnchoredObject& _rAnchoredObj )
         {
-            tEntry* pNewEntry = new tEntry;
-            pNewEntry->mpAnchoredObj = &_rAnchoredObj;
+            tEntry aNewEntry;
+            aNewEntry.mpAnchoredObj = &_rAnchoredObj;
             // #i33751#, #i34060# - method <GetPageFrameOfAnchor()>
             // is replaced by method <FindPageFrameOfAnchor()>. It's return 
value
             // have to be checked.
             SwPageFrame* pPageFrameOfAnchor = 
_rAnchoredObj.FindPageFrameOfAnchor();
             if ( pPageFrameOfAnchor )
             {
-                pNewEntry->mnPageNumOfAnchor = 
pPageFrameOfAnchor->GetPhyPageNum();
+                aNewEntry.mnPageNumOfAnchor = 
pPageFrameOfAnchor->GetPhyPageNum();
             }
             else
             {
-                pNewEntry->mnPageNumOfAnchor = 0;
+                aNewEntry.mnPageNumOfAnchor = 0;
             }
             // --> #i26945# - collect type of anchor
             SwTextFrame* pAnchorCharFrame = 
_rAnchoredObj.FindAnchorCharFrame();
             if ( pAnchorCharFrame )
             {
-                pNewEntry->mbAnchoredAtMaster = !pAnchorCharFrame->IsFollow();
+                aNewEntry.mbAnchoredAtMaster = !pAnchorCharFrame->IsFollow();
             }
             else
             {
-                pNewEntry->mbAnchoredAtMaster = true;
+                aNewEntry.mbAnchoredAtMaster = true;
             }
-            maObjList.push_back( pNewEntry );
+            maObjList.push_back( aNewEntry );
         }
 
         SwAnchoredObject* operator[]( sal_uInt32 _nIndex )
         {
-            SwAnchoredObject* bRetObj = nullptr;
-
-            if ( _nIndex < Count())
-            {
-                bRetObj = maObjList[_nIndex]->mpAnchoredObj;
-            }
-
-            return bRetObj;
+            return maObjList[_nIndex].mpAnchoredObj;
         }
 
         sal_uInt32 GetPageNum( sal_uInt32 _nIndex ) const
         {
-            sal_uInt32 nRetPgNum = 0;
-
-            if ( _nIndex < Count())
-            {
-                nRetPgNum = maObjList[_nIndex]->mnPageNumOfAnchor;
-            }
-
-            return nRetPgNum;
+            return maObjList[_nIndex].mnPageNumOfAnchor;
         }
 
         // --> #i26945#
         bool AnchoredAtMaster( sal_uInt32 _nIndex )
         {
-            bool bAnchoredAtMaster( true );
-
-            if ( _nIndex < Count())
-            {
-                bAnchoredAtMaster = maObjList[_nIndex]->mbAnchoredAtMaster;
-            }
-
-            return bAnchoredAtMaster;
+            return maObjList[_nIndex].mbAnchoredAtMaster;
         }
 
         sal_uInt32 Count() const
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to