xref: /trunk/main/sc/inc/afmtuno.hxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
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.
14  *
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).
20  *
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.
25  *
26  ************************************************************************/
27 
28 #ifndef SC_AFMTUNO_HXX
29 #define SC_AFMTUNO_HXX
30 
31 #include <svl/lstner.hxx>
32 #include <svl/itemprop.hxx>
33 #include <com/sun/star/lang/XServiceInfo.hpp>
34 #include <com/sun/star/container/XContainer.hpp>
35 #include <com/sun/star/container/XIndexContainer.hpp>
36 #include <com/sun/star/container/XNameReplace.hpp>
37 #include <com/sun/star/container/XContainerListener.hpp>
38 #include <com/sun/star/container/XSet.hpp>
39 #include <com/sun/star/container/ContainerEvent.hpp>
40 #include <com/sun/star/container/XIndexReplace.hpp>
41 #include <com/sun/star/container/XNameContainer.hpp>
42 #include <com/sun/star/container/XNamed.hpp>
43 #include <com/sun/star/beans/XPropertySet.hpp>
44 #include <com/sun/star/lang/XUnoTunnel.hpp>
45 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
46 #include <cppuhelper/implbase2.hxx>
47 #include <cppuhelper/implbase4.hxx>
48 #include <cppuhelper/implbase6.hxx>
49 
50 class ScAutoFormatFieldObj;
51 class ScAutoFormatObj;
52 
53 
54 #define SC_AFMTOBJ_INVALID  USHRT_MAX
55 
56 
57 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
58     ScAutoFormatsObj_CreateInstance(
59         const ::com::sun::star::uno::Reference<
60             ::com::sun::star::lang::XMultiServiceFactory >& );
61 
62 
63 class ScAutoFormatsObj : public ::cppu::WeakImplHelper4<
64                             ::com::sun::star::container::XNameContainer,
65                             ::com::sun::star::container::XEnumerationAccess,
66                             ::com::sun::star::container::XIndexAccess,
67                             ::com::sun::star::lang::XServiceInfo >
68 {
69 private:
70     ScAutoFormatObj*        GetObjectByIndex_Impl(sal_uInt16 nIndex);
71     ScAutoFormatObj*        GetObjectByName_Impl(const ::rtl::OUString& aName);
72 
73 public:
74                             ScAutoFormatsObj();
75     virtual                 ~ScAutoFormatsObj();
76 
77     static ::rtl::OUString  getImplementationName_Static();
78     static ::com::sun::star::uno::Sequence< ::rtl::OUString> getSupportedServiceNames_Static();
79 
80                             // XNameContainer
81     virtual void SAL_CALL   insertByName( const ::rtl::OUString& aName,
82                                 const ::com::sun::star::uno::Any& aElement )
83                                     throw(::com::sun::star::lang::IllegalArgumentException,
84                                         ::com::sun::star::container::ElementExistException,
85                                         ::com::sun::star::lang::WrappedTargetException,
86                                         ::com::sun::star::uno::RuntimeException);
87     virtual void SAL_CALL   removeByName( const ::rtl::OUString& Name )
88                                 throw(::com::sun::star::container::NoSuchElementException,
89                                     ::com::sun::star::lang::WrappedTargetException,
90                                     ::com::sun::star::uno::RuntimeException);
91 
92                             // XNameReplace
93     virtual void SAL_CALL   replaceByName( const ::rtl::OUString& aName,
94                                 const ::com::sun::star::uno::Any& aElement )
95                                     throw(::com::sun::star::lang::IllegalArgumentException,
96                                         ::com::sun::star::container::NoSuchElementException,
97                                         ::com::sun::star::lang::WrappedTargetException,
98                                         ::com::sun::star::uno::RuntimeException);
99 
100                             // XNameAccess
101     virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName )
102                                 throw(::com::sun::star::container::NoSuchElementException,
103                                     ::com::sun::star::lang::WrappedTargetException,
104                                     ::com::sun::star::uno::RuntimeException);
105     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames()
106                                 throw(::com::sun::star::uno::RuntimeException);
107     virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName )
108                                 throw(::com::sun::star::uno::RuntimeException);
109 
110                             // XElementAccess
111     virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
112                                 throw(::com::sun::star::uno::RuntimeException);
113     virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
114 
115                             // XEnumerationAccess
116     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL
117                             createEnumeration() throw(::com::sun::star::uno::RuntimeException);
118 
119                             // XIndexAccess
120     virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException);
121     virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index )
122                                 throw(::com::sun::star::lang::IndexOutOfBoundsException,
123                                     ::com::sun::star::lang::WrappedTargetException,
124                                     ::com::sun::star::uno::RuntimeException);
125 
126                             // XServiceInfo
127     virtual ::rtl::OUString SAL_CALL getImplementationName()
128                                 throw(::com::sun::star::uno::RuntimeException);
129     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
130                                 throw(::com::sun::star::uno::RuntimeException);
131     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
132                                 throw(::com::sun::star::uno::RuntimeException);
133 };
134 
135 
136 class ScAutoFormatObj : public ::cppu::WeakImplHelper6<
137                             ::com::sun::star::container::XIndexAccess,
138                             ::com::sun::star::container::XEnumerationAccess,
139                             ::com::sun::star::container::XNamed,
140                             ::com::sun::star::beans::XPropertySet,
141                             ::com::sun::star::lang::XUnoTunnel,
142                             ::com::sun::star::lang::XServiceInfo >,
143                         public SfxListener
144 {
145 private:
146     SfxItemPropertySet      aPropSet;
147     sal_uInt16                  nFormatIndex;
148 
149     ScAutoFormatFieldObj*   GetObjectByIndex_Impl(sal_uInt16 nIndex);
150 
151 public:
152                             ScAutoFormatObj(sal_uInt16 nIndex);
153     virtual                 ~ScAutoFormatObj();
154 
155     virtual void            Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
156 
157                             // per getImplementation gerufen:
158     sal_Bool                IsInserted() const      { return nFormatIndex != SC_AFMTOBJ_INVALID; }
159     void                    InitFormat( sal_uInt16 nNewIndex );
160 
161                             // XIndexAccess
162     virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException);
163     virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index )
164                                 throw(::com::sun::star::lang::IndexOutOfBoundsException,
165                                     ::com::sun::star::lang::WrappedTargetException,
166                                     ::com::sun::star::uno::RuntimeException);
167 
168                             // XElementAccess
169     virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
170                                 throw(::com::sun::star::uno::RuntimeException);
171     virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
172 
173                             // XEnumerationAccess
174     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL
175                             createEnumeration() throw(::com::sun::star::uno::RuntimeException);
176 
177                             // XNamed
178     virtual ::rtl::OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
179     virtual void SAL_CALL   setName( const ::rtl::OUString& aName )
180                                 throw(::com::sun::star::uno::RuntimeException);
181 
182                             // XPropertySet
183     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
184                             SAL_CALL getPropertySetInfo()
185                                 throw(::com::sun::star::uno::RuntimeException);
186     virtual void SAL_CALL   setPropertyValue( const ::rtl::OUString& aPropertyName,
187                                     const ::com::sun::star::uno::Any& aValue )
188                                 throw(::com::sun::star::beans::UnknownPropertyException,
189                                     ::com::sun::star::beans::PropertyVetoException,
190                                     ::com::sun::star::lang::IllegalArgumentException,
191                                     ::com::sun::star::lang::WrappedTargetException,
192                                     ::com::sun::star::uno::RuntimeException);
193     virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
194                                     const ::rtl::OUString& PropertyName )
195                                 throw(::com::sun::star::beans::UnknownPropertyException,
196                                     ::com::sun::star::lang::WrappedTargetException,
197                                     ::com::sun::star::uno::RuntimeException);
198     virtual void SAL_CALL   addPropertyChangeListener( const ::rtl::OUString& aPropertyName,
199                                     const ::com::sun::star::uno::Reference<
200                                         ::com::sun::star::beans::XPropertyChangeListener >& xListener )
201                                 throw(::com::sun::star::beans::UnknownPropertyException,
202                                     ::com::sun::star::lang::WrappedTargetException,
203                                     ::com::sun::star::uno::RuntimeException);
204     virtual void SAL_CALL   removePropertyChangeListener( const ::rtl::OUString& aPropertyName,
205                                     const ::com::sun::star::uno::Reference<
206                                         ::com::sun::star::beans::XPropertyChangeListener >& aListener )
207                                 throw(::com::sun::star::beans::UnknownPropertyException,
208                                     ::com::sun::star::lang::WrappedTargetException,
209                                     ::com::sun::star::uno::RuntimeException);
210     virtual void SAL_CALL   addVetoableChangeListener( const ::rtl::OUString& PropertyName,
211                                     const ::com::sun::star::uno::Reference<
212                                         ::com::sun::star::beans::XVetoableChangeListener >& aListener )
213                                 throw(::com::sun::star::beans::UnknownPropertyException,
214                                     ::com::sun::star::lang::WrappedTargetException,
215                                     ::com::sun::star::uno::RuntimeException);
216     virtual void SAL_CALL   removeVetoableChangeListener( const ::rtl::OUString& PropertyName,
217                                     const ::com::sun::star::uno::Reference<
218                                         ::com::sun::star::beans::XVetoableChangeListener >& aListener )
219                                 throw(::com::sun::star::beans::UnknownPropertyException,
220                                     ::com::sun::star::lang::WrappedTargetException,
221                                     ::com::sun::star::uno::RuntimeException);
222 
223                             // XServiceInfo
224     virtual ::rtl::OUString SAL_CALL getImplementationName()
225                                 throw(::com::sun::star::uno::RuntimeException);
226     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
227                                 throw(::com::sun::star::uno::RuntimeException);
228     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
229                                 throw(::com::sun::star::uno::RuntimeException);
230 
231                             // XUnoTunnel
232     virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence<
233                                     sal_Int8 >& aIdentifier )
234                                 throw(::com::sun::star::uno::RuntimeException);
235 
236     static const ::com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId();
237     static ScAutoFormatObj* getImplementation( const ::com::sun::star::uno::Reference<
238                                     ::com::sun::star::uno::XInterface> xObj );
239 };
240 
241 
242 class ScAutoFormatFieldObj : public ::cppu::WeakImplHelper2<
243                                 ::com::sun::star::beans::XPropertySet,
244                                 ::com::sun::star::lang::XServiceInfo >,
245                             public SfxListener
246 {
247 private:
248     SfxItemPropertySet      aPropSet;
249     sal_uInt16                  nFormatIndex;
250     sal_uInt16                  nFieldIndex;
251 
252 public:
253                             ScAutoFormatFieldObj(sal_uInt16 nFormat, sal_uInt16 nField);
254     virtual                 ~ScAutoFormatFieldObj();
255 
256     virtual void            Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
257 
258                             // XPropertySet
259     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
260                             SAL_CALL getPropertySetInfo()
261                                 throw(::com::sun::star::uno::RuntimeException);
262     virtual void SAL_CALL   setPropertyValue( const ::rtl::OUString& aPropertyName,
263                                     const ::com::sun::star::uno::Any& aValue )
264                                 throw(::com::sun::star::beans::UnknownPropertyException,
265                                     ::com::sun::star::beans::PropertyVetoException,
266                                     ::com::sun::star::lang::IllegalArgumentException,
267                                     ::com::sun::star::lang::WrappedTargetException,
268                                     ::com::sun::star::uno::RuntimeException);
269     virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
270                                     const ::rtl::OUString& PropertyName )
271                                 throw(::com::sun::star::beans::UnknownPropertyException,
272                                     ::com::sun::star::lang::WrappedTargetException,
273                                     ::com::sun::star::uno::RuntimeException);
274     virtual void SAL_CALL   addPropertyChangeListener( const ::rtl::OUString& aPropertyName,
275                                     const ::com::sun::star::uno::Reference<
276                                         ::com::sun::star::beans::XPropertyChangeListener >& xListener )
277                                 throw(::com::sun::star::beans::UnknownPropertyException,
278                                     ::com::sun::star::lang::WrappedTargetException,
279                                     ::com::sun::star::uno::RuntimeException);
280     virtual void SAL_CALL   removePropertyChangeListener( const ::rtl::OUString& aPropertyName,
281                                     const ::com::sun::star::uno::Reference<
282                                         ::com::sun::star::beans::XPropertyChangeListener >& aListener )
283                                 throw(::com::sun::star::beans::UnknownPropertyException,
284                                     ::com::sun::star::lang::WrappedTargetException,
285                                     ::com::sun::star::uno::RuntimeException);
286     virtual void SAL_CALL   addVetoableChangeListener( const ::rtl::OUString& PropertyName,
287                                     const ::com::sun::star::uno::Reference<
288                                         ::com::sun::star::beans::XVetoableChangeListener >& aListener )
289                                 throw(::com::sun::star::beans::UnknownPropertyException,
290                                     ::com::sun::star::lang::WrappedTargetException,
291                                     ::com::sun::star::uno::RuntimeException);
292     virtual void SAL_CALL   removeVetoableChangeListener( const ::rtl::OUString& PropertyName,
293                                     const ::com::sun::star::uno::Reference<
294                                         ::com::sun::star::beans::XVetoableChangeListener >& aListener )
295                                 throw(::com::sun::star::beans::UnknownPropertyException,
296                                     ::com::sun::star::lang::WrappedTargetException,
297                                     ::com::sun::star::uno::RuntimeException);
298 
299                             // XServiceInfo
300     virtual ::rtl::OUString SAL_CALL getImplementationName()
301                                 throw(::com::sun::star::uno::RuntimeException);
302     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
303                                 throw(::com::sun::star::uno::RuntimeException);
304     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
305                                 throw(::com::sun::star::uno::RuntimeException);
306 };
307 
308 
309 #endif
310 
311