Branch data Line data Source code
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 _COMPHELPER_MASTERPROPERTYSETHELPER_HXX_
21 : : #define _COMPHELPER_MASTERPROPERTYSETHELPER_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 <map>
28 : :
29 : : namespace comphelper
30 : : {
31 : : class MasterPropertySetInfo;
32 : : class ChainablePropertySet;
33 : 748 : struct SlaveData
34 : : {
35 : : ChainablePropertySet * mpSlave;
36 : : ::com::sun::star::uno::Reference < com::sun::star::beans::XPropertySet > mxSlave;
37 : : sal_Bool mbInit;
38 : : SlaveData ( ChainablePropertySet *pSlave);
39 : 0 : inline sal_Bool IsInit () { return mbInit;}
40 : 0 : inline void SetInit ( sal_Bool bInit) { mbInit = bInit; }
41 : : };
42 : : }
43 : : typedef std::map < sal_uInt8, comphelper::SlaveData* > SlaveMap;
44 : :
45 : : /*
46 : : * A MasterPropertySet implements all of the features of a ChainablePropertySet
47 : : * (it is not inherited from ChainablePropertySet to prevent MasterPropertySets
48 : : * being chained to each other), but also allows properties implemented in
49 : : * other ChainablePropertySets to be included as 'native' properties in a
50 : : * given MasterPropertySet implementation. These are registered using the
51 : : * 'registerSlave' method, and require that the implementation of the
52 : : * ChainablePropertySet and the implementation of the ChainablePropertySetInfo
53 : : * both declare the implementation of the MasterPropertySet as a friend.
54 : : */
55 : : namespace comphelper
56 : : {
57 : : class COMPHELPER_DLLPUBLIC MasterPropertySet : public ::com::sun::star::beans::XPropertySet,
58 : : public ::com::sun::star::beans::XPropertyState,
59 : : public ::com::sun::star::beans::XMultiPropertySet
60 : : {
61 : : protected:
62 : : MasterPropertySetInfo *mpInfo;
63 : : osl::SolarMutex* mpMutex;
64 : : sal_uInt8 mnLastId;
65 : : SlaveMap maSlaveMap;
66 : : ::com::sun::star::uno::Reference < com::sun::star::beans::XPropertySetInfo > mxInfo;
67 : :
68 : : virtual void _preSetValues ()
69 : : throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException ) = 0;
70 : : virtual void _setSingleValue( const comphelper::PropertyInfo & rInfo, const ::com::sun::star::uno::Any &rValue )
71 : : throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException ) = 0;
72 : : virtual void _postSetValues ()
73 : : throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException ) = 0;
74 : :
75 : : virtual void _preGetValues ()
76 : : throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException ) = 0;
77 : : virtual void _getSingleValue( const comphelper::PropertyInfo & rInfo, ::com::sun::star::uno::Any & rValue )
78 : : throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException ) = 0;
79 : : virtual void _postGetValues ()
80 : : throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException ) = 0;
81 : :
82 : : virtual void _preGetPropertyState ()
83 : : throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException );
84 : : virtual void _getPropertyState( const comphelper::PropertyInfo& rInfo, ::com::sun::star::beans::PropertyState& rState )
85 : : throw(::com::sun::star::beans::UnknownPropertyException );
86 : : virtual void _postGetPropertyState ()
87 : : throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException );
88 : :
89 : : virtual void _setPropertyToDefault( const comphelper::PropertyInfo& rEntry )
90 : : throw(::com::sun::star::beans::UnknownPropertyException );
91 : : virtual ::com::sun::star::uno::Any _getPropertyDefault( const comphelper::PropertyInfo& rEntry )
92 : : throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException );
93 : :
94 : : public:
95 : : MasterPropertySet( comphelper::MasterPropertySetInfo* pInfo, ::osl::SolarMutex* pMutex = NULL )
96 : : throw();
97 : : virtual ~MasterPropertySet()
98 : : throw();
99 : : void registerSlave ( ChainablePropertySet *pNewSet )
100 : : throw();
101 : :
102 : : // XPropertySet
103 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( )
104 : : throw(::com::sun::star::uno::RuntimeException);
105 : : virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue )
106 : : 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);
107 : : virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName )
108 : : throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
109 : : virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener )
110 : : throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
111 : : virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener )
112 : : throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
113 : : virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener )
114 : : throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
115 : : virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener )
116 : : throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
117 : :
118 : : // XMultiPropertySet
119 : : virtual void SAL_CALL setPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aValues )
120 : : throw(::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
121 : : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL getPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames )
122 : : throw(::com::sun::star::uno::RuntimeException);
123 : : virtual void SAL_CALL addPropertiesChangeListener( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener )
124 : : throw(::com::sun::star::uno::RuntimeException);
125 : : virtual void SAL_CALL removePropertiesChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener )
126 : : throw(::com::sun::star::uno::RuntimeException);
127 : : virtual void SAL_CALL firePropertiesChangeEvent( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener )
128 : : throw(::com::sun::star::uno::RuntimeException);
129 : :
130 : : // XPropertyState
131 : : virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& PropertyName )
132 : : throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
133 : : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > SAL_CALL getPropertyStates( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyName )
134 : : throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
135 : : virtual void SAL_CALL setPropertyToDefault( const ::rtl::OUString& PropertyName )
136 : : throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
137 : : virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( const ::rtl::OUString& aPropertyName )
138 : : throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
139 : : };
140 : : }
141 : : #endif
142 : :
143 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|