1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24
25 #ifndef _LINGU2_HYPHENIMP_HXX_
26 #define _LINGU2_HYPHENIMP_HXX_
27
28 #include <uno/lbnames.h> // CPPU_CURRENT_LANGUAGE_BINDING_NAME macro, which specify the environment type
29 #include <cppuhelper/implbase1.hxx> // helper for implementations
30 #include <cppuhelper/implbase6.hxx> // helper for implementations
31 #include <com/sun/star/lang/XComponent.hpp>
32 #include <com/sun/star/lang/XInitialization.hpp>
33 #include <com/sun/star/lang/XServiceDisplayName.hpp>
34 #include <com/sun/star/beans/XPropertySet.hpp>
35 #include <com/sun/star/beans/PropertyValues.hpp>
36 #include <com/sun/star/lang/XServiceInfo.hpp>
37 #include <com/sun/star/linguistic2/XHyphenator.hpp>
38 #include <com/sun/star/linguistic2/XSearchableDictionaryList.hpp>
39 #include <com/sun/star/linguistic2/XLinguServiceEventBroadcaster.hpp>
40 #include <tools/table.hxx>
41
42 #include <unotools/charclass.hxx>
43
44 #include <linguistic/misc.hxx>
45 #include <linguistic/lngprophelp.hxx>
46
47 #include <lingutil.hxx>
48 #include <stdio.h>
49
50 using namespace ::rtl;
51 using namespace ::com::sun::star::uno;
52 using namespace ::com::sun::star::beans;
53 using namespace ::com::sun::star::lang;
54 using namespace ::com::sun::star::linguistic2;
55
56
57 ///////////////////////////////////////////////////////////////////////////
58
59
60 struct HDInfo {
61 HyphenDict * aPtr;
62 OUString aName;
63 Locale aLoc;
64 rtl_TextEncoding eEnc;
65 CharClass * apCC;
66 };
67
68
69
70 class Hyphenator :
71 public cppu::WeakImplHelper6
72 <
73 XHyphenator,
74 XLinguServiceEventBroadcaster,
75 XInitialization,
76 XComponent,
77 XServiceInfo,
78 XServiceDisplayName
79 >
80 {
81 Sequence< Locale > aSuppLocales;
82 HDInfo * aDicts;
83 sal_Int32 numdict;
84
85 ::cppu::OInterfaceContainerHelper aEvtListeners;
86 Reference< XPropertyChangeListener > xPropHelper;
87 Reference< XMultiServiceFactory > rSMgr;
88 linguistic::PropertyHelper_Hyphen * pPropHelper;
89 sal_Bool bDisposing;
90
91 // disallow copy-constructor and assignment-operator for now
92 Hyphenator(const Hyphenator &);
93 Hyphenator & operator = (const Hyphenator &);
94
95 linguistic::PropertyHelper_Hyphen & GetPropHelper_Impl();
GetPropHelper()96 linguistic::PropertyHelper_Hyphen & GetPropHelper()
97 {
98 return pPropHelper ? *pPropHelper : GetPropHelper_Impl();
99 }
100
101 public:
102 Hyphenator();
103
104 virtual ~Hyphenator();
105
106 // XSupportedLocales (for XHyphenator)
107 virtual Sequence< Locale > SAL_CALL getLocales() throw(RuntimeException);
108 virtual sal_Bool SAL_CALL hasLocale( const Locale& rLocale ) throw(RuntimeException);
109
110 // XHyphenator
111 virtual ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XHyphenatedWord > SAL_CALL hyphenate( const ::rtl::OUString& aWord, const ::com::sun::star::lang::Locale& aLocale, sal_Int16 nMaxLeading, const ::com::sun::star::beans::PropertyValues& aProperties ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
112 virtual ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XHyphenatedWord > SAL_CALL queryAlternativeSpelling( const ::rtl::OUString& aWord, const ::com::sun::star::lang::Locale& aLocale, sal_Int16 nIndex, const ::com::sun::star::beans::PropertyValues& aProperties ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
113 virtual ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XPossibleHyphens > SAL_CALL createPossibleHyphens( const ::rtl::OUString& aWord, const ::com::sun::star::lang::Locale& aLocale, const ::com::sun::star::beans::PropertyValues& aProperties ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
114
115 // XLinguServiceEventBroadcaster
116 virtual sal_Bool SAL_CALL addLinguServiceEventListener( const Reference< XLinguServiceEventListener >& rxLstnr ) throw(RuntimeException);
117 virtual sal_Bool SAL_CALL removeLinguServiceEventListener( const Reference< XLinguServiceEventListener >& rxLstnr ) throw(RuntimeException);
118
119 // XServiceDisplayName
120 virtual OUString SAL_CALL getServiceDisplayName( const Locale& rLocale ) throw(RuntimeException);
121
122 // XInitialization
123 virtual void SAL_CALL initialize( const Sequence< Any >& rArguments ) throw(Exception, RuntimeException);
124
125 // XComponent
126 virtual void SAL_CALL dispose() throw(RuntimeException);
127 virtual void SAL_CALL addEventListener( const Reference< XEventListener >& rxListener ) throw(RuntimeException);
128 virtual void SAL_CALL removeEventListener( const Reference< XEventListener >& rxListener ) throw(RuntimeException);
129
130 // XServiceInfo
131 virtual OUString SAL_CALL getImplementationName() throw(RuntimeException);
132 virtual sal_Bool SAL_CALL supportsService( const OUString& rServiceName ) throw(RuntimeException);
133 virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(RuntimeException);
134
135
136 static inline OUString getImplementationName_Static() throw();
137 static Sequence< OUString > getSupportedServiceNames_Static() throw();
138
139
140 private:
141 sal_uInt16 SAL_CALL capitalType(const OUString&, CharClass *);
142 OUString SAL_CALL makeLowerCase(const OUString&, CharClass *);
143 OUString SAL_CALL makeUpperCase(const OUString&, CharClass *);
144 OUString SAL_CALL makeInitCap(const OUString&, CharClass *);
145 };
146
getImplementationName_Static()147 inline OUString Hyphenator::getImplementationName_Static() throw()
148 {
149 return A2OU( "org.openoffice.lingu.LibHnjHyphenator" );
150 }
151
152
153 ///////////////////////////////////////////////////////////////////////////
154
155 #endif
156
157