[Libreoffice-commits] core.git: basctl/source cui/source include/svtools svtools/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Tue Sep 25 12:28:48 UTC 2018
basctl/source/basicide/baside2b.cxx | 2 -
cui/source/options/fontsubs.cxx | 4 +--
cui/source/options/optfltr.cxx | 4 +--
cui/source/tabpages/autocdlg.cxx | 4 +--
include/svtools/treelistbox.hxx | 2 -
svtools/source/contnr/svimpbox.cxx | 6 ++---
svtools/source/contnr/treelistbox.cxx | 39 ++++++++++++++--------------------
7 files changed, 28 insertions(+), 33 deletions(-)
New commits:
commit add7d506b9ef9b799aefbbae1270642991b15668
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Mon Sep 17 15:58:34 2018 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Sep 25 14:28:26 2018 +0200
loplugin:useuniqueptr in SvImpLBox
Change-Id: I59aa026217ed250fab68afc4aa0086d4d1300eac
Reviewed-on: https://gerrit.libreoffice.org/60627
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx
index f2ccbc6e3812..4cbd2fe8c6b0 100644
--- a/basctl/source/basicide/baside2b.cxx
+++ b/basctl/source/basicide/baside2b.cxx
@@ -2096,7 +2096,7 @@ void WatchTreeListBox::SetTabs()
sal_uInt16 nTabCount_ = aTabs.size();
for( sal_uInt16 i = 0 ; i < nTabCount_ ; i++ )
{
- SvLBoxTab* pTab = aTabs[i];
+ SvLBoxTab* pTab = aTabs[i].get();
if( i == 2 )
pTab->nFlags |= SvLBoxTabFlags::EDITABLE;
else
diff --git a/cui/source/options/fontsubs.cxx b/cui/source/options/fontsubs.cxx
index ce5dd9668c30..228632262dfa 100644
--- a/cui/source/options/fontsubs.cxx
+++ b/cui/source/options/fontsubs.cxx
@@ -435,11 +435,11 @@ void SvxFontSubstCheckListBox::SetTabs()
SvSimpleTable::SetTabs();
SvLBoxTabFlags nAdjust = SvLBoxTabFlags::ADJUST_RIGHT|SvLBoxTabFlags::ADJUST_LEFT|SvLBoxTabFlags::ADJUST_CENTER|SvLBoxTabFlags::ADJUST_NUMERIC|SvLBoxTabFlags::FORCE;
- SvLBoxTab* pTab = aTabs[1];
+ SvLBoxTab* pTab = aTabs[1].get();
pTab->nFlags &= ~nAdjust;
pTab->nFlags |= SvLBoxTabFlags::PUSHABLE|SvLBoxTabFlags::ADJUST_CENTER|SvLBoxTabFlags::FORCE;
- pTab = aTabs[2];
+ pTab = aTabs[2].get();
pTab->nFlags &= ~nAdjust;
pTab->nFlags |= SvLBoxTabFlags::PUSHABLE|SvLBoxTabFlags::ADJUST_CENTER|SvLBoxTabFlags::FORCE;
}
diff --git a/cui/source/options/optfltr.cxx b/cui/source/options/optfltr.cxx
index 9ec7a56ed481..2e917cf10b4c 100644
--- a/cui/source/options/optfltr.cxx
+++ b/cui/source/options/optfltr.cxx
@@ -368,13 +368,13 @@ void OfaMSFilterTabPage2::MSFltrSimpleTable::SetTabs()
if( aTabs.size() > 1 )
{
- SvLBoxTab* pTab = aTabs[1];
+ SvLBoxTab* pTab = aTabs[1].get();
pTab->nFlags &= ~nAdjust;
pTab->nFlags |= SvLBoxTabFlags::PUSHABLE|SvLBoxTabFlags::ADJUST_CENTER|SvLBoxTabFlags::FORCE;
}
if( aTabs.size() > 2 )
{
- SvLBoxTab* pTab = aTabs[2];
+ SvLBoxTab* pTab = aTabs[2].get();
pTab->nFlags &= ~nAdjust;
pTab->nFlags |= SvLBoxTabFlags::PUSHABLE|SvLBoxTabFlags::ADJUST_CENTER|SvLBoxTabFlags::FORCE;
}
diff --git a/cui/source/tabpages/autocdlg.cxx b/cui/source/tabpages/autocdlg.cxx
index f221bb9da9e7..2fdb140df21c 100644
--- a/cui/source/tabpages/autocdlg.cxx
+++ b/cui/source/tabpages/autocdlg.cxx
@@ -761,13 +761,13 @@ void OfaACorrCheckListBox::SetTabs()
if( aTabs.size() > 1 )
{
- SvLBoxTab* pTab = aTabs[1];
+ SvLBoxTab* pTab = aTabs[1].get();
pTab->nFlags &= ~nAdjust;
pTab->nFlags |= SvLBoxTabFlags::PUSHABLE|SvLBoxTabFlags::ADJUST_CENTER|SvLBoxTabFlags::FORCE;
}
if( aTabs.size() > 2 )
{
- SvLBoxTab* pTab = aTabs[2];
+ SvLBoxTab* pTab = aTabs[2].get();
pTab->nFlags &= ~nAdjust;
pTab->nFlags |= SvLBoxTabFlags::PUSHABLE|SvLBoxTabFlags::ADJUST_CENTER|SvLBoxTabFlags::FORCE;
}
diff --git a/include/svtools/treelistbox.hxx b/include/svtools/treelistbox.hxx
index ee6fff1a7d91..abaf5adb3e75 100644
--- a/include/svtools/treelistbox.hxx
+++ b/include/svtools/treelistbox.hxx
@@ -251,7 +251,7 @@ protected:
Link<SvTreeListBox*,bool> aDoubleClickHdl;
SvTreeListEntry* pTargetEntry;
SvLBoxButtonData* pCheckButtonData;
- std::vector<SvLBoxTab*> aTabs;
+ std::vector<std::unique_ptr<SvLBoxTab>> aTabs;
SvTreeFlags nTreeFlags;
SvTreeListBoxFlags nImpFlags;
// Move/CopySelection: Position of the current Entry in SelectionList
diff --git a/svtools/source/contnr/svimpbox.cxx b/svtools/source/contnr/svimpbox.cxx
index 0ae2d0caf635..551122ad913d 100644
--- a/svtools/source/contnr/svimpbox.cxx
+++ b/svtools/source/contnr/svimpbox.cxx
@@ -3161,8 +3161,8 @@ SvLBoxTab* SvImpLBox::NextTab( SvLBoxTab const * pTab )
return nullptr;
for( int nTab=0; nTab < (nTabCount-1); nTab++)
{
- if( pView->aTabs[nTab]==pTab )
- return pView->aTabs[nTab+1];
+ if( pView->aTabs[nTab].get() == pTab )
+ return pView->aTabs[nTab+1].get();
}
return nullptr;
}
@@ -3199,7 +3199,7 @@ bool SvImpLBox::SetMostRight( SvTreeListEntry* pEntry )
if( nLastItem < nLastTab )
nLastTab = nLastItem;
- SvLBoxTab* pTab = pView->aTabs[ nLastTab ];
+ SvLBoxTab* pTab = pView->aTabs[ nLastTab ].get();
SvLBoxItem& rItem = pEntry->GetItem( nLastTab );
long nTabPos = pView->GetTabPos( pEntry, pTab );
diff --git a/svtools/source/contnr/treelistbox.cxx b/svtools/source/contnr/treelistbox.cxx
index bbc4e4c71024..d3a667d5abb4 100644
--- a/svtools/source/contnr/treelistbox.cxx
+++ b/svtools/source/contnr/treelistbox.cxx
@@ -2460,10 +2460,12 @@ void SvTreeListBox::EditItemText(SvTreeListEntry* pEntry, SvLBoxString* pItem, c
aPos.setX( GetTabPos( pEntry, pTab ) );
long nOutputWidth = pImpl->GetOutputSize().Width();
Size aSize( nOutputWidth - aPos.X(), aItemSize.Height() );
- sal_uInt16 nPos = std::find( aTabs.begin(), aTabs.end(), pTab ) - aTabs.begin();
+ sal_uInt16 nPos = std::find_if( aTabs.begin(), aTabs.end(),
+ [pTab](const std::unique_ptr<SvLBoxTab>& p) { return p.get() == pTab; })
+ - aTabs.begin();
if( nPos+1 < static_cast<sal_uInt16>(aTabs.size()) )
{
- SvLBoxTab* pRightTab = aTabs[ nPos + 1 ];
+ SvLBoxTab* pRightTab = aTabs[ nPos + 1 ].get();
long nRight = GetTabPos( pEntry, pRightTab );
if( nRight <= nOutputWidth )
aSize.setWidth( nRight - aPos.X() );
@@ -2685,9 +2687,9 @@ void SvTreeListBox::PaintEntry1(SvTreeListEntry& rEntry, long nLine, vcl::Render
while (nCurTab < nTabCount && nCurItem < nItemCount)
{
- SvLBoxTab* pTab = aTabs[nCurTab];
+ SvLBoxTab* pTab = aTabs[nCurTab].get();
sal_uInt16 nNextTab = nCurTab + 1;
- SvLBoxTab* pNextTab = nNextTab < nTabCount ? aTabs[nNextTab] : nullptr;
+ SvLBoxTab* pNextTab = nNextTab < nTabCount ? aTabs[nNextTab].get() : nullptr;
SvLBoxItem* pItem = nCurItem < nItemCount ? &rEntry.GetItem(nCurItem) : nullptr;
SvLBoxTabFlags nFlags = pTab->nFlags;
@@ -2854,7 +2856,7 @@ void SvTreeListBox::PaintEntry1(SvTreeListEntry& rEntry, long nLine, vcl::Render
do
{
nNextTab++;
- pNextTab = nNextTab < nTabCount ? aTabs[nNextTab] : nullptr;
+ pNextTab = nNextTab < nTabCount ? aTabs[nNextTab].get() : nullptr;
} while (pNextTab && pNextTab->IsDynamic());
if (!(!pNextTab || (GetTabPos( &rEntry, pNextTab ) > nDynTabPos)))
@@ -2949,7 +2951,7 @@ tools::Rectangle SvTreeListBox::GetFocusRect( SvTreeListEntry* pEntry, long nLin
long nNextTabPos;
if( pTab && nCurTab < aTabs.size() - 1 )
{
- SvLBoxTab* pNextTab = aTabs[ nCurTab + 1 ];
+ SvLBoxTab* pNextTab = aTabs[ nCurTab + 1 ].get();
nNextTabPos = GetTabPos( pEntry, pNextTab );
}
else
@@ -2990,7 +2992,7 @@ tools::Rectangle SvTreeListBox::GetFocusRect( SvTreeListEntry* pEntry, long nLin
GetLastTab(SvLBoxTabFlags::SHOW_SELECTION,nLastTab);
nLastTab++;
if( nLastTab < aTabs.size() ) // is there another one?
- pLastTab = aTabs[ nLastTab ];
+ pLastTab = aTabs[ nLastTab ].get();
aSize.setWidth( pLastTab ? pLastTab->GetPos() : 0x0fffffff );
nFocusWidth = static_cast<short>(aSize.Width());
@@ -3045,7 +3047,7 @@ SvLBoxItem* SvTreeListBox::GetItem_Impl( SvTreeListEntry* pEntry, long nX,
SvLBoxItem* pItemClicked = nullptr;
sal_uInt16 nTabCount = aTabs.size();
sal_uInt16 nItemCount = pEntry->ItemCount();
- SvLBoxTab* pTab = aTabs.front();
+ SvLBoxTab* pTab = aTabs.front().get();
SvLBoxItem* pItem = &pEntry->GetItem(0);
sal_uInt16 nNextItem = 1;
nX -= GetMapMode().GetOrigin().X();
@@ -3054,7 +3056,7 @@ SvLBoxItem* SvTreeListBox::GetItem_Impl( SvTreeListEntry* pEntry, long nX,
while( true )
{
- SvLBoxTab* pNextTab=nNextItem<nTabCount ? aTabs[nNextItem] : nullptr;
+ SvLBoxTab* pNextTab=nNextItem<nTabCount ? aTabs[nNextItem].get() : nullptr;
long nStart = GetTabPos( pEntry, pTab );
long nNextTabPos;
@@ -3088,7 +3090,7 @@ SvLBoxItem* SvTreeListBox::GetItem_Impl( SvTreeListEntry* pEntry, long nX,
}
if( nNextItem >= nItemCount || nNextItem >= nTabCount)
break;
- pTab = aTabs[ nNextItem ];
+ pTab = aTabs[ nNextItem ].get();
pItem = &pEntry->GetItem( nNextItem );
nNextItem++;
}
@@ -3195,7 +3197,7 @@ void SvTreeListBox::AddTab(long nTabPos, SvLBoxTabFlags nFlags )
{
nFocusWidth = -1;
SvLBoxTab* pTab = new SvLBoxTab( nTabPos, nFlags );
- aTabs.push_back( pTab );
+ aTabs.emplace_back( pTab );
if( nTreeFlags & SvTreeFlags::USESEL )
{
sal_uInt16 nPos = aTabs.size() - 1;
@@ -3215,7 +3217,7 @@ SvLBoxTab* SvTreeListBox::GetFirstDynamicTab( sal_uInt16& rPos ) const
sal_uInt16 nTabCount = aTabs.size();
while( nCurTab < nTabCount )
{
- SvLBoxTab* pTab = aTabs[nCurTab];
+ SvLBoxTab* pTab = aTabs[nCurTab].get();
if( pTab->nFlags & SvLBoxTabFlags::DYNAMIC )
{
rPos = nCurTab;
@@ -3235,18 +3237,11 @@ SvLBoxTab* SvTreeListBox::GetFirstDynamicTab() const
SvLBoxTab* SvTreeListBox::GetTab( SvTreeListEntry const * pEntry, SvLBoxItem const * pItem) const
{
sal_uInt16 nPos = pEntry->GetPos( pItem );
- return aTabs[ nPos ];
+ return aTabs[ nPos ].get();
}
void SvTreeListBox::ClearTabList()
{
- sal_uInt16 nTabCount = aTabs.size();
- while( nTabCount )
- {
- nTabCount--;
- SvLBoxTab* pDelTab = aTabs[ nTabCount ];
- delete pDelTab;
- }
aTabs.clear();
}
@@ -3335,7 +3330,7 @@ SvLBoxTab* SvTreeListBox::GetFirstTab( SvLBoxTabFlags nFlagMask, sal_uInt16& rPo
sal_uInt16 nTabCount = aTabs.size();
for( sal_uInt16 nPos = 0; nPos < nTabCount; nPos++ )
{
- SvLBoxTab* pTab = aTabs[ nPos ];
+ SvLBoxTab* pTab = aTabs[ nPos ].get();
if( pTab->nFlags & nFlagMask )
{
rPos = nPos;
@@ -3352,7 +3347,7 @@ void SvTreeListBox::GetLastTab( SvLBoxTabFlags nFlagMask, sal_uInt16& rTabPos )
while( nPos )
{
--nPos;
- SvLBoxTab* pTab = aTabs[ nPos ];
+ SvLBoxTab* pTab = aTabs[ nPos ].get();
if( pTab->nFlags & nFlagMask )
{
rTabPos = nPos;
More information about the Libreoffice-commits
mailing list