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

loplugin:useuniqueptr in SvxIconChoiceCtrl_Impl

Change-Id: I5bd4fb6b4942cea02168a8a92682fa215deae8cf
Reviewed-on: https://gerrit.libreoffice.org/64878
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 1cd32bcf
......@@ -97,45 +97,6 @@ struct LocalFocus
};
// Entry-List
class EntryList_Impl
{
private:
std::vector< SvxIconChoiceCtrlEntry* > maIconChoiceCtrlEntryList;
SvxIconChoiceCtrl_Impl* _pOwner;
public:
explicit EntryList_Impl( SvxIconChoiceCtrl_Impl* );
~EntryList_Impl();
void clear();
size_t size()
{
return maIconChoiceCtrlEntryList.size();
}
size_t size() const
{
return maIconChoiceCtrlEntryList.size();
}
SvxIconChoiceCtrlEntry* operator[]( size_t nPos )
{
return ( nPos < maIconChoiceCtrlEntryList.size() )
? maIconChoiceCtrlEntryList[ nPos ]
: nullptr;
}
SvxIconChoiceCtrlEntry* operator[]( size_t nPos ) const
{
return ( nPos < maIconChoiceCtrlEntryList.size() )
? maIconChoiceCtrlEntryList[ nPos ]
: nullptr;
}
void insert( size_t nPos, SvxIconChoiceCtrlEntry* pEntry );
};
// Implementation-class of IconChoiceCtrl
......@@ -145,11 +106,10 @@ typedef std::vector<SvxIconChoiceCtrlEntry*> SvxIconChoiceCtrlEntryPtrVec;
class SvxIconChoiceCtrl_Impl
{
friend class IcnCursor_Impl;
friend class EntryList_Impl;
friend class IcnGridMap_Impl;
bool bChooseWithCursor;
EntryList_Impl aEntries;
std::vector< std::unique_ptr<SvxIconChoiceCtrlEntry> > maEntries;
VclPtr<ScrollBar> aVerSBar;
VclPtr<ScrollBar> aHorSBar;
VclPtr<ScrollBarBox> aScrBarBox;
......@@ -177,7 +137,7 @@ class SvxIconChoiceCtrl_Impl
ImplSVEvent * nUserEventAdjustScrBars;
SvxIconChoiceCtrlEntry* pCurHighlightFrame;
bool bHighlightFramePressed;
SvxIconChoiceCtrlEntry* pHead; // top left entry
SvxIconChoiceCtrlEntry* pHead = nullptr; // top left entry
SvxIconChoiceCtrlEntry* pCursor;
SvxIconChoiceCtrlEntry* pHdlEntry;
VclPtr<VirtualDevice> pDDDev;
......@@ -302,7 +262,7 @@ public:
void Clear( bool bInCtor );
void SetStyle( WinBits nWinStyle );
WinBits GetStyle() const { return nWinBits; }
void InsertEntry( SvxIconChoiceCtrlEntry*, size_t nPos );
void InsertEntry( std::unique_ptr<SvxIconChoiceCtrlEntry>, size_t nPos );
void CreateAutoMnemonics( MnemonicGenerator* _pGenerator );
void FontModified();
void SelectAll();
......@@ -421,14 +381,14 @@ public:
SvxIconChoiceCtrlEntry* pEntry
);
#endif
size_t GetEntryCount() const { return aEntries.size(); }
size_t GetEntryCount() const { return maEntries.size(); }
SvxIconChoiceCtrlEntry* GetEntry( size_t nPos )
{
return aEntries[ nPos ];
return maEntries[ nPos ].get();
}
SvxIconChoiceCtrlEntry* GetEntry( size_t nPos ) const
{
return aEntries[ nPos ];
return maEntries[ nPos ].get();
}
SvxIconChoiceCtrlEntry* GetFirstSelectedEntry() const;
void SetSelectionMode( SelectionMode eMode ) { eSelectionMode=eMode; }
......
......@@ -70,10 +70,10 @@ void IcnCursor_Impl::ImplCreate()
xColumns.reset(new IconChoiceMap);
xRows.reset(new IconChoiceMap);
size_t nCount = pView->aEntries.size();
size_t nCount = pView->maEntries.size();
for( size_t nCur = 0; nCur < nCount; nCur++ )
{
SvxIconChoiceCtrlEntry* pEntry = pView->aEntries[ nCur ];
SvxIconChoiceCtrlEntry* pEntry = pView->maEntries[ nCur ].get();
// const Rectangle& rRect = pView->GetEntryBoundRect( pEntry );
tools::Rectangle rRect( pView->CalcBmpRect( pEntry ) );
short nY = static_cast<short>( ((rRect.Top()+rRect.Bottom())/2) / nDeltaHeight );
......@@ -341,8 +341,8 @@ SvxIconChoiceCtrlEntry* IcnCursor_Impl::GoPageUpDown( SvxIconChoiceCtrlEntry* pS
if( bDown )
{
nNewPos += nEntriesInView;
if( nNewPos >= static_cast<long>(pView->aEntries.size()) )
nNewPos = pView->aEntries.size() - 1;
if( nNewPos >= static_cast<long>(pView->maEntries.size()) )
nNewPos = pView->maEntries.size() - 1;
}
else
{
......@@ -351,7 +351,7 @@ SvxIconChoiceCtrlEntry* IcnCursor_Impl::GoPageUpDown( SvxIconChoiceCtrlEntry* pS
nNewPos = 0;
}
if( nPos != nNewPos )
return pView->aEntries[ static_cast<size_t>(nNewPos) ];
return pView->maEntries[ static_cast<size_t>(nNewPos) ].get();
return nullptr;
}
long nOpt = pView->GetEntryBoundRect( pStart ).Top();
......@@ -394,10 +394,10 @@ SvxIconChoiceCtrlEntry* IcnCursor_Impl::GoUpDown( SvxIconChoiceCtrlEntry* pCtrlE
if( pView->IsAutoArrange() && !(pView->nWinBits & WB_ALIGN_TOP) )
{
sal_uLong nPos = pView->GetEntryListPos( pCtrlEntry );
if( bDown && nPos < (pView->aEntries.size() - 1) )
return pView->aEntries[ nPos + 1 ];
if( bDown && nPos < (pView->maEntries.size() - 1) )
return pView->maEntries[ nPos + 1 ].get();
else if( !bDown && nPos > 0 )
return pView->aEntries[ nPos - 1 ];
return pView->maEntries[ nPos - 1 ].get();
return nullptr;
}
......@@ -524,9 +524,9 @@ void IcnGridMap_Impl::Create_Impl()
_pGridMap.reset( new bool[nCellCount] );
memset(_pGridMap.get(), 0, nCellCount * sizeof(bool));
const size_t nCount = _pView->aEntries.size();
const size_t nCount = _pView->maEntries.size();
for( size_t nCur=0; nCur < nCount; nCur++ )
OccupyGrids( _pView->aEntries[ nCur ] );
OccupyGrids( _pView->maEntries[ nCur ].get() );
}
void IcnGridMap_Impl::GetMinMapSize( sal_uInt16& rDX, sal_uInt16& rDY ) const
......
......@@ -98,7 +98,7 @@ SvxIconChoiceCtrlEntry* SvtIconChoiceCtrl::InsertEntry( const OUString& rText, c
{
SvxIconChoiceCtrlEntry* pEntry = new SvxIconChoiceCtrlEntry( rText, rImage);
_pImpl->InsertEntry(pEntry, _pImpl->GetEntryCount());
_pImpl->InsertEntry(std::unique_ptr<SvxIconChoiceCtrlEntry>(pEntry), _pImpl->GetEntryCount());
return pEntry;
}
......
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