Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
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"
26 :
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;
35 :
36 : // com::sun::star::lang::XTypeProvider
37 0 : Sequence< Type > OCallableStatement::getTypes() throw (RuntimeException, std::exception)
38 : {
39 0 : OTypeCollection aTypes(cppu::UnoType<XRow>::get(),
40 0 : cppu::UnoType<XOutParameters>::get(),
41 0 : OPreparedStatement::getTypes() );
42 :
43 0 : return aTypes.getTypes();
44 : }
45 :
46 0 : Sequence< sal_Int8 > OCallableStatement::getImplementationId() throw (RuntimeException, std::exception)
47 : {
48 0 : return css::uno::Sequence<sal_Int8>();
49 : }
50 :
51 : // com::sun::star::uno::XInterface
52 0 : Any OCallableStatement::queryInterface( const Type & rType ) throw (RuntimeException, std::exception)
53 : {
54 0 : Any aIface = OPreparedStatement::queryInterface( rType );
55 0 : if (!aIface.hasValue())
56 0 : aIface = ::cppu::queryInterface(
57 : rType,
58 : static_cast< XRow * >( this ),
59 0 : static_cast< XOutParameters * >( this ));
60 0 : return aIface;
61 : }
62 :
63 0 : void OCallableStatement::acquire() throw ()
64 : {
65 0 : OPreparedStatement::acquire();
66 0 : }
67 :
68 0 : void OCallableStatement::release() throw ()
69 : {
70 0 : OPreparedStatement::release();
71 0 : }
72 :
73 : // XServiceInfo
74 0 : OUString OCallableStatement::getImplementationName( ) throw(RuntimeException, std::exception)
75 : {
76 0 : return OUString("com.sun.star.sdb.OCallableStatement");
77 : }
78 :
79 0 : Sequence< OUString > OCallableStatement::getSupportedServiceNames( ) throw (RuntimeException, std::exception)
80 : {
81 0 : Sequence< OUString > aSNS( 2 );
82 0 : aSNS.getArray()[0] = SERVICE_SDBC_CALLABLESTATEMENT;
83 0 : aSNS.getArray()[1] = SERVICE_SDB_CALLABLESTATEMENT;
84 0 : return aSNS;
85 : }
86 :
87 : // XOutParameters
88 0 : void SAL_CALL OCallableStatement::registerOutParameter( sal_Int32 parameterIndex, sal_Int32 sqlType, const OUString& typeName ) throw(SQLException, RuntimeException, std::exception)
89 : {
90 0 : MutexGuard aGuard(m_aMutex);
91 :
92 0 : ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
93 :
94 0 : Reference< XOutParameters >(m_xAggregateAsSet, UNO_QUERY)->registerOutParameter( parameterIndex, sqlType, typeName );
95 0 : }
96 :
97 0 : void SAL_CALL OCallableStatement::registerNumericOutParameter( sal_Int32 parameterIndex, sal_Int32 sqlType, sal_Int32 scale ) throw(SQLException, RuntimeException, std::exception)
98 : {
99 0 : MutexGuard aGuard(m_aMutex);
100 0 : ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
101 :
102 0 : Reference< XOutParameters >(m_xAggregateAsSet, UNO_QUERY)->registerNumericOutParameter( parameterIndex, sqlType, scale );
103 0 : }
104 :
105 : // XRow
106 0 : sal_Bool SAL_CALL OCallableStatement::wasNull( ) throw(SQLException, RuntimeException, std::exception)
107 : {
108 0 : MutexGuard aGuard(m_aMutex);
109 0 : ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
110 :
111 0 : return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->wasNull();
112 : }
113 :
114 0 : OUString SAL_CALL OCallableStatement::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
115 : {
116 0 : MutexGuard aGuard(m_aMutex);
117 0 : ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
118 :
119 0 : return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getString( columnIndex );
120 : }
121 :
122 0 : sal_Bool SAL_CALL OCallableStatement::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
123 : {
124 0 : MutexGuard aGuard(m_aMutex);
125 0 : ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
126 :
127 0 : return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getBoolean( columnIndex );
128 : }
129 :
130 0 : sal_Int8 SAL_CALL OCallableStatement::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
131 : {
132 0 : MutexGuard aGuard(m_aMutex);
133 0 : ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
134 :
135 0 : return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getByte( columnIndex );
136 : }
137 :
138 0 : sal_Int16 SAL_CALL OCallableStatement::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
139 : {
140 0 : MutexGuard aGuard(m_aMutex);
141 0 : ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
142 0 : return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getShort( columnIndex );
143 : }
144 :
145 0 : sal_Int32 SAL_CALL OCallableStatement::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
146 : {
147 0 : MutexGuard aGuard(m_aMutex);
148 0 : ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
149 0 : return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getInt( columnIndex );
150 : }
151 :
152 0 : sal_Int64 SAL_CALL OCallableStatement::getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
153 : {
154 0 : MutexGuard aGuard(m_aMutex);
155 0 : ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
156 0 : return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getLong( columnIndex );
157 : }
158 :
159 0 : float SAL_CALL OCallableStatement::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
160 : {
161 0 : MutexGuard aGuard(m_aMutex);
162 0 : ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
163 0 : return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getFloat( columnIndex );
164 : }
165 :
166 0 : double SAL_CALL OCallableStatement::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
167 : {
168 0 : MutexGuard aGuard(m_aMutex);
169 0 : ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
170 0 : return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getDouble( columnIndex );
171 : }
172 :
173 0 : Sequence< sal_Int8 > SAL_CALL OCallableStatement::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
174 : {
175 0 : MutexGuard aGuard(m_aMutex);
176 0 : ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
177 0 : return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getBytes( columnIndex );
178 : }
179 :
180 0 : ::com::sun::star::util::Date SAL_CALL OCallableStatement::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
181 : {
182 0 : MutexGuard aGuard(m_aMutex);
183 0 : ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
184 0 : return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getDate( columnIndex );
185 : }
186 :
187 0 : ::com::sun::star::util::Time SAL_CALL OCallableStatement::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
188 : {
189 0 : MutexGuard aGuard(m_aMutex);
190 0 : ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
191 0 : return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getTime( columnIndex );
192 : }
193 :
194 0 : ::com::sun::star::util::DateTime SAL_CALL OCallableStatement::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
195 : {
196 0 : MutexGuard aGuard(m_aMutex);
197 0 : ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
198 :
199 0 : return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getTimestamp( columnIndex );
200 : }
201 :
202 0 : Reference< ::com::sun::star::io::XInputStream > SAL_CALL OCallableStatement::getBinaryStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
203 : {
204 0 : MutexGuard aGuard(m_aMutex);
205 0 : ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
206 :
207 0 : return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getBinaryStream( columnIndex );
208 : }
209 :
210 0 : Reference< ::com::sun::star::io::XInputStream > SAL_CALL OCallableStatement::getCharacterStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
211 : {
212 0 : MutexGuard aGuard(m_aMutex);
213 0 : ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
214 :
215 0 : return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getCharacterStream( columnIndex );
216 : }
217 :
218 0 : Any SAL_CALL OCallableStatement::getObject( sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(SQLException, RuntimeException, std::exception)
219 : {
220 0 : MutexGuard aGuard(m_aMutex);
221 0 : ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
222 :
223 0 : return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getObject( columnIndex, typeMap );
224 : }
225 :
226 0 : Reference< XRef > SAL_CALL OCallableStatement::getRef( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
227 : {
228 0 : MutexGuard aGuard(m_aMutex);
229 0 : ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
230 0 : return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getRef( columnIndex );
231 : }
232 :
233 0 : Reference< XBlob > SAL_CALL OCallableStatement::getBlob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
234 : {
235 0 : MutexGuard aGuard(m_aMutex);
236 0 : ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
237 0 : return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getBlob( columnIndex );
238 : }
239 :
240 0 : Reference< XClob > SAL_CALL OCallableStatement::getClob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
241 : {
242 0 : MutexGuard aGuard(m_aMutex);
243 0 : ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
244 0 : return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getClob( columnIndex );
245 : }
246 :
247 0 : Reference< XArray > SAL_CALL OCallableStatement::getArray( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
248 : {
249 0 : MutexGuard aGuard(m_aMutex);
250 0 : ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
251 0 : return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getArray( columnIndex );
252 : }
253 :
254 :
255 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|