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 virtual sal_Bool SAL_CALL 87 hasLocale( const ::com::sun::star::lang::Locale& aLocale ); 88 89 // XThesaurus 90 virtual ::com::sun::star::uno::Sequence< 91 ::com::sun::star::uno::Reference< 92 ::com::sun::star::linguistic2::XMeaning > > SAL_CALL 93 queryMeanings( const ::rtl::OUString& aTerm, 94 const ::com::sun::star::lang::Locale& aLocale, 95 const ::com::sun::star::beans::PropertyValues& aProperties ); 96 97 // LinguDispatcher 98 virtual void 99 SetServiceList( const ::com::sun::star::lang::Locale &rLocale, 100 const ::com::sun::star::uno::Sequence< 101 rtl::OUString > &rSvcImplNames ); 102 virtual ::com::sun::star::uno::Sequence< rtl::OUString > 103 GetServiceList( const ::com::sun::star::lang::Locale &rLocale ) const; 104 virtual DspType 105 GetDspType() const; 106 }; 107 108 109 inline ::com::sun::star::uno::Reference< 110 ::com::sun::star::beans::XPropertySet > GetPropSet()111 ThesaurusDispatcher::GetPropSet() 112 { 113 return xPropSet.is() ? 114 xPropSet : xPropSet = linguistic::GetLinguProperties(); 115 } 116 117 118 /////////////////////////////////////////////////////////////////////////// 119 120 #endif 121