Kaydet (Commit) 9472e9c7 authored tarafından Eike Rathke's avatar Eike Rathke

changes to "tools/table.hxx to std::map conversion"

* use consistent indenting with 4 spaces (instead of tabs (plus one space))
* use   erase(it++)   instead of   erase(it); ++it   to not access invalidated
  iterator
* for   First(); Remove(); Next()   loops over entire Table use   map::clear()
  at the end if it isn't in a dtor
* use existing typedef SvNumberFormatTable in numfmtsh.hxx instead of
  redefining, which means include zforlist.hxx now and some other forward
  declarations can be removed

* removed inlined duplicated code of GetEntry(), implemented it in
  zforlist.cxx instead and made const GetFormatEntry() just call GetEntry()
* removed the temporary sal_uIntPtr nFormat to be used as key, the sal_uIntPtr
  was only used because Table effectively had pointer size as keys.
* made initial assignments of nDefaultFormat and nDefaultCurrencyFormat use
  the ternary conditional operator
üst 0979307b
...@@ -561,8 +561,7 @@ public: ...@@ -561,8 +561,7 @@ public:
sal_uInt32 GetEntryKey( const String& sStr, LanguageType eLnge = LANGUAGE_DONTKNOW ); sal_uInt32 GetEntryKey( const String& sStr, LanguageType eLnge = LANGUAGE_DONTKNOW );
/// Return the format for a format index /// Return the format for a format index
const SvNumberformat* GetEntry(sal_uInt32 nKey) const const SvNumberformat* GetEntry( sal_uInt32 nKey ) const;
{ 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 /// Return the format index of the standard default number format for language/country
sal_uInt32 GetStandardIndex(LanguageType eLnge = LANGUAGE_DONTKNOW); sal_uInt32 GetStandardIndex(LanguageType eLnge = LANGUAGE_DONTKNOW);
...@@ -800,7 +799,7 @@ private: ...@@ -800,7 +799,7 @@ private:
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceManager; ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceManager;
::com::sun::star::lang::Locale aLocale; ::com::sun::star::lang::Locale aLocale;
SvNumberFormatTable aFTable; // Table of format keys to format entries SvNumberFormatTable aFTable; // Table of format keys to format entries
typedef std::map<sal_uInt32, sal_uInt32> DefaultFormatKeysMap; typedef std::map<sal_uInt32, sal_uInt32> DefaultFormatKeysMap;
DefaultFormatKeysMap aDefaultFormatKeys; // Table of default standard to format keys DefaultFormatKeysMap aDefaultFormatKeys; // Table of default standard to format keys
SvNumberFormatTable* pFormatTable; // For the UI dialog SvNumberFormatTable* pFormatTable; // For the UI dialog
SvNumberFormatterIndexTable* pMergeTable; // List of indices for merging two formatters SvNumberFormatterIndexTable* pMergeTable; // List of indices for merging two formatters
...@@ -913,8 +912,12 @@ private: ...@@ -913,8 +912,12 @@ private:
sal_Int32 nCount, bool bCheckCorrectness = true sal_Int32 nCount, bool bCheckCorrectness = true
); );
SVL_DLLPRIVATE SvNumberformat* GetFormatEntry(sal_uInt32 nKey); // Obtain the format entry for a given key index.
SVL_DLLPRIVATE const SvNumberformat* GetFormatEntry(sal_uInt32 nKey) const; SVL_DLLPRIVATE SvNumberformat* GetFormatEntry( sal_uInt32 nKey );
SVL_DLLPRIVATE const SvNumberformat* GetFormatEntry( sal_uInt32 nKey ) const
{
return GetEntry( nKey);
}
// used as a loop body inside of GetNewCurrencySymbolString() and GetCurrencyEntry() // used as a loop body inside of GetNewCurrencySymbolString() and GetCurrencyEntry()
#ifndef DBG_UTIL #ifndef DBG_UTIL
...@@ -1001,13 +1004,13 @@ public: ...@@ -1001,13 +1004,13 @@ public:
inline sal_uInt32 SvNumberFormatter::GetMergeFmtIndex( sal_uInt32 nOldFmt ) const inline sal_uInt32 SvNumberFormatter::GetMergeFmtIndex( sal_uInt32 nOldFmt ) const
{ {
if (pMergeTable) if (pMergeTable)
{ {
SvNumberFormatterIndexTable::iterator it = pMergeTable->find(nOldFmt); SvNumberFormatterIndexTable::iterator it = pMergeTable->find(nOldFmt);
if (it != pMergeTable->end()) if (it != pMergeTable->end())
return it->second; return it->second;
} }
return nOldFmt; return nOldFmt;
} }
inline bool SvNumberFormatter::HasMergeFmtTbl() const inline bool SvNumberFormatter::HasMergeFmtTbl() const
......
...@@ -466,8 +466,8 @@ uno::Sequence<sal_Int32> SAL_CALL SvNumberFormatsObj::queryKeys( sal_Int16 nType ...@@ -466,8 +466,8 @@ uno::Sequence<sal_Int32> SAL_CALL SvNumberFormatsObj::queryKeys( sal_Int16 nType
sal_uInt32 nCount = rTable.size(); sal_uInt32 nCount = rTable.size();
uno::Sequence<sal_Int32> aSeq(nCount); uno::Sequence<sal_Int32> aSeq(nCount);
sal_Int32* pAry = aSeq.getArray(); sal_Int32* pAry = aSeq.getArray();
sal_uInt32 i=0; sal_uInt32 i=0;
for (SvNumberFormatTable::iterator it = rTable.begin(); it != rTable.end(); ++it, ++i) for (SvNumberFormatTable::iterator it = rTable.begin(); it != rTable.end(); ++it, ++i)
pAry[i] = it->first; pAry[i] = it->first;
return aSeq; return aSeq;
......
This diff is collapsed.
...@@ -34,15 +34,12 @@ ...@@ -34,15 +34,12 @@
#include "svx/svxdllapi.h" #include "svx/svxdllapi.h"
#include <svl/svstdarr.hxx> #include <svl/svstdarr.hxx>
#include <svl/zforlist.hxx>
#include <vector> #include <vector>
#include <map> #include <map>
class Color; class Color;
class SvNumberFormatter;
class SvNumberformat;
typedef std::map<sal_uInt32, SvNumberformat*> SvNumberFormatTable;
class NfCurrencyEntry;
enum SvxNumberValueType enum SvxNumberValueType
{ {
......
...@@ -842,12 +842,12 @@ short SvxNumberFormatShell::FillEListWithSysCurrencys( std::vector<String*>& rLi ...@@ -842,12 +842,12 @@ short SvxNumberFormatShell::FillEListWithSysCurrencys( std::vector<String*>& rLi
if(nCurCategory!=NUMBERFORMAT_ALL) if(nCurCategory!=NUMBERFORMAT_ALL)
{ {
SvNumberFormatTable::iterator it = pCurFmtTable->begin(); SvNumberFormatTable::iterator it = pCurFmtTable->begin();
while ( it != pCurFmtTable->end() ) while ( it != pCurFmtTable->end() )
{ {
sal_uInt32 nKey = it->first; sal_uInt32 nKey = it->first;
pNumEntry = it->second; pNumEntry = it->second;
if ( !IsRemoved_Impl( nKey )) if ( !IsRemoved_Impl( nKey ))
{ {
...@@ -878,7 +878,7 @@ short SvxNumberFormatShell::FillEListWithSysCurrencys( std::vector<String*>& rLi ...@@ -878,7 +878,7 @@ short SvxNumberFormatShell::FillEListWithSysCurrencys( std::vector<String*>& rLi
aCurEntryList.push_back( nKey ); aCurEntryList.push_back( nKey );
} }
} }
++it; ++it;
} }
} }
return nSelPos; return nSelPos;
...@@ -945,11 +945,11 @@ short SvxNumberFormatShell::FillEListWithUserCurrencys( std::vector<String*>& rL ...@@ -945,11 +945,11 @@ short SvxNumberFormatShell::FillEListWithUserCurrencys( std::vector<String*>& rL
pTmpCurrencyEntry->BuildSymbolString(rShortSymbol,bTmpBanking,true); pTmpCurrencyEntry->BuildSymbolString(rShortSymbol,bTmpBanking,true);
} }
SvNumberFormatTable::iterator it = pCurFmtTable->begin(); SvNumberFormatTable::iterator it = pCurFmtTable->begin();
while ( it != pCurFmtTable->end() ) while ( it != pCurFmtTable->end() )
{ {
sal_uInt32 nKey = it->first; sal_uInt32 nKey = it->first;
const SvNumberformat* pNumEntry = it->second; const SvNumberformat* pNumEntry = it->second;
if ( !IsRemoved_Impl( nKey ) ) if ( !IsRemoved_Impl( nKey ) )
{ {
...@@ -964,7 +964,7 @@ short SvxNumberFormatShell::FillEListWithUserCurrencys( std::vector<String*>& rL ...@@ -964,7 +964,7 @@ short SvxNumberFormatShell::FillEListWithUserCurrencys( std::vector<String*>& rL
bool bInsFlag = false; bool bInsFlag = false;
if ( pNumEntry->HasNewCurrency() ) if ( pNumEntry->HasNewCurrency() )
{ {
bInsFlag = true; // merge locale formats into currency selection bInsFlag = true; // merge locale formats into currency selection
} }
else if( (!bTmpBanking && aNewFormNInfo.Search(rSymbol)!=STRING_NOTFOUND) || else if( (!bTmpBanking && aNewFormNInfo.Search(rSymbol)!=STRING_NOTFOUND) ||
(bTmpBanking && aNewFormNInfo.Search(rBankSymbol)!=STRING_NOTFOUND) ) (bTmpBanking && aNewFormNInfo.Search(rBankSymbol)!=STRING_NOTFOUND) )
...@@ -994,7 +994,7 @@ short SvxNumberFormatShell::FillEListWithUserCurrencys( std::vector<String*>& rL ...@@ -994,7 +994,7 @@ short SvxNumberFormatShell::FillEListWithUserCurrencys( std::vector<String*>& rL
} }
} }
} }
++it; ++it;
} }
NfWSStringsDtor aWSStringsDtor; NfWSStringsDtor aWSStringsDtor;
...@@ -1101,11 +1101,11 @@ short SvxNumberFormatShell::FillEListWithUsD_Impl( std::vector<String*>& rList, ...@@ -1101,11 +1101,11 @@ short SvxNumberFormatShell::FillEListWithUsD_Impl( std::vector<String*>& rList,
bool bAdditional = (nPrivCat != CAT_USERDEFINED && bool bAdditional = (nPrivCat != CAT_USERDEFINED &&
nCurCategory != NUMBERFORMAT_ALL); nCurCategory != NUMBERFORMAT_ALL);
SvNumberFormatTable::iterator it = pCurFmtTable->begin(); SvNumberFormatTable::iterator it = pCurFmtTable->begin();
while ( it != pCurFmtTable->end() ) while ( it != pCurFmtTable->end() )
{ {
sal_uInt32 nKey = it->first; sal_uInt32 nKey = it->first;
const SvNumberformat* pNumEntry = it->second; const SvNumberformat* pNumEntry = it->second;
if ( !IsRemoved_Impl( nKey ) ) if ( !IsRemoved_Impl( nKey ) )
{ {
...@@ -1134,7 +1134,7 @@ short SvxNumberFormatShell::FillEListWithUsD_Impl( std::vector<String*>& rList, ...@@ -1134,7 +1134,7 @@ short SvxNumberFormatShell::FillEListWithUsD_Impl( std::vector<String*>& rList,
} }
} }
} }
++it; ++it;
} }
return nSelPos; return nSelPos;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment