Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / sc / inc / styleuno.hxx
blob33bb7193aed1b09a06c69775420d790d61eeabbd
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/implbase.hxx>
38 #include <com/sun/star/lang/XComponent.hpp>
41 class SfxStyleSheetBase;
42 class ScDocShell;
43 class SfxObjectShell;
45 class ScStyleFamilyObj;
46 class ScStyleObj;
48 class ScStyleFamiliesObj : public ::cppu::WeakImplHelper<
49 css::container::XIndexAccess,
50 css::container::XNameAccess,
51 css::style::XStyleLoader2,
52 css::lang::XServiceInfo >,
53 public SfxListener
55 private:
56 ScDocShell* pDocShell;
58 ScStyleFamilyObj* GetObjectByType_Impl(SfxStyleFamily nType) const;
59 ScStyleFamilyObj* GetObjectByIndex_Impl(sal_uInt32 nIndex) const;
60 ScStyleFamilyObj* GetObjectByName_Impl(const OUString& aName) const;
62 public:
63 ScStyleFamiliesObj(ScDocShell* pDocSh);
64 virtual ~ScStyleFamiliesObj();
66 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
68 // XIndexAccess
69 virtual sal_Int32 SAL_CALL getCount() throw(css::uno::RuntimeException, std::exception) override;
70 virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index )
71 throw(css::lang::IndexOutOfBoundsException,
72 css::lang::WrappedTargetException,
73 css::uno::RuntimeException, std::exception) override;
75 // XNameAccess
76 virtual css::uno::Any SAL_CALL getByName( const OUString& aName )
77 throw(css::container::NoSuchElementException,
78 css::lang::WrappedTargetException,
79 css::uno::RuntimeException, std::exception) override;
80 virtual css::uno::Sequence< OUString > SAL_CALL getElementNames()
81 throw(css::uno::RuntimeException, std::exception) override;
82 virtual sal_Bool SAL_CALL hasByName( const OUString& aName )
83 throw(css::uno::RuntimeException, std::exception) override;
85 // XElementAccess
86 virtual css::uno::Type SAL_CALL getElementType()
87 throw(css::uno::RuntimeException, std::exception) override;
88 virtual sal_Bool SAL_CALL hasElements() throw(css::uno::RuntimeException, std::exception) override;
90 // XStyleLoader
91 virtual void SAL_CALL loadStylesFromURL( const OUString& URL,
92 const css::uno::Sequence< css::beans::PropertyValue >& aOptions )
93 throw(css::io::IOException,
94 css::uno::RuntimeException, std::exception) override;
95 virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL
96 getStyleLoaderOptions() throw(css::uno::RuntimeException, std::exception) override;
98 //XStyleLoader2
99 virtual void SAL_CALL loadStylesFromDocument( const css::uno::Reference < css::lang::XComponent > & aSourceComponent,
100 const css::uno::Sequence< css::beans::PropertyValue >& aOptions )
101 throw(css::io::IOException,
102 css::uno::RuntimeException, std::exception) override;
103 // XServiceInfo
104 virtual OUString SAL_CALL getImplementationName()
105 throw(css::uno::RuntimeException, std::exception) override;
106 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
107 throw(css::uno::RuntimeException, std::exception) override;
108 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
109 throw(css::uno::RuntimeException, std::exception) override;
110 private:
111 void loadStylesFromDocShell( ScDocShell* pSource,
112 const css::uno::Sequence< css::beans::PropertyValue>& aOptions )
113 throw(css::io::IOException,
114 css::uno::RuntimeException, std::exception);
117 class ScStyleFamilyObj : public ::cppu::WeakImplHelper<
118 css::container::XNameContainer,
119 css::container::XIndexAccess,
120 css::beans::XPropertySet,
121 css::lang::XServiceInfo >,
122 public SfxListener
124 private:
125 ScDocShell* pDocShell;
126 SfxStyleFamily eFamily; // Family
128 ScStyleObj* GetObjectByIndex_Impl(sal_uInt32 nIndex);
129 ScStyleObj* GetObjectByName_Impl(const OUString& Name);
131 public:
132 ScStyleFamilyObj(ScDocShell* pDocSh, SfxStyleFamily eFam);
133 virtual ~ScStyleFamilyObj();
135 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
137 // XNameContainer
138 virtual void SAL_CALL insertByName( const OUString& aName,
139 const css::uno::Any& aElement )
140 throw(css::lang::IllegalArgumentException,
141 css::container::ElementExistException,
142 css::lang::WrappedTargetException,
143 css::uno::RuntimeException, std::exception) override;
144 virtual void SAL_CALL removeByName( const OUString& Name )
145 throw(css::container::NoSuchElementException,
146 css::lang::WrappedTargetException,
147 css::uno::RuntimeException,
148 std::exception) override;
150 // XNameReplace
151 virtual void SAL_CALL replaceByName( const OUString& aName,
152 const css::uno::Any& aElement )
153 throw(css::lang::IllegalArgumentException,
154 css::container::NoSuchElementException,
155 css::lang::WrappedTargetException,
156 css::uno::RuntimeException, std::exception) override;
158 // XNameAccess
159 virtual css::uno::Any SAL_CALL getByName( const OUString& aName )
160 throw(css::container::NoSuchElementException,
161 css::lang::WrappedTargetException,
162 css::uno::RuntimeException, std::exception) override;
163 virtual css::uno::Sequence< OUString > SAL_CALL getElementNames()
164 throw(css::uno::RuntimeException, std::exception) override;
165 virtual sal_Bool SAL_CALL hasByName( const OUString& aName )
166 throw(css::uno::RuntimeException, std::exception) override;
168 // XIndexAccess
169 virtual sal_Int32 SAL_CALL getCount() throw(css::uno::RuntimeException, std::exception) override;
170 virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index )
171 throw(css::lang::IndexOutOfBoundsException,
172 css::lang::WrappedTargetException,
173 css::uno::RuntimeException, std::exception) override;
175 // XElementAccess
176 virtual css::uno::Type SAL_CALL getElementType()
177 throw(css::uno::RuntimeException, std::exception) override;
178 virtual sal_Bool SAL_CALL hasElements() throw(css::uno::RuntimeException, std::exception) override;
180 // XPropertySet
181 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo()
182 throw (css::uno::RuntimeException, std::exception) override;
183 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue )
184 throw (css::beans::UnknownPropertyException,
185 css::beans::PropertyVetoException,
186 css::lang::IllegalArgumentException,
187 css::lang::WrappedTargetException,
188 css::uno::RuntimeException, std::exception) override;
189 virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName )
190 throw (css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) override;
191 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener )
192 throw (css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) override;
193 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener )
194 throw (css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) override;
195 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener )
196 throw (css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) override;
197 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener )
198 throw (css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) override;
200 // XServiceInfo
201 virtual OUString SAL_CALL getImplementationName()
202 throw(css::uno::RuntimeException, std::exception) override;
203 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
204 throw(css::uno::RuntimeException, std::exception) override;
205 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
206 throw(css::uno::RuntimeException, std::exception) override;
209 class ScStyleObj : public ::cppu::WeakImplHelper<
210 css::style::XStyle,
211 css::beans::XPropertySet,
212 css::beans::XMultiPropertySet,
213 css::beans::XPropertyState,
214 css::beans::XMultiPropertyStates,
215 css::lang::XUnoTunnel,
216 css::lang::XServiceInfo >,
217 public SfxListener
219 private:
220 const SfxItemPropertySet* pPropSet;
221 ScDocShell* pDocShell;
222 SfxStyleFamily eFamily; // Family
223 OUString aStyleName;
225 SfxStyleSheetBase* GetStyle_Impl();
226 const SfxItemSet* GetStyleItemSet_Impl( const OUString& rPropName, const SfxItemPropertySimpleEntry*& rpEntry );
227 void SetOnePropertyValue( const OUString& rPropertyName,
228 const SfxItemPropertySimpleEntry* pEntry,
229 const css::uno::Any* pValue )
230 throw(css::lang::IllegalArgumentException,
231 css::uno::RuntimeException,
232 std::exception);
234 public:
235 ScStyleObj() = delete;
236 ScStyleObj(ScDocShell* pDocSh, SfxStyleFamily eFam, const OUString& rName);
237 virtual ~ScStyleObj();
239 // created by getImplementation:
240 bool IsInserted() const { return pDocShell != nullptr; }
241 SfxStyleFamily GetFamily() const { return eFamily; }
242 void InitDoc( ScDocShell* pNewDocSh, const OUString& rNewName );
244 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
246 static css::uno::Reference< css::container::XIndexReplace >
247 CreateEmptyNumberingRules();
249 // XStyle
250 virtual sal_Bool SAL_CALL isUserDefined() throw(css::uno::RuntimeException, std::exception) override;
251 virtual sal_Bool SAL_CALL isInUse() throw(css::uno::RuntimeException, std::exception) override;
252 virtual OUString SAL_CALL getParentStyle() throw(css::uno::RuntimeException, std::exception) override;
253 virtual void SAL_CALL setParentStyle( const OUString& aParentStyle )
254 throw(css::container::NoSuchElementException,
255 css::uno::RuntimeException,
256 std::exception) override;
258 // XNamed
259 virtual OUString SAL_CALL getName() throw(css::uno::RuntimeException, std::exception) override;
260 virtual void SAL_CALL setName( const OUString& aName )
261 throw(css::uno::RuntimeException, std::exception) override;
263 // XPropertySet
264 virtual css::uno::Reference< css::beans::XPropertySetInfo >
265 SAL_CALL getPropertySetInfo()
266 throw(css::uno::RuntimeException, std::exception) override;
267 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName,
268 const css::uno::Any& aValue )
269 throw(css::beans::UnknownPropertyException,
270 css::beans::PropertyVetoException,
271 css::lang::IllegalArgumentException,
272 css::lang::WrappedTargetException,
273 css::uno::RuntimeException,
274 std::exception) override;
275 virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName )
276 throw(css::beans::UnknownPropertyException,
277 css::lang::WrappedTargetException,
278 css::uno::RuntimeException, std::exception) override;
279 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName,
280 const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener )
281 throw(css::beans::UnknownPropertyException,
282 css::lang::WrappedTargetException,
283 css::uno::RuntimeException, std::exception) override;
284 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName,
285 const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener )
286 throw(css::beans::UnknownPropertyException,
287 css::lang::WrappedTargetException,
288 css::uno::RuntimeException, std::exception) override;
289 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName,
290 const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener )
291 throw(css::beans::UnknownPropertyException,
292 css::lang::WrappedTargetException,
293 css::uno::RuntimeException, std::exception) override;
294 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName,
295 const css::uno::Reference<
296 css::beans::XVetoableChangeListener >& aListener )
297 throw(css::beans::UnknownPropertyException,
298 css::lang::WrappedTargetException,
299 css::uno::RuntimeException, std::exception) override;
301 // XMultiPropertySet
302 virtual void SAL_CALL setPropertyValues( const css::uno::Sequence< OUString >& aPropertyNames,
303 const css::uno::Sequence< css::uno::Any >& aValues )
304 throw (css::beans::PropertyVetoException,
305 css::lang::IllegalArgumentException,
306 css::lang::WrappedTargetException,
307 css::uno::RuntimeException,
308 std::exception) override;
309 virtual css::uno::Sequence< css::uno::Any > SAL_CALL
310 getPropertyValues( const css::uno::Sequence< OUString >& aPropertyNames )
311 throw (css::uno::RuntimeException, std::exception) override;
312 virtual void SAL_CALL addPropertiesChangeListener( const css::uno::Sequence< OUString >& aPropertyNames,
313 const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener )
314 throw (css::uno::RuntimeException, std::exception) override;
315 virtual void SAL_CALL removePropertiesChangeListener( const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener )
316 throw (css::uno::RuntimeException, std::exception) override;
317 virtual void SAL_CALL firePropertiesChangeEvent( const css::uno::Sequence< OUString >& aPropertyNames,
318 const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener )
319 throw (css::uno::RuntimeException, std::exception) override;
321 // XPropertyState
322 virtual css::beans::PropertyState SAL_CALL getPropertyState(
323 const OUString& PropertyName )
324 throw(css::beans::UnknownPropertyException,
325 css::uno::RuntimeException, std::exception) override;
326 virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL
327 getPropertyStates( const css::uno::Sequence< OUString >& aPropertyName )
328 throw(css::beans::UnknownPropertyException,
329 css::uno::RuntimeException, std::exception) override;
330 virtual void SAL_CALL setPropertyToDefault( const OUString& PropertyName )
331 throw(css::beans::UnknownPropertyException,
332 css::uno::RuntimeException,
333 std::exception) override;
334 virtual css::uno::Any SAL_CALL getPropertyDefault( const OUString& aPropertyName )
335 throw(css::beans::UnknownPropertyException,
336 css::lang::WrappedTargetException,
337 css::uno::RuntimeException, std::exception) override;
339 // XMultiPropertyStates
340 // getPropertyStates already defined for XPropertyState
341 virtual void SAL_CALL setAllPropertiesToDefault()
342 throw (css::uno::RuntimeException,
343 std::exception) override;
344 virtual void SAL_CALL setPropertiesToDefault( const css::uno::Sequence< OUString >& aPropertyNames )
345 throw (css::beans::UnknownPropertyException,
346 css::uno::RuntimeException,
347 std::exception) override;
348 virtual css::uno::Sequence< css::uno::Any > SAL_CALL
349 getPropertyDefaults( const css::uno::Sequence< OUString >& aPropertyNames )
350 throw (css::beans::UnknownPropertyException,
351 css::lang::WrappedTargetException,
352 css::uno::RuntimeException, std::exception) override;
354 // XServiceInfo
355 virtual OUString SAL_CALL getImplementationName()
356 throw(css::uno::RuntimeException, std::exception) override;
357 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
358 throw(css::uno::RuntimeException, std::exception) override;
359 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
360 throw(css::uno::RuntimeException, std::exception) override;
362 // XUnoTunnel
363 virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier )
364 throw(css::uno::RuntimeException, std::exception) override;
366 static const css::uno::Sequence<sal_Int8>& getUnoTunnelId();
367 static ScStyleObj* getImplementation(const css::uno::Reference<css::uno::XInterface>& rObj);
371 #endif
373 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */