Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef SC_STYLEUNO_HXX
30 : : #define SC_STYLEUNO_HXX
31 : :
32 : : #include <svl/itemprop.hxx>
33 : : #include <svl/lstner.hxx>
34 : : #include <rsc/rscsfx.hxx>
35 : : #include <com/sun/star/container/XIndexAccess.hpp>
36 : : #include <com/sun/star/style/XStyle.hpp>
37 : : #include <com/sun/star/style/XStyleLoader.hpp>
38 : : #include <com/sun/star/lang/XServiceInfo.hpp>
39 : : #include <com/sun/star/container/XNameContainer.hpp>
40 : : #include <com/sun/star/container/XIndexReplace.hpp>
41 : : #include <com/sun/star/beans/XPropertySet.hpp>
42 : : #include <com/sun/star/beans/XMultiPropertySet.hpp>
43 : : #include <com/sun/star/beans/XPropertyState.hpp>
44 : : #include <com/sun/star/beans/XMultiPropertyStates.hpp>
45 : : #include <com/sun/star/lang/XUnoTunnel.hpp>
46 : : #include <cppuhelper/implbase4.hxx>
47 : : #include <cppuhelper/implbase7.hxx>
48 : :
49 : : class SfxStyleSheetBase;
50 : : class ScDocShell;
51 : :
52 : : class ScStyleFamilyObj;
53 : : class ScStyleObj;
54 : :
55 : :
56 : : class ScStyleNameConversion
57 : : {
58 : : public:
59 : : static String DisplayToProgrammaticName( const String& rDispName, sal_uInt16 nType );
60 : : static String ProgrammaticToDisplayName( const String& rProgName, sal_uInt16 nType );
61 : : };
62 : :
63 : :
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 >,
69 : : public SfxListener
70 : : {
71 : : private:
72 : : ScDocShell* pDocShell;
73 : :
74 : : ScStyleFamilyObj* GetObjectByType_Impl(sal_uInt16 Type) const;
75 : : ScStyleFamilyObj* GetObjectByIndex_Impl(sal_uInt32 nIndex) const;
76 : : ScStyleFamilyObj* GetObjectByName_Impl(const rtl::OUString& aName) const;
77 : :
78 : : public:
79 : : ScStyleFamiliesObj(ScDocShell* pDocSh);
80 : : virtual ~ScStyleFamiliesObj();
81 : :
82 : : virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
83 : :
84 : : // XIndexAccess
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);
90 : :
91 : : // XNameAccess
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);
100 : :
101 : : // XElementAccess
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);
105 : :
106 : : // XStyleLoader
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);
114 : :
115 : : // XServiceInfo
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);
122 : : };
123 : :
124 : :
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 >,
130 : : public SfxListener
131 : : {
132 : : private:
133 : : ScDocShell* pDocShell;
134 : : SfxStyleFamily eFamily; // Family
135 : :
136 : : ScStyleObj* GetObjectByIndex_Impl(sal_uInt32 nIndex);
137 : : ScStyleObj* GetObjectByName_Impl(const rtl::OUString& Name);
138 : :
139 : : public:
140 : : ScStyleFamilyObj(ScDocShell* pDocSh, SfxStyleFamily eFam);
141 : : virtual ~ScStyleFamilyObj();
142 : :
143 : : virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
144 : :
145 : : // XNameContainer
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);
156 : :
157 : : // XNameReplace
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);
164 : :
165 : : // XNameAccess
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);
174 : :
175 : : // XIndexAccess
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);
181 : :
182 : : // XElementAccess
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);
186 : :
187 : : // XPropertySet
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);
202 : :
203 : : // XServiceInfo
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);
210 : : };
211 : :
212 : :
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
222 : : {
223 : : private:
224 : : const SfxItemPropertySet* pPropSet;
225 : : ScDocShell* pDocShell;
226 : : SfxStyleFamily eFamily; // Family
227 : : String aStyleName;
228 : :
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);
236 : :
237 : : ScStyleObj(); // disabled
238 : : public:
239 : : ScStyleObj(ScDocShell* pDocSh, SfxStyleFamily eFam, const String& rName);
240 : : virtual ~ScStyleObj();
241 : :
242 : : // created by getImplementation:
243 : 125 : sal_Bool IsInserted() const { return pDocShell != NULL; }
244 : 125 : SfxStyleFamily GetFamily() const { return eFamily; }
245 : : void InitDoc( ScDocShell* pNewDocSh, const String& rNewName );
246 : :
247 : : virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
248 : :
249 : : static ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexReplace >
250 : : CreateEmptyNumberingRules();
251 : :
252 : : // XStyle
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);
259 : :
260 : : // XNamed
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);
264 : :
265 : : // XPropertySet
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);
305 : :
306 : : // XMultiPropertySet
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);
324 : :
325 : : // XPropertyState
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);
343 : :
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);
357 : :
358 : : // XServiceInfo
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);
365 : :
366 : : // XUnoTunnel
367 : : virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence<
368 : : sal_Int8 >& aIdentifier )
369 : : throw(::com::sun::star::uno::RuntimeException);
370 : :
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 );
374 : :
375 : : };
376 : :
377 : : #endif
378 : :
379 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|