xref: /aoo4110/main/sc/inc/styleuno.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_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     // enhance ODS load performance
234 	bool StyleSheetChangedUpdate();
235 	void SetOnePropertyValueWithoutUpdate(  const ::rtl::OUString& rPropertyName,
236 													const SfxItemPropertySimpleEntry* pEntry,
237 													const ::com::sun::star::uno::Any* pValue )
238 											throw(::com::sun::star::lang::IllegalArgumentException,
239 													::com::sun::star::uno::RuntimeException);
240 	//end add
241 
242 	ScStyleObj(); // disabled
243 public:
244 							ScStyleObj(ScDocShell* pDocSh, SfxStyleFamily eFam, const String& rName);
245 	virtual					~ScStyleObj();
246 
247 							// per getImplementation gerufen:
IsInserted() const248 	sal_Bool				IsInserted() const		{ return pDocShell != NULL; }
GetFamily() const249 	SfxStyleFamily 			GetFamily() const 		{ return eFamily; }
250 	void					InitDoc( ScDocShell* pNewDocSh, const String& rNewName );
251 
252 	virtual void			Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
253 
254 	static ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexReplace >
255 							CreateEmptyNumberingRules();
256 
257 							// XStyle
258 	virtual sal_Bool SAL_CALL isUserDefined() throw(::com::sun::star::uno::RuntimeException);
259 	virtual sal_Bool SAL_CALL isInUse() throw(::com::sun::star::uno::RuntimeException);
260 	virtual ::rtl::OUString	SAL_CALL getParentStyle() throw(::com::sun::star::uno::RuntimeException);
261 	virtual void SAL_CALL	setParentStyle( const ::rtl::OUString& aParentStyle )
262 								throw(::com::sun::star::container::NoSuchElementException,
263 									::com::sun::star::uno::RuntimeException);
264 
265 							// XNamed
266 	virtual ::rtl::OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
267 	virtual void SAL_CALL	setName( const ::rtl::OUString& aName )
268 								throw(::com::sun::star::uno::RuntimeException);
269 
270 							// XPropertySet
271 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
272 							SAL_CALL getPropertySetInfo()
273 								throw(::com::sun::star::uno::RuntimeException);
274 	virtual void SAL_CALL	setPropertyValue( const ::rtl::OUString& aPropertyName,
275 									const ::com::sun::star::uno::Any& aValue )
276 								throw(::com::sun::star::beans::UnknownPropertyException,
277 									::com::sun::star::beans::PropertyVetoException,
278 									::com::sun::star::lang::IllegalArgumentException,
279 									::com::sun::star::lang::WrappedTargetException,
280 									::com::sun::star::uno::RuntimeException);
281 	virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
282 									const ::rtl::OUString& PropertyName )
283 								throw(::com::sun::star::beans::UnknownPropertyException,
284 									::com::sun::star::lang::WrappedTargetException,
285 									::com::sun::star::uno::RuntimeException);
286 	virtual void SAL_CALL	addPropertyChangeListener( const ::rtl::OUString& aPropertyName,
287 									const ::com::sun::star::uno::Reference<
288 										::com::sun::star::beans::XPropertyChangeListener >& xListener )
289 								throw(::com::sun::star::beans::UnknownPropertyException,
290 									::com::sun::star::lang::WrappedTargetException,
291 									::com::sun::star::uno::RuntimeException);
292 	virtual void SAL_CALL	removePropertyChangeListener( const ::rtl::OUString& aPropertyName,
293 									const ::com::sun::star::uno::Reference<
294 										::com::sun::star::beans::XPropertyChangeListener >& aListener )
295 								throw(::com::sun::star::beans::UnknownPropertyException,
296 									::com::sun::star::lang::WrappedTargetException,
297 									::com::sun::star::uno::RuntimeException);
298 	virtual void SAL_CALL	addVetoableChangeListener( const ::rtl::OUString& PropertyName,
299 									const ::com::sun::star::uno::Reference<
300 										::com::sun::star::beans::XVetoableChangeListener >& aListener )
301 								throw(::com::sun::star::beans::UnknownPropertyException,
302 									::com::sun::star::lang::WrappedTargetException,
303 									::com::sun::star::uno::RuntimeException);
304 	virtual void SAL_CALL	removeVetoableChangeListener( const ::rtl::OUString& PropertyName,
305 									const ::com::sun::star::uno::Reference<
306 										::com::sun::star::beans::XVetoableChangeListener >& aListener )
307 								throw(::com::sun::star::beans::UnknownPropertyException,
308 									::com::sun::star::lang::WrappedTargetException,
309 									::com::sun::star::uno::RuntimeException);
310 
311 							// XMultiPropertySet
312 	virtual void SAL_CALL	setPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames,
313 									const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aValues )
314 								throw (::com::sun::star::beans::PropertyVetoException,
315 									::com::sun::star::lang::IllegalArgumentException,
316 									::com::sun::star::lang::WrappedTargetException,
317 									::com::sun::star::uno::RuntimeException);
318 	virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL
319 							getPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames )
320 								throw (::com::sun::star::uno::RuntimeException);
321 	virtual void SAL_CALL addPropertiesChangeListener( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames,
322 									const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener )
323 								throw (::com::sun::star::uno::RuntimeException);
324 	virtual void SAL_CALL removePropertiesChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener )
325 								throw (::com::sun::star::uno::RuntimeException);
326 	virtual void SAL_CALL firePropertiesChangeEvent( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames,
327 									const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener )
328 								throw (::com::sun::star::uno::RuntimeException);
329 
330 							// XPropertyState
331 	virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState(
332 									const ::rtl::OUString& PropertyName )
333 								throw(::com::sun::star::beans::UnknownPropertyException,
334 									::com::sun::star::uno::RuntimeException);
335 	virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > SAL_CALL
336 							getPropertyStates( const ::com::sun::star::uno::Sequence<
337 										::rtl::OUString >& aPropertyName )
338 								throw(::com::sun::star::beans::UnknownPropertyException,
339 									::com::sun::star::uno::RuntimeException);
340 	virtual void SAL_CALL	setPropertyToDefault( const ::rtl::OUString& PropertyName )
341 								throw(::com::sun::star::beans::UnknownPropertyException,
342 									::com::sun::star::uno::RuntimeException);
343 	virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault(
344 									const ::rtl::OUString& aPropertyName )
345 								throw(::com::sun::star::beans::UnknownPropertyException,
346 									::com::sun::star::lang::WrappedTargetException,
347 									::com::sun::star::uno::RuntimeException);
348 
349 							// XMultiPropertyStates
350 	// getPropertyStates already defined for XPropertyState
351 	virtual void SAL_CALL	setAllPropertiesToDefault() throw (::com::sun::star::uno::RuntimeException);
352 	virtual void SAL_CALL	setPropertiesToDefault( const ::com::sun::star::uno::Sequence<
353 										::rtl::OUString >& aPropertyNames )
354 								throw (::com::sun::star::beans::UnknownPropertyException,
355 									::com::sun::star::uno::RuntimeException);
356 	virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL
357 							getPropertyDefaults( const ::com::sun::star::uno::Sequence<
358 										::rtl::OUString >& aPropertyNames )
359 								throw (::com::sun::star::beans::UnknownPropertyException,
360 									::com::sun::star::lang::WrappedTargetException,
361 									::com::sun::star::uno::RuntimeException);
362 
363 							// XServiceInfo
364 	virtual ::rtl::OUString SAL_CALL getImplementationName()
365 								throw(::com::sun::star::uno::RuntimeException);
366 	virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
367 								throw(::com::sun::star::uno::RuntimeException);
368 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
369 								throw(::com::sun::star::uno::RuntimeException);
370 
371 							// XUnoTunnel
372 	virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence<
373 									sal_Int8 >& aIdentifier )
374 								throw(::com::sun::star::uno::RuntimeException);
375 
376 	static const ::com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId();
377 	static ScStyleObj* getImplementation( const ::com::sun::star::uno::Reference<
378 									::com::sun::star::uno::XInterface> xObj );
379 
380 };
381 
382 #endif
383 
384