LibreOffice Module comphelper (master)  1
MasterPropertySet.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_COMPHELPER_MASTERPROPERTYSET_HXX
21 #define INCLUDED_COMPHELPER_MASTERPROPERTYSET_HXX
22 #include <com/sun/star/beans/XPropertySet.hpp>
23 #include <com/sun/star/beans/XPropertyState.hpp>
24 #include <com/sun/star/beans/XMultiPropertySet.hpp>
27 #include <rtl/ref.hxx>
28 #include <map>
29 
30 namespace comphelper { class SolarMutex; }
31 namespace comphelper { struct PropertyInfo; }
32 
33 namespace comphelper
34 {
35  class MasterPropertySetInfo;
36  class ChainablePropertySet;
37  struct SlaveData
38  {
40  bool mbInit;
41 
43  bool IsInit () const { return mbInit;}
44  void SetInit ( bool bInit) { mbInit = bInit; }
45  };
46 }
47 
48 /*
49  * A MasterPropertySet implements all of the features of a ChainablePropertySet
50  * (it is not inherited from ChainablePropertySet to prevent MasterPropertySets
51  * being chained to each other), but also allows properties implemented in
52  * other ChainablePropertySets to be included as 'native' properties in a
53  * given MasterPropertySet implementation. These are registered using the
54  * 'registerSlave' method, and require that the implementation of the
55  * ChainablePropertySet and the implementation of the ChainablePropertySetInfo
56  * both declare the implementation of the MasterPropertySet as a friend.
57  */
58 namespace comphelper
59 {
60  class COMPHELPER_DLLPUBLIC MasterPropertySet : public css::beans::XPropertySet,
61  public css::beans::XPropertyState,
62  public css::beans::XMultiPropertySet
63  {
64  protected:
67  std::map< sal_uInt8, comphelper::SlaveData* > maSlaveMap;
69 
74  virtual void _preSetValues () = 0;
80  virtual void _setSingleValue( const comphelper::PropertyInfo & rInfo, const css::uno::Any &rValue ) = 0;
85  virtual void _postSetValues () = 0;
86 
91  virtual void _preGetValues () = 0;
95  virtual void _getSingleValue( const comphelper::PropertyInfo & rInfo, css::uno::Any & rValue ) = 0;
100  virtual void _postGetValues () = 0;
101 
102  public:
104  throw();
105  virtual ~MasterPropertySet()
106  throw();
107  void registerSlave ( ChainablePropertySet *pNewSet )
108  throw();
109 
110  // XPropertySet
111  virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override;
112  virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override;
113  virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
114  virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
115  virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
116  virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
117  virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
118 
119  // XMultiPropertySet
120  virtual void SAL_CALL setPropertyValues( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Sequence< css::uno::Any >& aValues ) override;
121  virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyValues( const css::uno::Sequence< OUString >& aPropertyNames ) override;
122  virtual void SAL_CALL addPropertiesChangeListener( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
123  virtual void SAL_CALL removePropertiesChangeListener( const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
124  virtual void SAL_CALL firePropertiesChangeEvent( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
125 
126  // XPropertyState
127  virtual css::beans::PropertyState SAL_CALL getPropertyState( const OUString& PropertyName ) override;
128  virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates( const css::uno::Sequence< OUString >& aPropertyName ) override;
129  virtual void SAL_CALL setPropertyToDefault( const OUString& PropertyName ) override;
130  virtual css::uno::Any SAL_CALL getPropertyDefault( const OUString& aPropertyName ) override;
131  };
132 }
133 #endif
134 
135 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::map< sal_uInt8, comphelper::SlaveData * > maSlaveMap
SlaveData(ChainablePropertySet *pSlave)
void SetInit(bool bInit)
rtl::Reference< MasterPropertySetInfo > mxInfo
unsigned char sal_uInt8
#define COMPHELPER_DLLPUBLIC
SolarMutex, needed for VCL's Application::GetSolarMutex().
Definition: solarmutex.hxx:46
rtl::Reference< ChainablePropertySet > mxSlave