summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-10-31 10:18:27 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-11-01 06:43:29 +0100
commitd4e96a36d78299794ff4ac86e937fbbb0843c6ed (patch)
treebe5ca239c5273fb672fe91d88d5b9fd792158e86
parentClean up file by sorting entries (diff)
downloadcore-d4e96a36d78299794ff4ac86e937fbbb0843c6ed.tar.gz
core-d4e96a36d78299794ff4ac86e937fbbb0843c6ed.zip
drop LISTBOX_ERROR
almost nobody checks it, so rather just assert Change-Id: Ic3ad4c04c4f6013db3e8757559d3a773df020a1d Reviewed-on: https://gerrit.libreoffice.org/62684 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--cui/source/options/optchart.cxx21
-rw-r--r--include/vcl/lstbox.hxx1
-rw-r--r--svtools/source/control/ctrlbox.cxx15
-rw-r--r--vcl/source/control/imp_listbox.cxx18
4 files changed, 19 insertions, 36 deletions
diff --git a/cui/source/options/optchart.cxx b/cui/source/options/optchart.cxx
index 089b641ea72c..3fd6630afeaf 100644
--- a/cui/source/options/optchart.cxx
+++ b/cui/source/options/optchart.cxx
@@ -51,19 +51,16 @@ void SvxDefaultColorOptPage::InsertColorEntry(const XColorEntry& rEntry, sal_Int
nPos = m_pLbChartColors->InsertEntry(rStr, Image(aBitmap), nPos);
- if (nPos != LISTBOX_ERROR)
+ if ( static_cast<size_t>(nPos) < aColorList.size() )
{
- if ( static_cast<size_t>(nPos) < aColorList.size() )
- {
- ImpColorList::iterator it = aColorList.begin();
- std::advance( it, nPos );
- aColorList.insert( it, rColor );
- }
- else
- {
- aColorList.push_back( rColor );
- nPos = aColorList.size() - 1;
- }
+ ImpColorList::iterator it = aColorList.begin();
+ std::advance( it, nPos );
+ aColorList.insert( it, rColor );
+ }
+ else
+ {
+ aColorList.push_back( rColor );
+ nPos = aColorList.size() - 1;
}
}
diff --git a/include/vcl/lstbox.hxx b/include/vcl/lstbox.hxx
index 2e8e8a618ccc..8ee51a2681fb 100644
--- a/include/vcl/lstbox.hxx
+++ b/include/vcl/lstbox.hxx
@@ -27,7 +27,6 @@
#define LISTBOX_APPEND (SAL_MAX_INT32)
#define LISTBOX_ENTRY_NOTFOUND (SAL_MAX_INT32)
-#define LISTBOX_ERROR (SAL_MAX_INT32)
#define LISTBOX_MAX_ENTRIES (SAL_MAX_INT32 - 1)
// the following defines can be used for the SetEntryFlags()
diff --git a/svtools/source/control/ctrlbox.cxx b/svtools/source/control/ctrlbox.cxx
index 6346d3284ad2..ca805b44cab5 100644
--- a/svtools/source/control/ctrlbox.cxx
+++ b/svtools/source/control/ctrlbox.cxx
@@ -748,15 +748,12 @@ void FontNameBox::Fill( const FontList* pList )
{
const FontMetric& rFontMetric = pList->GetFontName( i );
sal_Int32 nIndex = InsertEntry( rFontMetric.GetFamilyName() );
- if ( nIndex != LISTBOX_ERROR )
- {
- if ( nIndex < static_cast<sal_Int32>(mpFontList->size()) ) {
- ImplFontList::iterator it = mpFontList->begin();
- ::std::advance( it, nIndex );
- mpFontList->insert( it, rFontMetric );
- } else {
- mpFontList->push_back( rFontMetric );
- }
+ if ( nIndex < static_cast<sal_Int32>(mpFontList->size()) ) {
+ ImplFontList::iterator it = mpFontList->begin();
+ ::std::advance( it, nIndex );
+ mpFontList->insert( it, rFontMetric );
+ } else {
+ mpFontList->push_back( rFontMetric );
}
}
diff --git a/vcl/source/control/imp_listbox.cxx b/vcl/source/control/imp_listbox.cxx
index 174e6a01fbd9..6570fb34c578 100644
--- a/vcl/source/control/imp_listbox.cxx
+++ b/vcl/source/control/imp_listbox.cxx
@@ -121,8 +121,8 @@ sal_Int32 ListBox::NaturalSortCompare(const OUString &rA, const OUString &rB)
sal_Int32 ImplEntryList::InsertEntry( sal_Int32 nPos, ImplEntryType* pNewEntry, bool bSort )
{
- if (nPos < 0 || LISTBOX_MAX_ENTRIES <= maEntries.size())
- return LISTBOX_ERROR;
+ assert(nPos >= 0);
+ assert(maEntries.size() < LISTBOX_MAX_ENTRIES);
if ( !!pNewEntry->maImage )
mnImages++;
@@ -764,8 +764,8 @@ void ImplListBoxWindow::ImplCallSelect()
sal_Int32 ImplListBoxWindow::InsertEntry( sal_Int32 nPos, ImplEntryType* pNewEntry )
{
- if (nPos < 0 || LISTBOX_MAX_ENTRIES <= mpEntryList->GetEntryCount())
- return LISTBOX_ERROR;
+ assert(nPos >= 0);
+ assert(mpEntryList->GetEntryCount() < LISTBOX_MAX_ENTRIES);
ImplClearLayoutData();
sal_Int32 nNewPos = mpEntryList->InsertEntry( nPos, pNewEntry, mbSort );
@@ -2220,11 +2220,6 @@ sal_Int32 ImplListBox::InsertEntry( sal_Int32 nPos, const OUString& rStr )
{
ImplEntryType* pNewEntry = new ImplEntryType( rStr );
sal_Int32 nNewPos = maLBWindow->InsertEntry( nPos, pNewEntry );
- if (nNewPos == LISTBOX_ERROR)
- {
- delete pNewEntry;
- return nNewPos;
- }
CompatStateChanged( StateChangedType::Data );
return nNewPos;
}
@@ -2233,11 +2228,6 @@ sal_Int32 ImplListBox::InsertEntry( sal_Int32 nPos, const OUString& rStr, const
{
ImplEntryType* pNewEntry = new ImplEntryType( rStr, rImage );
sal_Int32 nNewPos = maLBWindow->InsertEntry( nPos, pNewEntry );
- if (nNewPos == LISTBOX_ERROR)
- {
- delete pNewEntry;
- return nNewPos;
- }
CompatStateChanged( StateChangedType::Data );
return nNewPos;
}