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     linguistic::PropertyHelper_Thesaurus*       pPropHelper;
85     sal_Bool                                    bDisposing;
86     CharClass **                            aCharSetInfo;
87     MyThes **                               aThes;
88     rtl_TextEncoding *                      aTEncs;
89     Locale *                                aTLocs;
90     OUString *                              aTNames;
91     sal_Int32                               numthes;
92 
93     // cache for the Thesaurus dialog
94     Sequence < Reference < ::com::sun::star::linguistic2::XMeaning > > prevMeanings;
95     OUString  prevTerm;
96     sal_Int16 prevLocale;
97 
98 	// disallow copy-constructor and assignment-operator for now
99 	Thesaurus(const Thesaurus &);
100 	Thesaurus & operator = (const Thesaurus &);
101 
102     linguistic::PropertyHelper_Thesaurus&   GetPropHelper_Impl();
GetPropHelper()103     linguistic::PropertyHelper_Thesaurus&   GetPropHelper()
104 	{
105 		return pPropHelper ? *pPropHelper : GetPropHelper_Impl();
106 	}
107 
108 
109 public:
110 	Thesaurus();
111 	virtual ~Thesaurus();
112 
113 	// XSupportedLocales (for XThesaurus)
114     virtual Sequence< Locale > SAL_CALL getLocales() throw(RuntimeException);
115     virtual sal_Bool SAL_CALL hasLocale( const Locale& rLocale ) throw(RuntimeException);
116 
117     // XThesaurus
118     virtual Sequence< Reference < ::com::sun::star::linguistic2::XMeaning > > SAL_CALL queryMeanings( const OUString& rTerm, const Locale& rLocale, const PropertyValues& rProperties ) throw(IllegalArgumentException, RuntimeException);
119 
120 	// XServiceDisplayName
121     virtual OUString SAL_CALL getServiceDisplayName( const Locale& rLocale ) throw(RuntimeException);
122 
123 	// XInitialization
124     virtual void SAL_CALL initialize( const Sequence< Any >& rArguments ) throw(Exception, RuntimeException);
125 
126 	// XComponent
127     virtual void SAL_CALL dispose() throw(RuntimeException);
128     virtual void SAL_CALL addEventListener( const Reference< XEventListener >& rxListener ) throw(RuntimeException);
129     virtual void SAL_CALL removeEventListener( const Reference< XEventListener >& rxListener ) throw(RuntimeException);
130 
131 	// XServiceInfo
132     virtual OUString SAL_CALL getImplementationName() throw(RuntimeException);
133     virtual sal_Bool SAL_CALL supportsService( const OUString& rServiceName ) throw(RuntimeException);
134     virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(RuntimeException);
135 
136 
137 	static inline OUString
138 		getImplementationName_Static() throw();
139         static Sequence< OUString >
140 		getSupportedServiceNames_Static() throw();
141 
142 private:
143         sal_uInt16 SAL_CALL capitalType(const OUString&, CharClass *);
144         OUString SAL_CALL makeLowerCase(const OUString&, CharClass *);
145         OUString SAL_CALL makeUpperCase(const OUString&, CharClass *);
146         OUString SAL_CALL makeInitCap(const OUString&, CharClass *);
147 
148 /*	static ::com::sun::star::uno::Reference<
149 		::com::sun::star::linguistic2::XLinguServiceManager > xLngSvcMgr;
150 	static ::com::sun::star::uno::Reference<
151 		::com::sun::star::linguistic2::XSpellChecker1 > xSpell;
152 */
153     static ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XLinguServiceManager > GetLngSvcMgr();
154 
155 };
156 
getImplementationName_Static()157 inline OUString Thesaurus::getImplementationName_Static() throw()
158 {
159 	return A2OU( "org.openoffice.lingu.new.Thesaurus" );
160 }
161 
162 
163 ///////////////////////////////////////////////////////////////////////////
164 
165 #endif
166