update emoji autocorrect entries from po-files
[LibreOffice.git] / sc / inc / miscuno.hxx
blob8ff6233647871bc77acc3e86da3bc5e2e1d9c822
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SC_INC_MISCUNO_HXX
21 #define INCLUDED_SC_INC_MISCUNO_HXX
23 #include <com/sun/star/lang/XServiceInfo.hpp>
24 #include <com/sun/star/beans/XPropertySet.hpp>
25 #include <com/sun/star/container/XEnumerationAccess.hpp>
26 #include <com/sun/star/container/XNameAccess.hpp>
27 #include <com/sun/star/container/XEnumeration.hpp>
28 #include <com/sun/star/container/XIndexAccess.hpp>
29 #include <cppuhelper/implbase2.hxx>
30 #include <cppuhelper/supportsservice.hxx>
31 #include "scdllapi.h"
33 #define SC_SIMPLE_SERVICE_INFO( ClassName, ClassNameAscii, ServiceAscii ) \
34 OUString SAL_CALL ClassName::getImplementationName() \
35 throw(::com::sun::star::uno::RuntimeException, std::exception) \
36 { \
37 return OUString(ClassNameAscii); \
38 } \
39 sal_Bool SAL_CALL ClassName::supportsService( const OUString& ServiceName ) \
40 throw(::com::sun::star::uno::RuntimeException, std::exception) \
41 { \
42 return cppu::supportsService(this, ServiceName); \
43 } \
44 ::com::sun::star::uno::Sequence< OUString > \
45 SAL_CALL ClassName::getSupportedServiceNames() \
46 throw(::com::sun::star::uno::RuntimeException, std::exception) \
47 { \
48 ::com::sun::star::uno::Sequence< OUString > aRet(1); \
49 OUString* pArray = aRet.getArray(); \
50 pArray[0] = ServiceAscii; \
51 return aRet; \
54 #define SC_IMPL_DUMMY_PROPERTY_LISTENER( ClassName ) \
55 void SAL_CALL ClassName::addPropertyChangeListener( const OUString&, \
56 const uno::Reference<beans::XPropertyChangeListener>&) \
57 throw(beans::UnknownPropertyException, \
58 lang::WrappedTargetException, uno::RuntimeException, std::exception) \
59 { OSL_FAIL("not implemented"); } \
60 void SAL_CALL ClassName::removePropertyChangeListener( const OUString&, \
61 const uno::Reference<beans::XPropertyChangeListener>&) \
62 throw(beans::UnknownPropertyException, \
63 lang::WrappedTargetException, uno::RuntimeException, std::exception) \
64 { OSL_FAIL("not implemented"); } \
65 void SAL_CALL ClassName::addVetoableChangeListener( const OUString&, \
66 const uno::Reference<beans::XVetoableChangeListener>&) \
67 throw(beans::UnknownPropertyException, \
68 lang::WrappedTargetException, uno::RuntimeException, std::exception) \
69 { OSL_FAIL("not implemented"); } \
70 void SAL_CALL ClassName::removeVetoableChangeListener( const OUString&, \
71 const uno::Reference<beans::XVetoableChangeListener>&) \
72 throw(beans::UnknownPropertyException, \
73 lang::WrappedTargetException, uno::RuntimeException, std::exception) \
74 { OSL_FAIL("not implemented"); }
76 #define SC_QUERYINTERFACE(x) \
77 if (rType == cppu::UnoType<x>::get()) \
78 { return uno::makeAny(uno::Reference<x>(this)); }
80 // SC_QUERY_MULTIPLE( XElementAccess, XIndexAccess ):
81 // use if interface is used several times in one class
83 #define SC_QUERY_MULTIPLE(x,y) \
84 if (rType == cppu::UnoType<x>::get()) \
85 { uno::Any aR; aR <<= uno::Reference<x>(static_cast<y*>(this)); return aR; }
87 class ScIndexEnumeration : public cppu::WeakImplHelper2<
88 com::sun::star::container::XEnumeration,
89 com::sun::star::lang::XServiceInfo >
91 private:
92 com::sun::star::uno::Reference<com::sun::star::container::XIndexAccess> xIndex;
93 OUString sServiceName;
94 sal_Int32 nPos;
96 public:
97 ScIndexEnumeration(const com::sun::star::uno::Reference<
98 com::sun::star::container::XIndexAccess>& rInd, const OUString& rServiceName);
99 virtual ~ScIndexEnumeration();
101 // XEnumeration
102 virtual sal_Bool SAL_CALL hasMoreElements() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
103 virtual ::com::sun::star::uno::Any SAL_CALL nextElement()
104 throw(::com::sun::star::container::NoSuchElementException,
105 ::com::sun::star::lang::WrappedTargetException,
106 ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
108 // XServiceInfo
109 virtual OUString SAL_CALL getImplementationName( )
110 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
111 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
112 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
113 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( )
114 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
117 // new (uno 3) variant
118 class ScNameToIndexAccess : public cppu::WeakImplHelper2<
119 com::sun::star::container::XIndexAccess,
120 com::sun::star::lang::XServiceInfo >
122 private:
123 com::sun::star::uno::Reference<com::sun::star::container::XNameAccess> xNameAccess;
124 com::sun::star::uno::Sequence<OUString> aNames;
126 public:
127 ScNameToIndexAccess(
128 const com::sun::star::uno::Reference<
129 com::sun::star::container::XNameAccess>& rNameObj );
130 virtual ~ScNameToIndexAccess();
132 // XIndexAccess
133 virtual sal_Int32 SAL_CALL getCount( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
134 virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index )
135 throw(::com::sun::star::lang::IndexOutOfBoundsException,
136 ::com::sun::star::lang::WrappedTargetException,
137 ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
139 // XElementAccess
140 virtual ::com::sun::star::uno::Type SAL_CALL getElementType( )
141 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
142 virtual sal_Bool SAL_CALL hasElements( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
144 // XServiceInfo
145 virtual OUString SAL_CALL getImplementationName( )
146 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
147 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
148 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
149 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( )
150 throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
153 class SC_DLLPUBLIC ScUnoHelpFunctions
155 public:
156 static com::sun::star::uno::Reference<com::sun::star::uno::XInterface>
157 AnyToInterface( const com::sun::star::uno::Any& rAny );
158 static bool GetBoolProperty( const com::sun::star::uno::Reference<
159 com::sun::star::beans::XPropertySet>& xProp,
160 const OUString& rName, bool bDefault = false );
161 static sal_Int32 GetLongProperty( const com::sun::star::uno::Reference<
162 com::sun::star::beans::XPropertySet>& xProp,
163 const OUString& rName, long nDefault = 0 );
164 static sal_Int32 GetEnumProperty( const com::sun::star::uno::Reference<
165 com::sun::star::beans::XPropertySet>& xProp,
166 const OUString& rName, long nDefault );
167 static OUString GetStringProperty(
168 const com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet>& xProp,
169 const OUString& rName, const OUString& rDefault );
171 static bool GetBoolFromAny( const com::sun::star::uno::Any& aAny );
172 static sal_Int16 GetInt16FromAny( const com::sun::star::uno::Any& aAny );
173 static sal_Int32 GetInt32FromAny( const com::sun::star::uno::Any& aAny );
174 static sal_Int32 GetEnumFromAny( const com::sun::star::uno::Any& aAny );
175 static void SetBoolInAny( com::sun::star::uno::Any& rAny, bool bValue );
177 static void SetOptionalPropertyValue(
178 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rPropSet,
179 const sal_Char* pPropName, const ::com::sun::star::uno::Any& rVal );
181 template<typename ValueType>
182 static void SetOptionalPropertyValue(
183 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rPropSet,
184 const sal_Char* pPropName, const ValueType& rVal )
186 ::com::sun::star::uno::Any any;
187 any <<= rVal;
188 SetOptionalPropertyValue(rPropSet, pPropName, any);
191 template<typename ValueType>
192 static com::sun::star::uno::Sequence<ValueType> VectorToSequence( const std::vector<ValueType>& rVector )
194 if (rVector.empty())
195 return com::sun::star::uno::Sequence<ValueType>();
197 return com::sun::star::uno::Sequence<ValueType>(&rVector[0], static_cast<sal_Int32>(rVector.size()));
201 #endif
203 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */