Hi,
See attached.
Note 1
------
With the for loop below Insert(x,nPos) was previously applied but nPos
is initialised to the end of vector and is always incremented in every
loop iteration i.e. Insert(x,nPos) is effectively a push_back(x). Agree?
In "short SvxNumberFormatShell::FillEListWithUserCurrencys(....)"
size_t nOldListCount = rList.size();
for( size_t i = 0, nPos = nOldListCount;
i < static_cast<size_t>(aWSStringsDtor.Count()); ++i )
{
bool bFlag = true;
... // code that only impacts bFlag
if(bFlag)
{
- rList.Insert(new String(aInsStr),nPos);
+ rList.push_back( new String(aInsStr) );
aCurEntryList.insert( aCurEntryList.begin() + (nPos++),
NUMBERFORMAT_ENTRY_NOT_FOUND);
}
else
{
- rList.Insert(aList[j],nPos);
- aList.Remove(j);
+ rList.push_back( aList[j] );
+ aList.erase( aList.begin()+j );
aCurEntryList.insert( aCurEntryList.begin() + (nPos++),
aKeyList[j]);
aKeyList.erase( aKeyList.begin()+j );
}
}
Note 2
------
I assume it's safe to cast from short to size_t? There is an existing
check at the start of the function to ensure the short >= 0.
SvxNumberFormatShell::GetFormat4Entry(short nEntry)
...
if(nEntry < 0)
return String();
...
- if(aCurrencyFormatList.Count()>nEntry)
+ if( aCurrencyFormatList.size() > static_cast<size_t>(nEntry) )
return *aCurrencyFormatList[nEntry];
Note 3
------
One function implicitly casted from sal_uInt16 to short. I assume now
casting from size_t to short doesn't make the situation any worse?
short nSelP = SELPOS_NONE;
...
- for( sal_uInt16 i=0; i<aCurrencyFormatList.Count(); i++ )
+ for( size_t i=0; i<aCurrencyFormatList.size(); i++ )
{
...
- nSelP = i;
+ nSelP = static_cast<short>(i);
Regards,
Brad
From 9fdbf0e39e985cc534835923a4e2574a6fa9051f Mon Sep 17 00:00:00 2001
From: Brad Sowden <code@sowden.org>
Date: Thu, 29 Dec 2011 18:18:21 +1300
Subject: [PATCH 6/8] fdo#38831 convert SvStrings to std::vector
numfmt*.cxx/hxx
Also get rid of SvxDelStrgs (variant of SvStrings)
---
cui/source/inc/numfmt.hxx | 5 +-
cui/source/tabpages/numfmt.cxx | 74 ++++++++++------------
svx/inc/svx/numfmtsh.hxx | 80 ++++++++++--------------
svx/source/items/numfmtsh.cxx | 131 +++++++++++++++++++++-------------------
4 files changed, 139 insertions(+), 151 deletions(-)
diff --git a/cui/source/inc/numfmt.hxx b/cui/source/inc/numfmt.hxx
index 2fb233d..ccfea59 100644
--- a/cui/source/inc/numfmt.hxx
+++ b/cui/source/inc/numfmt.hxx
@@ -46,6 +46,7 @@
class SvxNumberFormatShell;
class SvxNumberInfoItem;
+class vector;
//------------------------------------------------------------------------
@@ -147,10 +148,10 @@ private:
#ifdef _SVX_NUMFMT_CXX
void Init_Impl();
void FillCurrencyBox();
- void FillFormatListBox_Impl( SvxDelStrgs& rEntries );
+ void FillFormatListBox_Impl( std::vector<String*>& rEntries );
void UpdateOptions_Impl( sal_Bool bCheckCatChange );
void UpdateFormatListBox_Impl( sal_uInt16 bCat, sal_Bool bUpdateEdit );
- void DeleteEntryList_Impl( SvxDelStrgs& rEntries );
+ void DeleteEntryList_Impl( std::vector<String*>& rEntries );
void Obstructing();
void EnableBySourceFormat_Impl();
void SetCategory( sal_uInt16 nPos );
diff --git a/cui/source/tabpages/numfmt.cxx b/cui/source/tabpages/numfmt.cxx
index 5866cfc..17b2fbf 100644
--- a/cui/source/tabpages/numfmt.cxx
+++ b/cui/source/tabpages/numfmt.cxx
@@ -34,7 +34,6 @@
#include <unotools/localedatawrapper.hxx>
#include <i18npool/lang.h>
#include <svx/dialogs.hrc>
-#define _SVSTDARR_STRINGS
#define _SVSTDARR_STRINGSDTOR
#include <svl/svstdarr.hxx>
#include <svtools/colorcfg.hxx>
@@ -53,6 +52,7 @@
#include <sfx2/app.hxx>
#include <sfx2/basedlgs.hxx>
#include "svx/flagsdef.hxx"
+#include <vector>
#define NUMKEY_UNDEFINED SAL_MAX_UINT32
@@ -399,7 +399,7 @@ void SvxNumberFormatTabPage::Reset( const SfxItemSet& rSet )
sal_uInt16 nCatLbSelPos = 0;
sal_uInt16 nFmtLbSelPos = 0;
LanguageType eLangType = LANGUAGE_DONTKNOW;
- SvxDelStrgs aFmtEntryList;
+ std::vector<String*> aFmtEntryList;
SvxNumberValueType eValType = SVX_VALUE_TYPE_UNDEFINED;
double nValDouble = 0;
String aValString;
@@ -830,22 +830,21 @@ void SvxNumberFormatTabPage::SetInfoItem( const SvxNumberInfoItem& rItem )
}
}
-void SvxNumberFormatTabPage::FillFormatListBox_Impl( SvxDelStrgs& rEntries )
+void SvxNumberFormatTabPage::FillFormatListBox_Impl( std::vector<String*>& rEntries )
{
String* pEntry;
String aTmpString;
String aTmpCatString;
Font aFont=aLbCategory.GetFont();
- sal_uInt16 i = 0;
+ size_t i = 0;
short nTmpCatPos;
short aPrivCat;
aLbFormat.Clear();
aLbFormat.SetUpdateMode( sal_False );
- sal_uInt16 nCount = rEntries.Count();
-
- if(nCount<1) return;
+ if( rEntries.empty() )
+ return;
if(bOneAreaFlag)
{
@@ -878,10 +877,10 @@ void SvxNumberFormatTabPage::FillFormatListBox_Impl( SvxDelStrgs& rEntries )
if(pNumFmtShell!=NULL)
{
- for ( ; i < nCount; ++i )
+ for ( ; i < rEntries.size(); ++i )
{
pEntry = rEntries[i];
- aPrivCat=pNumFmtShell->GetCategory4Entry(i);
+ aPrivCat=pNumFmtShell->GetCategory4Entry( static_cast<sal_uInt16>(i) );
if(aPrivCat!=CAT_TEXT)
{
Color* pPreviewColor = NULL;
@@ -900,21 +899,11 @@ void SvxNumberFormatTabPage::FillFormatListBox_Impl( SvxDelStrgs& rEntries )
}
-/*************************************************************************
-#* Methode: DeleteEntryList_Impl
-#*------------------------------------------------------------------------
-#*
-#* Klasse: SvxNumberFormatTabPage
-#* Funktion: Loescht eine SvStrings- Liste
-#* Input: String-liste
-#* Output: ---
-#*
-#************************************************************************/
-
-void SvxNumberFormatTabPage::DeleteEntryList_Impl( SvxDelStrgs& rEntries )
+void SvxNumberFormatTabPage::DeleteEntryList_Impl( std::vector<String*>& rEntries )
{
- sal_uInt16 nCount = rEntries.Count();
- rEntries.DeleteAndDestroy(0,nCount);
+ for( std::vector<String*>::const_iterator it(rEntries.begin()); it != rEntries.end(); ++it )
+ delete *it;
+ rEntries.clear();
}
@@ -932,7 +921,6 @@ void SvxNumberFormatTabPage::DeleteEntryList_Impl( SvxDelStrgs& rEntries )
void SvxNumberFormatTabPage::UpdateOptions_Impl( sal_Bool bCheckCatChange /*= sal_False*/ )
{
- SvxDelStrgs aEntryList;
String theFormat = aEdFormat.GetText();
sal_uInt16 nCurCategory = aLbCategory.GetSelectEntryPos();
sal_uInt16 nCategory = nCurCategory;
@@ -1050,9 +1038,9 @@ void SvxNumberFormatTabPage::UpdateFormatListBox_Impl
sal_Bool bUpdateEdit // Format-Edit aktualisieren?
)
{
- SvxDelStrgs aEntryList;
- short nFmtLbSelPos = 0;
- short nTmpCatPos;
+ std::vector<String*> aEntryList;
+ short nFmtLbSelPos = 0;
+ short nTmpCatPos;
if(bOneAreaFlag)
{
@@ -1093,7 +1081,7 @@ void SvxNumberFormatTabPage::UpdateFormatListBox_Impl
REMOVE_DONTKNOW() // ggF. UI-Enable
- if ( (aEntryList.Count() > 0) && (nFmtLbSelPos != SELPOS_NONE) )
+ if ( (!aEntryList.empty()) && (nFmtLbSelPos != SELPOS_NONE) )
{
if(bUpdateEdit)
{
@@ -1146,6 +1134,8 @@ void SvxNumberFormatTabPage::UpdateFormatListBox_Impl
aWndPreview.NotifyChange( String() );
}
}
+
+ DeleteEntryList_Impl( aEntryList );
}
@@ -1243,7 +1233,6 @@ IMPL_LINK( SvxNumberFormatTabPage, SelFormatHdl_Impl, void *, pLb )
sal_uInt16 nSelPos = (sal_uInt16) aLbFormat.GetSelectEntryPos();
String aFormat = aLbFormat.GetSelectEntry();
String aComment;
- SvxDelStrgs aEntryList;
short nFmtLbSelPos = nSelPos;
@@ -1336,12 +1325,12 @@ IMPL_LINK( SvxNumberFormatTabPage, ClickHdl_Impl, ImageButton*, pIB)
if(pIB==&aIbAdd)
{ // Also called from FillItemSet() if a temporary currency format has
// to be added, not only if the Add button is enabled.
- String aFormat = aEdFormat.GetText();
- SvxDelStrgs aEntryList;
- SvxDelStrgs a2EntryList;
- sal_uInt16 nCatLbSelPos = 0;
- short nFmtLbSelPos = SELPOS_NONE;
- xub_StrLen nErrPos=0;
+ String aFormat = aEdFormat.GetText();
+ std::vector<String*> aEntryList;
+ std::vector<String*> a2EntryList;
+ sal_uInt16 nCatLbSelPos = 0;
+ short nFmtLbSelPos = SELPOS_NONE;
+ xub_StrLen nErrPos=0;
pNumFmtShell->SetCurCurrencyEntry(NULL);
bAdded = pNumFmtShell->AddFormat( aFormat, nErrPos,
@@ -1418,13 +1407,16 @@ IMPL_LINK( SvxNumberFormatTabPage, ClickHdl_Impl, ImageButton*, pIB)
}
EditHdl_Impl( &aEdFormat );
nReturn = ((nReturn & nReturnOneArea) ? 0 : (nReturn & nReturnChanged));
+
+ DeleteEntryList_Impl( aEntryList );
+ DeleteEntryList_Impl( a2EntryList );
}
else if(pIB==&aIbRemove)
{
- String aFormat = aEdFormat.GetText();
- SvxDelStrgs aEntryList;
- sal_uInt16 nCatLbSelPos = 0;
- short nFmtLbSelPos = SELPOS_NONE;
+ String aFormat = aEdFormat.GetText();
+ std::vector<String*> aEntryList;
+ sal_uInt16 nCatLbSelPos = 0;
+ short nFmtLbSelPos = SELPOS_NONE;
bDeleted = pNumFmtShell->RemoveFormat( aFormat,
nCatLbSelPos,
@@ -1434,7 +1426,7 @@ IMPL_LINK( SvxNumberFormatTabPage, ClickHdl_Impl, ImageButton*, pIB)
aEdComment.SetText(aLbCategory.GetEntry(1));
if ( bDeleted )
{
- if(nFmtLbSelPos>=0 && nFmtLbSelPos<aEntryList.Count())
+ if( nFmtLbSelPos>=0 && static_cast<size_t>(nFmtLbSelPos)<aEntryList.size() )
{
aFormat = *aEntryList[nFmtLbSelPos];
}
@@ -1460,6 +1452,8 @@ IMPL_LINK( SvxNumberFormatTabPage, ClickHdl_Impl, ImageButton*, pIB)
}
}
EditHdl_Impl( &aEdFormat );
+
+ DeleteEntryList_Impl( aEntryList );
}
else if(pIB==&aIbInfo)
{
diff --git a/svx/inc/svx/numfmtsh.hxx b/svx/inc/svx/numfmtsh.hxx
index 89e9686..5c7ce26 100644
--- a/svx/inc/svx/numfmtsh.hxx
+++ b/svx/inc/svx/numfmtsh.hxx
@@ -47,7 +47,6 @@
class Color;
class SvNumberFormatter;
class SvNumberFormatTable;
-class SvStrings;
class SvStringsDtor;
class NfCurrencyEntry;
// enum ------------------------------------------------------------------
@@ -78,15 +77,6 @@ enum SvxNumberValueType
#define NUMBERFORMAT_ENTRY_NEW_CURRENCY NUMBERFORMAT_ENTRY_NOT_FOUND-1
-class SvxDelStrgs: public SvStrings
-{
-
-public:
- ~SvxDelStrgs() { DeleteAndDestroy(0,Count());}
-
-};
-
-// class SvxNumberFormatShell --------------------------------------------
class SVX_DLLPUBLIC SvxNumberFormatShell
{
@@ -117,35 +107,35 @@ public:
const String* pNumStr = NULL );
- void GetInitSettings( sal_uInt16& nCatLbPos,
- LanguageType& rLangType,
- sal_uInt16& nFmtLbSelPos,
- SvStrings& rFmtEntries,
- String& rPrevString,
- Color*& rpPrevColor );
+ void GetInitSettings( sal_uInt16& nCatLbPos,
+ LanguageType& rLangType,
+ sal_uInt16& nFmtLbSelPos,
+ std::vector<String*>& rFmtEntries,
+ String& rPrevString,
+ Color*& rpPrevColor );
- void CategoryChanged( sal_uInt16 nCatLbPos,
- short& rFmtSelPos,
- SvStrings& rFmtEntries );
+ void CategoryChanged( sal_uInt16 nCatLbPos,
+ short& rFmtSelPos,
+ std::vector<String*>& rFmtEntries );
- void LanguageChanged( LanguageType eLangType,
- short& rFmtSelPos,
- SvStrings& rFmtEntries );
+ void LanguageChanged( LanguageType eLangType,
+ short& rFmtSelPos,
+ std::vector<String*>& rFmtEntries );
void FormatChanged( sal_uInt16 nFmtLbPos,
String& rPreviewStr,
Color*& rpFontColor );
- bool AddFormat( String& rFormat,
- xub_StrLen& rErrPos,
- sal_uInt16& rCatLbSelPos,
- short& rFmtSelPos,
- SvStrings& rFmtEntries );
+ bool AddFormat( String& rFormat,
+ xub_StrLen& rErrPos,
+ sal_uInt16& rCatLbSelPos,
+ short& rFmtSelPos,
+ std::vector<String*>& rFmtEntries );
- bool RemoveFormat( const String& rFormat,
- sal_uInt16& rCatLbSelPos,
- short& rFmtSelPos,
- SvStrings& rFmtEntries );
+ bool RemoveFormat( const String& rFormat,
+ sal_uInt16& rCatLbSelPos,
+ short& rFmtSelPos,
+ std::vector<String*>& rFmtEntries );
void MakeFormat( String& rFormat,
bool bThousand,
@@ -229,31 +219,29 @@ private:
NfCurrencyEntry* pCurCurrencyEntry;
bool bBankingSymbol;
sal_uInt16 nCurCurrencyEntryPos;
- SvStrings aCurrencyFormatList;
+ std::vector<String*> aCurrencyFormatList;
#ifdef _SVX_NUMFMTSH_CXX
- SVX_DLLPRIVATE short FillEntryList_Impl( SvStrings& rList );
- SVX_DLLPRIVATE void FillEListWithStd_Impl( SvStrings& rList,sal_uInt16
aPrivCat, short &Pos);
- SVX_DLLPRIVATE short FillEListWithFormats_Impl( SvStrings& rList,short nSelPos,
+ SVX_DLLPRIVATE short FillEntryList_Impl( std::vector<String*>& rList );
+ SVX_DLLPRIVATE void FillEListWithStd_Impl( std::vector<String*>& rList,sal_uInt16 aPrivCat,
short &Pos);
+ SVX_DLLPRIVATE short FillEListWithFormats_Impl( std::vector<String*>& rList,short nSelPos,
NfIndexTableOffset eOffsetStart,
NfIndexTableOffset eOffsetEnd);
+ SVX_DLLPRIVATE short FillEListWithDateTime_Impl( std::vector<String*>& rList,short nSelPos);
+ SVX_DLLPRIVATE short FillEListWithCurrency_Impl( std::vector<String*>& rList,short nSelPos);
+ SVX_DLLPRIVATE short FillEListWithSysCurrencys( std::vector<String*>& rList,short nSelPos);
+ SVX_DLLPRIVATE short FillEListWithUserCurrencys( std::vector<String*>& rList,short nSelPos);
+ SVX_DLLPRIVATE short FillEListWithUsD_Impl( std::vector<String*>& rList, sal_uInt16 nPrivCat,
short Pos );
- SVX_DLLPRIVATE short FillEListWithDateTime_Impl( SvStrings& rList,short
nSelPos);
-
- SVX_DLLPRIVATE short FillEListWithCurrency_Impl( SvStrings& rList,short
nSelPos);
- SVX_DLLPRIVATE short FillEListWithSysCurrencys( SvStrings& rList,short nSelPos);
- SVX_DLLPRIVATE short FillEListWithUserCurrencys( SvStrings& rList,short
nSelPos);
-
- SVX_DLLPRIVATE short FillEListWithUsD_Impl( SvStrings& rList,
sal_uInt16 nPrivCat, short Pos );
SVX_DLLPRIVATE ::std::vector<sal_uInt32>::iterator GetRemoved_Impl( size_t nKey );
SVX_DLLPRIVATE bool IsRemoved_Impl( size_t nKey );
SVX_DLLPRIVATE ::std::vector<sal_uInt32>::iterator GetAdded_Impl( size_t nKey );
SVX_DLLPRIVATE bool IsAdded_Impl( size_t nKey );
- SVX_DLLPRIVATE void GetPreviewString_Impl( String& rString,
- Color*& rpColor );
- SVX_DLLPRIVATE void PosToCategory_Impl( sal_uInt16 nPos, short& rCategory );
- SVX_DLLPRIVATE void CategoryToPos_Impl( short nCategory, sal_uInt16& rPos );
+ SVX_DLLPRIVATE void GetPreviewString_Impl( String& rString,
+ Color*& rpColor );
+ SVX_DLLPRIVATE void PosToCategory_Impl( sal_uInt16 nPos, short& rCategory );
+ SVX_DLLPRIVATE void CategoryToPos_Impl( short nCategory, sal_uInt16& rPos );
#endif
};
diff --git a/svx/source/items/numfmtsh.cxx b/svx/source/items/numfmtsh.cxx
index 9c0ba71..72b41fe 100644
--- a/svx/source/items/numfmtsh.cxx
+++ b/svx/source/items/numfmtsh.cxx
@@ -162,8 +162,9 @@ SvxNumberFormatShell::~SvxNumberFormatShell()
pFormatter->DeleteEntry( *it );
}
- if(aCurrencyFormatList.Count()>0)
- aCurrencyFormatList.DeleteAndDestroy(0,aCurrencyFormatList.Count());
+ for ( std::vector<String*>::const_iterator it(aCurrencyFormatList.begin());
+ it != aCurrencyFormatList.end(); ++it )
+ delete *it;
}
// -----------------------------------------------------------------------
@@ -188,9 +189,9 @@ void SvxNumberFormatShell::GetUpdateData( sal_uInt32* pDelArray, const sal_uInt3
// -----------------------------------------------------------------------
-void SvxNumberFormatShell::CategoryChanged( sal_uInt16 nCatLbPos,
- short& rFmtSelPos,
- SvStrings& rFmtEntries )
+void SvxNumberFormatShell::CategoryChanged( sal_uInt16 nCatLbPos,
+ short& rFmtSelPos,
+ std::vector<String*>& rFmtEntries )
{
short nOldCategory = nCurCategory;
PosToCategory_Impl( nCatLbPos, nCurCategory );
@@ -206,8 +207,8 @@ void SvxNumberFormatShell::CategoryChanged( sal_uInt16 nCatLbPos,
// -----------------------------------------------------------------------
void SvxNumberFormatShell::LanguageChanged( LanguageType eLangType,
- short& rFmtSelPos,
- SvStrings& rFmtEntries )
+ short& rFmtSelPos,
+ std::vector<String*>& rFmtEntries )
{
eCurLanguage = eLangType;
pCurFmtTable = &(pFormatter->ChangeCL( nCurCategory,
@@ -232,7 +233,7 @@ void SvxNumberFormatShell::FormatChanged( sal_uInt16 nFmtLbPos,
}
else if( nCurCategory == NUMBERFORMAT_CURRENCY )
{
- if(nFmtLbPos<aCurrencyFormatList.Count())
+ if( static_cast<size_t>(nFmtLbPos) < aCurrencyFormatList.size() )
{
MakePrevStringFromVal(*aCurrencyFormatList[nFmtLbPos],
rPreviewStr,rpFontColor,nValNum);
@@ -244,7 +245,7 @@ void SvxNumberFormatShell::FormatChanged( sal_uInt16 nFmtLbPos,
bool SvxNumberFormatShell::AddFormat( String& rFormat, xub_StrLen& rErrPos,
sal_uInt16& rCatLbSelPos, short& rFmtSelPos,
- SvStrings& rFmtEntries )
+ std::vector<String*>& rFmtEntries )
{
bool bInserted = false;
sal_uInt32 nAddKey = pFormatter->GetEntryKey( rFormat, eCurLanguage );
@@ -311,10 +312,10 @@ bool SvxNumberFormatShell::AddFormat( String& rFormat, xub_StrLen& rErrPos,
// -----------------------------------------------------------------------
-bool SvxNumberFormatShell::RemoveFormat( const String& rFormat,
- sal_uInt16& rCatLbSelPos,
- short& rFmtSelPos,
- SvStrings& rFmtEntries )
+bool SvxNumberFormatShell::RemoveFormat( const String& rFormat,
+ sal_uInt16& rCatLbSelPos,
+ short& rFmtSelPos,
+ std::vector<String*>& rFmtEntries )
{
sal_uInt32 nDelKey = pFormatter->GetEntryKey( rFormat, eCurLanguage );
@@ -352,10 +353,10 @@ void SvxNumberFormatShell::MakeFormat( String& rFormat,
sal_uInt16 nPrecision, sal_uInt16 nLeadingZeroes,
sal_uInt16 nCurrencyPos)
{
- if(aCurrencyFormatList.Count()>nCurrencyPos)
+ if( aCurrencyFormatList.size() > static_cast<size_t>(nCurrencyPos) )
{
xub_StrLen rErrPos=0;
- SvStrings aFmtEList;
+ std::vector<String*> aFmtEList;
sal_uInt32 nFound = pFormatter->TestNewString( *aCurrencyFormatList[nCurrencyPos],
eCurLanguage );
@@ -374,7 +375,8 @@ void SvxNumberFormatShell::MakeFormat( String& rFormat,
bThousand, bNegRed,
nPrecision, nLeadingZeroes );
}
- aFmtEList.DeleteAndDestroy(0,aFmtEList.Count());
+ for ( std::vector<String*>::const_iterator it(aFmtEList.begin()); it != aFmtEList.end();
++it )
+ delete *it;
}
else
{
@@ -517,13 +519,12 @@ bool SvxNumberFormatShell::FindEntry( const String& rFmtString, sal_uInt32*
pAt
// -----------------------------------------------------------------------
-void SvxNumberFormatShell::GetInitSettings(
- sal_uInt16& nCatLbPos,
- LanguageType& rLangType,
- sal_uInt16& nFmtLbSelPos,
- SvStrings& rFmtEntries,
- String& rPrevString,
- Color*& rpPrevColor )
+void SvxNumberFormatShell::GetInitSettings( sal_uInt16& nCatLbPos,
+ LanguageType& rLangType,
+ sal_uInt16& nFmtLbSelPos,
+ std::vector<String*>& rFmtEntries,
+ String& rPrevString,
+ Color*& rpPrevColor )
{
// -------------------------------------------------------------------
// Vorbedingung: Zahlenformatierer gefunden
@@ -558,7 +559,7 @@ void SvxNumberFormatShell::GetInitSettings(
// -----------------------------------------------------------------------
-short SvxNumberFormatShell::FillEntryList_Impl( SvStrings& rList )
+short SvxNumberFormatShell::FillEntryList_Impl( std::vector<String*>& rList )
{
/* Erstellen einer aktuellen Liste von Format-Eintraegen.
* Rueckgabewert ist die Listenposition des aktuellen Formates.
@@ -595,7 +596,8 @@ short SvxNumberFormatShell::FillEntryList_Impl( SvStrings& rList )
return nSelPos;
}
-void SvxNumberFormatShell::FillEListWithStd_Impl( SvStrings& rList,sal_uInt16 nPrivCat,short
&nSelPos )
+void SvxNumberFormatShell::FillEListWithStd_Impl( std::vector<String*>& rList,
+ sal_uInt16 nPrivCat,short &nSelPos )
{
/* Erstellen einer aktuellen Liste von Format-Eintraegen.
* Rueckgabewert ist die Listenposition des aktuellen Formates.
@@ -604,8 +606,10 @@ void SvxNumberFormatShell::FillEListWithStd_Impl( SvStrings& rList,sal_uInt16
nP
*/
DBG_ASSERT( pCurFmtTable != NULL, "Unbekanntes Zahlenformat!" );
- if(aCurrencyFormatList.Count()>0)
- aCurrencyFormatList.DeleteAndDestroy(0,aCurrencyFormatList.Count());
+ for ( std::vector<String*>::const_iterator it(aCurrencyFormatList.begin());
+ it != aCurrencyFormatList.end(); ++it )
+ delete *it;
+ aCurrencyFormatList.clear();
if(nPrivCat==CAT_CURRENCY)
{
@@ -658,7 +662,8 @@ void SvxNumberFormatShell::FillEListWithStd_Impl( SvStrings& rList,sal_uInt16 nP
}
}
-short SvxNumberFormatShell::FillEListWithFormats_Impl( SvStrings& rList,short nSelPos,
+short SvxNumberFormatShell::FillEListWithFormats_Impl( std::vector<String*>& rList,
+ short nSelPos,
NfIndexTableOffset eOffsetStart,
NfIndexTableOffset eOffsetEnd)
{
@@ -702,14 +707,15 @@ short SvxNumberFormatShell::FillEListWithFormats_Impl( SvStrings& rList,short
nS
nSelPos = ( !IsRemoved_Impl( nNFEntry ) ) ? aCurEntryList.size() : SELPOS_NONE;
}
- rList.Insert( pStr,rList.Count());
+ rList.push_back( pStr );
aCurEntryList.push_back( nNFEntry );
}
return nSelPos;
}
-short SvxNumberFormatShell::FillEListWithDateTime_Impl( SvStrings& rList,short nSelPos)
+short SvxNumberFormatShell::FillEListWithDateTime_Impl( std::vector<String*>& rList,
+ short nSelPos)
{
sal_uInt16 nMyType;
@@ -745,7 +751,7 @@ short SvxNumberFormatShell::FillEListWithDateTime_Impl( SvStrings& rList,short n
nSelPos = ( !IsRemoved_Impl( nNFEntry ) ) ? aCurEntryList.size() : SELPOS_NONE;
}
- rList.Insert( pStr,rList.Count());
+ rList.push_back( pStr );
aCurEntryList.push_back( nNFEntry );
}
}
@@ -753,7 +759,8 @@ short SvxNumberFormatShell::FillEListWithDateTime_Impl( SvStrings& rList,short n
return nSelPos;
}
-short SvxNumberFormatShell::FillEListWithCurrency_Impl( SvStrings& rList,short nSelPos)
+short SvxNumberFormatShell::FillEListWithCurrency_Impl( std::vector<String*>& rList,
+ short nSelPos)
{
/* Erstellen einer aktuellen Liste von Format-Eintraegen.
* Rueckgabewert ist die Listenposition des aktuellen Formates.
@@ -786,7 +793,8 @@ short SvxNumberFormatShell::FillEListWithCurrency_Impl( SvStrings& rList,short n
}
-short SvxNumberFormatShell::FillEListWithSysCurrencys( SvStrings& rList,short nSelPos)
+short SvxNumberFormatShell::FillEListWithSysCurrencys( std::vector<String*>& rList,
+ short nSelPos)
{
/* Erstellen einer aktuellen Liste von Format-Eintraegen.
* Rueckgabewert ist die Listenposition des aktuellen Formates.
@@ -832,7 +840,7 @@ short SvxNumberFormatShell::FillEListWithSysCurrencys( SvStrings& rList,short nS
nSelPos = ( !IsRemoved_Impl( nNFEntry ) ) ? aCurEntryList.size() : SELPOS_NONE;
}
- rList.Insert( pStr,rList.Count());
+ rList.push_back( pStr );
aCurEntryList.push_back( nNFEntry );
}
@@ -868,7 +876,7 @@ short SvxNumberFormatShell::FillEListWithSysCurrencys( SvStrings& rList,short nS
const StringPtr pStr = new String(aNewFormNInfo);
if ( nKey == nCurFormatKey ) nSelPos =aCurEntryList.size();
- rList.Insert( pStr,rList.Count());
+ rList.push_back( pStr );
aCurEntryList.push_back( nKey );
}
}
@@ -878,7 +886,8 @@ short SvxNumberFormatShell::FillEListWithSysCurrencys( SvStrings& rList,short nS
return nSelPos;
}
-short SvxNumberFormatShell::FillEListWithUserCurrencys( SvStrings& rList,short nSelPos)
+short SvxNumberFormatShell::FillEListWithUserCurrencys( std::vector<String*>& rList,
+ short nSelPos)
{
/* Erstellen einer aktuellen Liste von Format-Eintraegen.
* Rueckgabewert ist die Listenposition des aktuellen Formates.
@@ -900,7 +909,7 @@ short SvxNumberFormatShell::FillEListWithUserCurrencys( SvStrings& rList,short n
XubString rSymbol;
XubString rBankSymbol;
- SvStrings aList;
+ std::vector<String*> aList;
std::vector<sal_uInt32> aKeyList;
pFormatter->GetNewCurrencySymbolString(nCurFormatKey,rSymbol,
@@ -982,9 +991,7 @@ short SvxNumberFormatShell::FillEListWithUserCurrencys( SvStrings& rList,short n
if(bInsFlag)
{
- const StringPtr pStr = new String(aNewFormNInfo);
-
- aList.Insert( pStr,aList.Count());
+ aList.push_back( new String(aNewFormNInfo) );
aKeyList.push_back( nKey );
}
}
@@ -1020,14 +1027,14 @@ short SvxNumberFormatShell::FillEListWithUserCurrencys( SvStrings&
rList,short n
}
}
- size_t i,nPos;
- size_t nOldListCount = rList.Count();
- for( i = 0, nPos = nOldListCount; i < aWSStringsDtor.Count(); ++i)
+ size_t nOldListCount = rList.size();
+ for( size_t i = 0, nPos = nOldListCount;
+ i < static_cast<size_t>(aWSStringsDtor.Count()); ++i )
{
bool bFlag = true;
String aInsStr(*aWSStringsDtor[i]);
size_t j;
- for( j=0; j < aList.Count(); ++j )
+ for( j=0; j < aList.size(); ++j )
{
const StringPtr pTestStr=aList[j];
@@ -1039,30 +1046,30 @@ short SvxNumberFormatShell::FillEListWithUserCurrencys( SvStrings&
rList,short n
}
if(bFlag)
{
- rList.Insert(new String(aInsStr),nPos);
+ rList.push_back( new String(aInsStr) );
aCurEntryList.insert( aCurEntryList.begin() + (nPos++), NUMBERFORMAT_ENTRY_NOT_FOUND);
}
else
{
- rList.Insert(aList[j],nPos);
- aList.Remove(j);
+ rList.push_back( aList[j] );
+ aList.erase( aList.begin()+j );
aCurEntryList.insert( aCurEntryList.begin() + (nPos++), aKeyList[j]);
aKeyList.erase( aKeyList.begin()+j );
}
}
- for( i = 0; i < aKeyList.size(); ++i )
+ for( size_t i = 0; i < aKeyList.size(); ++i )
{
if( aKeyList[i] != NUMBERFORMAT_ENTRY_NOT_FOUND )
{
- rList.Insert(aList[i],rList.Count());
+ rList.push_back( aList[i] );
aCurEntryList.push_back( aKeyList[i] );
}
}
- for( i = nOldListCount; i < rList.Count(); ++i )
+ for( size_t i = nOldListCount; i < rList.size(); ++i )
{
- aCurrencyFormatList.Insert(new String(*rList[i]),aCurrencyFormatList.Count());
+ aCurrencyFormatList.push_back( new String(*rList[i]) );
if ( nSelPos == SELPOS_NONE && bAdaptSelPos && aCurEntryList[i] == nCurFormatKey )
nSelPos = i;
@@ -1075,7 +1082,8 @@ short SvxNumberFormatShell::FillEListWithUserCurrencys( SvStrings&
rList,short n
}
-short SvxNumberFormatShell::FillEListWithUsD_Impl( SvStrings& rList, sal_uInt16 nPrivCat, short
nSelPos)
+short SvxNumberFormatShell::FillEListWithUsD_Impl( std::vector<String*>& rList,
+ sal_uInt16 nPrivCat, short nSelPos )
{
/* Erstellen einer aktuellen Liste von Format-Eintraegen.
* Rueckgabewert ist die Listenposition des aktuellen Formates.
@@ -1122,7 +1130,7 @@ short SvxNumberFormatShell::FillEListWithUsD_Impl( SvStrings& rList,
sal_uInt16
const StringPtr pStr = new String(aNewFormNInfo);
if ( nKey == nCurFormatKey ) nSelPos = aCurEntryList.size();
- rList.Insert( pStr,rList.Count());
+ rList.push_back( pStr );
aCurEntryList.push_back( nKey );
}
}
@@ -1344,7 +1352,7 @@ short SvxNumberFormatShell::GetCategory4Entry(short nEntry)
}
return 0;
}
- else if(aCurrencyFormatList.Count()>0)
+ else if( !aCurrencyFormatList.empty() )
{
return CAT_CURRENCY;
}
@@ -1412,9 +1420,9 @@ String SvxNumberFormatShell::GetFormat4Entry(short nEntry)
if(nEntry < 0)
return String();
- if(aCurrencyFormatList.Count()>0)
+ if( !aCurrencyFormatList.empty() )
{
- if(aCurrencyFormatList.Count()>nEntry)
+ if( aCurrencyFormatList.size() > static_cast<size_t>(nEntry) )
return *aCurrencyFormatList[nEntry];
}
else
@@ -1478,15 +1486,12 @@ short SvxNumberFormatShell::GetListPos4Entry( const String& rFmtString )
}
else
{
- if(aCurrencyFormatList.Count()>0)
+ for( size_t i=0; i<aCurrencyFormatList.size(); i++ )
{
- for(sal_uInt16 i=0;i<aCurrencyFormatList.Count();i++)
+ if (rFmtString==*aCurrencyFormatList[i])
{
- if (rFmtString==*aCurrencyFormatList[i])
- {
- nSelP=i;
- break;
- }
+ nSelP = static_cast<short>(i);
+ break;
}
}
}
--
1.7.7.4
Context
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.