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_LNGOPT_HHX_ 29 #define _LINGUISTIC_LNGOPT_HHX_ 30 31 #include <functional> 32 33 #include <uno/lbnames.h> // CPPU_CURRENT_LANGUAGE_BINDING_NAME macro, which specify the environment type 34 #include <cppuhelper/implbase5.hxx> // helper for implementations 35 #include <cppuhelper/interfacecontainer.hxx> 36 #include <com/sun/star/beans/XPropertySet.hpp> 37 #include <com/sun/star/beans/XFastPropertySet.hpp> 38 #include <com/sun/star/lang/XServiceInfo.hpp> 39 #include <com/sun/star/beans/XPropertyAccess.hpp> 40 #include <com/sun/star/lang/XComponent.hpp> 41 #include <unotools/lingucfg.hxx> 42 #include <svl/itemprop.hxx> 43 #include <unotools/configitem.hxx> 44 #include <com/sun/star/uno/Any.h> 45 #include <tools/solar.h> 46 47 #include <svl/itemprop.hxx> 48 #include "linguistic/misc.hxx" 49 #include "defs.hxx" 50 #include <vos/refernce.hxx> 51 52 namespace com { namespace sun { namespace star { 53 namespace beans { 54 struct PropertyChangeEvent; 55 } 56 namespace registry { 57 class XRegistryKey; 58 } 59 }}} 60 61 62 63 /////////////////////////////////////////////////////////////////////////// 64 // LinguOptions 65 // This class represents all Linguistik relevant options. 66 // 67 68 class LinguOptions 69 { 70 static SvtLinguOptions *pData; 71 static vos::ORefCount aRefCount; // number of objects of this class 72 73 //! uses default assignment-operator 74 75 sal_Bool SetLocale_Impl( sal_Int16 &rLanguage, 76 ::com::sun::star::uno::Any &rOld, 77 const ::com::sun::star::uno::Any &rVal, sal_Int16 nType ); 78 79 public: 80 LinguOptions(); 81 LinguOptions(const LinguOptions &rOpt); 82 ~LinguOptions(); 83 84 sal_Bool SetValue( ::com::sun::star::uno::Any &rOld, 85 const ::com::sun::star::uno::Any &rVal, sal_Int32 nWID ); 86 void GetValue( ::com::sun::star::uno::Any &rVal, sal_Int32 nWID ) const; 87 88 static ::rtl::OUString GetName( sal_Int32 nWID ); 89 90 const ::com::sun::star::uno::Sequence< rtl::OUString > 91 GetActiveDics() const { return pData->aActiveDics; } 92 93 const ::com::sun::star::uno::Sequence< rtl::OUString > 94 GetActiveConvDics() const { return pData->aActiveConvDics; } 95 }; 96 97 98 /////////////////////////////////////////////////////////////////////////// 99 100 // uses templates from <cppuhelper/interfacecontainer.h> 101 102 103 // helper function call class 104 struct PropHashType_Impl 105 { 106 size_t operator()(const sal_Int32 &s) const { return s; } 107 }; 108 109 typedef cppu::OMultiTypeInterfaceContainerHelperVar 110 < 111 sal_Int32, 112 PropHashType_Impl, 113 std::equal_to< sal_Int32 > 114 > OPropertyListenerContainerHelper; 115 116 /////////////////////////////////////////////////////////////////////////// 117 118 119 class LinguProps : 120 public cppu::WeakImplHelper5 121 < 122 com::sun::star::beans::XPropertySet, 123 com::sun::star::beans::XFastPropertySet, 124 com::sun::star::beans::XPropertyAccess, 125 com::sun::star::lang::XComponent, 126 com::sun::star::lang::XServiceInfo 127 > 128 { 129 ::cppu::OInterfaceContainerHelper aEvtListeners; 130 OPropertyListenerContainerHelper aPropListeners; 131 132 SfxItemPropertyMap aPropertyMap; 133 SvtLinguConfig aConfig; 134 135 sal_Bool bDisposing; 136 137 // disallow copy-constructor and assignment-operator for now 138 LinguProps(const LinguProps &); 139 LinguProps & operator = (const LinguProps &); 140 141 void launchEvent( const ::com::sun::star::beans::PropertyChangeEvent &rEvt ) const; 142 143 public: 144 LinguProps(); 145 146 // XPropertySet 147 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException); 148 virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 149 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 150 virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& rxListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 151 virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& rxListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 152 virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& rxListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 153 virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& rxListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 154 155 // XFastPropertySet 156 virtual void SAL_CALL setFastPropertyValue( sal_Int32 nHandle, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 157 virtual ::com::sun::star::uno::Any SAL_CALL getFastPropertyValue( sal_Int32 nHandle ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 158 159 // XPropertyAccess 160 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL getPropertyValues() throw(::com::sun::star::uno::RuntimeException); 161 virtual void SAL_CALL setPropertyValues( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aProps ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 162 163 // XComponent 164 virtual void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException); 165 virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException); 166 virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException); 167 168 // XServiceInfo 169 virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException); 170 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException); 171 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException); 172 173 174 static inline ::rtl::OUString getImplementationName_Static() throw(); 175 static com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static() throw(); 176 }; 177 178 inline ::rtl::OUString LinguProps::getImplementationName_Static() throw() 179 { 180 return A2OU( "com.sun.star.lingu2.LinguProps" ); 181 } 182 183 /////////////////////////////////////////////////////////////////////////// 184 185 #endif 186 187