1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: transliteration_commonclass.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_i18npool.hxx"
34 #include <transliteration_commonclass.hxx>
35 #include <com/sun/star/i18n/CollatorOptions.hpp>
37 using namespace ::com::sun::star::uno
;
38 using namespace ::com::sun::star::lang
;
39 using namespace ::rtl
;
41 namespace com
{ namespace sun
{ namespace star
{ namespace i18n
{
43 transliteration_commonclass::transliteration_commonclass()
45 transliterationName
= "";
46 implementationName
= "";
50 OUString SAL_CALL
transliteration_commonclass::getName() throw(RuntimeException
)
52 return OUString::createFromAscii(transliterationName
);
55 void SAL_CALL
transliteration_commonclass::loadModule( TransliterationModules
/*modName*/, const Locale
& rLocale
)
56 throw(RuntimeException
)
63 transliteration_commonclass::loadModuleNew( const Sequence
< TransliterationModulesNew
>& /*modName*/, const Locale
& /*rLocale*/ )
64 throw(RuntimeException
)
66 throw RuntimeException();
71 transliteration_commonclass::loadModuleByImplName( const OUString
& /*implName*/, const Locale
& /*rLocale*/ )
72 throw(RuntimeException
)
74 throw RuntimeException();
78 transliteration_commonclass::loadModulesByImplNames(const Sequence
< OUString
>& /*modNamelist*/, const Locale
& /*rLocale*/)
79 throw(RuntimeException
)
81 throw RuntimeException();
84 Sequence
< OUString
> SAL_CALL
85 transliteration_commonclass::getAvailableModules( const Locale
& /*rLocale*/, sal_Int16
/*sType*/ )
86 throw(RuntimeException
)
88 throw RuntimeException();
92 transliteration_commonclass::compareSubstring(
93 const OUString
& str1
, sal_Int32 off1
, sal_Int32 len1
,
94 const OUString
& str2
, sal_Int32 off2
, sal_Int32 len2
)
95 throw(RuntimeException
)
97 const sal_Unicode
* unistr1
= NULL
;
98 const sal_Unicode
* unistr2
= NULL
;
102 Sequence
<sal_Int32
> offset1(2*len1
);
103 Sequence
<sal_Int32
> offset2(2*len2
);
105 OUString in_str1
= this->transliterate(str1
, off1
, len1
, offset1
);
106 OUString in_str2
= this->transliterate(str2
, off2
, len2
, offset2
);
107 strlen1
= in_str1
.getLength();
108 strlen2
= in_str2
.getLength();
109 unistr1
= in_str1
.getStr();
110 unistr2
= in_str2
.getStr();
112 while (strlen1
&& strlen2
)
114 sal_uInt32 ret
= *unistr1
- *unistr2
;
123 return strlen1
- strlen2
;
127 transliteration_commonclass::compareString( const OUString
& str1
, const OUString
& str2
) throw ( RuntimeException
)
129 return( this->compareSubstring(str1
, 0, str1
.getLength(), str2
, 0, str2
.getLength()));
133 transliteration_commonclass::transliterateString2String( const OUString
& inStr
, sal_Int32 startPos
, sal_Int32 nCount
) throw(RuntimeException
)
135 static Sequence
< sal_Int32
> dummy_offset
;
136 useOffset
= sal_False
;
137 OUString tmpStr
= transliterate(inStr
, startPos
, nCount
, dummy_offset
);
138 useOffset
= sal_True
;
143 transliteration_commonclass::transliterateChar2String( sal_Unicode inChar
) throw(RuntimeException
)
145 return transliteration_commonclass::transliterateString2String(OUString(&inChar
, 1), 0, 1);
148 OUString SAL_CALL
transliteration_commonclass::getImplementationName() throw( RuntimeException
)
150 return OUString::createFromAscii(implementationName
);
153 const sal_Char cTrans
[] = "com.sun.star.i18n.Transliteration.l10n";
155 sal_Bool SAL_CALL
transliteration_commonclass::supportsService(const OUString
& rServiceName
) throw( RuntimeException
)
157 return rServiceName
.equalsAscii(cTrans
);
160 Sequence
< OUString
> SAL_CALL
transliteration_commonclass::getSupportedServiceNames() throw( RuntimeException
)
162 Sequence
< OUString
> aRet(1);
163 aRet
[0] = OUString::createFromAscii(cTrans
);