update dev300-m58
[ooovba.git] / sc / inc / miscuno.hxx
blob7ce4c902b81a7f997376c018f83e1c3a083d5f65
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: miscuno.hxx,v $
10 * $Revision: 1.9.32.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SC_MISCUNO_HXX
32 #define SC_MISCUNO_HXX
34 #include <com/sun/star/lang/XServiceInfo.hpp>
35 #include <com/sun/star/beans/XPropertySet.hpp>
36 #include <com/sun/star/container/XEnumerationAccess.hpp>
37 #include <com/sun/star/container/XNameAccess.hpp>
38 #include <com/sun/star/container/XEnumeration.hpp>
39 #include <com/sun/star/container/XIndexAccess.hpp>
40 #include <cppuhelper/implbase2.hxx>
41 #include "scdllapi.h"
43 #define SC_SIMPLE_SERVICE_INFO( ClassName, ClassNameAscii, ServiceAscii ) \
44 ::rtl::OUString SAL_CALL ClassName::getImplementationName() \
45 throw(::com::sun::star::uno::RuntimeException) \
46 { \
47 return ::rtl::OUString::createFromAscii(ClassNameAscii); \
48 } \
49 sal_Bool SAL_CALL ClassName::supportsService( const ::rtl::OUString& ServiceName ) \
50 throw(::com::sun::star::uno::RuntimeException) \
51 { \
52 return !ServiceName.compareToAscii(ServiceAscii); \
53 } \
54 ::com::sun::star::uno::Sequence< ::rtl::OUString > \
55 SAL_CALL ClassName::getSupportedServiceNames(void) \
56 throw(::com::sun::star::uno::RuntimeException) \
57 { \
58 ::com::sun::star::uno::Sequence< ::rtl::OUString > aRet(1); \
59 ::rtl::OUString* pArray = aRet.getArray(); \
60 pArray[0] = ::rtl::OUString::createFromAscii(ServiceAscii); \
61 return aRet; \
64 #define SC_IMPL_DUMMY_PROPERTY_LISTENER( ClassName ) \
65 void SAL_CALL ClassName::addPropertyChangeListener( const rtl::OUString&, \
66 const uno::Reference<beans::XPropertyChangeListener>&) \
67 throw(beans::UnknownPropertyException, \
68 lang::WrappedTargetException, uno::RuntimeException) \
69 { DBG_ERROR("not implemented"); } \
70 void SAL_CALL ClassName::removePropertyChangeListener( const rtl::OUString&, \
71 const uno::Reference<beans::XPropertyChangeListener>&) \
72 throw(beans::UnknownPropertyException, \
73 lang::WrappedTargetException, uno::RuntimeException) \
74 { DBG_ERROR("not implemented"); } \
75 void SAL_CALL ClassName::addVetoableChangeListener( const rtl::OUString&, \
76 const uno::Reference<beans::XVetoableChangeListener>&) \
77 throw(beans::UnknownPropertyException, \
78 lang::WrappedTargetException, uno::RuntimeException) \
79 { DBG_ERROR("not implemented"); } \
80 void SAL_CALL ClassName::removeVetoableChangeListener( const rtl::OUString&, \
81 const uno::Reference<beans::XVetoableChangeListener>&) \
82 throw(beans::UnknownPropertyException, \
83 lang::WrappedTargetException, uno::RuntimeException) \
84 { DBG_ERROR("not implemented"); }
87 #define SC_QUERYINTERFACE(x) \
88 if (rType == getCppuType((const uno::Reference<x>*)0)) \
89 { return uno::makeAny(uno::Reference<x>(this)); }
91 // SC_QUERY_MULTIPLE( XElementAccess, XIndexAccess ):
92 // use if interface is used several times in one class
94 #define SC_QUERY_MULTIPLE(x,y) \
95 if (rType == getCppuType((const uno::Reference<x>*)0)) \
96 { uno::Any aR; aR <<= uno::Reference<x>(static_cast<y*>(this)); return aR; }
99 class ScIndexEnumeration : public cppu::WeakImplHelper2<
100 com::sun::star::container::XEnumeration,
101 com::sun::star::lang::XServiceInfo >
103 private:
104 com::sun::star::uno::Reference<com::sun::star::container::XIndexAccess> xIndex;
105 rtl::OUString sServiceName;
106 sal_Int32 nPos;
108 public:
109 ScIndexEnumeration(const com::sun::star::uno::Reference<
110 com::sun::star::container::XIndexAccess>& rInd, const rtl::OUString& rServiceName);
111 virtual ~ScIndexEnumeration();
113 // XEnumeration
114 virtual sal_Bool SAL_CALL hasMoreElements() throw(::com::sun::star::uno::RuntimeException);
115 virtual ::com::sun::star::uno::Any SAL_CALL nextElement()
116 throw(::com::sun::star::container::NoSuchElementException,
117 ::com::sun::star::lang::WrappedTargetException,
118 ::com::sun::star::uno::RuntimeException);
120 // XServiceInfo
121 virtual ::rtl::OUString SAL_CALL getImplementationName( )
122 throw(::com::sun::star::uno::RuntimeException);
123 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
124 throw(::com::sun::star::uno::RuntimeException);
125 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( )
126 throw(::com::sun::star::uno::RuntimeException);
129 //UNUSED2008-05 class ScEmptyEnumerationAccess : public cppu::WeakImplHelper2<
130 //UNUSED2008-05 com::sun::star::container::XEnumerationAccess,
131 //UNUSED2008-05 com::sun::star::lang::XServiceInfo >
132 //UNUSED2008-05 {
133 //UNUSED2008-05 public:
134 //UNUSED2008-05 ScEmptyEnumerationAccess();
135 //UNUSED2008-05 virtual ~ScEmptyEnumerationAccess();
136 //UNUSED2008-05
137 //UNUSED2008-05 // XEnumerationAccess
138 //UNUSED2008-05 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL
139 //UNUSED2008-05 createEnumeration() throw(::com::sun::star::uno::RuntimeException);
140 //UNUSED2008-05
141 //UNUSED2008-05 // XElementAccess
142 //UNUSED2008-05 virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
143 //UNUSED2008-05 throw(::com::sun::star::uno::RuntimeException);
144 //UNUSED2008-05 virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
145 //UNUSED2008-05
146 //UNUSED2008-05 // XServiceInfo
147 //UNUSED2008-05 virtual ::rtl::OUString SAL_CALL getImplementationName( )
148 //UNUSED2008-05 throw(::com::sun::star::uno::RuntimeException);
149 //UNUSED2008-05 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
150 //UNUSED2008-05 throw(::com::sun::star::uno::RuntimeException);
151 //UNUSED2008-05 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( )
152 //UNUSED2008-05 throw(::com::sun::star::uno::RuntimeException);
153 //UNUSED2008-05 };
155 //UNUSED2008-05 class ScEmptyEnumeration : public cppu::WeakImplHelper2<
156 //UNUSED2008-05 com::sun::star::container::XEnumeration,
157 //UNUSED2008-05 com::sun::star::lang::XServiceInfo >
158 //UNUSED2008-05 {
159 //UNUSED2008-05 public:
160 //UNUSED2008-05 ScEmptyEnumeration();
161 //UNUSED2008-05 virtual ~ScEmptyEnumeration();
162 //UNUSED2008-05
163 //UNUSED2008-05 // XEnumeration
164 //UNUSED2008-05 virtual sal_Bool SAL_CALL hasMoreElements() throw(::com::sun::star::uno::RuntimeException);
165 //UNUSED2008-05 virtual ::com::sun::star::uno::Any SAL_CALL nextElement()
166 //UNUSED2008-05 throw(::com::sun::star::container::NoSuchElementException,
167 //UNUSED2008-05 ::com::sun::star::lang::WrappedTargetException,
168 //UNUSED2008-05 ::com::sun::star::uno::RuntimeException);
169 //UNUSED2008-05
170 //UNUSED2008-05 // XServiceInfo
171 //UNUSED2008-05 virtual ::rtl::OUString SAL_CALL getImplementationName( )
172 //UNUSED2008-05 throw(::com::sun::star::uno::RuntimeException);
173 //UNUSED2008-05 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
174 //UNUSED2008-05 throw(::com::sun::star::uno::RuntimeException);
175 //UNUSED2008-05 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( )
176 //UNUSED2008-05 throw(::com::sun::star::uno::RuntimeException);
177 //UNUSED2008-05 };
179 // new (uno 3) variant
180 class ScNameToIndexAccess : public cppu::WeakImplHelper2<
181 com::sun::star::container::XIndexAccess,
182 com::sun::star::lang::XServiceInfo >
184 private:
185 com::sun::star::uno::Reference<com::sun::star::container::XNameAccess> xNameAccess;
186 com::sun::star::uno::Sequence<rtl::OUString> aNames;
188 public:
189 ScNameToIndexAccess(
190 const com::sun::star::uno::Reference<
191 com::sun::star::container::XNameAccess>& rNameObj );
192 virtual ~ScNameToIndexAccess();
194 // XIndexAccess
195 virtual sal_Int32 SAL_CALL getCount( ) throw(::com::sun::star::uno::RuntimeException);
196 virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index )
197 throw(::com::sun::star::lang::IndexOutOfBoundsException,
198 ::com::sun::star::lang::WrappedTargetException,
199 ::com::sun::star::uno::RuntimeException);
201 // XElementAccess
202 virtual ::com::sun::star::uno::Type SAL_CALL getElementType( )
203 throw(::com::sun::star::uno::RuntimeException);
204 virtual sal_Bool SAL_CALL hasElements( ) throw(::com::sun::star::uno::RuntimeException);
206 // XServiceInfo
207 virtual ::rtl::OUString SAL_CALL getImplementationName( )
208 throw(::com::sun::star::uno::RuntimeException);
209 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
210 throw(::com::sun::star::uno::RuntimeException);
211 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( )
212 throw(::com::sun::star::uno::RuntimeException);
215 //UNUSED2008-05 class ScPrintSettingsObj : public cppu::WeakImplHelper2<
216 //UNUSED2008-05 com::sun::star::beans::XPropertySet,
217 //UNUSED2008-05 com::sun::star::lang::XServiceInfo >
218 //UNUSED2008-05 {
219 //UNUSED2008-05 public:
220 //UNUSED2008-05 ScPrintSettingsObj();
221 //UNUSED2008-05 virtual ~ScPrintSettingsObj();
222 //UNUSED2008-05
223 //UNUSED2008-05 // XPropertySet
224 //UNUSED2008-05 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
225 //UNUSED2008-05 SAL_CALL getPropertySetInfo()
226 //UNUSED2008-05 throw(::com::sun::star::uno::RuntimeException);
227 //UNUSED2008-05 virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName,
228 //UNUSED2008-05 const ::com::sun::star::uno::Any& aValue )
229 //UNUSED2008-05 throw(::com::sun::star::beans::UnknownPropertyException,
230 //UNUSED2008-05 ::com::sun::star::beans::PropertyVetoException,
231 //UNUSED2008-05 ::com::sun::star::lang::IllegalArgumentException,
232 //UNUSED2008-05 ::com::sun::star::lang::WrappedTargetException,
233 //UNUSED2008-05 ::com::sun::star::uno::RuntimeException);
234 //UNUSED2008-05 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
235 //UNUSED2008-05 const ::rtl::OUString& PropertyName )
236 //UNUSED2008-05 throw(::com::sun::star::beans::UnknownPropertyException,
237 //UNUSED2008-05 ::com::sun::star::lang::WrappedTargetException,
238 //UNUSED2008-05 ::com::sun::star::uno::RuntimeException);
239 //UNUSED2008-05 virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName,
240 //UNUSED2008-05 const ::com::sun::star::uno::Reference<
241 //UNUSED2008-05 ::com::sun::star::beans::XPropertyChangeListener >& xListener )
242 //UNUSED2008-05 throw(::com::sun::star::beans::UnknownPropertyException,
243 //UNUSED2008-05 ::com::sun::star::lang::WrappedTargetException,
244 //UNUSED2008-05 ::com::sun::star::uno::RuntimeException);
245 //UNUSED2008-05 virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName,
246 //UNUSED2008-05 const ::com::sun::star::uno::Reference<
247 //UNUSED2008-05 ::com::sun::star::beans::XPropertyChangeListener >& aListener )
248 //UNUSED2008-05 throw(::com::sun::star::beans::UnknownPropertyException,
249 //UNUSED2008-05 ::com::sun::star::lang::WrappedTargetException,
250 //UNUSED2008-05 ::com::sun::star::uno::RuntimeException);
251 //UNUSED2008-05 virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName,
252 //UNUSED2008-05 const ::com::sun::star::uno::Reference<
253 //UNUSED2008-05 ::com::sun::star::beans::XVetoableChangeListener >& aListener )
254 //UNUSED2008-05 throw(::com::sun::star::beans::UnknownPropertyException,
255 //UNUSED2008-05 ::com::sun::star::lang::WrappedTargetException,
256 //UNUSED2008-05 ::com::sun::star::uno::RuntimeException);
257 //UNUSED2008-05 virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName,
258 //UNUSED2008-05 const ::com::sun::star::uno::Reference<
259 //UNUSED2008-05 ::com::sun::star::beans::XVetoableChangeListener >& aListener )
260 //UNUSED2008-05 throw(::com::sun::star::beans::UnknownPropertyException,
261 //UNUSED2008-05 ::com::sun::star::lang::WrappedTargetException,
262 //UNUSED2008-05 ::com::sun::star::uno::RuntimeException);
263 //UNUSED2008-05
264 //UNUSED2008-05 // XServiceInfo
265 //UNUSED2008-05 virtual ::rtl::OUString SAL_CALL getImplementationName( )
266 //UNUSED2008-05 throw(::com::sun::star::uno::RuntimeException);
267 //UNUSED2008-05 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
268 //UNUSED2008-05 throw(::com::sun::star::uno::RuntimeException);
269 //UNUSED2008-05 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( )
270 //UNUSED2008-05 throw(::com::sun::star::uno::RuntimeException);
271 //UNUSED2008-05 };
274 class SC_DLLPUBLIC ScUnoHelpFunctions
276 public:
277 static com::sun::star::uno::Reference<com::sun::star::uno::XInterface>
278 AnyToInterface( const com::sun::star::uno::Any& rAny );
279 static sal_Bool GetBoolProperty( const com::sun::star::uno::Reference<
280 com::sun::star::beans::XPropertySet>& xProp,
281 const ::rtl::OUString& rName, sal_Bool bDefault = sal_False );
282 static sal_Int32 GetLongProperty( const com::sun::star::uno::Reference<
283 com::sun::star::beans::XPropertySet>& xProp,
284 const ::rtl::OUString& rName, long nDefault = 0 );
285 static sal_Int32 GetEnumProperty( const com::sun::star::uno::Reference<
286 com::sun::star::beans::XPropertySet>& xProp,
287 const ::rtl::OUString& rName, long nDefault );
288 static ::rtl::OUString GetStringProperty(
289 const com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet>& xProp,
290 const ::rtl::OUString& rName, const ::rtl::OUString& rDefault );
292 static sal_Bool GetBoolFromAny( const com::sun::star::uno::Any& aAny );
293 static sal_Int16 GetInt16FromAny( const com::sun::star::uno::Any& aAny );
294 static sal_Int32 GetInt32FromAny( const com::sun::star::uno::Any& aAny );
295 static sal_Int32 GetEnumFromAny( const com::sun::star::uno::Any& aAny );
296 static void SetBoolInAny( com::sun::star::uno::Any& rAny, sal_Bool bValue );
298 static void SetOptionalPropertyValue(
299 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rPropSet,
300 const sal_Char* pPropName, const ::com::sun::star::uno::Any& rVal );
302 template<typename ValueType>
303 static void SetOptionalPropertyValue(
304 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rPropSet,
305 const sal_Char* pPropName, const ValueType& rVal )
307 ::com::sun::star::uno::Any any;
308 any <<= rVal;
309 SetOptionalPropertyValue(rPropSet, pPropName, any);
315 #endif