Bump version to 5.0-14
[LibreOffice.git] / dbaccess / source / core / api / callablestatement.cxx
blob23b733fa6c5d4c9399cb8b2f5991a73a8a748811
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 #include <callablestatement.hxx>
21 #include <com/sun/star/lang/DisposedException.hpp>
22 #include <cppuhelper/typeprovider.hxx>
23 #include <cppuhelper/queryinterface.hxx>
24 #include <comphelper/property.hxx>
25 #include "dbastrings.hrc"
27 using namespace dbaccess;
28 using namespace ::com::sun::star::sdbc;
29 using namespace ::com::sun::star::sdbcx;
30 using namespace ::com::sun::star::beans;
31 using namespace ::com::sun::star::uno;
32 using namespace ::com::sun::star::lang;
33 using namespace ::cppu;
34 using namespace ::osl;
36 // com::sun::star::lang::XTypeProvider
37 Sequence< Type > OCallableStatement::getTypes() throw (RuntimeException, std::exception)
39 OTypeCollection aTypes(cppu::UnoType<XRow>::get(),
40 cppu::UnoType<XOutParameters>::get(),
41 OPreparedStatement::getTypes() );
43 return aTypes.getTypes();
46 Sequence< sal_Int8 > OCallableStatement::getImplementationId() throw (RuntimeException, std::exception)
48 return css::uno::Sequence<sal_Int8>();
51 // com::sun::star::uno::XInterface
52 Any OCallableStatement::queryInterface( const Type & rType ) throw (RuntimeException, std::exception)
54 Any aIface = OPreparedStatement::queryInterface( rType );
55 if (!aIface.hasValue())
56 aIface = ::cppu::queryInterface(
57 rType,
58 static_cast< XRow * >( this ),
59 static_cast< XOutParameters * >( this ));
60 return aIface;
63 void OCallableStatement::acquire() throw ()
65 OPreparedStatement::acquire();
68 void OCallableStatement::release() throw ()
70 OPreparedStatement::release();
73 // XServiceInfo
74 OUString OCallableStatement::getImplementationName( ) throw(RuntimeException, std::exception)
76 return OUString("com.sun.star.sdb.OCallableStatement");
79 Sequence< OUString > OCallableStatement::getSupportedServiceNames( ) throw (RuntimeException, std::exception)
81 Sequence< OUString > aSNS( 2 );
82 aSNS.getArray()[0] = SERVICE_SDBC_CALLABLESTATEMENT;
83 aSNS.getArray()[1] = SERVICE_SDB_CALLABLESTATEMENT;
84 return aSNS;
87 // XOutParameters
88 void SAL_CALL OCallableStatement::registerOutParameter( sal_Int32 parameterIndex, sal_Int32 sqlType, const OUString& typeName ) throw(SQLException, RuntimeException, std::exception)
90 MutexGuard aGuard(m_aMutex);
92 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
94 Reference< XOutParameters >(m_xAggregateAsSet, UNO_QUERY)->registerOutParameter( parameterIndex, sqlType, typeName );
97 void SAL_CALL OCallableStatement::registerNumericOutParameter( sal_Int32 parameterIndex, sal_Int32 sqlType, sal_Int32 scale ) throw(SQLException, RuntimeException, std::exception)
99 MutexGuard aGuard(m_aMutex);
100 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
102 Reference< XOutParameters >(m_xAggregateAsSet, UNO_QUERY)->registerNumericOutParameter( parameterIndex, sqlType, scale );
105 // XRow
106 sal_Bool SAL_CALL OCallableStatement::wasNull( ) throw(SQLException, RuntimeException, std::exception)
108 MutexGuard aGuard(m_aMutex);
109 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
111 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->wasNull();
114 OUString SAL_CALL OCallableStatement::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
116 MutexGuard aGuard(m_aMutex);
117 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
119 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getString( columnIndex );
122 sal_Bool SAL_CALL OCallableStatement::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
124 MutexGuard aGuard(m_aMutex);
125 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
127 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getBoolean( columnIndex );
130 sal_Int8 SAL_CALL OCallableStatement::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
132 MutexGuard aGuard(m_aMutex);
133 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
135 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getByte( columnIndex );
138 sal_Int16 SAL_CALL OCallableStatement::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
140 MutexGuard aGuard(m_aMutex);
141 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
142 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getShort( columnIndex );
145 sal_Int32 SAL_CALL OCallableStatement::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
147 MutexGuard aGuard(m_aMutex);
148 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
149 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getInt( columnIndex );
152 sal_Int64 SAL_CALL OCallableStatement::getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
154 MutexGuard aGuard(m_aMutex);
155 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
156 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getLong( columnIndex );
159 float SAL_CALL OCallableStatement::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
161 MutexGuard aGuard(m_aMutex);
162 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
163 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getFloat( columnIndex );
166 double SAL_CALL OCallableStatement::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
168 MutexGuard aGuard(m_aMutex);
169 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
170 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getDouble( columnIndex );
173 Sequence< sal_Int8 > SAL_CALL OCallableStatement::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
175 MutexGuard aGuard(m_aMutex);
176 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
177 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getBytes( columnIndex );
180 ::com::sun::star::util::Date SAL_CALL OCallableStatement::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
182 MutexGuard aGuard(m_aMutex);
183 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
184 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getDate( columnIndex );
187 ::com::sun::star::util::Time SAL_CALL OCallableStatement::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
189 MutexGuard aGuard(m_aMutex);
190 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
191 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getTime( columnIndex );
194 ::com::sun::star::util::DateTime SAL_CALL OCallableStatement::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
196 MutexGuard aGuard(m_aMutex);
197 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
199 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getTimestamp( columnIndex );
202 Reference< ::com::sun::star::io::XInputStream > SAL_CALL OCallableStatement::getBinaryStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
204 MutexGuard aGuard(m_aMutex);
205 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
207 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getBinaryStream( columnIndex );
210 Reference< ::com::sun::star::io::XInputStream > SAL_CALL OCallableStatement::getCharacterStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
212 MutexGuard aGuard(m_aMutex);
213 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
215 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getCharacterStream( columnIndex );
218 Any SAL_CALL OCallableStatement::getObject( sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(SQLException, RuntimeException, std::exception)
220 MutexGuard aGuard(m_aMutex);
221 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
223 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getObject( columnIndex, typeMap );
226 Reference< XRef > SAL_CALL OCallableStatement::getRef( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
228 MutexGuard aGuard(m_aMutex);
229 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
230 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getRef( columnIndex );
233 Reference< XBlob > SAL_CALL OCallableStatement::getBlob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
235 MutexGuard aGuard(m_aMutex);
236 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
237 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getBlob( columnIndex );
240 Reference< XClob > SAL_CALL OCallableStatement::getClob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
242 MutexGuard aGuard(m_aMutex);
243 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
244 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getClob( columnIndex );
247 Reference< XArray > SAL_CALL OCallableStatement::getArray( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
249 MutexGuard aGuard(m_aMutex);
250 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
251 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getArray( columnIndex );
255 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */