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 
23 using namespace ::com::sun::star::uno;
24 using namespace ::com::sun::star::i18n;
25 using namespace ::com::sun::star::lang;
26 
27 namespace i18npool {
28 
30 {
32  implementationName = "";
33 }
34 
36 {
37  return OUString::createFromAscii(transliterationName);
38 }
39 
40 void SAL_CALL transliteration_commonclass::loadModule( TransliterationModules /*modName*/, const Locale& rLocale )
41 {
42  aLocale = rLocale;
43 }
44 
45 
46 void SAL_CALL
47 transliteration_commonclass::loadModuleNew( const Sequence < TransliterationModulesNew >& /*modName*/, const Locale& /*rLocale*/ )
48 {
49  throw RuntimeException();
50 }
51 
52 
53 void SAL_CALL
54 transliteration_commonclass::loadModuleByImplName( const OUString& /*implName*/, const Locale& /*rLocale*/ )
55 {
56  throw RuntimeException();
57 }
58 
59 void SAL_CALL
60 transliteration_commonclass::loadModulesByImplNames(const Sequence< OUString >& /*modNamelist*/, const Locale& /*rLocale*/)
61 {
62  throw RuntimeException();
63 }
64 
65 Sequence< OUString > SAL_CALL
66 transliteration_commonclass::getAvailableModules( const Locale& /*rLocale*/, sal_Int16 /*sType*/ )
67 {
68  throw RuntimeException();
69 }
70 
71 sal_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 
100 sal_Int32 SAL_CALL
101 transliteration_commonclass::compareString( const OUString& str1, const OUString& str2 )
102 {
103  return compareSubstring(str1, 0, str1.getLength(), str2, 0, str2.getLength());
104 }
105 
106 OUString SAL_CALL
107 transliteration_commonclass::transliterateString2String( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount )
108 {
109  return transliterateImpl(inStr, startPos, nCount, nullptr);
110 }
111 
112 OUString SAL_CALL
114 {
115  return transliteration_commonclass::transliterateString2String(OUString(&inChar, 1), 0, 1);
116 }
117 
119 {
120  return OUString::createFromAscii(implementationName);
121 }
122 
123 sal_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: */
void SAL_CALL loadModuleNew(const css::uno::Sequence< css::i18n::TransliterationModulesNew > &modName, const css::lang::Locale &rLocale) override
virtual OUString SAL_CALL getImplementationName() 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
void SAL_CALL loadModulesByImplNames(const css::uno::Sequence< OUString > &modNamelist, const css::lang::Locale &rLocale) override
css::uno::Sequence< OUString > SAL_CALL getAvailableModules(const css::lang::Locale &rLocale, sal_Int16 sType) override
sal_uInt16 sal_Unicode
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual OUString transliterateImpl(const OUString &inStr, sal_Int32 startPos, sal_Int32 nCount, css::uno::Sequence< sal_Int32 > *pOffset)=0
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
virtual OUString SAL_CALL transliterateString2String(const OUString &inStr, sal_Int32 startPos, sal_Int32 nCount) override
virtual sal_Int32 SAL_CALL compareString(const OUString &s1, const OUString &s2) override
void SAL_CALL loadModuleByImplName(const OUString &implName, const css::lang::Locale &rLocale) override
virtual OUString SAL_CALL getName() override
unsigned char sal_Bool
Constant values shared between i18npool and, for example, the number formatter.
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
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
void SAL_CALL loadModule(css::i18n::TransliterationModules modName, const css::lang::Locale &rLocale) override