diff --git a/Repository.mk b/Repository.mk index 88d01380140c..bee0b6ce5bca 100644 --- a/Repository.mk +++ b/Repository.mk @@ -705,7 +705,6 @@ $(eval $(call gb_Helper_register_plugins_for_install,PLAINLIBS_OOO,ooo, \ localedata_es \ localedata_euro \ localedata_others \ - textconv_dict \ )) ifeq ($(OS),WNT) diff --git a/i18npool/CustomTarget_textconversion.mk b/i18npool/CustomTarget_textconversion.mk index d91906c4dc45..d6669b06ce25 100644 --- a/i18npool/CustomTarget_textconversion.mk +++ b/i18npool/CustomTarget_textconversion.mk @@ -20,9 +20,7 @@ $(call gb_CustomTarget_get_workdir,i18npool/textconversion)/%.cxx : \ $(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),$(true),CDC,1) $(call gb_Trace_StartRange,$(subst $(WORKDIR)/,,$@),CDC) $(call gb_Helper_abbreviate_dirs, \ - $(call gb_Helper_execute,genconv_dict) $* $< $@.tmp && \ - sed 's/\(^.*get\)/SAL_DLLPUBLIC_EXPORT \1/' $@.tmp > $@ && \ - rm $@.tmp) + $(call gb_Helper_execute,genconv_dict) $* $< $@ ) $(call gb_Trace_EndRange,$(subst $(WORKDIR)/,,$@),CDC) # vim: set noet sw=4 ts=4: diff --git a/i18npool/Library_i18npool.mk b/i18npool/Library_i18npool.mk index 4c35c26047f9..8971eb388921 100644 --- a/i18npool/Library_i18npool.mk +++ b/i18npool/Library_i18npool.mk @@ -165,5 +165,10 @@ $(eval $(call gb_Library_add_generated_exception_objects,i18npool,\ CustomTarget/i18npool/indexentry/$(notdir $(basename $(txt)))) \ )) +# textconv_dict +$(eval $(call gb_Library_add_generated_exception_objects,i18npool,\ + $(foreach txt,$(wildcard $(SRCDIR)/i18npool/source/textconversion/data/*.dic),\ + CustomTarget/i18npool/textconversion/$(notdir $(basename $(txt)))) \ +)) # vim: set noet sw=4 ts=4: diff --git a/i18npool/Library_textconv_dict.mk b/i18npool/Library_textconv_dict.mk deleted file mode 100644 index f9cc2ef2ee6c..000000000000 --- a/i18npool/Library_textconv_dict.mk +++ /dev/null @@ -1,32 +0,0 @@ -# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- -# -# This file is part of the LibreOffice project. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# - -$(eval $(call gb_Library_Library,textconv_dict)) - -$(eval $(call gb_Library_set_plugin_for_nodep,textconv_dict,i18npool)) - -$(eval $(call gb_Library_set_include,textconv_dict,\ - $$(INCLUDE) \ - -I$(SRCDIR)/i18npool/inc \ -)) - -$(eval $(call gb_Library_use_sdk_api,textconv_dict)) - -$(eval $(call gb_Library_use_libraries,textconv_dict,\ - sal \ - cppu \ - cppuhelper \ -)) - -$(eval $(call gb_Library_add_generated_exception_objects,textconv_dict,\ - $(foreach txt,$(wildcard $(SRCDIR)/i18npool/source/textconversion/data/*.dic),\ - CustomTarget/i18npool/textconversion/$(notdir $(basename $(txt)))) \ -)) - -# vim: set noet sw=4 ts=4: diff --git a/i18npool/Module_i18npool.mk b/i18npool/Module_i18npool.mk index 69341fc744c0..6c06164761c9 100644 --- a/i18npool/Module_i18npool.mk +++ b/i18npool/Module_i18npool.mk @@ -24,7 +24,6 @@ $(eval $(call gb_Module_add_targets,i18npool,\ Library_localedata_es \ Library_localedata_euro \ Library_localedata_others \ - Library_textconv_dict \ )) $(eval $(call gb_Module_add_targets_for_build,i18npool,\ diff --git a/i18npool/inc/textconversion.hxx b/i18npool/inc/textconversion.hxx index ebb973de0b3a..d15ca121f32d 100644 --- a/i18npool/inc/textconversion.hxx +++ b/i18npool/inc/textconversion.hxx @@ -21,7 +21,6 @@ #include #include #include -#include namespace com::sun::star::linguistic2 { class XConversionDictionary; } namespace com::sun::star::linguistic2 { class XConversionDictionaryList; } @@ -66,11 +65,6 @@ public: getSupportedServiceNames() override; private: const char* implementationName; -protected: -#ifndef DISABLE_DYNLOADING - oslModule hModule; - oslGenericFunction getFunctionBySymbol(const char* func); -#endif }; // for Hangul2Hanja conversion @@ -112,8 +106,8 @@ private: css::uno::Reference < css::linguistic2::XConversionDictionaryList > xCDL; sal_Int32 maxLeftLength; sal_Int32 maxRightLength; - css::uno::Sequence< OUString > - getCharConversions(const OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength, bool toHanja); + static css::uno::Sequence< OUString > + getCharConversions(std::u16string_view aText, sal_Int32 nStartPos, sal_Int32 nLength, bool toHanja); }; @@ -144,12 +138,36 @@ public: private: // user defined dictionary list css::uno::Reference < css::linguistic2::XConversionDictionaryList > xCDL; - OUString getWordConversion(const OUString& aText, + OUString getWordConversion(std::u16string_view aText, sal_Int32 nStartPos, sal_Int32 nLength, bool toSChinese, sal_Int32 nConversionOptions, css::uno::Sequence & offset); - rtl:: OUString getCharConversion(const rtl:: OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength, bool toSChinese, sal_Int32 nConversionOptions); + static OUString getCharConversion(std::u16string_view aText, sal_Int32 nStartPos, sal_Int32 nLength, bool toSChinese, sal_Int32 nConversionOptions); css::lang::Locale aLocale; }; } // i18npool +extern "C" { + +const sal_Unicode* getHangul2HanjaData(); +const i18npool::Hangul_Index* getHangul2HanjaIndex(); +sal_Int16 getHangul2HanjaIndexCount(); +const sal_uInt16* getHanja2HangulIndex(); +const sal_Unicode* getHanja2HangulData(); + +const sal_Unicode* getSTC_CharData_T2S(); +const sal_uInt16* getSTC_CharIndex_T2S(); +const sal_Unicode* getSTC_CharData_S2V(); +const sal_uInt16* getSTC_CharIndex_S2V(); +const sal_Unicode* getSTC_CharData_S2T(); +const sal_uInt16* getSTC_CharIndex_S2T(); + +const sal_Unicode *getSTC_WordData(sal_Int32&); + +const sal_uInt16 *getSTC_WordIndex_T2S(sal_Int32&); +const sal_uInt16 *getSTC_WordEntry_T2S(); +const sal_uInt16 *getSTC_WordIndex_S2T(sal_Int32&); +const sal_uInt16 *getSTC_WordEntry_S2T(); + +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/i18npool/source/textconversion/textconversion.cxx b/i18npool/source/textconversion/textconversion.cxx index 0dba10e1f155..59a6143d18f7 100644 --- a/i18npool/source/textconversion/textconversion.cxx +++ b/i18npool/source/textconversion/textconversion.cxx @@ -24,47 +24,15 @@ using namespace com::sun::star::uno; namespace i18npool { -#ifndef DISABLE_DYNLOADING - -extern "C" { static void thisModule() {} } - -#endif - TextConversionService::TextConversionService(const char *pImplName) : implementationName(pImplName) { -#ifndef DISABLE_DYNLOADING - constexpr OUString lib( u"" SAL_MODULENAME( "textconv_dict" ) ""_ustr ); - hModule = osl_loadModuleRelative( - &thisModule, lib.pData, SAL_LOADMODULE_DEFAULT ); -#endif } TextConversionService::~TextConversionService() { -#ifndef DISABLE_DYNLOADING - if (hModule) osl_unloadModule(hModule); -#endif } -#ifndef DISABLE_DYNLOADING - -static void* nullFunc() -{ - return nullptr; -} - -oslGenericFunction -TextConversionService::getFunctionBySymbol(const char* func) -{ - if (hModule) - return osl_getFunctionSymbol(hModule, OUString::createFromAscii(func).pData); - else - return reinterpret_cast< oslGenericFunction >(nullFunc); -} - -#endif - OUString SAL_CALL TextConversionService::getImplementationName() { diff --git a/i18npool/source/textconversion/textconversion_ko.cxx b/i18npool/source/textconversion/textconversion_ko.cxx index fac1e7bc194b..c68c66a38cd4 100644 --- a/i18npool/source/textconversion/textconversion_ko.cxx +++ b/i18npool/source/textconversion/textconversion_ko.cxx @@ -105,33 +105,14 @@ static sal_Int16 checkScriptType(sal_Unicode c) } #ifdef DISABLE_DYNLOADING -extern "C" { - -const sal_Unicode* getHangul2HanjaData(); -const Hangul_Index* getHangul2HanjaIndex(); -sal_Int16 getHangul2HanjaIndexCount(); -const sal_uInt16* getHanja2HangulIndex(); -const sal_Unicode* getHanja2HangulData(); - -} #endif Sequence< OUString > -TextConversion_ko::getCharConversions(const OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength, bool toHanja) +TextConversion_ko::getCharConversions(std::u16string_view aText, sal_Int32 nStartPos, sal_Int32 nLength, bool toHanja) { sal_Unicode ch; Sequence< OUString > output; -#ifndef DISABLE_DYNLOADING - const sal_Unicode* (*getHangul2HanjaData)() = reinterpret_cast(getFunctionBySymbol("getHangul2HanjaData")); - const Hangul_Index* (*getHangul2HanjaIndex)() = reinterpret_cast(getFunctionBySymbol("getHangul2HanjaIndex")); - sal_Int16 (*getHangul2HanjaIndexCount)() = reinterpret_cast(getFunctionBySymbol("getHangul2HanjaIndexCount")); - const sal_uInt16* (*getHanja2HangulIndex)() = reinterpret_cast(getFunctionBySymbol("getHanja2HangulIndex")); - const sal_Unicode* (*getHanja2HangulData)() = reinterpret_cast(getFunctionBySymbol("getHanja2HangulData")); - - if (toHanja && getHangul2HanjaIndex && getHangul2HanjaIndexCount && getHangul2HanjaData) -#else if (toHanja) -#endif { ch = aText[nStartPos]; const Hangul_Index *Hangul_ko = getHangul2HanjaIndex(); @@ -157,11 +138,7 @@ TextConversion_ko::getCharConversions(const OUString& aText, sal_Int32 nStartPos } } } -#ifndef DISABLE_DYNLOADING - else if (!toHanja && getHanja2HangulIndex && getHanja2HangulData) -#else else if (!toHanja) -#endif { std::unique_ptr newStr(new sal_Unicode[nLength+1]); sal_Int32 count = 0; diff --git a/i18npool/source/textconversion/textconversion_zh.cxx b/i18npool/source/textconversion/textconversion_zh.cxx index b5da23e7e00d..a2c4429eb4cc 100644 --- a/i18npool/source/textconversion/textconversion_zh.cxx +++ b/i18npool/source/textconversion/textconversion_zh.cxx @@ -57,42 +57,17 @@ static sal_Unicode getOneCharConversion(sal_Unicode ch, const sal_Unicode* Data, extern "C" { -const sal_Unicode* getSTC_CharData_T2S(); -const sal_uInt16* getSTC_CharIndex_T2S(); -const sal_Unicode* getSTC_CharData_S2V(); -const sal_uInt16* getSTC_CharIndex_S2V(); -const sal_Unicode* getSTC_CharData_S2T(); -const sal_uInt16* getSTC_CharIndex_S2T(); - -const sal_Unicode *getSTC_WordData(sal_Int32&); - -const sal_uInt16 *getSTC_WordIndex_T2S(sal_Int32&); -const sal_uInt16 *getSTC_WordEntry_T2S(); -const sal_uInt16 *getSTC_WordIndex_S2T(sal_Int32&); -const sal_uInt16 *getSTC_WordEntry_S2T(); } #endif OUString -TextConversion_zh::getCharConversion(const OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength, bool toSChinese, sal_Int32 nConversionOptions) +TextConversion_zh::getCharConversion(std::u16string_view aText, sal_Int32 nStartPos, sal_Int32 nLength, bool toSChinese, sal_Int32 nConversionOptions) { const sal_Unicode *Data; const sal_uInt16 *Index; -#ifndef DISABLE_DYNLOADING - if (toSChinese) { - Data = reinterpret_cast(getFunctionBySymbol("getSTC_CharData_T2S"))(); - Index = reinterpret_cast(getFunctionBySymbol("getSTC_CharIndex_T2S"))(); - } else if (nConversionOptions & TextConversionOption::USE_CHARACTER_VARIANTS) { - Data = reinterpret_cast(getFunctionBySymbol("getSTC_CharData_S2V"))(); - Index = reinterpret_cast(getFunctionBySymbol("getSTC_CharIndex_S2V"))(); - } else { - Data = reinterpret_cast(getFunctionBySymbol("getSTC_CharData_S2T"))(); - Index = reinterpret_cast(getFunctionBySymbol("getSTC_CharIndex_S2T"))(); - } -#else if (toSChinese) { Data = getSTC_CharData_T2S(); Index = getSTC_CharIndex_T2S(); @@ -103,7 +78,6 @@ TextConversion_zh::getCharConversion(const OUString& aText, sal_Int32 nStartPos, Data = getSTC_CharData_S2T(); Index = getSTC_CharIndex_S2T(); } -#endif rtl_uString * newStr = rtl_uString_alloc(nLength); for (sal_Int32 i = 0; i < nLength; i++) @@ -113,7 +87,7 @@ TextConversion_zh::getCharConversion(const OUString& aText, sal_Int32 nStartPos, } OUString -TextConversion_zh::getWordConversion(const OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength, bool toSChinese, sal_Int32 nConversionOptions, Sequence& offset) +TextConversion_zh::getWordConversion(std::u16string_view aText, sal_Int32 nStartPos, sal_Int32 nLength, bool toSChinese, sal_Int32 nConversionOptions, Sequence& offset) { sal_Int32 dictLen = 0; sal_Int32 maxLen = 0; @@ -123,25 +97,6 @@ TextConversion_zh::getWordConversion(const OUString& aText, sal_Int32 nStartPos, const sal_uInt16 *charIndex; bool one2one=true; -#ifndef DISABLE_DYNLOADING - const sal_Unicode *wordData = reinterpret_cast(getFunctionBySymbol("getSTC_WordData"))(dictLen); - if (toSChinese) { - index = reinterpret_cast(getFunctionBySymbol("getSTC_WordIndex_T2S"))(maxLen); - entry = reinterpret_cast(getFunctionBySymbol("getSTC_WordEntry_T2S"))(); - charData = reinterpret_cast(getFunctionBySymbol("getSTC_CharData_T2S"))(); - charIndex = reinterpret_cast(getFunctionBySymbol("getSTC_CharIndex_T2S"))(); - } else { - index = reinterpret_cast(getFunctionBySymbol("getSTC_WordIndex_S2T"))(maxLen); - entry = reinterpret_cast(getFunctionBySymbol("getSTC_WordEntry_S2T"))(); - if (nConversionOptions & TextConversionOption::USE_CHARACTER_VARIANTS) { - charData = reinterpret_cast(getFunctionBySymbol("getSTC_CharData_S2V"))(); - charIndex = reinterpret_cast(getFunctionBySymbol("getSTC_CharIndex_S2V"))(); - } else { - charData = reinterpret_cast(getFunctionBySymbol("getSTC_CharData_S2T"))(); - charIndex = reinterpret_cast(getFunctionBySymbol("getSTC_CharIndex_S2T"))(); - } - } -#else const sal_Unicode *wordData = getSTC_WordData(dictLen); if (toSChinese) { index = getSTC_WordIndex_T2S(maxLen); @@ -159,7 +114,6 @@ TextConversion_zh::getWordConversion(const OUString& aText, sal_Int32 nStartPos, charIndex = getSTC_CharIndex_S2T(); } } -#endif if ((!wordData || !index || !entry) && !xCDL.is()) // no word mapping defined, do char2char conversion. return getCharConversion(aText, nStartPos, nLength, toSChinese, nConversionOptions); @@ -173,7 +127,7 @@ TextConversion_zh::getWordConversion(const OUString& aText, sal_Int32 nStartPos, if (len > maxLen) len = maxLen; for (; len > 0 && ! found; len--) { - OUString word = aText.copy(nStartPos + currPos, len); + OUString word( aText.substr(nStartPos + currPos, len) ); sal_Int32 current = 0; // user dictionary if (xCDL.is()) { diff --git a/sw/CppunitTest_sw_core_unocore.mk b/sw/CppunitTest_sw_core_unocore.mk index 1269158d3f67..43fb58bf4fe1 100644 --- a/sw/CppunitTest_sw_core_unocore.mk +++ b/sw/CppunitTest_sw_core_unocore.mk @@ -72,7 +72,7 @@ $(eval $(call gb_CppunitTest_use_uiconfigs,sw_core_unocore, \ )) $(call gb_CppunitTest_get_target,sw_core_unocore): \ - $(call gb_Library_get_target,textconv_dict) + $(call gb_Library_get_target,i18npool) $(eval $(call gb_CppunitTest_use_more_fonts,sw_core_unocore)) diff --git a/sw/CppunitTest_sw_unowriter.mk b/sw/CppunitTest_sw_unowriter.mk index 2babe32e19b1..9ed2a7522ec6 100644 --- a/sw/CppunitTest_sw_unowriter.mk +++ b/sw/CppunitTest_sw_unowriter.mk @@ -72,7 +72,7 @@ $(eval $(call gb_CppunitTest_use_uiconfigs,sw_unowriter, \ )) $(call gb_CppunitTest_get_target,sw_unowriter): \ - $(call gb_Library_get_target,textconv_dict) + $(call gb_Library_get_target,i18npool) $(eval $(call gb_CppunitTest_use_more_fonts,sw_unowriter)) diff --git a/sw/layoutwriter_setup.mk b/sw/layoutwriter_setup.mk index bfc9548fceef..be4902a83274 100644 --- a/sw/layoutwriter_setup.mk +++ b/sw/layoutwriter_setup.mk @@ -82,7 +82,7 @@ $(eval $(call gb_CppunitTest_use_uiconfigs,sw_layoutwriter$(1), \ )) $(call gb_CppunitTest_get_target,sw_layoutwriter$(1)): \ - $(call gb_Library_get_target,textconv_dict) + $(call gb_Library_get_target,i18npool) # assert if font/glyph fallback occurs $(eval $(call gb_CppunitTest_set_non_application_font_use,sw_layoutwriter$(1),abort)) diff --git a/sw/uiwriter_setup.mk b/sw/uiwriter_setup.mk index 013cb3e29953..d4956ecbc468 100644 --- a/sw/uiwriter_setup.mk +++ b/sw/uiwriter_setup.mk @@ -92,7 +92,7 @@ $(eval $(call gb_CppunitTest_use_packages,sw_uiwriter$(1),\ sfx2_classification \ )) -$(call gb_CppunitTest_get_target,sw_uiwriter$(1)) : $(call gb_Library_get_target,textconv_dict) +$(call gb_CppunitTest_get_target,sw_uiwriter$(1)) : $(call gb_Library_get_target,i18npool) $(eval $(call gb_CppunitTest_use_more_fonts,sw_uiwriter$(1)))