Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / include / comphelper / MasterPropertySet.hxx
blob867583d646ca11fea1779ff0e0fcc3f7b0c99ed0
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/comphelperdllapi.h>
26 #include <comphelper/ChainablePropertySet.hxx>
27 #include <rtl/ref.hxx>
28 #include <map>
30 namespace comphelper { class SolarMutex; }
31 namespace comphelper { struct PropertyInfo; }
33 namespace comphelper
35 class MasterPropertySetInfo;
36 class ChainablePropertySet;
37 struct SlaveData
39 rtl::Reference < ChainablePropertySet > mxSlave;
40 bool mbInit;
42 SlaveData ( ChainablePropertySet *pSlave);
43 bool IsInit () const { return mbInit;}
44 void SetInit ( bool bInit) { mbInit = bInit; }
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.
58 namespace comphelper
60 class COMPHELPER_DLLPUBLIC MasterPropertySet : public css::beans::XPropertySet,
61 public css::beans::XPropertyState,
62 public css::beans::XMultiPropertySet
64 SolarMutex* const mpMutex;
65 sal_uInt8 mnLastId;
66 std::map< sal_uInt8, comphelper::SlaveData* > maSlaveMap;
67 rtl::Reference< MasterPropertySetInfo > mxInfo;
69 protected:
70 /// @throws css::beans::UnknownPropertyException
71 /// @throws css::beans::PropertyVetoException
72 /// @throws css::lang::IllegalArgumentException
73 /// @throws css::lang::WrappedTargetException
74 virtual void _preSetValues () = 0;
75 /// @throws css::beans::UnknownPropertyException
76 /// @throws css::beans::PropertyVetoException
77 /// @throws css::lang::IllegalArgumentException
78 /// @throws css::lang::WrappedTargetException
79 /// @throws css::uno::RuntimeException
80 virtual void _setSingleValue( const comphelper::PropertyInfo & rInfo, const css::uno::Any &rValue ) = 0;
81 /// @throws css::beans::UnknownPropertyException
82 /// @throws css::beans::PropertyVetoException
83 /// @throws css::lang::IllegalArgumentException
84 /// @throws css::lang::WrappedTargetException
85 virtual void _postSetValues () = 0;
87 /// @throws css::beans::UnknownPropertyException
88 /// @throws css::beans::PropertyVetoException
89 /// @throws css::lang::IllegalArgumentException
90 /// @throws css::lang::WrappedTargetException
91 virtual void _preGetValues () = 0;
92 /// @throws css::beans::UnknownPropertyException
93 /// @throws css::lang::WrappedTargetException
94 /// @throws css::uno::RuntimeException
95 virtual void _getSingleValue( const comphelper::PropertyInfo & rInfo, css::uno::Any & rValue ) = 0;
96 /// @throws css::beans::UnknownPropertyException
97 /// @throws css::beans::PropertyVetoException
98 /// @throws css::lang::IllegalArgumentException
99 /// @throws css::lang::WrappedTargetException
100 virtual void _postGetValues () = 0;
102 public:
103 MasterPropertySet( comphelper::MasterPropertySetInfo* pInfo, SolarMutex* pMutex )
104 noexcept;
105 virtual ~MasterPropertySet()
106 noexcept;
107 void registerSlave ( ChainablePropertySet *pNewSet )
108 noexcept;
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;
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;
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;
133 #endif
135 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */