1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_i18npool.hxx" 30 31 #include <transliteration_commonclass.hxx> 32 #include <com/sun/star/i18n/CollatorOptions.hpp> 33 34 using namespace ::com::sun::star::uno; 35 using namespace ::com::sun::star::lang; 36 using namespace ::rtl; 37 38 namespace com { namespace sun { namespace star { namespace i18n { 39 40 transliteration_commonclass::transliteration_commonclass() 41 { 42 transliterationName = ""; 43 implementationName = ""; 44 useOffset = sal_True; 45 } 46 47 OUString SAL_CALL transliteration_commonclass::getName() throw(RuntimeException) 48 { 49 return OUString::createFromAscii(transliterationName); 50 } 51 52 void SAL_CALL transliteration_commonclass::loadModule( TransliterationModules /*modName*/, const Locale& rLocale ) 53 throw(RuntimeException) 54 { 55 aLocale = rLocale; 56 } 57 58 59 void SAL_CALL 60 transliteration_commonclass::loadModuleNew( const Sequence < TransliterationModulesNew >& /*modName*/, const Locale& /*rLocale*/ ) 61 throw(RuntimeException) 62 { 63 throw RuntimeException(); 64 } 65 66 67 void SAL_CALL 68 transliteration_commonclass::loadModuleByImplName( const OUString& /*implName*/, const Locale& /*rLocale*/ ) 69 throw(RuntimeException) 70 { 71 throw RuntimeException(); 72 } 73 74 void SAL_CALL 75 transliteration_commonclass::loadModulesByImplNames(const Sequence< OUString >& /*modNamelist*/, const Locale& /*rLocale*/) 76 throw(RuntimeException) 77 { 78 throw RuntimeException(); 79 } 80 81 Sequence< OUString > SAL_CALL 82 transliteration_commonclass::getAvailableModules( const Locale& /*rLocale*/, sal_Int16 /*sType*/ ) 83 throw(RuntimeException) 84 { 85 throw RuntimeException(); 86 } 87 88 sal_Int32 SAL_CALL 89 transliteration_commonclass::compareSubstring( 90 const OUString& str1, sal_Int32 off1, sal_Int32 len1, 91 const OUString& str2, sal_Int32 off2, sal_Int32 len2) 92 throw(RuntimeException) 93 { 94 const sal_Unicode* unistr1 = NULL; 95 const sal_Unicode* unistr2 = NULL; 96 sal_uInt32 strlen1; 97 sal_uInt32 strlen2; 98 99 Sequence <sal_Int32> offset1(2*len1); 100 Sequence <sal_Int32> offset2(2*len2); 101 102 OUString in_str1 = this->transliterate(str1, off1, len1, offset1); 103 OUString in_str2 = this->transliterate(str2, off2, len2, offset2); 104 strlen1 = in_str1.getLength(); 105 strlen2 = in_str2.getLength(); 106 unistr1 = in_str1.getStr(); 107 unistr2 = in_str2.getStr(); 108 109 while (strlen1 && strlen2) 110 { 111 sal_uInt32 ret = *unistr1 - *unistr2; 112 if (ret) 113 return ret; 114 115 unistr1++; 116 unistr2++; 117 strlen1--; 118 strlen2--; 119 } 120 return strlen1 - strlen2; 121 } 122 123 sal_Int32 SAL_CALL 124 transliteration_commonclass::compareString( const OUString& str1, const OUString& str2 ) throw ( RuntimeException) 125 { 126 return( this->compareSubstring(str1, 0, str1.getLength(), str2, 0, str2.getLength())); 127 } 128 129 OUString SAL_CALL 130 transliteration_commonclass::transliterateString2String( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount ) throw(RuntimeException) 131 { 132 static Sequence < sal_Int32 > dummy_offset; 133 useOffset = sal_False; 134 OUString tmpStr = transliterate(inStr, startPos, nCount, dummy_offset); 135 useOffset = sal_True; 136 return tmpStr; 137 } 138 139 OUString SAL_CALL 140 transliteration_commonclass::transliterateChar2String( sal_Unicode inChar ) throw(RuntimeException) 141 { 142 return transliteration_commonclass::transliterateString2String(OUString(&inChar, 1), 0, 1); 143 } 144 145 OUString SAL_CALL transliteration_commonclass::getImplementationName() throw( RuntimeException ) 146 { 147 return OUString::createFromAscii(implementationName); 148 } 149 150 const sal_Char cTrans[] = "com.sun.star.i18n.Transliteration.l10n"; 151 152 sal_Bool SAL_CALL transliteration_commonclass::supportsService(const OUString& rServiceName) throw( RuntimeException ) 153 { 154 return rServiceName.equalsAscii(cTrans); 155 } 156 157 Sequence< OUString > SAL_CALL transliteration_commonclass::getSupportedServiceNames() throw( RuntimeException ) 158 { 159 Sequence< OUString > aRet(1); 160 aRet[0] = OUString::createFromAscii(cTrans); 161 return aRet; 162 } 163 164 } } } } 165