LibreOffice LibreOffice 5.3 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 = true );
128
135 OPropertyArrayHelper(
136 const css::uno::Sequence< css::beans::Property > & aProps,
137 sal_Bool bSorted = 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 // helper defines needed for an interface container with a 32 bit key values
208
209 struct equalInt32_Impl
210 {
211 bool operator()(const sal_Int32 & i1 , const sal_Int32 & i2) const
212 { return i1 == i2; }
213 };
214
215 struct hashInt32_Impl
216 {
217 size_t operator()(const sal_Int32 & i) const
218 { return i; }
219 };
223 class CPPUHELPER_DLLPUBLIC OMultiTypeInterfaceContainerHelperInt32
224 {
225 public:
226 // these are here to force memory de/allocation to sal lib.
227 inline static void * SAL_CALL operator new( size_t nSize )
228 { return ::rtl_allocateMemory( nSize ); }
229 inline static void SAL_CALL operator delete( void * pMem )
230 { ::rtl_freeMemory( pMem ); }
231 inline static void * SAL_CALL operator new( size_t, void * pMem )
232 { return pMem; }
233 inline static void SAL_CALL operator delete( void *, void * )
234 {}
235
243 OMultiTypeInterfaceContainerHelperInt32( ::osl::Mutex & rMutex );
247 ~OMultiTypeInterfaceContainerHelperInt32();
248
252 css::uno::Sequence< sal_Int32 > SAL_CALL getContainedTypes() const;
253
259 OInterfaceContainerHelper * SAL_CALL getContainer( const sal_Int32 & rKey ) const;
260
268 sal_Int32 SAL_CALL addInterface(
269 const sal_Int32 & rKey,
270 const css::uno::Reference< css::uno::XInterface > & r );
271
279 sal_Int32 SAL_CALL removeInterface(
280 const sal_Int32 & rKey,
281 const css::uno::Reference< css::uno::XInterface > & rxIFace );
282
287 void SAL_CALL disposeAndClear( const css::lang::EventObject & rEvt );
291 void SAL_CALL clear();
292
293 typedef sal_Int32 keyType;
294 private:
295 void * m_pMap;
296 ::osl::Mutex & rMutex;
297
298 OMultiTypeInterfaceContainerHelperInt32( const OMultiTypeInterfaceContainerHelperInt32 & ) SAL_DELETED_FUNCTION;
299 OMultiTypeInterfaceContainerHelperInt32 & operator = ( const OMultiTypeInterfaceContainerHelperInt32 & )SAL_DELETED_FUNCTION;
300 };
301
302
305 class IEventNotificationHook
306 {
307 public:
330 virtual void fireEvents(
331 sal_Int32 * pnHandles,
332 sal_Int32 nCount,
333 sal_Bool bVetoable,
334 bool bIgnoreRuntimeExceptionsWhileFiring) = 0;
335
336 #if !defined _MSC_VER // public -> protected changes mangled names there
337 protected:
338 #elif defined __clang__
339 #pragma clang diagnostic push
340 #pragma clang diagnostic ignored "-Wnon-virtual-dtor"
341 #endif
342 ~IEventNotificationHook() {}
343 // avoid warnings about virtual members and non-virtual dtor
344 #if defined _MSC_VER && defined __clang__
345 #pragma clang diagnostic pop
346 #endif
347 };
348
349
362 class CPPUHELPER_DLLPUBLIC OPropertySetHelper :
363 public css::beans::XMultiPropertySet,
364 public css::beans::XFastPropertySet,
365 public css::beans::XPropertySet
366 {
367 public:
374 OPropertySetHelper( OBroadcastHelper & rBHelper );
375
394 OPropertySetHelper(
395 OBroadcastHelper & rBHelper, bool bIgnoreRuntimeExceptionsWhileFiring );
396
418 OPropertySetHelper(
419 OBroadcastHelper & rBHelper,
420 IEventNotificationHook *i_pFireEvents,
421 bool bIgnoreRuntimeExceptionsWhileFiring = false);
422
427 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType )
428 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
429
432 css::uno::Sequence< css::uno::Type > getTypes()
433 throw(css::uno::RuntimeException);
434
441 void SAL_CALL disposing();
442
448 virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& rPropertyName, const css::uno::Any& aValue )
449 throw(css::beans::UnknownPropertyException, css::beans::PropertyVetoException, css::lang::IllegalArgumentException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
454 virtual css::uno::Any SAL_CALL getPropertyValue(const ::rtl::OUString& aPropertyName)
455 throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
457 virtual void SAL_CALL addPropertyChangeListener(
458 const ::rtl::OUString& aPropertyName,
459 const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener)
460 throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
461
463 virtual void SAL_CALL removePropertyChangeListener(
464 const ::rtl::OUString& aPropertyName,
465 const css::uno::Reference < css::beans::XPropertyChangeListener >& aListener)
466 throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
467
469 virtual void SAL_CALL addVetoableChangeListener(
470 const ::rtl::OUString& aPropertyName,
471 const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener)
472 throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
473
475 virtual void SAL_CALL removeVetoableChangeListener(
476 const ::rtl::OUString& aPropertyName,
477 const css::uno::Reference< css::beans::XVetoableChangeListener > & aListener )
478 throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
479
487 virtual void SAL_CALL setFastPropertyValue( sal_Int32 nHandle, const css::uno::Any& rValue )
488 throw(css::beans::UnknownPropertyException, css::beans::PropertyVetoException, css::lang::IllegalArgumentException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
489
494 virtual css::uno::Any SAL_CALL getFastPropertyValue( sal_Int32 nHandle )
495 throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
496
497 // XMultiPropertySet
498 virtual void SAL_CALL setPropertyValues(
499 const css::uno::Sequence< ::rtl::OUString >& PropertyNames,
500 const css::uno::Sequence< css::uno::Any >& Values )
501 throw(css::beans::PropertyVetoException, css::lang::IllegalArgumentException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
502
503 virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyValues(
504 const css::uno::Sequence< ::rtl::OUString >& PropertyNames )
505 throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
506
507 virtual void SAL_CALL addPropertiesChangeListener(
508 const css::uno::Sequence< ::rtl::OUString >& PropertyNames,
509 const css::uno::Reference< css::beans::XPropertiesChangeListener >& Listener )
510 throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
511
512 virtual void SAL_CALL removePropertiesChangeListener(
513 const css::uno::Reference< css::beans::XPropertiesChangeListener >& Listener )
514 throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
515
516 virtual void SAL_CALL firePropertiesChangeEvent(
517 const css::uno::Sequence< ::rtl::OUString >& PropertyNames,
518 const css::uno::Reference< css::beans::XPropertiesChangeListener > & Listener )
519 throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
520
524 static css::uno::Reference < css::beans::XPropertySetInfo > SAL_CALL
525 createPropertySetInfo( IPropertyArrayHelper & rProperties );
526 protected:
536 void SAL_CALL fire(
537 sal_Int32 * pnHandles,
538 const css::uno::Any * pNewValues,
539 const css::uno::Any * pOldValues,
540 sal_Int32 nCount,
541 sal_Bool bVetoable );
542
552 void SAL_CALL setFastPropertyValues(
553 sal_Int32 nSeqLen,
554 sal_Int32 * pHandles,
555 const css::uno::Any * pValues,
556 sal_Int32 nHitCount );
557
562 virtual IPropertyArrayHelper & SAL_CALL getInfoHelper() = 0;
563
576 virtual sal_Bool SAL_CALL convertFastPropertyValue(
577 css::uno::Any & rConvertedValue,
578 css::uno::Any & rOldValue,
579 sal_Int32 nHandle,
580 const css::uno::Any& rValue )
581 throw (css::lang::IllegalArgumentException,
582 css::beans::UnknownPropertyException,
583 css::uno::RuntimeException, std::exception) = 0;
584
603 virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
604 sal_Int32 nHandle,
605 const css::uno::Any& rValue )
606 throw (css::uno::Exception,
607 std::exception) = 0;
613 virtual void SAL_CALL getFastPropertyValue(
614 css::uno::Any& rValue,
615 sal_Int32 nHandle ) const = 0;
616
635 void setDependentFastPropertyValue(
636 sal_Int32 i_handle,
637 const css::uno::Any& i_value
638 );
639
641 OBroadcastHelper &rBHelper;
645 OMultiTypeInterfaceContainerHelperInt32 aBoundLC;
649 OMultiTypeInterfaceContainerHelperInt32 aVetoableLC;
650
651 class Impl;
652
655 Impl * const m_pReserved;
656
657 private:
658 OPropertySetHelper( const OPropertySetHelper & ) SAL_DELETED_FUNCTION;
659 OPropertySetHelper & operator = ( const OPropertySetHelper & )
660 SAL_DELETED_FUNCTION;
661
665 void impl_fireAll(
666 sal_Int32* i_handles,
667 const css::uno::Any * i_newValues,
668 const css::uno::Any * i_oldValues,
669 sal_Int32 i_count
670 );
671
672 #if defined _MSC_VER // public -> protected changes mangled names there
673 public:
674 #else
675 protected:
676 #endif
677 // Suppress warning about virtual functions but non-virtual destructor:
678 #if defined _MSC_VER
679 #pragma warning(push)
680 #pragma warning(disable: 4265)
681 #if defined __clang__
682 #pragma clang diagnostic push
683 #pragma clang diagnostic ignored "-Wnon-virtual-dtor"
684 #endif
685 #endif
686
689 ~OPropertySetHelper();
690 };
691 #if defined _MSC_VER
692 #if defined __clang__
693 #pragma clang diagnostic pop
694 #endif
695 #pragma warning(pop)
696 #endif
697
705 class CPPUHELPER_DLLPUBLIC OPropertySetHelper2 : public OPropertySetHelper,
706 public css::beans::XPropertySetOption
707 {
708 public:
713 explicit OPropertySetHelper2(
714 OBroadcastHelper & rBHelper,
715 IEventNotificationHook *i_pFireEvents = NULL,
716 bool bIgnoreRuntimeExceptionsWhileFiring = false);
717
718 // XInterface
719 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType )
720 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
721
722 // XPropertySetOption
723 virtual void SAL_CALL enableChangeListenerNotification( sal_Bool bEnable )
724 throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
725
726
727 private:
728 OPropertySetHelper2( const OPropertySetHelper2 & ) SAL_DELETED_FUNCTION;
729 OPropertySetHelper2 & operator = ( const OPropertySetHelper2 & )
730 SAL_DELETED_FUNCTION;
731
732 #if defined _MSC_VER // public -> protected changes mangled names there
733 public:
734 #else
735 protected:
736 #endif
737 // Suppress warning about virtual functions but non-virtual destructor:
741 virtual ~OPropertySetHelper2();
742 };
743
744 } // end namespace cppuhelper
745 #endif
746
747
748 /* 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:423
cppu::OPropertySetHelper::aVetoableLC
OMultiTypeInterfaceContainerHelperInt32 aVetoableLC
Container for the XPropertyVetoableListener.
Definition: propshlp.hxx:649
cppu::OPropertySetHelper::aBoundLC
OMultiTypeInterfaceContainerHelperInt32 aBoundLC
Container for the XProperyChangedListener.
Definition: propshlp.hxx:645
cppu::OPropertySetHelper::m_pReserved
Impl *const m_pReserved
reserved for future use.
Definition: propshlp.hxx:651
CPPUHELPER_DLLPUBLIC
#define CPPUHELPER_DLLPUBLIC
Definition: cppuhelperdllapi.h:28
cppu::hashInt32_Impl::operator()
size_t operator()(const sal_Int32 &i) const
Definition: propshlp.hxx:217
SAL_DELETED_FUNCTION
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition: types.h:410
cppu::equalInt32_Impl
Definition: propshlp.hxx:209
rtl_allocateMemory
SAL_DLLPUBLIC void * rtl_allocateMemory(sal_Size Bytes) SAL_THROW_EXTERN_C()
Allocate memory.
cppu::OPropertySetHelper2
OPropertySetHelper plus XPropertySetOption.
Definition: propshlp.hxx:705
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:293
cppu::OMultiTypeInterfaceContainerHelperInt32
Specialized class for key type sal_Int32, without explicit usage of STL symbols.
Definition: propshlp.hxx:223
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:362
cppu::OPropertySetHelper::rBHelper
OBroadcastHelper & rBHelper
The common data of a broadcaster.
Definition: propshlp.hxx:641
cppu::hashInt32_Impl
Definition: propshlp.hxx:215
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:211
cppu::IEventNotificationHook::~IEventNotificationHook
~IEventNotificationHook()
Definition: propshlp.hxx:342
cppu::IEventNotificationHook
An interface to extend event notification actions.
Definition: propshlp.hxx:305
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