update credits
[LibreOffice.git] / sc / inc / styleuno.hxx
blobb8abfed38bff22600bdd44fbb09f8aa5226d38e2
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SC_INC_STYLEUNO_HXX
21 #define INCLUDED_SC_INC_STYLEUNO_HXX
23 #include <svl/itemprop.hxx>
24 #include <svl/lstner.hxx>
25 #include <rsc/rscsfx.hxx>
26 #include <com/sun/star/container/XIndexAccess.hpp>
27 #include <com/sun/star/style/XStyle.hpp>
28 #include <com/sun/star/style/XStyleLoader2.hpp>
29 #include <com/sun/star/lang/XServiceInfo.hpp>
30 #include <com/sun/star/container/XNameContainer.hpp>
31 #include <com/sun/star/container/XIndexReplace.hpp>
32 #include <com/sun/star/beans/XPropertySet.hpp>
33 #include <com/sun/star/beans/XMultiPropertySet.hpp>
34 #include <com/sun/star/beans/XPropertyState.hpp>
35 #include <com/sun/star/beans/XMultiPropertyStates.hpp>
36 #include <com/sun/star/lang/XUnoTunnel.hpp>
37 #include <cppuhelper/implbase4.hxx>
38 #include <cppuhelper/implbase7.hxx>
39 #include <com/sun/star/lang/XComponent.hpp>
42 class SfxStyleSheetBase;
43 class ScDocShell;
44 class SfxObjectShell;
46 class ScStyleFamilyObj;
47 class ScStyleObj;
49 class ScStyleFamiliesObj : public ::cppu::WeakImplHelper4<
50 ::com::sun::star::container::XIndexAccess,
51 ::com::sun::star::container::XNameAccess,
52 ::com::sun::star::style::XStyleLoader2,
53 ::com::sun::star::lang::XServiceInfo >,
54 public SfxListener
56 private:
57 ScDocShell* pDocShell;
59 ScStyleFamilyObj* GetObjectByType_Impl(sal_uInt16 Type) const;
60 ScStyleFamilyObj* GetObjectByIndex_Impl(sal_uInt32 nIndex) const;
61 ScStyleFamilyObj* GetObjectByName_Impl(const OUString& aName) const;
63 public:
64 ScStyleFamiliesObj(ScDocShell* pDocSh);
65 virtual ~ScStyleFamiliesObj();
67 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) SAL_OVERRIDE;
69 // XIndexAccess
70 virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
71 virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index )
72 throw(::com::sun::star::lang::IndexOutOfBoundsException,
73 ::com::sun::star::lang::WrappedTargetException,
74 ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
76 // XNameAccess
77 virtual ::com::sun::star::uno::Any SAL_CALL getByName( const OUString& aName )
78 throw(::com::sun::star::container::NoSuchElementException,
79 ::com::sun::star::lang::WrappedTargetException,
80 ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
81 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getElementNames()
82 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
83 virtual sal_Bool SAL_CALL hasByName( const OUString& aName )
84 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
86 // XElementAccess
87 virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
88 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
89 virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
91 // XStyleLoader
92 virtual void SAL_CALL loadStylesFromURL( const OUString& URL,
93 const ::com::sun::star::uno::Sequence<
94 ::com::sun::star::beans::PropertyValue >& aOptions )
95 throw(::com::sun::star::io::IOException,
96 ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
97 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL
98 getStyleLoaderOptions() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
100 //XStyleLoader2
101 virtual void SAL_CALL loadStylesFromDocument( const ::com::sun::star::uno::Reference < ::com::sun::star::lang::XComponent > & aSourceComponent,
102 const ::com::sun::star::uno::Sequence<
103 ::com::sun::star::beans::PropertyValue >& aOptions )
104 throw(::com::sun::star::io::IOException,
105 ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
106 // XServiceInfo
107 virtual OUString SAL_CALL getImplementationName()
108 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
109 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
110 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
111 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
112 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
113 private:
114 void loadStylesFromDocShell( ScDocShell* pSource,
115 const ::com::sun::star::uno::Sequence<
116 ::com::sun::star::beans::PropertyValue>& aOptions )
117 throw(::com::sun::star::io::IOException,
118 ::com::sun::star::uno::RuntimeException, std::exception);
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
128 private:
129 ScDocShell* pDocShell;
130 SfxStyleFamily eFamily; // Family
132 ScStyleObj* GetObjectByIndex_Impl(sal_uInt32 nIndex);
133 ScStyleObj* GetObjectByName_Impl(const OUString& Name);
135 public:
136 ScStyleFamilyObj(ScDocShell* pDocSh, SfxStyleFamily eFam);
137 virtual ~ScStyleFamilyObj();
139 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) SAL_OVERRIDE;
141 // XNameContainer
142 virtual void SAL_CALL insertByName( const 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, std::exception) SAL_OVERRIDE;
148 virtual void SAL_CALL removeByName( const OUString& Name )
149 throw(::com::sun::star::container::NoSuchElementException,
150 ::com::sun::star::lang::WrappedTargetException,
151 ::com::sun::star::uno::RuntimeException,
152 std::exception) SAL_OVERRIDE;
154 // XNameReplace
155 virtual void SAL_CALL replaceByName( const OUString& aName,
156 const ::com::sun::star::uno::Any& aElement )
157 throw(::com::sun::star::lang::IllegalArgumentException,
158 ::com::sun::star::container::NoSuchElementException,
159 ::com::sun::star::lang::WrappedTargetException,
160 ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
162 // XNameAccess
163 virtual ::com::sun::star::uno::Any SAL_CALL getByName( const OUString& aName )
164 throw(::com::sun::star::container::NoSuchElementException,
165 ::com::sun::star::lang::WrappedTargetException,
166 ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
167 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getElementNames()
168 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
169 virtual sal_Bool SAL_CALL hasByName( const OUString& aName )
170 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
172 // XIndexAccess
173 virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
174 virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index )
175 throw(::com::sun::star::lang::IndexOutOfBoundsException,
176 ::com::sun::star::lang::WrappedTargetException,
177 ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
179 // XElementAccess
180 virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
181 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
182 virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
184 // XPropertySet
185 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo()
186 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
187 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue )
188 throw (::com::sun::star::beans::UnknownPropertyException,
189 ::com::sun::star::beans::PropertyVetoException,
190 ::com::sun::star::lang::IllegalArgumentException,
191 ::com::sun::star::lang::WrappedTargetException,
192 ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
193 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName )
194 throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
195 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener )
196 throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
197 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener )
198 throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
199 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener )
200 throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
201 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener )
202 throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
204 // XServiceInfo
205 virtual OUString SAL_CALL getImplementationName()
206 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
207 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
208 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
209 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
210 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
213 class ScStyleObj : public ::cppu::WeakImplHelper7<
214 ::com::sun::star::style::XStyle,
215 ::com::sun::star::beans::XPropertySet,
216 ::com::sun::star::beans::XMultiPropertySet,
217 ::com::sun::star::beans::XPropertyState,
218 ::com::sun::star::beans::XMultiPropertyStates,
219 ::com::sun::star::lang::XUnoTunnel,
220 ::com::sun::star::lang::XServiceInfo >,
221 public SfxListener
223 private:
224 const SfxItemPropertySet* pPropSet;
225 ScDocShell* pDocShell;
226 SfxStyleFamily eFamily; // Family
227 OUString aStyleName;
229 SfxStyleSheetBase* GetStyle_Impl();
230 const SfxItemSet* GetStyleItemSet_Impl( const OUString& rPropName, const SfxItemPropertySimpleEntry*& rpEntry );
231 void SetOnePropertyValue( const OUString& rPropertyName,
232 const SfxItemPropertySimpleEntry* pEntry,
233 const ::com::sun::star::uno::Any* pValue )
234 throw(::com::sun::star::lang::IllegalArgumentException,
235 ::com::sun::star::uno::RuntimeException,
236 std::exception);
238 ScStyleObj(); // disabled
239 public:
240 ScStyleObj(ScDocShell* pDocSh, SfxStyleFamily eFam, const OUString& rName);
241 virtual ~ScStyleObj();
243 // created by getImplementation:
244 bool IsInserted() const { return pDocShell != NULL; }
245 SfxStyleFamily GetFamily() const { return eFamily; }
246 void InitDoc( ScDocShell* pNewDocSh, const OUString& rNewName );
248 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) SAL_OVERRIDE;
250 static ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexReplace >
251 CreateEmptyNumberingRules();
253 // XStyle
254 virtual sal_Bool SAL_CALL isUserDefined() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
255 virtual sal_Bool SAL_CALL isInUse() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
256 virtual OUString SAL_CALL getParentStyle() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
257 virtual void SAL_CALL setParentStyle( const OUString& aParentStyle )
258 throw(::com::sun::star::container::NoSuchElementException,
259 ::com::sun::star::uno::RuntimeException,
260 std::exception) SAL_OVERRIDE;
262 // XNamed
263 virtual OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
264 virtual void SAL_CALL setName( const OUString& aName )
265 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
267 // XPropertySet
268 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
269 SAL_CALL getPropertySetInfo()
270 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
271 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName,
272 const ::com::sun::star::uno::Any& aValue )
273 throw(::com::sun::star::beans::UnknownPropertyException,
274 ::com::sun::star::beans::PropertyVetoException,
275 ::com::sun::star::lang::IllegalArgumentException,
276 ::com::sun::star::lang::WrappedTargetException,
277 ::com::sun::star::uno::RuntimeException,
278 std::exception) SAL_OVERRIDE;
279 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
280 const OUString& PropertyName )
281 throw(::com::sun::star::beans::UnknownPropertyException,
282 ::com::sun::star::lang::WrappedTargetException,
283 ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
284 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName,
285 const ::com::sun::star::uno::Reference<
286 ::com::sun::star::beans::XPropertyChangeListener >& xListener )
287 throw(::com::sun::star::beans::UnknownPropertyException,
288 ::com::sun::star::lang::WrappedTargetException,
289 ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
290 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName,
291 const ::com::sun::star::uno::Reference<
292 ::com::sun::star::beans::XPropertyChangeListener >& aListener )
293 throw(::com::sun::star::beans::UnknownPropertyException,
294 ::com::sun::star::lang::WrappedTargetException,
295 ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
296 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName,
297 const ::com::sun::star::uno::Reference<
298 ::com::sun::star::beans::XVetoableChangeListener >& aListener )
299 throw(::com::sun::star::beans::UnknownPropertyException,
300 ::com::sun::star::lang::WrappedTargetException,
301 ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
302 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName,
303 const ::com::sun::star::uno::Reference<
304 ::com::sun::star::beans::XVetoableChangeListener >& aListener )
305 throw(::com::sun::star::beans::UnknownPropertyException,
306 ::com::sun::star::lang::WrappedTargetException,
307 ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
309 // XMultiPropertySet
310 virtual void SAL_CALL setPropertyValues( const ::com::sun::star::uno::Sequence< OUString >& aPropertyNames,
311 const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aValues )
312 throw (::com::sun::star::beans::PropertyVetoException,
313 ::com::sun::star::lang::IllegalArgumentException,
314 ::com::sun::star::lang::WrappedTargetException,
315 ::com::sun::star::uno::RuntimeException,
316 std::exception) SAL_OVERRIDE;
317 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL
318 getPropertyValues( const ::com::sun::star::uno::Sequence< OUString >& aPropertyNames )
319 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
320 virtual void SAL_CALL addPropertiesChangeListener( const ::com::sun::star::uno::Sequence< OUString >& aPropertyNames,
321 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener )
322 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
323 virtual void SAL_CALL removePropertiesChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener )
324 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
325 virtual void SAL_CALL firePropertiesChangeEvent( const ::com::sun::star::uno::Sequence< OUString >& aPropertyNames,
326 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener )
327 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
329 // XPropertyState
330 virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState(
331 const OUString& PropertyName )
332 throw(::com::sun::star::beans::UnknownPropertyException,
333 ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
334 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > SAL_CALL
335 getPropertyStates( const ::com::sun::star::uno::Sequence<
336 OUString >& aPropertyName )
337 throw(::com::sun::star::beans::UnknownPropertyException,
338 ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
339 virtual void SAL_CALL setPropertyToDefault( const OUString& PropertyName )
340 throw(::com::sun::star::beans::UnknownPropertyException,
341 ::com::sun::star::uno::RuntimeException,
342 std::exception) SAL_OVERRIDE;
343 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault(
344 const OUString& aPropertyName )
345 throw(::com::sun::star::beans::UnknownPropertyException,
346 ::com::sun::star::lang::WrappedTargetException,
347 ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
349 // XMultiPropertyStates
350 // getPropertyStates already defined for XPropertyState
351 virtual void SAL_CALL setAllPropertiesToDefault()
352 throw (::com::sun::star::uno::RuntimeException,
353 std::exception) SAL_OVERRIDE;
354 virtual void SAL_CALL setPropertiesToDefault( const ::com::sun::star::uno::Sequence<
355 OUString >& aPropertyNames )
356 throw (::com::sun::star::beans::UnknownPropertyException,
357 ::com::sun::star::uno::RuntimeException,
358 std::exception) SAL_OVERRIDE;
359 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL
360 getPropertyDefaults( const ::com::sun::star::uno::Sequence<
361 OUString >& aPropertyNames )
362 throw (::com::sun::star::beans::UnknownPropertyException,
363 ::com::sun::star::lang::WrappedTargetException,
364 ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
366 // XServiceInfo
367 virtual OUString SAL_CALL getImplementationName()
368 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
369 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
370 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
371 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
372 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
374 // XUnoTunnel
375 virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence<
376 sal_Int8 >& aIdentifier )
377 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
379 static const ::com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId();
380 static ScStyleObj* getImplementation(const css::uno::Reference<css::uno::XInterface>& rObj);
384 #endif
386 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */