Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef SC_STYLEUNO_HXX
21 : #define SC_STYLEUNO_HXX
22 :
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>
39 :
40 : class SfxStyleSheetBase;
41 : class ScDocShell;
42 :
43 : class ScStyleFamilyObj;
44 : class ScStyleObj;
45 :
46 :
47 : class ScStyleNameConversion
48 : {
49 : public:
50 : static String DisplayToProgrammaticName( const String& rDispName, sal_uInt16 nType );
51 : static String ProgrammaticToDisplayName( const String& rProgName, sal_uInt16 nType );
52 : };
53 :
54 :
55 : class ScStyleFamiliesObj : public ::cppu::WeakImplHelper4<
56 : ::com::sun::star::container::XIndexAccess,
57 : ::com::sun::star::container::XNameAccess,
58 : ::com::sun::star::style::XStyleLoader,
59 : ::com::sun::star::lang::XServiceInfo >,
60 : public SfxListener
61 : {
62 : private:
63 : ScDocShell* pDocShell;
64 :
65 : ScStyleFamilyObj* GetObjectByType_Impl(sal_uInt16 Type) const;
66 : ScStyleFamilyObj* GetObjectByIndex_Impl(sal_uInt32 nIndex) const;
67 : ScStyleFamilyObj* GetObjectByName_Impl(const rtl::OUString& aName) const;
68 :
69 : public:
70 : ScStyleFamiliesObj(ScDocShell* pDocSh);
71 : virtual ~ScStyleFamiliesObj();
72 :
73 : virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
74 :
75 : // XIndexAccess
76 : virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException);
77 : virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index )
78 : throw(::com::sun::star::lang::IndexOutOfBoundsException,
79 : ::com::sun::star::lang::WrappedTargetException,
80 : ::com::sun::star::uno::RuntimeException);
81 :
82 : // XNameAccess
83 : virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName )
84 : throw(::com::sun::star::container::NoSuchElementException,
85 : ::com::sun::star::lang::WrappedTargetException,
86 : ::com::sun::star::uno::RuntimeException);
87 : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames()
88 : throw(::com::sun::star::uno::RuntimeException);
89 : virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName )
90 : throw(::com::sun::star::uno::RuntimeException);
91 :
92 : // XElementAccess
93 : virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
94 : throw(::com::sun::star::uno::RuntimeException);
95 : virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
96 :
97 : // XStyleLoader
98 : virtual void SAL_CALL loadStylesFromURL( const ::rtl::OUString& URL,
99 : const ::com::sun::star::uno::Sequence<
100 : ::com::sun::star::beans::PropertyValue >& aOptions )
101 : throw(::com::sun::star::io::IOException,
102 : ::com::sun::star::uno::RuntimeException);
103 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL
104 : getStyleLoaderOptions() throw(::com::sun::star::uno::RuntimeException);
105 :
106 : // XServiceInfo
107 : virtual ::rtl::OUString SAL_CALL getImplementationName()
108 : throw(::com::sun::star::uno::RuntimeException);
109 : virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
110 : throw(::com::sun::star::uno::RuntimeException);
111 : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
112 : throw(::com::sun::star::uno::RuntimeException);
113 : };
114 :
115 :
116 : class ScStyleFamilyObj : public ::cppu::WeakImplHelper4<
117 : ::com::sun::star::container::XNameContainer,
118 : ::com::sun::star::container::XIndexAccess,
119 : ::com::sun::star::beans::XPropertySet,
120 : ::com::sun::star::lang::XServiceInfo >,
121 : public SfxListener
122 : {
123 : private:
124 : ScDocShell* pDocShell;
125 : SfxStyleFamily eFamily; // Family
126 :
127 : ScStyleObj* GetObjectByIndex_Impl(sal_uInt32 nIndex);
128 : ScStyleObj* GetObjectByName_Impl(const rtl::OUString& Name);
129 :
130 : public:
131 : ScStyleFamilyObj(ScDocShell* pDocSh, SfxStyleFamily eFam);
132 : virtual ~ScStyleFamilyObj();
133 :
134 : virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
135 :
136 : // XNameContainer
137 : virtual void SAL_CALL insertByName( const ::rtl::OUString& aName,
138 : const ::com::sun::star::uno::Any& aElement )
139 : throw(::com::sun::star::lang::IllegalArgumentException,
140 : ::com::sun::star::container::ElementExistException,
141 : ::com::sun::star::lang::WrappedTargetException,
142 : ::com::sun::star::uno::RuntimeException);
143 : virtual void SAL_CALL removeByName( const ::rtl::OUString& Name )
144 : throw(::com::sun::star::container::NoSuchElementException,
145 : ::com::sun::star::lang::WrappedTargetException,
146 : ::com::sun::star::uno::RuntimeException);
147 :
148 : // XNameReplace
149 : virtual void SAL_CALL replaceByName( const ::rtl::OUString& aName,
150 : const ::com::sun::star::uno::Any& aElement )
151 : throw(::com::sun::star::lang::IllegalArgumentException,
152 : ::com::sun::star::container::NoSuchElementException,
153 : ::com::sun::star::lang::WrappedTargetException,
154 : ::com::sun::star::uno::RuntimeException);
155 :
156 : // XNameAccess
157 : virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName )
158 : throw(::com::sun::star::container::NoSuchElementException,
159 : ::com::sun::star::lang::WrappedTargetException,
160 : ::com::sun::star::uno::RuntimeException);
161 : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames()
162 : throw(::com::sun::star::uno::RuntimeException);
163 : virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName )
164 : throw(::com::sun::star::uno::RuntimeException);
165 :
166 : // XIndexAccess
167 : virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException);
168 : virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index )
169 : throw(::com::sun::star::lang::IndexOutOfBoundsException,
170 : ::com::sun::star::lang::WrappedTargetException,
171 : ::com::sun::star::uno::RuntimeException);
172 :
173 : // XElementAccess
174 : virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
175 : throw(::com::sun::star::uno::RuntimeException);
176 : virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
177 :
178 : // XPropertySet
179 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo()
180 : throw (::com::sun::star::uno::RuntimeException);
181 : virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue )
182 : 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);
183 : virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName )
184 : throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
185 : virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener )
186 : throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
187 : virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener )
188 : throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
189 : virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener )
190 : throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
191 : virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener )
192 : throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
193 :
194 : // XServiceInfo
195 : virtual ::rtl::OUString SAL_CALL getImplementationName()
196 : throw(::com::sun::star::uno::RuntimeException);
197 : virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
198 : throw(::com::sun::star::uno::RuntimeException);
199 : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
200 : throw(::com::sun::star::uno::RuntimeException);
201 : };
202 :
203 :
204 : class ScStyleObj : public ::cppu::WeakImplHelper7<
205 : ::com::sun::star::style::XStyle,
206 : ::com::sun::star::beans::XPropertySet,
207 : ::com::sun::star::beans::XMultiPropertySet,
208 : ::com::sun::star::beans::XPropertyState,
209 : ::com::sun::star::beans::XMultiPropertyStates,
210 : ::com::sun::star::lang::XUnoTunnel,
211 : ::com::sun::star::lang::XServiceInfo >,
212 : public SfxListener
213 : {
214 : private:
215 : const SfxItemPropertySet* pPropSet;
216 : ScDocShell* pDocShell;
217 : SfxStyleFamily eFamily; // Family
218 : String aStyleName;
219 :
220 : SfxStyleSheetBase* GetStyle_Impl();
221 : const SfxItemSet* GetStyleItemSet_Impl( const ::rtl::OUString& rPropName, const SfxItemPropertySimpleEntry*& rpEntry );
222 : void SetOnePropertyValue( const ::rtl::OUString& rPropertyName,
223 : const SfxItemPropertySimpleEntry* pEntry,
224 : const ::com::sun::star::uno::Any* pValue )
225 : throw(::com::sun::star::lang::IllegalArgumentException,
226 : ::com::sun::star::uno::RuntimeException);
227 :
228 : ScStyleObj(); // disabled
229 : public:
230 : ScStyleObj(ScDocShell* pDocSh, SfxStyleFamily eFam, const String& rName);
231 : virtual ~ScStyleObj();
232 :
233 : // created by getImplementation:
234 76 : sal_Bool IsInserted() const { return pDocShell != NULL; }
235 76 : SfxStyleFamily GetFamily() const { return eFamily; }
236 : void InitDoc( ScDocShell* pNewDocSh, const String& rNewName );
237 :
238 : virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
239 :
240 : static ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexReplace >
241 : CreateEmptyNumberingRules();
242 :
243 : // XStyle
244 : virtual sal_Bool SAL_CALL isUserDefined() throw(::com::sun::star::uno::RuntimeException);
245 : virtual sal_Bool SAL_CALL isInUse() throw(::com::sun::star::uno::RuntimeException);
246 : virtual ::rtl::OUString SAL_CALL getParentStyle() throw(::com::sun::star::uno::RuntimeException);
247 : virtual void SAL_CALL setParentStyle( const ::rtl::OUString& aParentStyle )
248 : throw(::com::sun::star::container::NoSuchElementException,
249 : ::com::sun::star::uno::RuntimeException);
250 :
251 : // XNamed
252 : virtual ::rtl::OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
253 : virtual void SAL_CALL setName( const ::rtl::OUString& aName )
254 : throw(::com::sun::star::uno::RuntimeException);
255 :
256 : // XPropertySet
257 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
258 : SAL_CALL getPropertySetInfo()
259 : throw(::com::sun::star::uno::RuntimeException);
260 : virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName,
261 : const ::com::sun::star::uno::Any& aValue )
262 : throw(::com::sun::star::beans::UnknownPropertyException,
263 : ::com::sun::star::beans::PropertyVetoException,
264 : ::com::sun::star::lang::IllegalArgumentException,
265 : ::com::sun::star::lang::WrappedTargetException,
266 : ::com::sun::star::uno::RuntimeException);
267 : virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
268 : const ::rtl::OUString& PropertyName )
269 : throw(::com::sun::star::beans::UnknownPropertyException,
270 : ::com::sun::star::lang::WrappedTargetException,
271 : ::com::sun::star::uno::RuntimeException);
272 : virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName,
273 : const ::com::sun::star::uno::Reference<
274 : ::com::sun::star::beans::XPropertyChangeListener >& xListener )
275 : throw(::com::sun::star::beans::UnknownPropertyException,
276 : ::com::sun::star::lang::WrappedTargetException,
277 : ::com::sun::star::uno::RuntimeException);
278 : virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName,
279 : const ::com::sun::star::uno::Reference<
280 : ::com::sun::star::beans::XPropertyChangeListener >& aListener )
281 : throw(::com::sun::star::beans::UnknownPropertyException,
282 : ::com::sun::star::lang::WrappedTargetException,
283 : ::com::sun::star::uno::RuntimeException);
284 : virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName,
285 : const ::com::sun::star::uno::Reference<
286 : ::com::sun::star::beans::XVetoableChangeListener >& aListener )
287 : throw(::com::sun::star::beans::UnknownPropertyException,
288 : ::com::sun::star::lang::WrappedTargetException,
289 : ::com::sun::star::uno::RuntimeException);
290 : virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName,
291 : const ::com::sun::star::uno::Reference<
292 : ::com::sun::star::beans::XVetoableChangeListener >& aListener )
293 : throw(::com::sun::star::beans::UnknownPropertyException,
294 : ::com::sun::star::lang::WrappedTargetException,
295 : ::com::sun::star::uno::RuntimeException);
296 :
297 : // XMultiPropertySet
298 : virtual void SAL_CALL setPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames,
299 : const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aValues )
300 : throw (::com::sun::star::beans::PropertyVetoException,
301 : ::com::sun::star::lang::IllegalArgumentException,
302 : ::com::sun::star::lang::WrappedTargetException,
303 : ::com::sun::star::uno::RuntimeException);
304 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL
305 : getPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames )
306 : throw (::com::sun::star::uno::RuntimeException);
307 : virtual void SAL_CALL addPropertiesChangeListener( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames,
308 : const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener )
309 : throw (::com::sun::star::uno::RuntimeException);
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);
312 : virtual void SAL_CALL firePropertiesChangeEvent( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames,
313 : const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener )
314 : throw (::com::sun::star::uno::RuntimeException);
315 :
316 : // XPropertyState
317 : virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState(
318 : const ::rtl::OUString& PropertyName )
319 : throw(::com::sun::star::beans::UnknownPropertyException,
320 : ::com::sun::star::uno::RuntimeException);
321 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > SAL_CALL
322 : getPropertyStates( const ::com::sun::star::uno::Sequence<
323 : ::rtl::OUString >& aPropertyName )
324 : throw(::com::sun::star::beans::UnknownPropertyException,
325 : ::com::sun::star::uno::RuntimeException);
326 : virtual void SAL_CALL setPropertyToDefault( const ::rtl::OUString& PropertyName )
327 : throw(::com::sun::star::beans::UnknownPropertyException,
328 : ::com::sun::star::uno::RuntimeException);
329 : virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault(
330 : const ::rtl::OUString& aPropertyName )
331 : throw(::com::sun::star::beans::UnknownPropertyException,
332 : ::com::sun::star::lang::WrappedTargetException,
333 : ::com::sun::star::uno::RuntimeException);
334 :
335 : // XMultiPropertyStates
336 : // getPropertyStates already defined for XPropertyState
337 : virtual void SAL_CALL setAllPropertiesToDefault() throw (::com::sun::star::uno::RuntimeException);
338 : virtual void SAL_CALL setPropertiesToDefault( const ::com::sun::star::uno::Sequence<
339 : ::rtl::OUString >& aPropertyNames )
340 : throw (::com::sun::star::beans::UnknownPropertyException,
341 : ::com::sun::star::uno::RuntimeException);
342 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL
343 : getPropertyDefaults( const ::com::sun::star::uno::Sequence<
344 : ::rtl::OUString >& aPropertyNames )
345 : throw (::com::sun::star::beans::UnknownPropertyException,
346 : ::com::sun::star::lang::WrappedTargetException,
347 : ::com::sun::star::uno::RuntimeException);
348 :
349 : // XServiceInfo
350 : virtual ::rtl::OUString SAL_CALL getImplementationName()
351 : throw(::com::sun::star::uno::RuntimeException);
352 : virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
353 : throw(::com::sun::star::uno::RuntimeException);
354 : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
355 : throw(::com::sun::star::uno::RuntimeException);
356 :
357 : // XUnoTunnel
358 : virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence<
359 : sal_Int8 >& aIdentifier )
360 : throw(::com::sun::star::uno::RuntimeException);
361 :
362 : static const ::com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId();
363 : static ScStyleObj* getImplementation( const ::com::sun::star::uno::Reference<
364 : ::com::sun::star::uno::XInterface> xObj );
365 :
366 : };
367 :
368 : #endif
369 :
370 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|