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