Kaydet (Commit) a0f99670 authored tarafından Noel Grandin's avatar Noel Grandin

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: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 1b95eb30
...@@ -44,86 +44,56 @@ class SwPageNumAndTypeOfAnchors ...@@ -44,86 +44,56 @@ class SwPageNumAndTypeOfAnchors
bool mbAnchoredAtMaster; bool mbAnchoredAtMaster;
}; };
std::vector< tEntry* > maObjList; std::vector< tEntry > maObjList;
public: public:
SwPageNumAndTypeOfAnchors() SwPageNumAndTypeOfAnchors()
{ {
} }
~SwPageNumAndTypeOfAnchors()
{
for ( std::vector< tEntry* >::iterator aIter = maObjList.begin();
aIter != maObjList.end(); ++aIter )
{
delete *aIter;
}
maObjList.clear();
}
void Collect( SwAnchoredObject& _rAnchoredObj ) void Collect( SwAnchoredObject& _rAnchoredObj )
{ {
tEntry* pNewEntry = new tEntry; tEntry aNewEntry;
pNewEntry->mpAnchoredObj = &_rAnchoredObj; aNewEntry.mpAnchoredObj = &_rAnchoredObj;
// #i33751#, #i34060# - method <GetPageFrameOfAnchor()> // #i33751#, #i34060# - method <GetPageFrameOfAnchor()>
// is replaced by method <FindPageFrameOfAnchor()>. It's return value // is replaced by method <FindPageFrameOfAnchor()>. It's return value
// have to be checked. // have to be checked.
SwPageFrame* pPageFrameOfAnchor = _rAnchoredObj.FindPageFrameOfAnchor(); SwPageFrame* pPageFrameOfAnchor = _rAnchoredObj.FindPageFrameOfAnchor();
if ( pPageFrameOfAnchor ) if ( pPageFrameOfAnchor )
{ {
pNewEntry->mnPageNumOfAnchor = pPageFrameOfAnchor->GetPhyPageNum(); aNewEntry.mnPageNumOfAnchor = pPageFrameOfAnchor->GetPhyPageNum();
} }
else else
{ {
pNewEntry->mnPageNumOfAnchor = 0; aNewEntry.mnPageNumOfAnchor = 0;
} }
// --> #i26945# - collect type of anchor // --> #i26945# - collect type of anchor
SwTextFrame* pAnchorCharFrame = _rAnchoredObj.FindAnchorCharFrame(); SwTextFrame* pAnchorCharFrame = _rAnchoredObj.FindAnchorCharFrame();
if ( pAnchorCharFrame ) if ( pAnchorCharFrame )
{ {
pNewEntry->mbAnchoredAtMaster = !pAnchorCharFrame->IsFollow(); aNewEntry.mbAnchoredAtMaster = !pAnchorCharFrame->IsFollow();
} }
else else
{ {
pNewEntry->mbAnchoredAtMaster = true; aNewEntry.mbAnchoredAtMaster = true;
} }
maObjList.push_back( pNewEntry ); maObjList.push_back( aNewEntry );
} }
SwAnchoredObject* operator[]( sal_uInt32 _nIndex ) SwAnchoredObject* operator[]( sal_uInt32 _nIndex )
{ {
SwAnchoredObject* bRetObj = nullptr; return maObjList[_nIndex].mpAnchoredObj;
if ( _nIndex < Count())
{
bRetObj = maObjList[_nIndex]->mpAnchoredObj;
}
return bRetObj;
} }
sal_uInt32 GetPageNum( sal_uInt32 _nIndex ) const sal_uInt32 GetPageNum( sal_uInt32 _nIndex ) const
{ {
sal_uInt32 nRetPgNum = 0; return maObjList[_nIndex].mnPageNumOfAnchor;
if ( _nIndex < Count())
{
nRetPgNum = maObjList[_nIndex]->mnPageNumOfAnchor;
}
return nRetPgNum;
} }
// --> #i26945# // --> #i26945#
bool AnchoredAtMaster( sal_uInt32 _nIndex ) bool AnchoredAtMaster( sal_uInt32 _nIndex )
{ {
bool bAnchoredAtMaster( true ); return maObjList[_nIndex].mbAnchoredAtMaster;
if ( _nIndex < Count())
{
bAnchoredAtMaster = maObjList[_nIndex]->mbAnchoredAtMaster;
}
return bAnchoredAtMaster;
} }
sal_uInt32 Count() const sal_uInt32 Count() const
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment