UDK 3.2.7 C/C++ API Reference
|
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 00002 /************************************************************************* 00003 * 00004 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 00005 * 00006 * Copyright 2000, 2010 Oracle and/or its affiliates. 00007 * 00008 * OpenOffice.org - a multi-platform office productivity suite 00009 * 00010 * This file is part of OpenOffice.org. 00011 * 00012 * OpenOffice.org is free software: you can redistribute it and/or modify 00013 * it under the terms of the GNU Lesser General Public License version 3 00014 * only, as published by the Free Software Foundation. 00015 * 00016 * OpenOffice.org is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Lesser General Public License version 3 for more details 00020 * (a copy is included in the LICENSE file that accompanied this code). 00021 * 00022 * You should have received a copy of the GNU Lesser General Public License 00023 * version 3 along with OpenOffice.org. If not, see 00024 * <http://www.openoffice.org/license.html> 00025 * for a copy of the LGPLv3 License. 00026 * 00027 ************************************************************************/ 00028 00029 #ifndef _CPPUHELPER_PROPSHLP_HXX 00030 #define _CPPUHELPER_PROPSHLP_HXX 00031 00032 #include <rtl/alloc.h> 00033 00034 #include <cppuhelper/interfacecontainer.hxx> 00035 00036 #include <com/sun/star/beans/XPropertySet.hpp> 00037 #include <com/sun/star/beans/XPropertySetOption.hpp> 00038 #include <com/sun/star/beans/XMultiPropertySet.hpp> 00039 #include <com/sun/star/beans/XFastPropertySet.hpp> 00040 00041 #include <memory> 00042 #include "cppuhelperdllapi.h" 00043 00044 00045 namespace cppu 00046 { 00047 00048 00049 /************************************************************************* 00050 *************************************************************************/ 00051 00052 00056 class CPPUHELPER_DLLPUBLIC IPropertyArrayHelper 00057 { 00058 public: 00059 // these are here to force memory de/allocation to sal lib. 00060 inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW(()) 00061 { return ::rtl_allocateMemory( nSize ); } 00062 inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW(()) 00063 { ::rtl_freeMemory( pMem ); } 00064 inline static void * SAL_CALL operator new( size_t, void * pMem ) SAL_THROW(()) 00065 { return pMem; } 00066 inline static void SAL_CALL operator delete( void *, void * ) SAL_THROW(()) 00067 {} 00068 00072 virtual ~IPropertyArrayHelper(); 00073 00085 virtual sal_Bool SAL_CALL fillPropertyMembersByHandle( 00086 ::rtl::OUString * pPropName, sal_Int16 * pAttributes, sal_Int32 nHandle ) = 0; 00090 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > SAL_CALL getProperties(void) = 0; 00096 virtual ::com::sun::star::beans::Property SAL_CALL getPropertyByName( 00097 const ::rtl::OUString& rPropertyName ) 00098 throw (::com::sun::star::beans::UnknownPropertyException) = 0; 00103 virtual sal_Bool SAL_CALL hasPropertyByName(const ::rtl::OUString& rPropertyName) = 0; 00109 virtual sal_Int32 SAL_CALL getHandleByName( const ::rtl::OUString & rPropertyName ) = 0; 00115 virtual sal_Int32 SAL_CALL fillHandles( 00116 /*out*/ sal_Int32 * pHandles, const ::com::sun::star::uno::Sequence< ::rtl::OUString > & rPropNames ) = 0; 00117 }; 00118 00123 class CPPUHELPER_DLLPUBLIC OPropertyArrayHelper : public IPropertyArrayHelper 00124 { 00125 public: 00134 OPropertyArrayHelper( 00135 ::com::sun::star::beans::Property *pProps, 00136 sal_Int32 nElements , 00137 sal_Bool bSorted = sal_True ) 00138 SAL_THROW(()); 00139 00146 OPropertyArrayHelper( 00147 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > & aProps, 00148 sal_Bool bSorted = sal_True ) 00149 SAL_THROW(()); 00150 00154 sal_Int32 SAL_CALL getCount() const SAL_THROW(()); 00167 virtual sal_Bool SAL_CALL fillPropertyMembersByHandle( 00168 ::rtl::OUString * pPropName, sal_Int16 * pAttributes, sal_Int32 nHandle ); 00172 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > SAL_CALL getProperties(void); 00178 virtual ::com::sun::star::beans::Property SAL_CALL getPropertyByName( 00179 const ::rtl::OUString& rPropertyName ) 00180 throw (::com::sun::star::beans::UnknownPropertyException); 00185 virtual sal_Bool SAL_CALL hasPropertyByName(const ::rtl::OUString& rPropertyName); 00191 virtual sal_Int32 SAL_CALL getHandleByName( const ::rtl::OUString & rPropertyName ); 00197 virtual sal_Int32 SAL_CALL fillHandles( 00198 /*out*/sal_Int32 * pHandles, const ::com::sun::star::uno::Sequence< ::rtl::OUString > & rPropNames ); 00199 00200 protected: 00203 void * m_pReserved; 00204 00205 private: 00206 void init( sal_Bool bSorted ) SAL_THROW(()); 00207 00209 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > aInfos; 00210 00215 sal_Bool bRightOrdered; 00216 }; 00217 00218 00219 //----------------------------------------------------------------------------- 00220 // helper defines needed for an interface container with a 32 bit key values 00221 00222 struct equalInt32_Impl 00223 { 00224 bool operator()(const sal_Int32 & i1 , const sal_Int32 & i2) const SAL_THROW(()) 00225 { return i1 == i2; } 00226 }; 00227 00228 struct hashInt32_Impl 00229 { 00230 size_t operator()(const sal_Int32 & i) const SAL_THROW(()) 00231 { return i; } 00232 }; 00236 class CPPUHELPER_DLLPUBLIC OMultiTypeInterfaceContainerHelperInt32 00237 { 00238 public: 00239 // these are here to force memory de/allocation to sal lib. 00240 inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW(()) 00241 { return ::rtl_allocateMemory( nSize ); } 00242 inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW(()) 00243 { ::rtl_freeMemory( pMem ); } 00244 inline static void * SAL_CALL operator new( size_t, void * pMem ) SAL_THROW(()) 00245 { return pMem; } 00246 inline static void SAL_CALL operator delete( void *, void * ) SAL_THROW(()) 00247 {} 00248 00256 OMultiTypeInterfaceContainerHelperInt32( ::osl::Mutex & rMutex ) SAL_THROW(()); 00260 ~OMultiTypeInterfaceContainerHelperInt32() SAL_THROW(()); 00261 00265 ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL getContainedTypes() const SAL_THROW(()); 00266 00272 OInterfaceContainerHelper * SAL_CALL getContainer( const sal_Int32 & rKey ) const SAL_THROW(()); 00273 00281 sal_Int32 SAL_CALL addInterface( 00282 const sal_Int32 & rKey, 00283 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & r ) 00284 SAL_THROW(()); 00285 00293 sal_Int32 SAL_CALL removeInterface( 00294 const sal_Int32 & rKey, 00295 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & rxIFace ) 00296 SAL_THROW(()); 00297 00302 void SAL_CALL disposeAndClear( const ::com::sun::star::lang::EventObject & rEvt ) SAL_THROW(()); 00306 void SAL_CALL clear() SAL_THROW(()); 00307 00308 typedef sal_Int32 keyType; 00309 private: 00310 void *m_pMap; 00311 ::osl::Mutex & rMutex; 00312 00313 inline OMultiTypeInterfaceContainerHelperInt32( const OMultiTypeInterfaceContainerHelperInt32 & ) SAL_THROW(()); 00314 inline OMultiTypeInterfaceContainerHelperInt32 & operator = ( const OMultiTypeInterfaceContainerHelperInt32 & ) SAL_THROW(()); 00315 }; 00316 00317 00320 class IEventNotificationHook 00321 { 00322 public: 00332 virtual void fireEvents( 00333 sal_Int32 * pnHandles, 00334 sal_Int32 nCount, 00335 sal_Bool bVetoable, 00336 bool bIgnoreRuntimeExceptionsWhileFiring) = 0; 00337 00338 #if !defined _MSC_VER // public -> protected changes mangled names there 00339 protected: 00340 #endif 00341 ~IEventNotificationHook() {} 00342 // avoid warnings about virtual members and non-virtual dtor 00343 }; 00344 00345 00346 00359 class CPPUHELPER_DLLPUBLIC OPropertySetHelper : 00360 public ::com::sun::star::beans::XMultiPropertySet, 00361 public ::com::sun::star::beans::XFastPropertySet, 00362 public ::com::sun::star::beans::XPropertySet 00363 { 00364 public: 00371 OPropertySetHelper( OBroadcastHelper & rBHelper ) SAL_THROW(()); 00372 00391 OPropertySetHelper( 00392 OBroadcastHelper & rBHelper, bool bIgnoreRuntimeExceptionsWhileFiring ); 00393 00415 OPropertySetHelper( 00416 OBroadcastHelper & rBHelper, 00417 IEventNotificationHook *i_pFireEvents, 00418 bool bIgnoreRuntimeExceptionsWhileFiring = false); 00419 00424 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) 00425 throw (::com::sun::star::uno::RuntimeException); 00426 00429 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > getTypes() 00430 throw(::com::sun::star::uno::RuntimeException); 00431 00438 void SAL_CALL disposing() SAL_THROW(()); 00439 00445 virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& rPropertyName, const ::com::sun::star::uno::Any& aValue ) 00446 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); 00451 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(const ::rtl::OUString& aPropertyName) 00452 throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 00454 virtual void SAL_CALL addPropertyChangeListener( 00455 const ::rtl::OUString& aPropertyName, 00456 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener) 00457 throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 00458 00460 virtual void SAL_CALL removePropertyChangeListener( 00461 const ::rtl::OUString& aPropertyName, 00462 const ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertyChangeListener >& aListener) 00463 throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 00464 00466 virtual void SAL_CALL addVetoableChangeListener( 00467 const ::rtl::OUString& aPropertyName, 00468 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener) 00469 throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 00470 00472 virtual void SAL_CALL removeVetoableChangeListener( 00473 const ::rtl::OUString& aPropertyName, 00474 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener > & aListener ) 00475 throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 00476 00484 virtual void SAL_CALL setFastPropertyValue( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) 00485 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); 00486 00491 virtual ::com::sun::star::uno::Any SAL_CALL getFastPropertyValue( sal_Int32 nHandle ) 00492 throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 00493 00494 // XMultiPropertySet 00495 virtual void SAL_CALL setPropertyValues( 00496 const ::com::sun::star::uno::Sequence< ::rtl::OUString >& PropertyNames, 00497 const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Values ) 00498 throw(::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 00499 00500 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL getPropertyValues( 00501 const ::com::sun::star::uno::Sequence< ::rtl::OUString >& PropertyNames ) 00502 throw(::com::sun::star::uno::RuntimeException); 00503 00504 virtual void SAL_CALL addPropertiesChangeListener( 00505 const ::com::sun::star::uno::Sequence< ::rtl::OUString >& PropertyNames, 00506 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& Listener ) 00507 throw(::com::sun::star::uno::RuntimeException); 00508 00509 virtual void SAL_CALL removePropertiesChangeListener( 00510 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& Listener ) 00511 throw(::com::sun::star::uno::RuntimeException); 00512 00513 virtual void SAL_CALL firePropertiesChangeEvent( 00514 const ::com::sun::star::uno::Sequence< ::rtl::OUString >& PropertyNames, 00515 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener > & Listener ) 00516 throw(::com::sun::star::uno::RuntimeException); 00517 00521 static ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySetInfo > SAL_CALL 00522 createPropertySetInfo( IPropertyArrayHelper & rProperties ) SAL_THROW(()); 00523 protected: 00533 void SAL_CALL fire( 00534 sal_Int32 * pnHandles, 00535 const ::com::sun::star::uno::Any * pNewValues, 00536 const ::com::sun::star::uno::Any * pOldValues, 00537 sal_Int32 nCount, 00538 sal_Bool bVetoable ); 00539 00549 void SAL_CALL setFastPropertyValues( 00550 sal_Int32 nSeqLen, 00551 sal_Int32 * pHandles, 00552 const ::com::sun::star::uno::Any * pValues, 00553 sal_Int32 nHitCount ) 00554 SAL_THROW( (::com::sun::star::uno::Exception) ); 00555 00560 virtual IPropertyArrayHelper & SAL_CALL getInfoHelper() = 0; 00561 00573 virtual sal_Bool SAL_CALL convertFastPropertyValue( 00574 ::com::sun::star::uno::Any & rConvertedValue, 00575 ::com::sun::star::uno::Any & rOldValue, 00576 sal_Int32 nHandle, 00577 const ::com::sun::star::uno::Any& rValue ) 00578 throw (::com::sun::star::lang::IllegalArgumentException) = 0; 00579 00598 virtual void SAL_CALL setFastPropertyValue_NoBroadcast( 00599 sal_Int32 nHandle, 00600 const ::com::sun::star::uno::Any& rValue ) 00601 throw (::com::sun::star::uno::Exception) = 0; 00607 virtual void SAL_CALL getFastPropertyValue( 00608 ::com::sun::star::uno::Any& rValue, 00609 sal_Int32 nHandle ) const = 0; 00610 00629 void setDependentFastPropertyValue( 00630 sal_Int32 i_handle, 00631 const ::com::sun::star::uno::Any& i_value 00632 ); 00633 00635 OBroadcastHelper &rBHelper; 00639 OMultiTypeInterfaceContainerHelperInt32 aBoundLC; 00643 OMultiTypeInterfaceContainerHelperInt32 aVetoableLC; 00644 00645 class Impl; 00646 00649 const std::auto_ptr<Impl> m_pReserved; 00650 00651 private: 00652 OPropertySetHelper( const OPropertySetHelper & ) SAL_THROW(()); 00653 OPropertySetHelper & operator = ( const OPropertySetHelper & ) SAL_THROW(()); 00654 00658 void impl_fireAll( 00659 sal_Int32* i_handles, 00660 const ::com::sun::star::uno::Any * i_newValues, 00661 const ::com::sun::star::uno::Any * i_oldValues, 00662 sal_Int32 i_count 00663 ); 00664 00665 #if defined _MSC_VER // public -> protected changes mangled names there 00666 public: 00667 #else 00668 protected: 00669 #endif 00670 // Suppress warning about virtual functions but non-virtual destructor: 00671 #if defined _MSC_VER 00672 #pragma warning(push) 00673 #pragma warning(disable: 4265) 00674 #endif 00675 00678 ~OPropertySetHelper() SAL_THROW(()); 00679 }; 00680 #if defined _MSC_VER 00681 #pragma warning(pop) 00682 #endif 00683 00687 class CPPUHELPER_DLLPUBLIC OPropertySetHelper2 : public OPropertySetHelper, 00688 public ::com::sun::star::beans::XPropertySetOption 00689 { 00690 public: 00695 explicit OPropertySetHelper2( 00696 OBroadcastHelper & rBHelper, 00697 IEventNotificationHook *i_pFireEvents = NULL, 00698 bool bIgnoreRuntimeExceptionsWhileFiring = false); 00699 00700 // XInterface 00701 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) 00702 throw (::com::sun::star::uno::RuntimeException); 00703 00704 // XPropertySetOption 00705 virtual void SAL_CALL enableChangeListenerNotification( sal_Bool bEnable ) 00706 throw(::com::sun::star::uno::RuntimeException); 00707 00708 00709 00710 private: 00711 OPropertySetHelper2( const OPropertySetHelper2 & ) SAL_THROW(()); 00712 OPropertySetHelper2 & operator = ( const OPropertySetHelper2 & ) SAL_THROW(()); 00713 00714 #if defined _MSC_VER // public -> protected changes mangled names there 00715 public: 00716 #else 00717 protected: 00718 #endif 00719 // Suppress warning about virtual functions but non-virtual destructor: 00723 virtual ~OPropertySetHelper2() SAL_THROW(()); 00724 }; 00725 00726 } // end namespace cppuhelper 00727 #endif // 00728 00729 00730 00731 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */