summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorTakeshi Abe <tabe@fixedpoint.jp>2017-12-24 20:46:53 +0900
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-12-26 07:17:38 +0100
commitc2ae5bc29b7064a599871358e6a4bb7b1dec2b85 (patch)
treeaab5fddf878f40fae52802878bb9e3acc2ef7f9d /svtools
parentc54d34f70819c5928fe30585e86d744eda4a254a (diff)
svtools: Use std::unique_ptr for LineListBox
This also inlines LineListBox::ImplInit(). Note that m_vLineList never contains nullptr. Change-Id: Ia4798943fbb53e1720d51faff7643e46d2cd2585 Reviewed-on: https://gerrit.libreoffice.org/47046 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svtools')
-rw-r--r--svtools/source/control/ctrlbox.cxx98
1 files changed, 39 insertions, 59 deletions
diff --git a/svtools/source/control/ctrlbox.cxx b/svtools/source/control/ctrlbox.cxx
index b7b3ceae461a..16c6fdcb7310 100644
--- a/svtools/source/control/ctrlbox.cxx
+++ b/svtools/source/control/ctrlbox.cxx
@@ -470,11 +470,16 @@ void LineListBox::ImpGetLine( long nLine1, long nLine2, long nDistance,
rBmp = aVirDev->GetBitmap( Point(), Size( aSize.Width(), n1+nDist+n2 ) );
}
-void LineListBox::ImplInit()
+LineListBox::LineListBox( vcl::Window* pParent, WinBits nWinStyle ) :
+ ListBox( pParent, nWinStyle ),
+ m_nWidth( 5 ),
+ m_sNone( ),
+ aVirDev( VclPtr<VirtualDevice>::Create() ),
+ aColor( COL_BLACK ),
+ maPaintCol( COL_BLACK )
{
aTxtSize.Width() = GetTextWidth( " " );
aTxtSize.Height() = GetTextHeight();
- pLineList = new ImpLineList;
eSourceUnit = FUNIT_POINT;
aVirDev->SetLineColor();
@@ -483,17 +488,6 @@ void LineListBox::ImplInit()
UpdatePaintLineColor();
}
-LineListBox::LineListBox( vcl::Window* pParent, WinBits nWinStyle ) :
- ListBox( pParent, nWinStyle ),
- m_nWidth( 5 ),
- m_sNone( ),
- aVirDev( VclPtr<VirtualDevice>::Create() ),
- aColor( COL_BLACK ),
- maPaintCol( COL_BLACK )
-{
- ImplInit();
-}
-
extern "C" SAL_DLLPUBLIC_EXPORT void makeLineListBox(VclPtr<vcl::Window> & rRet, VclPtr<vcl::Window> & pParent, VclBuilder::stringmap & rMap)
{
bool bDropdown = BuilderUtils::extractDropdown(rMap);
@@ -513,10 +507,7 @@ LineListBox::~LineListBox()
void LineListBox::dispose()
{
- for (ImpLineListData* p : *pLineList)
- delete p;
- pLineList->clear();
- delete pLineList;
+ m_vLineList.clear();
ListBox::dispose();
}
@@ -528,11 +519,11 @@ sal_Int32 LineListBox::GetStylePos( sal_Int32 nListPos, long nWidth )
sal_Int32 n = 0;
size_t i = 0;
- size_t nCount = pLineList->size();
+ size_t nCount = m_vLineList.size();
while ( nPos == LISTBOX_ENTRY_NOTFOUND && i < nCount )
{
- ImpLineListData* pData = (*pLineList)[ i ];
- if ( pData && pData->GetMinWidth() <= nWidth )
+ auto& pData = m_vLineList[ i ];
+ if ( pData->GetMinWidth() <= nWidth )
{
if ( nListPos == n )
nPos = static_cast<sal_Int32>(i);
@@ -555,26 +546,22 @@ void LineListBox::InsertEntry(
const BorderWidthImpl& rWidthImpl, SvxBorderLineStyle nStyle, long nMinWidth,
ColorFunc pColor1Fn, ColorFunc pColor2Fn, ColorDistFunc pColorDistFn )
{
- ImpLineListData* pData = new ImpLineListData(
- rWidthImpl, nStyle, nMinWidth, pColor1Fn, pColor2Fn, pColorDistFn);
- pLineList->push_back( pData );
+ m_vLineList.emplace_back(new ImpLineListData(
+ rWidthImpl, nStyle, nMinWidth, pColor1Fn, pColor2Fn, pColorDistFn));
}
sal_Int32 LineListBox::GetEntryPos( SvxBorderLineStyle nStyle ) const
{
if(nStyle == SvxBorderLineStyle::NONE && !m_sNone.isEmpty())
return 0;
- for ( size_t i = 0, n = pLineList->size(); i < n; ++i ) {
- ImpLineListData* pData = (*pLineList)[ i ];
- if ( pData )
+ for ( size_t i = 0, n = m_vLineList.size(); i < n; ++i ) {
+ auto& pData = m_vLineList[ i ];
+ if ( pData->GetStyle() == nStyle )
{
- if ( GetEntryStyle( i ) == nStyle )
- {
- size_t nPos = i;
- if (!m_sNone.isEmpty())
- nPos ++;
- return (sal_Int32)nPos;
- }
+ size_t nPos = i;
+ if (!m_sNone.isEmpty())
+ nPos ++;
+ return (sal_Int32)nPos;
}
}
return LISTBOX_ENTRY_NOTFOUND;
@@ -582,7 +569,7 @@ sal_Int32 LineListBox::GetEntryPos( SvxBorderLineStyle nStyle ) const
SvxBorderLineStyle LineListBox::GetEntryStyle( sal_Int32 nPos ) const
{
- ImpLineListData* pData = (0 <= nPos && static_cast<size_t>(nPos) < pLineList->size()) ? (*pLineList)[ nPos ] : nullptr;
+ ImpLineListData* pData = (0 <= nPos && static_cast<size_t>(nPos) < m_vLineList.size()) ? m_vLineList[ nPos ].get() : nullptr;
return pData ? pData->GetStyle() : SvxBorderLineStyle::NONE;
}
@@ -615,11 +602,11 @@ void LineListBox::UpdateEntries( long nOldWidth )
ListBox::InsertEntry( m_sNone );
sal_uInt16 n = 0;
- sal_uInt16 nCount = pLineList->size( );
+ sal_uInt16 nCount = m_vLineList.size( );
while ( n < nCount )
{
- ImpLineListData* pData = (*pLineList)[ n ];
- if ( pData && pData->GetMinWidth() <= m_nWidth )
+ auto& pData = m_vLineList[ n ];
+ if ( pData->GetMinWidth() <= m_nWidth )
{
Bitmap aBmp;
ImpGetLine( pData->GetLine1ForWidth( m_nWidth ),
@@ -644,38 +631,31 @@ void LineListBox::UpdateEntries( long nOldWidth )
Color LineListBox::GetColorLine1( sal_Int32 nPos )
{
- Color rResult = GetPaintColor( );
-
- sal_uInt16 nStyle = GetStylePos( nPos, m_nWidth );
- ImpLineListData* pData = (*pLineList)[ nStyle ];
- if ( pData )
- rResult = pData->GetColorLine1( GetColor( ) );
-
- return rResult;
+ sal_Int32 nStyle = GetStylePos( nPos, m_nWidth );
+ if (nStyle == LISTBOX_ENTRY_NOTFOUND)
+ return GetPaintColor( );
+ auto& pData = m_vLineList[ nStyle ];
+ return pData->GetColorLine1( GetColor( ) );
}
Color LineListBox::GetColorLine2( sal_Int32 nPos )
{
- Color rResult = GetPaintColor( );
-
- sal_uInt16 nStyle = GetStylePos( nPos, m_nWidth );
- ImpLineListData* pData = (*pLineList)[ nStyle ];
- if ( pData )
- rResult = pData->GetColorLine2( GetColor( ) );
-
- return rResult;
+ sal_Int32 nStyle = GetStylePos( nPos, m_nWidth );
+ if (nStyle == LISTBOX_ENTRY_NOTFOUND)
+ return GetPaintColor( );
+ auto& pData = m_vLineList[ nStyle ];
+ return pData->GetColorLine2( GetColor( ) );
}
Color LineListBox::GetColorDist( sal_Int32 nPos )
{
Color rResult = GetSettings().GetStyleSettings().GetFieldColor();
- sal_uInt16 nStyle = GetStylePos( nPos, m_nWidth );
- ImpLineListData* pData = (*pLineList)[ nStyle ];
- if ( pData )
- rResult = pData->GetColorDist( GetColor( ), rResult );
-
- return rResult;
+ sal_Int32 nStyle = GetStylePos( nPos, m_nWidth );
+ if (nStyle == LISTBOX_ENTRY_NOTFOUND)
+ return rResult;
+ auto& pData = m_vLineList[ nStyle ];
+ return pData->GetColorDist( GetColor( ), rResult );
}
void LineListBox::DataChanged( const DataChangedEvent& rDCEvt )