diff options
author | Mohammed Abdul Azeem <azeemmysore@gmail.com> | 2016-03-23 03:18:14 +0530 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2016-03-23 13:42:19 +0000 |
commit | f9cf53a082f1d99b313ebd09c8791541859eac40 (patch) | |
tree | d201bc51b5763b15e144eda189e942553d774609 /svx | |
parent | 8f61630300974b0a41e8b2ea6b9ec87f1c9faa5f (diff) |
tdf#82641 Changes to currency drop-down list
Common codes have been shared in a static function. Now the list
shows complete set of currency options.
Change-Id: I17639b3123d2fd86c5a414df927ef5f07e37d845
Reviewed-on: https://gerrit.libreoffice.org/23444
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/items/numfmtsh.cxx | 79 | ||||
-rw-r--r-- | svx/source/tbxctrls/tbcontrl.cxx | 147 |
2 files changed, 107 insertions, 119 deletions
diff --git a/svx/source/items/numfmtsh.cxx b/svx/source/items/numfmtsh.cxx index 12dc40982188..7d78ecac523d 100644 --- a/svx/source/items/numfmtsh.cxx +++ b/svx/source/items/numfmtsh.cxx @@ -26,12 +26,8 @@ #include <svl/zformat.hxx> #include <svl/currencytable.hxx> -#include <svtools/langtab.hxx> -#include <vcl/svapp.hxx> -#include <vcl/settings.hxx> -#include <comphelper/processfactory.hxx> - #include <svx/numfmtsh.hxx> +#include <svx/tbcontrl.hxx> #include <limits> @@ -1369,7 +1365,7 @@ void SvxNumberFormatShell::GetCurrencySymbols(std::vector<OUString>& rList, sal_ bool bFlag=(pTmpCurrencyEntry==nullptr); - GetCurrencySymbols(rList, bFlag); + SvxCurrencyToolBoxControl::GetCurrencySymbols( rList, bFlag, aCurCurrencyList ); if(pPos!=nullptr) { @@ -1402,77 +1398,6 @@ void SvxNumberFormatShell::GetCurrencySymbols(std::vector<OUString>& rList, sal_ } -void SvxNumberFormatShell::GetCurrencySymbols(std::vector<OUString>& rList, bool bFlag) -{ - aCurCurrencyList.clear(); - - const NfCurrencyTable& rCurrencyTable=SvNumberFormatter::GetTheCurrencyTable(); - sal_uInt16 nCount=rCurrencyTable.size(); - - sal_uInt16 nStart=1; - - OUString aString( ApplyLreOrRleEmbedding( rCurrencyTable[0].GetSymbol())); - aString += " "; - aString += ApplyLreOrRleEmbedding( SvtLanguageTable::GetLanguageString( rCurrencyTable[0].GetLanguage())); - - rList.push_back(aString); - sal_uInt16 nAuto=(sal_uInt16)-1; - aCurCurrencyList.push_back(nAuto); - - if(bFlag) - { - rList.push_back(aString); - aCurCurrencyList.push_back(0); - ++nStart; - } - - CollatorWrapper aCollator( ::comphelper::getProcessComponentContext()); - aCollator.loadDefaultCollator( Application::GetSettings().GetLanguageTag().getLocale(), 0); - - const OUString aTwoSpace(" "); - - for(sal_uInt16 i = 1; i < nCount; ++i) - { - OUString aStr( ApplyLreOrRleEmbedding( rCurrencyTable[i].GetBankSymbol())); - aStr += aTwoSpace; - aStr += ApplyLreOrRleEmbedding( rCurrencyTable[i].GetSymbol()); - aStr += aTwoSpace; - aStr += ApplyLreOrRleEmbedding( SvtLanguageTable::GetLanguageString( rCurrencyTable[i].GetLanguage())); - - sal_uInt16 j = nStart; - for(; j < rList.size(); ++j) - if (aCollator.compareString(aStr, rList[j]) < 0) - break; // insert before first greater than - - rList.insert(rList.begin() + j, aStr); - aCurCurrencyList.insert(aCurCurrencyList.begin() + j, i); - } - - // Append ISO codes to symbol list. - // XXX If this is to be changed, various other places would had to be - // adapted that assume this order! - sal_uInt16 nCont = rList.size(); - - for(sal_uInt16 i = 1; i < nCount; ++i) - { - bool bInsert = true; - OUString aStr(ApplyLreOrRleEmbedding(rCurrencyTable[i].GetBankSymbol())); - - sal_uInt16 j = nCont; - for(; j < rList.size() && bInsert; ++j) - { - if(rList[j] == aStr) - bInsert = false; - else if (aCollator.compareString(aStr, rList[j]) < 0) - break; // insert before first greater than - } - if(bInsert) - { - rList.insert(rList.begin() + j, aStr); - aCurCurrencyList.insert(aCurCurrencyList.begin()+j, i); - } - } -} void SvxNumberFormatShell::SetCurrencySymbol(sal_uInt32 nPos) { diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx index 50a55a82dcf7..0a5690108b3b 100644 --- a/svx/source/tbxctrls/tbcontrl.cxx +++ b/svx/source/tbxctrls/tbcontrl.cxx @@ -1885,43 +1885,40 @@ SvxCurrencyList_Impl::SvxCurrencyList_Impl( SetOutputSizePixel( Size( 304, 144 ) ); std::vector< OUString > aList; + std::vector< sal_uInt16 > aCurrencyList; const NfCurrencyTable& rCurrencyTable = SvNumberFormatter::GetTheCurrencyTable(); - sal_uInt16 nCount = rCurrencyTable.size(); - - CollatorWrapper aCollator( ::comphelper::getProcessComponentContext()); - aCollator.loadDefaultCollator( Application::GetSettings().GetLanguageTag().getLocale(), 0); + sal_uInt16 nLen = rCurrencyTable.size(); - const OUString aTwoSpace(" "); - SvNumberFormatter aFormatter = SvNumberFormatter(rxContext, LANGUAGE_SYSTEM); + SvNumberFormatter aFormatter( rxContext, LANGUAGE_SYSTEM ); m_eFormatLanguage = aFormatter.GetLanguage(); - for(sal_uInt16 i = 0; i < nCount; ++i) - { - OUString aStr( rCurrencyTable[i].GetBankSymbol() ); - aStr += aTwoSpace; - aStr += rCurrencyTable[i].GetSymbol(); - aStr += aTwoSpace; - aStr += SvtLanguageTable::GetLanguageString( rCurrencyTable[i].GetLanguage() ); - NfWSStringsDtor aStringsDtor; - sal_uInt16 nDefaultFormat = aFormatter.GetCurrencyFormatStrings( aStringsDtor, rCurrencyTable[i], false ); - sal_uInt16 j = 0; - for(; j < aList.size(); ++j) - if ( aCollator.compareString( aStr, aList[j] ) < 0 ) - break; + SvxCurrencyToolBoxControl::GetCurrencySymbols( aList, true, aCurrencyList ); - aList.insert( aList.begin() + j, aStr ); - m_aFormatEntries.insert( m_aFormatEntries.begin() + j, aStringsDtor[nDefaultFormat] ); - } - - sal_uInt16 nPos = 0; + sal_uInt16 nPos = 0, nCount = 0; sal_Int32 nSelectedPos = -1; - for(std::vector< OUString >::iterator i = aList.begin(); i != aList.end(); ++i, ++nPos) + bool bIsSymbol; + NfWSStringsDtor aStringsDtor; + + for( std::vector< OUString >::iterator i = aList.begin(); i != aList.end(); ++i, ++nCount ) { - m_pCurrencyLb->InsertEntry (*i); - OUString *pFormatStr = &m_aFormatEntries[nPos]; - m_pCurrencyLb->SetEntryData( nPos, pFormatStr ); - if( *pFormatStr == m_rSelectedFormat ) - nSelectedPos = nPos; + sal_uInt16& rCurrencyIndex = aCurrencyList[ nCount ]; + if ( rCurrencyIndex < nLen ) + { + m_pCurrencyLb->InsertEntry( *i ); + const NfCurrencyEntry& aCurrencyEntry = rCurrencyTable[ rCurrencyIndex ]; + + if ( nPos < nLen ) + bIsSymbol = false; + else + bIsSymbol = true; + + sal_uInt16 nDefaultFormat = aFormatter.GetCurrencyFormatStrings( aStringsDtor, aCurrencyEntry, bIsSymbol ); + OUString& pFormatStr = aStringsDtor[ nDefaultFormat ]; + m_aFormatEntries.push_back( pFormatStr ); + if( pFormatStr == m_rSelectedFormat ) + nSelectedPos = nPos; + ++nPos; + } } m_pCurrencyLb->SetSelectHdl( LINK( this, SvxCurrencyList_Impl, SelectHdl ) ); SetText( SVX_RESSTR( RID_SVXSTR_TBLAFMT_CURRENCY ) ); @@ -2001,15 +1998,8 @@ IMPL_LINK_NOARG_TYPED(SvxCurrencyList_Impl, SelectHdl, ListBox&, void) if (!m_xControl.is()) return; - OUString* pFormat = static_cast<OUString*> ( - m_pCurrencyLb->GetEntryData( m_pCurrencyLb->GetSelectEntryPos() ) ); - - assert( pFormat ); - if ( pFormat ) - { - m_rSelectedFormat = *pFormat; - m_eSelectedLanguage = m_eFormatLanguage; - } + m_rSelectedFormat = m_aFormatEntries[ m_pCurrencyLb->GetSelectEntryPos() ]; + m_eSelectedLanguage = m_eFormatLanguage; m_xControl->Select( m_pCurrencyLb->GetSelectEntryPos() + 1 ); } @@ -3050,9 +3040,6 @@ VclPtr<SfxPopupWindow> SvxCurrencyToolBoxControl::CreatePopupWindow() void SvxCurrencyToolBoxControl::Select( sal_uInt16 nSelectModifier ) { - if (getenv("DO_NOTHING")) - return; - sal_uInt32 nFormatKey; if (m_aFormatString.isEmpty()) nFormatKey = NUMBERFORMAT_ENTRY_NOT_FOUND; @@ -3117,4 +3104,80 @@ Reference< css::accessibility::XAccessible > SvxFontNameBox_Impl::CreateAccessib return FontNameBox::CreateAccessible(); } +//static +void SvxCurrencyToolBoxControl::GetCurrencySymbols( std::vector<OUString>& rList, bool bFlag, + std::vector<sal_uInt16>& rCurrencyList ) +{ + rCurrencyList.clear(); + + const NfCurrencyTable& rCurrencyTable = SvNumberFormatter::GetTheCurrencyTable(); + sal_uInt16 nCount = rCurrencyTable.size(); + + sal_uInt16 nStart = 1; + + OUString aString( ApplyLreOrRleEmbedding( rCurrencyTable[0].GetSymbol() ) ); + aString += " "; + aString += ApplyLreOrRleEmbedding( SvtLanguageTable::GetLanguageString( + rCurrencyTable[0].GetLanguage() ) ); + + rList.push_back( aString ); + sal_uInt16 nAuto = ( sal_uInt16 )-1; + rCurrencyList.push_back( nAuto ); + + if( bFlag ) + { + rList.push_back( aString ); + rCurrencyList.push_back( 0 ); + ++nStart; + } + + CollatorWrapper aCollator( ::comphelper::getProcessComponentContext() ); + aCollator.loadDefaultCollator( Application::GetSettings().GetLanguageTag().getLocale(), 0 ); + + const OUString aTwoSpace(" "); + + for( sal_uInt16 i = 1; i < nCount; ++i ) + { + OUString aStr( ApplyLreOrRleEmbedding( rCurrencyTable[i].GetBankSymbol() ) ); + aStr += aTwoSpace; + aStr += ApplyLreOrRleEmbedding( rCurrencyTable[i].GetSymbol() ); + aStr += aTwoSpace; + aStr += ApplyLreOrRleEmbedding( SvtLanguageTable::GetLanguageString( + rCurrencyTable[i].GetLanguage() ) ); + + sal_uInt16 j = nStart; + for( ; j < rList.size(); ++j ) + if ( aCollator.compareString( aStr, rList[j] ) < 0 ) + break; // insert before first greater than + + rList.insert( rList.begin() + j, aStr ); + rCurrencyList.insert( rCurrencyList.begin() + j, i ); + } + + // Append ISO codes to symbol list. + // XXX If this is to be changed, various other places would had to be + // adapted that assume this order! + sal_uInt16 nCont = rList.size(); + + for ( sal_uInt16 i = 1; i < nCount; ++i ) + { + bool bInsert = true; + OUString aStr( ApplyLreOrRleEmbedding( rCurrencyTable[i].GetBankSymbol() ) ); + + sal_uInt16 j = nCont; + for ( ; j < rList.size() && bInsert; ++j ) + { + if( rList[j] == aStr ) + bInsert = false; + else if ( aCollator.compareString( aStr, rList[j] ) < 0 ) + break; // insert before first greater than + } + if ( bInsert ) + { + rList.insert( rList.begin() + j, aStr ); + rCurrencyList.insert( rCurrencyList.begin() + j, i ); + } + } +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |