summaryrefslogtreecommitdiff
path: root/i18npool
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2024-02-19 15:48:38 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2024-02-19 20:33:57 +0100
commit191e3f8d891c6d2b5e0f63823a1f9afb7d54418f (patch)
tree3570823540b4c34b0f70cd564b66e30001461f22 /i18npool
parent9bd2012df77da01b9ee30b25698237fb45673f49 (diff)
merge textconv_dict into i18npool
(*) it is a small library (*) this avoids more dynamic symbol lookup (*) this unblocks more --enable-mergedlibs optimisation Change-Id: Icb708828e9d711981ec4273351cd73343aa206d7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163596 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'i18npool')
-rw-r--r--i18npool/CustomTarget_textconversion.mk4
-rw-r--r--i18npool/Library_i18npool.mk5
-rw-r--r--i18npool/Library_textconv_dict.mk32
-rw-r--r--i18npool/Module_i18npool.mk1
-rw-r--r--i18npool/inc/textconversion.hxx38
-rw-r--r--i18npool/source/textconversion/textconversion.cxx32
-rw-r--r--i18npool/source/textconversion/textconversion_ko.cxx25
-rw-r--r--i18npool/source/textconversion/textconversion_zh.cxx52
8 files changed, 38 insertions, 151 deletions
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 <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/i18n/XExtendedTextConversion.hpp>
#include <cppuhelper/implbase.hxx>
-#include <osl/module.h>
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 <sal_Int32>& 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<const sal_Unicode* (*)()>(getFunctionBySymbol("getHangul2HanjaData"));
- const Hangul_Index* (*getHangul2HanjaIndex)() = reinterpret_cast<const Hangul_Index* (*)()>(getFunctionBySymbol("getHangul2HanjaIndex"));
- sal_Int16 (*getHangul2HanjaIndexCount)() = reinterpret_cast<sal_Int16 (*)()>(getFunctionBySymbol("getHangul2HanjaIndexCount"));
- const sal_uInt16* (*getHanja2HangulIndex)() = reinterpret_cast<const sal_uInt16* (*)()>(getFunctionBySymbol("getHanja2HangulIndex"));
- const sal_Unicode* (*getHanja2HangulData)() = reinterpret_cast<const sal_Unicode* (*)()>(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<sal_Unicode[]> 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<const sal_Unicode* (*)()>(getFunctionBySymbol("getSTC_CharData_T2S"))();
- Index = reinterpret_cast<const sal_uInt16* (*)()>(getFunctionBySymbol("getSTC_CharIndex_T2S"))();
- } else if (nConversionOptions & TextConversionOption::USE_CHARACTER_VARIANTS) {
- Data = reinterpret_cast<const sal_Unicode* (*)()>(getFunctionBySymbol("getSTC_CharData_S2V"))();
- Index = reinterpret_cast<const sal_uInt16* (*)()>(getFunctionBySymbol("getSTC_CharIndex_S2V"))();
- } else {
- Data = reinterpret_cast<const sal_Unicode* (*)()>(getFunctionBySymbol("getSTC_CharData_S2T"))();
- Index = reinterpret_cast<const sal_uInt16* (*)()>(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<sal_Int32>& offset)
+TextConversion_zh::getWordConversion(std::u16string_view aText, sal_Int32 nStartPos, sal_Int32 nLength, bool toSChinese, sal_Int32 nConversionOptions, Sequence<sal_Int32>& 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<const sal_Unicode* (*)(sal_Int32&)>(getFunctionBySymbol("getSTC_WordData"))(dictLen);
- if (toSChinese) {
- index = reinterpret_cast<const sal_uInt16* (*)(sal_Int32&)>(getFunctionBySymbol("getSTC_WordIndex_T2S"))(maxLen);
- entry = reinterpret_cast<const sal_uInt16* (*)()>(getFunctionBySymbol("getSTC_WordEntry_T2S"))();
- charData = reinterpret_cast<const sal_Unicode* (*)()>(getFunctionBySymbol("getSTC_CharData_T2S"))();
- charIndex = reinterpret_cast<const sal_uInt16* (*)()>(getFunctionBySymbol("getSTC_CharIndex_T2S"))();
- } else {
- index = reinterpret_cast<const sal_uInt16* (*)(sal_Int32&)>(getFunctionBySymbol("getSTC_WordIndex_S2T"))(maxLen);
- entry = reinterpret_cast<const sal_uInt16* (*)()>(getFunctionBySymbol("getSTC_WordEntry_S2T"))();
- if (nConversionOptions & TextConversionOption::USE_CHARACTER_VARIANTS) {
- charData = reinterpret_cast<const sal_Unicode* (*)()>(getFunctionBySymbol("getSTC_CharData_S2V"))();
- charIndex = reinterpret_cast<const sal_uInt16* (*)()>(getFunctionBySymbol("getSTC_CharIndex_S2V"))();
- } else {
- charData = reinterpret_cast<const sal_Unicode* (*)()>(getFunctionBySymbol("getSTC_CharData_S2T"))();
- charIndex = reinterpret_cast<const sal_uInt16* (*)()>(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()) {