1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
27 #ifndef _I18N_TRANSLITERATIONIMPL_HXX_
28 #define _I18N_TRANSLITERATIONIMPL_HXX_
30 #include <com/sun/star/i18n/XLocaleData.hpp>
31 #include <com/sun/star/i18n/XExtendedTransliteration.hpp>
32 #include <cppuhelper/implbase2.hxx> // helper for implementations
33 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
34 #include <com/sun/star/lang/XServiceInfo.hpp>
35 #include <sal/types.h>
37 namespace com
{ namespace sun
{ namespace star
{ namespace i18n
{
39 #if OSL_DEBUG_LEVEL > 1
40 #define RETURN_DEBUG_STRING (rtl::OUString::createFromAscii("return from transliterationImpl"));
41 #define RETURN_DEBUG_NUMBER 'TRAN'
43 #define RETURN_DEBUG_STRING
44 #define RETURN_DEBUG_NUMBER
47 class TransliterationImpl
: public cppu::WeakImplHelper2
49 com::sun::star::i18n::XExtendedTransliteration
,
50 com::sun::star::lang::XServiceInfo
55 TransliterationImpl(const com::sun::star::uno::Reference
< com::sun::star::lang::XMultiServiceFactory
>& xMSF
);
57 ~TransliterationImpl();
60 virtual rtl::OUString SAL_CALL
getName( ) throw(com::sun::star::uno::RuntimeException
) ;
61 virtual sal_Int16 SAL_CALL
getType( ) throw(com::sun::star::uno::RuntimeException
) ;
63 virtual void SAL_CALL
loadModule( TransliterationModules modName
, const com::sun::star::lang::Locale
& rLocale
)
64 throw(com::sun::star::uno::RuntimeException
) ;
65 virtual void SAL_CALL
loadModuleNew( const com::sun::star::uno::Sequence
< TransliterationModulesNew
>& modName
,
66 const com::sun::star::lang::Locale
& rLocale
) throw(com::sun::star::uno::RuntimeException
) ;
67 virtual void SAL_CALL
loadModuleByImplName( const rtl::OUString
& implName
,
68 const com::sun::star::lang::Locale
& rLocale
) throw(com::sun::star::uno::RuntimeException
);
69 virtual void SAL_CALL
loadModulesByImplNames(const com::sun::star::uno::Sequence
< rtl::OUString
>& modNamelist
,
70 const com::sun::star::lang::Locale
& rLocale
) throw(com::sun::star::uno::RuntimeException
);
72 virtual com::sun::star::uno::Sequence
< rtl::OUString
> SAL_CALL
getAvailableModules(
73 const com::sun::star::lang::Locale
& rLocale
, sal_Int16 sType
)
74 throw(com::sun::star::uno::RuntimeException
);
76 virtual rtl::OUString SAL_CALL
transliterate( const rtl::OUString
& inStr
, sal_Int32 startPos
, sal_Int32 nCount
,
77 com::sun::star::uno::Sequence
< sal_Int32
>& offset
) throw(com::sun::star::uno::RuntimeException
) ;
79 virtual rtl::OUString SAL_CALL
folding( const rtl::OUString
& inStr
, sal_Int32 startPos
, sal_Int32 nCount
,
80 com::sun::star::uno::Sequence
< sal_Int32
>& offset
) throw(com::sun::star::uno::RuntimeException
);
82 // Methods in XExtendedTransliteration
83 virtual rtl::OUString SAL_CALL
transliterateString2String( const rtl::OUString
& inStr
, sal_Int32 startPos
, sal_Int32 nCount
)
84 throw(com::sun::star::uno::RuntimeException
) ;
85 virtual rtl::OUString SAL_CALL
transliterateChar2String( sal_Unicode inChar
)
86 throw(com::sun::star::uno::RuntimeException
) ;
87 virtual sal_Unicode SAL_CALL
transliterateChar2Char( sal_Unicode inChar
)
88 throw(com::sun::star::i18n::MultipleCharsOutputException
,
89 com::sun::star::uno::RuntimeException
) ;
92 virtual void SAL_CALL createCascadeInstance( const com::sun::star::uno::Sequence< rtl::OUString >& modNamelist,
93 const com::sun::star::lang::Locale& rLocale ) throw(com::sun::star::uno::RuntimeException) ;
94 virtual rtl::OUString SAL_CALL folding_reverse( const rtl::OUString& inStr, sal_Int32 startPos,
95 sal_Int32 nCount ) throw(com::sun::star::uno::RuntimeException);
96 virtual sal_Int32 SAL_CALL transliterateMatch( const rtl::OUString& content, sal_Int32 pos1, sal_Int32 nCount1,
97 const rtl::OUString& pattern, sal_Int32 pos2, sal_Int32 nCount2 )
98 throw(com::sun::star::uno::RuntimeException);
100 virtual sal_Bool SAL_CALL
equals( const rtl::OUString
& str1
, sal_Int32 pos1
, sal_Int32 nCount1
,
101 sal_Int32
& nMatch1
, const rtl::OUString
& str2
, sal_Int32 pos2
, sal_Int32 nCount2
, sal_Int32
& nMatch2
)
102 throw(com::sun::star::uno::RuntimeException
);
103 virtual com::sun::star::uno::Sequence
< rtl::OUString
> SAL_CALL
transliterateRange( const rtl::OUString
& str1
,
104 const rtl::OUString
& str2
) throw(com::sun::star::uno::RuntimeException
) ;
106 virtual sal_Int32 SAL_CALL
compareSubstring( const rtl::OUString
& s1
, sal_Int32 off1
, sal_Int32 len1
,
107 const rtl::OUString
& s2
, sal_Int32 off2
, sal_Int32 len2
) throw(com::sun::star::uno::RuntimeException
);
109 virtual sal_Int32 SAL_CALL
compareString( const rtl::OUString
& s1
, const rtl::OUString
& s2
)
110 throw(com::sun::star::uno::RuntimeException
);
113 virtual rtl::OUString SAL_CALL
getImplementationName(void) throw( com::sun::star::uno::RuntimeException
);
114 virtual sal_Bool SAL_CALL
supportsService(const rtl::OUString
& ServiceName
)
115 throw( com::sun::star::uno::RuntimeException
);
116 virtual com::sun::star::uno::Sequence
< rtl::OUString
> SAL_CALL
getSupportedServiceNames(void)
117 throw( com::sun::star::uno::RuntimeException
);
120 #define maxCascade 27
121 com::sun::star::uno::Reference
< com::sun::star::i18n::XExtendedTransliteration
> bodyCascade
[maxCascade
];
122 sal_Int16 numCascade
;
123 sal_Bool caseignoreOnly
;
124 com::sun::star::uno::Reference
< com::sun::star::lang::XMultiServiceFactory
> xSMgr
;
125 com::sun::star::uno::Reference
< XLocaleData
> localedata
;
126 com::sun::star::uno::Reference
< com::sun::star::i18n::XExtendedTransliteration
> caseignore
;
128 /** structure to cache the last transliteration body used. */
132 ::rtl::OUString Name
;
133 ::com::sun::star::uno::Reference
< ::com::sun::star::i18n::XExtendedTransliteration
> Body
;
135 static TransBody lastTransBody
;
137 virtual sal_Bool SAL_CALL
loadModuleByName( const rtl::OUString
& implName
,
138 com::sun::star::uno::Reference
<com::sun::star::i18n::XExtendedTransliteration
> & body
, const com::sun::star::lang::Locale
& rLocale
)
139 throw(com::sun::star::uno::RuntimeException
);
143 void loadBody( ::rtl::OUString
&implName
,
144 ::com::sun::star::uno::Reference
< ::com::sun::star::i18n::XExtendedTransliteration
>& body
)
145 throw (::com::sun::star::uno::RuntimeException
);
147 com::sun::star::uno::Sequence
< rtl::OUString
> SAL_CALL
getRange(
148 const com::sun::star::uno::Sequence
< rtl::OUString
> &inStrs
,
149 sal_Int32 length
, const sal_Int16 _nCascade
)
150 throw(com::sun::star::uno::RuntimeException
);