1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 #ifndef SC_STYLEUNO_HXX
29 #define SC_STYLEUNO_HXX
31 #include <svl/itemprop.hxx>
32 #include <svl/lstner.hxx>
33 #include <rsc/rscsfx.hxx>
34 #include <com/sun/star/container/XIndexAccess.hpp>
35 #include <com/sun/star/style/XStyle.hpp>
36 #include <com/sun/star/style/XStyleLoader.hpp>
37 #include <com/sun/star/lang/XServiceInfo.hpp>
38 #include <com/sun/star/container/XNameContainer.hpp>
39 #include <com/sun/star/container/XIndexReplace.hpp>
40 #include <com/sun/star/beans/XPropertySet.hpp>
41 #include <com/sun/star/beans/XMultiPropertySet.hpp>
42 #include <com/sun/star/beans/XPropertyState.hpp>
43 #include <com/sun/star/beans/XMultiPropertyStates.hpp>
44 #include <com/sun/star/lang/XUnoTunnel.hpp>
45 //#include <cppuhelper/implbase3.hxx>
46 #include <cppuhelper/implbase4.hxx>
47 #include <cppuhelper/implbase7.hxx>
49 class SfxStyleSheetBase
;
52 class ScStyleFamilyObj
;
56 class ScStyleNameConversion
59 static String
DisplayToProgrammaticName( const String
& rDispName
, UINT16 nType
);
60 static String
ProgrammaticToDisplayName( const String
& rProgName
, UINT16 nType
);
64 class ScStyleFamiliesObj
: public ::cppu::WeakImplHelper4
<
65 ::com::sun::star::container::XIndexAccess
,
66 ::com::sun::star::container::XNameAccess
,
67 ::com::sun::star::style::XStyleLoader
,
68 ::com::sun::star::lang::XServiceInfo
>,
72 ScDocShell
* pDocShell
;
74 ScStyleFamilyObj
* GetObjectByType_Impl(UINT16 Type
) const;
75 ScStyleFamilyObj
* GetObjectByIndex_Impl(UINT32 nIndex
) const;
76 ScStyleFamilyObj
* GetObjectByName_Impl(const rtl::OUString
& aName
) const;
79 ScStyleFamiliesObj(ScDocShell
* pDocSh
);
80 virtual ~ScStyleFamiliesObj();
82 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
);
85 virtual sal_Int32 SAL_CALL
getCount() throw(::com::sun::star::uno::RuntimeException
);
86 virtual ::com::sun::star::uno::Any SAL_CALL
getByIndex( sal_Int32 Index
)
87 throw(::com::sun::star::lang::IndexOutOfBoundsException
,
88 ::com::sun::star::lang::WrappedTargetException
,
89 ::com::sun::star::uno::RuntimeException
);
92 virtual ::com::sun::star::uno::Any SAL_CALL
getByName( const ::rtl::OUString
& aName
)
93 throw(::com::sun::star::container::NoSuchElementException
,
94 ::com::sun::star::lang::WrappedTargetException
,
95 ::com::sun::star::uno::RuntimeException
);
96 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getElementNames()
97 throw(::com::sun::star::uno::RuntimeException
);
98 virtual sal_Bool SAL_CALL
hasByName( const ::rtl::OUString
& aName
)
99 throw(::com::sun::star::uno::RuntimeException
);
102 virtual ::com::sun::star::uno::Type SAL_CALL
getElementType()
103 throw(::com::sun::star::uno::RuntimeException
);
104 virtual sal_Bool SAL_CALL
hasElements() throw(::com::sun::star::uno::RuntimeException
);
107 virtual void SAL_CALL
loadStylesFromURL( const ::rtl::OUString
& URL
,
108 const ::com::sun::star::uno::Sequence
<
109 ::com::sun::star::beans::PropertyValue
>& aOptions
)
110 throw(::com::sun::star::io::IOException
,
111 ::com::sun::star::uno::RuntimeException
);
112 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
> SAL_CALL
113 getStyleLoaderOptions() throw(::com::sun::star::uno::RuntimeException
);
116 virtual ::rtl::OUString SAL_CALL
getImplementationName()
117 throw(::com::sun::star::uno::RuntimeException
);
118 virtual sal_Bool SAL_CALL
supportsService( const ::rtl::OUString
& ServiceName
)
119 throw(::com::sun::star::uno::RuntimeException
);
120 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames()
121 throw(::com::sun::star::uno::RuntimeException
);
125 class ScStyleFamilyObj
: public ::cppu::WeakImplHelper4
<
126 ::com::sun::star::container::XNameContainer
,
127 ::com::sun::star::container::XIndexAccess
,
128 ::com::sun::star::beans::XPropertySet
,
129 ::com::sun::star::lang::XServiceInfo
>,
133 ScDocShell
* pDocShell
;
134 SfxStyleFamily eFamily
; // Familie
136 ScStyleObj
* GetObjectByIndex_Impl(UINT32 nIndex
);
137 ScStyleObj
* GetObjectByName_Impl(const rtl::OUString
& Name
);
140 ScStyleFamilyObj(ScDocShell
* pDocSh
, SfxStyleFamily eFam
);
141 virtual ~ScStyleFamilyObj();
143 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
);
146 virtual void SAL_CALL
insertByName( const ::rtl::OUString
& aName
,
147 const ::com::sun::star::uno::Any
& aElement
)
148 throw(::com::sun::star::lang::IllegalArgumentException
,
149 ::com::sun::star::container::ElementExistException
,
150 ::com::sun::star::lang::WrappedTargetException
,
151 ::com::sun::star::uno::RuntimeException
);
152 virtual void SAL_CALL
removeByName( const ::rtl::OUString
& Name
)
153 throw(::com::sun::star::container::NoSuchElementException
,
154 ::com::sun::star::lang::WrappedTargetException
,
155 ::com::sun::star::uno::RuntimeException
);
158 virtual void SAL_CALL
replaceByName( const ::rtl::OUString
& aName
,
159 const ::com::sun::star::uno::Any
& aElement
)
160 throw(::com::sun::star::lang::IllegalArgumentException
,
161 ::com::sun::star::container::NoSuchElementException
,
162 ::com::sun::star::lang::WrappedTargetException
,
163 ::com::sun::star::uno::RuntimeException
);
166 virtual ::com::sun::star::uno::Any SAL_CALL
getByName( const ::rtl::OUString
& aName
)
167 throw(::com::sun::star::container::NoSuchElementException
,
168 ::com::sun::star::lang::WrappedTargetException
,
169 ::com::sun::star::uno::RuntimeException
);
170 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getElementNames()
171 throw(::com::sun::star::uno::RuntimeException
);
172 virtual sal_Bool SAL_CALL
hasByName( const ::rtl::OUString
& aName
)
173 throw(::com::sun::star::uno::RuntimeException
);
176 virtual sal_Int32 SAL_CALL
getCount() throw(::com::sun::star::uno::RuntimeException
);
177 virtual ::com::sun::star::uno::Any SAL_CALL
getByIndex( sal_Int32 Index
)
178 throw(::com::sun::star::lang::IndexOutOfBoundsException
,
179 ::com::sun::star::lang::WrappedTargetException
,
180 ::com::sun::star::uno::RuntimeException
);
183 virtual ::com::sun::star::uno::Type SAL_CALL
getElementType()
184 throw(::com::sun::star::uno::RuntimeException
);
185 virtual sal_Bool SAL_CALL
hasElements() throw(::com::sun::star::uno::RuntimeException
);
188 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo()
189 throw (::com::sun::star::uno::RuntimeException
);
190 virtual void SAL_CALL
setPropertyValue( const ::rtl::OUString
& aPropertyName
, const ::com::sun::star::uno::Any
& aValue
)
191 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
);
192 virtual ::com::sun::star::uno::Any SAL_CALL
getPropertyValue( const ::rtl::OUString
& PropertyName
)
193 throw (::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
194 virtual void SAL_CALL
addPropertyChangeListener( const ::rtl::OUString
& aPropertyName
, const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertyChangeListener
>& xListener
)
195 throw (::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
196 virtual void SAL_CALL
removePropertyChangeListener( const ::rtl::OUString
& aPropertyName
, const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertyChangeListener
>& aListener
)
197 throw (::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
198 virtual void SAL_CALL
addVetoableChangeListener( const ::rtl::OUString
& PropertyName
, const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XVetoableChangeListener
>& aListener
)
199 throw (::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
200 virtual void SAL_CALL
removeVetoableChangeListener( const ::rtl::OUString
& PropertyName
, const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XVetoableChangeListener
>& aListener
)
201 throw (::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
204 virtual ::rtl::OUString SAL_CALL
getImplementationName()
205 throw(::com::sun::star::uno::RuntimeException
);
206 virtual sal_Bool SAL_CALL
supportsService( const ::rtl::OUString
& ServiceName
)
207 throw(::com::sun::star::uno::RuntimeException
);
208 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames()
209 throw(::com::sun::star::uno::RuntimeException
);
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
>,
224 const SfxItemPropertySet
* pPropSet
;
225 ScDocShell
* pDocShell
;
226 SfxStyleFamily eFamily
; // Familie
229 SfxStyleSheetBase
* GetStyle_Impl();
230 const SfxItemSet
* GetStyleItemSet_Impl( const ::rtl::OUString
& rPropName
, const SfxItemPropertySimpleEntry
*& rpEntry
);
231 void SetOnePropertyValue( const ::rtl::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
);
237 ScStyleObj(); // disabled
239 ScStyleObj(ScDocShell
* pDocSh
, SfxStyleFamily eFam
, const String
& rName
);
240 virtual ~ScStyleObj();
242 // per getImplementation gerufen:
243 sal_Bool
IsInserted() const { return pDocShell
!= NULL
; }
244 SfxStyleFamily
GetFamily() const { return eFamily
; }
245 void InitDoc( ScDocShell
* pNewDocSh
, const String
& rNewName
);
247 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
);
249 static ::com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexReplace
>
250 CreateEmptyNumberingRules();
253 virtual sal_Bool SAL_CALL
isUserDefined() throw(::com::sun::star::uno::RuntimeException
);
254 virtual sal_Bool SAL_CALL
isInUse() throw(::com::sun::star::uno::RuntimeException
);
255 virtual ::rtl::OUString SAL_CALL
getParentStyle() throw(::com::sun::star::uno::RuntimeException
);
256 virtual void SAL_CALL
setParentStyle( const ::rtl::OUString
& aParentStyle
)
257 throw(::com::sun::star::container::NoSuchElementException
,
258 ::com::sun::star::uno::RuntimeException
);
261 virtual ::rtl::OUString SAL_CALL
getName() throw(::com::sun::star::uno::RuntimeException
);
262 virtual void SAL_CALL
setName( const ::rtl::OUString
& aName
)
263 throw(::com::sun::star::uno::RuntimeException
);
266 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySetInfo
>
267 SAL_CALL
getPropertySetInfo()
268 throw(::com::sun::star::uno::RuntimeException
);
269 virtual void SAL_CALL
setPropertyValue( const ::rtl::OUString
& aPropertyName
,
270 const ::com::sun::star::uno::Any
& aValue
)
271 throw(::com::sun::star::beans::UnknownPropertyException
,
272 ::com::sun::star::beans::PropertyVetoException
,
273 ::com::sun::star::lang::IllegalArgumentException
,
274 ::com::sun::star::lang::WrappedTargetException
,
275 ::com::sun::star::uno::RuntimeException
);
276 virtual ::com::sun::star::uno::Any SAL_CALL
getPropertyValue(
277 const ::rtl::OUString
& PropertyName
)
278 throw(::com::sun::star::beans::UnknownPropertyException
,
279 ::com::sun::star::lang::WrappedTargetException
,
280 ::com::sun::star::uno::RuntimeException
);
281 virtual void SAL_CALL
addPropertyChangeListener( const ::rtl::OUString
& aPropertyName
,
282 const ::com::sun::star::uno::Reference
<
283 ::com::sun::star::beans::XPropertyChangeListener
>& xListener
)
284 throw(::com::sun::star::beans::UnknownPropertyException
,
285 ::com::sun::star::lang::WrappedTargetException
,
286 ::com::sun::star::uno::RuntimeException
);
287 virtual void SAL_CALL
removePropertyChangeListener( const ::rtl::OUString
& aPropertyName
,
288 const ::com::sun::star::uno::Reference
<
289 ::com::sun::star::beans::XPropertyChangeListener
>& aListener
)
290 throw(::com::sun::star::beans::UnknownPropertyException
,
291 ::com::sun::star::lang::WrappedTargetException
,
292 ::com::sun::star::uno::RuntimeException
);
293 virtual void SAL_CALL
addVetoableChangeListener( const ::rtl::OUString
& PropertyName
,
294 const ::com::sun::star::uno::Reference
<
295 ::com::sun::star::beans::XVetoableChangeListener
>& aListener
)
296 throw(::com::sun::star::beans::UnknownPropertyException
,
297 ::com::sun::star::lang::WrappedTargetException
,
298 ::com::sun::star::uno::RuntimeException
);
299 virtual void SAL_CALL
removeVetoableChangeListener( const ::rtl::OUString
& PropertyName
,
300 const ::com::sun::star::uno::Reference
<
301 ::com::sun::star::beans::XVetoableChangeListener
>& aListener
)
302 throw(::com::sun::star::beans::UnknownPropertyException
,
303 ::com::sun::star::lang::WrappedTargetException
,
304 ::com::sun::star::uno::RuntimeException
);
307 virtual void SAL_CALL
setPropertyValues( const ::com::sun::star::uno::Sequence
< ::rtl::OUString
>& aPropertyNames
,
308 const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
>& aValues
)
309 throw (::com::sun::star::beans::PropertyVetoException
,
310 ::com::sun::star::lang::IllegalArgumentException
,
311 ::com::sun::star::lang::WrappedTargetException
,
312 ::com::sun::star::uno::RuntimeException
);
313 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
> SAL_CALL
314 getPropertyValues( const ::com::sun::star::uno::Sequence
< ::rtl::OUString
>& aPropertyNames
)
315 throw (::com::sun::star::uno::RuntimeException
);
316 virtual void SAL_CALL
addPropertiesChangeListener( const ::com::sun::star::uno::Sequence
< ::rtl::OUString
>& aPropertyNames
,
317 const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertiesChangeListener
>& xListener
)
318 throw (::com::sun::star::uno::RuntimeException
);
319 virtual void SAL_CALL
removePropertiesChangeListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertiesChangeListener
>& xListener
)
320 throw (::com::sun::star::uno::RuntimeException
);
321 virtual void SAL_CALL
firePropertiesChangeEvent( 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
);
326 virtual ::com::sun::star::beans::PropertyState SAL_CALL
getPropertyState(
327 const ::rtl::OUString
& PropertyName
)
328 throw(::com::sun::star::beans::UnknownPropertyException
,
329 ::com::sun::star::uno::RuntimeException
);
330 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyState
> SAL_CALL
331 getPropertyStates( const ::com::sun::star::uno::Sequence
<
332 ::rtl::OUString
>& aPropertyName
)
333 throw(::com::sun::star::beans::UnknownPropertyException
,
334 ::com::sun::star::uno::RuntimeException
);
335 virtual void SAL_CALL
setPropertyToDefault( const ::rtl::OUString
& PropertyName
)
336 throw(::com::sun::star::beans::UnknownPropertyException
,
337 ::com::sun::star::uno::RuntimeException
);
338 virtual ::com::sun::star::uno::Any SAL_CALL
getPropertyDefault(
339 const ::rtl::OUString
& aPropertyName
)
340 throw(::com::sun::star::beans::UnknownPropertyException
,
341 ::com::sun::star::lang::WrappedTargetException
,
342 ::com::sun::star::uno::RuntimeException
);
344 // XMultiPropertyStates
345 // getPropertyStates already defined for XPropertyState
346 virtual void SAL_CALL
setAllPropertiesToDefault() throw (::com::sun::star::uno::RuntimeException
);
347 virtual void SAL_CALL
setPropertiesToDefault( const ::com::sun::star::uno::Sequence
<
348 ::rtl::OUString
>& aPropertyNames
)
349 throw (::com::sun::star::beans::UnknownPropertyException
,
350 ::com::sun::star::uno::RuntimeException
);
351 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
> SAL_CALL
352 getPropertyDefaults( const ::com::sun::star::uno::Sequence
<
353 ::rtl::OUString
>& aPropertyNames
)
354 throw (::com::sun::star::beans::UnknownPropertyException
,
355 ::com::sun::star::lang::WrappedTargetException
,
356 ::com::sun::star::uno::RuntimeException
);
359 virtual ::rtl::OUString SAL_CALL
getImplementationName()
360 throw(::com::sun::star::uno::RuntimeException
);
361 virtual sal_Bool SAL_CALL
supportsService( const ::rtl::OUString
& ServiceName
)
362 throw(::com::sun::star::uno::RuntimeException
);
363 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames()
364 throw(::com::sun::star::uno::RuntimeException
);
367 virtual sal_Int64 SAL_CALL
getSomething( const ::com::sun::star::uno::Sequence
<
368 sal_Int8
>& aIdentifier
)
369 throw(::com::sun::star::uno::RuntimeException
);
371 static const ::com::sun::star::uno::Sequence
<sal_Int8
>& getUnoTunnelId();
372 static ScStyleObj
* getImplementation( const ::com::sun::star::uno::Reference
<
373 ::com::sun::star::uno::XInterface
> xObj
);