LibreOffice
LibreOffice 7.4 SDK C/C++ API Reference
Loading...
Searching...
No Matches
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/*
21 * This file is part of LibreOffice published API.
22 */
23
24#ifndef INCLUDED_CPPUHELPER_PROPSHLP_HXX
25#define INCLUDED_CPPUHELPER_PROPSHLP_HXX
26
27#include "rtl/alloc.h"
28
30
31#include "com/sun/star/beans/XPropertySet.hpp"
32#include "com/sun/star/beans/XPropertySetOption.hpp"
33#include "com/sun/star/beans/XMultiPropertySet.hpp"
34#include "com/sun/star/beans/XFastPropertySet.hpp"
35
37
38
39namespace cppu
40{
41
42
43/*************************************************************************
44*************************************************************************/
45
46
51{
52public:
53 // these are here to force memory de/allocation to sal lib.
54 static void * SAL_CALL operator new( size_t nSize )
55 { return ::rtl_allocateMemory( nSize ); }
56 static void SAL_CALL operator delete( void * pMem )
57 { ::rtl_freeMemory( pMem ); }
58 static void * SAL_CALL operator new( size_t, void * pMem )
59 { return pMem; }
60 static void SAL_CALL operator delete( void *, void * )
61 {}
62
67
80 ::rtl::OUString * pPropName, sal_Int16 * pAttributes, sal_Int32 nHandle ) = 0;
84 virtual css::uno::Sequence< css::beans::Property > SAL_CALL getProperties() = 0;
90 virtual css::beans::Property SAL_CALL getPropertyByName(
91 const ::rtl::OUString& rPropertyName ) = 0;
96 virtual sal_Bool SAL_CALL hasPropertyByName(const ::rtl::OUString& rPropertyName) = 0;
102 virtual sal_Int32 SAL_CALL getHandleByName( const ::rtl::OUString & rPropertyName ) = 0;
108 virtual sal_Int32 SAL_CALL fillHandles(
109 /*out*/ sal_Int32 * pHandles, const css::uno::Sequence< ::rtl::OUString > & rPropNames ) = 0;
110};
111
117{
118public:
128 css::beans::Property *pProps,
129 sal_Int32 nElements ,
130 sal_Bool bSorted = true );
131
139 const css::uno::Sequence< css::beans::Property > & aProps,
140 sal_Bool bSorted = true );
141
145 sal_Int32 SAL_CALL getCount() const;
159 ::rtl::OUString * pPropName, sal_Int16 * pAttributes, sal_Int32 nHandle ) SAL_OVERRIDE;
163 virtual css::uno::Sequence< css::beans::Property > SAL_CALL getProperties() SAL_OVERRIDE;
169 virtual css::beans::Property SAL_CALL getPropertyByName(
170 const ::rtl::OUString& rPropertyName ) SAL_OVERRIDE;
175 virtual sal_Bool SAL_CALL hasPropertyByName(const ::rtl::OUString& rPropertyName) SAL_OVERRIDE;
181 virtual sal_Int32 SAL_CALL getHandleByName( const ::rtl::OUString & rPropertyName ) SAL_OVERRIDE;
187 virtual sal_Int32 SAL_CALL fillHandles(
188 /*out*/sal_Int32 * pHandles, const css::uno::Sequence< ::rtl::OUString > & rPropNames ) SAL_OVERRIDE;
189
190protected:
193 void * m_pReserved;
194
195private:
196 void init( sal_Bool bSorted );
197
199 css::uno::Sequence< css::beans::Property > aInfos;
200
205 sal_Bool bRightOrdered;
206};
207
208
209// helper defines needed for an interface container with a 32 bit key values
210
212{
213 bool operator()(const sal_Int32 & i1 , const sal_Int32 & i2) const
214 { return i1 == i2; }
215};
216
218{
219 size_t operator()(const sal_Int32 & i) const
220 { return i; }
221};
222
227{
228public:
229 // these are here to force memory de/allocation to sal lib.
230 static void * SAL_CALL operator new( size_t nSize )
231 { return ::rtl_allocateMemory( nSize ); }
232 static void SAL_CALL operator delete( void * pMem )
233 { ::rtl_freeMemory( pMem ); }
234 static void * SAL_CALL operator new( size_t, void * pMem )
235 { return pMem; }
236 static void SAL_CALL operator delete( void *, void * )
237 {}
238
251
255 css::uno::Sequence< sal_Int32 > SAL_CALL getContainedTypes() const;
256
262 OInterfaceContainerHelper * SAL_CALL getContainer( const sal_Int32 & rKey ) const;
263
271 sal_Int32 SAL_CALL addInterface(
272 const sal_Int32 & rKey,
273 const css::uno::Reference< css::uno::XInterface > & r );
274
282 sal_Int32 SAL_CALL removeInterface(
283 const sal_Int32 & rKey,
284 const css::uno::Reference< css::uno::XInterface > & rxIFace );
285
290 void SAL_CALL disposeAndClear( const css::lang::EventObject & rEvt );
294 void SAL_CALL clear();
295
296 typedef sal_Int32 keyType;
297private:
298 void * m_pMap;
299 ::osl::Mutex & rMutex;
300
303};
304
305
309{
310public:
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
337protected:
338#elif defined __clang__
339#pragma clang diagnostic push
340#pragma clang diagnostic ignored "-Wnon-virtual-dtor"
341#endif
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
363 public css::beans::XMultiPropertySet,
364 public css::beans::XFastPropertySet,
365 public css::beans::XPropertySet
366{
367public:
375
395 OBroadcastHelper & rBHelper, bool bIgnoreRuntimeExceptionsWhileFiring );
396
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 ) SAL_OVERRIDE;
428
433 css::uno::Sequence< css::uno::Type > getTypes();
434
441 void SAL_CALL disposing();
442
448 virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& rPropertyName, const css::uno::Any& aValue ) SAL_OVERRIDE;
453 virtual css::uno::Any SAL_CALL getPropertyValue(const ::rtl::OUString& aPropertyName) SAL_OVERRIDE;
455 virtual void SAL_CALL addPropertyChangeListener(
456 const ::rtl::OUString& aPropertyName,
457 const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener) SAL_OVERRIDE;
458
460 virtual void SAL_CALL removePropertyChangeListener(
461 const ::rtl::OUString& aPropertyName,
462 const css::uno::Reference < css::beans::XPropertyChangeListener >& aListener) SAL_OVERRIDE;
463
465 virtual void SAL_CALL addVetoableChangeListener(
466 const ::rtl::OUString& aPropertyName,
467 const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener) SAL_OVERRIDE;
468
470 virtual void SAL_CALL removeVetoableChangeListener(
471 const ::rtl::OUString& aPropertyName,
472 const css::uno::Reference< css::beans::XVetoableChangeListener > & aListener ) SAL_OVERRIDE;
473
481 virtual void SAL_CALL setFastPropertyValue( sal_Int32 nHandle, const css::uno::Any& rValue ) SAL_OVERRIDE;
482
487 virtual css::uno::Any SAL_CALL getFastPropertyValue( sal_Int32 nHandle ) SAL_OVERRIDE;
488
489 // XMultiPropertySet
490 virtual void SAL_CALL setPropertyValues(
491 const css::uno::Sequence< ::rtl::OUString >& PropertyNames,
492 const css::uno::Sequence< css::uno::Any >& Values ) SAL_OVERRIDE;
493
494 virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyValues(
495 const css::uno::Sequence< ::rtl::OUString >& PropertyNames ) SAL_OVERRIDE;
496
497 virtual void SAL_CALL addPropertiesChangeListener(
498 const css::uno::Sequence< ::rtl::OUString >& PropertyNames,
499 const css::uno::Reference< css::beans::XPropertiesChangeListener >& Listener ) SAL_OVERRIDE;
500
501 virtual void SAL_CALL removePropertiesChangeListener(
502 const css::uno::Reference< css::beans::XPropertiesChangeListener >& Listener ) SAL_OVERRIDE;
503
504 virtual void SAL_CALL firePropertiesChangeEvent(
505 const css::uno::Sequence< ::rtl::OUString >& PropertyNames,
506 const css::uno::Reference< css::beans::XPropertiesChangeListener > & Listener ) SAL_OVERRIDE;
507
511 static css::uno::Reference < css::beans::XPropertySetInfo > SAL_CALL
513protected:
523 void SAL_CALL fire(
524 sal_Int32 * pnHandles,
525 const css::uno::Any * pNewValues,
526 const css::uno::Any * pOldValues,
527 sal_Int32 nCount,
528 sal_Bool bVetoable );
529
540 sal_Int32 nSeqLen,
541 sal_Int32 * pHandles,
542 const css::uno::Any * pValues,
543 sal_Int32 nHitCount );
544
549 virtual IPropertyArrayHelper & SAL_CALL getInfoHelper() = 0;
550
567 css::uno::Any & rConvertedValue,
568 css::uno::Any & rOldValue,
569 sal_Int32 nHandle,
570 const css::uno::Any& rValue ) = 0;
571
591 virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
592 sal_Int32 nHandle,
593 const css::uno::Any& rValue ) = 0;
599 virtual void SAL_CALL getFastPropertyValue(
600 css::uno::Any& rValue,
601 sal_Int32 nHandle ) const = 0;
602
622 sal_Int32 i_handle,
623 const css::uno::Any& i_value
624 );
625
636
637 class Impl;
638
641 Impl * const m_pReserved;
642
643private:
645 OPropertySetHelper & operator = ( const OPropertySetHelper & )
647
651 void impl_fireAll(
652 sal_Int32* i_handles,
653 const css::uno::Any * i_newValues,
654 const css::uno::Any * i_oldValues,
655 sal_Int32 i_count
656 );
657
658#if defined _MSC_VER // public -> protected changes mangled names there
659public:
660#else
661protected:
662#endif
663// Suppress warning about virtual functions but non-virtual destructor:
664#if defined _MSC_VER
665#if defined __clang__
666#pragma clang diagnostic push
667#pragma clang diagnostic ignored "-Wnon-virtual-dtor"
668#endif
669#endif
674};
675#if defined _MSC_VER
676#if defined __clang__
677#pragma clang diagnostic pop
678#endif
679#endif
680
689 public css::beans::XPropertySetOption
690{
691public:
697 OBroadcastHelper & rBHelper,
698 IEventNotificationHook *i_pFireEvents = NULL,
699 bool bIgnoreRuntimeExceptionsWhileFiring = false);
700
701 // XInterface
702 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) SAL_OVERRIDE;
703
704 // XPropertySetOption
706
707
708private:
710 OPropertySetHelper2 & operator = ( const OPropertySetHelper2 & )
712
713#if defined _MSC_VER // public -> protected changes mangled names there
714public:
715#else
716protected:
717#endif
718// Suppress warning about virtual functions but non-virtual destructor:
723};
724
725} // end namespace cppuhelper
726#endif
727
728
729/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition: types.h:378
unsigned char sal_Bool
Definition: types.h:38
#define SAL_OVERRIDE
C++11 "override" feature.
Definition: types.h:391
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:587
SAL_DLLPUBLIC void rtl_freeMemory(void *Ptr) SAL_THROW_EXTERN_C()
Free memory.
#define CPPUHELPER_DLLPUBLIC
Definition: cppuhelperdllapi.h:32
Definition: types.h:359
Definition: bootstrap.hxx:34
Definition: Enterable.hxx:31
This String class provides base functionality for C++ like Unicode character array handling.
Definition: ustring.hxx:203
A mutual exclusion synchronization object.
Definition: mutex.hxx:35
A container of interfaces.
Definition: interfacecontainer.h:132
This struct contains the standard variables of a broadcaster.
Definition: interfacecontainer.h:440
This interface is used by the OPropertyHelper, to access the property description.
Definition: propshlp.hxx:51
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:117
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:212
bool operator()(const sal_Int32 &i1, const sal_Int32 &i2) const
Definition: propshlp.hxx:213
Definition: propshlp.hxx:218
size_t operator()(const sal_Int32 &i) const
Definition: propshlp.hxx:219
Specialized class for key type sal_Int32, without explicit usage of STL symbols.
Definition: propshlp.hxx:227
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:296
~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:309
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:342
This abstract class maps the methods of the interfaces XMultiPropertySet, XFastPropertySet and XPrope...
Definition: propshlp.hxx:366
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:641
~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:631
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:627
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:635
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:690
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.