[Libreoffice-commits] .: 2 commits - cui/source i18npool/source svx/inc svx/source

Eike Rathke erack at kemper.freedesktop.org
Mon Aug 8 02:14:23 PDT 2011


 cui/source/tabpages/numfmt.cxx            |    2 
 i18npool/source/localedata/data/de_LI.xml |    4 
 svx/inc/svx/numfmtsh.hxx                  |   10 +
 svx/source/items/numfmtsh.cxx             |  178 +++++++++++++-----------------
 4 files changed, 87 insertions(+), 107 deletions(-)

New commits:
commit 5207c9fdde58c3e4f1b5329cb8e7177129b2905d
Author: Eike Rathke <erack at erack.de>
Date:   Mon Aug 8 03:31:05 2011 +0200

    Fix decimal separator of a German_Liechtenstein [de-LI] currency format

diff --git a/i18npool/source/localedata/data/de_LI.xml b/i18npool/source/localedata/data/de_LI.xml
index 9908831..6352b44 100644
--- a/i18npool/source/localedata/data/de_LI.xml
+++ b/i18npool/source/localedata/data/de_LI.xml
@@ -20,7 +20,7 @@
       <Time100SecSeparator>.</Time100SecSeparator>
       <ListSeparator>;</ListSeparator>
       <LongDateDayOfWeekSeparator>, </LongDateDayOfWeekSeparator>
-      <LongDateDaySeparator>.</LongDateDaySeparator>
+      <LongDateDaySeparator>. </LongDateDaySeparator>
       <LongDateMonthSeparator> </LongDateMonthSeparator>
       <LongDateYearSeparator> </LongDateYearSeparator>
     </Separators>
@@ -81,7 +81,7 @@
       <FormatCode>#'##0.00 CCC</FormatCode>
     </FormatElement>
     <FormatElement msgid="CurrencyFormatskey6" default="false" type="medium" usage="CURRENCY" formatindex="17">
-      <FormatCode>[$SFr.-1407] #'##0,--;[ROT][$SFr.-1407]-#'##0,--</FormatCode>
+      <FormatCode>[$SFr.-1407] #'##0.--;[ROT][$SFr.-1407]-#'##0.--</FormatCode>
     </FormatElement>
     <FormatElement msgid="DateFormatskey1" default="true" type="short" usage="DATE" formatindex="18">
       <FormatCode>TT.MM.JJ</FormatCode>
commit c1be3dab3d37b74570b49d8534c4d2677a318286
Author: Maciej Rumianowski <maciej.rumianowski at gmail.com>
Date:   Sun Aug 7 16:46:17 2011 +0200

    Replace SvULongs with vector and code clean up
    
    Instead of SvULongs use std::vector<sal_uInt32>
    replace sal_Bool with bool where variable is not interfering with return value

diff --git a/cui/source/tabpages/numfmt.cxx b/cui/source/tabpages/numfmt.cxx
index 0295c32..8320b5d 100644
--- a/cui/source/tabpages/numfmt.cxx
+++ b/cui/source/tabpages/numfmt.cxx
@@ -782,7 +782,7 @@ sal_Bool SvxNumberFormatTabPage::FillItemSet( SfxItemSet& rCoreAttrs )
         // --------------------------------------------------------------
         // List of changed user defined formats:
         // -------------------------------------
-        const sal_uInt32 nDelCount = pNumFmtShell->GetUpdateDataCount();
+        const size_t nDelCount = pNumFmtShell->GetUpdateDataCount();
 
         if ( nDelCount > 0 )
         {
diff --git a/svx/inc/svx/numfmtsh.hxx b/svx/inc/svx/numfmtsh.hxx
index a9253c0..4366e93 100644
--- a/svx/inc/svx/numfmtsh.hxx
+++ b/svx/inc/svx/numfmtsh.hxx
@@ -46,6 +46,8 @@
 
 #include <svl/svstdarr.hxx>
 
+#include <vector>
+
 // forward ---------------------------------------------------------------
 
 class Color;
@@ -183,7 +185,7 @@ public:
     sal_Bool                FindEntry( const String& rFmtString, sal_uInt32* pAt = NULL );
 
     void                ValidateNewEntries( sal_Bool bValidate = sal_True ) { bUndoAddList = !bValidate; }
-    sal_uInt32          GetUpdateDataCount() const;
+    size_t              GetUpdateDataCount() const;
     void                GetUpdateData( sal_uInt32* pDelArray, const sal_uInt32 nSize );
 
     void                SetCurNumFmtKey( sal_uInt32 nNew )  { nCurFormatKey = nNew; }
@@ -228,9 +230,9 @@ private:
     String                  aValStr;
     double                  nValNum;
     sal_Bool                    bUndoAddList;
-    SvULongs                aAddList;
-    SvULongs                aDelList;
-    SvULongs                aCurEntryList;
+    std::vector<sal_uInt32> aAddList;
+    std::vector<sal_uInt32> aDelList;
+    std::vector<sal_uInt32> aCurEntryList;
     sal_uInt32              nInitFormatKey;
     sal_uInt32              nCurFormatKey;
     short                   nCurCategory;
diff --git a/svx/source/items/numfmtsh.cxx b/svx/source/items/numfmtsh.cxx
index 7b106ae..ffe0b0a 100644
--- a/svx/source/items/numfmtsh.cxx
+++ b/svx/source/items/numfmtsh.cxx
@@ -159,38 +159,32 @@ SvxNumberFormatShell::~SvxNumberFormatShell()
         // Hinzugefuegte Formate sind nicht gueltig:
         // => wieder entfernen:
 
-        for ( sal_uInt16 i = 0; i < aAddList.Count(); ++i )
-            pFormatter->DeleteEntry( aAddList[i] );
+        for ( std::vector<sal_uInt32>::const_iterator it(aAddList.begin()); it != aAddList.end(); ++it )
+            pFormatter->DeleteEntry( *it );
     }
 
-    //--------------------------------
-    // Add-/Remove-Listen leerraeumen:
-    //--------------------------------
-    aAddList.Remove( 0, aAddList.Count() );
-    aDelList.Remove( 0, aAddList.Count() );
-
     if(aCurrencyFormatList.Count()>0)
         aCurrencyFormatList.DeleteAndDestroy(0,aCurrencyFormatList.Count());
 }
 
 // -----------------------------------------------------------------------
 
-sal_uInt32 SvxNumberFormatShell::GetUpdateDataCount() const
+size_t SvxNumberFormatShell::GetUpdateDataCount() const
 {
-    return aDelList.Count();
+    return aDelList.size();
 }
 
 // -----------------------------------------------------------------------
 
 void SvxNumberFormatShell::GetUpdateData( sal_uInt32* pDelArray, const sal_uInt32 nSize )
 {
-    const sal_uInt32 nCount = aDelList.Count();
+    const size_t nListSize = aDelList.size();
 
-    DBG_ASSERT( pDelArray && ( nSize == nCount ), "Array nicht initialisiert!" );
+    DBG_ASSERT( pDelArray && ( nSize == nListSize ), "Array nicht initialisiert!" );
 
-    if ( pDelArray && ( nSize == nCount ) )
-        for ( sal_uInt16 i = 0; i < aDelList.Count(); ++i )
-            *pDelArray++ = aDelList[i];
+    if ( pDelArray && ( nSize == nListSize ) )
+        for (std::vector<sal_uInt32>::const_iterator it(aDelList.begin()); it != aDelList.end(); ++it )
+            *pDelArray++ = *it;
 }
 
 // -----------------------------------------------------------------------
@@ -229,21 +223,18 @@ void SvxNumberFormatShell::FormatChanged( sal_uInt16  nFmtLbPos,
                                           String& rPreviewStr,
                                           Color*& rpFontColor )
 {
-    //nCurFormatKey = pCurFmtTable->GetKey( pCurFmtTable->GetObject( nFmtLbPos ) );
-
-    if(nFmtLbPos<aCurEntryList.Count())
+    if( static_cast<size_t>(nFmtLbPos) < aCurEntryList.size() )
     {
-        nCurFormatKey=aCurEntryList[nFmtLbPos];
+        nCurFormatKey = aCurEntryList[nFmtLbPos];
 
-        if(nCurFormatKey!=NUMBERFORMAT_ENTRY_NOT_FOUND)
+        if( nCurFormatKey != NUMBERFORMAT_ENTRY_NOT_FOUND )
         {
             GetPreviewString_Impl( rPreviewStr, rpFontColor );
         }
-        else if(nCurCategory==NUMBERFORMAT_CURRENCY)
+        else if( nCurCategory == NUMBERFORMAT_CURRENCY )
         {
             if(nFmtLbPos<aCurrencyFormatList.Count())
             {
-                //nCurFormatKey=nFmtLbPos;
                 MakePrevStringFromVal(*aCurrencyFormatList[nFmtLbPos],
                                     rPreviewStr,rpFontColor,nValNum);
             }
@@ -263,20 +254,19 @@ sal_Bool SvxNumberFormatShell::AddFormat( String& rFormat,  xub_StrLen& rErrPos,
     {
         if ( IsRemoved_Impl( nAddKey ) )
         {
-            // Key suchen und loeschen
             sal_Bool    bFound  = sal_False;
-            sal_uInt16  nAt     = 0;
+            std::vector<sal_uInt32>::iterator nAt = aDelList.begin();
 
-            for ( sal_uInt16 i = 0; !bFound && i < aDelList.Count(); ++i )
+            for (std::vector<sal_uInt32>::iterator it(aDelList.begin()); !bFound && it != aDelList.end(); ++it )
             {
-                if ( aDelList[i] == nAddKey )
+                if ( *it == nAddKey )
                 {
                     bFound  = sal_True;
-                    nAt     = i;
+                    nAt = it;
                 }
             }
             DBG_ASSERT( bFound, "Key not found" );
-            aDelList.Remove( nAt );
+            aDelList.erase( nAt );
             bInserted = sal_True;
         }
         else
@@ -309,7 +299,7 @@ sal_Bool SvxNumberFormatShell::AddFormat( String& rFormat,  xub_StrLen& rErrPos,
     {
         nCurFormatKey = nAddKey;
         DBG_ASSERT( !IsAdded_Impl( nCurFormatKey ), "Doppeltes Format!" );
-        aAddList.Insert( nCurFormatKey, aAddList.Count() );
+        aAddList.push_back( nCurFormatKey );
 
         // aktuelle Tabelle holen
         pCurFmtTable = &(pFormatter->GetEntryTable( nCurCategory,
@@ -345,27 +335,27 @@ sal_Bool SvxNumberFormatShell::RemoveFormat( const String&  rFormat,
 
     if ( (nDelKey != NUMBERFORMAT_ENTRY_NOT_FOUND) && !IsRemoved_Impl( nDelKey ) )
     {
-        aDelList.Insert( nDelKey, aDelList.Count() );
+        aDelList.push_back( nDelKey );
 
         if ( IsAdded_Impl( nDelKey ) )
         {
-            // Key suchen und loeschen
-            sal_Bool    bFound  = sal_False;
-            sal_uInt16  nAt     = 0;
+            bool bFound = false;
+            std::vector<sal_uInt32>::iterator nAt = aAddList.begin();
 
-            for ( sal_uInt16 i = 0; !bFound && i < aAddList.Count(); ++i )
+            for ( std::vector<sal_uInt32>::iterator it(aAddList.begin()); !bFound && it != aAddList.end(); ++it )
             {
-                if ( aAddList[i] == nDelKey )
+                if ( *it == nDelKey )
                 {
-                    bFound  = sal_True;
-                    nAt     = i;
+                    bFound = true;
+                    nAt = it;
                 }
             }
             DBG_ASSERT( bFound, "Key not found" );
-            aAddList.Remove( nAt );
+            if( bFound )
+                aAddList.erase( nAt );
         }
 
-        nCurCategory=pFormatter->GetType(nDelKey); //@@ 01.10.97
+        nCurCategory=pFormatter->GetType(nDelKey);
         pCurFmtTable = &(pFormatter->GetEntryTable( nCurCategory,
                                                     nCurFormatKey,
                                                     eCurLanguage ));
@@ -375,7 +365,6 @@ sal_Bool SvxNumberFormatShell::RemoveFormat( const String&  rFormat,
 
         CategoryToPos_Impl( nCurCategory, rCatLbSelPos );
         rFmtSelPos = FillEntryList_Impl( rFmtEntries );
-        //rFmtSelPos = (short) nCurFormatKey; //@@ 01.10.97
     }
     return sal_True;
 }
@@ -601,10 +590,11 @@ short SvxNumberFormatShell::FillEntryList_Impl( SvStrings& rList )
      * so wird SELPOS_NONE geliefert.
      */
     short nSelPos=0;
-    aCurEntryList.Remove(nSelPos,aCurEntryList.Count());
-    sal_uInt16          nPrivCat = CAT_CURRENCY;
+    sal_uInt16 nPrivCat = CAT_CURRENCY;
     nSelPos=SELPOS_NONE;
 
+    aCurEntryList.clear();
+
     if(nCurCategory==NUMBERFORMAT_ALL)
     {
         FillEListWithStd_Impl(rList,CAT_NUMBER,nSelPos);
@@ -706,7 +696,6 @@ short SvxNumberFormatShell::FillEListWithFormats_Impl( SvStrings& rList,short nS
     DBG_ASSERT( pCurFmtTable != NULL, "Unbekanntes Zahlenformat!" );
 
     const SvNumberformat*   pNumEntry   = pCurFmtTable->First();
-//  sal_uInt16          nCount      = 0;
     sal_uInt32          nNFEntry;
     String          aStrComment;
     String          aNewFormNInfo;
@@ -714,7 +703,6 @@ short SvxNumberFormatShell::FillEListWithFormats_Impl( SvStrings& rList,short nS
     String          a2PrevString;
 
     short           nMyCat      = SELPOS_NONE;
-//  short           nIq=0;
 
     long nIndex;
 
@@ -735,11 +723,11 @@ short SvxNumberFormatShell::FillEListWithFormats_Impl( SvStrings& rList,short nS
 
         if ( nNFEntry == nCurFormatKey )
         {
-            nSelPos = ( !IsRemoved_Impl( nNFEntry ) ) ? aCurEntryList.Count() : SELPOS_NONE;
+            nSelPos = ( !IsRemoved_Impl( nNFEntry ) ) ? aCurEntryList.size() : SELPOS_NONE;
         }
 
         rList.Insert( pStr,rList.Count());
-        aCurEntryList.Insert( nNFEntry, aCurEntryList.Count() );
+        aCurEntryList.push_back( nNFEntry );
     }
 
     return nSelPos;
@@ -752,7 +740,6 @@ short SvxNumberFormatShell::FillEListWithDateTime_Impl( SvStrings& rList,short n
     DBG_ASSERT( pCurFmtTable != NULL, "Unbekanntes Zahlenformat!" );
 
     const SvNumberformat*   pNumEntry   = pCurFmtTable->First();
-//  sal_uInt16          nCount      = 0;
     sal_uInt32          nNFEntry;
     String          aStrComment;
     String          aNewFormNInfo;
@@ -760,7 +747,6 @@ short SvxNumberFormatShell::FillEListWithDateTime_Impl( SvStrings& rList,short n
     String          a2PrevString;
 
     short           nMyCat      = SELPOS_NONE;
-//  short           nIq=0;
 
     long nIndex;
 
@@ -780,11 +766,11 @@ short SvxNumberFormatShell::FillEListWithDateTime_Impl( SvStrings& rList,short n
 
             if ( nNFEntry == nCurFormatKey )
             {
-                nSelPos = ( !IsRemoved_Impl( nNFEntry ) ) ? aCurEntryList.Count() : SELPOS_NONE;
+                nSelPos = ( !IsRemoved_Impl( nNFEntry ) ) ? aCurEntryList.size() : SELPOS_NONE;
             }
 
             rList.Insert( pStr,rList.Count());
-            aCurEntryList.Insert( nNFEntry, aCurEntryList.Count() );
+            aCurEntryList.push_back( nNFEntry );
         }
     }
 
@@ -836,7 +822,6 @@ short SvxNumberFormatShell::FillEListWithSysCurrencys( SvStrings& rList,short nS
     DBG_ASSERT( pCurFmtTable != NULL, "Unbekanntes Zahlenformat!" );
 
     const SvNumberformat*   pNumEntry   = pCurFmtTable->First();
-    sal_uInt16          nCount      = 0;
     sal_uInt32          nNFEntry;
     String          aStrComment;
     String          aNewFormNInfo;
@@ -846,7 +831,6 @@ short SvxNumberFormatShell::FillEListWithSysCurrencys( SvStrings& rList,short nS
     nCurCurrencyEntryPos=0;
 
     short           nMyCat      = SELPOS_NONE;
-//  short           nIq=0;
 
     NfIndexTableOffset eOffsetStart=NF_CURRENCY_START;
     NfIndexTableOffset eOffsetEnd=NF_CURRENCY_END;;
@@ -869,23 +853,20 @@ short SvxNumberFormatShell::FillEListWithSysCurrencys( SvStrings& rList,short nS
 
         if ( nNFEntry == nCurFormatKey )
         {
-            nSelPos = ( !IsRemoved_Impl( nNFEntry ) ) ? aCurEntryList.Count() : SELPOS_NONE;
+            nSelPos = ( !IsRemoved_Impl( nNFEntry ) ) ? aCurEntryList.size() : SELPOS_NONE;
         }
 
         rList.Insert( pStr,rList.Count());
-        aCurEntryList.Insert( nNFEntry, aCurEntryList.Count() );
+        aCurEntryList.push_back( nNFEntry );
     }
 
     if(nCurCategory!=NUMBERFORMAT_ALL)
     {
         pNumEntry   = pCurFmtTable->First();
-        nCount      = 0;
         while ( pNumEntry )
         {
             sal_uInt32 nKey = pCurFmtTable->GetCurKey();
 
-            nCount++;
-
             if ( !IsRemoved_Impl( nKey ))
             {
                 sal_Bool bUserNewCurrency=sal_False;
@@ -910,9 +891,9 @@ short SvxNumberFormatShell::FillEListWithSysCurrencys( SvStrings& rList,short nS
 
                     const StringPtr pStr = new String(aNewFormNInfo);
 
-                    if ( nKey == nCurFormatKey ) nSelPos =aCurEntryList.Count();
+                    if ( nKey == nCurFormatKey ) nSelPos =aCurEntryList.size();
                     rList.Insert( pStr,rList.Count());
-                    aCurEntryList.Insert( nKey, aCurEntryList.Count() );
+                    aCurEntryList.push_back( nKey );
                 }
             }
             pNumEntry = pCurFmtTable->Next();
@@ -932,13 +913,11 @@ short SvxNumberFormatShell::FillEListWithUserCurrencys( SvStrings& rList,short n
 
     DBG_ASSERT( pCurFmtTable != NULL, "Unbekanntes Zahlenformat!" );
 
-    sal_uInt16          nCount      = 0;
     String          aStrComment;
     String          aNewFormNInfo;
     String          aPrevString;
     String          a2PrevString;
     short           nMyCat = SELPOS_NONE;
-//  short           nIq=0;
 
     const NfCurrencyEntry* pTmpCurrencyEntry;
     sal_Bool        bTmpBanking, bAdaptSelPos;
@@ -946,7 +925,7 @@ short SvxNumberFormatShell::FillEListWithUserCurrencys( SvStrings& rList,short n
     XubString       rBankSymbol;
 
     SvStrings       aList;
-    SvULongs        aKeyList;
+    std::vector<sal_uInt32> aKeyList;
 
     /*sal_Bool bFlag=*/pFormatter->GetNewCurrencySymbolString(nCurFormatKey,rSymbol,
                 &pTmpCurrencyEntry,&bTmpBanking);
@@ -989,8 +968,6 @@ short SvxNumberFormatShell::FillEListWithUserCurrencys( SvStrings& rList,short n
     {
         sal_uInt32 nKey = pCurFmtTable->GetCurKey();
 
-        nCount++;
-
         if ( !IsRemoved_Impl( nKey ) )
         {
             if( pNumEntry->GetType() & NUMBERFORMAT_DEFINED ||
@@ -1001,13 +978,15 @@ short SvxNumberFormatShell::FillEListWithUserCurrencys( SvStrings& rList,short n
                 CategoryToPos_Impl(nMyCat,nMyType);
                 aNewFormNInfo=  pNumEntry->GetFormatstring();
 
-                sal_Bool bInsFlag=sal_False;
+                bool bInsFlag = false;
                 if ( pNumEntry->HasNewCurrency() )
-                    bInsFlag = sal_True;    // merge locale formats into currency selection
+                {
+                    bInsFlag = true;	// merge locale formats into currency selection
+                }
                 else if( (!bTmpBanking && aNewFormNInfo.Search(rSymbol)!=STRING_NOTFOUND) ||
                    (bTmpBanking && aNewFormNInfo.Search(rBankSymbol)!=STRING_NOTFOUND) )
                 {
-                    bInsFlag=sal_True;
+                    bInsFlag = true;
                 }
                 else if(aNewFormNInfo.Search(rShortSymbol)!=STRING_NOTFOUND)
                 {
@@ -1015,12 +994,12 @@ short SvxNumberFormatShell::FillEListWithUserCurrencys( SvStrings& rList,short n
                     const NfCurrencyEntry* pTstCurrencyEntry;
                     sal_Bool bTstBanking;
 
-                    /*sal_Bool bTstFlag=*/pFormatter->GetNewCurrencySymbolString(nKey,rTstSymbol,
+                    pFormatter->GetNewCurrencySymbolString(nKey,rTstSymbol,
                                 &pTstCurrencyEntry,&bTstBanking);
 
                     if(pTmpCurrencyEntry==pTstCurrencyEntry && bTstBanking==bTmpBanking)
                     {
-                        bInsFlag=sal_True;
+                        bInsFlag = true;
                     }
 
                 }
@@ -1030,7 +1009,7 @@ short SvxNumberFormatShell::FillEListWithUserCurrencys( SvStrings& rList,short n
                     const StringPtr pStr = new String(aNewFormNInfo);
 
                     aList.Insert( pStr,aList.Count());
-                    aKeyList.Insert( nKey, aKeyList.Count() );
+                    aKeyList.push_back( nKey );
                 }
             }
         }
@@ -1065,47 +1044,47 @@ short SvxNumberFormatShell::FillEListWithUserCurrencys( SvStrings& rList,short n
         }
     }
 
-    sal_uInt16 i,nPos;
-    sal_uInt16 nOldListCount = rList.Count();
-    for( i=0, nPos=nOldListCount; i<aWSStringsDtor.Count(); i++)
+    size_t i,nPos;
+    size_t nOldListCount = rList.Count();
+    for( i = 0, nPos = nOldListCount; i < aWSStringsDtor.Count(); ++i)
     {
-        sal_Bool bFlag=sal_True;
+        bool bFlag = true;
         String aInsStr(*aWSStringsDtor[i]);
-        sal_uInt16 j;
-        for(j=0;j<aList.Count();j++)
+        size_t j;
+        for( j=0; j < aList.Count(); ++j )
         {
             const StringPtr pTestStr=aList[j];
 
             if(*pTestStr==aInsStr)
             {
-                bFlag=sal_False;
+                bFlag = false;
                 break;
             }
         }
         if(bFlag)
         {
             rList.Insert(new String(aInsStr),nPos);
-            aCurEntryList.Insert( NUMBERFORMAT_ENTRY_NOT_FOUND, nPos++);
+            aCurEntryList.insert( aCurEntryList.begin() + (nPos++), NUMBERFORMAT_ENTRY_NOT_FOUND);
         }
         else
         {
             rList.Insert(aList[j],nPos);
             aList.Remove(j);
-            aCurEntryList.Insert( aKeyList[j],nPos++);
-            aKeyList.Remove(j);
+            aCurEntryList.insert( aCurEntryList.begin() + (nPos++), aKeyList[j]);
+            aKeyList.erase( aKeyList.begin()+j );
         }
     }
 
-    for(i=0;i<aKeyList.Count();i++)
+    for( i = 0; i < aKeyList.size(); ++i )
     {
-        if(aKeyList[i]!=NUMBERFORMAT_ENTRY_NOT_FOUND)
+        if( aKeyList[i] != NUMBERFORMAT_ENTRY_NOT_FOUND )
         {
             rList.Insert(aList[i],rList.Count());
-            aCurEntryList.Insert( aKeyList[i],aCurEntryList.Count());
+            aCurEntryList.push_back( aKeyList[i] );
         }
     }
 
-    for(i=nOldListCount;i<rList.Count();i++)
+    for( i = nOldListCount; i < rList.Count(); ++i )
     {
         aCurrencyFormatList.Insert(new String(*rList[i]),aCurrencyFormatList.Count());
 
@@ -1132,14 +1111,12 @@ short SvxNumberFormatShell::FillEListWithUsD_Impl( SvStrings& rList, sal_uInt16
     DBG_ASSERT( pCurFmtTable != NULL, "Unbekanntes Zahlenformat!" );
 
     const SvNumberformat*   pNumEntry   = pCurFmtTable->First();
-    sal_uInt16          nCount      = 0;
     String          aStrComment;
     String          aNewFormNInfo;
     String          aPrevString;
     String          a2PrevString;
 
     short           nMyCat      = SELPOS_NONE;
-//  short           nIq=0;
     sal_Bool        bAdditional = (nPrivCat != CAT_USERDEFINED &&
                                     nCurCategory != NUMBERFORMAT_ALL);
 
@@ -1147,8 +1124,6 @@ short SvxNumberFormatShell::FillEListWithUsD_Impl( SvStrings& rList, sal_uInt16
     {
         sal_uInt32 nKey = pCurFmtTable->GetCurKey();
 
-        nCount++;
-
         if ( !IsRemoved_Impl( nKey ) )
         {
             if( (pNumEntry->GetType() & NUMBERFORMAT_DEFINED) ||
@@ -1170,9 +1145,9 @@ short SvxNumberFormatShell::FillEListWithUsD_Impl( SvStrings& rList, sal_uInt16
                 {
                     const StringPtr pStr = new String(aNewFormNInfo);
 
-                    if ( nKey == nCurFormatKey ) nSelPos =aCurEntryList.Count();
+                    if ( nKey == nCurFormatKey ) nSelPos = aCurEntryList.size();
                     rList.Insert( pStr,rList.Count());
-                    aCurEntryList.Insert( nKey, aCurEntryList.Count() );
+                    aCurEntryList.push_back( nKey );
                 }
             }
         }
@@ -1203,8 +1178,8 @@ void SvxNumberFormatShell::GetPreviewString_Impl( String& rString, Color*& rpCol
 sal_Bool SvxNumberFormatShell::IsRemoved_Impl( sal_uInt32 nKey )
 {
     sal_Bool bFound = sal_False;
-    for ( sal_uInt16 i = 0; !bFound && i < aDelList.Count(); ++i )
-        if ( aDelList[i] == nKey )
+    for (std::vector<sal_uInt32>::const_iterator it(aDelList.begin()); !bFound && it != aDelList.end(); ++it )
+        if ( *it == nKey )
             bFound = sal_True;
     return bFound;
 }
@@ -1214,8 +1189,8 @@ sal_Bool SvxNumberFormatShell::IsRemoved_Impl( sal_uInt32 nKey )
 sal_Bool SvxNumberFormatShell::IsAdded_Impl( sal_uInt32 nKey )
 {
     sal_Bool bFound = sal_False;
-    for ( sal_uInt16 i = 0; !bFound && i < aAddList.Count(); ++i )
-        if ( aAddList[i] == nKey )
+    for ( std::vector<sal_uInt32>::const_iterator it(aAddList.begin()); !bFound && it != aAddList.end(); ++it )
+        if ( *it == nKey )
             bFound = sal_True;
     return bFound;
 }
@@ -1339,7 +1314,7 @@ String SvxNumberFormatShell::GetComment4Entry(short nEntry)
     if(nEntry < 0)
         return String();
 
-    if(nEntry<aCurEntryList.Count())
+    if( static_cast<size_t>(nEntry) < aCurEntryList.size())
     {
         sal_uInt32  nMyNfEntry=aCurEntryList[nEntry];
         pNumEntry = pFormatter->GetEntry(nMyNfEntry);
@@ -1370,7 +1345,7 @@ short SvxNumberFormatShell::GetCategory4Entry(short nEntry)
     const SvNumberformat *pNumEntry;
     if(nEntry<0) return 0;
 
-    if(nEntry<aCurEntryList.Count())
+    if( static_cast<size_t>(nEntry) < aCurEntryList.size() )
     {
         sal_uInt32  nMyNfEntry=aCurEntryList[nEntry];
 
@@ -1415,7 +1390,8 @@ sal_Bool SvxNumberFormatShell::GetUserDefined4Entry(short nEntry)
 {
     const SvNumberformat *pNumEntry;
     if(nEntry<0) return 0;
-    if(nEntry<aCurEntryList.Count())
+
+    if( static_cast<size_t>(nEntry) < aCurEntryList.size())
     {
         sal_uInt32  nMyNfEntry=aCurEntryList[nEntry];
         pNumEntry = pFormatter->GetEntry(nMyNfEntry);
@@ -1488,9 +1464,11 @@ String SvxNumberFormatShell::GetFormat4Entry(short nEntry)
 short SvxNumberFormatShell::GetListPos4Entry(sal_uInt32 nIdx)
 {
     short nSelP=SELPOS_NONE;
-    if( aCurEntryList.Count() <= 0x7fff )
+
+    // Check list size against return type limit.
+    if( aCurEntryList.Count() <= ::std::numeric_limits< short >::max() )
     {
-        for(short i=0;i<aCurEntryList.Count();i++)
+        for(size_t i=0; i < aCurEntryList.size(); ++i)
         {
             if(aCurEntryList[i]==nIdx)
             {
@@ -1501,7 +1479,7 @@ short SvxNumberFormatShell::GetListPos4Entry(sal_uInt32 nIdx)
     }
     else
     {
-        OSL_FAIL("svx::SvxNumberFormatShell::GetListPos4Entry(), list got to large!" );
+        OSL_FAIL("svx::SvxNumberFormatShell::GetListPos4Entry(), list got too large!" );
     }
     return nSelP;
 }


More information about the Libreoffice-commits mailing list