LibreOffice
LibreOffice 4.4 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 
32 #include <memory>
34 
35 
36 namespace cppu
37 {
38 
39 
40 /*************************************************************************
41 *************************************************************************/
42 
43 
48 {
49 public:
50  // these are here to force memory de/allocation to sal lib.
51  inline static void * SAL_CALL operator new( size_t nSize )
52  { return ::rtl_allocateMemory( nSize ); }
53  inline static void SAL_CALL operator delete( void * pMem )
54  { ::rtl_freeMemory( pMem ); }
55  inline static void * SAL_CALL operator new( size_t, void * pMem )
56  { return pMem; }
57  inline static void SAL_CALL operator delete( void *, void * )
58  {}
59 
63  virtual ~IPropertyArrayHelper();
64 
76  virtual sal_Bool SAL_CALL fillPropertyMembersByHandle(
77  ::rtl::OUString * pPropName, sal_Int16 * pAttributes, sal_Int32 nHandle ) = 0;
81  virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > SAL_CALL getProperties(void) = 0;
87  virtual ::com::sun::star::beans::Property SAL_CALL getPropertyByName(
88  const ::rtl::OUString& rPropertyName )
89  throw (::com::sun::star::beans::UnknownPropertyException) = 0;
94  virtual sal_Bool SAL_CALL hasPropertyByName(const ::rtl::OUString& rPropertyName) = 0;
100  virtual sal_Int32 SAL_CALL getHandleByName( const ::rtl::OUString & rPropertyName ) = 0;
106  virtual sal_Int32 SAL_CALL fillHandles(
107  /*out*/ sal_Int32 * pHandles, const ::com::sun::star::uno::Sequence< ::rtl::OUString > & rPropNames ) = 0;
108 };
109 
115 {
116 public:
126  ::com::sun::star::beans::Property *pProps,
127  sal_Int32 nElements ,
128  sal_Bool bSorted = sal_True );
129 
137  const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > & aProps,
138  sal_Bool bSorted = sal_True );
139 
143  sal_Int32 SAL_CALL getCount() const;
156  virtual sal_Bool SAL_CALL fillPropertyMembersByHandle(
157  ::rtl::OUString * pPropName, sal_Int16 * pAttributes, sal_Int32 nHandle ) SAL_OVERRIDE;
161  virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > SAL_CALL getProperties(void) SAL_OVERRIDE;
167  virtual ::com::sun::star::beans::Property SAL_CALL getPropertyByName(
168  const ::rtl::OUString& rPropertyName )
169  throw (::com::sun::star::beans::UnknownPropertyException) SAL_OVERRIDE;
174  virtual sal_Bool SAL_CALL hasPropertyByName(const ::rtl::OUString& rPropertyName) SAL_OVERRIDE;
180  virtual sal_Int32 SAL_CALL getHandleByName( const ::rtl::OUString & rPropertyName ) SAL_OVERRIDE;
186  virtual sal_Int32 SAL_CALL fillHandles(
187  /*out*/sal_Int32 * pHandles, const ::com::sun::star::uno::Sequence< ::rtl::OUString > & rPropNames ) SAL_OVERRIDE;
188 
189 protected:
192  void * m_pReserved;
193 
194 private:
195  void init( sal_Bool bSorted );
196 
199 
204  sal_Bool bRightOrdered;
205 };
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 };
226 {
227 public:
228  // these are here to force memory de/allocation to sal lib.
229  inline static void * SAL_CALL operator new( size_t nSize )
230  { return ::rtl_allocateMemory( nSize ); }
231  inline static void SAL_CALL operator delete( void * pMem )
232  { ::rtl_freeMemory( pMem ); }
233  inline static void * SAL_CALL operator new( size_t, void * pMem )
234  { return pMem; }
235  inline static void SAL_CALL operator delete( void *, void * )
236  {}
237 
250 
254  ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL getContainedTypes() const;
255 
261  OInterfaceContainerHelper * SAL_CALL getContainer( const sal_Int32 & rKey ) const;
262 
270  sal_Int32 SAL_CALL addInterface(
271  const sal_Int32 & rKey,
272  const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & r );
273 
281  sal_Int32 SAL_CALL removeInterface(
282  const sal_Int32 & rKey,
283  const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & rxIFace );
284 
289  void SAL_CALL disposeAndClear( const ::com::sun::star::lang::EventObject & rEvt );
293  void SAL_CALL clear();
294 
295  typedef sal_Int32 keyType;
296 private:
297  void *m_pMap;
298  ::osl::Mutex & rMutex;
299 
302 };
303 
304 
308 {
309 public:
332  virtual void fireEvents(
333  sal_Int32 * pnHandles,
334  sal_Int32 nCount,
335  sal_Bool bVetoable,
336  bool bIgnoreRuntimeExceptionsWhileFiring) = 0;
337 
338 #if !defined _MSC_VER // public -> protected changes mangled names there
339 protected:
340 #endif
342  // avoid warnings about virtual members and non-virtual dtor
343 };
344 
345 
346 
360  public ::com::sun::star::beans::XMultiPropertySet,
361  public ::com::sun::star::beans::XFastPropertySet,
362  public ::com::sun::star::beans::XPropertySet
363 {
364 public:
371  OPropertySetHelper( OBroadcastHelper & rBHelper );
372 
392  OBroadcastHelper & rBHelper, bool bIgnoreRuntimeExceptionsWhileFiring );
393 
416  OBroadcastHelper & rBHelper,
417  IEventNotificationHook *i_pFireEvents,
418  bool bIgnoreRuntimeExceptionsWhileFiring = false);
419 
424  virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType )
425  throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
426 
430  throw(::com::sun::star::uno::RuntimeException);
431 
438  void SAL_CALL disposing();
439 
445  virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& rPropertyName, const ::com::sun::star::uno::Any& aValue )
446  throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
451  virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(const ::rtl::OUString& aPropertyName)
452  throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
454  virtual void SAL_CALL addPropertyChangeListener(
455  const ::rtl::OUString& aPropertyName,
456  const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener)
457  throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
458 
460  virtual void SAL_CALL removePropertyChangeListener(
461  const ::rtl::OUString& aPropertyName,
462  const ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertyChangeListener >& aListener)
463  throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
464 
466  virtual void SAL_CALL addVetoableChangeListener(
467  const ::rtl::OUString& aPropertyName,
468  const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener)
469  throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
470 
472  virtual void SAL_CALL removeVetoableChangeListener(
473  const ::rtl::OUString& aPropertyName,
474  const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener > & aListener )
475  throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
476 
484  virtual void SAL_CALL setFastPropertyValue( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue )
485  throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
486 
491  virtual ::com::sun::star::uno::Any SAL_CALL getFastPropertyValue( sal_Int32 nHandle )
492  throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
493 
494  // XMultiPropertySet
495  virtual void SAL_CALL setPropertyValues(
496  const ::com::sun::star::uno::Sequence< ::rtl::OUString >& PropertyNames,
497  const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Values )
498  throw(::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
499 
500  virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL getPropertyValues(
501  const ::com::sun::star::uno::Sequence< ::rtl::OUString >& PropertyNames )
502  throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
503 
504  virtual void SAL_CALL addPropertiesChangeListener(
505  const ::com::sun::star::uno::Sequence< ::rtl::OUString >& PropertyNames,
506  const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& Listener )
507  throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
508 
509  virtual void SAL_CALL removePropertiesChangeListener(
510  const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& Listener )
511  throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
512 
513  virtual void SAL_CALL firePropertiesChangeEvent(
514  const ::com::sun::star::uno::Sequence< ::rtl::OUString >& PropertyNames,
515  const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener > & Listener )
516  throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
517 
521  static ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySetInfo > SAL_CALL
522  createPropertySetInfo( IPropertyArrayHelper & rProperties );
523 protected:
533  void SAL_CALL fire(
534  sal_Int32 * pnHandles,
535  const ::com::sun::star::uno::Any * pNewValues,
536  const ::com::sun::star::uno::Any * pOldValues,
537  sal_Int32 nCount,
538  sal_Bool bVetoable );
539 
549  void SAL_CALL setFastPropertyValues(
550  sal_Int32 nSeqLen,
551  sal_Int32 * pHandles,
552  const ::com::sun::star::uno::Any * pValues,
553  sal_Int32 nHitCount );
554 
559  virtual IPropertyArrayHelper & SAL_CALL getInfoHelper() = 0;
560 
573  virtual sal_Bool SAL_CALL convertFastPropertyValue(
574  ::com::sun::star::uno::Any & rConvertedValue,
575  ::com::sun::star::uno::Any & rOldValue,
576  sal_Int32 nHandle,
577  const ::com::sun::star::uno::Any& rValue )
578  throw (css::lang::IllegalArgumentException,
579  css::beans::UnknownPropertyException,
580  css::uno::RuntimeException, std::exception) = 0;
581 
600  virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
601  sal_Int32 nHandle,
602  const ::com::sun::star::uno::Any& rValue )
603  throw (::com::sun::star::uno::Exception,
604  std::exception) = 0;
610  virtual void SAL_CALL getFastPropertyValue(
611  ::com::sun::star::uno::Any& rValue,
612  sal_Int32 nHandle ) const = 0;
613 
632  void setDependentFastPropertyValue(
633  sal_Int32 i_handle,
634  const ::com::sun::star::uno::Any& i_value
635  );
636 
647 
648  class Impl;
649 
652  const std::auto_ptr<Impl> m_pReserved;
653 
654 private:
656  OPropertySetHelper & operator = ( const OPropertySetHelper & );
657 
661  void impl_fireAll(
662  sal_Int32* i_handles,
663  const ::com::sun::star::uno::Any * i_newValues,
664  const ::com::sun::star::uno::Any * i_oldValues,
665  sal_Int32 i_count
666  );
667 
668 #if defined _MSC_VER // public -> protected changes mangled names there
669 public:
670 #else
671 protected:
672 #endif
673 // Suppress warning about virtual functions but non-virtual destructor:
674 #if defined _MSC_VER
675 #pragma warning(push)
676 #pragma warning(disable: 4265)
677 #endif
678 
682 };
683 #if defined _MSC_VER
684 #pragma warning(pop)
685 #endif
686 
691  public ::com::sun::star::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 ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType )
705  throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
706 
707  // XPropertySetOption
708  virtual void SAL_CALL enableChangeListenerNotification( sal_Bool bEnable )
709  throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
710 
711 
712 
713 private:
715  OPropertySetHelper2 & operator = ( const OPropertySetHelper2 & );
716 
717 #if defined _MSC_VER // public -> protected changes mangled names there
718 public:
719 #else
720 protected:
721 #endif
722 // Suppress warning about virtual functions but non-virtual destructor:
726  virtual ~OPropertySetHelper2();
727 };
728 
729 } // end namespace cppuhelper
730 #endif
731 
732 
733 
734 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This interface is used by the OPropertyHelper, to access the property description.
Definition: propshlp.hxx:47
unsigned char sal_Bool
Definition: types.h:48
sal_Int32 keyType
Definition: propshlp.hxx:295
OPropertySetHelper plus XPropertySetOption.
Definition: propshlp.hxx:690
bool operator()(const sal_Int32 &i1, const sal_Int32 &i2) const
Definition: propshlp.hxx:213
You can use this helper class to map a XPropertySet-Interface to a XFast- or a XMultiPropertySet inte...
Definition: propshlp.hxx:114
Definition: Enterable.hxx:26
A mutual exclusion synchronization object.
Definition: mutex.hxx:30
const std::auto_ptr< Impl > m_pReserved
reserved for future use.
Definition: propshlp.hxx:648
An interface to extend event notification actions.
Definition: propshlp.hxx:307
SAL_DLLPUBLIC void rtl_freeMemory(void *Ptr) SAL_THROW_EXTERN_C()
Free memory.
This abstract class maps the methods of the interfaces XMultiPropertySet, XFastPropertySet and XPrope...
Definition: propshlp.hxx:359
#define sal_True
Definition: types.h:50
~IEventNotificationHook()
Definition: propshlp.hxx:341
Definition: propshlp.hxx:211
void * m_pReserved
reserved for future use.
Definition: propshlp.hxx:192
C++ class representing an IDL any.
Definition: Any.h:49
#define CPPUHELPER_DLLPUBLIC
Definition: cppuhelperdllapi.h:28
A container of interfaces.
Definition: interfacecontainer.h:120
OBroadcastHelper & rBHelper
The common data of a broadcaster.
Definition: propshlp.hxx:638
OMultiTypeInterfaceContainerHelperInt32 aVetoableLC
Container for the XPropertyVetoableListener.
Definition: propshlp.hxx:646
This String class provides base functionality for C++ like Unicode character array handling...
Definition: ustring.hxx:81
Specialized class for key type sal_Int32, without explicit usage of STL symbols.
Definition: propshlp.hxx:225
This struct contains the standard variables of a broadcaster.
Definition: interfacecontainer.h:427
virtual void fireEvents(sal_Int32 *pnHandles, sal_Int32 nCount, sal_Bool bVetoable, bool bIgnoreRuntimeExceptionsWhileFiring)=0
Method to be called by OPropertySetHelper::fire.
#define SAL_OVERRIDE
C++11 "override" feature.
Definition: types.h:407
SAL_DLLPUBLIC void * rtl_allocateMemory(sal_Size Bytes) SAL_THROW_EXTERN_C()
Allocate memory.
size_t operator()(const sal_Int32 &i) const
Definition: propshlp.hxx:219
inline::com::sun::star::uno::Any queryInterface(const ::com::sun::star::uno::Type &rType, Interface1 *p1)
Compares demanded type to given template argument types.
Definition: queryinterface.hxx:39
Definition: propshlp.hxx:217
OMultiTypeInterfaceContainerHelperInt32 aBoundLC
Container for the XProperyChangedListener.
Definition: propshlp.hxx:642