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