LibreOffice
LibreOffice 7.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
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
33
34
35namespace cppu
36{
37
38
39/*************************************************************************
40*************************************************************************/
41
42
47{
48public:
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
63
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
113{
114public:
124 css::beans::Property *pProps,
125 sal_Int32 nElements ,
126 sal_Bool bSorted = true );
127
135 const css::uno::Sequence< css::beans::Property > & aProps,
136 sal_Bool bSorted = true );
137
141 sal_Int32 SAL_CALL getCount() const;
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
186protected:
189 void * m_pReserved;
190
191private:
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
208{
209 bool operator()(const sal_Int32 & i1 , const sal_Int32 & i2) const
210 { return i1 == i2; }
211};
212
214{
215 size_t operator()(const sal_Int32 & i) const
216 { return i; }
217};
218
223{
224public:
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
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;
293private:
294 void * m_pMap;
295 ::osl::Mutex & rMutex;
296
299};
300
301
305{
306public:
326 virtual void fireEvents(
327 sal_Int32 * pnHandles,
328 sal_Int32 nCount,
329 sal_Bool bVetoable,
330 bool bIgnoreRuntimeExceptionsWhileFiring) = 0;
331
332#if !defined _MSC_VER // public -> protected changes mangled names there
333protected:
334#elif defined __clang__
335#pragma clang diagnostic push
336#pragma clang diagnostic ignored "-Wnon-virtual-dtor"
337#endif
339 // avoid warnings about virtual members and non-virtual dtor
340#if defined _MSC_VER && defined __clang__
341#pragma clang diagnostic pop
342#endif
343};
344
345
359 public css::beans::XMultiPropertySet,
360 public css::beans::XFastPropertySet,
361 public css::beans::XPropertySet
362{
363public:
371
391 OBroadcastHelper & rBHelper, bool bIgnoreRuntimeExceptionsWhileFiring );
392
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 ) SAL_OVERRIDE;
424
429 css::uno::Sequence< css::uno::Type > getTypes();
430
437 void SAL_CALL disposing();
438
444 virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& rPropertyName, const css::uno::Any& aValue ) SAL_OVERRIDE;
449 virtual css::uno::Any SAL_CALL getPropertyValue(const ::rtl::OUString& aPropertyName) SAL_OVERRIDE;
451 virtual void SAL_CALL addPropertyChangeListener(
452 const ::rtl::OUString& aPropertyName,
453 const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener) SAL_OVERRIDE;
454
456 virtual void SAL_CALL removePropertyChangeListener(
457 const ::rtl::OUString& aPropertyName,
458 const css::uno::Reference < css::beans::XPropertyChangeListener >& aListener) SAL_OVERRIDE;
459
461 virtual void SAL_CALL addVetoableChangeListener(
462 const ::rtl::OUString& aPropertyName,
463 const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener) SAL_OVERRIDE;
464
466 virtual void SAL_CALL removeVetoableChangeListener(
467 const ::rtl::OUString& aPropertyName,
468 const css::uno::Reference< css::beans::XVetoableChangeListener > & aListener ) SAL_OVERRIDE;
469
477 virtual void SAL_CALL setFastPropertyValue( sal_Int32 nHandle, const css::uno::Any& rValue ) SAL_OVERRIDE;
478
483 virtual css::uno::Any SAL_CALL getFastPropertyValue( sal_Int32 nHandle ) SAL_OVERRIDE;
484
485 // XMultiPropertySet
486 virtual void SAL_CALL setPropertyValues(
487 const css::uno::Sequence< ::rtl::OUString >& PropertyNames,
488 const css::uno::Sequence< css::uno::Any >& Values ) SAL_OVERRIDE;
489
490 virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyValues(
491 const css::uno::Sequence< ::rtl::OUString >& PropertyNames ) SAL_OVERRIDE;
492
493 virtual void SAL_CALL addPropertiesChangeListener(
494 const css::uno::Sequence< ::rtl::OUString >& PropertyNames,
495 const css::uno::Reference< css::beans::XPropertiesChangeListener >& Listener ) SAL_OVERRIDE;
496
497 virtual void SAL_CALL removePropertiesChangeListener(
498 const css::uno::Reference< css::beans::XPropertiesChangeListener >& Listener ) SAL_OVERRIDE;
499
500 virtual void SAL_CALL firePropertiesChangeEvent(
501 const css::uno::Sequence< ::rtl::OUString >& PropertyNames,
502 const css::uno::Reference< css::beans::XPropertiesChangeListener > & Listener ) SAL_OVERRIDE;
503
507 static css::uno::Reference < css::beans::XPropertySetInfo > SAL_CALL
509protected:
519 void SAL_CALL fire(
520 sal_Int32 * pnHandles,
521 const css::uno::Any * pNewValues,
522 const css::uno::Any * pOldValues,
523 sal_Int32 nCount,
524 sal_Bool bVetoable );
525
536 sal_Int32 nSeqLen,
537 sal_Int32 * pHandles,
538 const css::uno::Any * pValues,
539 sal_Int32 nHitCount );
540
545 virtual IPropertyArrayHelper & SAL_CALL getInfoHelper() = 0;
546
563 css::uno::Any & rConvertedValue,
564 css::uno::Any & rOldValue,
565 sal_Int32 nHandle,
566 const css::uno::Any& rValue ) = 0;
567
587 virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
588 sal_Int32 nHandle,
589 const css::uno::Any& rValue ) = 0;
595 virtual void SAL_CALL getFastPropertyValue(
596 css::uno::Any& rValue,
597 sal_Int32 nHandle ) const = 0;
598
618 sal_Int32 i_handle,
619 const css::uno::Any& i_value
620 );
621
632
633 class Impl;
634
637 Impl * const m_pReserved;
638
639private:
641 OPropertySetHelper & operator = ( const OPropertySetHelper & )
643
647 void impl_fireAll(
648 sal_Int32* i_handles,
649 const css::uno::Any * i_newValues,
650 const css::uno::Any * i_oldValues,
651 sal_Int32 i_count
652 );
653
654#if defined _MSC_VER // public -> protected changes mangled names there
655public:
656#else
657protected:
658#endif
659// Suppress warning about virtual functions but non-virtual destructor:
660#if defined _MSC_VER
661#if defined __clang__
662#pragma clang diagnostic push
663#pragma clang diagnostic ignored "-Wnon-virtual-dtor"
664#endif
665#endif
670};
671#if defined _MSC_VER
672#if defined __clang__
673#pragma clang diagnostic pop
674#endif
675#endif
676
685 public css::beans::XPropertySetOption
686{
687public:
693 OBroadcastHelper & rBHelper,
694 IEventNotificationHook *i_pFireEvents = NULL,
695 bool bIgnoreRuntimeExceptionsWhileFiring = false);
696
697 // XInterface
698 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) SAL_OVERRIDE;
699
700 // XPropertySetOption
702
703
704private:
706 OPropertySetHelper2 & operator = ( const OPropertySetHelper2 & )
708
709#if defined _MSC_VER // public -> protected changes mangled names there
710public:
711#else
712protected:
713#endif
714// Suppress warning about virtual functions but non-virtual destructor:
719};
720
721} // end namespace cppuhelper
722#endif
723
724
725/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition: types.h:374
unsigned char sal_Bool
Definition: types.h:34
#define SAL_OVERRIDE
C++11 "override" feature.
Definition: types.h:387
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:558
SAL_DLLPUBLIC void rtl_freeMemory(void *Ptr) SAL_THROW_EXTERN_C()
Free memory.
SAL_DLLPUBLIC void * rtl_allocateMemory(sal_Size Bytes) SAL_THROW_EXTERN_C()
Allocate memory.
#define CPPUHELPER_DLLPUBLIC
Definition: cppuhelperdllapi.h:28
Definition: Enterable.hxx:27
Definition: unotype.hxx:35
Definition: unotype.hxx:43
A container of interfaces.
Definition: interfacecontainer.h:129
This struct contains the standard variables of a broadcaster.
Definition: interfacecontainer.h:437
This interface is used by the OPropertyHelper, to access the property description.
Definition: propshlp.hxx:47
virtual sal_Bool hasPropertyByName(const ::rtl::OUString &rPropertyName)=0
Return true if the property with the name rPropertyName exist, otherwise false.
virtual css::beans::Property getPropertyByName(const ::rtl::OUString &rPropertyName)=0
Return the property with the name rPropertyName.
virtual ~IPropertyArrayHelper()
Following the rule, the first virtual method implies a virtual destructor.
virtual sal_Bool fillPropertyMembersByHandle(::rtl::OUString *pPropName, sal_Int16 *pAttributes, sal_Int32 nHandle)=0
Return the property members Name and Attribute from the handle nHandle.
virtual sal_Int32 fillHandles(sal_Int32 *pHandles, const css::uno::Sequence< ::rtl::OUString > &rPropNames)=0
Fill the array with the handles of the properties.
virtual css::uno::Sequence< css::beans::Property > getProperties()=0
Return the sequence of properties.
virtual sal_Int32 getHandleByName(const ::rtl::OUString &rPropertyName)=0
Return the handle of the property with the name rPropertyName.
You can use this helper class to map a XPropertySet-Interface to a XFast- or a XMultiPropertySet inte...
Definition: propshlp.hxx:113
sal_Int32 getCount() const
Return the number of properties.
OPropertyArrayHelper(const css::uno::Sequence< css::beans::Property > &aProps, sal_Bool bSorted=true)
Create an object which supports the common property interfaces.
virtual css::uno::Sequence< css::beans::Property > getProperties() SAL_OVERRIDE
Return the sequence of properties.
OPropertyArrayHelper(css::beans::Property *pProps, sal_Int32 nElements, sal_Bool bSorted=true)
Create an object which supports the common property interfaces.
virtual sal_Bool fillPropertyMembersByHandle(::rtl::OUString *pPropName, sal_Int16 *pAttributes, sal_Int32 nHandle) SAL_OVERRIDE
Return the property members Name and Attribute from the handle nHandle.
Definition: propshlp.hxx:208
bool operator()(const sal_Int32 &i1, const sal_Int32 &i2) const
Definition: propshlp.hxx:209
Definition: propshlp.hxx:214
size_t operator()(const sal_Int32 &i) const
Definition: propshlp.hxx:215
Specialized class for key type sal_Int32, without explicit usage of STL symbols.
Definition: propshlp.hxx:223
sal_Int32 addInterface(const sal_Int32 &rKey, const css::uno::Reference< css::uno::XInterface > &r)
Insert an element in the container specified with the key.
void clear()
Remove all elements of all containers.
css::uno::Sequence< sal_Int32 > getContainedTypes() const
Return all id's under which at least one interface is added.
sal_Int32 keyType
Definition: propshlp.hxx:292
~OMultiTypeInterfaceContainerHelperInt32()
Delete all containers.
sal_Int32 removeInterface(const sal_Int32 &rKey, const css::uno::Reference< css::uno::XInterface > &rxIFace)
Remove an element from the container specified with the key.
OMultiTypeInterfaceContainerHelperInt32(::osl::Mutex &rMutex)
Create a container of interface containers.
void disposeAndClear(const css::lang::EventObject &rEvt)
Call disposing on all objects in the container that support XEventListener.
OInterfaceContainerHelper * getContainer(const sal_Int32 &rKey) const
Return the container created under this key.
An interface to extend event notification actions.
Definition: propshlp.hxx:305
virtual void fireEvents(sal_Int32 *pnHandles, sal_Int32 nCount, sal_Bool bVetoable, bool bIgnoreRuntimeExceptionsWhileFiring)=0
Method to be called by OPropertySetHelper::fire.
~IEventNotificationHook()
Definition: propshlp.hxx:338
This abstract class maps the methods of the interfaces XMultiPropertySet, XFastPropertySet and XPrope...
Definition: propshlp.hxx:362
virtual sal_Bool convertFastPropertyValue(css::uno::Any &rConvertedValue, css::uno::Any &rOldValue, sal_Int32 nHandle, const css::uno::Any &rValue)=0
Converted the value rValue and return the result in rConvertedValue and the old value in rOldValue.
void setDependentFastPropertyValue(sal_Int32 i_handle, const css::uno::Any &i_value)
sets an dependent property's value
virtual void removeVetoableChangeListener(const ::rtl::OUString &aPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) SAL_OVERRIDE
Ignored if the property is not constrained.
virtual IPropertyArrayHelper & getInfoHelper()=0
This abstract method must return the name to index table.
void setFastPropertyValues(sal_Int32 nSeqLen, sal_Int32 *pHandles, const css::uno::Any *pValues, sal_Int32 nHitCount)
Set multiple properties with the handles.
virtual void firePropertiesChangeEvent(const css::uno::Sequence< ::rtl::OUString > &PropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener > &Listener) SAL_OVERRIDE
virtual css::uno::Sequence< css::uno::Any > getPropertyValues(const css::uno::Sequence< ::rtl::OUString > &PropertyNames) SAL_OVERRIDE
virtual void setPropertyValue(const ::rtl::OUString &rPropertyName, const css::uno::Any &aValue) SAL_OVERRIDE
Throw UnknownPropertyException or PropertyVetoException if the property with the name rPropertyName d...
Impl *const m_pReserved
reserved for future use.
Definition: propshlp.hxx:633
~OPropertySetHelper()
You must call disposing before destruction.
virtual void getFastPropertyValue(css::uno::Any &rValue, sal_Int32 nHandle) const =0
The same as getFastPropertyValue, but return the value through rValue and nHandle is always valid.
OMultiTypeInterfaceContainerHelperInt32 aBoundLC
Container for the XPropertyChangedListener.
Definition: propshlp.hxx:627
virtual void setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const css::uno::Any &rValue)=0
The same as setFastPropertyValue; nHandle is always valid.
virtual void setFastPropertyValue(sal_Int32 nHandle, const css::uno::Any &rValue) SAL_OVERRIDE
Throw UnknownPropertyException or PropertyVetoException if the property with the name rPropertyName d...
void disposing()
Send a disposing notification to the listeners in the containers aBoundLC and aVetoableLC.
OBroadcastHelper & rBHelper
The common data of a broadcaster.
Definition: propshlp.hxx:623
OPropertySetHelper(OBroadcastHelper &rBHelper, bool bIgnoreRuntimeExceptionsWhileFiring)
Constructor.
virtual css::uno::Any queryInterface(const css::uno::Type &rType) SAL_OVERRIDE
Only returns a reference to XMultiPropertySet, XFastPropertySet, XPropertySet and XEventListener.
virtual css::uno::Any getPropertyValue(const ::rtl::OUString &aPropertyName) SAL_OVERRIDE
Throw UnknownPropertyException if the property with the name rPropertyName does not exist.
OMultiTypeInterfaceContainerHelperInt32 aVetoableLC
Container for the XPropertyVetoableListener.
Definition: propshlp.hxx:631
virtual void setPropertyValues(const css::uno::Sequence< ::rtl::OUString > &PropertyNames, const css::uno::Sequence< css::uno::Any > &Values) SAL_OVERRIDE
OPropertySetHelper(OBroadcastHelper &rBHelper)
virtual css::uno::Any getFastPropertyValue(sal_Int32 nHandle) SAL_OVERRIDE
virtual void removePropertiesChangeListener(const css::uno::Reference< css::beans::XPropertiesChangeListener > &Listener) SAL_OVERRIDE
virtual void removePropertyChangeListener(const ::rtl::OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) SAL_OVERRIDE
Ignored if the property is not bound.
OPropertySetHelper(OBroadcastHelper &rBHelper, IEventNotificationHook *i_pFireEvents, bool bIgnoreRuntimeExceptionsWhileFiring=false)
Constructor.
void fire(sal_Int32 *pnHandles, const css::uno::Any *pNewValues, const css::uno::Any *pOldValues, sal_Int32 nCount, sal_Bool bVetoable)
This method fire events to all registered property listeners.
virtual void addPropertyChangeListener(const ::rtl::OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) SAL_OVERRIDE
Ignored if the property is not bound.
virtual void addVetoableChangeListener(const ::rtl::OUString &aPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) SAL_OVERRIDE
Ignored if the property is not constrained.
virtual void addPropertiesChangeListener(const css::uno::Sequence< ::rtl::OUString > &PropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener > &Listener) SAL_OVERRIDE
css::uno::Sequence< css::uno::Type > getTypes()
eases implementing XTypeProvider::getTypes, returns the types of XMultiPropertySet,...
static css::uno::Reference< css::beans::XPropertySetInfo > createPropertySetInfo(IPropertyArrayHelper &rProperties)
The property sequence is created in the call.
OPropertySetHelper plus XPropertySetOption.
Definition: propshlp.hxx:686
virtual void enableChangeListenerNotification(sal_Bool bEnable) SAL_OVERRIDE
virtual css::uno::Any queryInterface(const css::uno::Type &rType) SAL_OVERRIDE
Only returns a reference to XMultiPropertySet, XFastPropertySet, XPropertySet and XEventListener.
OPropertySetHelper2(OBroadcastHelper &rBHelper, IEventNotificationHook *i_pFireEvents=NULL, bool bIgnoreRuntimeExceptionsWhileFiring=false)
Constructor.
virtual ~OPropertySetHelper2()
You must call disposing before destruction.
A mutual exclusion synchronization object.
Definition: mutex.hxx:31
This String class provides base functionality for C++ like Unicode character array handling.
Definition: ustring.hxx:161