merge index_data into i18npool
(*) it is a small library (*) this avoids another dynamic symbol lookup (*) this unblocks more --enable-mergedlibs optimisation Change-Id: I9230230c3d72f4e9ce19408f4b5716452ccd4fad Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163364 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
parent
028affcf44
commit
de43ed1088
11 changed files with 34 additions and 144 deletions
|
@ -701,7 +701,6 @@ $(eval $(call gb_Helper_register_libraries_for_install,PLAINLIBS_OOO,ooo, \
|
|||
$(eval $(call gb_Helper_register_plugins_for_install,PLAINLIBS_OOO,ooo, \
|
||||
dict_ja \
|
||||
dict_zh \
|
||||
index_data \
|
||||
localedata_en \
|
||||
localedata_es \
|
||||
localedata_euro \
|
||||
|
|
|
@ -20,6 +20,7 @@ $(eval $(call gb_CppunitTest_use_components,i18npool_transliteration, \
|
|||
$(eval $(call gb_CppunitTest_use_libraries,i18npool_transliteration, \
|
||||
cppu \
|
||||
cppuhelper \
|
||||
i18npool \
|
||||
sal \
|
||||
))
|
||||
|
||||
|
@ -27,6 +28,4 @@ $(eval $(call gb_CppunitTest_use_sdk_api,i18npool_transliteration))
|
|||
|
||||
$(eval $(call gb_CppunitTest_use_ure,i18npool_transliteration))
|
||||
|
||||
$(call gb_CppunitTest_get_target,i18npool_transliteration): $(call gb_Library_get_target,index_data)
|
||||
|
||||
# vim: set noet sw=4 ts=4:
|
||||
|
|
|
@ -159,4 +159,11 @@ $(eval $(call gb_Library_add_generated_cobjects,i18npool,\
|
|||
$(if $(filter GCC,$(COM)),-Wno-unused-macros) \
|
||||
))
|
||||
|
||||
# index data
|
||||
$(eval $(call gb_Library_add_generated_exception_objects,i18npool,\
|
||||
$(foreach txt,$(wildcard $(SRCDIR)/i18npool/source/indexentry/data/*.txt),\
|
||||
CustomTarget/i18npool/indexentry/$(notdir $(basename $(txt)))) \
|
||||
))
|
||||
|
||||
|
||||
# vim: set noet sw=4 ts=4:
|
||||
|
|
|
@ -1,19 +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,index_data))
|
||||
|
||||
$(eval $(call gb_Library_set_plugin_for_nodep,index_data,i18npool))
|
||||
|
||||
$(eval $(call gb_Library_add_generated_exception_objects,index_data,\
|
||||
$(foreach txt,$(wildcard $(SRCDIR)/i18npool/source/indexentry/data/*.txt),\
|
||||
CustomTarget/i18npool/indexentry/$(notdir $(basename $(txt)))) \
|
||||
))
|
||||
|
||||
# vim: set noet sw=4 ts=4:
|
|
@ -20,7 +20,6 @@ $(eval $(call gb_Module_add_targets,i18npool,\
|
|||
Library_dict_zh) \
|
||||
Library_i18npool \
|
||||
Library_i18nsearch \
|
||||
Library_index_data \
|
||||
Library_localedata_en \
|
||||
Library_localedata_es \
|
||||
Library_localedata_euro \
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
|
||||
|
||||
#include "indexentrysupplier_common.hxx"
|
||||
#include <osl/module.h>
|
||||
|
||||
namespace i18npool {
|
||||
|
||||
|
@ -44,12 +43,25 @@ public:
|
|||
const css::lang::Locale& rLocale2 ) override;
|
||||
OUString SAL_CALL getPhoneticCandidate( const OUString& rIndexEntry,
|
||||
const css::lang::Locale& rLocale ) override;
|
||||
#ifndef DISABLE_DYNLOADING
|
||||
private:
|
||||
oslModule hModule;
|
||||
#endif
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
||||
const sal_uInt16** get_indexdata_ko_dict(sal_Int16&);
|
||||
const sal_uInt16** get_indexdata_zh_TW_radical(sal_Int16&);
|
||||
const sal_uInt16** get_indexdata_zh_TW_stroke(sal_Int16&);
|
||||
const sal_uInt16** get_indexdata_zh_pinyin(sal_Int16&);
|
||||
const sal_uInt16** get_indexdata_zh_radical(sal_Int16&);
|
||||
const sal_uInt16** get_indexdata_zh_stroke(sal_Int16&);
|
||||
const sal_uInt16** get_indexdata_zh_zhuyin(sal_Int16&);
|
||||
|
||||
const sal_uInt16** get_ko_phonetic(sal_Int16&);
|
||||
const sal_uInt16** get_zh_pinyin(sal_Int16&);
|
||||
const sal_uInt16** get_zh_zhuyin(sal_Int16&);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
|
|
@ -20,25 +20,17 @@
|
|||
#pragma once
|
||||
|
||||
#include "transliteration_Ignore.hxx"
|
||||
#include <osl/module.hxx>
|
||||
|
||||
namespace i18npool {
|
||||
|
||||
class TextToPronounce_zh : public transliteration_Ignore
|
||||
{
|
||||
protected:
|
||||
#ifndef DISABLE_DYNLOADING
|
||||
oslModule hModule;
|
||||
#endif
|
||||
sal_uInt16 const **idx;
|
||||
const sal_Unicode* getPronounce(const sal_Unicode ch);
|
||||
|
||||
public:
|
||||
#ifndef DISABLE_DYNLOADING
|
||||
TextToPronounce_zh(const char* func_name);
|
||||
#else
|
||||
TextToPronounce_zh(sal_uInt16 const ** (*function)(sal_Int16 &));
|
||||
#endif
|
||||
virtual ~TextToPronounce_zh() override;
|
||||
|
||||
OUString
|
||||
|
|
|
@ -62,8 +62,8 @@ static void data_write(char* file, char* name, sal_uInt8 *data, sal_Int32 len)
|
|||
}
|
||||
fprintf(fp, "\n};\n\n");
|
||||
|
||||
fprintf(fp, "SAL_DLLPUBLIC_EXPORT const sal_uInt8* get_collator_data_%s() { return %s; }\n", name, name);
|
||||
fprintf(fp, "SAL_DLLPUBLIC_EXPORT size_t get_collator_data_%s_length() { return sizeof(%s); }\n", name, name);
|
||||
fprintf(fp, "const sal_uInt8* get_collator_data_%s() { return %s; }\n", name, name);
|
||||
fprintf(fp, "size_t get_collator_data_%s_length() { return sizeof(%s); }\n", name, name);
|
||||
fprintf(fp, "\n");
|
||||
fprintf (fp, "}\n");
|
||||
|
||||
|
|
|
@ -30,66 +30,23 @@ using namespace ::com::sun::star::lang;
|
|||
|
||||
namespace i18npool {
|
||||
|
||||
#ifndef DISABLE_DYNLOADING
|
||||
|
||||
extern "C" { static void thisModule() {} }
|
||||
|
||||
#endif
|
||||
|
||||
IndexEntrySupplier_asian::IndexEntrySupplier_asian(
|
||||
const Reference < XComponentContext >& rxContext ) : IndexEntrySupplier_Common(rxContext)
|
||||
{
|
||||
implementationName = "com.sun.star.i18n.IndexEntrySupplier_asian";
|
||||
#ifndef DISABLE_DYNLOADING
|
||||
constexpr OUString lib( u"" SAL_MODULENAME( "index_data" ) ""_ustr );
|
||||
hModule = osl_loadModuleRelative(
|
||||
&thisModule, lib.pData, SAL_LOADMODULE_DEFAULT );
|
||||
#endif
|
||||
}
|
||||
|
||||
IndexEntrySupplier_asian::~IndexEntrySupplier_asian()
|
||||
{
|
||||
#ifndef DISABLE_DYNLOADING
|
||||
if (hModule) osl_unloadModule(hModule);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef DISABLE_DYNLOADING
|
||||
|
||||
extern "C" {
|
||||
|
||||
sal_uInt16** get_indexdata_ko_dict(sal_Int16*);
|
||||
sal_uInt16** get_indexdata_zh_TW_radical(sal_Int16*);
|
||||
sal_uInt16** get_indexdata_zh_TW_stroke(sal_Int16*);
|
||||
sal_uInt16** get_indexdata_zh_pinyin(sal_Int16*);
|
||||
sal_uInt16** get_indexdata_zh_radical(sal_Int16*);
|
||||
sal_uInt16** get_indexdata_zh_stroke(sal_Int16*);
|
||||
sal_uInt16** get_indexdata_zh_zhuyin(sal_Int16*);
|
||||
|
||||
sal_uInt16** get_ko_phonetic(sal_Int16*);
|
||||
sal_uInt16** get_zh_pinyin(sal_Int16*);
|
||||
sal_uInt16** get_zh_zhuyin(sal_Int16*);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
OUString SAL_CALL
|
||||
IndexEntrySupplier_asian::getIndexCharacter( const OUString& rIndexEntry,
|
||||
const Locale& rLocale, const OUString& rAlgorithm )
|
||||
{
|
||||
sal_uInt32 ch = rIndexEntry.iterateCodePoints(&o3tl::temporary(sal_Int32(0)), 0);
|
||||
|
||||
sal_uInt16** (*func)(sal_Int16*)=nullptr;
|
||||
#ifndef DISABLE_DYNLOADING
|
||||
if (hModule) {
|
||||
OUString get("get_indexdata_");
|
||||
if ( rLocale.Language == "zh" && OUString( "TW HK MO" ).indexOf(rLocale.Country) >= 0 )
|
||||
func=reinterpret_cast<sal_uInt16** (*)(sal_Int16*)>(osl_getFunctionSymbol(hModule, OUString(get+rLocale.Language+"_TW_"+rAlgorithm).pData));
|
||||
if (!func)
|
||||
func=reinterpret_cast<sal_uInt16** (*)(sal_Int16*)>(osl_getFunctionSymbol(hModule, OUString(get+rLocale.Language+"_"+rAlgorithm).pData));
|
||||
}
|
||||
#else
|
||||
const sal_uInt16** (*func)(sal_Int16&)=nullptr;
|
||||
if ( rLocale.Language == "zh" && OUString( "TW HK MO" ).indexOf(rLocale.Country) >= 0 ) {
|
||||
if ( rAlgorithm == "radical" )
|
||||
func = get_indexdata_zh_TW_radical;
|
||||
|
@ -111,17 +68,16 @@ IndexEntrySupplier_asian::getIndexCharacter( const OUString& rIndexEntry,
|
|||
func = get_indexdata_zh_zhuyin;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (func) {
|
||||
sal_Int16 max_index;
|
||||
sal_uInt16** idx=func(&max_index);
|
||||
const sal_uInt16** idx=func(max_index);
|
||||
if (static_cast<sal_Int16>(ch >> 8) <= max_index) {
|
||||
sal_uInt16 address=idx[0][ch >> 8];
|
||||
if (address != 0xFFFF) {
|
||||
address=idx[1][address+(ch & 0xFF)];
|
||||
return idx[2]
|
||||
? OUString(
|
||||
reinterpret_cast<sal_Unicode *>(&idx[2][address]))
|
||||
reinterpret_cast<const sal_Unicode *>(&idx[2][address]))
|
||||
: OUString(sal_Unicode(address));
|
||||
}
|
||||
}
|
||||
|
@ -159,28 +115,16 @@ OUString SAL_CALL
|
|||
IndexEntrySupplier_asian::getPhoneticCandidate( const OUString& rIndexEntry,
|
||||
const Locale& rLocale )
|
||||
{
|
||||
sal_uInt16 **(*func)(sal_Int16*)=nullptr;
|
||||
#ifndef DISABLE_DYNLOADING
|
||||
if (hModule) {
|
||||
const char *func_name=nullptr;
|
||||
if ( rLocale.Language == "zh" )
|
||||
func_name=(OUString("TW HK MO").indexOf(rLocale.Country) >= 0) ? "get_zh_zhuyin" : "get_zh_pinyin";
|
||||
else if ( rLocale.Language == "ko" )
|
||||
func_name="get_ko_phonetic";
|
||||
if (func_name)
|
||||
func=reinterpret_cast<sal_uInt16 **(*)(sal_Int16*)>(osl_getFunctionSymbol(hModule, OUString::createFromAscii(func_name).pData));
|
||||
}
|
||||
#else
|
||||
sal_uInt16 const **(*func)(sal_Int16&)=nullptr;
|
||||
if ( rLocale.Language == "zh" )
|
||||
func = (OUString("TW HK MO").indexOf(rLocale.Country) >= 0) ? get_zh_zhuyin : get_zh_pinyin;
|
||||
else if ( rLocale.Language == "ko" )
|
||||
func = get_ko_phonetic;
|
||||
|
||||
#endif
|
||||
if (func) {
|
||||
OUStringBuffer candidate;
|
||||
sal_Int16 max_index;
|
||||
sal_uInt16** idx=func(&max_index);
|
||||
sal_uInt16 const ** idx=func(max_index);
|
||||
for (sal_Int32 i=0,j=0; i < rIndexEntry.getLength(); i=j) {
|
||||
sal_uInt32 ch = rIndexEntry.iterateCodePoints(&j);
|
||||
if (static_cast<sal_Int16>(ch>>8) <= max_index) {
|
||||
|
@ -191,7 +135,7 @@ IndexEntrySupplier_asian::getPhoneticCandidate( const OUString& rIndexEntry,
|
|||
candidate.append(" ");
|
||||
if (idx[2])
|
||||
candidate.append(
|
||||
reinterpret_cast<sal_Unicode *>(&idx[2][address]));
|
||||
reinterpret_cast<const sal_Unicode *>(&idx[2][address]));
|
||||
else
|
||||
candidate.append(sal_Unicode(address));
|
||||
} else
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <rtl/ustrbuf.hxx>
|
||||
|
||||
#include <textToPronounce_zh.hxx>
|
||||
#include <indexentrysupplier_asian.hxx>
|
||||
|
||||
using namespace com::sun::star::i18n;
|
||||
using namespace com::sun::star::uno;
|
||||
|
@ -123,70 +124,27 @@ TextToPronounce_zh::equals( const OUString & str1, sal_Int32 pos1, sal_Int32 nCo
|
|||
return (nCount1 == nCount2);
|
||||
}
|
||||
|
||||
#ifdef DISABLE_DYNLOADING
|
||||
|
||||
extern "C" {
|
||||
|
||||
sal_uInt16 const ** get_zh_zhuyin(sal_Int16 & max_index);
|
||||
sal_uInt16 const ** get_zh_pinyin(sal_Int16 & max_index);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
TextToPinyin_zh_CN::TextToPinyin_zh_CN() :
|
||||
#ifndef DISABLE_DYNLOADING
|
||||
TextToPronounce_zh("get_zh_pinyin")
|
||||
#else
|
||||
TextToPronounce_zh(get_zh_pinyin)
|
||||
#endif
|
||||
{
|
||||
transliterationName = "ChineseCharacterToPinyin";
|
||||
implementationName = "com.sun.star.i18n.Transliteration.TextToPinyin_zh_CN";
|
||||
}
|
||||
|
||||
TextToChuyin_zh_TW::TextToChuyin_zh_TW() :
|
||||
#ifndef DISABLE_DYNLOADING
|
||||
TextToPronounce_zh("get_zh_zhuyin")
|
||||
#else
|
||||
TextToPronounce_zh(get_zh_zhuyin)
|
||||
#endif
|
||||
{
|
||||
transliterationName = "ChineseCharacterToChuyin";
|
||||
implementationName = "com.sun.star.i18n.Transliteration.TextToChuyin_zh_TW";
|
||||
}
|
||||
|
||||
#ifndef DISABLE_DYNLOADING
|
||||
|
||||
extern "C" { static void thisModule() {} }
|
||||
|
||||
TextToPronounce_zh::TextToPronounce_zh(const char* func_name)
|
||||
{
|
||||
constexpr OUString lib( u"" SAL_MODULENAME( "index_data" ) ""_ustr );
|
||||
hModule = osl_loadModuleRelative(
|
||||
&thisModule, lib.pData, SAL_LOADMODULE_DEFAULT );
|
||||
idx=nullptr;
|
||||
if (hModule) {
|
||||
sal_uInt16 const ** (*function)(sal_Int16 &) = reinterpret_cast<sal_uInt16 const ** (*)(sal_Int16 &)>(osl_getFunctionSymbol(hModule, OUString::createFromAscii(func_name).pData));
|
||||
if (function)
|
||||
idx=function(o3tl::temporary(sal_Int16()));
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
TextToPronounce_zh::TextToPronounce_zh(sal_uInt16 const ** (*function)(sal_Int16 &))
|
||||
{
|
||||
idx = function(o3tl::temporary(sal_Int16()));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
TextToPronounce_zh::~TextToPronounce_zh()
|
||||
{
|
||||
#ifndef DISABLE_DYNLOADING
|
||||
if (hModule) osl_unloadModule(hModule);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -150,7 +150,6 @@ fuzzer_core_libraries = \
|
|||
gcc3_uno \
|
||||
salhelper \
|
||||
sal \
|
||||
index_data \
|
||||
localedata_en \
|
||||
localedata_others \
|
||||
|
||||
|
|
Loading…
Reference in a new issue