LibreOffice: cppuhelper/propshlp.hxx Source File

LibreOffice LibreOffice 5.4 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 SAL_WARN_UNUSED CPPUHELPER_DLLPUBLIC IPropertyArrayHelper
47 {
48 public:
49 // these are here to force memory de/allocation to sal lib.
50 static void * SAL_CALL operator new( size_t nSize )
51 { return ::rtl_allocateMemory( nSize ); }
52 static void SAL_CALL operator delete( void * pMem )
53 { ::rtl_freeMemory( pMem ); }
54 static void * SAL_CALL operator new( size_t, void * pMem )
55 { return pMem; }
56 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 ) = 0;
92 virtual sal_Bool SAL_CALL hasPropertyByName(const ::rtl::OUString& rPropertyName) = 0;
98 virtual sal_Int32 SAL_CALL getHandleByName( const ::rtl::OUString & rPropertyName ) = 0;
104 virtual sal_Int32 SAL_CALL fillHandles(
105 /*out*/ sal_Int32 * pHandles, const css::uno::Sequence< ::rtl::OUString > & rPropNames ) = 0;
106 };
107
112 class SAL_WARN_UNUSED CPPUHELPER_DLLPUBLIC OPropertyArrayHelper : public IPropertyArrayHelper
113 {
114 public:
123 OPropertyArrayHelper(
124 css::beans::Property *pProps,
125 sal_Int32 nElements ,
126 sal_Bool bSorted = true );
127
134 OPropertyArrayHelper(
135 const css::uno::Sequence< css::beans::Property > & aProps,
136 sal_Bool bSorted = true );
137
141 sal_Int32 SAL_CALL getCount() const;
154 virtual sal_Bool SAL_CALL fillPropertyMembersByHandle(
155 ::rtl::OUString * pPropName, sal_Int16 * pAttributes, sal_Int32 nHandle ) SAL_OVERRIDE;
159 virtual css::uno::Sequence< css::beans::Property > SAL_CALL getProperties() SAL_OVERRIDE;
165 virtual css::beans::Property SAL_CALL getPropertyByName(
166 const ::rtl::OUString& rPropertyName ) SAL_OVERRIDE;
171 virtual sal_Bool SAL_CALL hasPropertyByName(const ::rtl::OUString& rPropertyName) SAL_OVERRIDE;
177 virtual sal_Int32 SAL_CALL getHandleByName( const ::rtl::OUString & rPropertyName ) SAL_OVERRIDE;
183 virtual sal_Int32 SAL_CALL fillHandles(
184 /*out*/sal_Int32 * pHandles, const css::uno::Sequence< ::rtl::OUString > & rPropNames ) SAL_OVERRIDE;
185
186 protected:
189 void * m_pReserved;
190
191 private:
192 void init( sal_Bool bSorted );
193
195 css::uno::Sequence< css::beans::Property > aInfos;
196
201 sal_Bool bRightOrdered;
202 };
203
204
205 // helper defines needed for an interface container with a 32 bit key values
206
207 struct equalInt32_Impl
208 {
209 bool operator()(const sal_Int32 & i1 , const sal_Int32 & i2) const
210 { return i1 == i2; }
211 };
212
213 struct hashInt32_Impl
214 {
215 size_t operator()(const sal_Int32 & i) const
216 { return i; }
217 };
218
222 class SAL_WARN_UNUSED CPPUHELPER_DLLPUBLIC OMultiTypeInterfaceContainerHelperInt32
223 {
224 public:
225 // these are here to force memory de/allocation to sal lib.
226 static void * SAL_CALL operator new( size_t nSize )
227 { return ::rtl_allocateMemory( nSize ); }
228 static void SAL_CALL operator delete( void * pMem )
229 { ::rtl_freeMemory( pMem ); }
230 static void * SAL_CALL operator new( size_t, void * pMem )
231 { return pMem; }
232 static void SAL_CALL operator delete( void *, void * )
233 {}
234
242 OMultiTypeInterfaceContainerHelperInt32( ::osl::Mutex & rMutex );
246 ~OMultiTypeInterfaceContainerHelperInt32();
247
251 css::uno::Sequence< sal_Int32 > SAL_CALL getContainedTypes() const;
252
258 OInterfaceContainerHelper * SAL_CALL getContainer( const sal_Int32 & rKey ) const;
259
267 sal_Int32 SAL_CALL addInterface(
268 const sal_Int32 & rKey,
269 const css::uno::Reference< css::uno::XInterface > & r );
270
278 sal_Int32 SAL_CALL removeInterface(
279 const sal_Int32 & rKey,
280 const css::uno::Reference< css::uno::XInterface > & rxIFace );
281
286 void SAL_CALL disposeAndClear( const css::lang::EventObject & rEvt );
290 void SAL_CALL clear();
291
292 typedef sal_Int32 keyType;
293 private:
294 void * m_pMap;
295 ::osl::Mutex & rMutex;
296
297 OMultiTypeInterfaceContainerHelperInt32( const OMultiTypeInterfaceContainerHelperInt32 & ) SAL_DELETED_FUNCTION;
298 OMultiTypeInterfaceContainerHelperInt32 & operator = ( const OMultiTypeInterfaceContainerHelperInt32 & )SAL_DELETED_FUNCTION;
299 };
300
301
304 class IEventNotificationHook
305 {
306 public:
329 virtual void fireEvents(
330 sal_Int32 * pnHandles,
331 sal_Int32 nCount,
332 sal_Bool bVetoable,
333 bool bIgnoreRuntimeExceptionsWhileFiring) = 0;
334
335 #if !defined _MSC_VER // public -> protected changes mangled names there
336 protected:
337 #elif defined __clang__
338 #pragma clang diagnostic push
339 #pragma clang diagnostic ignored "-Wnon-virtual-dtor"
340 #endif
341 ~IEventNotificationHook() {}
342 // avoid warnings about virtual members and non-virtual dtor
343 #if defined _MSC_VER && defined __clang__
344 #pragma clang diagnostic pop
345 #endif
346 };
347
348
361 class CPPUHELPER_DLLPUBLIC OPropertySetHelper :
362 public css::beans::XMultiPropertySet,
363 public css::beans::XFastPropertySet,
364 public css::beans::XPropertySet
365 {
366 public:
373 OPropertySetHelper( OBroadcastHelper & rBHelper );
374
393 OPropertySetHelper(
394 OBroadcastHelper & rBHelper, bool bIgnoreRuntimeExceptionsWhileFiring );
395
417 OPropertySetHelper(
418 OBroadcastHelper & rBHelper,
419 IEventNotificationHook *i_pFireEvents,
420 bool bIgnoreRuntimeExceptionsWhileFiring = false);
421
426 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) SAL_OVERRIDE;
427
432 css::uno::Sequence< css::uno::Type > getTypes();
433
440 void SAL_CALL disposing();
441
447 virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& rPropertyName, const css::uno::Any& aValue ) SAL_OVERRIDE;
452 virtual css::uno::Any SAL_CALL getPropertyValue(const ::rtl::OUString& aPropertyName) SAL_OVERRIDE;
454 virtual void SAL_CALL addPropertyChangeListener(
455 const ::rtl::OUString& aPropertyName,
456 const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener) SAL_OVERRIDE;
457
459 virtual void SAL_CALL removePropertyChangeListener(
460 const ::rtl::OUString& aPropertyName,
461 const css::uno::Reference < css::beans::XPropertyChangeListener >& aListener) SAL_OVERRIDE;
462
464 virtual void SAL_CALL addVetoableChangeListener(
465 const ::rtl::OUString& aPropertyName,
466 const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener) SAL_OVERRIDE;
467
469 virtual void SAL_CALL removeVetoableChangeListener(
470 const ::rtl::OUString& aPropertyName,
471 const css::uno::Reference< css::beans::XVetoableChangeListener > & aListener ) SAL_OVERRIDE;
472
480 virtual void SAL_CALL setFastPropertyValue( sal_Int32 nHandle, const css::uno::Any& rValue ) SAL_OVERRIDE;
481
486 virtual css::uno::Any SAL_CALL getFastPropertyValue( sal_Int32 nHandle ) SAL_OVERRIDE;
487
488 // XMultiPropertySet
489 virtual void SAL_CALL setPropertyValues(
490 const css::uno::Sequence< ::rtl::OUString >& PropertyNames,
491 const css::uno::Sequence< css::uno::Any >& Values ) SAL_OVERRIDE;
492
493 virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyValues(
494 const css::uno::Sequence< ::rtl::OUString >& PropertyNames ) SAL_OVERRIDE;
495
496 virtual void SAL_CALL addPropertiesChangeListener(
497 const css::uno::Sequence< ::rtl::OUString >& PropertyNames,
498 const css::uno::Reference< css::beans::XPropertiesChangeListener >& Listener ) SAL_OVERRIDE;
499
500 virtual void SAL_CALL removePropertiesChangeListener(
501 const css::uno::Reference< css::beans::XPropertiesChangeListener >& Listener ) SAL_OVERRIDE;
502
503 virtual void SAL_CALL firePropertiesChangeEvent(
504 const css::uno::Sequence< ::rtl::OUString >& PropertyNames,
505 const css::uno::Reference< css::beans::XPropertiesChangeListener > & Listener ) SAL_OVERRIDE;
506
510 static css::uno::Reference < css::beans::XPropertySetInfo > SAL_CALL
511 createPropertySetInfo( IPropertyArrayHelper & rProperties );
512 protected:
522 void SAL_CALL fire(
523 sal_Int32 * pnHandles,
524 const css::uno::Any * pNewValues,
525 const css::uno::Any * pOldValues,
526 sal_Int32 nCount,
527 sal_Bool bVetoable );
528
538 void SAL_CALL setFastPropertyValues(
539 sal_Int32 nSeqLen,
540 sal_Int32 * pHandles,
541 const css::uno::Any * pValues,
542 sal_Int32 nHitCount );
543
548 virtual IPropertyArrayHelper & SAL_CALL getInfoHelper() = 0;
549
565 virtual sal_Bool SAL_CALL convertFastPropertyValue(
566 css::uno::Any & rConvertedValue,
567 css::uno::Any & rOldValue,
568 sal_Int32 nHandle,
569 const css::uno::Any& rValue ) = 0;
570
590 virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
591 sal_Int32 nHandle,
592 const css::uno::Any& rValue ) = 0;
598 virtual void SAL_CALL getFastPropertyValue(
599 css::uno::Any& rValue,
600 sal_Int32 nHandle ) const = 0;
601
620 void setDependentFastPropertyValue(
621 sal_Int32 i_handle,
622 const css::uno::Any& i_value
623 );
624
626 OBroadcastHelper &rBHelper;
630 OMultiTypeInterfaceContainerHelperInt32 aBoundLC;
634 OMultiTypeInterfaceContainerHelperInt32 aVetoableLC;
635
636 class Impl;
637
640 Impl * const m_pReserved;
641
642 private:
643 OPropertySetHelper( const OPropertySetHelper & ) SAL_DELETED_FUNCTION;
644 OPropertySetHelper & operator = ( const OPropertySetHelper & )
645 SAL_DELETED_FUNCTION;
646
650 void impl_fireAll(
651 sal_Int32* i_handles,
652 const css::uno::Any * i_newValues,
653 const css::uno::Any * i_oldValues,
654 sal_Int32 i_count
655 );
656
657 #if defined _MSC_VER // public -> protected changes mangled names there
658 public:
659 #else
660 protected:
661 #endif
662 // Suppress warning about virtual functions but non-virtual destructor:
663 #if defined _MSC_VER
664 #pragma warning(push)
665 #pragma warning(disable: 4265)
666 #if defined __clang__
667 #pragma clang diagnostic push
668 #pragma clang diagnostic ignored "-Wnon-virtual-dtor"
669 #endif
670 #endif
671
674 ~OPropertySetHelper();
675 };
676 #if defined _MSC_VER
677 #if defined __clang__
678 #pragma clang diagnostic pop
679 #endif
680 #pragma warning(pop)
681 #endif
682
690 class CPPUHELPER_DLLPUBLIC OPropertySetHelper2 : public OPropertySetHelper,
691 public css::beans::XPropertySetOption
692 {
693 public:
698 explicit OPropertySetHelper2(
699 OBroadcastHelper & rBHelper,
700 IEventNotificationHook *i_pFireEvents = NULL,
701 bool bIgnoreRuntimeExceptionsWhileFiring = false);
702
703 // XInterface
704 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) SAL_OVERRIDE;
705
706 // XPropertySetOption
707 virtual void SAL_CALL enableChangeListenerNotification( sal_Bool bEnable ) SAL_OVERRIDE;
708
709
710 private:
711 OPropertySetHelper2( const OPropertySetHelper2 & ) SAL_DELETED_FUNCTION;
712 OPropertySetHelper2 & operator = ( const OPropertySetHelper2 & )
713 SAL_DELETED_FUNCTION;
714
715 #if defined _MSC_VER // public -> protected changes mangled names there
716 public:
717 #else
718 protected:
719 #endif
720 // Suppress warning about virtual functions but non-virtual destructor:
724 virtual ~OPropertySetHelper2();
725 };
726
727 } // end namespace cppuhelper
728 #endif
729
730
731 /* 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:405
cppu::OPropertySetHelper::aVetoableLC
OMultiTypeInterfaceContainerHelperInt32 aVetoableLC
Container for the XPropertyVetoableListener.
Definition: propshlp.hxx:634
cppu::OPropertySetHelper::aBoundLC
OMultiTypeInterfaceContainerHelperInt32 aBoundLC
Container for the XProperyChangedListener.
Definition: propshlp.hxx:630
cppu::OPropertySetHelper::m_pReserved
Impl *const m_pReserved
reserved for future use.
Definition: propshlp.hxx:636
CPPUHELPER_DLLPUBLIC
#define CPPUHELPER_DLLPUBLIC
Definition: cppuhelperdllapi.h:28
cppu::hashInt32_Impl::operator()
size_t operator()(const sal_Int32 &i) const
Definition: propshlp.hxx:215
SAL_DELETED_FUNCTION
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition: types.h:392
SAL_WARN_UNUSED
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:598
cppu::equalInt32_Impl
Definition: propshlp.hxx:207
rtl_allocateMemory
SAL_DLLPUBLIC void * rtl_allocateMemory(sal_Size Bytes) SAL_THROW_EXTERN_C()
Allocate memory.
cppu::OPropertySetHelper2
OPropertySetHelper plus XPropertySetOption.
Definition: propshlp.hxx:690
sal_Bool
unsigned char sal_Bool
Definition: types.h:39
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:292
cppu::OMultiTypeInterfaceContainerHelperInt32
Specialized class for key type sal_Int32, without explicit usage of STL symbols.
Definition: propshlp.hxx:222
cppu::OPropertyArrayHelper
You can use this helper class to map a XPropertySet-Interface to a XFast- or a XMultiPropertySet inte...
Definition: propshlp.hxx:112
rtl::OUString
This String class provides base functionality for C++ like Unicode character array handling...
Definition: ustring.hxx:120
cppuhelperdllapi.h
cppu::OPropertyArrayHelper::m_pReserved
void * m_pReserved
reserved for future use.
Definition: propshlp.hxx:189
cppu::OPropertySetHelper
This abstract class maps the methods of the interfaces XMultiPropertySet, XFastPropertySet and XPrope...
Definition: propshlp.hxx:361
cppu::OPropertySetHelper::rBHelper
OBroadcastHelper & rBHelper
The common data of a broadcaster.
Definition: propshlp.hxx:626
cppu::hashInt32_Impl
Definition: propshlp.hxx:213
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:209
cppu::IEventNotificationHook::~IEventNotificationHook
~IEventNotificationHook()
Definition: propshlp.hxx:341
cppu::IEventNotificationHook
An interface to extend event notification actions.
Definition: propshlp.hxx:304
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