Line data Source code
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 :
20 : #include <transliteration_commonclass.hxx>
21 : #include <com/sun/star/i18n/CollatorOptions.hpp>
22 : #include <cppuhelper/supportsservice.hxx>
23 :
24 : using namespace ::com::sun::star::uno;
25 : using namespace ::com::sun::star::lang;
26 :
27 : namespace com { namespace sun { namespace star { namespace i18n {
28 :
29 40173 : transliteration_commonclass::transliteration_commonclass()
30 : {
31 40173 : transliterationName = "";
32 40173 : implementationName = "";
33 40173 : useOffset = true;
34 40173 : }
35 :
36 0 : OUString SAL_CALL transliteration_commonclass::getName() throw(RuntimeException, std::exception)
37 : {
38 0 : return OUString::createFromAscii(transliterationName);
39 : }
40 :
41 281 : void SAL_CALL transliteration_commonclass::loadModule( TransliterationModules /*modName*/, const Locale& rLocale )
42 : throw(RuntimeException, std::exception)
43 : {
44 281 : aLocale = rLocale;
45 281 : }
46 :
47 :
48 : void SAL_CALL
49 0 : transliteration_commonclass::loadModuleNew( const Sequence < TransliterationModulesNew >& /*modName*/, const Locale& /*rLocale*/ )
50 : throw(RuntimeException, std::exception)
51 : {
52 0 : throw RuntimeException();
53 : }
54 :
55 :
56 : void SAL_CALL
57 0 : transliteration_commonclass::loadModuleByImplName( const OUString& /*implName*/, const Locale& /*rLocale*/ )
58 : throw(RuntimeException, std::exception)
59 : {
60 0 : throw RuntimeException();
61 : }
62 :
63 : void SAL_CALL
64 0 : transliteration_commonclass::loadModulesByImplNames(const Sequence< OUString >& /*modNamelist*/, const Locale& /*rLocale*/)
65 : throw(RuntimeException, std::exception)
66 : {
67 0 : throw RuntimeException();
68 : }
69 :
70 : Sequence< OUString > SAL_CALL
71 0 : transliteration_commonclass::getAvailableModules( const Locale& /*rLocale*/, sal_Int16 /*sType*/ )
72 : throw(RuntimeException, std::exception)
73 : {
74 0 : throw RuntimeException();
75 : }
76 :
77 : sal_Int32 SAL_CALL
78 0 : transliteration_commonclass::compareSubstring(
79 : const OUString& str1, sal_Int32 off1, sal_Int32 len1,
80 : const OUString& str2, sal_Int32 off2, sal_Int32 len2)
81 : throw(RuntimeException, std::exception)
82 : {
83 0 : Sequence <sal_Int32> offset1(2*len1);
84 0 : Sequence <sal_Int32> offset2(2*len2);
85 :
86 0 : OUString in_str1 = this->transliterate(str1, off1, len1, offset1);
87 0 : OUString in_str2 = this->transliterate(str2, off2, len2, offset2);
88 0 : sal_Int32 strlen1 = in_str1.getLength();
89 0 : sal_Int32 strlen2 = in_str2.getLength();
90 0 : const sal_Unicode* unistr1 = in_str1.getStr();
91 0 : const sal_Unicode* unistr2 = in_str2.getStr();
92 :
93 0 : while (strlen1 && strlen2)
94 : {
95 0 : sal_Int32 ret = *unistr1 - *unistr2;
96 0 : if (ret)
97 0 : return ret;
98 :
99 0 : unistr1++;
100 0 : unistr2++;
101 0 : strlen1--;
102 0 : strlen2--;
103 : }
104 0 : return strlen1 - strlen2;
105 : }
106 :
107 : sal_Int32 SAL_CALL
108 0 : transliteration_commonclass::compareString( const OUString& str1, const OUString& str2 ) throw ( RuntimeException, std::exception)
109 : {
110 0 : return( this->compareSubstring(str1, 0, str1.getLength(), str2, 0, str2.getLength()));
111 : }
112 :
113 : OUString SAL_CALL
114 13777027 : transliteration_commonclass::transliterateString2String( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount ) throw(RuntimeException, std::exception)
115 : {
116 13777027 : Sequence < sal_Int32 > dummy_offset;
117 13777027 : useOffset = false;
118 13777027 : OUString tmpStr = transliterate(inStr, startPos, nCount, dummy_offset);
119 13777027 : useOffset = true;
120 13777027 : return tmpStr;
121 : }
122 :
123 : OUString SAL_CALL
124 0 : transliteration_commonclass::transliterateChar2String( sal_Unicode inChar ) throw(RuntimeException, std::exception)
125 : {
126 0 : return transliteration_commonclass::transliterateString2String(OUString(&inChar, 1), 0, 1);
127 : }
128 :
129 0 : OUString SAL_CALL transliteration_commonclass::getImplementationName() throw( RuntimeException, std::exception )
130 : {
131 0 : return OUString::createFromAscii(implementationName);
132 : }
133 :
134 0 : sal_Bool SAL_CALL transliteration_commonclass::supportsService(const OUString& rServiceName) throw( RuntimeException, std::exception )
135 : {
136 0 : return cppu::supportsService(this, rServiceName);
137 : }
138 :
139 0 : Sequence< OUString > SAL_CALL transliteration_commonclass::getSupportedServiceNames() throw( RuntimeException, std::exception )
140 : {
141 0 : Sequence< OUString > aRet(1);
142 0 : aRet[0] = "com.sun.star.i18n.Transliteration.l10n";
143 0 : return aRet;
144 : }
145 :
146 : } } } }
147 :
148 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|