1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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_CHAINABLEPROPERTYSET_HXX
21 #define INCLUDED_COMPHELPER_CHAINABLEPROPERTYSET_HXX
23 #include <com/sun/star/beans/XPropertySet.hpp>
24 #include <com/sun/star/beans/XPropertyState.hpp>
25 #include <com/sun/star/beans/XMultiPropertySet.hpp>
26 #include <com/sun/star/lang/XServiceInfo.hpp>
27 #include <comphelper/comphelperdllapi.h>
28 #include <cppuhelper/implbase.hxx>
29 #include <rtl/ref.hxx>
31 namespace comphelper
{ class SolarMutex
; }
32 namespace comphelper
{ struct PropertyInfo
; }
36 class ChainablePropertySetInfo
;
40 * A ChainablePropertySet has the following features:
42 * 1. It implements both the PropertySet and MultiPropertySet interfaces.
43 * 2. It can be 'included' in a MasterPropertySet to seamlessly appear as if
44 * if it's properties were in the master.
46 * To be used as a base class for PropertySets, the subclass must implement
47 * the 6 protected pure virtual functions. If a mutex is passed to the
48 * constructor, this is locked before any call to _getSingleValue or
49 * _setSingleValue and released after all processing has completed
50 * (including _postSetValues or _postGetValues )
52 * Any MasterPropertySet implementations that can include an
53 * implementation of a given ChainablePropertySet must be
54 * declared as a 'friend' in the implementation of the ChainablePropertySet.
60 typedef cppu::WeakImplHelper
62 css::beans::XPropertySet
,
63 css::beans::XMultiPropertySet
,
64 css::lang::XServiceInfo
66 ChainablePropertySetBase
;
67 class COMPHELPER_DLLPUBLIC ChainablePropertySet
: public ChainablePropertySetBase
,
68 public css::beans::XPropertyState
70 friend class MasterPropertySet
;
72 SolarMutex
* const mpMutex
;
73 rtl::Reference
< ChainablePropertySetInfo
> mxInfo
;
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 _preSetValues () = 0;
81 /// @throws css::beans::UnknownPropertyException
82 /// @throws css::beans::PropertyVetoException
83 /// @throws css::lang::IllegalArgumentException
84 /// @throws css::lang::WrappedTargetException
85 /// @throws css::uno::RuntimeException
86 virtual void _setSingleValue(const comphelper::PropertyInfo
& rInfo
, const css::uno::Any
&rValue
) = 0;
87 /// @throws css::beans::UnknownPropertyException
88 /// @throws css::beans::PropertyVetoException
89 /// @throws css::lang::IllegalArgumentException
90 /// @throws css::lang::WrappedTargetException
91 /// @throws css::uno::RuntimeException
92 virtual void _postSetValues () = 0;
94 /// @throws css::beans::UnknownPropertyException
95 /// @throws css::beans::PropertyVetoException
96 /// @throws css::lang::IllegalArgumentException
97 /// @throws css::lang::WrappedTargetException
98 /// @throws css::uno::RuntimeException
99 virtual void _preGetValues () = 0;
100 /// @throws css::beans::UnknownPropertyException
101 /// @throws css::lang::WrappedTargetException
102 /// @throws css::uno::RuntimeException
103 virtual void _getSingleValue( const comphelper::PropertyInfo
& rInfo
, css::uno::Any
& rValue
) = 0;
104 /// @throws css::beans::UnknownPropertyException
105 /// @throws css::beans::PropertyVetoException
106 /// @throws css::lang::IllegalArgumentException
107 /// @throws css::lang::WrappedTargetException
108 virtual void _postGetValues () = 0;
111 ChainablePropertySet( comphelper::ChainablePropertySetInfo
* pInfo
, SolarMutex
* pMutex
)
113 virtual ~ChainablePropertySet()
116 css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& aType
) override
117 { return ChainablePropertySetBase::queryInterface( aType
); }
118 void SAL_CALL
acquire( ) noexcept override
119 { ChainablePropertySetBase::acquire( ); }
120 void SAL_CALL
release( ) noexcept override
121 { ChainablePropertySetBase::release( ); }
124 virtual css::uno::Reference
< css::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo( ) override
;
125 virtual void SAL_CALL
setPropertyValue( const OUString
& aPropertyName
, const css::uno::Any
& aValue
) override
;
126 virtual css::uno::Any SAL_CALL
getPropertyValue( const OUString
& PropertyName
) override
;
127 virtual void SAL_CALL
addPropertyChangeListener( const OUString
& aPropertyName
, const css::uno::Reference
< css::beans::XPropertyChangeListener
>& xListener
) override
;
128 virtual void SAL_CALL
removePropertyChangeListener( const OUString
& aPropertyName
, const css::uno::Reference
< css::beans::XPropertyChangeListener
>& aListener
) override
;
129 virtual void SAL_CALL
addVetoableChangeListener( const OUString
& PropertyName
, const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
) override
;
130 virtual void SAL_CALL
removeVetoableChangeListener( const OUString
& PropertyName
, const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
) override
;
133 virtual void SAL_CALL
setPropertyValues( const css::uno::Sequence
< OUString
>& aPropertyNames
, const css::uno::Sequence
< css::uno::Any
>& aValues
) override
;
134 virtual css::uno::Sequence
< css::uno::Any
> SAL_CALL
getPropertyValues( const css::uno::Sequence
< OUString
>& aPropertyNames
) override
;
135 virtual void SAL_CALL
addPropertiesChangeListener( const css::uno::Sequence
< OUString
>& aPropertyNames
, const css::uno::Reference
< css::beans::XPropertiesChangeListener
>& xListener
) override
;
136 virtual void SAL_CALL
removePropertiesChangeListener( const css::uno::Reference
< css::beans::XPropertiesChangeListener
>& xListener
) override
;
137 virtual void SAL_CALL
firePropertiesChangeEvent( const css::uno::Sequence
< OUString
>& aPropertyNames
, const css::uno::Reference
< css::beans::XPropertiesChangeListener
>& xListener
) override
;
140 virtual css::beans::PropertyState SAL_CALL
getPropertyState( const OUString
& PropertyName
) override
;
141 virtual css::uno::Sequence
< css::beans::PropertyState
> SAL_CALL
getPropertyStates( const css::uno::Sequence
< OUString
>& aPropertyName
) override
;
142 virtual void SAL_CALL
setPropertyToDefault( const OUString
& PropertyName
) override
;
143 virtual css::uno::Any SAL_CALL
getPropertyDefault( const OUString
& aPropertyName
) override
;
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */