LibreOffice
LibreOffice 6.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 
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 
299 };
300 
301 
305 {
306 public:
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
333 protected:
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 {
363 public:
370  OPropertySetHelper( OBroadcastHelper & rBHelper );
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
508  createPropertySetInfo( IPropertyArrayHelper & rProperties );
509 protected:
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 
535  void SAL_CALL setFastPropertyValues(
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 
562  virtual sal_Bool SAL_CALL convertFastPropertyValue(
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 
617  void setDependentFastPropertyValue(
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 
639 private:
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
655 public:
656 #else
657 protected:
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
666 
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 {
687 public:
692  explicit OPropertySetHelper2(
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
701  virtual void SAL_CALL enableChangeListenerNotification( sal_Bool bEnable ) SAL_OVERRIDE;
702 
703 
704 private:
706  OPropertySetHelper2 & operator = ( const OPropertySetHelper2 & )
708 
709 #if defined _MSC_VER // public -> protected changes mangled names there
710 public:
711 #else
712 protected:
713 #endif
714 // Suppress warning about virtual functions but non-virtual destructor:
718  virtual ~OPropertySetHelper2();
719 };
720 
721 } // end namespace cppuhelper
722 #endif
723 
724 
725 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Any queryInterface(const css::uno::Type &rType, Interface1 *p1)
Compares demanded type to given template argument types.
Definition: queryinterface.hxx:39
#define SAL_OVERRIDE
C++11 "override" feature.
Definition: types.h:409
~IEventNotificationHook()
Definition: propshlp.hxx:338
OMultiTypeInterfaceContainerHelperInt32 aVetoableLC
Container for the XPropertyVetoableListener.
Definition: propshlp.hxx:631
You can use this helper class to map a XPropertySet-Interface to a XFast- or a XMultiPropertySet inte...
Definition: propshlp.hxx:112
virtual void fireEvents(sal_Int32 *pnHandles, sal_Int32 nCount, sal_Bool bVetoable, bool bIgnoreRuntimeExceptionsWhileFiring)=0
Method to be called by OPropertySetHelper::fire.
void * m_pReserved
reserved for future use.
Definition: propshlp.hxx:189
This abstract class maps the methods of the interfaces XMultiPropertySet, XFastPropertySet and XPrope...
Definition: propshlp.hxx:358
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition: types.h:396
Definition: propshlp.hxx:213
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:578
OBroadcastHelper & rBHelper
The common data of a broadcaster.
Definition: propshlp.hxx:623
SAL_DLLPUBLIC void * rtl_allocateMemory(sal_Size Bytes) SAL_THROW_EXTERN_C()
Allocate memory.
A container of interfaces.
Definition: interfacecontainer.h:128
OMultiTypeInterfaceContainerHelperInt32 aBoundLC
Container for the XPropertyChangedListener.
Definition: propshlp.hxx:627
This interface is used by the OPropertyHelper, to access the property description.
Definition: propshlp.hxx:46
unsigned char sal_Bool
Definition: types.h:38
Impl *const m_pReserved
reserved for future use.
Definition: propshlp.hxx:633
A mutual exclusion synchronization object.
Definition: mutex.hxx:31
An interface to extend event notification actions.
Definition: propshlp.hxx:304
Definition: propshlp.hxx:207
Definition: Enterable.hxx:26
size_t operator()(const sal_Int32 &i) const
Definition: propshlp.hxx:215
sal_Int32 keyType
Definition: propshlp.hxx:292
OPropertySetHelper plus XPropertySetOption.
Definition: propshlp.hxx:684
Specialized class for key type sal_Int32, without explicit usage of STL symbols.
Definition: propshlp.hxx:222
#define CPPUHELPER_DLLPUBLIC
Definition: cppuhelperdllapi.h:28
bool operator()(const sal_Int32 &i1, const sal_Int32 &i2) const
Definition: propshlp.hxx:209
This String class provides base functionality for C++ like Unicode character array handling...
Definition: ustring.hxx:126
SAL_DLLPUBLIC void rtl_freeMemory(void *Ptr) SAL_THROW_EXTERN_C()
Free memory.
This struct contains the standard variables of a broadcaster.
Definition: interfacecontainer.h:436