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 #ifndef _LINGU2_THESIMP_HXX_
25 #define _LINGU2_THESIMP_HXX_
26
27 #include <uno/lbnames.h> // CPPU_CURRENT_LANGUAGE_BINDING_NAME macro, which specify the environment type
28 #include <cppuhelper/implbase1.hxx> // helper for implementations
29 #include <cppuhelper/implbase5.hxx> // helper for implementations
30 #include <com/sun/star/uno/Reference.h>
31 #include <com/sun/star/uno/Sequence.h>
32 #include <com/sun/star/lang/XComponent.hpp>
33 #include <com/sun/star/lang/XInitialization.hpp>
34 #include <com/sun/star/lang/XServiceDisplayName.hpp>
35 #include <com/sun/star/beans/XPropertySet.hpp>
36 #include <com/sun/star/beans/PropertyValues.hpp>
37
38 #include <com/sun/star/lang/XServiceInfo.hpp>
39 #include <com/sun/star/linguistic2/XMeaning.hpp>
40 #include <com/sun/star/linguistic2/XThesaurus.hpp>
41
42 #include <com/sun/star/linguistic2/XLinguServiceManager.hpp>
43 #include <com/sun/star/linguistic2/XSpellChecker1.hpp>
44
45 #include <tools/table.hxx>
46
47 #include <unotools/charclass.hxx>
48
49 #include <lingutil.hxx>
50 #include <linguistic/misc.hxx>
51 #include <linguistic/lngprophelp.hxx>
52
53 #include <osl/file.hxx>
54 #include "mythes.hxx"
55
56 using namespace ::rtl;
57 using namespace ::com::sun::star::uno;
58 using namespace ::com::sun::star::beans;
59 using namespace ::com::sun::star::lang;
60 using namespace ::com::sun::star::linguistic2;
61
62 namespace com { namespace sun { namespace star { namespace beans {
63 class XPropertySet;
64 }}}}
65
66
67
68 ///////////////////////////////////////////////////////////////////////////
69
70
71 class Thesaurus :
72 public cppu::WeakImplHelper5
73 <
74 XThesaurus,
75 XInitialization,
76 XComponent,
77 XServiceInfo,
78 XServiceDisplayName
79 >
80 {
81 Sequence< Locale > aSuppLocales;
82
83 ::cppu::OInterfaceContainerHelper aEvtListeners;
84 Reference< XPropertyChangeListener > xPropHelper;
85 linguistic::PropertyHelper_Thes * pPropHelper;
86 sal_Bool bDisposing;
87 CharClass ** aCharSetInfo;
88 MyThes ** aThes;
89 rtl_TextEncoding * aTEncs;
90 Locale * aTLocs;
91 OUString * aTNames;
92 sal_Int32 numthes;
93
94 // cache for the Thesaurus dialog
95 Sequence < Reference < ::com::sun::star::linguistic2::XMeaning > > prevMeanings;
96 OUString prevTerm;
97 sal_Int16 prevLocale;
98
99 // disallow copy-constructor and assignment-operator for now
100 Thesaurus(const Thesaurus &);
101 Thesaurus & operator = (const Thesaurus &);
102
103 linguistic::PropertyHelper_Thes & GetPropHelper_Impl();
GetPropHelper()104 linguistic::PropertyHelper_Thes & GetPropHelper()
105 {
106 return pPropHelper ? *pPropHelper : GetPropHelper_Impl();
107 }
108
109
110 public:
111 Thesaurus();
112 virtual ~Thesaurus();
113
114 // XSupportedLocales (for XThesaurus)
115 virtual Sequence< Locale > SAL_CALL getLocales() throw(RuntimeException);
116 virtual sal_Bool SAL_CALL hasLocale( const Locale& rLocale ) throw(RuntimeException);
117
118 // XThesaurus
119 virtual Sequence< Reference < ::com::sun::star::linguistic2::XMeaning > > SAL_CALL queryMeanings( const OUString& rTerm, const Locale& rLocale, const PropertyValues& rProperties ) throw(IllegalArgumentException, RuntimeException);
120
121 // XServiceDisplayName
122 virtual OUString SAL_CALL getServiceDisplayName( const Locale& rLocale ) throw(RuntimeException);
123
124 // XInitialization
125 virtual void SAL_CALL initialize( const Sequence< Any >& rArguments ) throw(Exception, RuntimeException);
126
127 // XComponent
128 virtual void SAL_CALL dispose() throw(RuntimeException);
129 virtual void SAL_CALL addEventListener( const Reference< XEventListener >& rxListener ) throw(RuntimeException);
130 virtual void SAL_CALL removeEventListener( const Reference< XEventListener >& rxListener ) throw(RuntimeException);
131
132 // XServiceInfo
133 virtual OUString SAL_CALL getImplementationName() throw(RuntimeException);
134 virtual sal_Bool SAL_CALL supportsService( const OUString& rServiceName ) throw(RuntimeException);
135 virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(RuntimeException);
136
137
138 static inline OUString
139 getImplementationName_Static() throw();
140 static Sequence< OUString >
141 getSupportedServiceNames_Static() throw();
142
143 private:
144 sal_uInt16 SAL_CALL capitalType(const OUString&, CharClass *);
145 OUString SAL_CALL makeLowerCase(const OUString&, CharClass *);
146 OUString SAL_CALL makeUpperCase(const OUString&, CharClass *);
147 OUString SAL_CALL makeInitCap(const OUString&, CharClass *);
148
149 /* static ::com::sun::star::uno::Reference<
150 ::com::sun::star::linguistic2::XLinguServiceManager > xLngSvcMgr;
151 static ::com::sun::star::uno::Reference<
152 ::com::sun::star::linguistic2::XSpellChecker1 > xSpell;
153 */
154 static ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XLinguServiceManager > GetLngSvcMgr();
155
156 };
157
getImplementationName_Static()158 inline OUString Thesaurus::getImplementationName_Static() throw()
159 {
160 return A2OU( "org.openoffice.lingu.new.Thesaurus" );
161 }
162
163
164 ///////////////////////////////////////////////////////////////////////////
165
166 #endif
167