xref: /aoo42x/main/sc/inc/styleuno.hxx (revision 38d50f7b)
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_STYLEUNO_HXX
25 #define SC_STYLEUNO_HXX
26 
27 #include <svl/itemprop.hxx>
28 #include <svl/lstner.hxx>
29 #include <rsc/rscsfx.hxx>
30 #include <com/sun/star/container/XIndexAccess.hpp>
31 #include <com/sun/star/style/XStyle.hpp>
32 #include <com/sun/star/style/XStyleLoader.hpp>
33 #include <com/sun/star/lang/XServiceInfo.hpp>
34 #include <com/sun/star/container/XNameContainer.hpp>
35 #include <com/sun/star/container/XIndexReplace.hpp>
36 #include <com/sun/star/beans/XPropertySet.hpp>
37 #include <com/sun/star/beans/XMultiPropertySet.hpp>
38 #include <com/sun/star/beans/XPropertyState.hpp>
39 #include <com/sun/star/beans/XMultiPropertyStates.hpp>
40 #include <com/sun/star/lang/XUnoTunnel.hpp>
41 //#include <cppuhelper/implbase3.hxx>
42 #include <cppuhelper/implbase4.hxx>
43 #include <cppuhelper/implbase7.hxx>
44 
45 class SfxStyleSheetBase;
46 class ScDocShell;
47 
48 class ScStyleFamilyObj;
49 class ScStyleObj;
50 
51 
52 class ScStyleNameConversion
53 {
54 public:
55 	static String DisplayToProgrammaticName( const String& rDispName, sal_uInt16 nType );
56 	static String ProgrammaticToDisplayName( const String& rProgName, sal_uInt16 nType );
57 };
58 
59 
60 class ScStyleFamiliesObj : public ::cppu::WeakImplHelper4<
61 							::com::sun::star::container::XIndexAccess,
62 							::com::sun::star::container::XNameAccess,
63 							::com::sun::star::style::XStyleLoader,
64                             ::com::sun::star::lang::XServiceInfo >,
65 						public SfxListener
66 {
67 private:
68 	ScDocShell*				pDocShell;
69 
70 	ScStyleFamilyObj*		GetObjectByType_Impl(sal_uInt16 Type) const;
71 	ScStyleFamilyObj*		GetObjectByIndex_Impl(sal_uInt32 nIndex) const;
72 	ScStyleFamilyObj*		GetObjectByName_Impl(const rtl::OUString& aName) const;
73 
74 public:
75 							ScStyleFamiliesObj(ScDocShell* pDocSh);
76 	virtual					~ScStyleFamiliesObj();
77 
78 	virtual void			Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
79 
80 							// XIndexAccess
81 	virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException);
82 	virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index )
83 								throw(::com::sun::star::lang::IndexOutOfBoundsException,
84 									::com::sun::star::lang::WrappedTargetException,
85 									::com::sun::star::uno::RuntimeException);
86 
87 							// XNameAccess
88 	virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName )
89 								throw(::com::sun::star::container::NoSuchElementException,
90 									::com::sun::star::lang::WrappedTargetException,
91 									::com::sun::star::uno::RuntimeException);
92 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames()
93 								throw(::com::sun::star::uno::RuntimeException);
94 	virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName )
95 								throw(::com::sun::star::uno::RuntimeException);
96 
97 							// XElementAccess
98 	virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
99 								throw(::com::sun::star::uno::RuntimeException);
100 	virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
101 
102 							// XStyleLoader
103 	virtual void SAL_CALL	loadStylesFromURL( const ::rtl::OUString& URL,
104 								const ::com::sun::star::uno::Sequence<
105 									::com::sun::star::beans::PropertyValue >& aOptions )
106 										throw(::com::sun::star::io::IOException,
107 											::com::sun::star::uno::RuntimeException);
108 	virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL
109 							getStyleLoaderOptions() throw(::com::sun::star::uno::RuntimeException);
110 
111 							// XServiceInfo
112 	virtual ::rtl::OUString SAL_CALL getImplementationName()
113 								throw(::com::sun::star::uno::RuntimeException);
114 	virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
115 								throw(::com::sun::star::uno::RuntimeException);
116 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
117 								throw(::com::sun::star::uno::RuntimeException);
118 };
119 
120 
121 class ScStyleFamilyObj : public ::cppu::WeakImplHelper4<
122 							::com::sun::star::container::XNameContainer,
123                             ::com::sun::star::container::XIndexAccess,
124                             ::com::sun::star::beans::XPropertySet,
125 							::com::sun::star::lang::XServiceInfo >,
126 						public SfxListener
127 {
128 private:
129 	ScDocShell*				pDocShell;
130 	SfxStyleFamily 			eFamily;		// Familie
131 
132 	ScStyleObj*				GetObjectByIndex_Impl(sal_uInt32 nIndex);
133 	ScStyleObj*				GetObjectByName_Impl(const rtl::OUString& Name);
134 
135 public:
136 							ScStyleFamilyObj(ScDocShell* pDocSh, SfxStyleFamily eFam);
137 	virtual					~ScStyleFamilyObj();
138 
139 	virtual void			Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
140 
141 							// XNameContainer
142 	virtual void SAL_CALL	insertByName( const ::rtl::OUString& aName,
143 								const ::com::sun::star::uno::Any& aElement )
144 									throw(::com::sun::star::lang::IllegalArgumentException,
145 										::com::sun::star::container::ElementExistException,
146 										::com::sun::star::lang::WrappedTargetException,
147 										::com::sun::star::uno::RuntimeException);
148 	virtual void SAL_CALL	removeByName( const ::rtl::OUString& Name )
149 								throw(::com::sun::star::container::NoSuchElementException,
150 									::com::sun::star::lang::WrappedTargetException,
151 									::com::sun::star::uno::RuntimeException);
152 
153 							// XNameReplace
154 	virtual void SAL_CALL	replaceByName( const ::rtl::OUString& aName,
155 								const ::com::sun::star::uno::Any& aElement )
156 									throw(::com::sun::star::lang::IllegalArgumentException,
157 										::com::sun::star::container::NoSuchElementException,
158 										::com::sun::star::lang::WrappedTargetException,
159 										::com::sun::star::uno::RuntimeException);
160 
161 							// XNameAccess
162 	virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName )
163 								throw(::com::sun::star::container::NoSuchElementException,
164 									::com::sun::star::lang::WrappedTargetException,
165 									::com::sun::star::uno::RuntimeException);
166 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames()
167 								throw(::com::sun::star::uno::RuntimeException);
168 	virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName )
169 								throw(::com::sun::star::uno::RuntimeException);
170 
171 							// XIndexAccess
172 	virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException);
173 	virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index )
174 								throw(::com::sun::star::lang::IndexOutOfBoundsException,
175 									::com::sun::star::lang::WrappedTargetException,
176 									::com::sun::star::uno::RuntimeException);
177 
178 							// XElementAccess
179 	virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
180 								throw(::com::sun::star::uno::RuntimeException);
181 	virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
182 
183                             // XPropertySet
184     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo()
185                                 throw (::com::sun::star::uno::RuntimeException);
186     virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue )
187                                 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);
188     virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName )
189                                 throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
190     virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener )
191                                 throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
192     virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener )
193                                 throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
194     virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener )
195                                 throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
196     virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener )
197                                 throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
198 
199                             // XServiceInfo
200 	virtual ::rtl::OUString SAL_CALL getImplementationName()
201 								throw(::com::sun::star::uno::RuntimeException);
202 	virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
203 								throw(::com::sun::star::uno::RuntimeException);
204 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
205 								throw(::com::sun::star::uno::RuntimeException);
206 };
207 
208 
209 class ScStyleObj : public ::cppu::WeakImplHelper7<
210 					::com::sun::star::style::XStyle,
211 					::com::sun::star::beans::XPropertySet,
212 					::com::sun::star::beans::XMultiPropertySet,
213 					::com::sun::star::beans::XPropertyState,
214 					::com::sun::star::beans::XMultiPropertyStates,
215 					::com::sun::star::lang::XUnoTunnel,
216 					::com::sun::star::lang::XServiceInfo >,
217 				public SfxListener
218 {
219 private:
220 	const SfxItemPropertySet* pPropSet;
221 	ScDocShell*				pDocShell;
222 	SfxStyleFamily 			eFamily;		// Familie
223 	String 					aStyleName;
224 
225 	SfxStyleSheetBase*		GetStyle_Impl();
226     const SfxItemSet*       GetStyleItemSet_Impl( const ::rtl::OUString& rPropName, const SfxItemPropertySimpleEntry*& rpEntry );
227     void                    SetOnePropertyValue(    const ::rtl::OUString& rPropertyName,
228                                                     const SfxItemPropertySimpleEntry* pEntry,
229 													const ::com::sun::star::uno::Any* pValue )
230 											throw(::com::sun::star::lang::IllegalArgumentException,
231 													::com::sun::star::uno::RuntimeException);
232 
233 	ScStyleObj(); // disabled
234 public:
235 							ScStyleObj(ScDocShell* pDocSh, SfxStyleFamily eFam, const String& rName);
236 	virtual					~ScStyleObj();
237 
238 							// per getImplementation gerufen:
239 	sal_Bool				IsInserted() const		{ return pDocShell != NULL; }
240 	SfxStyleFamily 			GetFamily() const 		{ return eFamily; }
241 	void					InitDoc( ScDocShell* pNewDocSh, const String& rNewName );
242 
243 	virtual void			Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
244 
245 	static ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexReplace >
246 							CreateEmptyNumberingRules();
247 
248 							// XStyle
249 	virtual sal_Bool SAL_CALL isUserDefined() throw(::com::sun::star::uno::RuntimeException);
250 	virtual sal_Bool SAL_CALL isInUse() throw(::com::sun::star::uno::RuntimeException);
251 	virtual ::rtl::OUString	SAL_CALL getParentStyle() throw(::com::sun::star::uno::RuntimeException);
252 	virtual void SAL_CALL	setParentStyle( const ::rtl::OUString& aParentStyle )
253 								throw(::com::sun::star::container::NoSuchElementException,
254 									::com::sun::star::uno::RuntimeException);
255 
256 							// XNamed
257 	virtual ::rtl::OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
258 	virtual void SAL_CALL	setName( const ::rtl::OUString& aName )
259 								throw(::com::sun::star::uno::RuntimeException);
260 
261 							// XPropertySet
262 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
263 							SAL_CALL getPropertySetInfo()
264 								throw(::com::sun::star::uno::RuntimeException);
265 	virtual void SAL_CALL	setPropertyValue( const ::rtl::OUString& aPropertyName,
266 									const ::com::sun::star::uno::Any& aValue )
267 								throw(::com::sun::star::beans::UnknownPropertyException,
268 									::com::sun::star::beans::PropertyVetoException,
269 									::com::sun::star::lang::IllegalArgumentException,
270 									::com::sun::star::lang::WrappedTargetException,
271 									::com::sun::star::uno::RuntimeException);
272 	virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
273 									const ::rtl::OUString& PropertyName )
274 								throw(::com::sun::star::beans::UnknownPropertyException,
275 									::com::sun::star::lang::WrappedTargetException,
276 									::com::sun::star::uno::RuntimeException);
277 	virtual void SAL_CALL	addPropertyChangeListener( const ::rtl::OUString& aPropertyName,
278 									const ::com::sun::star::uno::Reference<
279 										::com::sun::star::beans::XPropertyChangeListener >& xListener )
280 								throw(::com::sun::star::beans::UnknownPropertyException,
281 									::com::sun::star::lang::WrappedTargetException,
282 									::com::sun::star::uno::RuntimeException);
283 	virtual void SAL_CALL	removePropertyChangeListener( const ::rtl::OUString& aPropertyName,
284 									const ::com::sun::star::uno::Reference<
285 										::com::sun::star::beans::XPropertyChangeListener >& aListener )
286 								throw(::com::sun::star::beans::UnknownPropertyException,
287 									::com::sun::star::lang::WrappedTargetException,
288 									::com::sun::star::uno::RuntimeException);
289 	virtual void SAL_CALL	addVetoableChangeListener( const ::rtl::OUString& PropertyName,
290 									const ::com::sun::star::uno::Reference<
291 										::com::sun::star::beans::XVetoableChangeListener >& aListener )
292 								throw(::com::sun::star::beans::UnknownPropertyException,
293 									::com::sun::star::lang::WrappedTargetException,
294 									::com::sun::star::uno::RuntimeException);
295 	virtual void SAL_CALL	removeVetoableChangeListener( const ::rtl::OUString& PropertyName,
296 									const ::com::sun::star::uno::Reference<
297 										::com::sun::star::beans::XVetoableChangeListener >& aListener )
298 								throw(::com::sun::star::beans::UnknownPropertyException,
299 									::com::sun::star::lang::WrappedTargetException,
300 									::com::sun::star::uno::RuntimeException);
301 
302 							// XMultiPropertySet
303 	virtual void SAL_CALL	setPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames,
304 									const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aValues )
305 								throw (::com::sun::star::beans::PropertyVetoException,
306 									::com::sun::star::lang::IllegalArgumentException,
307 									::com::sun::star::lang::WrappedTargetException,
308 									::com::sun::star::uno::RuntimeException);
309 	virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL
310 							getPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames )
311 								throw (::com::sun::star::uno::RuntimeException);
312 	virtual void SAL_CALL addPropertiesChangeListener( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames,
313 									const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener )
314 								throw (::com::sun::star::uno::RuntimeException);
315 	virtual void SAL_CALL removePropertiesChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener )
316 								throw (::com::sun::star::uno::RuntimeException);
317 	virtual void SAL_CALL firePropertiesChangeEvent( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames,
318 									const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener )
319 								throw (::com::sun::star::uno::RuntimeException);
320 
321 							// XPropertyState
322 	virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState(
323 									const ::rtl::OUString& PropertyName )
324 								throw(::com::sun::star::beans::UnknownPropertyException,
325 									::com::sun::star::uno::RuntimeException);
326 	virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > SAL_CALL
327 							getPropertyStates( const ::com::sun::star::uno::Sequence<
328 										::rtl::OUString >& aPropertyName )
329 								throw(::com::sun::star::beans::UnknownPropertyException,
330 									::com::sun::star::uno::RuntimeException);
331 	virtual void SAL_CALL	setPropertyToDefault( const ::rtl::OUString& PropertyName )
332 								throw(::com::sun::star::beans::UnknownPropertyException,
333 									::com::sun::star::uno::RuntimeException);
334 	virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault(
335 									const ::rtl::OUString& aPropertyName )
336 								throw(::com::sun::star::beans::UnknownPropertyException,
337 									::com::sun::star::lang::WrappedTargetException,
338 									::com::sun::star::uno::RuntimeException);
339 
340 							// XMultiPropertyStates
341 	// getPropertyStates already defined for XPropertyState
342 	virtual void SAL_CALL	setAllPropertiesToDefault() throw (::com::sun::star::uno::RuntimeException);
343 	virtual void SAL_CALL	setPropertiesToDefault( const ::com::sun::star::uno::Sequence<
344 										::rtl::OUString >& aPropertyNames )
345 								throw (::com::sun::star::beans::UnknownPropertyException,
346 									::com::sun::star::uno::RuntimeException);
347 	virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL
348 							getPropertyDefaults( const ::com::sun::star::uno::Sequence<
349 										::rtl::OUString >& aPropertyNames )
350 								throw (::com::sun::star::beans::UnknownPropertyException,
351 									::com::sun::star::lang::WrappedTargetException,
352 									::com::sun::star::uno::RuntimeException);
353 
354 							// XServiceInfo
355 	virtual ::rtl::OUString SAL_CALL getImplementationName()
356 								throw(::com::sun::star::uno::RuntimeException);
357 	virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
358 								throw(::com::sun::star::uno::RuntimeException);
359 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
360 								throw(::com::sun::star::uno::RuntimeException);
361 
362 							// XUnoTunnel
363 	virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence<
364 									sal_Int8 >& aIdentifier )
365 								throw(::com::sun::star::uno::RuntimeException);
366 
367 	static const ::com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId();
368 	static ScStyleObj* getImplementation( const ::com::sun::star::uno::Reference<
369 									::com::sun::star::uno::XInterface> xObj );
370 
371 };
372 
373 #endif
374 
375