1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: miscuno.hxx,v $
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 #ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
35 #include <com/sun/star/lang/XServiceInfo.hpp>
37 #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
38 #include <com/sun/star/beans/XPropertySet.hpp>
40 #ifndef _COM_SUN_STAR_CONTAINER_XENUMERATIONACCESS_HPP_
41 #include <com/sun/star/container/XEnumerationAccess.hpp>
43 #ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
44 #include <com/sun/star/container/XNameAccess.hpp>
46 #ifndef _COM_SUN_STAR_CONTAINER_XINDEXACCESS_HPP_
47 #include <com/sun/star/container/XIndexAccess.hpp>
50 #ifndef _CPPUHELPER_IMPLBASE2_HXX_
51 #include <cppuhelper/implbase2.hxx>
56 #define SC_SIMPLE_SERVICE_INFO( ClassName, ClassNameAscii, ServiceAscii ) \
57 ::rtl::OUString SAL_CALL ClassName::getImplementationName() \
58 throw(::com::sun::star::uno::RuntimeException) \
60 return ::rtl::OUString::createFromAscii(ClassNameAscii); \
62 sal_Bool SAL_CALL ClassName::supportsService( const ::rtl::OUString& ServiceName ) \
63 throw(::com::sun::star::uno::RuntimeException) \
65 return !ServiceName.compareToAscii(ServiceAscii); \
67 ::com::sun::star::uno::Sequence< ::rtl::OUString > \
68 SAL_CALL ClassName::getSupportedServiceNames(void) \
69 throw(::com::sun::star::uno::RuntimeException) \
71 ::com::sun::star::uno::Sequence< ::rtl::OUString > aRet(1); \
72 ::rtl::OUString* pArray = aRet.getArray(); \
73 pArray[0] = ::rtl::OUString::createFromAscii(ServiceAscii); \
77 #define SC_IMPL_DUMMY_PROPERTY_LISTENER( ClassName ) \
78 void SAL_CALL ClassName::addPropertyChangeListener( const ::rtl::OUString&, \
79 const uno::Reference<beans::XPropertyChangeListener>&) \
80 throw(beans::UnknownPropertyException, \
81 lang::WrappedTargetException, uno::RuntimeException) \
82 { DBG_ERROR("not implemented"); } \
83 void SAL_CALL ClassName::removePropertyChangeListener( const ::rtl::OUString&, \
84 const uno::Reference<beans::XPropertyChangeListener>&) \
85 throw(beans::UnknownPropertyException, \
86 lang::WrappedTargetException, uno::RuntimeException) \
87 { DBG_ERROR("not implemented"); } \
88 void SAL_CALL ClassName::addVetoableChangeListener( const ::rtl::OUString&, \
89 const uno::Reference<beans::XVetoableChangeListener>&) \
90 throw(beans::UnknownPropertyException, \
91 lang::WrappedTargetException, uno::RuntimeException) \
92 { DBG_ERROR("not implemented"); } \
93 void SAL_CALL ClassName::removeVetoableChangeListener( const ::rtl::OUString&, \
94 const uno::Reference<beans::XVetoableChangeListener>&) \
95 throw(beans::UnknownPropertyException, \
96 lang::WrappedTargetException, uno::RuntimeException) \
97 { DBG_ERROR("not implemented"); }
100 #define SC_QUERYINTERFACE(x) \
101 if (rType == getCppuType((const uno::Reference<x>*)0)) \
102 { uno::Any aR; aR <<= uno::Reference<x>(this); return aR; }
104 // SC_QUERY_MULTIPLE( XElementAccess, XIndexAccess ):
105 // use if interface is used several times in one class
107 #define SC_QUERY_MULTIPLE(x,y) \
108 if (rType == getCppuType((const uno::Reference<x>*)0)) \
109 { uno::Any aR; aR <<= uno::Reference<x>(static_cast<y*>(this)); return aR; }
112 class ScIndexEnumeration
: public cppu::WeakImplHelper2
<
113 ::com::sun::star::container::XEnumeration
,
114 ::com::sun::star::lang::XServiceInfo
>
117 ::com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexAccess
> xIndex
;
118 ::rtl::OUString sServiceName
;
122 ScIndexEnumeration(const ::com::sun::star::uno::Reference
<
123 ::com::sun::star::container::XIndexAccess
>& rInd
, const ::rtl::OUString
& rServiceName
);
124 virtual ~ScIndexEnumeration();
127 virtual sal_Bool SAL_CALL
hasMoreElements() throw(::com::sun::star::uno::RuntimeException
);
128 virtual ::com::sun::star::uno::Any SAL_CALL
nextElement()
129 throw(::com::sun::star::container::NoSuchElementException
,
130 ::com::sun::star::lang::WrappedTargetException
,
131 ::com::sun::star::uno::RuntimeException
);
134 virtual ::rtl::OUString SAL_CALL
getImplementationName( )
135 throw(::com::sun::star::uno::RuntimeException
);
136 virtual sal_Bool SAL_CALL
supportsService( const ::rtl::OUString
& ServiceName
)
137 throw(::com::sun::star::uno::RuntimeException
);
138 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames( )
139 throw(::com::sun::star::uno::RuntimeException
);
143 class ScEmptyEnumerationAccess
: public cppu::WeakImplHelper2
<
144 ::com::sun::star::container::XEnumerationAccess
,
145 ::com::sun::star::lang::XServiceInfo
>
148 virtual ~ScEmptyEnumerationAccess();
150 // XEnumerationAccess
151 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::container::XEnumeration
> SAL_CALL
152 createEnumeration() throw(::com::sun::star::uno::RuntimeException
);
155 virtual ::com::sun::star::uno::Type SAL_CALL
getElementType()
156 throw(::com::sun::star::uno::RuntimeException
);
157 virtual sal_Bool SAL_CALL
hasElements() throw(::com::sun::star::uno::RuntimeException
);
160 virtual ::rtl::OUString SAL_CALL
getImplementationName( )
161 throw(::com::sun::star::uno::RuntimeException
);
162 virtual sal_Bool SAL_CALL
supportsService( const ::rtl::OUString
& ServiceName
)
163 throw(::com::sun::star::uno::RuntimeException
);
164 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames( )
165 throw(::com::sun::star::uno::RuntimeException
);
169 class ScEmptyEnumeration
: public cppu::WeakImplHelper2
<
170 ::com::sun::star::container::XEnumeration
,
171 ::com::sun::star::lang::XServiceInfo
>
174 ScEmptyEnumeration();
175 virtual ~ScEmptyEnumeration();
178 virtual sal_Bool SAL_CALL
hasMoreElements() throw(::com::sun::star::uno::RuntimeException
);
179 virtual ::com::sun::star::uno::Any SAL_CALL
nextElement()
180 throw(::com::sun::star::container::NoSuchElementException
,
181 ::com::sun::star::lang::WrappedTargetException
,
182 ::com::sun::star::uno::RuntimeException
);
185 virtual ::rtl::OUString SAL_CALL
getImplementationName( )
186 throw(::com::sun::star::uno::RuntimeException
);
187 virtual sal_Bool SAL_CALL
supportsService( const ::rtl::OUString
& ServiceName
)
188 throw(::com::sun::star::uno::RuntimeException
);
189 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames( )
190 throw(::com::sun::star::uno::RuntimeException
);
193 // new (uno 3) variant
194 class ScNameToIndexAccess
: public cppu::WeakImplHelper2
<
195 ::com::sun::star::container::XIndexAccess
,
196 ::com::sun::star::lang::XServiceInfo
>
199 ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameAccess
> xNameAccess
;
200 ::com::sun::star::uno::Sequence
<rtl::OUString
> aNames
;
204 const ::com::sun::star::uno::Reference
<
205 ::com::sun::star::container::XNameAccess
>& rNameObj
);
206 virtual ~ScNameToIndexAccess();
209 virtual sal_Int32 SAL_CALL
getCount( ) throw(::com::sun::star::uno::RuntimeException
);
210 virtual ::com::sun::star::uno::Any SAL_CALL
getByIndex( sal_Int32 Index
)
211 throw(::com::sun::star::lang::IndexOutOfBoundsException
,
212 ::com::sun::star::lang::WrappedTargetException
,
213 ::com::sun::star::uno::RuntimeException
);
216 virtual ::com::sun::star::uno::Type SAL_CALL
getElementType( )
217 throw(::com::sun::star::uno::RuntimeException
);
218 virtual sal_Bool SAL_CALL
hasElements( ) throw(::com::sun::star::uno::RuntimeException
);
221 virtual ::rtl::OUString SAL_CALL
getImplementationName( )
222 throw(::com::sun::star::uno::RuntimeException
);
223 virtual sal_Bool SAL_CALL
supportsService( const ::rtl::OUString
& ServiceName
)
224 throw(::com::sun::star::uno::RuntimeException
);
225 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames( )
226 throw(::com::sun::star::uno::RuntimeException
);
229 class ScPrintSettingsObj
: public cppu::WeakImplHelper2
<
230 ::com::sun::star::beans::XPropertySet
,
231 ::com::sun::star::lang::XServiceInfo
>
234 virtual ~ScPrintSettingsObj();
237 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySetInfo
>
238 SAL_CALL
getPropertySetInfo()
239 throw(::com::sun::star::uno::RuntimeException
);
240 virtual void SAL_CALL
setPropertyValue( const ::rtl::OUString
& aPropertyName
,
241 const ::com::sun::star::uno::Any
& aValue
)
242 throw(::com::sun::star::beans::UnknownPropertyException
,
243 ::com::sun::star::beans::PropertyVetoException
,
244 ::com::sun::star::lang::IllegalArgumentException
,
245 ::com::sun::star::lang::WrappedTargetException
,
246 ::com::sun::star::uno::RuntimeException
);
247 virtual ::com::sun::star::uno::Any SAL_CALL
getPropertyValue(
248 const ::rtl::OUString
& PropertyName
)
249 throw(::com::sun::star::beans::UnknownPropertyException
,
250 ::com::sun::star::lang::WrappedTargetException
,
251 ::com::sun::star::uno::RuntimeException
);
252 virtual void SAL_CALL
addPropertyChangeListener( const ::rtl::OUString
& aPropertyName
,
253 const ::com::sun::star::uno::Reference
<
254 ::com::sun::star::beans::XPropertyChangeListener
>& xListener
)
255 throw(::com::sun::star::beans::UnknownPropertyException
,
256 ::com::sun::star::lang::WrappedTargetException
,
257 ::com::sun::star::uno::RuntimeException
);
258 virtual void SAL_CALL
removePropertyChangeListener( const ::rtl::OUString
& aPropertyName
,
259 const ::com::sun::star::uno::Reference
<
260 ::com::sun::star::beans::XPropertyChangeListener
>& aListener
)
261 throw(::com::sun::star::beans::UnknownPropertyException
,
262 ::com::sun::star::lang::WrappedTargetException
,
263 ::com::sun::star::uno::RuntimeException
);
264 virtual void SAL_CALL
addVetoableChangeListener( const ::rtl::OUString
& PropertyName
,
265 const ::com::sun::star::uno::Reference
<
266 ::com::sun::star::beans::XVetoableChangeListener
>& aListener
)
267 throw(::com::sun::star::beans::UnknownPropertyException
,
268 ::com::sun::star::lang::WrappedTargetException
,
269 ::com::sun::star::uno::RuntimeException
);
270 virtual void SAL_CALL
removeVetoableChangeListener( const ::rtl::OUString
& PropertyName
,
271 const ::com::sun::star::uno::Reference
<
272 ::com::sun::star::beans::XVetoableChangeListener
>& aListener
)
273 throw(::com::sun::star::beans::UnknownPropertyException
,
274 ::com::sun::star::lang::WrappedTargetException
,
275 ::com::sun::star::uno::RuntimeException
);
278 virtual ::rtl::OUString SAL_CALL
getImplementationName( )
279 throw(::com::sun::star::uno::RuntimeException
);
280 virtual sal_Bool SAL_CALL
supportsService( const ::rtl::OUString
& ServiceName
)
281 throw(::com::sun::star::uno::RuntimeException
);
282 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames( )
283 throw(::com::sun::star::uno::RuntimeException
);
287 class ScUnoHelpFunctions
290 static ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>
291 AnyToInterface( const ::com::sun::star::uno::Any
& rAny
);
292 static sal_Bool
GetBoolProperty( const ::com::sun::star::uno::Reference
<
293 ::com::sun::star::beans::XPropertySet
>& xProp
,
294 const ::rtl::OUString
& rName
, sal_Bool bDefault
= sal_False
);
295 static sal_Int32
GetLongProperty( const ::com::sun::star::uno::Reference
<
296 ::com::sun::star::beans::XPropertySet
>& xProp
,
297 const ::rtl::OUString
& rName
, long nDefault
= 0 );
298 static sal_Int32
GetEnumProperty( const ::com::sun::star::uno::Reference
<
299 ::com::sun::star::beans::XPropertySet
>& xProp
,
300 const ::rtl::OUString
& rName
, long nDefault
);
302 static sal_Bool
GetBoolFromAny( const ::com::sun::star::uno::Any
& aAny
);
303 static sal_Int16
GetInt16FromAny( const ::com::sun::star::uno::Any
& aAny
);
304 static sal_Int32
GetInt32FromAny( const ::com::sun::star::uno::Any
& aAny
);
305 static sal_Int32
GetEnumFromAny( const ::com::sun::star::uno::Any
& aAny
);
306 static void SetBoolInAny( ::com::sun::star::uno::Any
& rAny
, sal_Bool bValue
);
311 } //namespace binfilter