xref: /AOO41X/main/comphelper/inc/comphelper/composedprops.hxx (revision 9877b273795ec465a3ce9c15d738eb34c0455705)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _COMPHELPER_COMPOSEDPROPS_HXX_
25 #define _COMPHELPER_COMPOSEDPROPS_HXX_
26 
27 #include <cppuhelper/implbase2.hxx>
28 #include <comphelper/types.hxx>
29 #include <comphelper/stl_types.hxx>
30 #include <com/sun/star/beans/XPropertySet.hpp>
31 #include <com/sun/star/beans/XPropertyState.hpp>
32 #include <com/sun/star/beans/XPropertySetInfo.hpp>
33 #include <osl/mutex.hxx>
34 #include "comphelper/comphelperdllapi.h"
35 
36 //.........................................................................
37 namespace comphelper
38 {
39 //.........................................................................
40     //=====================================================================
41     //= IPropertySetComposerCallback
42     //=====================================================================
43     class IPropertySetComposerCallback
44     {
45     public:
46         /** determines whether or not a property should appear in the composed property set
47             @param  _rPropertyName
48                 the name of the property
49         */
50         virtual sal_Bool isComposeable(const ::rtl::OUString& _rPropertyName) const = 0;
51     };
52 
53     //=====================================================================
54     //= OComposedPropertySet
55     //=====================================================================
56     class OComposedPropertySetInfo;
57     typedef ::cppu::WeakImplHelper2 <   ::com::sun::star::beans::XPropertySet
58                                     ,   ::com::sun::star::beans::XPropertyState
59                                     >   OComposedPropertySet_Base;
60     /** helper class for composing a property set from a sequence of other property sets.
61         <p>First: This class is a fast shot, so don't sue me :) (To be honest, it's the migration of an old ugly
62         implementation. It's still ugly).</p>
63         <p>The property listener mechanisms are not supported (you can't add property listeners).</p>
64         <p>Speaking strictly, the property defaults (getPropertyDefault) do not work correctly, as there's always
65         an empty <type scope="com.sun.star.uno">Any</type> returned.</p>
66     */
67     class COMPHELPER_DLLPUBLIC OComposedPropertySet : public OComposedPropertySet_Base
68     {
69     private:
70         ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >
71                                     m_aProperties;
72         OComposedPropertySetInfo*   m_pInfo;
73 
74     protected:
75         ::osl::Mutex                m_aMutex;
76         DECLARE_STL_VECTOR(::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>, PropertySetArray);
77         PropertySetArray            m_aSingleSets;
78 
79     public:
80         /** constructs a composed property set
81 
82             @param _rElements
83                 the single property sets to compose
84                 <p>The first property set in the sequence is the master set, any properties not present here
85                 are not present in the composed set.<br/>
86                 This may change in the future (as it's just missing implementation), so don't rely on this behaviour.</p>
87 
88             @param _pPropertyMetaData
89                 the callback for retrieving property meta data (namely composeability)<br/>
90                 if not specified, all properties are assumed to be composable
91         */
92         OComposedPropertySet(
93             const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> > & _rElements,
94             const IPropertySetComposerCallback* _pPropertyMetaData = NULL
95             );
96 
97         // XPropertyState
98         virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
99         virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > SAL_CALL getPropertyStates( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
100         virtual void SAL_CALL setPropertyToDefault( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
101         virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( const ::rtl::OUString& aPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
102 
103         // XPropertySet
104         virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException);
105         virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) 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);
106         virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
107         virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
108         virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
109         virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
110         virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
111 
112     protected:
113                         ~OComposedPropertySet();
114         void            compose(const IPropertySetComposerCallback* _pMetaData);
115     };
116 
117 //.........................................................................
118 }   // namespace comphelper
119 //.........................................................................
120 
121 #endif // _COMPHELPER_COMPOSEDPROPS_HXX_
122 
123 
124