LibreOffice
LibreOffice 6.0 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 
35 namespace cppu
36 {
37 
38 
39 /*************************************************************************
40 *************************************************************************/
41 
42 
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 
113 {
114 public:
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;
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 
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 {
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 
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 
298  OMultiTypeInterfaceContainerHelperInt32 & operator = ( const OMultiTypeInterfaceContainerHelperInt32 & )SAL_DELETED_FUNCTION;
299 };
300 
301 
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
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 
362  public css::beans::XMultiPropertySet,
363  public css::beans::XFastPropertySet,
364  public css::beans::XPropertySet
365 {
366 public:
373  OPropertySetHelper( OBroadcastHelper & rBHelper );
374 
394  OBroadcastHelper & rBHelper, bool bIgnoreRuntimeExceptionsWhileFiring );
395 
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 
635 
636  class Impl;
637 
640  Impl * const m_pReserved;
641 
642 private:
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 
675 };
676 #if defined _MSC_VER
677 #if defined __clang__
678 #pragma clang diagnostic pop
679 #endif
680 #pragma warning(pop)
681 #endif
682 
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:
712  OPropertySetHelper2 & operator = ( const OPropertySetHelper2 & )
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: */
sal_Int32 keyType
Definition: propshlp.hxx:292
OPropertySetHelper plus XPropertySetOption.
Definition: propshlp.hxx:690
size_t operator()(const sal_Int32 &i) const
Definition: propshlp.hxx:215
You can use this helper class to map a XPropertySet-Interface to a XFast- or a XMultiPropertySet inte...
Definition: propshlp.hxx:112
Definition: Enterable.hxx:26
A mutual exclusion synchronization object.
Definition: mutex.hxx:30
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition: types.h:402
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:608
css::uno::Any queryInterface(const css::uno::Type &rType, Interface1 *p1)
Compares demanded type to given template argument types.
Definition: queryinterface.hxx:39
Impl *const m_pReserved
reserved for future use.
Definition: propshlp.hxx:636
SAL_DLLPUBLIC void rtl_freeMemory(void *Ptr) SAL_THROW_EXTERN_C()
Free memory.
Definition: propshlp.hxx:207
#define SAL_OVERRIDE
C++11 "override" feature.
Definition: types.h:415
Definition: types.h:383
This abstract class maps the methods of the interfaces XMultiPropertySet, XFastPropertySet and XPrope...
Definition: propshlp.hxx:361
unsigned char sal_Bool
Definition: types.h:39
Definition: propshlp.hxx:213
void * m_pReserved
reserved for future use.
Definition: propshlp.hxx:189
bool operator()(const sal_Int32 &i1, const sal_Int32 &i2) const
Definition: propshlp.hxx:209
#define CPPUHELPER_DLLPUBLIC
Definition: cppuhelperdllapi.h:28
A container of interfaces.
Definition: interfacecontainer.h:127
OBroadcastHelper & rBHelper
The common data of a broadcaster.
Definition: propshlp.hxx:626
OMultiTypeInterfaceContainerHelperInt32 aVetoableLC
Container for the XPropertyVetoableListener.
Definition: propshlp.hxx:634
This interface is used by the OPropertyHelper, to access the property description.
Definition: propshlp.hxx:46
This String class provides base functionality for C++ like Unicode character array handling...
Definition: ustring.hxx:120
Specialized class for key type sal_Int32, without explicit usage of STL symbols.
Definition: propshlp.hxx:222
~IEventNotificationHook()
Definition: propshlp.hxx:341
This struct contains the standard variables of a broadcaster.
Definition: interfacecontainer.h:435
SAL_DLLPUBLIC void * rtl_allocateMemory(sal_Size Bytes) SAL_THROW_EXTERN_C()
Allocate memory.
An interface to extend event notification actions.
Definition: propshlp.hxx:304
OMultiTypeInterfaceContainerHelperInt32 aBoundLC
Container for the XProperyChangedListener.
Definition: propshlp.hxx:630