Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / comphelper / MasterPropertySet.hxx
blob937832488b788891cb0e031ed47340a301e2d49d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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>
25 #include <comphelper/PropertyInfoHash.hxx>
26 #include <comphelper/comphelperdllapi.h>
27 #include <comphelper/solarmutex.hxx>
28 #include <rtl/ref.hxx>
29 #include <map>
31 namespace comphelper
33 class MasterPropertySetInfo;
34 class ChainablePropertySet;
35 struct SlaveData
37 ChainablePropertySet * mpSlave;
38 css::uno::Reference < css::beans::XPropertySet > mxSlave;
39 bool mbInit;
41 SlaveData ( ChainablePropertySet *pSlave);
42 bool IsInit () { return mbInit;}
43 void SetInit ( bool bInit) { mbInit = bInit; }
48 * A MasterPropertySet implements all of the features of a ChainablePropertySet
49 * (it is not inherited from ChainablePropertySet to prevent MasterPropertySets
50 * being chained to each other), but also allows properties implemented in
51 * other ChainablePropertySets to be included as 'native' properties in a
52 * given MasterPropertySet implementation. These are registered using the
53 * 'registerSlave' method, and require that the implementation of the
54 * ChainablePropertySet and the implementation of the ChainablePropertySetInfo
55 * both declare the implementation of the MasterPropertySet as a friend.
57 namespace comphelper
59 class COMPHELPER_DLLPUBLIC MasterPropertySet : public css::beans::XPropertySet,
60 public css::beans::XPropertyState,
61 public css::beans::XMultiPropertySet
63 protected:
64 SolarMutex* mpMutex;
65 sal_uInt8 mnLastId;
66 std::map< sal_uInt8, comphelper::SlaveData* > maSlaveMap;
67 rtl::Reference< MasterPropertySetInfo > mxInfo;
69 /// @throws css::beans::UnknownPropertyException
70 /// @throws css::beans::PropertyVetoException
71 /// @throws css::lang::IllegalArgumentException
72 /// @throws css::lang::WrappedTargetException
73 virtual void _preSetValues () = 0;
74 /// @throws css::beans::UnknownPropertyException
75 /// @throws css::beans::PropertyVetoException
76 /// @throws css::lang::IllegalArgumentException
77 /// @throws css::lang::WrappedTargetException
78 /// @throws css::uno::RuntimeException
79 virtual void _setSingleValue( const comphelper::PropertyInfo & rInfo, const css::uno::Any &rValue ) = 0;
80 /// @throws css::beans::UnknownPropertyException
81 /// @throws css::beans::PropertyVetoException
82 /// @throws css::lang::IllegalArgumentException
83 /// @throws css::lang::WrappedTargetException
84 virtual void _postSetValues () = 0;
86 /// @throws css::beans::UnknownPropertyException
87 /// @throws css::beans::PropertyVetoException
88 /// @throws css::lang::IllegalArgumentException
89 /// @throws css::lang::WrappedTargetException
90 virtual void _preGetValues () = 0;
91 /// @throws css::beans::UnknownPropertyException
92 /// @throws css::lang::WrappedTargetException
93 /// @throws css::uno::RuntimeException
94 virtual void _getSingleValue( const comphelper::PropertyInfo & rInfo, css::uno::Any & rValue ) = 0;
95 /// @throws css::beans::UnknownPropertyException
96 /// @throws css::beans::PropertyVetoException
97 /// @throws css::lang::IllegalArgumentException
98 /// @throws css::lang::WrappedTargetException
99 virtual void _postGetValues () = 0;
101 public:
102 MasterPropertySet( comphelper::MasterPropertySetInfo* pInfo, SolarMutex* pMutex = nullptr )
103 throw();
104 virtual ~MasterPropertySet()
105 throw();
106 void registerSlave ( ChainablePropertySet *pNewSet )
107 throw();
109 // XPropertySet
110 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override;
111 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override;
112 virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
113 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
114 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
115 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
116 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
118 // XMultiPropertySet
119 virtual void SAL_CALL setPropertyValues( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Sequence< css::uno::Any >& aValues ) override;
120 virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyValues( const css::uno::Sequence< OUString >& aPropertyNames ) override;
121 virtual void SAL_CALL addPropertiesChangeListener( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
122 virtual void SAL_CALL removePropertiesChangeListener( const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
123 virtual void SAL_CALL firePropertiesChangeEvent( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
125 // XPropertyState
126 virtual css::beans::PropertyState SAL_CALL getPropertyState( const OUString& PropertyName ) override;
127 virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates( const css::uno::Sequence< OUString >& aPropertyName ) override;
128 virtual void SAL_CALL setPropertyToDefault( const OUString& PropertyName ) override;
129 virtual css::uno::Any SAL_CALL getPropertyDefault( const OUString& aPropertyName ) override;
132 #endif
134 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */