1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include <transliteration_commonclass.hxx>
22 #include <com/sun/star/i18n/CollatorOptions.hpp>
24 using namespace ::com::sun::star::uno
;
25 using namespace ::com::sun::star::lang
;
26 using namespace ::rtl
;
28 namespace com
{ namespace sun
{ namespace star
{ namespace i18n
{
30 transliteration_commonclass::transliteration_commonclass()
32 transliterationName
= "";
33 implementationName
= "";
37 OUString SAL_CALL
transliteration_commonclass::getName() throw(RuntimeException
)
39 return OUString::createFromAscii(transliterationName
);
42 void SAL_CALL
transliteration_commonclass::loadModule( TransliterationModules
/*modName*/, const Locale
& rLocale
)
43 throw(RuntimeException
)
50 transliteration_commonclass::loadModuleNew( const Sequence
< TransliterationModulesNew
>& /*modName*/, const Locale
& /*rLocale*/ )
51 throw(RuntimeException
)
53 throw RuntimeException();
58 transliteration_commonclass::loadModuleByImplName( const OUString
& /*implName*/, const Locale
& /*rLocale*/ )
59 throw(RuntimeException
)
61 throw RuntimeException();
65 transliteration_commonclass::loadModulesByImplNames(const Sequence
< OUString
>& /*modNamelist*/, const Locale
& /*rLocale*/)
66 throw(RuntimeException
)
68 throw RuntimeException();
71 Sequence
< OUString
> SAL_CALL
72 transliteration_commonclass::getAvailableModules( const Locale
& /*rLocale*/, sal_Int16
/*sType*/ )
73 throw(RuntimeException
)
75 throw RuntimeException();
79 transliteration_commonclass::compareSubstring(
80 const OUString
& str1
, sal_Int32 off1
, sal_Int32 len1
,
81 const OUString
& str2
, sal_Int32 off2
, sal_Int32 len2
)
82 throw(RuntimeException
)
84 const sal_Unicode
* unistr1
= NULL
;
85 const sal_Unicode
* unistr2
= NULL
;
89 Sequence
<sal_Int32
> offset1(2*len1
);
90 Sequence
<sal_Int32
> offset2(2*len2
);
92 OUString in_str1
= this->transliterate(str1
, off1
, len1
, offset1
);
93 OUString in_str2
= this->transliterate(str2
, off2
, len2
, offset2
);
94 strlen1
= in_str1
.getLength();
95 strlen2
= in_str2
.getLength();
96 unistr1
= in_str1
.getStr();
97 unistr2
= in_str2
.getStr();
99 while (strlen1
&& strlen2
)
101 sal_uInt32 ret
= *unistr1
- *unistr2
;
110 return strlen1
- strlen2
;
114 transliteration_commonclass::compareString( const OUString
& str1
, const OUString
& str2
) throw ( RuntimeException
)
116 return( this->compareSubstring(str1
, 0, str1
.getLength(), str2
, 0, str2
.getLength()));
120 transliteration_commonclass::transliterateString2String( const OUString
& inStr
, sal_Int32 startPos
, sal_Int32 nCount
) throw(RuntimeException
)
122 Sequence
< sal_Int32
> dummy_offset
;
123 useOffset
= sal_False
;
124 OUString tmpStr
= transliterate(inStr
, startPos
, nCount
, dummy_offset
);
125 useOffset
= sal_True
;
130 transliteration_commonclass::transliterateChar2String( sal_Unicode inChar
) throw(RuntimeException
)
132 return transliteration_commonclass::transliterateString2String(OUString(&inChar
, 1), 0, 1);
135 OUString SAL_CALL
transliteration_commonclass::getImplementationName() throw( RuntimeException
)
137 return OUString::createFromAscii(implementationName
);
140 const sal_Char cTrans
[] = "com.sun.star.i18n.Transliteration.l10n";
142 sal_Bool SAL_CALL
transliteration_commonclass::supportsService(const OUString
& rServiceName
) throw( RuntimeException
)
144 return rServiceName
.equalsAscii(cTrans
);
147 Sequence
< OUString
> SAL_CALL
transliteration_commonclass::getSupportedServiceNames() throw( RuntimeException
)
149 Sequence
< OUString
> aRet(1);
150 aRet
[0] = OUString::createFromAscii(cTrans
);
156 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */