sc/inc/addincol.hxx | 54 +++++---- sc/source/core/tool/addincol.cxx | 225 ++++++++++++++++++--------------------- 2 files changed, 136 insertions(+), 143 deletions(-)
New commits: commit c979adad481bd41bff90047b1e59ce1741e642e1 Author: Eike Rathke <er...@redhat.com> Date: Tue Apr 9 23:37:14 2013 +0200 sal_Bool to bool Change-Id: I2d9baed5032e267ac5053267d367723999526c8f diff --git a/sc/inc/addincol.hxx b/sc/inc/addincol.hxx index daa2931..15abd4c 100644 --- a/sc/inc/addincol.hxx +++ b/sc/inc/addincol.hxx @@ -27,7 +27,6 @@ #include <com/sun/star/sheet/ResultEvent.hpp> #include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/reflection/XIdlMethod.hpp> -#include <com/sun/star/sheet/LocalizedName.hpp> #include <i18nlangtag/lang.h> #include <rtl/ustring.h> #include "scdllapi.h" @@ -71,7 +70,7 @@ struct ScAddInArgDesc OUString aName; OUString aDescription; ScAddInArgumentType eType; - sal_Bool bOptional; + bool bOptional; }; class ScUnoAddInFuncData @@ -99,7 +98,7 @@ private: sal_uInt16 nCategory; OString sHelpId; mutable ::std::vector< LocalizedName > maCompNames; - mutable sal_Bool bCompInitialized; + mutable bool bCompInitialized; public: ScUnoAddInFuncData( const OUString& rNam, const OUString& rLoc, @@ -127,7 +126,7 @@ public: const OString GetHelpId() const { return sHelpId; } const ::std::vector< LocalizedName >& GetCompNames() const; - sal_Bool GetExcelName( LanguageType eDestLang, OUString& rRetExcelName ) const; + bool GetExcelName( LanguageType eDestLang, OUString& rRetExcelName ) const; void SetFunction( const com::sun::star::uno::Reference< com::sun::star::reflection::XIdlMethod>& rNewFunc, const com::sun::star::uno::Any& rNewObj ); @@ -146,7 +145,7 @@ private: ScAddInHashMap* pExactHashMap; ///< exact internal name ScAddInHashMap* pNameHashMap; ///< internal name upper ScAddInHashMap* pLocalHashMap; ///< localized name upper - sal_Bool bInitialized; + bool bInitialized; void Initialize(); void ReadConfiguration(); @@ -162,7 +161,7 @@ public: ~ScUnoAddInCollection(); /// User enetered name. rUpperName MUST already be upper case! - OUString FindFunction( const OUString& rUpperName, sal_Bool bLocalFirst ); + OUString FindFunction( const OUString& rUpperName, bool bLocalFirst ); /** Only if bComplete is set, the function reference and argument types are initialized (component may have to be loaded). @@ -180,13 +179,13 @@ public: void LocalizeString( OUString& rName ); ///< modify rName - input: exact name long GetFuncCount(); - sal_Bool FillFunctionDesc( long nFunc, ScFuncDesc& rDesc ); + bool FillFunctionDesc( long nFunc, ScFuncDesc& rDesc ); - static sal_Bool FillFunctionDescFromData( const ScUnoAddInFuncData& rFuncData, ScFuncDesc& rDesc ); + static bool FillFunctionDescFromData( const ScUnoAddInFuncData& rFuncData, ScFuncDesc& rDesc ); /// leave rRetExcelName unchanged, if no matching name is found - sal_Bool GetExcelName( const OUString& rCalcName, LanguageType eDestLang, OUString& rRetExcelName ); + bool GetExcelName( const OUString& rCalcName, LanguageType eDestLang, OUString& rRetExcelName ); /// leave rRetCalcName unchanged, if no matching name is found - sal_Bool GetCalcName( const OUString& rExcelName, OUString& rRetCalcName ); + bool GetCalcName( const OUString& rExcelName, OUString& rRetCalcName ); }; @@ -197,12 +196,12 @@ private: com::sun::star::uno::Sequence<com::sun::star::uno::Any> aArgs; com::sun::star::uno::Sequence<com::sun::star::uno::Any> aVarArg; com::sun::star::uno::Reference<com::sun::star::uno::XInterface> xCaller; - sal_Bool bValidCount; + bool bValidCount; // result: - sal_uInt16 nErrCode; - sal_Bool bHasString; + sal_uInt16 nErrCode; + bool bHasString; double fValue; - OUString aString; + OUString aString; ScMatrixRef xMatrix; com::sun::star::uno::Reference<com::sun::star::sheet::XVolatileResult> xVarRes; @@ -215,12 +214,12 @@ public: long nParamCount ); ~ScUnoAddInCall(); - sal_Bool NeedsCaller() const; + bool NeedsCaller() const; void SetCaller( const com::sun::star::uno::Reference< com::sun::star::uno::XInterface>& rInterface ); void SetCallerFromObjectShell( SfxObjectShell* pSh ); - sal_Bool ValidParamCount(); + bool ValidParamCount(); ScAddInArgumentType GetArgType( long nPos ); void SetParam( long nPos, const com::sun::star::uno::Any& rValue ); @@ -228,12 +227,12 @@ public: void SetResult( const com::sun::star::uno::Any& rNewRes ); - sal_uInt16 GetErrCode() const { return nErrCode; } - sal_Bool HasString() const { return bHasString; } + sal_uInt16 GetErrCode() const { return nErrCode; } + bool HasString() const { return bHasString; } bool HasMatrix() const { return xMatrix.get(); } - sal_Bool HasVarRes() const { return ( xVarRes.is() ); } + bool HasVarRes() const { return ( xVarRes.is() ); } double GetValue() const { return fValue; } - const OUString& GetString() const { return aString; } + const OUString& GetString() const { return aString; } ScMatrixRef GetMatrix() const { return xMatrix; } com::sun::star::uno::Reference<com::sun::star::sheet::XVolatileResult> GetVarRes() const { return xVarRes; } diff --git a/sc/source/core/tool/addincol.cxx b/sc/source/core/tool/addincol.cxx index a4ff289..d5c5401 100644 --- a/sc/source/core/tool/addincol.cxx +++ b/sc/source/core/tool/addincol.cxx @@ -121,7 +121,7 @@ const ::std::vector<ScUnoAddInFuncData::LocalizedName>& ScUnoAddInFuncData::GetC } } - bCompInitialized = sal_True; // also if not successful + bCompInitialized = true; // also if not successful } return maCompNames; } @@ -132,10 +132,10 @@ void ScUnoAddInFuncData::SetCompNames( const ::std::vector< ScUnoAddInFuncData:: maCompNames = rNew; - bCompInitialized = sal_True; + bCompInitialized = true; } -sal_Bool ScUnoAddInFuncData::GetExcelName( LanguageType eDestLang, OUString& rRetExcelName ) const +bool ScUnoAddInFuncData::GetExcelName( LanguageType eDestLang, OUString& rRetExcelName ) const { const ::std::vector<LocalizedName>& rCompNames = GetCompNames(); if ( !rCompNames.empty() ) @@ -194,7 +194,7 @@ sal_Bool ScUnoAddInFuncData::GetExcelName( LanguageType eDestLang, OUString& rRe // Third, last resort, use first (default) entry. rRetExcelName = rCompNames[0].maName; - return sal_True; + return true; } return false; } @@ -319,7 +319,7 @@ void ScUnoAddInCollection::Initialize() // when argument information is needed). ReadConfiguration(); - bInitialized = sal_True; // with or without functions + bInitialized = true; // with or without functions } // ----------------------------------------------------------------------------- @@ -610,7 +610,7 @@ void ScUnoAddInCollection::LoadComponent( const ScUnoAddInFuncData& rFuncData ) } } -sal_Bool ScUnoAddInCollection::GetExcelName( const OUString& rCalcName, +bool ScUnoAddInCollection::GetExcelName( const OUString& rCalcName, LanguageType eDestLang, OUString& rRetExcelName ) { const ScUnoAddInFuncData* pFuncData = GetFuncData( rCalcName ); @@ -619,7 +619,7 @@ sal_Bool ScUnoAddInCollection::GetExcelName( const OUString& rCalcName, return false; } -sal_Bool ScUnoAddInCollection::GetCalcName( const OUString& rExcelName, OUString& rRetCalcName ) +bool ScUnoAddInCollection::GetCalcName( const OUString& rExcelName, OUString& rRetCalcName ) { if (!bInitialized) Initialize(); @@ -643,7 +643,7 @@ sal_Bool ScUnoAddInCollection::GetCalcName( const OUString& rExcelName, OUString // use the first function that has this name for any language rRetCalcName = pFuncData->GetOriginalName(); - return sal_True; + return true; } } } @@ -652,12 +652,12 @@ sal_Bool ScUnoAddInCollection::GetCalcName( const OUString& rExcelName, OUString return false; } -inline sal_Bool IsTypeName( const OUString& rName, const uno::Type& rType ) +inline bool IsTypeName( const OUString& rName, const uno::Type& rType ) { return rName == rType.getTypeName(); } -static sal_Bool lcl_ValidReturnType( const uno::Reference<reflection::XIdlClass>& xClass ) +static bool lcl_ValidReturnType( const uno::Reference<reflection::XIdlClass>& xClass ) { // this must match with ScUnoAddInCall::SetResult @@ -677,7 +677,7 @@ static sal_Bool lcl_ValidReturnType( const uno::Reference<reflection::XIdlClass> case uno::TypeClass_FLOAT: case uno::TypeClass_DOUBLE: case uno::TypeClass_STRING: - return sal_True; // values or string + return true; // values or string case uno::TypeClass_INTERFACE: { @@ -811,7 +811,7 @@ void ScUnoAddInCollection::ReadFromAddIn( const uno::Reference<uno::XInterface>& // leave out internal functions uno::Reference<reflection::XIdlClass> xClass = xFunc->getDeclaringClass(); - sal_Bool bSkip = sal_True; + bool bSkip = true; if ( xClass.is() ) { //! XIdlClass needs getType() method! @@ -831,7 +831,7 @@ void ScUnoAddInCollection::ReadFromAddIn( const uno::Reference<uno::XInterface>& uno::Reference<reflection::XIdlClass> xReturn = xFunc->getReturnType(); if ( !lcl_ValidReturnType( xReturn ) ) - bSkip = sal_True; + bSkip = true; } if (!bSkip) { @@ -844,7 +844,7 @@ void ScUnoAddInCollection::ReadFromAddIn( const uno::Reference<uno::XInterface>& aFuncNameBuffer.append(aFuncU); OUString aFuncName = aFuncNameBuffer.makeStringAndClear(); - sal_Bool bValid = sal_True; + bool bValid = true; long nVisibleCount = 0; long nCallerPos = SC_CALLERPOS_NONE; @@ -930,7 +930,7 @@ void ScUnoAddInCollection::ReadFromAddIn( const uno::Reference<uno::XInterface>& aArgDesc = "###"; } - sal_Bool bOptional = + bool bOptional = ( eArgType == SC_ADDINARG_VALUE_OR_ARRAY || eArgType == SC_ADDINARG_VARARGS ); @@ -1059,7 +1059,7 @@ void ScUnoAddInCollection::UpdateFromAddIn( const uno::Reference<uno::XInterface // Local names and descriptions from pOldData are looked up using the // internal argument name. - sal_Bool bValid = sal_True; + bool bValid = true; long nVisibleCount = 0; long nCallerPos = SC_CALLERPOS_NONE; @@ -1107,7 +1107,7 @@ void ScUnoAddInCollection::UpdateFromAddIn( const uno::Reference<uno::XInterface else aDesc.aName = aDesc.aDescription = "###"; - sal_Bool bOptional = + bool bOptional = ( eArgType == SC_ADDINARG_VALUE_OR_ARRAY || eArgType == SC_ADDINARG_VARARGS ); @@ -1137,7 +1137,7 @@ void ScUnoAddInCollection::UpdateFromAddIn( const uno::Reference<uno::XInterface } } -OUString ScUnoAddInCollection::FindFunction( const OUString& rUpperName, sal_Bool bLocalFirst ) +OUString ScUnoAddInCollection::FindFunction( const OUString& rUpperName, bool bLocalFirst ) { if (!bInitialized) Initialize(); @@ -1224,7 +1224,7 @@ long ScUnoAddInCollection::GetFuncCount() return nFuncCount; } -sal_Bool ScUnoAddInCollection::FillFunctionDesc( long nFunc, ScFuncDesc& rDesc ) +bool ScUnoAddInCollection::FillFunctionDesc( long nFunc, ScFuncDesc& rDesc ) { if (!bInitialized) Initialize(); @@ -1237,11 +1237,11 @@ sal_Bool ScUnoAddInCollection::FillFunctionDesc( long nFunc, ScFuncDesc& rDesc ) return FillFunctionDescFromData( rFuncData, rDesc ); } -sal_Bool ScUnoAddInCollection::FillFunctionDescFromData( const ScUnoAddInFuncData& rFuncData, ScFuncDesc& rDesc ) +bool ScUnoAddInCollection::FillFunctionDescFromData( const ScUnoAddInFuncData& rFuncData, ScFuncDesc& rDesc ) { rDesc.Clear(); - sal_Bool bIncomplete = !rFuncData.GetFunction().is(); //! extra flag? + bool bIncomplete = !rFuncData.GetFunction().is(); //! extra flag? long nArgCount = rFuncData.GetArgumentCount(); if ( nArgCount > USHRT_MAX ) @@ -1266,7 +1266,7 @@ sal_Bool ScUnoAddInCollection::FillFunctionDescFromData( const ScUnoAddInFuncDat rDesc.nArgCount = (sal_uInt16)nArgCount; if ( nArgCount ) { - sal_Bool bMultiple = false; + bool bMultiple = false; const ScAddInArgDesc* pArgs = rFuncData.GetArguments(); rDesc.ppDefArgNames = new OUString*[nArgCount]; @@ -1289,7 +1289,7 @@ sal_Bool ScUnoAddInCollection::FillFunctionDescFromData( const ScUnoAddInFuncDat // last argument repeated? if ( nArg+1 == nArgCount && ( pArgs[nArg].eType == SC_ADDINARG_VARARGS ) ) - bMultiple = sal_True; + bMultiple = true; } if ( bMultiple ) @@ -1298,7 +1298,7 @@ sal_Bool ScUnoAddInCollection::FillFunctionDescFromData( const ScUnoAddInFuncDat rDesc.bIncomplete = bIncomplete; - return sal_True; + return true; } @@ -1308,7 +1308,7 @@ ScUnoAddInCall::ScUnoAddInCall( ScUnoAddInCollection& rColl, const OUString& rNa long nParamCount ) : bValidCount( false ), nErrCode( errNoCode ), // before function was called - bHasString( sal_True ), + bHasString( true ), fValue( 0.0 ), xMatrix( NULL ) { @@ -1325,12 +1325,12 @@ ScUnoAddInCall::ScUnoAddInCall( ScUnoAddInCollection& rColl, const OUString& rNa { long nVarCount = nParamCount - ( nDescCount - 1 ); // size of last argument aVarArg.realloc( nVarCount ); - bValidCount = sal_True; + bValidCount = true; } else if ( nParamCount <= nDescCount ) { // all args behind nParamCount must be optional - bValidCount = sal_True; + bValidCount = true; for (long i=nParamCount; i<nDescCount; i++) if ( !pArgs[i].bOptional ) bValidCount = false; @@ -1347,7 +1347,7 @@ ScUnoAddInCall::~ScUnoAddInCall() // pFuncData is deleted with ScUnoAddInCollection } -sal_Bool ScUnoAddInCall::ValidParamCount() +bool ScUnoAddInCall::ValidParamCount() { return bValidCount; } @@ -1369,7 +1369,7 @@ ScAddInArgumentType ScUnoAddInCall::GetArgType( long nPos ) return SC_ADDINARG_VALUE_OR_ARRAY; //! error code !!!! } -sal_Bool ScUnoAddInCall::NeedsCaller() const +bool ScUnoAddInCall::NeedsCaller() const { return pFuncData && pFuncData->GetCallerPos() != SC_CALLERPOS_NONE; } @@ -1546,7 +1546,7 @@ void ScUnoAddInCall::SetResult( const uno::Any& rNewRes ) case uno::TypeClass_STRING: { rNewRes >>= aString; - bHasString = sal_True; + bHasString = true; } break; commit 104c9cc2482d3843f441f9263fb7cb3c0f3f397f Author: Eike Rathke <er...@redhat.com> Date: Tue Apr 9 23:30:53 2013 +0200 use language tags Change-Id: Ifa5ded07e3af153e747fdbd82a75560dfb7e2b75 diff --git a/sc/inc/addincol.hxx b/sc/inc/addincol.hxx index c6d9b3d..daa2931 100644 --- a/sc/inc/addincol.hxx +++ b/sc/inc/addincol.hxx @@ -76,6 +76,15 @@ struct ScAddInArgDesc class ScUnoAddInFuncData { +public: + struct LocalizedName + { + OUString maLocale; + OUString maName; + + LocalizedName( const OUString& rLocale, const OUString& rName ) + : maLocale( rLocale), maName( rName) { } + }; private: OUString aOriginalName; ///< kept in formula OUString aLocalName; ///< for display @@ -89,7 +98,7 @@ private: long nCallerPos; sal_uInt16 nCategory; OString sHelpId; - mutable com::sun::star::uno::Sequence< com::sun::star::sheet::LocalizedName> aCompNames; + mutable ::std::vector< LocalizedName > maCompNames; mutable sal_Bool bCompInitialized; public: @@ -117,14 +126,14 @@ public: sal_uInt16 GetCategory() const { return nCategory; } const OString GetHelpId() const { return sHelpId; } - const com::sun::star::uno::Sequence< com::sun::star::sheet::LocalizedName>& GetCompNames() const; + const ::std::vector< LocalizedName >& GetCompNames() const; sal_Bool GetExcelName( LanguageType eDestLang, OUString& rRetExcelName ) const; void SetFunction( const com::sun::star::uno::Reference< com::sun::star::reflection::XIdlMethod>& rNewFunc, const com::sun::star::uno::Any& rNewObj ); void SetArguments( long nNewCount, const ScAddInArgDesc* pNewDescs ); void SetCallerPos( long nNewPos ); - void SetCompNames( const com::sun::star::uno::Sequence< com::sun::star::sheet::LocalizedName>& rNew ); + void SetCompNames( const ::std::vector< LocalizedName >& rNew ); }; //------------------------------------------------------------------------ diff --git a/sc/source/core/tool/addincol.cxx b/sc/source/core/tool/addincol.cxx index fd4c27e..a4ff289 100644 --- a/sc/source/core/tool/addincol.cxx +++ b/sc/source/core/tool/addincol.cxx @@ -92,7 +92,7 @@ ScUnoAddInFuncData::~ScUnoAddInFuncData() delete[] pArgDescs; } -const uno::Sequence<sheet::LocalizedName>& ScUnoAddInFuncData::GetCompNames() const +const ::std::vector<ScUnoAddInFuncData::LocalizedName>& ScUnoAddInFuncData::GetCompNames() const { if ( !bCompInitialized ) { @@ -105,21 +105,17 @@ const uno::Sequence<sheet::LocalizedName>& ScUnoAddInFuncData::GetCompNames() co if ( xComp.is() && xFunction.is() ) { OUString aMethodName = xFunction->getName(); - aCompNames = xComp->getCompatibilityNames( aMethodName ); - - // change all locale entries to default case - // (language in lower case, country in upper case) - // for easier searching - - long nSeqLen = aCompNames.getLength(); + uno::Sequence< sheet::LocalizedName> aCompNames( xComp->getCompatibilityNames( aMethodName )); + maCompNames.clear(); + sal_Int32 nSeqLen = aCompNames.getLength(); if ( nSeqLen ) { - sheet::LocalizedName* pArray = aCompNames.getArray(); - for (long i=0; i<nSeqLen; i++) + const sheet::LocalizedName* pArray = aCompNames.getArray(); + for (sal_Int32 i=0; i<nSeqLen; i++) { - lang::Locale& rLocale = pArray[i].Locale; - rLocale.Language = rLocale.Language.toAsciiLowerCase(); - rLocale.Country = rLocale.Country.toAsciiUpperCase(); + maCompNames.push_back( LocalizedName( + LanguageTag( pArray[i].Locale).getBcp47( false), + pArray[i].Name)); } } } @@ -127,76 +123,77 @@ const uno::Sequence<sheet::LocalizedName>& ScUnoAddInFuncData::GetCompNames() co bCompInitialized = sal_True; // also if not successful } - return aCompNames; + return maCompNames; } -void ScUnoAddInFuncData::SetCompNames( const uno::Sequence< sheet::LocalizedName>& rNew ) +void ScUnoAddInFuncData::SetCompNames( const ::std::vector< ScUnoAddInFuncData::LocalizedName >& rNew ) { OSL_ENSURE( !bCompInitialized, "SetCompNames after initializing" ); - aCompNames = rNew; - - // change all locale entries to default case - // (language in lower case, country in upper case) - // for easier searching - - long nSeqLen = aCompNames.getLength(); - if ( nSeqLen ) - { - sheet::LocalizedName* pArray = aCompNames.getArray(); - for (long i=0; i<nSeqLen; i++) - { - lang::Locale& rLocale = pArray[i].Locale; - rLocale.Language = rLocale.Language.toAsciiLowerCase(); - rLocale.Country = rLocale.Country.toAsciiUpperCase(); - } - } + maCompNames = rNew; bCompInitialized = sal_True; } sal_Bool ScUnoAddInFuncData::GetExcelName( LanguageType eDestLang, OUString& rRetExcelName ) const { - const uno::Sequence<sheet::LocalizedName>& rSequence = GetCompNames(); - long nSeqLen = rSequence.getLength(); - if ( nSeqLen ) + const ::std::vector<LocalizedName>& rCompNames = GetCompNames(); + if ( !rCompNames.empty() ) { - const sheet::LocalizedName* pArray = rSequence.getConstArray(); - long i; - - /* FIXME-BCP47: we may want to handle language tags here as well. */ - OUString aLangStr, aCountryStr; - LanguageTag( eDestLang ).getIsoLanguageCountry( aLangStr, aCountryStr ); - OUString aUserLang = aLangStr.toAsciiLowerCase(); - OUString aUserCountry = aCountryStr.toAsciiUpperCase(); + LanguageTag aLanguageTag( eDestLang); + const OUString aSearch( aLanguageTag.getBcp47()); - // first check for match of both language and country - - for ( i=0; i<nSeqLen; i++) - if ( pArray[i].Locale.Language == aUserLang && - pArray[i].Locale.Country == aUserCountry ) + // First, check exact match without fallback overhead. + ::std::vector<LocalizedName>::const_iterator itNames( rCompNames.begin()); + for ( ; itNames != rCompNames.end(); ++itNames) + { + if ((*itNames).maLocale == aSearch) { - rRetExcelName = pArray[i].Name; - return sal_True; + rRetExcelName = (*itNames).maName; + return true; } + } - // second: check only language - - for ( i=0; i<nSeqLen; i++) - if ( pArray[i].Locale.Language == aUserLang ) + // Second, try match of fallback search with fallback locales, + // appending also 'en-US' and 'en' to search if not queried. + ::std::vector< OUString > aFallbackSearch( aLanguageTag.getFallbackStrings()); + if (aSearch != "en-US") + { + aFallbackSearch.push_back( "en-US"); + if (aSearch != "en") { - rRetExcelName = pArray[i].Name; - return sal_True; + aFallbackSearch.push_back( "en"); } + } + bool bFirst = true; + ::std::vector< OUString >::const_iterator itSearch( aFallbackSearch.begin()); + for ( ; itSearch != aFallbackSearch.end(); ++itSearch) + { + itNames = rCompNames.begin(); + for ( ; itNames != rCompNames.end(); ++itNames) + { + ::std::vector< OUString > aFallbackLocales( LanguageTag( (*itNames).maLocale).getFallbackStrings()); + ::std::vector< OUString >::const_iterator itLocales( aFallbackLocales.begin()); + if (bFirst) + { + // We checked already the full tag, start with second. + if (itLocales != aFallbackLocales.end()) + ++itLocales; + } + for ( ; itLocales != aFallbackLocales.end(); ++itLocales) + { + if (*itLocales == *itSearch) + { + rRetExcelName = (*itNames).maName; + return true; + } + } + } + bFirst = false; + } - // third: #i57772# fall-back to en-US - - if ( eDestLang != LANGUAGE_ENGLISH_US ) - return GetExcelName( LANGUAGE_ENGLISH_US, rRetExcelName ); - - // forth: use first (default) entry - - rRetExcelName = pArray[0].Name; + // Third, last resort, use first (default) entry. + rRetExcelName = rCompNames[0].maName; return sal_True; } return false; @@ -471,7 +468,7 @@ void ScUnoAddInCollection::ReadConfiguration() // get compatibility names - uno::Sequence<sheet::LocalizedName> aCompNames; + ::std::vector<ScUnoAddInFuncData::LocalizedName> aCompNames; OUString aCompPath = aFuncPropPath; aCompPath += OUString(CFGSTR_COMPATIBILITYNAME); @@ -484,30 +481,17 @@ void ScUnoAddInCollection::ReadConfiguration() if ( aCompProperties[0] >>= aLocalEntries ) { sal_Int32 nLocaleCount = aLocalEntries.getLength(); - aCompNames.realloc( nLocaleCount ); const beans::PropertyValue* pConfigArray = aLocalEntries.getConstArray(); - sheet::LocalizedName* pCompArray = aCompNames.getArray(); for ( sal_Int32 nLocale = 0; nLocale < nLocaleCount; nLocale++ ) { - const sal_Unicode cLocaleSep = '-'; // separator in configuration locale strings - - // PropertyValue name is the locale (convert from string to Locale struct) - - const OUString& rLocaleStr = pConfigArray[nLocale].Name; - lang::Locale& rLocale = pCompArray[nLocale].Locale; - sal_Int32 nSepPos = rLocaleStr.indexOf( cLocaleSep ); - if ( nSepPos >= 0 ) - { - rLocale.Language = rLocaleStr.copy( 0, nSepPos ); - rLocale.Country = rLocaleStr.copy( nSepPos+1 ); - } - else - rLocale.Language = rLocaleStr; // leave country empty (default ctor from sequence) - + // PropertyValue name is the locale ("convert" from + // string to string to canonicalize) + OUString aLocale( LanguageTag( pConfigArray[nLocale].Name, true).getBcp47( false)); // PropertyValue value is the localized value (string in this case) - - pConfigArray[nLocale].Value >>= pCompArray[nLocale].Name; + OUString aName; + pConfigArray[nLocale].Value >>= aName; + aCompNames.push_back( ScUnoAddInFuncData::LocalizedName( aLocale, aName)); } } } @@ -647,13 +631,13 @@ sal_Bool ScUnoAddInCollection::GetCalcName( const OUString& rExcelName, OUString ScUnoAddInFuncData* pFuncData = ppFuncData[i]; if ( pFuncData ) { - const uno::Sequence<sheet::LocalizedName>& rSequence = pFuncData->GetCompNames(); - long nSeqLen = rSequence.getLength(); - if ( nSeqLen ) + const ::std::vector<ScUnoAddInFuncData::LocalizedName>& rNames = pFuncData->GetCompNames(); + if ( !rNames.empty() ) { - const sheet::LocalizedName* pArray = rSequence.getConstArray(); - for ( long nName=0; nName<nSeqLen; nName++) - if ( ScGlobal::pCharClass->uppercase( pArray[nName].Name ) == aUpperCmp ) + ::std::vector<ScUnoAddInFuncData::LocalizedName>::const_iterator it( rNames.begin()); + for ( ; it != rNames.end(); ++it) + { + if ( ScGlobal::pCharClass->uppercase( (*it).maName ) == aUpperCmp ) { //! store upper case for comparing? @@ -661,6 +645,7 @@ sal_Bool ScUnoAddInCollection::GetCalcName( const OUString& rExcelName, OUString rRetCalcName = pFuncData->GetOriginalName(); return sal_True; } + } } } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits