xref: /aoo4110/main/linguistic/source/thesdsp.hxx (revision b1cdbd2c)
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 _LINGUISTIC_THESDSP_HXX_
25 #define _LINGUISTIC_THESDSP_HXX_
26 
27 #include <com/sun/star/uno/Reference.h>
28 #include <com/sun/star/uno/Sequence.h>
29 #include <com/sun/star/beans/XPropertySet.hpp>
30 #include <com/sun/star/beans/XPropertyAccess.hpp>
31 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
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 
36 #include <com/sun/star/lang/XServiceInfo.hpp>
37 #include <com/sun/star/linguistic2/XThesaurus.hpp>
38 
39 #include <uno/lbnames.h>			// CPPU_CURRENT_LANGUAGE_BINDING_NAME macro, which specify the environment type
40 #include <cppuhelper/implbase1.hxx>	// helper for implementations
41 #include <cppuhelper/implbase5.hxx>	// helper for implementations
42 #include <cppuhelper/interfacecontainer.h>
43 
44 #include <vos/mutex.hxx>
45 
46 #include <boost/shared_ptr.hpp>
47 #include <map>
48 
49 #include "lngopt.hxx"
50 
51 
52 ///////////////////////////////////////////////////////////////////////////
53 
54 class ThesaurusDispatcher :
55 	public cppu::WeakImplHelper1
56 	<
57 		::com::sun::star::linguistic2::XThesaurus
58 	>,
59 	public LinguDispatcher
60 {
61     typedef boost::shared_ptr< LangSvcEntries_Thes >                LangSvcEntries_Thes_Ptr_t;
62     typedef std::map< LanguageType, LangSvcEntries_Thes_Ptr_t >     ThesSvcByLangMap_t;
63     ThesSvcByLangMap_t      aSvcMap;
64 
65 	::com::sun::star::uno::Reference<
66 		::com::sun::star::beans::XPropertySet >		xPropSet;
67 
68 	// disallow copy-constructor and assignment-operator for now
69 	ThesaurusDispatcher(const ThesaurusDispatcher &);
70 	ThesaurusDispatcher & operator = (const ThesaurusDispatcher &);
71 
72 	inline ::com::sun::star::uno::Reference<
73 		::com::sun::star::beans::XPropertySet >
74 			GetPropSet();
75 
76 	void 	ClearSvcList();
77 
78 public:
79 	ThesaurusDispatcher();
80 	virtual ~ThesaurusDispatcher();
81 
82 	// XSupportedLocales
83     virtual ::com::sun::star::uno::Sequence<
84 			::com::sun::star::lang::Locale > SAL_CALL
85 		getLocales()
86 			throw(::com::sun::star::uno::RuntimeException);
87     virtual sal_Bool SAL_CALL
88 		hasLocale( const ::com::sun::star::lang::Locale& aLocale )
89 			throw(::com::sun::star::uno::RuntimeException);
90 
91 	// XThesaurus
92     virtual ::com::sun::star::uno::Sequence<
93 			::com::sun::star::uno::Reference<
94 				::com::sun::star::linguistic2::XMeaning > > SAL_CALL
95 		queryMeanings( const ::rtl::OUString& aTerm,
96 				const ::com::sun::star::lang::Locale& aLocale,
97 				const ::com::sun::star::beans::PropertyValues& aProperties )
98 			throw(::com::sun::star::lang::IllegalArgumentException,
99 				  ::com::sun::star::uno::RuntimeException);
100 
101 	// LinguDispatcher
102 	virtual void
103 		SetServiceList( const ::com::sun::star::lang::Locale &rLocale,
104 				const ::com::sun::star::uno::Sequence<
105 					rtl::OUString > &rSvcImplNames );
106 	virtual ::com::sun::star::uno::Sequence< rtl::OUString >
107 		GetServiceList( const ::com::sun::star::lang::Locale &rLocale ) const;
108 	virtual DspType
109 		GetDspType() const;
110 };
111 
112 
113 inline ::com::sun::star::uno::Reference<
114 	::com::sun::star::beans::XPropertySet >
GetPropSet()115 		ThesaurusDispatcher::GetPropSet()
116 {
117 	return xPropSet.is() ?
118 		xPropSet : xPropSet = linguistic::GetLinguProperties();
119 }
120 
121 
122 ///////////////////////////////////////////////////////////////////////////
123 
124 #endif
125 
126