[Libreoffice-commits] .: svl/source
Joseph Powers
jpowers at kemper.freedesktop.org
Thu Jul 14 19:34:52 PDT 2011
svl/source/numbers/zforlist.cxx | 77 +++++++++++++++++++++++-----------------
1 file changed, 45 insertions(+), 32 deletions(-)
New commits:
commit 82b5d9c09aabd6e80f9d9f6bf65916f19963c242
Author: Joseph Powers <jpowers27 at cox.net>
Date: Thu Jul 14 18:09:42 2011 -0700
Replace List with std::vector< SvNumberFormatter* >
diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx
index eede4a1..bc0df6a 100644
--- a/svl/source/numbers/zforlist.cxx
+++ b/svl/source/numbers/zforlist.cxx
@@ -2,7 +2,7 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
@@ -100,26 +100,28 @@ static sal_uInt32 theIndexTable[NF_INDEX_TABLE_ENTRIES];
also handles one instance of the SysLocale options
*/
+typedef ::std::vector< SvNumberFormatter* > SvNumberFormatterList_impl;
+
class SvNumberFormatterRegistry_Impl : public utl::ConfigurationListener
{
- List aFormatters;
- SvtSysLocaleOptions aSysLocaleOptions;
- LanguageType eSysLanguage;
+ SvNumberFormatterList_impl aFormatters;
+ SvtSysLocaleOptions aSysLocaleOptions;
+ LanguageType eSysLanguage;
public:
SvNumberFormatterRegistry_Impl();
virtual ~SvNumberFormatterRegistry_Impl();
- void Insert( SvNumberFormatter* pThis )
- { aFormatters.Insert( pThis, LIST_APPEND ); }
- SvNumberFormatter* Remove( SvNumberFormatter* pThis )
- { return (SvNumberFormatter*)aFormatters.Remove( pThis ); }
- sal_uInt32 Count()
- { return aFormatters.Count(); }
+ void Insert( SvNumberFormatter* pThis )
+ { aFormatters.push_back( pThis ); }
- virtual void ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 );
-};
+ SvNumberFormatter* Remove( SvNumberFormatter* pThis );
+
+ size_t Count()
+ { return aFormatters.size(); }
+ virtual void ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 );
+};
SvNumberFormatterRegistry_Impl::SvNumberFormatterRegistry_Impl()
{
@@ -134,26 +136,37 @@ SvNumberFormatterRegistry_Impl::~SvNumberFormatterRegistry_Impl()
}
-void SvNumberFormatterRegistry_Impl::ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 nHint )
+SvNumberFormatter* SvNumberFormatterRegistry_Impl::Remove( SvNumberFormatter* pThis )
{
+ for(
+ SvNumberFormatterList_impl::iterator it = aFormatters.begin();
+ it < aFormatters.end();
+ ++it
+ ) {
+ if ( *it == pThis ) {
+ aFormatters.erase( it );
+ break;
+ }
+ }
+ return pThis;
+}
+
+void SvNumberFormatterRegistry_Impl::ConfigurationChanged(
+ utl::ConfigurationBroadcaster*,
+ sal_uInt32 nHint
+) {
if ( nHint & SYSLOCALEOPTIONS_HINT_LOCALE )
{
::osl::MutexGuard aGuard( SvNumberFormatter::GetMutex() );
- for ( SvNumberFormatter* p = (SvNumberFormatter*)aFormatters.First();
- p; p = (SvNumberFormatter*)aFormatters.Next() )
- {
- p->ReplaceSystemCL( eSysLanguage );
- }
+ for( size_t i = 0, n = aFormatters.size(); i < n; ++i )
+ aFormatters[ i ]->ReplaceSystemCL( eSysLanguage );
eSysLanguage = MsLangId::getRealLanguage( LANGUAGE_SYSTEM );
}
if ( nHint & SYSLOCALEOPTIONS_HINT_CURRENCY )
{
::osl::MutexGuard aGuard( SvNumberFormatter::GetMutex() );
- for ( SvNumberFormatter* p = (SvNumberFormatter*)aFormatters.First();
- p; p = (SvNumberFormatter*)aFormatters.Next() )
- {
- p->ResetDefaultSystemCurrency();
- }
+ for( size_t i = 0, n = aFormatters.size(); i < n; ++i )
+ aFormatters[ i ]->ResetDefaultSystemCurrency();
}
}
@@ -162,13 +175,13 @@ void SvNumberFormatterRegistry_Impl::ConfigurationChanged( utl::ConfigurationBro
SvNumberFormatterRegistry_Impl* SvNumberFormatter::pFormatterRegistry = NULL;
sal_Bool SvNumberFormatter::bCurrencyTableInitialized = sal_False;
-namespace
+namespace
{
- struct theCurrencyTable :
- public rtl::Static< NfCurrencyTable, theCurrencyTable > {};
+ struct theCurrencyTable :
+ public rtl::Static< NfCurrencyTable, theCurrencyTable > {};
- struct theLegacyOnlyCurrencyTable :
- public rtl::Static< NfCurrencyTable, theLegacyOnlyCurrencyTable > {};
+ struct theLegacyOnlyCurrencyTable :
+ public rtl::Static< NfCurrencyTable, theLegacyOnlyCurrencyTable > {};
}
sal_uInt16 SvNumberFormatter::nSystemCurrencyPosition = 0;
SV_IMPL_PTRARR( NfCurrencyTable, NfCurrencyEntry* );
@@ -610,13 +623,13 @@ sal_uInt32 SvNumberFormatter::GetIndexPuttingAndConverting( String & rString,
nKey = nOrig; // none avaliable, maybe user-defined
else
nKey = GetFormatForLanguageIfBuiltIn( nOrig, SvtSysLocale().GetLanguage() );
-
+
if (nKey == nOrig)
{
// Not a builtin format, convert.
// The format code string may get modified and adapted to the real
// language and wouldn't match eSysLnge anymore, do that on a copy.
- String aTmp( rString);
+ String aTmp( rString);
rNewInserted = PutandConvertEntrySystem( aTmp, rCheckPos, rType,
nKey, eLnge, SvtSysLocale().GetLanguage());
if (rCheckPos > 0)
@@ -1745,8 +1758,8 @@ sal_Bool SvNumberFormatter::GetPreviewString( const String& sFormatString,
GetOutputString( aNonConstPreview, nKey, sOutString, ppColor);
else
{
- // If the format is valid but not a text format and does not
- // include a text subformat, an empty string would result. Same as
+ // If the format is valid but not a text format and does not
+ // include a text subformat, an empty string would result. Same as
// in SvNumberFormatter::GetOutputString()
if (p_Entry->IsTextFormat() || p_Entry->HasTextFormat())
p_Entry->GetOutputString( aNonConstPreview, sOutString, ppColor);
More information about the Libreoffice-commits
mailing list