LibreOffice: cppuhelper/propshlp.hxx Source File

LibreOffice LibreOffice 5.1 SDK C/C++ API Reference

propshlp.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20 #ifndef INCLUDED_CPPUHELPER_PROPSHLP_HXX
21 #define INCLUDED_CPPUHELPER_PROPSHLP_HXX
22
23 #include <rtl/alloc.h>
24
25 #include <cppuhelper/interfacecontainer.h>
26
27 #include <com/sun/star/beans/XPropertySet.hpp>
28 #include <com/sun/star/beans/XPropertySetOption.hpp>
29 #include <com/sun/star/beans/XMultiPropertySet.hpp>
30 #include <com/sun/star/beans/XFastPropertySet.hpp>
31
32 #include <cppuhelper/cppuhelperdllapi.h>
33
34
35 namespace cppu
36 {
37
38
39 /*************************************************************************
40 *************************************************************************/
41
42
46 class CPPUHELPER_DLLPUBLIC IPropertyArrayHelper
47 {
48 public:
49 // these are here to force memory de/allocation to sal lib.
50 inline static void * SAL_CALL operator new( size_t nSize )
51 { return ::rtl_allocateMemory( nSize ); }
52 inline static void SAL_CALL operator delete( void * pMem )
53 { ::rtl_freeMemory( pMem ); }
54 inline static void * SAL_CALL operator new( size_t, void * pMem )
55 { return pMem; }
56 inline static void SAL_CALL operator delete( void *, void * )
57 {}
58
62 virtual ~IPropertyArrayHelper();
63
75 virtual sal_Bool SAL_CALL fillPropertyMembersByHandle(
76 ::rtl::OUString * pPropName, sal_Int16 * pAttributes, sal_Int32 nHandle ) = 0;
80 virtual css::uno::Sequence< css::beans::Property > SAL_CALL getProperties() = 0;
86 virtual css::beans::Property SAL_CALL getPropertyByName(
87 const ::rtl::OUString& rPropertyName )
88 throw (css::beans::UnknownPropertyException) = 0;
93 virtual sal_Bool SAL_CALL hasPropertyByName(const ::rtl::OUString& rPropertyName) = 0;
99 virtual sal_Int32 SAL_CALL getHandleByName( const ::rtl::OUString & rPropertyName ) = 0;
105 virtual sal_Int32 SAL_CALL fillHandles(
106 /*out*/ sal_Int32 * pHandles, const css::uno::Sequence< ::rtl::OUString > & rPropNames ) = 0;
107 };
108
113 class CPPUHELPER_DLLPUBLIC OPropertyArrayHelper : public IPropertyArrayHelper
114 {
115 public:
124 OPropertyArrayHelper(
125 css::beans::Property *pProps,
126 sal_Int32 nElements ,
127 sal_Bool bSorted = sal_True );
128
135 OPropertyArrayHelper(
136 const css::uno::Sequence< css::beans::Property > & aProps,
137 sal_Bool bSorted = sal_True );
138
142 sal_Int32 SAL_CALL getCount() const;
155 virtual sal_Bool SAL_CALL fillPropertyMembersByHandle(
156 ::rtl::OUString * pPropName, sal_Int16 * pAttributes, sal_Int32 nHandle ) SAL_OVERRIDE;
160 virtual css::uno::Sequence< css::beans::Property > SAL_CALL getProperties() SAL_OVERRIDE;
166 virtual css::beans::Property SAL_CALL getPropertyByName(
167 const ::rtl::OUString& rPropertyName )
168 throw (css::beans::UnknownPropertyException) SAL_OVERRIDE;
173 virtual sal_Bool SAL_CALL hasPropertyByName(const ::rtl::OUString& rPropertyName) SAL_OVERRIDE;
179 virtual sal_Int32 SAL_CALL getHandleByName( const ::rtl::OUString & rPropertyName ) SAL_OVERRIDE;
185 virtual sal_Int32 SAL_CALL fillHandles(
186 /*out*/sal_Int32 * pHandles, const css::uno::Sequence< ::rtl::OUString > & rPropNames ) SAL_OVERRIDE;
187
188 protected:
191 void * m_pReserved;
192
193 private:
194 void init( sal_Bool bSorted );
195
197 css::uno::Sequence< css::beans::Property > aInfos;
198
203 sal_Bool bRightOrdered;
204 };
205
206
207
208 // helper defines needed for an interface container with a 32 bit key values
209
210 struct equalInt32_Impl
211 {
212 bool operator()(const sal_Int32 & i1 , const sal_Int32 & i2) const
213 { return i1 == i2; }
214 };
215
216 struct hashInt32_Impl
217 {
218 size_t operator()(const sal_Int32 & i) const
219 { return i; }
220 };
224 class CPPUHELPER_DLLPUBLIC OMultiTypeInterfaceContainerHelperInt32
225 {
226 public:
227 // these are here to force memory de/allocation to sal lib.
228 inline static void * SAL_CALL operator new( size_t nSize )
229 { return ::rtl_allocateMemory( nSize ); }
230 inline static void SAL_CALL operator delete( void * pMem )
231 { ::rtl_freeMemory( pMem ); }
232 inline static void * SAL_CALL operator new( size_t, void * pMem )
233 { return pMem; }
234 inline static void SAL_CALL operator delete( void *, void * )
235 {}
236
244 OMultiTypeInterfaceContainerHelperInt32( ::osl::Mutex & rMutex );
248 ~OMultiTypeInterfaceContainerHelperInt32();
249
253 css::uno::Sequence< sal_Int32 > SAL_CALL getContainedTypes() const;
254
260 OInterfaceContainerHelper * SAL_CALL getContainer( const sal_Int32 & rKey ) const;
261
269 sal_Int32 SAL_CALL addInterface(
270 const sal_Int32 & rKey,
271 const css::uno::Reference< css::uno::XInterface > & r );
272
280 sal_Int32 SAL_CALL removeInterface(
281 const sal_Int32 & rKey,
282 const css::uno::Reference< css::uno::XInterface > & rxIFace );
283
288 void SAL_CALL disposeAndClear( const css::lang::EventObject & rEvt );
292 void SAL_CALL clear();
293
294 typedef sal_Int32 keyType;
295 private:
296 void * m_pMap;
297 ::osl::Mutex & rMutex;
298
299 OMultiTypeInterfaceContainerHelperInt32( const OMultiTypeInterfaceContainerHelperInt32 & ) SAL_DELETED_FUNCTION;
300 OMultiTypeInterfaceContainerHelperInt32 & operator = ( const OMultiTypeInterfaceContainerHelperInt32 & )SAL_DELETED_FUNCTION;
301 };
302
303
306 class IEventNotificationHook
307 {
308 public:
331 virtual void fireEvents(
332 sal_Int32 * pnHandles,
333 sal_Int32 nCount,
334 sal_Bool bVetoable,
335 bool bIgnoreRuntimeExceptionsWhileFiring) = 0;
336
337 #if !defined _MSC_VER // public -> protected changes mangled names there
338 protected:
339 #endif
340 ~IEventNotificationHook() {}
341 // avoid warnings about virtual members and non-virtual dtor
342 };
343
344
345
358 class CPPUHELPER_DLLPUBLIC OPropertySetHelper :
359 public css::beans::XMultiPropertySet,
360 public css::beans::XFastPropertySet,
361 public css::beans::XPropertySet
362 {
363 public:
370 OPropertySetHelper( OBroadcastHelper & rBHelper );
371
390 OPropertySetHelper(
391 OBroadcastHelper & rBHelper, bool bIgnoreRuntimeExceptionsWhileFiring );
392
414 OPropertySetHelper(
415 OBroadcastHelper & rBHelper,
416 IEventNotificationHook *i_pFireEvents,
417 bool bIgnoreRuntimeExceptionsWhileFiring = false);
418
423 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType )
424 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
425
428 css::uno::Sequence< css::uno::Type > getTypes()
429 throw(css::uno::RuntimeException);
430
437 void SAL_CALL disposing();
438
444 virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& rPropertyName, const css::uno::Any& aValue )
445 throw(css::beans::UnknownPropertyException, css::beans::PropertyVetoException, css::lang::IllegalArgumentException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
450 virtual css::uno::Any SAL_CALL getPropertyValue(const ::rtl::OUString& aPropertyName)
451 throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
453 virtual void SAL_CALL addPropertyChangeListener(
454 const ::rtl::OUString& aPropertyName,
455 const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener)
456 throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
457
459 virtual void SAL_CALL removePropertyChangeListener(
460 const ::rtl::OUString& aPropertyName,
461 const css::uno::Reference < css::beans::XPropertyChangeListener >& aListener)
462 throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
463
465 virtual void SAL_CALL addVetoableChangeListener(
466 const ::rtl::OUString& aPropertyName,
467 const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener)
468 throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
469
471 virtual void SAL_CALL removeVetoableChangeListener(
472 const ::rtl::OUString& aPropertyName,
473 const css::uno::Reference< css::beans::XVetoableChangeListener > & aListener )
474 throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
475
483 virtual void SAL_CALL setFastPropertyValue( sal_Int32 nHandle, const css::uno::Any& rValue )
484 throw(css::beans::UnknownPropertyException, css::beans::PropertyVetoException, css::lang::IllegalArgumentException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
485
490 virtual css::uno::Any SAL_CALL getFastPropertyValue( sal_Int32 nHandle )
491 throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
492
493 // XMultiPropertySet
494 virtual void SAL_CALL setPropertyValues(
495 const css::uno::Sequence< ::rtl::OUString >& PropertyNames,
496 const css::uno::Sequence< css::uno::Any >& Values )
497 throw(css::beans::PropertyVetoException, css::lang::IllegalArgumentException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
498
499 virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyValues(
500 const css::uno::Sequence< ::rtl::OUString >& PropertyNames )
501 throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
502
503 virtual void SAL_CALL addPropertiesChangeListener(
504 const css::uno::Sequence< ::rtl::OUString >& PropertyNames,
505 const css::uno::Reference< css::beans::XPropertiesChangeListener >& Listener )
506 throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
507
508 virtual void SAL_CALL removePropertiesChangeListener(
509 const css::uno::Reference< css::beans::XPropertiesChangeListener >& Listener )
510 throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
511
512 virtual void SAL_CALL firePropertiesChangeEvent(
513 const css::uno::Sequence< ::rtl::OUString >& PropertyNames,
514 const css::uno::Reference< css::beans::XPropertiesChangeListener > & Listener )
515 throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
516
520 static css::uno::Reference < css::beans::XPropertySetInfo > SAL_CALL
521 createPropertySetInfo( IPropertyArrayHelper & rProperties );
522 protected:
532 void SAL_CALL fire(
533 sal_Int32 * pnHandles,
534 const css::uno::Any * pNewValues,
535 const css::uno::Any * pOldValues,
536 sal_Int32 nCount,
537 sal_Bool bVetoable );
538
548 void SAL_CALL setFastPropertyValues(
549 sal_Int32 nSeqLen,
550 sal_Int32 * pHandles,
551 const css::uno::Any * pValues,
552 sal_Int32 nHitCount );
553
558 virtual IPropertyArrayHelper & SAL_CALL getInfoHelper() = 0;
559
572 virtual sal_Bool SAL_CALL convertFastPropertyValue(
573 css::uno::Any & rConvertedValue,
574 css::uno::Any & rOldValue,
575 sal_Int32 nHandle,
576 const css::uno::Any& rValue )
577 throw (css::lang::IllegalArgumentException,
578 css::beans::UnknownPropertyException,
579 css::uno::RuntimeException, std::exception) = 0;
580
599 virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
600 sal_Int32 nHandle,
601 const css::uno::Any& rValue )
602 throw (css::uno::Exception,
603 std::exception) = 0;
609 virtual void SAL_CALL getFastPropertyValue(
610 css::uno::Any& rValue,
611 sal_Int32 nHandle ) const = 0;
612
631 void setDependentFastPropertyValue(
632 sal_Int32 i_handle,
633 const css::uno::Any& i_value
634 );
635
637 OBroadcastHelper &rBHelper;
641 OMultiTypeInterfaceContainerHelperInt32 aBoundLC;
645 OMultiTypeInterfaceContainerHelperInt32 aVetoableLC;
646
647 class Impl;
648
651 Impl * const m_pReserved;
652
653 private:
654 OPropertySetHelper( const OPropertySetHelper & ) SAL_DELETED_FUNCTION;
655 OPropertySetHelper & operator = ( const OPropertySetHelper & )
656 SAL_DELETED_FUNCTION;
657
661 void impl_fireAll(
662 sal_Int32* i_handles,
663 const css::uno::Any * i_newValues,
664 const css::uno::Any * i_oldValues,
665 sal_Int32 i_count
666 );
667
668 #if defined _MSC_VER // public -> protected changes mangled names there
669 public:
670 #else
671 protected:
672 #endif
673 // Suppress warning about virtual functions but non-virtual destructor:
674 #if defined _MSC_VER
675 #pragma warning(push)
676 #pragma warning(disable: 4265)
677 #endif
678
681 ~OPropertySetHelper();
682 };
683 #if defined _MSC_VER
684 #pragma warning(pop)
685 #endif
686
694 class CPPUHELPER_DLLPUBLIC OPropertySetHelper2 : public OPropertySetHelper,
695 public css::beans::XPropertySetOption
696 {
697 public:
702 explicit OPropertySetHelper2(
703 OBroadcastHelper & rBHelper,
704 IEventNotificationHook *i_pFireEvents = NULL,
705 bool bIgnoreRuntimeExceptionsWhileFiring = false);
706
707 // XInterface
708 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType )
709 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
710
711 // XPropertySetOption
712 virtual void SAL_CALL enableChangeListenerNotification( sal_Bool bEnable )
713 throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
714
715
716
717 private:
718 OPropertySetHelper2( const OPropertySetHelper2 & ) SAL_DELETED_FUNCTION;
719 OPropertySetHelper2 & operator = ( const OPropertySetHelper2 & )
720 SAL_DELETED_FUNCTION;
721
722 #if defined _MSC_VER // public -> protected changes mangled names there
723 public:
724 #else
725 protected:
726 #endif
727 // Suppress warning about virtual functions but non-virtual destructor:
731 virtual ~OPropertySetHelper2();
732 };
733
734 } // end namespace cppuhelper
735 #endif
736
737
738
739 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
cppu::queryInterface
css::uno::Any queryInterface(const css::uno::Type &rType, Interface1 *p1)
Compares demanded type to given template argument types.
Definition: queryinterface.hxx:39
SAL_OVERRIDE
#define SAL_OVERRIDE
C++11 "override" feature.
Definition: types.h:421
cppu::OPropertySetHelper::aVetoableLC
OMultiTypeInterfaceContainerHelperInt32 aVetoableLC
Container for the XPropertyVetoableListener.
Definition: propshlp.hxx:645
cppu::OPropertySetHelper::aBoundLC
OMultiTypeInterfaceContainerHelperInt32 aBoundLC
Container for the XProperyChangedListener.
Definition: propshlp.hxx:641
cppu::OPropertySetHelper::m_pReserved
Impl *const m_pReserved
reserved for future use.
Definition: propshlp.hxx:647
CPPUHELPER_DLLPUBLIC
#define CPPUHELPER_DLLPUBLIC
Definition: cppuhelperdllapi.h:28
sal_True
#define sal_True
Definition: types.h:50
cppu::hashInt32_Impl::operator()
size_t operator()(const sal_Int32 &i) const
Definition: propshlp.hxx:218
SAL_DELETED_FUNCTION
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition: types.h:408
cppu::equalInt32_Impl
Definition: propshlp.hxx:210
rtl_allocateMemory
SAL_DLLPUBLIC void * rtl_allocateMemory(sal_Size Bytes) SAL_THROW_EXTERN_C()
Allocate memory.
cppu::OPropertySetHelper2
OPropertySetHelper plus XPropertySetOption.
Definition: propshlp.hxx:694
sal_Bool
unsigned char sal_Bool
Definition: types.h:48
osl::Mutex
A mutual exclusion synchronization object.
Definition: mutex.hxx:30
cppu
Definition: Enterable.hxx:26
interfacecontainer.h
cppu::OMultiTypeInterfaceContainerHelperInt32::keyType
sal_Int32 keyType
Definition: propshlp.hxx:294
cppu::OMultiTypeInterfaceContainerHelperInt32
Specialized class for key type sal_Int32, without explicit usage of STL symbols.
Definition: propshlp.hxx:224
com::sun::star
Definition: types.h:389
cppu::OPropertyArrayHelper
You can use this helper class to map a XPropertySet-Interface to a XFast- or a XMultiPropertySet inte...
Definition: propshlp.hxx:113
rtl::OUString
This String class provides base functionality for C++ like Unicode character array handling...
Definition: ustring.hxx:106
cppuhelperdllapi.h
cppu::OPropertyArrayHelper::m_pReserved
void * m_pReserved
reserved for future use.
Definition: propshlp.hxx:191
cppu::OPropertySetHelper
This abstract class maps the methods of the interfaces XMultiPropertySet, XFastPropertySet and XPrope...
Definition: propshlp.hxx:358
cppu::OPropertySetHelper::rBHelper
OBroadcastHelper & rBHelper
The common data of a broadcaster.
Definition: propshlp.hxx:637
cppu::hashInt32_Impl
Definition: propshlp.hxx:216
rtl_freeMemory
SAL_DLLPUBLIC void rtl_freeMemory(void *Ptr) SAL_THROW_EXTERN_C()
Free memory.
cppu::IPropertyArrayHelper
This interface is used by the OPropertyHelper, to access the property description.
Definition: propshlp.hxx:46
alloc.h
cppu::equalInt32_Impl::operator()
bool operator()(const sal_Int32 &i1, const sal_Int32 &i2) const
Definition: propshlp.hxx:212
cppu::IEventNotificationHook::~IEventNotificationHook
~IEventNotificationHook()
Definition: propshlp.hxx:340
cppu::IEventNotificationHook
An interface to extend event notification actions.
Definition: propshlp.hxx:306
cppu::OBroadcastHelperVar
This struct contains the standard variables of a broadcaster.
Definition: interfacecontainer.h:435
cppu::OInterfaceContainerHelper
A container of interfaces.
Definition: interfacecontainer.h:127