diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2012-06-09 17:15:22 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2012-06-12 23:25:10 +0200 |
commit | 6d0961d194b02707faab5fb64207b8dc40488c2b (patch) | |
tree | 72075c8d40a143ca5fdd7a3a72a3bc89b4e26e13 | |
parent | 072a67d198120a1e7a0cea16e834e33fcc9631bc (diff) |
Convert SV_DECL_PTRARR_DEL(NfCurrencyTable) to boost::ptr_vector
Change-Id: I4e288a90f3b1662462ba06053343c8bab5fe46cf
-rw-r--r-- | cui/source/options/optgdlg.cxx | 4 | ||||
-rw-r--r-- | svl/inc/svl/zforlist.hxx | 5 | ||||
-rw-r--r-- | svl/source/numbers/zforlist.cxx | 87 | ||||
-rw-r--r-- | svx/source/items/numfmtsh.cxx | 42 |
4 files changed, 64 insertions, 74 deletions
diff --git a/cui/source/options/optgdlg.cxx b/cui/source/options/optgdlg.cxx index 762ec3d78d83..40fd21e79a3a 100644 --- a/cui/source/options/optgdlg.cxx +++ b/cui/source/options/optgdlg.cxx @@ -1356,11 +1356,11 @@ OfaLanguagesTabPage::OfaLanguagesTabPage( Window* pParent, const SfxItemSet& rSe aCurrencyLB.InsertEntry( aDefaultCurr ); // all currencies String aTwoSpace( RTL_CONSTASCII_USTRINGPARAM( " " ) ); - sal_uInt16 nCurrCount = rCurrTab.Count(); + sal_uInt16 nCurrCount = rCurrTab.size(); // first entry is SYSTEM, skip it for ( sal_uInt16 j=1; j < nCurrCount; ++j ) { - const NfCurrencyEntry* pCurr = rCurrTab[j]; + const NfCurrencyEntry* pCurr = &rCurrTab[j]; String aStr_( pCurr->GetBankSymbol() ); aStr_ += aTwoSpace; aStr_ += pCurr->GetSymbol(); diff --git a/svl/inc/svl/zforlist.hxx b/svl/inc/svl/zforlist.hxx index 79bff15dc8c7..10bac7e98267 100644 --- a/svl/inc/svl/zforlist.hxx +++ b/svl/inc/svl/zforlist.hxx @@ -31,7 +31,6 @@ #include "svl/svldllapi.h" #include <tools/string.hxx> #include <i18npool/lang.h> -#include <svl/svarray.hxx> #include <com/sun/star/uno/Reference.hxx> #include <com/sun/star/lang/Locale.hpp> #include <com/sun/star/i18n/NumberFormatCode.hpp> @@ -42,6 +41,7 @@ #include <map> #include <set> +#include <boost/ptr_container/ptr_vector.hpp> class Date; class SvStream; @@ -316,8 +316,7 @@ public: static sal_Char GetEuroSymbol( rtl_TextEncoding eTextEncoding ); }; -typedef NfCurrencyEntry* NfCurrencyEntryPtr; -SV_DECL_PTRARR_DEL( NfCurrencyTable, NfCurrencyEntryPtr, 128 ) +typedef boost::ptr_vector<NfCurrencyEntry> NfCurrencyTable; typedef String* WSStringPtr; class SVL_DLLPUBLIC NfWSStringsDtor : public std::vector<WSStringPtr> diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx index 65f4922ac7f9..0228ac7aaabb 100644 --- a/svl/source/numbers/zforlist.cxx +++ b/svl/source/numbers/zforlist.cxx @@ -185,7 +185,6 @@ namespace } sal_uInt16 SvNumberFormatter::nSystemCurrencyPosition = 0; -SV_IMPL_PTRARR( NfCurrencyTable, NfCurrencyEntry* ); // Whether BankSymbol (not CurrencySymbol!) is always at the end (1 $;-1 $) or // language dependent. @@ -3064,7 +3063,7 @@ const NfCurrencyEntry* SvNumberFormatter::MatchSystemCurrency() { // MUST call GetTheCurrencyTable() before accessing nSystemCurrencyPosition const NfCurrencyTable& rTable = GetTheCurrencyTable(); - return nSystemCurrencyPosition ? rTable[nSystemCurrencyPosition] : NULL; + return nSystemCurrencyPosition ? &rTable[nSystemCurrencyPosition] : NULL; } @@ -3074,20 +3073,19 @@ const NfCurrencyEntry& SvNumberFormatter::GetCurrencyEntry( LanguageType eLang ) if ( eLang == LANGUAGE_SYSTEM ) { const NfCurrencyEntry* pCurr = MatchSystemCurrency(); - return pCurr ? *pCurr : *(GetTheCurrencyTable()[0]); + return pCurr ? *pCurr : GetTheCurrencyTable()[0]; } else { eLang = MsLangId::getRealLanguage( eLang ); const NfCurrencyTable& rTable = GetTheCurrencyTable(); - sal_uInt16 nCount = rTable.Count(); - const NfCurrencyEntryPtr* ppData = rTable.GetData(); - for ( sal_uInt16 j = 0; j < nCount; j++, ppData++ ) + sal_uInt16 nCount = rTable.size(); + for ( sal_uInt16 j = 0; j < nCount; j++ ) { - if ( (*ppData)->GetLanguage() == eLang ) - return **ppData; + if ( rTable[j].GetLanguage() == eLang ) + return rTable[j]; } - return *(rTable[0]); + return rTable[0]; } } @@ -3098,13 +3096,12 @@ const NfCurrencyEntry* SvNumberFormatter::GetCurrencyEntry( { eLang = MsLangId::getRealLanguage( eLang ); const NfCurrencyTable& rTable = GetTheCurrencyTable(); - sal_uInt16 nCount = rTable.Count(); - const NfCurrencyEntryPtr* ppData = rTable.GetData(); - for ( sal_uInt16 j = 0; j < nCount; j++, ppData++ ) + sal_uInt16 nCount = rTable.size(); + for ( sal_uInt16 j = 0; j < nCount; j++ ) { - if ( (*ppData)->GetLanguage() == eLang && - (*ppData)->GetBankSymbol() == rAbbrev ) - return *ppData; + if ( rTable[j].GetLanguage() == eLang && + rTable[j].GetBankSymbol() == rAbbrev ) + return &rTable[j]; } return NULL; } @@ -3117,13 +3114,12 @@ const NfCurrencyEntry* SvNumberFormatter::GetLegacyOnlyCurrencyEntry( if (!bCurrencyTableInitialized) GetTheCurrencyTable(); // just for initialization const NfCurrencyTable& rTable = theLegacyOnlyCurrencyTable::get(); - sal_uInt16 nCount = rTable.Count(); - const NfCurrencyEntryPtr* ppData = rTable.GetData(); - for ( sal_uInt16 j = 0; j < nCount; j++, ppData++ ) + sal_uInt16 nCount = rTable.size(); + for ( sal_uInt16 j = 0; j < nCount; j++ ) { - if ( (*ppData)->GetSymbol() == rSymbol && - (*ppData)->GetBankSymbol() == rAbbrev ) - return *ppData; + if ( rTable[j].GetSymbol() == rSymbol && + rTable[j].GetBankSymbol() == rAbbrev ) + return &rTable[j]; } return NULL; } @@ -3148,13 +3144,12 @@ void SvNumberFormatter::SetDefaultSystemCurrency( const String& rAbbrev, Languag if ( eLang == LANGUAGE_SYSTEM ) eLang = SvtSysLocale().GetLanguage(); const NfCurrencyTable& rTable = GetTheCurrencyTable(); - sal_uInt16 nCount = rTable.Count(); - const NfCurrencyEntryPtr* ppData = rTable.GetData(); + sal_uInt16 nCount = rTable.size(); if ( rAbbrev.Len() ) { - for ( sal_uInt16 j = 0; j < nCount; j++, ppData++ ) + for ( sal_uInt16 j = 0; j < nCount; j++ ) { - if ( (*ppData)->GetLanguage() == eLang && (*ppData)->GetBankSymbol() == rAbbrev ) + if ( rTable[j].GetLanguage() == eLang && rTable[j].GetBankSymbol() == rAbbrev ) { nSystemCurrencyPosition = j; return ; @@ -3163,9 +3158,9 @@ void SvNumberFormatter::SetDefaultSystemCurrency( const String& rAbbrev, Languag } else { - for ( sal_uInt16 j = 0; j < nCount; j++, ppData++ ) + for ( sal_uInt16 j = 0; j < nCount; j++ ) { - if ( (*ppData)->GetLanguage() == eLang ) + if ( rTable[j].GetLanguage() == eLang ) { nSystemCurrencyPosition = j; return ; @@ -3382,23 +3377,22 @@ const NfCurrencyEntry* SvNumberFormatter::GetCurrencyEntry( bool & bFoundBank, eExtLang = LANGUAGE_DONTKNOW; const NfCurrencyEntry* pFoundEntry = NULL; const NfCurrencyTable& rTable = GetTheCurrencyTable(); - sal_uInt16 nCount = rTable.Count(); + sal_uInt16 nCount = rTable.size(); bool bCont = true; // first try with given extension language/country if ( nExtLen ) { - const NfCurrencyEntryPtr* ppData = rTable.GetData(); - for ( sal_uInt16 j = 0; j < nCount && bCont; j++, ppData++ ) + for ( sal_uInt16 j = 0; j < nCount && bCont; j++ ) { - LanguageType eLang = (*ppData)->GetLanguage(); + LanguageType eLang = rTable[j].GetLanguage(); if ( eLang == eExtLang || ((eExtLang == LANGUAGE_DONTKNOW) && (eLang == LANGUAGE_SYSTEM)) ) { bCont = ImpLookupCurrencyEntryLoopBody( pFoundEntry, bFoundBank, - *ppData, j, rSymbol ); + &rTable[j], j, rSymbol ); } } } @@ -3410,17 +3404,16 @@ const NfCurrencyEntry* SvNumberFormatter::GetCurrencyEntry( bool & bFoundBank, if ( !bOnlyStringLanguage ) { // now try the language/country of the number format - const NfCurrencyEntryPtr* ppData = rTable.GetData(); - for ( sal_uInt16 j = 0; j < nCount && bCont; j++, ppData++ ) + for ( sal_uInt16 j = 0; j < nCount && bCont; j++ ) { - LanguageType eLang = (*ppData)->GetLanguage(); + LanguageType eLang = rTable[j].GetLanguage(); if ( eLang == eFormatLanguage || ((eFormatLanguage == LANGUAGE_DONTKNOW) && (eLang == LANGUAGE_SYSTEM)) ) { bCont = ImpLookupCurrencyEntryLoopBody( pFoundEntry, bFoundBank, - *ppData, j, rSymbol ); + &rTable[j], j, rSymbol ); } } @@ -3432,11 +3425,10 @@ const NfCurrencyEntry* SvNumberFormatter::GetCurrencyEntry( bool & bFoundBank, // then try without language/country if no extension specified if ( !nExtLen ) { - const NfCurrencyEntryPtr* ppData = rTable.GetData(); - for ( sal_uInt16 j = 0; j < nCount && bCont; j++, ppData++ ) + for ( sal_uInt16 j = 0; j < nCount && bCont; j++ ) { bCont = ImpLookupCurrencyEntryLoopBody( pFoundEntry, bFoundBank, - *ppData, j, rSymbol ); + &rTable[j], j, rSymbol ); } } @@ -3553,11 +3545,11 @@ void SvNumberFormatter::ImpInitCurrencyTable() aConfiguredCurrencyAbbrev, eConfiguredCurrencyLanguage ); sal_uInt16 nSecondarySystemCurrencyPosition = 0; sal_uInt16 nMatchingSystemCurrencyPosition = 0; - NfCurrencyEntryPtr pEntry; + NfCurrencyEntry* pEntry; // first entry is SYSTEM pEntry = new NfCurrencyEntry( *pLocaleData, LANGUAGE_SYSTEM ); - theCurrencyTable::get().Insert( pEntry, 0 ); + theCurrencyTable::get().insert( theCurrencyTable::get().begin(), pEntry ); sal_uInt16 nCurrencyPos = 1; ::com::sun::star::uno::Sequence< ::com::sun::star::lang::Locale > xLoc = @@ -3594,7 +3586,7 @@ void SvNumberFormatter::ImpInitCurrencyTable() if (LocaleDataWrapper::areChecksEnabled()) lcl_CheckCurrencySymbolPosition( *pEntry ); - rCurrencyTable.Insert( pEntry, nCurrencyPos++ ); + rCurrencyTable.insert( rCurrencyTable.begin() + nCurrencyPos++, pEntry ); if ( !nSystemCurrencyPosition && (aConfiguredCurrencyAbbrev.Len() ? pEntry->GetBankSymbol() == aConfiguredCurrencyAbbrev && pEntry->GetLanguage() == eConfiguredCurrencyLanguage : false) ) @@ -3612,19 +3604,18 @@ void SvNumberFormatter::ImpInitCurrencyTable() if (pCurrencies[nCurrency].LegacyOnly) { pEntry = new NfCurrencyEntry( pCurrencies[nCurrency], *pLocaleData, eLang ); - rLegacyOnlyCurrencyTable.Insert( pEntry, nLegacyOnlyCurrencyPos++ ); + rLegacyOnlyCurrencyTable.insert( rLegacyOnlyCurrencyTable.begin() + nLegacyOnlyCurrencyPos++, pEntry ); } else if ( nCurrency != nDefault ) { pEntry = new NfCurrencyEntry( pCurrencies[nCurrency], *pLocaleData, eLang ); // no dupes bool bInsert = true; - NfCurrencyEntry const * const * pData = rCurrencyTable.GetData(); - sal_uInt16 n = rCurrencyTable.Count(); - pData++; // skip first SYSTEM entry + sal_uInt16 n = rCurrencyTable.size(); + sal_uInt16 aCurrencyIndex = 1; // skip first SYSTEM entry for ( sal_uInt16 j=1; j<n; j++ ) { - if ( *(*pData++) == *pEntry ) + if ( rCurrencyTable[aCurrencyIndex++] == *pEntry ) { bInsert = false; break; // for @@ -3634,7 +3625,7 @@ void SvNumberFormatter::ImpInitCurrencyTable() delete pEntry; else { - rCurrencyTable.Insert( pEntry, nCurrencyPos++ ); + rCurrencyTable.insert( rCurrencyTable.begin() + nCurrencyPos++, pEntry ); if ( !nSecondarySystemCurrencyPosition && (aConfiguredCurrencyAbbrev.Len() ? pEntry->GetBankSymbol() == aConfiguredCurrencyAbbrev : diff --git a/svx/source/items/numfmtsh.cxx b/svx/source/items/numfmtsh.cxx index b2ee52a00695..ef25577453bb 100644 --- a/svx/source/items/numfmtsh.cxx +++ b/svx/source/items/numfmtsh.cxx @@ -1012,11 +1012,11 @@ short SvxNumberFormatShell::FillEListWithUserCurrencys( std::vector<String*>& rL if ( !bTmpBanking && nCurCategory != NUMBERFORMAT_ALL ) { // append formats for all currencies defined in the current I18N locale const NfCurrencyTable& rCurrencyTable = SvNumberFormatter::GetTheCurrencyTable(); - sal_uInt16 nCurrCount = rCurrencyTable.Count(); + sal_uInt16 nCurrCount = rCurrencyTable.size(); LanguageType eLang = MsLangId::getRealLanguage( eCurLanguage ); for ( sal_uInt16 i=0; i < nCurrCount; ++i ) { - const NfCurrencyEntry* pCurr = rCurrencyTable[i]; + const NfCurrencyEntry* pCurr = &rCurrencyTable[i]; if ( pCurr->GetLanguage() == eLang && pTmpCurrencyEntry != pCurr ) { pFormatter->GetCurrencyFormatStrings( aWSStringsDtor, *pCurr, false ); @@ -1513,7 +1513,7 @@ void SvxNumberFormatShell::GetCurrencySymbols(std::vector<rtl::OUString>& rList, if(pPos!=NULL) { const NfCurrencyTable& rCurrencyTable=SvNumberFormatter::GetTheCurrencyTable(); - sal_uInt16 nTableCount=rCurrencyTable.Count(); + sal_uInt16 nTableCount=rCurrencyTable.size(); *pPos=0; size_t nCount=aCurCurrencyList.size(); @@ -1529,7 +1529,7 @@ void SvxNumberFormatShell::GetCurrencySymbols(std::vector<rtl::OUString>& rList, { const sal_uInt16 j = aCurCurrencyList[i]; if (j != (sal_uInt16)-1 && j < nTableCount && - pTmpCurrencyEntry == rCurrencyTable[j]) + pTmpCurrencyEntry == &rCurrencyTable[j]) { *pPos=static_cast<sal_uInt16>(i); nCurCurrencyEntryPos=static_cast<sal_uInt16>(i); @@ -1546,15 +1546,15 @@ void SvxNumberFormatShell::GetCurrencySymbols(std::vector<rtl::OUString>& rList, aCurCurrencyList.clear(); const NfCurrencyTable& rCurrencyTable=SvNumberFormatter::GetTheCurrencyTable(); - sal_uInt16 nCount=rCurrencyTable.Count(); + sal_uInt16 nCount=rCurrencyTable.size(); SvtLanguageTable* pLanguageTable=new SvtLanguageTable; sal_uInt16 nStart=1; - XubString aString( ApplyLreOrRleEmbedding( rCurrencyTable[0]->GetSymbol())); + XubString aString( ApplyLreOrRleEmbedding( rCurrencyTable[0].GetSymbol())); aString += sal_Unicode(' '); - aString += ApplyLreOrRleEmbedding( pLanguageTable->GetString( rCurrencyTable[0]->GetLanguage())); + aString += ApplyLreOrRleEmbedding( pLanguageTable->GetString( rCurrencyTable[0].GetLanguage())); rList.push_back(aString); sal_uInt16 nAuto=(sal_uInt16)-1; @@ -1574,11 +1574,11 @@ void SvxNumberFormatShell::GetCurrencySymbols(std::vector<rtl::OUString>& rList, for(sal_uInt16 i = 1; i < nCount; ++i) { - XubString aStr( ApplyLreOrRleEmbedding( rCurrencyTable[i]->GetBankSymbol())); + XubString aStr( ApplyLreOrRleEmbedding( rCurrencyTable[i].GetBankSymbol())); aStr += aTwoSpace; - aStr += ApplyLreOrRleEmbedding( rCurrencyTable[i]->GetSymbol()); + aStr += ApplyLreOrRleEmbedding( rCurrencyTable[i].GetSymbol()); aStr += aTwoSpace; - aStr += ApplyLreOrRleEmbedding( pLanguageTable->GetString( rCurrencyTable[i]->GetLanguage())); + aStr += ApplyLreOrRleEmbedding( pLanguageTable->GetString( rCurrencyTable[i].GetLanguage())); sal_uInt16 j = nStart; for(; j < rList.size(); ++j) @@ -1597,7 +1597,7 @@ void SvxNumberFormatShell::GetCurrencySymbols(std::vector<rtl::OUString>& rList, for(sal_uInt16 i = 1; i < nCount; ++i) { bool bInsert = true; - rtl::OUString aStr(ApplyLreOrRleEmbedding(rCurrencyTable[i]->GetBankSymbol())); + rtl::OUString aStr(ApplyLreOrRleEmbedding(rCurrencyTable[i].GetBankSymbol())); sal_uInt16 j = nCont; for(; j < rList.size() && bInsert; ++j) @@ -1620,7 +1620,7 @@ void SvxNumberFormatShell::GetCurrencySymbols(std::vector<rtl::OUString>& rList, void SvxNumberFormatShell::SetCurrencySymbol(sal_uInt16 nPos) { const NfCurrencyTable& rCurrencyTable=SvNumberFormatter::GetTheCurrencyTable(); - sal_uInt16 nCount=rCurrencyTable.Count(); + sal_uInt16 nCount=rCurrencyTable.size(); bBankingSymbol=(nPos>=nCount); @@ -1629,7 +1629,7 @@ void SvxNumberFormatShell::SetCurrencySymbol(sal_uInt16 nPos) sal_uInt16 nCurrencyPos=aCurCurrencyList[nPos]; if(nCurrencyPos!=(sal_uInt16)-1) { - pCurCurrencyEntry=rCurrencyTable[nCurrencyPos]; + pCurCurrencyEntry=(NfCurrencyEntry*)&rCurrencyTable[nCurrencyPos]; nCurCurrencyEntryPos=nPos; } else @@ -1667,7 +1667,7 @@ bool SvxNumberFormatShell::IsTmpCurrencyFormat( const String& rFmtString ) sal_uInt16 SvxNumberFormatShell::FindCurrencyFormat( const String& rFmtString ) { const NfCurrencyTable& rCurrencyTable=SvNumberFormatter::GetTheCurrencyTable(); - sal_uInt16 nCount=rCurrencyTable.Count(); + sal_uInt16 nCount=rCurrencyTable.size(); bool bTestBanking=false; @@ -1693,7 +1693,7 @@ sal_uInt16 SvxNumberFormatShell::FindCurrencyTableEntry( const String& rFmtStrin sal_uInt16 nPos=(sal_uInt16) -1; const NfCurrencyTable& rCurrencyTable=SvNumberFormatter::GetTheCurrencyTable(); - sal_uInt16 nCount=rCurrencyTable.Count(); + sal_uInt16 nCount=rCurrencyTable.size(); const SvNumberformat* pFormat; String aSymbol, aExtension; @@ -1709,7 +1709,7 @@ sal_uInt16 SvxNumberFormatShell::FindCurrencyTableEntry( const String& rFmtStrin { for(sal_uInt16 i=0;i<nCount;i++) { - if(pTmpCurrencyEntry==rCurrencyTable[i]) + if(pTmpCurrencyEntry==&rCurrencyTable[i]) { nPos=i; break; @@ -1721,7 +1721,7 @@ sal_uInt16 SvxNumberFormatShell::FindCurrencyTableEntry( const String& rFmtStrin { // search symbol string only for(sal_uInt16 i=0;i<nCount;i++) { - const NfCurrencyEntry* pTmpCurrencyEntry=rCurrencyTable[i]; + const NfCurrencyEntry* pTmpCurrencyEntry=&rCurrencyTable[i]; XubString _aSymbol, aBankSymbol; pTmpCurrencyEntry->BuildSymbolString(_aSymbol,false); pTmpCurrencyEntry->BuildSymbolString(aBankSymbol,true); @@ -1747,12 +1747,12 @@ sal_uInt16 SvxNumberFormatShell::FindCurrencyTableEntry( const String& rFmtStrin sal_uInt16 SvxNumberFormatShell::FindCurrencyFormat(const NfCurrencyEntry* pTmpCurrencyEntry,bool bTmpBanking) { const NfCurrencyTable& rCurrencyTable=SvNumberFormatter::GetTheCurrencyTable(); - sal_uInt16 nCount=rCurrencyTable.Count(); + sal_uInt16 nCount=rCurrencyTable.size(); sal_uInt16 nPos=0; for(sal_uInt16 i=0;i<nCount;i++) { - if(pTmpCurrencyEntry==rCurrencyTable[i]) + if(pTmpCurrencyEntry==&rCurrencyTable[i]) { nPos=i; break; @@ -1778,13 +1778,13 @@ bool SvxNumberFormatShell::IsInTable(sal_uInt16 nPos,bool bTmpBanking,const Stri if(nPos!=(sal_uInt16)-1) { const NfCurrencyTable& rCurrencyTable=SvNumberFormatter::GetTheCurrencyTable(); - sal_uInt16 nCount=rCurrencyTable.Count(); + sal_uInt16 nCount=rCurrencyTable.size(); if(nPos<nCount) { NfWSStringsDtor aWSStringsDtor; - const NfCurrencyEntry* pTmpCurrencyEntry=rCurrencyTable[nPos]; + const NfCurrencyEntry* pTmpCurrencyEntry=&rCurrencyTable[nPos]; if ( pTmpCurrencyEntry!=NULL) { |