LibreOffice
LibreOffice 5.3 SDK C/C++ API Reference
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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  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 
114 {
115 public:
125  css::beans::Property *pProps,
126  sal_Int32 nElements ,
127  sal_Bool bSorted = true );
128 
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 
210 {
211  bool operator()(const sal_Int32 & i1 , const sal_Int32 & i2) const
212  { return i1 == i2; }
213 };
214 
216 {
217  size_t operator()(const sal_Int32 & i) const
218  { return i; }
219 };
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 
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 
299  OMultiTypeInterfaceContainerHelperInt32 & operator = ( const OMultiTypeInterfaceContainerHelperInt32 & )SAL_DELETED_FUNCTION;
300 };
301 
302 
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
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 {
367 public:
374  OPropertySetHelper( OBroadcastHelper & rBHelper );
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 )
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 
650 
651  class Impl;
652 
655  Impl * const m_pReserved;
656 
657 private:
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 
690 };
691 #if defined _MSC_VER
692 #if defined __clang__
693 #pragma clang diagnostic pop
694 #endif
695 #pragma warning(pop)
696 #endif
697 
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:
729  OPropertySetHelper2 & operator = ( const OPropertySetHelper2 & )
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: */
sal_Int32 keyType
Definition: propshlp.hxx:293
OPropertySetHelper plus XPropertySetOption.
Definition: propshlp.hxx:705
size_t operator()(const sal_Int32 &i) const
Definition: propshlp.hxx:217
You can use this helper class to map a XPropertySet-Interface to a XFast- or a XMultiPropertySet inte...
Definition: propshlp.hxx:113
A mutual exclusion synchronization object.
Definition: mutex.hxx:30
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition: types.h:410
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:651
SAL_DLLPUBLIC void rtl_freeMemory(void *Ptr) SAL_THROW_EXTERN_C()
Free memory.
Definition: propshlp.hxx:209
#define SAL_OVERRIDE
C++11 &quot;override&quot; feature.
Definition: types.h:423
This abstract class maps the methods of the interfaces XMultiPropertySet, XFastPropertySet and XPrope...
Definition: propshlp.hxx:362
unsigned char sal_Bool
Definition: types.h:48
Definition: propshlp.hxx:215
void * m_pReserved
reserved for future use.
Definition: propshlp.hxx:191
bool operator()(const sal_Int32 &i1, const sal_Int32 &i2) const
Definition: propshlp.hxx:211
#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:641
OMultiTypeInterfaceContainerHelperInt32 aVetoableLC
Container for the XPropertyVetoableListener.
Definition: propshlp.hxx:649
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:106
Specialized class for key type sal_Int32, without explicit usage of STL symbols.
Definition: propshlp.hxx:223
~IEventNotificationHook()
Definition: propshlp.hxx:342
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:305
OMultiTypeInterfaceContainerHelperInt32 aBoundLC
Container for the XProperyChangedListener.
Definition: propshlp.hxx:645