1*449ab281SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*449ab281SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*449ab281SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*449ab281SAndrew Rist * distributed with this work for additional information
6*449ab281SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*449ab281SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*449ab281SAndrew Rist * "License"); you may not use this file except in compliance
9*449ab281SAndrew Rist * with the License. You may obtain a copy of the License at
10*449ab281SAndrew Rist *
11*449ab281SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*449ab281SAndrew Rist *
13*449ab281SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*449ab281SAndrew Rist * software distributed under the License is distributed on an
15*449ab281SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*449ab281SAndrew Rist * KIND, either express or implied. See the License for the
17*449ab281SAndrew Rist * specific language governing permissions and limitations
18*449ab281SAndrew Rist * under the License.
19*449ab281SAndrew Rist *
20*449ab281SAndrew Rist *************************************************************/
21*449ab281SAndrew Rist
22*449ab281SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_i18npool.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <transliteration_commonclass.hxx>
28cdf0e10cSrcweir #include <com/sun/star/i18n/CollatorOptions.hpp>
29cdf0e10cSrcweir
30cdf0e10cSrcweir using namespace ::com::sun::star::uno;
31cdf0e10cSrcweir using namespace ::com::sun::star::lang;
32cdf0e10cSrcweir using namespace ::rtl;
33cdf0e10cSrcweir
34cdf0e10cSrcweir namespace com { namespace sun { namespace star { namespace i18n {
35cdf0e10cSrcweir
transliteration_commonclass()36cdf0e10cSrcweir transliteration_commonclass::transliteration_commonclass()
37cdf0e10cSrcweir {
38cdf0e10cSrcweir transliterationName = "";
39cdf0e10cSrcweir implementationName = "";
40cdf0e10cSrcweir useOffset = sal_True;
41cdf0e10cSrcweir }
42cdf0e10cSrcweir
getName()43cdf0e10cSrcweir OUString SAL_CALL transliteration_commonclass::getName() throw(RuntimeException)
44cdf0e10cSrcweir {
45cdf0e10cSrcweir return OUString::createFromAscii(transliterationName);
46cdf0e10cSrcweir }
47cdf0e10cSrcweir
loadModule(TransliterationModules,const Locale & rLocale)48cdf0e10cSrcweir void SAL_CALL transliteration_commonclass::loadModule( TransliterationModules /*modName*/, const Locale& rLocale )
49cdf0e10cSrcweir throw(RuntimeException)
50cdf0e10cSrcweir {
51cdf0e10cSrcweir aLocale = rLocale;
52cdf0e10cSrcweir }
53cdf0e10cSrcweir
54cdf0e10cSrcweir
55cdf0e10cSrcweir void SAL_CALL
loadModuleNew(const Sequence<TransliterationModulesNew> &,const Locale &)56cdf0e10cSrcweir transliteration_commonclass::loadModuleNew( const Sequence < TransliterationModulesNew >& /*modName*/, const Locale& /*rLocale*/ )
57cdf0e10cSrcweir throw(RuntimeException)
58cdf0e10cSrcweir {
59cdf0e10cSrcweir throw RuntimeException();
60cdf0e10cSrcweir }
61cdf0e10cSrcweir
62cdf0e10cSrcweir
63cdf0e10cSrcweir void SAL_CALL
loadModuleByImplName(const OUString &,const Locale &)64cdf0e10cSrcweir transliteration_commonclass::loadModuleByImplName( const OUString& /*implName*/, const Locale& /*rLocale*/ )
65cdf0e10cSrcweir throw(RuntimeException)
66cdf0e10cSrcweir {
67cdf0e10cSrcweir throw RuntimeException();
68cdf0e10cSrcweir }
69cdf0e10cSrcweir
70cdf0e10cSrcweir void SAL_CALL
loadModulesByImplNames(const Sequence<OUString> &,const Locale &)71cdf0e10cSrcweir transliteration_commonclass::loadModulesByImplNames(const Sequence< OUString >& /*modNamelist*/, const Locale& /*rLocale*/)
72cdf0e10cSrcweir throw(RuntimeException)
73cdf0e10cSrcweir {
74cdf0e10cSrcweir throw RuntimeException();
75cdf0e10cSrcweir }
76cdf0e10cSrcweir
77cdf0e10cSrcweir Sequence< OUString > SAL_CALL
getAvailableModules(const Locale &,sal_Int16)78cdf0e10cSrcweir transliteration_commonclass::getAvailableModules( const Locale& /*rLocale*/, sal_Int16 /*sType*/ )
79cdf0e10cSrcweir throw(RuntimeException)
80cdf0e10cSrcweir {
81cdf0e10cSrcweir throw RuntimeException();
82cdf0e10cSrcweir }
83cdf0e10cSrcweir
84cdf0e10cSrcweir sal_Int32 SAL_CALL
compareSubstring(const OUString & str1,sal_Int32 off1,sal_Int32 len1,const OUString & str2,sal_Int32 off2,sal_Int32 len2)85cdf0e10cSrcweir transliteration_commonclass::compareSubstring(
86cdf0e10cSrcweir const OUString& str1, sal_Int32 off1, sal_Int32 len1,
87cdf0e10cSrcweir const OUString& str2, sal_Int32 off2, sal_Int32 len2)
88cdf0e10cSrcweir throw(RuntimeException)
89cdf0e10cSrcweir {
90cdf0e10cSrcweir const sal_Unicode* unistr1 = NULL;
91cdf0e10cSrcweir const sal_Unicode* unistr2 = NULL;
92cdf0e10cSrcweir sal_uInt32 strlen1;
93cdf0e10cSrcweir sal_uInt32 strlen2;
94cdf0e10cSrcweir
95cdf0e10cSrcweir Sequence <sal_Int32> offset1(2*len1);
96cdf0e10cSrcweir Sequence <sal_Int32> offset2(2*len2);
97cdf0e10cSrcweir
98cdf0e10cSrcweir OUString in_str1 = this->transliterate(str1, off1, len1, offset1);
99cdf0e10cSrcweir OUString in_str2 = this->transliterate(str2, off2, len2, offset2);
100cdf0e10cSrcweir strlen1 = in_str1.getLength();
101cdf0e10cSrcweir strlen2 = in_str2.getLength();
102cdf0e10cSrcweir unistr1 = in_str1.getStr();
103cdf0e10cSrcweir unistr2 = in_str2.getStr();
104cdf0e10cSrcweir
105cdf0e10cSrcweir while (strlen1 && strlen2)
106cdf0e10cSrcweir {
107cdf0e10cSrcweir sal_uInt32 ret = *unistr1 - *unistr2;
108cdf0e10cSrcweir if (ret)
109cdf0e10cSrcweir return ret;
110cdf0e10cSrcweir
111cdf0e10cSrcweir unistr1++;
112cdf0e10cSrcweir unistr2++;
113cdf0e10cSrcweir strlen1--;
114cdf0e10cSrcweir strlen2--;
115cdf0e10cSrcweir }
116cdf0e10cSrcweir return strlen1 - strlen2;
117cdf0e10cSrcweir }
118cdf0e10cSrcweir
119cdf0e10cSrcweir sal_Int32 SAL_CALL
compareString(const OUString & str1,const OUString & str2)120cdf0e10cSrcweir transliteration_commonclass::compareString( const OUString& str1, const OUString& str2 ) throw ( RuntimeException)
121cdf0e10cSrcweir {
122cdf0e10cSrcweir return( this->compareSubstring(str1, 0, str1.getLength(), str2, 0, str2.getLength()));
123cdf0e10cSrcweir }
124cdf0e10cSrcweir
125cdf0e10cSrcweir OUString SAL_CALL
transliterateString2String(const OUString & inStr,sal_Int32 startPos,sal_Int32 nCount)126cdf0e10cSrcweir transliteration_commonclass::transliterateString2String( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount ) throw(RuntimeException)
127cdf0e10cSrcweir {
128cdf0e10cSrcweir static Sequence < sal_Int32 > dummy_offset;
129cdf0e10cSrcweir useOffset = sal_False;
130cdf0e10cSrcweir OUString tmpStr = transliterate(inStr, startPos, nCount, dummy_offset);
131cdf0e10cSrcweir useOffset = sal_True;
132cdf0e10cSrcweir return tmpStr;
133cdf0e10cSrcweir }
134cdf0e10cSrcweir
135cdf0e10cSrcweir OUString SAL_CALL
transliterateChar2String(sal_Unicode inChar)136cdf0e10cSrcweir transliteration_commonclass::transliterateChar2String( sal_Unicode inChar ) throw(RuntimeException)
137cdf0e10cSrcweir {
138cdf0e10cSrcweir return transliteration_commonclass::transliterateString2String(OUString(&inChar, 1), 0, 1);
139cdf0e10cSrcweir }
140cdf0e10cSrcweir
getImplementationName()141cdf0e10cSrcweir OUString SAL_CALL transliteration_commonclass::getImplementationName() throw( RuntimeException )
142cdf0e10cSrcweir {
143cdf0e10cSrcweir return OUString::createFromAscii(implementationName);
144cdf0e10cSrcweir }
145cdf0e10cSrcweir
146cdf0e10cSrcweir const sal_Char cTrans[] = "com.sun.star.i18n.Transliteration.l10n";
147cdf0e10cSrcweir
supportsService(const OUString & rServiceName)148cdf0e10cSrcweir sal_Bool SAL_CALL transliteration_commonclass::supportsService(const OUString& rServiceName) throw( RuntimeException )
149cdf0e10cSrcweir {
150cdf0e10cSrcweir return rServiceName.equalsAscii(cTrans);
151cdf0e10cSrcweir }
152cdf0e10cSrcweir
getSupportedServiceNames()153cdf0e10cSrcweir Sequence< OUString > SAL_CALL transliteration_commonclass::getSupportedServiceNames() throw( RuntimeException )
154cdf0e10cSrcweir {
155cdf0e10cSrcweir Sequence< OUString > aRet(1);
156cdf0e10cSrcweir aRet[0] = OUString::createFromAscii(cTrans);
157cdf0e10cSrcweir return aRet;
158cdf0e10cSrcweir }
159cdf0e10cSrcweir
160cdf0e10cSrcweir } } } }
161