LibreOffice Module i18npool (master) 1
transliteration_commonclass.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
22
23using namespace ::com::sun::star::uno;
24using namespace ::com::sun::star::i18n;
25using namespace ::com::sun::star::lang;
26
27namespace i18npool {
28
30{
33}
34
36{
37 return OUString::createFromAscii(transliterationName);
38}
39
40void SAL_CALL transliteration_commonclass::loadModule( TransliterationModules /*modName*/, const Locale& rLocale )
41{
42 aLocale = rLocale;
43}
44
45
46void SAL_CALL
47transliteration_commonclass::loadModuleNew( const Sequence < TransliterationModulesNew >& /*modName*/, const Locale& /*rLocale*/ )
48{
49 throw RuntimeException();
50}
51
52
53void SAL_CALL
54transliteration_commonclass::loadModuleByImplName( const OUString& /*implName*/, const Locale& /*rLocale*/ )
55{
56 throw RuntimeException();
57}
58
59void SAL_CALL
60transliteration_commonclass::loadModulesByImplNames(const Sequence< OUString >& /*modNamelist*/, const Locale& /*rLocale*/)
61{
62 throw RuntimeException();
63}
64
65Sequence< OUString > SAL_CALL
66transliteration_commonclass::getAvailableModules( const Locale& /*rLocale*/, sal_Int16 /*sType*/ )
67{
68 throw RuntimeException();
69}
70
71sal_Int32 SAL_CALL
73 const OUString& str1, sal_Int32 off1, sal_Int32 len1,
74 const OUString& str2, sal_Int32 off2, sal_Int32 len2)
75{
76 Sequence <sal_Int32> offset1(2*len1);
77 Sequence <sal_Int32> offset2(2*len2);
78
79 OUString in_str1 = transliterate(str1, off1, len1, offset1);
80 OUString in_str2 = transliterate(str2, off2, len2, offset2);
81 sal_Int32 strlen1 = in_str1.getLength();
82 sal_Int32 strlen2 = in_str2.getLength();
83 const sal_Unicode* unistr1 = in_str1.getStr();
84 const sal_Unicode* unistr2 = in_str2.getStr();
85
86 while (strlen1 && strlen2)
87 {
88 sal_Int32 ret = *unistr1 - *unistr2;
89 if (ret)
90 return ret;
91
92 unistr1++;
93 unistr2++;
94 strlen1--;
95 strlen2--;
96 }
97 return strlen1 - strlen2;
98}
99
100sal_Int32 SAL_CALL
101transliteration_commonclass::compareString( const OUString& str1, const OUString& str2 )
102{
103 return compareSubstring(str1, 0, str1.getLength(), str2, 0, str2.getLength());
104}
105
106OUString SAL_CALL
107transliteration_commonclass::transliterateString2String( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount )
108{
109 return transliterateImpl(inStr, startPos, nCount, nullptr);
110}
111
112OUString SAL_CALL
114{
115 return transliteration_commonclass::transliterateString2String(OUString(&inChar, 1), 0, 1);
116}
117
119{
120 return OUString::createFromAscii(implementationName);
121}
122
123sal_Bool SAL_CALL transliteration_commonclass::supportsService(const OUString& rServiceName)
124{
125 return cppu::supportsService(this, rServiceName);
126}
127
129{
130 return { "com.sun.star.i18n.Transliteration.l10n" };
131}
132
133}
134
135/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual OUString SAL_CALL transliterate(const OUString &inStr, sal_Int32 startPos, sal_Int32 nCount, css::uno::Sequence< sal_Int32 > &offset) override final
virtual OUString SAL_CALL transliterateChar2String(sal_Unicode inChar) override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual OUString SAL_CALL getName() override
void SAL_CALL loadModuleByImplName(const OUString &implName, const css::lang::Locale &rLocale) override
void SAL_CALL loadModulesByImplNames(const css::uno::Sequence< OUString > &modNamelist, const css::lang::Locale &rLocale) override
void SAL_CALL loadModuleNew(const css::uno::Sequence< css::i18n::TransliterationModulesNew > &modName, const css::lang::Locale &rLocale) override
virtual OUString transliterateImpl(const OUString &inStr, sal_Int32 startPos, sal_Int32 nCount, css::uno::Sequence< sal_Int32 > *pOffset)=0
virtual OUString SAL_CALL getImplementationName() override
void SAL_CALL loadModule(css::i18n::TransliterationModules modName, const css::lang::Locale &rLocale) override
virtual sal_Int32 SAL_CALL compareString(const OUString &s1, const OUString &s2) override
virtual sal_Int32 SAL_CALL compareSubstring(const OUString &s1, sal_Int32 off1, sal_Int32 len1, const OUString &s2, sal_Int32 off2, sal_Int32 len2) override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
css::uno::Sequence< OUString > SAL_CALL getAvailableModules(const css::lang::Locale &rLocale, sal_Int16 sType) override
virtual OUString SAL_CALL transliterateString2String(const OUString &inStr, sal_Int32 startPos, sal_Int32 nCount) override
int nCount
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
Constant values shared between i18npool and, for example, the number formatter.
unsigned char sal_Bool
sal_uInt16 sal_Unicode