1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/XStyleLoader.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>
40 class SfxStyleSheetBase
;
43 class ScStyleFamilyObj
;
46 class ScStyleFamiliesObj
: public ::cppu::WeakImplHelper4
<
47 ::com::sun::star::container::XIndexAccess
,
48 ::com::sun::star::container::XNameAccess
,
49 ::com::sun::star::style::XStyleLoader
,
50 ::com::sun::star::lang::XServiceInfo
>,
54 ScDocShell
* pDocShell
;
56 ScStyleFamilyObj
* GetObjectByType_Impl(sal_uInt16 Type
) const;
57 ScStyleFamilyObj
* GetObjectByIndex_Impl(sal_uInt32 nIndex
) const;
58 ScStyleFamilyObj
* GetObjectByName_Impl(const OUString
& aName
) const;
61 ScStyleFamiliesObj(ScDocShell
* pDocSh
);
62 virtual ~ScStyleFamiliesObj();
64 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
) SAL_OVERRIDE
;
67 virtual sal_Int32 SAL_CALL
getCount() throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
68 virtual ::com::sun::star::uno::Any SAL_CALL
getByIndex( sal_Int32 Index
)
69 throw(::com::sun::star::lang::IndexOutOfBoundsException
,
70 ::com::sun::star::lang::WrappedTargetException
,
71 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
74 virtual ::com::sun::star::uno::Any SAL_CALL
getByName( const OUString
& aName
)
75 throw(::com::sun::star::container::NoSuchElementException
,
76 ::com::sun::star::lang::WrappedTargetException
,
77 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
78 virtual ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
getElementNames()
79 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
80 virtual sal_Bool SAL_CALL
hasByName( const OUString
& aName
)
81 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
84 virtual ::com::sun::star::uno::Type SAL_CALL
getElementType()
85 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
86 virtual sal_Bool SAL_CALL
hasElements() throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
89 virtual void SAL_CALL
loadStylesFromURL( const OUString
& URL
,
90 const ::com::sun::star::uno::Sequence
<
91 ::com::sun::star::beans::PropertyValue
>& aOptions
)
92 throw(::com::sun::star::io::IOException
,
93 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
94 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
> SAL_CALL
95 getStyleLoaderOptions() throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
98 virtual OUString SAL_CALL
getImplementationName()
99 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
100 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
)
101 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
102 virtual ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames()
103 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
107 class ScStyleFamilyObj
: public ::cppu::WeakImplHelper4
<
108 ::com::sun::star::container::XNameContainer
,
109 ::com::sun::star::container::XIndexAccess
,
110 ::com::sun::star::beans::XPropertySet
,
111 ::com::sun::star::lang::XServiceInfo
>,
115 ScDocShell
* pDocShell
;
116 SfxStyleFamily eFamily
; // Family
118 ScStyleObj
* GetObjectByIndex_Impl(sal_uInt32 nIndex
);
119 ScStyleObj
* GetObjectByName_Impl(const OUString
& Name
);
122 ScStyleFamilyObj(ScDocShell
* pDocSh
, SfxStyleFamily eFam
);
123 virtual ~ScStyleFamilyObj();
125 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
) SAL_OVERRIDE
;
128 virtual void SAL_CALL
insertByName( const OUString
& aName
,
129 const ::com::sun::star::uno::Any
& aElement
)
130 throw(::com::sun::star::lang::IllegalArgumentException
,
131 ::com::sun::star::container::ElementExistException
,
132 ::com::sun::star::lang::WrappedTargetException
,
133 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
134 virtual void SAL_CALL
removeByName( const OUString
& Name
)
135 throw(::com::sun::star::container::NoSuchElementException
,
136 ::com::sun::star::lang::WrappedTargetException
,
137 ::com::sun::star::uno::RuntimeException
,
138 std::exception
) SAL_OVERRIDE
;
141 virtual void SAL_CALL
replaceByName( const OUString
& aName
,
142 const ::com::sun::star::uno::Any
& aElement
)
143 throw(::com::sun::star::lang::IllegalArgumentException
,
144 ::com::sun::star::container::NoSuchElementException
,
145 ::com::sun::star::lang::WrappedTargetException
,
146 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
149 virtual ::com::sun::star::uno::Any SAL_CALL
getByName( const OUString
& aName
)
150 throw(::com::sun::star::container::NoSuchElementException
,
151 ::com::sun::star::lang::WrappedTargetException
,
152 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
153 virtual ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
getElementNames()
154 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
155 virtual sal_Bool SAL_CALL
hasByName( const OUString
& aName
)
156 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
159 virtual sal_Int32 SAL_CALL
getCount() throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
160 virtual ::com::sun::star::uno::Any SAL_CALL
getByIndex( sal_Int32 Index
)
161 throw(::com::sun::star::lang::IndexOutOfBoundsException
,
162 ::com::sun::star::lang::WrappedTargetException
,
163 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
166 virtual ::com::sun::star::uno::Type SAL_CALL
getElementType()
167 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
168 virtual sal_Bool SAL_CALL
hasElements() throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
171 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo()
172 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
173 virtual void SAL_CALL
setPropertyValue( const OUString
& aPropertyName
, const ::com::sun::star::uno::Any
& aValue
)
174 throw (::com::sun::star::beans::UnknownPropertyException
,
175 ::com::sun::star::beans::PropertyVetoException
,
176 ::com::sun::star::lang::IllegalArgumentException
,
177 ::com::sun::star::lang::WrappedTargetException
,
178 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
179 virtual ::com::sun::star::uno::Any SAL_CALL
getPropertyValue( const OUString
& PropertyName
)
180 throw (::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
181 virtual void SAL_CALL
addPropertyChangeListener( const OUString
& aPropertyName
, const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertyChangeListener
>& xListener
)
182 throw (::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
183 virtual void SAL_CALL
removePropertyChangeListener( const OUString
& aPropertyName
, const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertyChangeListener
>& aListener
)
184 throw (::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
185 virtual void SAL_CALL
addVetoableChangeListener( const OUString
& PropertyName
, const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XVetoableChangeListener
>& aListener
)
186 throw (::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
187 virtual void SAL_CALL
removeVetoableChangeListener( const OUString
& PropertyName
, const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XVetoableChangeListener
>& aListener
)
188 throw (::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
191 virtual OUString SAL_CALL
getImplementationName()
192 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
193 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
)
194 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
195 virtual ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames()
196 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
200 class ScStyleObj
: public ::cppu::WeakImplHelper7
<
201 ::com::sun::star::style::XStyle
,
202 ::com::sun::star::beans::XPropertySet
,
203 ::com::sun::star::beans::XMultiPropertySet
,
204 ::com::sun::star::beans::XPropertyState
,
205 ::com::sun::star::beans::XMultiPropertyStates
,
206 ::com::sun::star::lang::XUnoTunnel
,
207 ::com::sun::star::lang::XServiceInfo
>,
211 const SfxItemPropertySet
* pPropSet
;
212 ScDocShell
* pDocShell
;
213 SfxStyleFamily eFamily
; // Family
216 SfxStyleSheetBase
* GetStyle_Impl();
217 const SfxItemSet
* GetStyleItemSet_Impl( const OUString
& rPropName
, const SfxItemPropertySimpleEntry
*& rpEntry
);
218 void SetOnePropertyValue( const OUString
& rPropertyName
,
219 const SfxItemPropertySimpleEntry
* pEntry
,
220 const ::com::sun::star::uno::Any
* pValue
)
221 throw(::com::sun::star::lang::IllegalArgumentException
,
222 ::com::sun::star::uno::RuntimeException
,
225 ScStyleObj(); // disabled
227 ScStyleObj(ScDocShell
* pDocSh
, SfxStyleFamily eFam
, const OUString
& rName
);
228 virtual ~ScStyleObj();
230 // created by getImplementation:
231 bool IsInserted() const { return pDocShell
!= NULL
; }
232 SfxStyleFamily
GetFamily() const { return eFamily
; }
233 void InitDoc( ScDocShell
* pNewDocSh
, const OUString
& rNewName
);
235 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
) SAL_OVERRIDE
;
237 static ::com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexReplace
>
238 CreateEmptyNumberingRules();
241 virtual sal_Bool SAL_CALL
isUserDefined() throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
242 virtual sal_Bool SAL_CALL
isInUse() throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
243 virtual OUString SAL_CALL
getParentStyle() throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
244 virtual void SAL_CALL
setParentStyle( const OUString
& aParentStyle
)
245 throw(::com::sun::star::container::NoSuchElementException
,
246 ::com::sun::star::uno::RuntimeException
,
247 std::exception
) SAL_OVERRIDE
;
250 virtual OUString SAL_CALL
getName() throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
251 virtual void SAL_CALL
setName( const OUString
& aName
)
252 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
255 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySetInfo
>
256 SAL_CALL
getPropertySetInfo()
257 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
258 virtual void SAL_CALL
setPropertyValue( const 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 std::exception
) SAL_OVERRIDE
;
266 virtual ::com::sun::star::uno::Any SAL_CALL
getPropertyValue(
267 const OUString
& PropertyName
)
268 throw(::com::sun::star::beans::UnknownPropertyException
,
269 ::com::sun::star::lang::WrappedTargetException
,
270 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
271 virtual void SAL_CALL
addPropertyChangeListener( const OUString
& aPropertyName
,
272 const ::com::sun::star::uno::Reference
<
273 ::com::sun::star::beans::XPropertyChangeListener
>& xListener
)
274 throw(::com::sun::star::beans::UnknownPropertyException
,
275 ::com::sun::star::lang::WrappedTargetException
,
276 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
277 virtual void SAL_CALL
removePropertyChangeListener( const OUString
& aPropertyName
,
278 const ::com::sun::star::uno::Reference
<
279 ::com::sun::star::beans::XPropertyChangeListener
>& aListener
)
280 throw(::com::sun::star::beans::UnknownPropertyException
,
281 ::com::sun::star::lang::WrappedTargetException
,
282 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
283 virtual void SAL_CALL
addVetoableChangeListener( const OUString
& PropertyName
,
284 const ::com::sun::star::uno::Reference
<
285 ::com::sun::star::beans::XVetoableChangeListener
>& aListener
)
286 throw(::com::sun::star::beans::UnknownPropertyException
,
287 ::com::sun::star::lang::WrappedTargetException
,
288 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
289 virtual void SAL_CALL
removeVetoableChangeListener( const 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
, std::exception
) SAL_OVERRIDE
;
297 virtual void SAL_CALL
setPropertyValues( const ::com::sun::star::uno::Sequence
< OUString
>& aPropertyNames
,
298 const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
>& aValues
)
299 throw (::com::sun::star::beans::PropertyVetoException
,
300 ::com::sun::star::lang::IllegalArgumentException
,
301 ::com::sun::star::lang::WrappedTargetException
,
302 ::com::sun::star::uno::RuntimeException
,
303 std::exception
) SAL_OVERRIDE
;
304 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
> SAL_CALL
305 getPropertyValues( const ::com::sun::star::uno::Sequence
< OUString
>& aPropertyNames
)
306 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
307 virtual void SAL_CALL
addPropertiesChangeListener( const ::com::sun::star::uno::Sequence
< OUString
>& aPropertyNames
,
308 const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertiesChangeListener
>& xListener
)
309 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
310 virtual void SAL_CALL
removePropertiesChangeListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertiesChangeListener
>& xListener
)
311 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
312 virtual void SAL_CALL
firePropertiesChangeEvent( const ::com::sun::star::uno::Sequence
< OUString
>& aPropertyNames
,
313 const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertiesChangeListener
>& xListener
)
314 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
317 virtual ::com::sun::star::beans::PropertyState SAL_CALL
getPropertyState(
318 const OUString
& PropertyName
)
319 throw(::com::sun::star::beans::UnknownPropertyException
,
320 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
321 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyState
> SAL_CALL
322 getPropertyStates( const ::com::sun::star::uno::Sequence
<
323 OUString
>& aPropertyName
)
324 throw(::com::sun::star::beans::UnknownPropertyException
,
325 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
326 virtual void SAL_CALL
setPropertyToDefault( const OUString
& PropertyName
)
327 throw(::com::sun::star::beans::UnknownPropertyException
,
328 ::com::sun::star::uno::RuntimeException
,
329 std::exception
) SAL_OVERRIDE
;
330 virtual ::com::sun::star::uno::Any SAL_CALL
getPropertyDefault(
331 const OUString
& aPropertyName
)
332 throw(::com::sun::star::beans::UnknownPropertyException
,
333 ::com::sun::star::lang::WrappedTargetException
,
334 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
336 // XMultiPropertyStates
337 // getPropertyStates already defined for XPropertyState
338 virtual void SAL_CALL
setAllPropertiesToDefault()
339 throw (::com::sun::star::uno::RuntimeException
,
340 std::exception
) SAL_OVERRIDE
;
341 virtual void SAL_CALL
setPropertiesToDefault( const ::com::sun::star::uno::Sequence
<
342 OUString
>& aPropertyNames
)
343 throw (::com::sun::star::beans::UnknownPropertyException
,
344 ::com::sun::star::uno::RuntimeException
,
345 std::exception
) SAL_OVERRIDE
;
346 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
> SAL_CALL
347 getPropertyDefaults( const ::com::sun::star::uno::Sequence
<
348 OUString
>& aPropertyNames
)
349 throw (::com::sun::star::beans::UnknownPropertyException
,
350 ::com::sun::star::lang::WrappedTargetException
,
351 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
354 virtual OUString SAL_CALL
getImplementationName()
355 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
356 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
)
357 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
358 virtual ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames()
359 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
362 virtual sal_Int64 SAL_CALL
getSomething( const ::com::sun::star::uno::Sequence
<
363 sal_Int8
>& aIdentifier
)
364 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
366 static const ::com::sun::star::uno::Sequence
<sal_Int8
>& getUnoTunnelId();
367 static ScStyleObj
* getImplementation( const ::com::sun::star::uno::Reference
<
368 ::com::sun::star::uno::XInterface
> xObj
);
374 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */