1*f7bd9df4SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*f7bd9df4SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*f7bd9df4SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*f7bd9df4SAndrew Rist  * distributed with this work for additional information
6*f7bd9df4SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*f7bd9df4SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*f7bd9df4SAndrew Rist  * "License"); you may not use this file except in compliance
9*f7bd9df4SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*f7bd9df4SAndrew Rist  *
11*f7bd9df4SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*f7bd9df4SAndrew Rist  *
13*f7bd9df4SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*f7bd9df4SAndrew Rist  * software distributed under the License is distributed on an
15*f7bd9df4SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*f7bd9df4SAndrew Rist  * KIND, either express or implied.  See the License for the
17*f7bd9df4SAndrew Rist  * specific language governing permissions and limitations
18*f7bd9df4SAndrew Rist  * under the License.
19*f7bd9df4SAndrew Rist  *
20*f7bd9df4SAndrew Rist  *************************************************************/
21*f7bd9df4SAndrew Rist 
22*f7bd9df4SAndrew Rist 
23cdf0e10cSrcweir #ifndef _I18N_TRANSLITERATIONIMPL_HXX_
24cdf0e10cSrcweir #define _I18N_TRANSLITERATIONIMPL_HXX_
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include <com/sun/star/i18n/XLocaleData.hpp>
27cdf0e10cSrcweir #include <com/sun/star/i18n/XExtendedTransliteration.hpp>
28cdf0e10cSrcweir #include <cppuhelper/implbase2.hxx> // helper for implementations
29cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
30cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
31cdf0e10cSrcweir #include <sal/types.h>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir namespace com { namespace sun { namespace star { namespace i18n {
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
36cdf0e10cSrcweir #define RETURN_DEBUG_STRING (rtl::OUString::createFromAscii("return from transliterationImpl"));
37cdf0e10cSrcweir #define RETURN_DEBUG_NUMBER 'TRAN'
38cdf0e10cSrcweir #else
39cdf0e10cSrcweir #define RETURN_DEBUG_STRING
40cdf0e10cSrcweir #define RETURN_DEBUG_NUMBER
41cdf0e10cSrcweir #endif
42cdf0e10cSrcweir 
43cdf0e10cSrcweir class TransliterationImpl : public cppu::WeakImplHelper2
44cdf0e10cSrcweir <
45cdf0e10cSrcweir     com::sun::star::i18n::XExtendedTransliteration,
46cdf0e10cSrcweir     com::sun::star::lang::XServiceInfo
47cdf0e10cSrcweir >
48cdf0e10cSrcweir {
49cdf0e10cSrcweir public:
50cdf0e10cSrcweir     // Constructors
51cdf0e10cSrcweir     TransliterationImpl(const com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory >& xMSF);
52cdf0e10cSrcweir     // Destructor
53cdf0e10cSrcweir     ~TransliterationImpl();
54cdf0e10cSrcweir 
55cdf0e10cSrcweir     // Methods
56cdf0e10cSrcweir     virtual rtl::OUString SAL_CALL getName(  ) throw(com::sun::star::uno::RuntimeException) ;
57cdf0e10cSrcweir     virtual sal_Int16 SAL_CALL getType(  ) throw(com::sun::star::uno::RuntimeException) ;
58cdf0e10cSrcweir 
59cdf0e10cSrcweir     virtual void SAL_CALL loadModule( TransliterationModules modName, const com::sun::star::lang::Locale& rLocale )
60cdf0e10cSrcweir         throw(com::sun::star::uno::RuntimeException) ;
61cdf0e10cSrcweir     virtual void SAL_CALL loadModuleNew( const com::sun::star::uno::Sequence< TransliterationModulesNew >& modName,
62cdf0e10cSrcweir         const com::sun::star::lang::Locale& rLocale ) throw(com::sun::star::uno::RuntimeException) ;
63cdf0e10cSrcweir     virtual void SAL_CALL loadModuleByImplName( const rtl::OUString& implName,
64cdf0e10cSrcweir         const com::sun::star::lang::Locale& rLocale ) throw(com::sun::star::uno::RuntimeException);
65cdf0e10cSrcweir     virtual void SAL_CALL loadModulesByImplNames(const com::sun::star::uno::Sequence< rtl::OUString >& modNamelist,
66cdf0e10cSrcweir         const com::sun::star::lang::Locale& rLocale) throw(com::sun::star::uno::RuntimeException);
67cdf0e10cSrcweir 
68cdf0e10cSrcweir     virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getAvailableModules(
69cdf0e10cSrcweir         const com::sun::star::lang::Locale& rLocale, sal_Int16 sType )
70cdf0e10cSrcweir         throw(com::sun::star::uno::RuntimeException);
71cdf0e10cSrcweir 
72cdf0e10cSrcweir     virtual rtl::OUString SAL_CALL transliterate( const rtl::OUString& inStr, sal_Int32 startPos, sal_Int32 nCount,
73cdf0e10cSrcweir         com::sun::star::uno::Sequence< sal_Int32 >& offset  ) throw(com::sun::star::uno::RuntimeException) ;
74cdf0e10cSrcweir 
75cdf0e10cSrcweir     virtual rtl::OUString SAL_CALL folding( const rtl::OUString& inStr, sal_Int32 startPos, sal_Int32 nCount,
76cdf0e10cSrcweir         com::sun::star::uno::Sequence< sal_Int32 >& offset ) throw(com::sun::star::uno::RuntimeException);
77cdf0e10cSrcweir 
78cdf0e10cSrcweir     // Methods in XExtendedTransliteration
79cdf0e10cSrcweir     virtual rtl::OUString SAL_CALL transliterateString2String( const rtl::OUString& inStr, sal_Int32 startPos, sal_Int32 nCount )
80cdf0e10cSrcweir         throw(com::sun::star::uno::RuntimeException) ;
81cdf0e10cSrcweir     virtual rtl::OUString SAL_CALL transliterateChar2String( sal_Unicode inChar )
82cdf0e10cSrcweir         throw(com::sun::star::uno::RuntimeException) ;
83cdf0e10cSrcweir     virtual sal_Unicode SAL_CALL transliterateChar2Char( sal_Unicode inChar )
84cdf0e10cSrcweir         throw(com::sun::star::i18n::MultipleCharsOutputException,
85cdf0e10cSrcweir                 com::sun::star::uno::RuntimeException) ;
86cdf0e10cSrcweir 
87cdf0e10cSrcweir /*
88cdf0e10cSrcweir     virtual void SAL_CALL createCascadeInstance( const com::sun::star::uno::Sequence< rtl::OUString >& modNamelist,
89cdf0e10cSrcweir         const com::sun::star::lang::Locale& rLocale ) throw(com::sun::star::uno::RuntimeException) ;
90cdf0e10cSrcweir     virtual rtl::OUString SAL_CALL folding_reverse( const rtl::OUString& inStr, sal_Int32 startPos,
91cdf0e10cSrcweir         sal_Int32 nCount ) throw(com::sun::star::uno::RuntimeException);
92cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL transliterateMatch( const rtl::OUString& content, sal_Int32 pos1, sal_Int32 nCount1,
93cdf0e10cSrcweir         const rtl::OUString& pattern, sal_Int32 pos2, sal_Int32 nCount2 )
94cdf0e10cSrcweir         throw(com::sun::star::uno::RuntimeException);
95cdf0e10cSrcweir */
96cdf0e10cSrcweir     virtual sal_Bool SAL_CALL equals( const rtl::OUString& str1, sal_Int32 pos1, sal_Int32 nCount1,
97cdf0e10cSrcweir         sal_Int32& nMatch1, const rtl::OUString& str2, sal_Int32 pos2, sal_Int32 nCount2, sal_Int32& nMatch2 )
98cdf0e10cSrcweir         throw(com::sun::star::uno::RuntimeException);
99cdf0e10cSrcweir     virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL transliterateRange( const rtl::OUString& str1,
100cdf0e10cSrcweir         const rtl::OUString& str2 ) throw(com::sun::star::uno::RuntimeException) ;
101cdf0e10cSrcweir 
102cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL compareSubstring( const rtl::OUString& s1, sal_Int32 off1, sal_Int32 len1,
103cdf0e10cSrcweir         const rtl::OUString& s2, sal_Int32 off2, sal_Int32 len2) throw(com::sun::star::uno::RuntimeException);
104cdf0e10cSrcweir 
105cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL compareString( const rtl::OUString& s1, const rtl::OUString& s2)
106cdf0e10cSrcweir         throw(com::sun::star::uno::RuntimeException);
107cdf0e10cSrcweir 
108cdf0e10cSrcweir     //XServiceInfo
109cdf0e10cSrcweir     virtual rtl::OUString SAL_CALL getImplementationName(void) throw( com::sun::star::uno::RuntimeException );
110cdf0e10cSrcweir     virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName)
111cdf0e10cSrcweir         throw( com::sun::star::uno::RuntimeException );
112cdf0e10cSrcweir     virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void)
113cdf0e10cSrcweir         throw( com::sun::star::uno::RuntimeException );
114cdf0e10cSrcweir 
115cdf0e10cSrcweir private:
116cdf0e10cSrcweir #define maxCascade 27
117cdf0e10cSrcweir     com::sun::star::uno::Reference< com::sun::star::i18n::XExtendedTransliteration > bodyCascade[maxCascade];
118cdf0e10cSrcweir     sal_Int16 numCascade;
119cdf0e10cSrcweir     sal_Bool caseignoreOnly;
120cdf0e10cSrcweir     com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > xSMgr;
121cdf0e10cSrcweir     com::sun::star::uno::Reference< XLocaleData > localedata;
122cdf0e10cSrcweir     com::sun::star::uno::Reference< com::sun::star::i18n::XExtendedTransliteration > caseignore;
123cdf0e10cSrcweir 
124cdf0e10cSrcweir     virtual sal_Bool SAL_CALL loadModuleByName( const rtl::OUString& implName,
125cdf0e10cSrcweir         com::sun::star::uno::Reference<com::sun::star::i18n::XExtendedTransliteration> & body, const com::sun::star::lang::Locale& rLocale)
126cdf0e10cSrcweir         throw(com::sun::star::uno::RuntimeException);
127cdf0e10cSrcweir 
128cdf0e10cSrcweir     void clear();
129cdf0e10cSrcweir 
130cdf0e10cSrcweir     void loadBody( ::rtl::OUString &implName,
131cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XExtendedTransliteration >& body )
132cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
133cdf0e10cSrcweir 
134cdf0e10cSrcweir     com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getRange(
135cdf0e10cSrcweir         const com::sun::star::uno::Sequence< rtl::OUString > &inStrs,
136cdf0e10cSrcweir         sal_Int32 length, const sal_Int16 _nCascade)
137cdf0e10cSrcweir         throw(com::sun::star::uno::RuntimeException);
138cdf0e10cSrcweir };
139cdf0e10cSrcweir 
140cdf0e10cSrcweir } } } }
141cdf0e10cSrcweir 
142cdf0e10cSrcweir #endif
143