summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2012-02-06 12:50:59 +0200
committerEike Rathke <erack@redhat.com>2012-02-08 13:15:30 +0100
commit0979307bbf769399f97da10a29f04936a6cf117c (patch)
treef04aea01ba738e29902aceaeeb720fc73a00a408 /svl
parent809fd00863026cdff4bf2de7d02956d39e867eeb (diff)
tools/table.hxx to std::map conversion in SV, SVL and SVX modules
This patch converts one use of tools/table.hxx in svl/inc/svl/zforlist.hxx, whose use in turn spans 3 modules.
Diffstat (limited to 'svl')
-rw-r--r--svl/inc/svl/zforlist.hxx26
-rw-r--r--svl/source/misc/inettype.cxx1
-rw-r--r--svl/source/numbers/numfmuno.cxx7
-rw-r--r--svl/source/numbers/zforlist.cxx269
4 files changed, 154 insertions, 149 deletions
diff --git a/svl/inc/svl/zforlist.hxx b/svl/inc/svl/zforlist.hxx
index ac387d472f35..14229a06c6d1 100644
--- a/svl/inc/svl/zforlist.hxx
+++ b/svl/inc/svl/zforlist.hxx
@@ -30,7 +30,6 @@
#include "svl/svldllapi.h"
#include <tools/string.hxx>
-#include <tools/table.hxx>
#include <i18npool/lang.h>
#include <svl/svarray.hxx>
#include <com/sun/star/uno/Reference.hxx>
@@ -214,10 +213,10 @@ enum NfEvalDateFormat
};
-DECLARE_TABLE (SvNumberFormatTable, SvNumberformat*)
-DECLARE_TABLE (SvNumberFormatterIndexTable, sal_uInt32*)
+typedef std::map<sal_uInt32, SvNumberformat*> SvNumberFormatTable;
+typedef std::map<sal_uInt16, sal_uInt32> SvNumberFormatterIndexTable;
-typedef ::std::map< sal_uInt32, sal_uInt32 > SvNumberFormatterMergeMap;
+typedef ::std::map< sal_uInt32, sal_uInt32> SvNumberFormatterMergeMap;
typedef ::std::set< LanguageType > NfInstalledLocales;
@@ -563,7 +562,7 @@ public:
/// Return the format for a format index
const SvNumberformat* GetEntry(sal_uInt32 nKey) const
- { return (SvNumberformat*) aFTable.Get(nKey); }
+ { SvNumberFormatTable::const_iterator it = aFTable.find(nKey); return it == aFTable.end() ? 0 : it->second; }
/// Return the format index of the standard default number format for language/country
sal_uInt32 GetStandardIndex(LanguageType eLnge = LANGUAGE_DONTKNOW);
@@ -801,7 +800,8 @@ private:
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceManager;
::com::sun::star::lang::Locale aLocale;
SvNumberFormatTable aFTable; // Table of format keys to format entries
- Table aDefaultFormatKeys; // Table of default standard to format keys
+ typedef std::map<sal_uInt32, sal_uInt32> DefaultFormatKeysMap;
+ DefaultFormatKeysMap aDefaultFormatKeys; // Table of default standard to format keys
SvNumberFormatTable* pFormatTable; // For the UI dialog
SvNumberFormatterIndexTable* pMergeTable; // List of indices for merging two formatters
CharClass* pCharClass; // CharacterClassification
@@ -913,6 +913,9 @@ private:
sal_Int32 nCount, bool bCheckCorrectness = true
);
+ SVL_DLLPRIVATE SvNumberformat* GetFormatEntry(sal_uInt32 nKey);
+ SVL_DLLPRIVATE const SvNumberformat* GetFormatEntry(sal_uInt32 nKey) const;
+
// used as a loop body inside of GetNewCurrencySymbolString() and GetCurrencyEntry()
#ifndef DBG_UTIL
inline
@@ -998,13 +1001,18 @@ public:
inline sal_uInt32 SvNumberFormatter::GetMergeFmtIndex( sal_uInt32 nOldFmt ) const
{
- sal_uInt32* pU = (pMergeTable && pMergeTable->Count()) ? (sal_uInt32*)pMergeTable->Get( nOldFmt ) : 0;
- return pU ? *pU : nOldFmt;
+ if (pMergeTable)
+ {
+ SvNumberFormatterIndexTable::iterator it = pMergeTable->find(nOldFmt);
+ if (it != pMergeTable->end())
+ return it->second;
+ }
+ return nOldFmt;
}
inline bool SvNumberFormatter::HasMergeFmtTbl() const
{
- return pMergeTable && (0 != pMergeTable->Count());
+ return pMergeTable && !pMergeTable->empty();
}
diff --git a/svl/source/misc/inettype.cxx b/svl/source/misc/inettype.cxx
index c68e52868556..edf11cbdcb17 100644
--- a/svl/source/misc/inettype.cxx
+++ b/svl/source/misc/inettype.cxx
@@ -26,7 +26,6 @@
*
************************************************************************/
-#include <tools/table.hxx>
#include <tools/wldcrd.hxx>
#include <rtl/instance.hxx>
#include <svl/inettype.hxx>
diff --git a/svl/source/numbers/numfmuno.cxx b/svl/source/numbers/numfmuno.cxx
index cd7761ed3732..ceb316bb4c43 100644
--- a/svl/source/numbers/numfmuno.cxx
+++ b/svl/source/numbers/numfmuno.cxx
@@ -463,11 +463,12 @@ uno::Sequence<sal_Int32> SAL_CALL SvNumberFormatsObj::queryKeys( sal_Int16 nType
SvNumberFormatTable& rTable = bCreate ?
pFormatter->ChangeCL( nType, nIndex, eLang ) :
pFormatter->GetEntryTable( nType, nIndex, eLang );
- sal_uInt32 nCount = rTable.Count();
+ sal_uInt32 nCount = rTable.size();
uno::Sequence<sal_Int32> aSeq(nCount);
sal_Int32* pAry = aSeq.getArray();
- for (sal_uInt32 i=0; i<nCount; i++)
- pAry[i] = rTable.GetObjectKey( i );
+ sal_uInt32 i=0;
+ for (SvNumberFormatTable::iterator it = rTable.begin(); it != rTable.end(); ++it, ++i)
+ pAry[i] = it->first;
return aSeq;
}
diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx
index 1f5085da16a1..e540ac322cfb 100644
--- a/svl/source/numbers/zforlist.cxx
+++ b/svl/source/numbers/zforlist.cxx
@@ -62,6 +62,7 @@ using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::i18n;
using namespace ::com::sun::star::lang;
+using namespace ::std;
using ::rtl::OUString;
@@ -215,12 +216,8 @@ SvNumberFormatter::~SvNumberFormatter()
}
}
- SvNumberformat* pEntry = aFTable.First();
- while (pEntry)
- {
- delete pEntry;
- pEntry = aFTable.Next();
- }
+ for (SvNumberFormatTable::iterator it = aFTable.begin(); it != aFTable.end(); ++it)
+ delete it->second;
delete pFormatTable;
delete pCharClass;
delete pStringScanner;
@@ -360,24 +357,21 @@ void SvNumberFormatter::ImpChangeSysCL( LanguageType eLnge, bool bLoadingSO5 )
{
IniLnge = eLnge;
ChangeIntl(eLnge);
- SvNumberformat* pEntry = aFTable.First();
- while (pEntry) // delete old formats
- {
- pEntry = (SvNumberformat*) aFTable.Remove(aFTable.GetCurKey());
- delete pEntry;
- pEntry = (SvNumberformat*) aFTable.First();
- }
+ // delete old formats
+ for (SvNumberFormatTable::iterator it = aFTable.begin(); it != aFTable.end(); ++it)
+ delete it->second;
ImpGenerateFormats( 0, bLoadingSO5 ); // new standard formats
}
else if ( bLoadingSO5 )
{ // delete additional standard formats
sal_uInt32 nKey;
- aFTable.Seek( SV_MAX_ANZ_STANDARD_FORMATE + 1 );
- while ( (nKey = aFTable.GetCurKey()) > SV_MAX_ANZ_STANDARD_FORMATE &&
+ SvNumberFormatTable::iterator it = aFTable.find( SV_MAX_ANZ_STANDARD_FORMATE + 1 );
+ while ( (nKey = it->first) > SV_MAX_ANZ_STANDARD_FORMATE &&
nKey < SV_COUNTRY_LANGUAGE_OFFSET )
{
- SvNumberformat* pEntry = (SvNumberformat*) aFTable.Remove( nKey );
- delete pEntry;
+ delete it->second;
+ aFTable.erase( it );
+ ++it;
}
}
}
@@ -394,19 +388,21 @@ void SvNumberFormatter::ReplaceSystemCL( LanguageType eOldLanguage )
sal_uInt32 nKey;
// remove old builtin formats
- aFTable.Seek( nCLOffset );
- while ( (nKey = aFTable.GetCurKey()) >= nCLOffset && nKey <= nMaxBuiltin && aFTable.Count() )
+ SvNumberFormatTable::iterator it = aFTable.find( nCLOffset );
+ while ( it != aFTable.end() && (nKey = it->first) >= nCLOffset && nKey <= nMaxBuiltin )
{
- SvNumberformat* pEntry = (SvNumberformat*) aFTable.Remove( nKey );
- delete pEntry;
+ delete it->second;
+ aFTable.erase( it );
+ ++it;
}
// move additional and user defined to temporary table
- Table aOldTable;
- while ( (nKey = aFTable.GetCurKey()) >= nCLOffset && nKey < nNextCL && aFTable.Count() )
+ SvNumberFormatTable aOldTable;
+ while ( it != aFTable.end() && (nKey = it->first) >= nCLOffset && nKey < nNextCL )
{
- SvNumberformat* pEntry = (SvNumberformat*) aFTable.Remove( nKey );
- aOldTable.Insert( nKey, pEntry );
+ aOldTable[ nKey ] = it->second;
+ aFTable.erase( it );
+ ++it;
}
// generate new old builtin formats
@@ -416,16 +412,16 @@ void SvNumberFormatter::ReplaceSystemCL( LanguageType eOldLanguage )
ImpGenerateFormats( nCLOffset, true );
// convert additional and user defined from old system to new system
- SvNumberformat* pStdFormat = (SvNumberformat*) aFTable.Get( nCLOffset + ZF_STANDARD );
+ SvNumberformat* pStdFormat = GetFormatEntry( nCLOffset + ZF_STANDARD );
sal_uInt32 nLastKey = nMaxBuiltin;
pFormatScanner->SetConvertMode( eOldLanguage, LANGUAGE_SYSTEM, true );
- aOldTable.First();
- while ( aOldTable.Count() )
+ while ( !aOldTable.empty() )
{
- nKey = aOldTable.GetCurKey();
+ nKey = aOldTable.begin()->first;
if ( nLastKey < nKey )
nLastKey = nKey;
- SvNumberformat* pOldEntry = (SvNumberformat*) aOldTable.Remove( nKey );
+ SvNumberformat* pOldEntry = aOldTable.begin()->second;
+ aOldTable.erase( nKey );
String aString( pOldEntry->GetFormatstring() );
xub_StrLen nCheckPos = STRING_NOTFOUND;
@@ -446,7 +442,7 @@ void SvNumberFormatter::ReplaceSystemCL( LanguageType eOldLanguage )
else
pNewEntry->SetType( NUMBERFORMAT_DEFINED );
- if ( !aFTable.Insert( nKey, pNewEntry ) )
+ if ( !aFTable.insert( make_pair(nKey, pNewEntry) ).second )
delete pNewEntry;
else
bCheck = true;
@@ -467,7 +463,7 @@ void SvNumberFormatter::ReplaceSystemCL( LanguageType eOldLanguage )
bool SvNumberFormatter::IsTextFormat(sal_uInt32 F_Index) const
{
- SvNumberformat* pFormat = (SvNumberformat*) aFTable.Get(F_Index);
+ const SvNumberformat* pFormat = GetFormatEntry(F_Index);
if (!pFormat)
return false;
else
@@ -518,14 +514,14 @@ bool SvNumberFormatter::PutEntry(String& rString,
else
{
SvNumberformat* pStdFormat =
- (SvNumberformat*) aFTable.Get(CLOffset + ZF_STANDARD);
+ GetFormatEntry(CLOffset + ZF_STANDARD);
sal_uInt32 nPos = CLOffset + pStdFormat->GetLastInsertKey();
if (nPos - CLOffset >= SV_COUNTRY_LANGUAGE_OFFSET)
{
OSL_FAIL("SvNumberFormatter:: Zu viele Formate pro CL");
delete p_Entry;
}
- else if (!aFTable.Insert(nPos+1,p_Entry))
+ else if (!aFTable.insert(make_pair(nPos+1,p_Entry)).second)
delete p_Entry;
else
{
@@ -658,8 +654,8 @@ sal_uInt32 SvNumberFormatter::GetIndexPuttingAndConverting( String & rString,
void SvNumberFormatter::DeleteEntry(sal_uInt32 nKey)
{
- SvNumberformat* pEntry = aFTable.Remove(nKey);
- delete pEntry;
+ delete aFTable[nKey];
+ aFTable.erase(nKey);
}
bool SvNumberFormatter::Load( SvStream& rStream )
@@ -820,11 +816,11 @@ bool SvNumberFormatter::Load( SvStream& rStream )
}
if ( nOffset == 0 ) // StandardFormat
{
- SvNumberformat* pEnt = aFTable.Get(nPos);
+ SvNumberformat* pEnt = GetFormatEntry(nPos);
if (pEnt)
pEnt->SetLastInsertKey(pEntry->GetLastInsertKey());
}
- if (!aFTable.Insert(nPos, pEntry))
+ if (!aFTable.insert(make_pair(nPos, pEntry)).second)
delete pEntry;
rStream >> nPos;
}
@@ -873,23 +869,24 @@ bool SvNumberFormatter::Save( SvStream& rStream ) const
// ab 364i wird gespeichert was SYSTEM wirklich war, vorher hart LANGUAGE_SYSTEM
rStream << (sal_uInt16) SV_NUMBERFORMATTER_VERSION;
rStream << (sal_uInt16) SvtSysLocale().GetLanguage() << (sal_uInt16) IniLnge;
- SvNumberFormatTable* pTable = (SvNumberFormatTable*) &aFTable;
- SvNumberformat* pEntry = (SvNumberformat*) pTable->First();
- while (pEntry)
+ const SvNumberFormatTable* pTable = &aFTable;
+ SvNumberFormatTable::const_iterator it = pTable->begin();
+ while (it != pTable->end())
{
+ SvNumberformat* pEntry = it->second;
// Gespeichert werden alle markierten, benutzerdefinierten Formate und
// jeweils das Standardformat zu allen angewaehlten CL-Kombinationen
// sowie NewStandardDefined
if ( pEntry->GetUsed() || (pEntry->GetType() & NUMBERFORMAT_DEFINED) ||
pEntry->GetNewStandardDefined() ||
- (pTable->GetCurKey() % SV_COUNTRY_LANGUAGE_OFFSET == 0) )
+ (it->first % SV_COUNTRY_LANGUAGE_OFFSET == 0) )
{
- rStream << static_cast<sal_uInt32>(pTable->GetCurKey())
+ rStream << it->first
<< (sal_uInt16) LANGUAGE_SYSTEM
<< (sal_uInt16) pEntry->GetLanguage();
pEntry->Save(rStream, aHdr);
}
- pEntry = (SvNumberformat*) pTable->Next();
+ ++it;
}
rStream << NUMBERFORMAT_ENTRY_NOT_FOUND; // EndeKennung
@@ -911,7 +908,7 @@ void SvNumberFormatter::GetUsedLanguages( std::vector<sal_uInt16>& rList )
sal_uInt32 nOffset = 0;
while (nOffset <= MaxCLOffset)
{
- SvNumberformat* pFormat = (SvNumberformat*) aFTable.Get(nOffset);
+ SvNumberformat* pFormat = GetFormatEntry(nOffset);
if (pFormat)
rList.push_back( pFormat->GetLanguage() );
nOffset += SV_COUNTRY_LANGUAGE_OFFSET;
@@ -952,11 +949,10 @@ String SvNumberFormatter::GetStandardName( LanguageType eLnge )
sal_uInt32 SvNumberFormatter::ImpGetCLOffset(LanguageType eLnge) const
{
- SvNumberformat* pFormat;
sal_uInt32 nOffset = 0;
while (nOffset <= MaxCLOffset)
{
- pFormat = (SvNumberformat*) aFTable.Get(nOffset);
+ const SvNumberformat* pFormat = GetFormatEntry(nOffset);
if (pFormat && pFormat->GetLanguage() == eLnge)
return nOffset;
nOffset += SV_COUNTRY_LANGUAGE_OFFSET;
@@ -969,15 +965,14 @@ sal_uInt32 SvNumberFormatter::ImpIsEntry(const String& rString,
LanguageType eLnge)
{
sal_uInt32 res = NUMBERFORMAT_ENTRY_NOT_FOUND;
- SvNumberformat* pEntry;
- pEntry = (SvNumberformat*) aFTable.Seek(nCLOffset);
+ SvNumberFormatTable::iterator it = aFTable.find(nCLOffset);
while ( res == NUMBERFORMAT_ENTRY_NOT_FOUND &&
- pEntry && pEntry->GetLanguage() == eLnge )
+ it != aFTable.end() && it->second->GetLanguage() == eLnge )
{
- if ( rString == pEntry->GetFormatstring() )
- res = aFTable.GetCurKey();
+ if ( rString == it->second->GetFormatstring() )
+ res = it->first;
else
- pEntry = (SvNumberformat*) aFTable.Next();
+ ++it;
}
return res;
}
@@ -993,7 +988,7 @@ SvNumberFormatTable& SvNumberFormatter::GetFirstEntryTable(
rLnge = IniLnge;
else
{
- SvNumberformat* pFormat = (SvNumberformat*) aFTable.Get(FIndex);
+ SvNumberformat* pFormat = GetFormatEntry(FIndex);
if (!pFormat)
{
// OSL_FAIL("SvNumberFormatter:: Unbekanntes altes Zahlformat (1)");
@@ -1105,7 +1100,7 @@ SvNumberFormatTable& SvNumberFormatter::GetEntryTable(
LanguageType eLnge)
{
if ( pFormatTable )
- pFormatTable->Clear();
+ pFormatTable->clear();
else
pFormatTable = new SvNumberFormatTable;
ChangeIntl(eLnge);
@@ -1115,30 +1110,29 @@ SvNumberFormatTable& SvNumberFormatter::GetEntryTable(
// (e.g. currency) => has to be done before collecting formats.
sal_uInt32 nDefaultIndex = GetStandardFormat( eType, ActLnge );
- SvNumberformat* pEntry;
- pEntry = (SvNumberformat*) aFTable.Seek(CLOffset);
+ SvNumberFormatTable::iterator it = aFTable.find(CLOffset);
if (eType == NUMBERFORMAT_ALL)
{
- while (pEntry && pEntry->GetLanguage() == ActLnge)
+ while (it != aFTable.end() && it->second->GetLanguage() == ActLnge)
{ // copy all entries to output table
- pFormatTable->Insert( aFTable.GetCurKey(), pEntry );
- pEntry = (SvNumberformat*) aFTable.Next();
+ (*pFormatTable)[ it->first ] = it->second;
+ ++it;
}
}
else
{
- while (pEntry && pEntry->GetLanguage() == ActLnge)
+ while (it != aFTable.end() && it->second->GetLanguage() == ActLnge)
{ // copy entries of queried type to output table
- if ((pEntry->GetType()) & eType)
- pFormatTable->Insert(aFTable.GetCurKey(),pEntry);
- pEntry = (SvNumberformat*) aFTable.Next();
+ if ((it->second->GetType()) & eType)
+ (*pFormatTable)[ it->first ] = it->second;
+ ++it;
}
}
- if ( pFormatTable->Count() > 0 )
+ if ( !pFormatTable->empty() )
{ // select default if queried format doesn't exist or queried type or
// language differ from existing format
- pEntry = aFTable.Get(FIndex);
+ SvNumberformat* pEntry = GetFormatEntry(FIndex);
if ( !pEntry || !(pEntry->GetType() & eType) || pEntry->GetLanguage() != ActLnge )
FIndex = nDefaultIndex;
}
@@ -1150,7 +1144,7 @@ bool SvNumberFormatter::IsNumberFormat(const String& sString,
double& fOutNumber)
{
short FType;
- const SvNumberformat* pFormat = (SvNumberformat*) aFTable.Get(F_Index);
+ const SvNumberformat* pFormat = GetFormatEntry(F_Index);
if (!pFormat)
{
ChangeIntl(IniLnge);
@@ -1293,25 +1287,25 @@ sal_uInt32 SvNumberFormatter::ImpGetDefaultFormat( short nType )
default:
nSearch = CLOffset + ZF_STANDARD;
}
- sal_uInt32 nDefaultFormat = (sal_uInt32)(sal_uLong) aDefaultFormatKeys.Get( nSearch );
- if ( !nDefaultFormat )
- nDefaultFormat = NUMBERFORMAT_ENTRY_NOT_FOUND;
+ sal_uInt32 nDefaultFormat = NUMBERFORMAT_ENTRY_NOT_FOUND;
+ DefaultFormatKeysMap::iterator it = aDefaultFormatKeys.find(nSearch);
+ if ( it != aDefaultFormatKeys.end() )
+ nDefaultFormat = it->second;
if ( nDefaultFormat == NUMBERFORMAT_ENTRY_NOT_FOUND )
{ // look for a defined standard
sal_uInt32 nStopKey = CLOffset + SV_COUNTRY_LANGUAGE_OFFSET;
sal_uInt32 nKey;
- aFTable.Seek( CLOffset );
- while ( (nKey = aFTable.GetCurKey()) >= CLOffset && nKey < nStopKey )
+ SvNumberFormatTable::iterator it2 = aFTable.find( CLOffset );
+ while ( (nKey = it2->first ) >= CLOffset && nKey < nStopKey )
{
- const SvNumberformat* pEntry =
- (const SvNumberformat*) aFTable.GetCurObject();
+ const SvNumberformat* pEntry = it2->second;
if ( pEntry->IsStandard() && ((pEntry->GetType() &
~NUMBERFORMAT_DEFINED) == nType) )
{
nDefaultFormat = nKey;
break; // while
}
- aFTable.Next();
+ ++it2;
}
if ( nDefaultFormat == NUMBERFORMAT_ENTRY_NOT_FOUND )
@@ -1338,7 +1332,7 @@ sal_uInt32 SvNumberFormatter::ImpGetDefaultFormat( short nType )
}
}
sal_uIntPtr nFormat = nDefaultFormat;
- aDefaultFormatKeys.Insert( nSearch, (void*) nFormat );
+ aDefaultFormatKeys[ nSearch ] = nFormat;
}
return nDefaultFormat;
}
@@ -1495,11 +1489,10 @@ void SvNumberFormatter::GetInputLineString(const double& fOutNumber,
sal_uInt32 nFIndex,
String& sOutString)
{
- SvNumberformat* pFormat;
Color* pColor;
- pFormat = (SvNumberformat*) aFTable.Get(nFIndex);
+ SvNumberformat* pFormat = GetFormatEntry( nFIndex );
if (!pFormat)
- pFormat = aFTable.Get(ZF_STANDARD);
+ pFormat = GetFormatEntry(ZF_STANDARD);
LanguageType eLang = pFormat->GetLanguage();
ChangeIntl( eLang );
short eType = pFormat->GetType() & ~NUMBERFORMAT_DEFINED;
@@ -1519,7 +1512,7 @@ void SvNumberFormatter::GetInputLineString(const double& fOutNumber,
}
sal_uInt32 nKey = GetEditFormat( fOutNumber, nFIndex, eType, eLang, pFormat);
if ( nKey != nFIndex )
- pFormat = (SvNumberformat*) aFTable.Get( nKey );
+ pFormat = GetFormatEntry( nKey );
if (pFormat)
{
if ( eType == NUMBERFORMAT_TIME && pFormat->GetFormatPrecision() )
@@ -1552,9 +1545,9 @@ void SvNumberFormatter::GetOutputString(const double& fOutNumber,
sOutString.Erase();
return;
}
- SvNumberformat* pFormat = (SvNumberformat*) aFTable.Get(nFIndex);
+ SvNumberformat* pFormat = GetFormatEntry( nFIndex );
if (!pFormat)
- pFormat = aFTable.Get(ZF_STANDARD);
+ pFormat = GetFormatEntry(ZF_STANDARD);
ChangeIntl(pFormat->GetLanguage());
pFormat->GetOutputString(fOutNumber, sOutString, ppColor);
}
@@ -1564,9 +1557,9 @@ void SvNumberFormatter::GetOutputString(String& sString,
String& sOutString,
Color** ppColor)
{
- SvNumberformat* pFormat = (SvNumberformat*) aFTable.Get(nFIndex);
+ SvNumberformat* pFormat = GetFormatEntry( nFIndex );
if (!pFormat)
- pFormat = aFTable.Get(ZF_STANDARD_TEXT);
+ pFormat = GetFormatEntry(ZF_STANDARD_TEXT);
if (!pFormat->IsTextFormat() && !pFormat->HasTextFormat())
{
*ppColor = NULL;
@@ -1894,7 +1887,7 @@ SvNumberformat* SvNumberFormatter::ImpInsertFormat(
return NULL;
}
}
- if ( !aFTable.Insert( nPos, pFormat ) )
+ if ( !aFTable.insert( make_pair(nPos, pFormat) ).second )
{
if (LocaleDataWrapper::areChecksEnabled())
{
@@ -1938,7 +1931,7 @@ void SvNumberFormatter::GetFormatSpecialInfo(sal_uInt32 nFormat,
sal_uInt16& nAnzLeading)
{
- const SvNumberformat* pFormat = aFTable.Get(nFormat);
+ SvNumberformat* pFormat = GetFormatEntry( nFormat );
if (pFormat)
pFormat->GetFormatSpecialInfo(bThousand, IsRed,
nPrecision, nAnzLeading);
@@ -1953,7 +1946,7 @@ void SvNumberFormatter::GetFormatSpecialInfo(sal_uInt32 nFormat,
sal_uInt16 SvNumberFormatter::GetFormatPrecision( sal_uInt32 nFormat ) const
{
- const SvNumberformat* pFormat = aFTable.Get( nFormat );
+ const SvNumberformat* pFormat = GetFormatEntry( nFormat );
if ( pFormat )
return pFormat->GetFormatPrecision();
else
@@ -1963,7 +1956,7 @@ sal_uInt16 SvNumberFormatter::GetFormatPrecision( sal_uInt32 nFormat ) const
String SvNumberFormatter::GetFormatDecimalSep( sal_uInt32 nFormat ) const
{
- const SvNumberformat* pFormat = aFTable.Get( nFormat );
+ const SvNumberformat* pFormat = GetFormatEntry(nFormat);
if ( !pFormat || pFormat->GetLanguage() == ActLnge )
return GetNumDecimalSep();
@@ -2188,6 +2181,21 @@ sal_Int32 SvNumberFormatter::ImpAdjustFormatCodeDefault(
return nDef;
}
+SvNumberformat* SvNumberFormatter::GetFormatEntry(sal_uInt32 nKey)
+{
+ SvNumberFormatTable::iterator it = aFTable.find(nKey);
+ if (it != aFTable.end())
+ return it->second;
+ return 0;
+}
+
+const SvNumberformat* SvNumberFormatter::GetFormatEntry(sal_uInt32 nKey) const
+{
+ SvNumberFormatTable::const_iterator it = aFTable.find(nKey);
+ if (it != aFTable.end())
+ return it->second;
+ return 0;
+}
void SvNumberFormatter::ImpGenerateFormats( sal_uInt32 CLOffset, bool bLoadingSO5 )
{
@@ -2259,9 +2267,9 @@ void SvNumberFormatter::ImpGenerateFormats( sal_uInt32 CLOffset, bool bLoadingSO
pFormatScanner, pStringScanner, nCheckPos, ActLnge );
pNewFormat->SetType(NUMBERFORMAT_LOGICAL);
pNewFormat->SetStandard();
- if ( !aFTable.Insert(
+ if ( !aFTable.insert(make_pair(
CLOffset + SetIndexTable( NF_BOOLEAN, ZF_STANDARD_LOGICAL ),
- pNewFormat))
+ pNewFormat)).second)
delete pNewFormat;
// Text
@@ -2270,9 +2278,9 @@ void SvNumberFormatter::ImpGenerateFormats( sal_uInt32 CLOffset, bool bLoadingSO
pFormatScanner, pStringScanner, nCheckPos, ActLnge );
pNewFormat->SetType(NUMBERFORMAT_TEXT);
pNewFormat->SetStandard();
- if ( !aFTable.Insert(
+ if ( !aFTable.insert(make_pair(
CLOffset + SetIndexTable( NF_TEXT, ZF_STANDARD_TEXT ),
- pNewFormat))
+ pNewFormat)).second)
delete pNewFormat;
@@ -2642,8 +2650,7 @@ void SvNumberFormatter::ImpGenerateAdditionalFormats( sal_uInt32 CLOffset,
{
using namespace ::com::sun::star;
- SvNumberformat* pStdFormat =
- (SvNumberformat*) aFTable.Get( CLOffset + ZF_STANDARD );
+ SvNumberformat* pStdFormat = GetFormatEntry( CLOffset + ZF_STANDARD );
if ( !pStdFormat )
{
SAL_WARN( "svl.numbers", "ImpGenerateAdditionalFormats: no GENERAL format" );
@@ -2747,7 +2754,7 @@ void SvNumberFormatter::GenerateFormat(String& sString,
const xub_StrLen nDigitsInFirstGroup = static_cast<xub_StrLen>(aGrouping.get());
const String& rThSep = GetNumThousandSep();
- SvNumberformat* pFormat = (SvNumberformat*) aFTable.Get(nIndex);
+ SvNumberformat* pFormat = GetFormatEntry( nIndex );
if (nAnzLeading == 0)
{
@@ -2891,7 +2898,7 @@ bool SvNumberFormatter::IsUserDefined(const String& sStr,
sal_uInt32 nKey = ImpIsEntry(sStr, CLOffset, eLnge);
if (nKey == NUMBERFORMAT_ENTRY_NOT_FOUND)
return true;
- SvNumberformat* pEntry = aFTable.Get(nKey);
+ SvNumberformat* pEntry = GetFormatEntry( nKey );
if ( pEntry && ((pEntry->GetType() & NUMBERFORMAT_DEFINED) != 0) )
return true;
return false;
@@ -2917,7 +2924,7 @@ sal_uInt32 SvNumberFormatter::GetStandardIndex(LanguageType eLnge)
short SvNumberFormatter::GetType(sal_uInt32 nFIndex)
{
short eType;
- SvNumberformat* pFormat = (SvNumberformat*) aFTable.Get(nFIndex);
+ SvNumberformat* pFormat = GetFormatEntry( nFIndex );
if (!pFormat)
eType = NUMBERFORMAT_UNDEFINED;
else
@@ -2933,13 +2940,7 @@ void SvNumberFormatter::ClearMergeTable()
{
if ( pMergeTable )
{
- sal_uInt32* pIndex = (sal_uInt32*) pMergeTable->First();
- while (pIndex)
- {
- delete pIndex;
- pIndex = pMergeTable->Next();
- }
- pMergeTable->Clear();
+ pMergeTable->clear();
}
}
@@ -2951,12 +2952,12 @@ SvNumberFormatterIndexTable* SvNumberFormatter::MergeFormatter(SvNumberFormatter
pMergeTable = new SvNumberFormatterIndexTable;
sal_uInt32 nCLOffset = 0;
sal_uInt32 nOldKey, nOffset, nNewKey;
- sal_uInt32* pNewIndex;
SvNumberformat* pNewEntry;
- SvNumberformat* pFormat = rTable.aFTable.First();
- while (pFormat)
+ SvNumberFormatTable::iterator it = rTable.aFTable.begin();
+ while (it != rTable.aFTable.end())
{
- nOldKey = rTable.aFTable.GetCurKey();
+ SvNumberformat* pFormat = it->second;
+ nOldKey = it->first;
nOffset = nOldKey % SV_COUNTRY_LANGUAGE_OFFSET; // relativIndex
if (nOffset == 0) // 1. Format von CL
nCLOffset = ImpGenerateCL(pFormat->GetLanguage());
@@ -2964,18 +2965,16 @@ SvNumberFormatterIndexTable* SvNumberFormatter::MergeFormatter(SvNumberFormatter
if (nOffset <= SV_MAX_ANZ_STANDARD_FORMATE) // Std.form.
{
nNewKey = nCLOffset + nOffset;
- if (!aFTable.Get(nNewKey)) // noch nicht da
+ if (aFTable.find(nNewKey) == aFTable.end()) // noch nicht da
{
// pNewEntry = new SvNumberformat(*pFormat); // Copy reicht nicht !!!
pNewEntry = new SvNumberformat( *pFormat, *pFormatScanner );
- if (!aFTable.Insert(nNewKey, pNewEntry))
+ if (!aFTable.insert(make_pair(nNewKey, pNewEntry)).second)
delete pNewEntry;
}
if (nNewKey != nOldKey) // neuer Index
{
- pNewIndex = new sal_uInt32(nNewKey);
- if (!pMergeTable->Insert(nOldKey,pNewIndex))
- delete pNewIndex;
+ (*pMergeTable)[nOldKey] = nNewKey;
}
}
else // benutzerdef.
@@ -2990,7 +2989,7 @@ SvNumberFormatterIndexTable* SvNumberFormatter::MergeFormatter(SvNumberFormatter
else
{
SvNumberformat* pStdFormat =
- (SvNumberformat*) aFTable.Get(nCLOffset + ZF_STANDARD);
+ GetFormatEntry(nCLOffset + ZF_STANDARD);
sal_uInt32 nPos = nCLOffset + pStdFormat->GetLastInsertKey();
nNewKey = nPos+1;
if (nPos - nCLOffset >= SV_COUNTRY_LANGUAGE_OFFSET)
@@ -2999,19 +2998,17 @@ SvNumberFormatterIndexTable* SvNumberFormatter::MergeFormatter(SvNumberFormatter
"SvNumberFormatter:: Zu viele Formate pro CL");
delete pNewEntry;
}
- else if (!aFTable.Insert(nNewKey, pNewEntry))
+ else if (!aFTable.insert(make_pair(nNewKey, pNewEntry)).second)
delete pNewEntry;
else
pStdFormat->SetLastInsertKey((sal_uInt16) (nNewKey - nCLOffset));
}
if (nNewKey != nOldKey) // neuer Index
{
- pNewIndex = new sal_uInt32(nNewKey);
- if (!pMergeTable->Insert(nOldKey,pNewIndex))
- delete pNewIndex;
+ (*pMergeTable)[nOldKey] = nNewKey;
}
}
- pFormat = rTable.aFTable.Next();
+ ++it;
}
return pMergeTable;
}
@@ -3023,11 +3020,11 @@ SvNumberFormatterMergeMap SvNumberFormatter::ConvertMergeTableToMap()
return SvNumberFormatterMergeMap();
SvNumberFormatterMergeMap aMap;
- for (sal_uInt32* pIndex = pMergeTable->First(); pIndex; pIndex = pMergeTable->Next())
- {
- sal_uInt32 nOldKey = pMergeTable->GetCurKey();
- aMap.insert( SvNumberFormatterMergeMap::value_type( nOldKey, *pIndex));
- }
+ for (SvNumberFormatterIndexTable::iterator it = pMergeTable->begin(); it != pMergeTable->end(); ++it)
+ {
+ sal_uInt32 nOldKey = it->first;
+ aMap[ nOldKey ] = it->second;
+ }
ClearMergeTable();
return aMap;
}
@@ -3261,26 +3258,27 @@ sal_uInt32 SvNumberFormatter::ImpGetDefaultSystemCurrencyFormat()
sal_uInt32 SvNumberFormatter::ImpGetDefaultCurrencyFormat()
{
sal_uInt32 CLOffset = ImpGetCLOffset( ActLnge );
- sal_uInt32 nDefaultCurrencyFormat =
- (sal_uInt32)(sal_uLong) aDefaultFormatKeys.Get( CLOffset + ZF_STANDARD_CURRENCY );
- if ( !nDefaultCurrencyFormat )
+ sal_uInt32 nDefaultCurrencyFormat;
+ DefaultFormatKeysMap::iterator it = aDefaultFormatKeys.find( CLOffset + ZF_STANDARD_CURRENCY );
+ if ( it != aDefaultFormatKeys.end() )
+ nDefaultCurrencyFormat = it->second;
+ else
nDefaultCurrencyFormat = NUMBERFORMAT_ENTRY_NOT_FOUND;
if ( nDefaultCurrencyFormat == NUMBERFORMAT_ENTRY_NOT_FOUND )
{
// look for a defined standard
sal_uInt32 nStopKey = CLOffset + SV_COUNTRY_LANGUAGE_OFFSET;
sal_uInt32 nKey;
- aFTable.Seek( CLOffset );
- while ( (nKey = aFTable.GetCurKey()) >= CLOffset && nKey < nStopKey )
+ SvNumberFormatTable::iterator it2 = aFTable.lower_bound( CLOffset );
+ while ( (nKey = it2->first) >= CLOffset && nKey < nStopKey )
{
- const SvNumberformat* pEntry =
- (const SvNumberformat*) aFTable.GetCurObject();
+ const SvNumberformat* pEntry = it2->second;
if ( pEntry->IsStandard() && (pEntry->GetType() & NUMBERFORMAT_CURRENCY) )
{
nDefaultCurrencyFormat = nKey;
break; // while
}
- aFTable.Next();
+ ++it2;
}
if ( nDefaultCurrencyFormat == NUMBERFORMAT_ENTRY_NOT_FOUND )
@@ -3306,14 +3304,13 @@ sal_uInt32 SvNumberFormatter::ImpGetDefaultCurrencyFormat()
nDefaultCurrencyFormat = CLOffset + ZF_STANDARD_CURRENCY+3;
else
{ // mark as standard so that it is found next time
- SvNumberformat* pEntry = aFTable.Get( nDefaultCurrencyFormat );
+ SvNumberformat* pEntry = GetFormatEntry( nDefaultCurrencyFormat );
if ( pEntry )
pEntry->SetStandard();
}
}
sal_uIntPtr nFormat = nDefaultCurrencyFormat;
- aDefaultFormatKeys.Insert( CLOffset + ZF_STANDARD_CURRENCY,
- (void*) nFormat );
+ aDefaultFormatKeys[ CLOffset + ZF_STANDARD_CURRENCY ] = nFormat;
}
return nDefaultCurrencyFormat;
}
@@ -3375,7 +3372,7 @@ bool SvNumberFormatter::GetNewCurrencySymbolString( sal_uInt32 nFormat,
*ppEntry = NULL;
if ( pBank )
*pBank = false;
- SvNumberformat* pFormat = (SvNumberformat*) aFTable.Get( nFormat );
+ const SvNumberformat* pFormat = GetFormatEntry(nFormat);
if ( pFormat )
{
String aSymbol, aExtension;