diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-08-16 11:38:54 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-08-17 08:23:16 +0200 |
commit | a0f996703ec37c1403eeda27144bebfa1986aea5 (patch) | |
tree | 11f090b64bbc968727da93b2d3342f7d1ebcadac /sw | |
parent | 1b95eb30f6358a9ebdedee2888be8273120669c8 (diff) |
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.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/layout/objectformatter.cxx | 52 |
1 files changed, 11 insertions, 41 deletions
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 |