xref: /aoo4110/main/sc/inc/afmtuno.hxx (revision b1cdbd2c)
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 SC_AFMTUNO_HXX
25 #define SC_AFMTUNO_HXX
26 
27 #include <svl/lstner.hxx>
28 #include <svl/itemprop.hxx>
29 #include <com/sun/star/lang/XServiceInfo.hpp>
30 #include <com/sun/star/container/XContainer.hpp>
31 #include <com/sun/star/container/XIndexContainer.hpp>
32 #include <com/sun/star/container/XNameReplace.hpp>
33 #include <com/sun/star/container/XContainerListener.hpp>
34 #include <com/sun/star/container/XSet.hpp>
35 #include <com/sun/star/container/ContainerEvent.hpp>
36 #include <com/sun/star/container/XIndexReplace.hpp>
37 #include <com/sun/star/container/XNameContainer.hpp>
38 #include <com/sun/star/container/XNamed.hpp>
39 #include <com/sun/star/beans/XPropertySet.hpp>
40 #include <com/sun/star/lang/XUnoTunnel.hpp>
41 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
42 #include <cppuhelper/implbase2.hxx>
43 #include <cppuhelper/implbase4.hxx>
44 #include <cppuhelper/implbase6.hxx>
45 
46 class ScAutoFormatFieldObj;
47 class ScAutoFormatObj;
48 
49 
50 #define SC_AFMTOBJ_INVALID	USHRT_MAX
51 
52 
53 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
54 	ScAutoFormatsObj_CreateInstance(
55 		const ::com::sun::star::uno::Reference<
56 			::com::sun::star::lang::XMultiServiceFactory >& );
57 
58 
59 class ScAutoFormatsObj : public ::cppu::WeakImplHelper4<
60 							::com::sun::star::container::XNameContainer,
61 							::com::sun::star::container::XEnumerationAccess,
62 							::com::sun::star::container::XIndexAccess,
63 							::com::sun::star::lang::XServiceInfo >
64 {
65 private:
66 	ScAutoFormatObj*		GetObjectByIndex_Impl(sal_uInt16 nIndex);
67 	ScAutoFormatObj*		GetObjectByName_Impl(const ::rtl::OUString& aName);
68 
69 public:
70 							ScAutoFormatsObj();
71 	virtual					~ScAutoFormatsObj();
72 
73 	static ::rtl::OUString	getImplementationName_Static();
74 	static ::com::sun::star::uno::Sequence< ::rtl::OUString> getSupportedServiceNames_Static();
75 
76 							// XNameContainer
77 	virtual void SAL_CALL	insertByName( const ::rtl::OUString& aName,
78 								const ::com::sun::star::uno::Any& aElement )
79 									throw(::com::sun::star::lang::IllegalArgumentException,
80 										::com::sun::star::container::ElementExistException,
81 										::com::sun::star::lang::WrappedTargetException,
82 										::com::sun::star::uno::RuntimeException);
83 	virtual void SAL_CALL	removeByName( const ::rtl::OUString& Name )
84 								throw(::com::sun::star::container::NoSuchElementException,
85 									::com::sun::star::lang::WrappedTargetException,
86 									::com::sun::star::uno::RuntimeException);
87 
88 							// XNameReplace
89 	virtual void SAL_CALL	replaceByName( const ::rtl::OUString& aName,
90 								const ::com::sun::star::uno::Any& aElement )
91 									throw(::com::sun::star::lang::IllegalArgumentException,
92 										::com::sun::star::container::NoSuchElementException,
93 										::com::sun::star::lang::WrappedTargetException,
94 										::com::sun::star::uno::RuntimeException);
95 
96 							// XNameAccess
97 	virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName )
98 								throw(::com::sun::star::container::NoSuchElementException,
99 									::com::sun::star::lang::WrappedTargetException,
100 									::com::sun::star::uno::RuntimeException);
101 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames()
102 								throw(::com::sun::star::uno::RuntimeException);
103 	virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName )
104 								throw(::com::sun::star::uno::RuntimeException);
105 
106 							// XElementAccess
107 	virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
108 								throw(::com::sun::star::uno::RuntimeException);
109 	virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
110 
111 							// XEnumerationAccess
112 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL
113 							createEnumeration() throw(::com::sun::star::uno::RuntimeException);
114 
115 							// XIndexAccess
116 	virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException);
117 	virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index )
118 								throw(::com::sun::star::lang::IndexOutOfBoundsException,
119 									::com::sun::star::lang::WrappedTargetException,
120 									::com::sun::star::uno::RuntimeException);
121 
122 							// XServiceInfo
123 	virtual ::rtl::OUString SAL_CALL getImplementationName()
124 								throw(::com::sun::star::uno::RuntimeException);
125 	virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
126 								throw(::com::sun::star::uno::RuntimeException);
127 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
128 								throw(::com::sun::star::uno::RuntimeException);
129 };
130 
131 
132 class ScAutoFormatObj : public ::cppu::WeakImplHelper6<
133 							::com::sun::star::container::XIndexAccess,
134 							::com::sun::star::container::XEnumerationAccess,
135 							::com::sun::star::container::XNamed,
136 							::com::sun::star::beans::XPropertySet,
137 							::com::sun::star::lang::XUnoTunnel,
138 							::com::sun::star::lang::XServiceInfo >,
139 						public SfxListener
140 {
141 private:
142 	SfxItemPropertySet		aPropSet;
143 	sal_uInt16					nFormatIndex;
144 
145 	ScAutoFormatFieldObj*	GetObjectByIndex_Impl(sal_uInt16 nIndex);
146 
147 public:
148 							ScAutoFormatObj(sal_uInt16 nIndex);
149 	virtual					~ScAutoFormatObj();
150 
151 	virtual void			Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
152 
153 							// per getImplementation gerufen:
IsInserted() const154 	sal_Bool				IsInserted() const		{ return nFormatIndex != SC_AFMTOBJ_INVALID; }
155 	void					InitFormat( sal_uInt16 nNewIndex );
156 
157 							// XIndexAccess
158 	virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException);
159 	virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index )
160 								throw(::com::sun::star::lang::IndexOutOfBoundsException,
161 									::com::sun::star::lang::WrappedTargetException,
162 									::com::sun::star::uno::RuntimeException);
163 
164 							// XElementAccess
165 	virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
166 								throw(::com::sun::star::uno::RuntimeException);
167 	virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
168 
169 							// XEnumerationAccess
170 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL
171 							createEnumeration() throw(::com::sun::star::uno::RuntimeException);
172 
173 							// XNamed
174 	virtual ::rtl::OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
175 	virtual void SAL_CALL	setName( const ::rtl::OUString& aName )
176 								throw(::com::sun::star::uno::RuntimeException);
177 
178 							// XPropertySet
179 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
180 							SAL_CALL getPropertySetInfo()
181 								throw(::com::sun::star::uno::RuntimeException);
182 	virtual void SAL_CALL	setPropertyValue( const ::rtl::OUString& aPropertyName,
183 									const ::com::sun::star::uno::Any& aValue )
184 								throw(::com::sun::star::beans::UnknownPropertyException,
185 									::com::sun::star::beans::PropertyVetoException,
186 									::com::sun::star::lang::IllegalArgumentException,
187 									::com::sun::star::lang::WrappedTargetException,
188 									::com::sun::star::uno::RuntimeException);
189 	virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
190 									const ::rtl::OUString& PropertyName )
191 								throw(::com::sun::star::beans::UnknownPropertyException,
192 									::com::sun::star::lang::WrappedTargetException,
193 									::com::sun::star::uno::RuntimeException);
194 	virtual void SAL_CALL	addPropertyChangeListener( const ::rtl::OUString& aPropertyName,
195 									const ::com::sun::star::uno::Reference<
196 										::com::sun::star::beans::XPropertyChangeListener >& xListener )
197 								throw(::com::sun::star::beans::UnknownPropertyException,
198 									::com::sun::star::lang::WrappedTargetException,
199 									::com::sun::star::uno::RuntimeException);
200 	virtual void SAL_CALL	removePropertyChangeListener( const ::rtl::OUString& aPropertyName,
201 									const ::com::sun::star::uno::Reference<
202 										::com::sun::star::beans::XPropertyChangeListener >& aListener )
203 								throw(::com::sun::star::beans::UnknownPropertyException,
204 									::com::sun::star::lang::WrappedTargetException,
205 									::com::sun::star::uno::RuntimeException);
206 	virtual void SAL_CALL	addVetoableChangeListener( const ::rtl::OUString& PropertyName,
207 									const ::com::sun::star::uno::Reference<
208 										::com::sun::star::beans::XVetoableChangeListener >& aListener )
209 								throw(::com::sun::star::beans::UnknownPropertyException,
210 									::com::sun::star::lang::WrappedTargetException,
211 									::com::sun::star::uno::RuntimeException);
212 	virtual void SAL_CALL	removeVetoableChangeListener( const ::rtl::OUString& PropertyName,
213 									const ::com::sun::star::uno::Reference<
214 										::com::sun::star::beans::XVetoableChangeListener >& aListener )
215 								throw(::com::sun::star::beans::UnknownPropertyException,
216 									::com::sun::star::lang::WrappedTargetException,
217 									::com::sun::star::uno::RuntimeException);
218 
219 							// XServiceInfo
220 	virtual ::rtl::OUString SAL_CALL getImplementationName()
221 								throw(::com::sun::star::uno::RuntimeException);
222 	virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
223 								throw(::com::sun::star::uno::RuntimeException);
224 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
225 								throw(::com::sun::star::uno::RuntimeException);
226 
227 							// XUnoTunnel
228 	virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence<
229 									sal_Int8 >& aIdentifier )
230 								throw(::com::sun::star::uno::RuntimeException);
231 
232 	static const ::com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId();
233 	static ScAutoFormatObj* getImplementation( const ::com::sun::star::uno::Reference<
234 									::com::sun::star::uno::XInterface> xObj );
235 };
236 
237 
238 class ScAutoFormatFieldObj : public ::cppu::WeakImplHelper2<
239 								::com::sun::star::beans::XPropertySet,
240 								::com::sun::star::lang::XServiceInfo >,
241 							public SfxListener
242 {
243 private:
244 	SfxItemPropertySet		aPropSet;
245 	sal_uInt16					nFormatIndex;
246 	sal_uInt16					nFieldIndex;
247 
248 public:
249 							ScAutoFormatFieldObj(sal_uInt16 nFormat, sal_uInt16 nField);
250 	virtual					~ScAutoFormatFieldObj();
251 
252 	virtual void			Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
253 
254 							// XPropertySet
255 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
256 							SAL_CALL getPropertySetInfo()
257 								throw(::com::sun::star::uno::RuntimeException);
258 	virtual void SAL_CALL	setPropertyValue( const ::rtl::OUString& aPropertyName,
259 									const ::com::sun::star::uno::Any& aValue )
260 								throw(::com::sun::star::beans::UnknownPropertyException,
261 									::com::sun::star::beans::PropertyVetoException,
262 									::com::sun::star::lang::IllegalArgumentException,
263 									::com::sun::star::lang::WrappedTargetException,
264 									::com::sun::star::uno::RuntimeException);
265 	virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
266 									const ::rtl::OUString& PropertyName )
267 								throw(::com::sun::star::beans::UnknownPropertyException,
268 									::com::sun::star::lang::WrappedTargetException,
269 									::com::sun::star::uno::RuntimeException);
270 	virtual void SAL_CALL	addPropertyChangeListener( const ::rtl::OUString& aPropertyName,
271 									const ::com::sun::star::uno::Reference<
272 										::com::sun::star::beans::XPropertyChangeListener >& xListener )
273 								throw(::com::sun::star::beans::UnknownPropertyException,
274 									::com::sun::star::lang::WrappedTargetException,
275 									::com::sun::star::uno::RuntimeException);
276 	virtual void SAL_CALL	removePropertyChangeListener( const ::rtl::OUString& aPropertyName,
277 									const ::com::sun::star::uno::Reference<
278 										::com::sun::star::beans::XPropertyChangeListener >& aListener )
279 								throw(::com::sun::star::beans::UnknownPropertyException,
280 									::com::sun::star::lang::WrappedTargetException,
281 									::com::sun::star::uno::RuntimeException);
282 	virtual void SAL_CALL	addVetoableChangeListener( const ::rtl::OUString& PropertyName,
283 									const ::com::sun::star::uno::Reference<
284 										::com::sun::star::beans::XVetoableChangeListener >& aListener )
285 								throw(::com::sun::star::beans::UnknownPropertyException,
286 									::com::sun::star::lang::WrappedTargetException,
287 									::com::sun::star::uno::RuntimeException);
288 	virtual void SAL_CALL	removeVetoableChangeListener( const ::rtl::OUString& PropertyName,
289 									const ::com::sun::star::uno::Reference<
290 										::com::sun::star::beans::XVetoableChangeListener >& aListener )
291 								throw(::com::sun::star::beans::UnknownPropertyException,
292 									::com::sun::star::lang::WrappedTargetException,
293 									::com::sun::star::uno::RuntimeException);
294 
295 							// XServiceInfo
296 	virtual ::rtl::OUString SAL_CALL getImplementationName()
297 								throw(::com::sun::star::uno::RuntimeException);
298 	virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
299 								throw(::com::sun::star::uno::RuntimeException);
300 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
301 								throw(::com::sun::star::uno::RuntimeException);
302 };
303 
304 
305 #endif
306 
307