diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index 02790bc..bd650b4 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -2163,7 +2163,7 @@ void ScDocument::MergeNumberFormatter(ScDocument* pSrcDoc) { SvNumberFormatterIndexTable* pExchangeList = pThisFormatter->MergeFormatter(*(pOtherFormatter)); - if (pExchangeList->Count() > 0) + if (!pExchangeList->empty()) pFormatExchangeList = pExchangeList; } } diff --git a/sc/source/core/data/patattr.cxx b/sc/source/core/data/patattr.cxx index 6de3e0a..5dfa7be 100644 --- a/sc/source/core/data/patattr.cxx +++ b/sc/source/core/data/patattr.cxx @@ -970,9 +970,12 @@ SfxStyleSheetBase* lcl_CopyStyleToPool rSrcSet.GetItemState( ATTR_VALUE_FORMAT, false, &pSrcItem ) == SFX_ITEM_SET ) { sal_uLong nOldFormat = static_cast(pSrcItem)->GetValue(); - sal_uInt32* pNewFormat = static_cast(pFormatExchangeList->Get( nOldFormat )); - if (pNewFormat) - rDestSet.Put( SfxUInt32Item( ATTR_VALUE_FORMAT, *pNewFormat ) ); + SvNumberFormatterIndexTable::const_iterator it = pFormatExchangeList->find(nOldFormat); + if (it != pFormatExchangeList->end()) + { + sal_uInt32 nNewFormat = it->second; + rDestSet.Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNewFormat ) ); + } } // ggF. abgeleitete Styles erzeugen, wenn nicht vorhanden: @@ -1075,9 +1078,12 @@ ScPatternAttr* ScPatternAttr::PutInPool( ScDocument* pDestDoc, ScDocument* pSrcD // Zahlformate nach Exchange-Liste sal_uLong nOldFormat = ((const SfxUInt32Item*)pSrcItem)->GetValue(); - sal_uInt32* pNewFormat = static_cast(pDestDoc->GetFormatExchangeList()->Get(nOldFormat)); - if (pNewFormat) - pNewItem = new SfxUInt32Item( ATTR_VALUE_FORMAT, (sal_uInt32) (*pNewFormat) ); + SvNumberFormatterIndexTable::const_iterator it = pDestDoc->GetFormatExchangeList()->find(nOldFormat); + if (it != pDestDoc->GetFormatExchangeList()->end()) + { + sal_uInt32 nNewFormat = it->second; + pNewItem = new SfxUInt32Item( ATTR_VALUE_FORMAT, nNewFormat ); + } } if ( pNewItem ) diff --git a/sc/source/core/data/stlpool.cxx b/sc/source/core/data/stlpool.cxx index f9dbef0..e98f33e 100644 --- a/sc/source/core/data/stlpool.cxx +++ b/sc/source/core/data/stlpool.cxx @@ -198,9 +198,12 @@ void ScStyleSheetPool::CopyStyleFrom( ScStyleSheetPool* pSrcPool, rSourceSet.GetItemState( ATTR_VALUE_FORMAT, false, &pItem ) == SFX_ITEM_SET ) { sal_uLong nOldFormat = static_cast(pItem)->GetValue(); - sal_uInt32* pNewFormat = static_cast(pDoc->GetFormatExchangeList()->Get( nOldFormat )); - if (pNewFormat) - rDestSet.Put( SfxUInt32Item( ATTR_VALUE_FORMAT, *pNewFormat ) ); + SvNumberFormatterIndexTable::const_iterator it = pDoc->GetFormatExchangeList()->find(nOldFormat); + if (it != pDoc->GetFormatExchangeList()->end()) + { + sal_uInt32 nNewFormat = it->second; + rDestSet.Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNewFormat ) ); + } } } } diff --git a/svl/inc/svl/zforlist.hxx b/svl/inc/svl/zforlist.hxx index ac387d4..14229a0 100644 --- a/svl/inc/svl/zforlist.hxx +++ b/svl/inc/svl/zforlist.hxx @@ -30,7 +30,6 @@ #include "svl/svldllapi.h" #include -#include #include #include #include @@ -214,10 +213,10 @@ enum NfEvalDateFormat }; -DECLARE_TABLE (SvNumberFormatTable, SvNumberformat*) -DECLARE_TABLE (SvNumberFormatterIndexTable, sal_uInt32*) +typedef std::map SvNumberFormatTable; +typedef std::map 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 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 c68e528..edf11cb 100644 --- a/svl/source/misc/inettype.cxx +++ b/svl/source/misc/inettype.cxx @@ -26,7 +26,6 @@ * ************************************************************************/ -#include #include #include #include diff --git a/svl/source/numbers/numfmuno.cxx b/svl/source/numbers/numfmuno.cxx index cd7761e..ceb316b 100644 --- a/svl/source/numbers/numfmuno.cxx +++ b/svl/source/numbers/numfmuno.cxx @@ -463,11 +463,12 @@ uno::Sequence 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 aSeq(nCount); sal_Int32* pAry = aSeq.getArray(); - for (sal_uInt32 i=0; ifirst; return aSeq; } diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx index 1f5085d..e540ac3 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(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& 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(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; diff --git a/svx/inc/svx/numfmtsh.hxx b/svx/inc/svx/numfmtsh.hxx index e9b4772..32a7da3 100644 --- a/svx/inc/svx/numfmtsh.hxx +++ b/svx/inc/svx/numfmtsh.hxx @@ -36,10 +36,12 @@ #include #include +#include class Color; class SvNumberFormatter; -class SvNumberFormatTable; +class SvNumberformat; +typedef std::map SvNumberFormatTable; class NfCurrencyEntry; enum SvxNumberValueType diff --git a/svx/source/items/numfmtsh.cxx b/svx/source/items/numfmtsh.cxx index c76f7a4..4c23829 100644 --- a/svx/source/items/numfmtsh.cxx +++ b/svx/source/items/numfmtsh.cxx @@ -672,7 +672,7 @@ short SvxNumberFormatShell::FillEListWithFormats_Impl( std::vector& rLi DBG_ASSERT( pCurFmtTable != NULL, "Unbekanntes Zahlenformat!" ); - const SvNumberformat* pNumEntry = pCurFmtTable->First(); + const SvNumberformat* pNumEntry = pCurFmtTable->empty() ? 0 : pCurFmtTable->begin()->second; sal_uInt32 nNFEntry; String aStrComment; String aNewFormNInfo; @@ -717,7 +717,7 @@ short SvxNumberFormatShell::FillEListWithDateTime_Impl( std::vector& rL DBG_ASSERT( pCurFmtTable != NULL, "Unbekanntes Zahlenformat!" ); - const SvNumberformat* pNumEntry = pCurFmtTable->First(); + const SvNumberformat* pNumEntry = pCurFmtTable->empty() ? 0 : pCurFmtTable->begin()->second; sal_uInt32 nNFEntry; String aStrComment; String aNewFormNInfo; @@ -801,7 +801,7 @@ short SvxNumberFormatShell::FillEListWithSysCurrencys( std::vector& rLi DBG_ASSERT( pCurFmtTable != NULL, "Unbekanntes Zahlenformat!" ); - const SvNumberformat* pNumEntry = pCurFmtTable->First(); + const SvNumberformat* pNumEntry = pCurFmtTable->empty() ? 0 : pCurFmtTable->begin()->second; sal_uInt32 nNFEntry; String aStrComment; String aNewFormNInfo; @@ -842,10 +842,12 @@ short SvxNumberFormatShell::FillEListWithSysCurrencys( std::vector& rLi if(nCurCategory!=NUMBERFORMAT_ALL) { - pNumEntry = pCurFmtTable->First(); - while ( pNumEntry ) + SvNumberFormatTable::iterator it = pCurFmtTable->begin(); + + while ( it != pCurFmtTable->end() ) { - sal_uInt32 nKey = pCurFmtTable->GetCurKey(); + sal_uInt32 nKey = it->first; + pNumEntry = it->second; if ( !IsRemoved_Impl( nKey )) { @@ -876,7 +878,7 @@ short SvxNumberFormatShell::FillEListWithSysCurrencys( std::vector& rLi aCurEntryList.push_back( nKey ); } } - pNumEntry = pCurFmtTable->Next(); + ++it; } } return nSelPos; @@ -943,11 +945,11 @@ short SvxNumberFormatShell::FillEListWithUserCurrencys( std::vector& rL pTmpCurrencyEntry->BuildSymbolString(rShortSymbol,bTmpBanking,true); } - const SvNumberformat* pNumEntry = pCurFmtTable->First(); - - while ( pNumEntry ) + SvNumberFormatTable::iterator it = pCurFmtTable->begin(); + while ( it != pCurFmtTable->end() ) { - sal_uInt32 nKey = pCurFmtTable->GetCurKey(); + sal_uInt32 nKey = it->first; + const SvNumberformat* pNumEntry = it->second; if ( !IsRemoved_Impl( nKey ) ) { @@ -992,7 +994,7 @@ short SvxNumberFormatShell::FillEListWithUserCurrencys( std::vector& rL } } } - pNumEntry = pCurFmtTable->Next(); + ++it; } NfWSStringsDtor aWSStringsDtor; @@ -1090,7 +1092,6 @@ short SvxNumberFormatShell::FillEListWithUsD_Impl( std::vector& rList, DBG_ASSERT( pCurFmtTable != NULL, "Unbekanntes Zahlenformat!" ); - const SvNumberformat* pNumEntry = pCurFmtTable->First(); String aStrComment; String aNewFormNInfo; String aPrevString; @@ -1100,9 +1101,11 @@ short SvxNumberFormatShell::FillEListWithUsD_Impl( std::vector& rList, bool bAdditional = (nPrivCat != CAT_USERDEFINED && nCurCategory != NUMBERFORMAT_ALL); - while ( pNumEntry ) + SvNumberFormatTable::iterator it = pCurFmtTable->begin(); + while ( it != pCurFmtTable->end() ) { - sal_uInt32 nKey = pCurFmtTable->GetCurKey(); + sal_uInt32 nKey = it->first; + const SvNumberformat* pNumEntry = it->second; if ( !IsRemoved_Impl( nKey ) ) { @@ -1131,7 +1134,7 @@ short SvxNumberFormatShell::FillEListWithUsD_Impl( std::vector& rList, } } } - pNumEntry = pCurFmtTable->Next(); + ++it; } return nSelPos; } diff --git a/vcl/source/control/combobox.cxx b/vcl/source/control/combobox.cxx index 97abfc1..0c9904c 100644 --- a/vcl/source/control/combobox.cxx +++ b/vcl/source/control/combobox.cxx @@ -29,7 +29,6 @@ #include #include -#include #include #include #include diff --git a/xmloff/source/style/xmlnumfe.cxx b/xmloff/source/style/xmlnumfe.cxx index 7025a3d..517a9bf 100644 --- a/xmloff/source/style/xmlnumfe.cxx +++ b/xmloff/source/style/xmlnumfe.cxx @@ -1699,10 +1699,11 @@ void SvXMLNumFmtExport::Export( sal_Bool bIsAutoStyle ) sal_uInt32 nDefaultIndex = 0; SvNumberFormatTable& rTable = pFormatter->GetEntryTable( NUMBERFORMAT_DEFINED, nDefaultIndex, nLang ); - pFormat = rTable.First(); - while (pFormat) + SvNumberFormatTable::iterator it2 = rTable.begin(); + while (it2 != rTable.end()) { - nKey = rTable.GetCurKey(); + nKey = it2->first; + pFormat = it2->second; if (!pUsedList->IsUsed(nKey)) { DBG_ASSERT((pFormat->GetType() & NUMBERFORMAT_DEFINED) != 0, "a not user defined numberformat found"); @@ -1712,7 +1713,7 @@ void SvXMLNumFmtExport::Export( sal_Bool bIsAutoStyle ) pUsedList->SetUsed(nKey); } - pFormat = rTable.Next(); + ++it2; } } }