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: transliterationImpl.hxx,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 ************************************************************************/
30 #ifndef _I18N_TRANSLITERATIONIMPL_HXX_
31 #define _I18N_TRANSLITERATIONIMPL_HXX_
33 #include <com/sun/star/i18n/XLocaleData.hpp>
34 #include <com/sun/star/i18n/XExtendedTransliteration.hpp>
35 #include <cppuhelper/implbase2.hxx> // helper for implementations
36 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
37 #include <com/sun/star/lang/XServiceInfo.hpp>
38 #include <sal/types.h>
40 namespace com
{ namespace sun
{ namespace star
{ namespace i18n
{
42 #if OSL_DEBUG_LEVEL > 1
43 #define RETURN_DEBUG_STRING (rtl::OUString::createFromAscii("return from transliterationImpl"));
44 #define RETURN_DEBUG_NUMBER 'TRAN'
46 #define RETURN_DEBUG_STRING
47 #define RETURN_DEBUG_NUMBER
50 class TransliterationImpl
: public cppu::WeakImplHelper2
52 com::sun::star::i18n::XExtendedTransliteration
,
53 com::sun::star::lang::XServiceInfo
58 TransliterationImpl(const com::sun::star::uno::Reference
< com::sun::star::lang::XMultiServiceFactory
>& xMSF
);
60 ~TransliterationImpl();
63 virtual rtl::OUString SAL_CALL
getName( ) throw(com::sun::star::uno::RuntimeException
) ;
64 virtual sal_Int16 SAL_CALL
getType( ) throw(com::sun::star::uno::RuntimeException
) ;
66 virtual void SAL_CALL
loadModule( TransliterationModules modName
, const com::sun::star::lang::Locale
& rLocale
)
67 throw(com::sun::star::uno::RuntimeException
) ;
68 virtual void SAL_CALL
loadModuleNew( const com::sun::star::uno::Sequence
< TransliterationModulesNew
>& modName
,
69 const com::sun::star::lang::Locale
& rLocale
) throw(com::sun::star::uno::RuntimeException
) ;
70 virtual void SAL_CALL
loadModuleByImplName( const rtl::OUString
& implName
,
71 const com::sun::star::lang::Locale
& rLocale
) throw(com::sun::star::uno::RuntimeException
);
72 virtual void SAL_CALL
loadModulesByImplNames(const com::sun::star::uno::Sequence
< rtl::OUString
>& modNamelist
,
73 const com::sun::star::lang::Locale
& rLocale
) throw(com::sun::star::uno::RuntimeException
);
75 virtual com::sun::star::uno::Sequence
< rtl::OUString
> SAL_CALL
getAvailableModules(
76 const com::sun::star::lang::Locale
& rLocale
, sal_Int16 sType
)
77 throw(com::sun::star::uno::RuntimeException
);
79 virtual rtl::OUString SAL_CALL
transliterate( 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 virtual rtl::OUString SAL_CALL
folding( const rtl::OUString
& inStr
, sal_Int32 startPos
, sal_Int32 nCount
,
83 com::sun::star::uno::Sequence
< sal_Int32
>& offset
) throw(com::sun::star::uno::RuntimeException
);
85 // Methods in XExtendedTransliteration
86 virtual rtl::OUString SAL_CALL
transliterateString2String( const rtl::OUString
& inStr
, sal_Int32 startPos
, sal_Int32 nCount
)
87 throw(com::sun::star::uno::RuntimeException
) ;
88 virtual rtl::OUString SAL_CALL
transliterateChar2String( sal_Unicode inChar
)
89 throw(com::sun::star::uno::RuntimeException
) ;
90 virtual sal_Unicode SAL_CALL
transliterateChar2Char( sal_Unicode inChar
)
91 throw(com::sun::star::i18n::MultipleCharsOutputException
,
92 com::sun::star::uno::RuntimeException
) ;
95 virtual void SAL_CALL createCascadeInstance( const com::sun::star::uno::Sequence< rtl::OUString >& modNamelist,
96 const com::sun::star::lang::Locale& rLocale ) throw(com::sun::star::uno::RuntimeException) ;
97 virtual rtl::OUString SAL_CALL folding_reverse( const rtl::OUString& inStr, sal_Int32 startPos,
98 sal_Int32 nCount ) throw(com::sun::star::uno::RuntimeException);
99 virtual sal_Int32 SAL_CALL transliterateMatch( const rtl::OUString& content, sal_Int32 pos1, sal_Int32 nCount1,
100 const rtl::OUString& pattern, sal_Int32 pos2, sal_Int32 nCount2 )
101 throw(com::sun::star::uno::RuntimeException);
103 virtual sal_Bool SAL_CALL
equals( const rtl::OUString
& str1
, sal_Int32 pos1
, sal_Int32 nCount1
,
104 sal_Int32
& nMatch1
, const rtl::OUString
& str2
, sal_Int32 pos2
, sal_Int32 nCount2
, sal_Int32
& nMatch2
)
105 throw(com::sun::star::uno::RuntimeException
);
106 virtual com::sun::star::uno::Sequence
< rtl::OUString
> SAL_CALL
transliterateRange( const rtl::OUString
& str1
,
107 const rtl::OUString
& str2
) throw(com::sun::star::uno::RuntimeException
) ;
109 virtual sal_Int32 SAL_CALL
compareSubstring( const rtl::OUString
& s1
, sal_Int32 off1
, sal_Int32 len1
,
110 const rtl::OUString
& s2
, sal_Int32 off2
, sal_Int32 len2
) throw(com::sun::star::uno::RuntimeException
);
112 virtual sal_Int32 SAL_CALL
compareString( const rtl::OUString
& s1
, const rtl::OUString
& s2
)
113 throw(com::sun::star::uno::RuntimeException
);
116 virtual rtl::OUString SAL_CALL
getImplementationName(void) throw( com::sun::star::uno::RuntimeException
);
117 virtual sal_Bool SAL_CALL
supportsService(const rtl::OUString
& ServiceName
)
118 throw( com::sun::star::uno::RuntimeException
);
119 virtual com::sun::star::uno::Sequence
< rtl::OUString
> SAL_CALL
getSupportedServiceNames(void)
120 throw( com::sun::star::uno::RuntimeException
);
123 #define maxCascade 27
124 com::sun::star::uno::Reference
< com::sun::star::i18n::XExtendedTransliteration
> bodyCascade
[maxCascade
];
125 sal_Int16 numCascade
;
126 sal_Bool caseignoreOnly
;
127 com::sun::star::uno::Reference
< com::sun::star::lang::XMultiServiceFactory
> xSMgr
;
128 com::sun::star::uno::Reference
< XLocaleData
> localedata
;
129 com::sun::star::uno::Reference
< com::sun::star::i18n::XExtendedTransliteration
> caseignore
;
131 /** structure to cache the last transliteration body used. */
135 ::rtl::OUString Name
;
136 ::com::sun::star::uno::Reference
< ::com::sun::star::i18n::XExtendedTransliteration
> Body
;
138 static TransBody lastTransBody
;
140 virtual sal_Bool SAL_CALL
loadModuleByName( const rtl::OUString
& implName
,
141 com::sun::star::uno::Reference
<com::sun::star::i18n::XExtendedTransliteration
> & body
, const com::sun::star::lang::Locale
& rLocale
)
142 throw(com::sun::star::uno::RuntimeException
);
146 void loadBody( ::rtl::OUString
&implName
,
147 ::com::sun::star::uno::Reference
< ::com::sun::star::i18n::XExtendedTransliteration
>& body
)
148 throw (::com::sun::star::uno::RuntimeException
);
150 com::sun::star::uno::Sequence
< rtl::OUString
> SAL_CALL
getRange(
151 const com::sun::star::uno::Sequence
< rtl::OUString
> &inStrs
,
152 sal_Int32 length
, const sal_Int16 _nCascade
)
153 throw(com::sun::star::uno::RuntimeException
);