diff options
-rw-r--r-- | i18npool/source/localedata/LocaleNode.cxx | 38 | ||||
-rw-r--r-- | i18npool/source/localedata/localedata.cxx | 32 |
2 files changed, 33 insertions, 37 deletions
diff --git a/i18npool/source/localedata/LocaleNode.cxx b/i18npool/source/localedata/LocaleNode.cxx index e0cac2020d4c..b70cae2c713f 100644 --- a/i18npool/source/localedata/LocaleNode.cxx +++ b/i18npool/source/localedata/LocaleNode.cxx @@ -1316,8 +1316,8 @@ void LCCollationNode::generateCode (const OFileWriter &of) const OUString useLocale = getAttr().getValueByName("ref"); if (!useLocale.isEmpty()) { useLocale = useLocale.replace( '-', '_'); - of.writeRefFunction("getCollatorImplementation_", useLocale); - of.writeRefFunction("getCollationOptions_", useLocale); + of.writeOUStringRefFunction("getCollatorImplementation_", useLocale); + of.writeOUStringRefFunction("getCollationOptions_", useLocale); return; } sal_Int16 nbOfCollations = 0; @@ -1329,11 +1329,11 @@ void LCCollationNode::generateCode (const OFileWriter &of) const { OUString str; str = currNode->getAttr().getValueByName("unoid"); - of.writeParameter("CollatorID", str, j); + of.writeOUStringLiteralParameter("CollatorID", str, j); str = currNode->getValue(); - of.writeParameter("CollatorRule", str, j); + of.writeOUStringLiteralParameter("CollatorRule", str, j); str = currNode -> getAttr().getValueByName("default"); - of.writeDefaultParameter("Collator", str, j); + of.writeOUStringLiteralDefaultParameter("Collator", str, j); of.writeAsciiString("\n"); nbOfCollations++; @@ -1344,7 +1344,7 @@ void LCCollationNode::generateCode (const OFileWriter &of) const nbOfCollationOptions = sal::static_int_cast<sal_Int16>( pCollationOptions->getNumberOfChildren() ); for( sal_Int16 i=0; i<nbOfCollationOptions; i++ ) { - of.writeParameter("collationOption", pCollationOptions->getChildAt( i )->getValue(), i ); + of.writeOUStringLiteralParameter("collationOption", pCollationOptions->getChildAt( i )->getValue(), i ); } of.writeAsciiString("static const sal_Int16 nbOfCollationOptions = "); @@ -1356,7 +1356,7 @@ void LCCollationNode::generateCode (const OFileWriter &of) const of.writeInt(nbOfCollations); of.writeAsciiString(";\n\n"); - of.writeAsciiString("\nstatic const sal_Unicode* LCCollatorArray[] = {\n"); + of.writeAsciiString("\nstatic constexpr rtl::OUStringConstExpr LCCollatorArray[] = {\n"); for(sal_Int16 j = 0; j < nbOfCollations; j++) { of.writeAsciiString("\tCollatorID"); of.writeInt(j); @@ -1372,16 +1372,17 @@ void LCCollationNode::generateCode (const OFileWriter &of) const } of.writeAsciiString("};\n\n"); - of.writeAsciiString("static const sal_Unicode* collationOptions[] = {"); + of.writeAsciiString("static constexpr rtl::OUStringConstExpr collationOptions[] = {"); for( sal_Int16 j=0; j<nbOfCollationOptions; j++ ) { + if (j) + of.writeAsciiString( ", " ); of.writeAsciiString( "collationOption" ); of.writeInt( j ); - of.writeAsciiString( ", " ); } - of.writeAsciiString("NULL };\n"); - of.writeFunction("getCollatorImplementation_", "nbOfCollations", "LCCollatorArray"); - of.writeFunction("getCollationOptions_", "nbOfCollationOptions", "collationOptions"); + of.writeAsciiString("};\n"); + of.writeOUStringFunction("getCollatorImplementation_", "nbOfCollations", "LCCollatorArray"); + of.writeOUStringFunction("getCollationOptions_", "nbOfCollationOptions", "collationOptions"); } void LCSearchNode::generateCode (const OFileWriter &of) const @@ -1389,7 +1390,7 @@ void LCSearchNode::generateCode (const OFileWriter &of) const OUString useLocale = getAttr().getValueByName("ref"); if (!useLocale.isEmpty()) { useLocale = useLocale.replace( '-', '_'); - of.writeRefFunction("getSearchOptions_", useLocale); + of.writeOUStringRefFunction("getSearchOptions_", useLocale); return; } @@ -1405,22 +1406,23 @@ void LCSearchNode::generateCode (const OFileWriter &of) const sal_Int32 nSearchOptions = pSearchOptions->getNumberOfChildren(); for( i=0; i<nSearchOptions; i++ ) { - of.writeParameter("searchOption", pSearchOptions->getChildAt( i )->getValue(), sal::static_int_cast<sal_Int16>(i) ); + of.writeOUStringLiteralParameter("searchOption", pSearchOptions->getChildAt( i )->getValue(), sal::static_int_cast<sal_Int16>(i) ); } of.writeAsciiString("static const sal_Int16 nbOfSearchOptions = "); of.writeInt( sal::static_int_cast<sal_Int16>( nSearchOptions ) ); of.writeAsciiString(";\n\n"); - of.writeAsciiString("static const sal_Unicode* searchOptions[] = {"); + of.writeAsciiString("static constexpr rtl::OUStringConstExpr searchOptions[] = {"); for( i=0; i<nSearchOptions; i++ ) { + if (i) + of.writeAsciiString( ", " ); of.writeAsciiString( "searchOption" ); of.writeInt( sal::static_int_cast<sal_Int16>(i) ); - of.writeAsciiString( ", " ); } - of.writeAsciiString("NULL };\n"); - of.writeFunction("getSearchOptions_", "nbOfSearchOptions", "searchOptions"); + of.writeAsciiString(" };\n"); + of.writeOUStringFunction("getSearchOptions_", "nbOfSearchOptions", "searchOptions"); } void LCIndexNode::generateCode (const OFileWriter &of) const diff --git a/i18npool/source/localedata/localedata.cxx b/i18npool/source/localedata/localedata.cxx index 12149ca14ff7..3f45df6cdd1a 100644 --- a/i18npool/source/localedata/localedata.cxx +++ b/i18npool/source/localedata/localedata.cxx @@ -904,13 +904,13 @@ LocaleDataImpl::getDateAcceptancePatterns( const Locale& rLocale ) OUString LocaleDataImpl::getCollatorRuleByAlgorithm( const Locale& rLocale, std::u16string_view algorithm ) { - MyFunc_Type func = reinterpret_cast<MyFunc_Type>(getFunctionSymbol( rLocale, "getCollatorImplementation" )); + MyFuncOUString_Type func = reinterpret_cast<MyFuncOUString_Type>(getFunctionSymbol( rLocale, "getCollatorImplementation" )); if ( func ) { sal_Int16 collatorCount = 0; - sal_Unicode **collatorArray = func(collatorCount); + OUString const *collatorArray = func(collatorCount); for(sal_Int16 i = 0; i < collatorCount; i++) if (algorithm == collatorArray[i * COLLATOR_ELEMENTS + COLLATOR_OFFSET_ALGO]) - return OUString(collatorArray[i * COLLATOR_ELEMENTS + COLLATOR_OFFSET_RULE]); + return collatorArray[i * COLLATOR_ELEMENTS + COLLATOR_OFFSET_RULE]; } return OUString(); } @@ -919,18 +919,17 @@ LocaleDataImpl::getCollatorRuleByAlgorithm( const Locale& rLocale, std::u16strin Sequence< Implementation > SAL_CALL LocaleDataImpl::getCollatorImplementations( const Locale& rLocale ) { - MyFunc_Type func = reinterpret_cast<MyFunc_Type>(getFunctionSymbol( rLocale, "getCollatorImplementation" )); + MyFuncOUString_Type func = reinterpret_cast<MyFuncOUString_Type>(getFunctionSymbol( rLocale, "getCollatorImplementation" )); if ( func ) { sal_Int16 collatorCount = 0; - sal_Unicode **collatorArray = func(collatorCount); + OUString const *collatorArray = func(collatorCount); Sequence< Implementation > seq(collatorCount); auto seqRange = asNonConstRange(seq); for(sal_Int16 i = 0; i < collatorCount; i++) { - Implementation impl( - OUString(collatorArray[i * COLLATOR_ELEMENTS + COLLATOR_OFFSET_ALGO]), + seqRange[i] = Implementation( + collatorArray[i * COLLATOR_ELEMENTS + COLLATOR_OFFSET_ALGO], collatorArray[i * COLLATOR_ELEMENTS + COLLATOR_OFFSET_DEFAULT][0] != 0); - seqRange[i] = impl; } return seq; } @@ -942,15 +941,15 @@ LocaleDataImpl::getCollatorImplementations( const Locale& rLocale ) Sequence< OUString > SAL_CALL LocaleDataImpl::getCollationOptions( const Locale& rLocale ) { - MyFunc_Type func = reinterpret_cast<MyFunc_Type>(getFunctionSymbol( rLocale, "getCollationOptions" )); + MyFuncOUString_Type func = reinterpret_cast<MyFuncOUString_Type>(getFunctionSymbol( rLocale, "getCollationOptions" )); if ( func ) { sal_Int16 optionsCount = 0; - sal_Unicode **optionsArray = func(optionsCount); + OUString const *optionsArray = func(optionsCount); Sequence< OUString > seq(optionsCount); auto seqRange = asNonConstRange(seq); for(sal_Int16 i = 0; i < optionsCount; i++) { - seqRange[i] = OUString( optionsArray[i] ); + seqRange[i] = optionsArray[i]; } return seq; } @@ -962,17 +961,12 @@ LocaleDataImpl::getCollationOptions( const Locale& rLocale ) Sequence< OUString > SAL_CALL LocaleDataImpl::getSearchOptions( const Locale& rLocale ) { - MyFunc_Type func = reinterpret_cast<MyFunc_Type>(getFunctionSymbol( rLocale, "getSearchOptions" )); + MyFuncOUString_Type func = reinterpret_cast<MyFuncOUString_Type>(getFunctionSymbol( rLocale, "getSearchOptions" )); if ( func ) { sal_Int16 optionsCount = 0; - sal_Unicode **optionsArray = func(optionsCount); - Sequence< OUString > seq(optionsCount); - auto seqRange = asNonConstRange(seq); - for(sal_Int16 i = 0; i < optionsCount; i++) { - seqRange[i] = OUString( optionsArray[i] ); - } - return seq; + OUString const *optionsArray = func(optionsCount); + return Sequence< OUString >(optionsArray, optionsCount); } else { return {}; |