xref: /aoo41x/main/basic/source/inc/propacc.hxx (revision 234bd5c5)
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 #ifndef _SFX_PROPBAG_HXX
24 #define _SFX_PROPBAG_HXX
25 
26 #include <svl/svarray.hxx>
27 #ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HXX_
28 #include <com/sun/star/beans/PropertyValue.hpp>
29 #endif
30 #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HXX_
31 #include <com/sun/star/beans/XPropertySet.hpp>
32 #endif
33 #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSETINFO_HXX_
34 #include <com/sun/star/beans/XPropertySetInfo.hpp>
35 #endif
36 #ifndef _COM_SUN_STAR_BEANS_XPROPERTYACCESS_HXX_
37 #include <com/sun/star/beans/XPropertyAccess.hpp>
38 #endif
39 #ifndef _COM_SUN_STAR_BEANS_XPROPERTYCONTAINER_HXX_
40 #include <com/sun/star/beans/XPropertyContainer.hpp>
41 #endif
42 #include <cppuhelper/implbase1.hxx>
43 #include <cppuhelper/implbase2.hxx>
44 
45 #define NS_BEANS	::com::sun::star::beans
46 #define NS_LANG		::com::sun::star::lang
47 #define NS_UNO		::com::sun::star::uno
48 
49 typedef NS_BEANS::PropertyValue* SbPropertyValuePtr;
50 SV_DECL_PTRARR( SbPropertyValueArr_Impl, SbPropertyValuePtr, 4, 4 )
51 
52 typedef ::cppu::WeakImplHelper2< NS_BEANS::XPropertySet,
53 								 NS_BEANS::XPropertyAccess > SbPropertyValuesHelper;
54 
55 
56 //==========================================================================
57 
58 class SbPropertyValues: 	public SbPropertyValuesHelper
59 {
60 	SbPropertyValueArr_Impl	_aPropVals;
61 	NS_UNO::Reference< ::com::sun::star::beans::XPropertySetInfo > _xInfo;
62 
63 private:
64 	sal_Int32 					GetIndex_Impl( const ::rtl::OUString &rPropName ) const;
65 
66 public:
67 							SbPropertyValues();
68 	virtual					~SbPropertyValues();
69 
70 	// XPropertySet
71 	virtual NS_UNO::Reference< NS_BEANS::XPropertySetInfo > SAL_CALL
72 		getPropertySetInfo(void) throw( NS_UNO::RuntimeException );
73 	virtual void SAL_CALL	setPropertyValue(
74 								const ::rtl::OUString& aPropertyName,
75 								const NS_UNO::Any& aValue)
76                                 throw (::com::sun::star::beans::UnknownPropertyException,
77                                 ::com::sun::star::beans::PropertyVetoException,
78                                 ::com::sun::star::lang::IllegalArgumentException,
79                                 ::com::sun::star::lang::WrappedTargetException,
80                                 ::com::sun::star::uno::RuntimeException);
81     virtual NS_UNO::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName )
82 		throw(	NS_BEANS::UnknownPropertyException,
83 				NS_LANG::WrappedTargetException,
84 				NS_UNO::RuntimeException);
85 	virtual void SAL_CALL	addPropertyChangeListener(
86 								const ::rtl::OUString& aPropertyName,
87 								const NS_UNO::Reference< NS_BEANS::XPropertyChangeListener >& )
88                                 throw ();
89 	virtual void SAL_CALL	removePropertyChangeListener(
90 								const ::rtl::OUString& aPropertyName,
91 								const NS_UNO::Reference< NS_BEANS::XPropertyChangeListener >& )
92                                 throw ();
93 	virtual void SAL_CALL	addVetoableChangeListener(
94 								const ::rtl::OUString& aPropertyName,
95 								const NS_UNO::Reference< NS_BEANS::XVetoableChangeListener >& )
96                                 throw ();
97 	virtual void SAL_CALL	removeVetoableChangeListener(
98 								const ::rtl::OUString& aPropertyName,
99 								const NS_UNO::Reference< NS_BEANS::XVetoableChangeListener >& )
100                                 throw ();
101 
102 	// XPropertyAccess
103 	virtual NS_UNO::Sequence< NS_BEANS::PropertyValue > SAL_CALL getPropertyValues(void) throw (::com::sun::star::uno::RuntimeException);
104 	virtual void SAL_CALL setPropertyValues(const NS_UNO::Sequence< NS_BEANS::PropertyValue >& PropertyValues_) 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);
105 };
106 
107 //==========================================================================
108 
109 typedef ::cppu::WeakImplHelper1< NS_BEANS::XPropertySetInfo > SbPropertySetInfoHelper;
110 
111 // AB 20.3.2000 Help Class for XPropertySetInfo implementation
112 class PropertySetInfoImpl
113 {
114 	friend class SbPropertySetInfo;
115 	friend class SbPropertyContainer;
116 
117 	NS_UNO::Sequence< NS_BEANS::Property > _aProps;
118 
119 	sal_Int32 GetIndex_Impl( const ::rtl::OUString &rPropName ) const;
120 
121 public:
122 	PropertySetInfoImpl();
123 	PropertySetInfoImpl( NS_UNO::Sequence< NS_BEANS::Property >& rProps );
124 
125 	// XPropertySetInfo
126 	NS_UNO::Sequence< NS_BEANS::Property > SAL_CALL getProperties(void) throw ();
127 	NS_BEANS::Property SAL_CALL getPropertyByName(const ::rtl::OUString& Name)
128 		throw( NS_UNO::RuntimeException );
129 	sal_Bool SAL_CALL hasPropertyByName(const ::rtl::OUString& Name)
130 		throw ( NS_UNO::RuntimeException );
131 };
132 
133 class SbPropertySetInfo: 	public SbPropertySetInfoHelper
134 {
135 	PropertySetInfoImpl aImpl;
136 
137 public:
138 							SbPropertySetInfo();
139 							SbPropertySetInfo( const SbPropertyValueArr_Impl &rPropVals );
140 	virtual					~SbPropertySetInfo();
141 
142 	// XPropertySetInfo
143 	virtual NS_UNO::Sequence< NS_BEANS::Property > SAL_CALL getProperties(void)
144 		throw( NS_UNO::RuntimeException );
145 	virtual NS_BEANS::Property SAL_CALL getPropertyByName(const ::rtl::OUString& Name)
146 		throw( NS_UNO::RuntimeException );
147 	virtual sal_Bool SAL_CALL hasPropertyByName(const ::rtl::OUString& Name)
148 		throw( NS_UNO::RuntimeException );
149 };
150 
151 //==========================================================================
152 
153 typedef ::cppu::WeakImplHelper2< NS_BEANS::XPropertySetInfo, NS_BEANS::XPropertyContainer > SbPropertyContainerHelper;
154 
155 class SbPropertyContainer: public SbPropertyContainerHelper
156 {
157 	PropertySetInfoImpl aImpl;
158 
159 public:
160 							SbPropertyContainer();
161 	virtual					~SbPropertyContainer();
162 
163 	// XPropertyContainer
164     virtual void SAL_CALL addProperty(	const ::rtl::OUString& Name,
165 										sal_Int16 Attributes,
166 										const NS_UNO::Any& DefaultValue)
167 		throw(  NS_BEANS::PropertyExistException, NS_BEANS::IllegalTypeException,
168 				NS_LANG::IllegalArgumentException, NS_UNO::RuntimeException );
169     virtual void SAL_CALL removeProperty(const ::rtl::OUString& Name)
170 		throw( NS_BEANS::UnknownPropertyException, NS_UNO::RuntimeException );
171 
172 	// XPropertySetInfo
173 	virtual NS_UNO::Sequence< NS_BEANS::Property > SAL_CALL getProperties(void) throw();
174 	virtual NS_BEANS::Property SAL_CALL getPropertyByName(const ::rtl::OUString& Name)
175 		throw( NS_UNO::RuntimeException );
176 	virtual sal_Bool SAL_CALL hasPropertyByName(const ::rtl::OUString& Name)
177 		throw( NS_UNO::RuntimeException );
178 
179 	// XPropertyAccess
180 	virtual NS_UNO::Sequence< NS_BEANS::PropertyValue > SAL_CALL getPropertyValues(void);
181 	virtual void SAL_CALL setPropertyValues(const NS_UNO::Sequence< NS_BEANS::PropertyValue >& PropertyValues_);
182 };
183 
184 //=========================================================================
185 
186 class StarBASIC;
187 class SbxArray;
188 
189 void RTL_Impl_CreatePropertySet( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite );
190 
191 
192 #undef NS_BEANS
193 #undef NS_LANG
194 #undef NS_UNO
195 
196 
197 
198 #endif
199 
200