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 "datacolumn.hxx"
21 : #include <com/sun/star/lang/DisposedException.hpp>
22 : #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
23 : #include <com/sun/star/sdbc/DataType.hpp>
24 : #include <com/sun/star/sdbc/ColumnValue.hpp>
25 : #include <cppuhelper/queryinterface.hxx>
26 : #include <cppuhelper/typeprovider.hxx>
27 : #include <tools/debug.hxx>
28 : #include "dbastrings.hrc"
29 : #include "apitools.hxx"
30 :
31 : using namespace dbaccess;
32 : using namespace ::com::sun::star::sdbc;
33 : using namespace ::com::sun::star::sdb;
34 : using namespace ::com::sun::star::beans;
35 : using namespace ::com::sun::star::uno;
36 : using namespace ::com::sun::star::lang;
37 : using namespace ::com::sun::star::container;
38 : using namespace ::osl;
39 : using namespace ::comphelper;
40 : using namespace ::cppu;
41 :
42 :
43 665 : ODataColumn::ODataColumn(
44 : const Reference < XResultSetMetaData >& _xMetaData,
45 : const Reference < XRow >& _xRow,
46 : const Reference < XRowUpdate >& _xRowUpdate,
47 : sal_Int32 _nPos,
48 : const Reference< XDatabaseMetaData >& _rxDBMeta)
49 : :OResultColumn(_xMetaData, _nPos, _rxDBMeta)
50 : ,m_xRow(_xRow)
51 665 : ,m_xRowUpdate(_xRowUpdate)
52 : {
53 665 : }
54 :
55 665 : ODataColumn::~ODataColumn()
56 : {
57 665 : }
58 :
59 : // com::sun::star::lang::XTypeProvider
60 0 : Sequence< Type > ODataColumn::getTypes() throw (RuntimeException, std::exception)
61 : {
62 0 : OTypeCollection aTypes(cppu::UnoType<XColumn>::get(),
63 0 : cppu::UnoType<XColumnUpdate>::get(),
64 0 : OColumn::getTypes());
65 0 : return aTypes.getTypes();
66 : }
67 :
68 0 : Sequence< sal_Int8 > ODataColumn::getImplementationId() throw (RuntimeException, std::exception)
69 : {
70 0 : return css::uno::Sequence<sal_Int8>();
71 : }
72 :
73 7641 : Any SAL_CALL ODataColumn::queryInterface( const Type & _rType ) throw (RuntimeException, std::exception)
74 : {
75 7641 : Any aReturn = OResultColumn::queryInterface(_rType);
76 7641 : if (!aReturn.hasValue())
77 2064 : aReturn = ::cppu::queryInterface(_rType,
78 : static_cast< XColumn* >(this),
79 : static_cast< XColumnUpdate* >(this)
80 1032 : );
81 7641 : return aReturn;
82 : }
83 :
84 : // XServiceInfo
85 0 : OUString ODataColumn::getImplementationName( ) throw(RuntimeException, std::exception)
86 : {
87 0 : return OUString("com.sun.star.sdb.ODataColumn");
88 : }
89 :
90 0 : Sequence< OUString > ODataColumn::getSupportedServiceNames( ) throw (RuntimeException, std::exception)
91 : {
92 0 : Sequence< OUString > aSNS( 3 );
93 0 : aSNS[0] = SERVICE_SDBCX_COLUMN;
94 0 : aSNS[1] = SERVICE_SDB_RESULTCOLUMN;
95 0 : aSNS[2] = SERVICE_SDB_DATACOLUMN;
96 0 : return aSNS;
97 : }
98 :
99 : // OComponentHelper
100 665 : void ODataColumn::disposing()
101 : {
102 665 : OResultColumn::disposing();
103 :
104 665 : m_xRow = NULL;
105 665 : m_xRowUpdate = NULL;
106 665 : }
107 :
108 : // ::com::sun::star::sdb::XColumn
109 73 : sal_Bool ODataColumn::wasNull() throw( SQLException, RuntimeException, std::exception )
110 : {
111 73 : MutexGuard aGuard(m_aMutex);
112 73 : ::connectivity::checkDisposed(!m_xRow.is());
113 :
114 73 : return m_xRow->wasNull();
115 : }
116 :
117 793 : OUString ODataColumn::getString() throw( SQLException, RuntimeException, std::exception )
118 : {
119 793 : MutexGuard aGuard(m_aMutex);
120 793 : ::connectivity::checkDisposed(!m_xRow.is());
121 :
122 793 : return m_xRow->getString(m_nPos);
123 : }
124 :
125 0 : sal_Bool ODataColumn::getBoolean() throw( SQLException, RuntimeException, std::exception )
126 : {
127 0 : MutexGuard aGuard(m_aMutex);
128 0 : ::connectivity::checkDisposed(!m_xRow.is());
129 :
130 0 : return m_xRow->getBoolean(m_nPos);
131 : }
132 :
133 0 : sal_Int8 ODataColumn::getByte() throw( SQLException, RuntimeException, std::exception )
134 : {
135 0 : MutexGuard aGuard(m_aMutex);
136 0 : ::connectivity::checkDisposed(!m_xRow.is());
137 :
138 0 : return m_xRow->getByte(m_nPos);
139 : }
140 :
141 0 : sal_Int16 ODataColumn::getShort() throw( SQLException, RuntimeException, std::exception )
142 : {
143 0 : MutexGuard aGuard(m_aMutex);
144 0 : ::connectivity::checkDisposed(!m_xRow.is());
145 :
146 0 : return m_xRow->getShort(m_nPos);
147 : }
148 :
149 0 : sal_Int32 ODataColumn::getInt() throw( SQLException, RuntimeException, std::exception )
150 : {
151 0 : MutexGuard aGuard(m_aMutex);
152 0 : ::connectivity::checkDisposed(!m_xRow.is());
153 :
154 0 : return m_xRow->getInt(m_nPos);
155 : }
156 :
157 0 : sal_Int64 ODataColumn::getLong() throw( SQLException, RuntimeException, std::exception )
158 : {
159 0 : MutexGuard aGuard(m_aMutex);
160 0 : ::connectivity::checkDisposed(!m_xRow.is());
161 :
162 0 : return m_xRow->getLong(m_nPos);
163 : }
164 :
165 0 : float ODataColumn::getFloat() throw( SQLException, RuntimeException, std::exception )
166 : {
167 0 : MutexGuard aGuard(m_aMutex);
168 0 : ::connectivity::checkDisposed(!m_xRow.is());
169 :
170 0 : return m_xRow->getFloat(m_nPos);
171 : }
172 :
173 0 : double ODataColumn::getDouble() throw( SQLException, RuntimeException, std::exception )
174 : {
175 0 : MutexGuard aGuard(m_aMutex);
176 0 : ::connectivity::checkDisposed(!m_xRow.is());
177 :
178 0 : return m_xRow->getDouble(m_nPos);
179 : }
180 :
181 0 : Sequence< sal_Int8 > ODataColumn::getBytes() throw( SQLException, RuntimeException, std::exception )
182 : {
183 0 : MutexGuard aGuard(m_aMutex);
184 0 : ::connectivity::checkDisposed(!m_xRow.is());
185 :
186 0 : return m_xRow->getBytes(m_nPos);
187 : }
188 :
189 0 : com::sun::star::util::Date ODataColumn::getDate() throw( SQLException, RuntimeException, std::exception )
190 : {
191 0 : MutexGuard aGuard(m_aMutex);
192 0 : ::connectivity::checkDisposed(!m_xRow.is());
193 :
194 0 : return m_xRow->getDate(m_nPos);
195 : }
196 :
197 0 : com::sun::star::util::Time ODataColumn::getTime() throw( SQLException, RuntimeException, std::exception )
198 : {
199 0 : MutexGuard aGuard(m_aMutex);
200 0 : ::connectivity::checkDisposed(!m_xRow.is());
201 :
202 0 : return m_xRow->getTime(m_nPos);
203 : }
204 :
205 0 : com::sun::star::util::DateTime ODataColumn::getTimestamp() throw( SQLException, RuntimeException, std::exception )
206 : {
207 0 : MutexGuard aGuard(m_aMutex);
208 0 : ::connectivity::checkDisposed(!m_xRow.is());
209 :
210 0 : return m_xRow->getTimestamp(m_nPos);
211 : }
212 :
213 0 : Reference< ::com::sun::star::io::XInputStream > ODataColumn::getBinaryStream() throw( SQLException, RuntimeException, std::exception )
214 : {
215 0 : MutexGuard aGuard(m_aMutex);
216 0 : ::connectivity::checkDisposed(!m_xRow.is());
217 :
218 0 : return m_xRow->getBinaryStream(m_nPos);
219 : }
220 :
221 0 : Reference< ::com::sun::star::io::XInputStream > ODataColumn::getCharacterStream() throw( SQLException, RuntimeException, std::exception )
222 : {
223 0 : MutexGuard aGuard(m_aMutex);
224 0 : ::connectivity::checkDisposed(!m_xRow.is());
225 :
226 0 : return m_xRow->getCharacterStream(m_nPos);
227 : }
228 :
229 0 : Any ODataColumn::getObject(const Reference< ::com::sun::star::container::XNameAccess > & typeMap) throw( SQLException, RuntimeException, std::exception )
230 : {
231 0 : MutexGuard aGuard(m_aMutex);
232 0 : ::connectivity::checkDisposed(!m_xRow.is());
233 :
234 0 : return m_xRow->getObject(m_nPos, typeMap);
235 : }
236 :
237 0 : Reference< XRef > ODataColumn::getRef() throw( SQLException, RuntimeException, std::exception )
238 : {
239 0 : MutexGuard aGuard(m_aMutex);
240 0 : ::connectivity::checkDisposed(!m_xRow.is());
241 :
242 0 : return m_xRow->getRef(m_nPos);
243 : }
244 :
245 0 : Reference< XBlob > ODataColumn::getBlob() throw( SQLException, RuntimeException, std::exception )
246 : {
247 0 : MutexGuard aGuard(m_aMutex);
248 0 : ::connectivity::checkDisposed(!m_xRow.is());
249 :
250 0 : return m_xRow->getBlob(m_nPos);
251 : }
252 :
253 0 : Reference< XClob > ODataColumn::getClob() throw( SQLException, RuntimeException, std::exception )
254 : {
255 0 : MutexGuard aGuard(m_aMutex);
256 0 : ::connectivity::checkDisposed(!m_xRow.is());
257 :
258 0 : return m_xRow->getClob(m_nPos);
259 : }
260 :
261 0 : Reference< XArray > ODataColumn::getArray() throw( SQLException, RuntimeException, std::exception )
262 : {
263 0 : MutexGuard aGuard(m_aMutex);
264 0 : ::connectivity::checkDisposed(!m_xRow.is());
265 :
266 0 : return m_xRow->getArray(m_nPos);
267 : }
268 :
269 : // ::com::sun::star::sdb::XColumnUpdate
270 0 : void ODataColumn::updateNull() throw( SQLException, RuntimeException, std::exception )
271 : {
272 0 : MutexGuard aGuard( m_aMutex );
273 0 : ::connectivity::checkDisposed(!m_xRowUpdate.is());
274 :
275 0 : m_xRowUpdate->updateNull(m_nPos);
276 0 : }
277 :
278 0 : void ODataColumn::updateBoolean(sal_Bool x) throw( SQLException, RuntimeException, std::exception )
279 : {
280 0 : MutexGuard aGuard( m_aMutex );
281 0 : ::connectivity::checkDisposed(!m_xRowUpdate.is());
282 :
283 0 : m_xRowUpdate->updateBoolean(m_nPos, x);
284 0 : }
285 :
286 0 : void ODataColumn::updateByte(sal_Int8 x) throw( SQLException, RuntimeException, std::exception )
287 : {
288 0 : MutexGuard aGuard( m_aMutex );
289 0 : ::connectivity::checkDisposed(!m_xRowUpdate.is());
290 :
291 0 : m_xRowUpdate->updateByte(m_nPos, x);
292 0 : }
293 :
294 0 : void ODataColumn::updateShort(sal_Int16 x) throw( SQLException, RuntimeException, std::exception )
295 : {
296 0 : MutexGuard aGuard( m_aMutex );
297 0 : ::connectivity::checkDisposed(!m_xRowUpdate.is());
298 :
299 0 : m_xRowUpdate->updateShort(m_nPos, x);
300 0 : }
301 :
302 0 : void ODataColumn::updateInt(sal_Int32 x) throw( SQLException, RuntimeException, std::exception )
303 : {
304 0 : MutexGuard aGuard( m_aMutex );
305 0 : ::connectivity::checkDisposed(!m_xRowUpdate.is());
306 :
307 0 : m_xRowUpdate->updateInt(m_nPos, x);
308 0 : }
309 :
310 0 : void ODataColumn::updateLong(sal_Int64 x) throw( SQLException, RuntimeException, std::exception )
311 : {
312 0 : MutexGuard aGuard( m_aMutex );
313 0 : ::connectivity::checkDisposed(!m_xRowUpdate.is());
314 :
315 0 : m_xRowUpdate->updateLong(m_nPos, x);
316 0 : }
317 :
318 0 : void ODataColumn::updateFloat(float x) throw( SQLException, RuntimeException, std::exception )
319 : {
320 0 : MutexGuard aGuard( m_aMutex );
321 0 : ::connectivity::checkDisposed(!m_xRowUpdate.is());
322 :
323 0 : m_xRowUpdate->updateFloat(m_nPos, x);
324 0 : }
325 :
326 0 : void ODataColumn::updateDouble(double x) throw( SQLException, RuntimeException, std::exception )
327 : {
328 0 : MutexGuard aGuard( m_aMutex );
329 0 : ::connectivity::checkDisposed(!m_xRowUpdate.is());
330 :
331 0 : m_xRowUpdate->updateDouble(m_nPos, x);
332 0 : }
333 :
334 0 : void ODataColumn::updateString(const OUString& x) throw( SQLException, RuntimeException, std::exception )
335 : {
336 0 : MutexGuard aGuard( m_aMutex );
337 0 : ::connectivity::checkDisposed(!m_xRowUpdate.is());
338 :
339 0 : m_xRowUpdate->updateString(m_nPos, x);
340 0 : }
341 :
342 0 : void ODataColumn::updateBytes(const Sequence< sal_Int8 >& x) throw( SQLException, RuntimeException, std::exception )
343 : {
344 0 : MutexGuard aGuard( m_aMutex );
345 0 : ::connectivity::checkDisposed(!m_xRowUpdate.is());
346 :
347 0 : m_xRowUpdate->updateBytes(m_nPos, x);
348 0 : }
349 :
350 0 : void ODataColumn::updateDate(const com::sun::star::util::Date& x) throw( SQLException, RuntimeException, std::exception )
351 : {
352 0 : MutexGuard aGuard( m_aMutex );
353 0 : ::connectivity::checkDisposed(!m_xRowUpdate.is());
354 :
355 0 : m_xRowUpdate->updateDate(m_nPos, x);
356 0 : }
357 :
358 0 : void ODataColumn::updateTime(const ::com::sun::star::util::Time& x) throw( SQLException, RuntimeException, std::exception )
359 : {
360 0 : MutexGuard aGuard( m_aMutex );
361 0 : ::connectivity::checkDisposed(!m_xRowUpdate.is());
362 :
363 0 : m_xRowUpdate->updateTime(m_nPos, x);
364 0 : }
365 :
366 0 : void ODataColumn::updateTimestamp(const ::com::sun::star::util::DateTime& x) throw( SQLException, RuntimeException, std::exception )
367 : {
368 0 : MutexGuard aGuard( m_aMutex );
369 0 : ::connectivity::checkDisposed(!m_xRowUpdate.is());
370 :
371 0 : m_xRowUpdate->updateTimestamp(m_nPos, x);
372 0 : }
373 :
374 0 : void ODataColumn::updateCharacterStream(const Reference< ::com::sun::star::io::XInputStream > & x, sal_Int32 length) throw( SQLException, RuntimeException, std::exception )
375 : {
376 0 : MutexGuard aGuard( m_aMutex );
377 0 : ::connectivity::checkDisposed(!m_xRowUpdate.is());
378 :
379 0 : m_xRowUpdate->updateCharacterStream(m_nPos, x, length);
380 0 : }
381 :
382 0 : void ODataColumn::updateBinaryStream(const Reference< ::com::sun::star::io::XInputStream > & x, sal_Int32 length) throw( SQLException, RuntimeException, std::exception )
383 : {
384 0 : MutexGuard aGuard( m_aMutex );
385 0 : ::connectivity::checkDisposed(!m_xRowUpdate.is());
386 :
387 0 : m_xRowUpdate->updateBinaryStream(m_nPos, x, length);
388 0 : }
389 :
390 0 : void ODataColumn::updateNumericObject(const Any& x, sal_Int32 scale) throw( SQLException, RuntimeException, std::exception )
391 : {
392 0 : MutexGuard aGuard( m_aMutex );
393 0 : ::connectivity::checkDisposed(!m_xRowUpdate.is());
394 :
395 0 : m_xRowUpdate->updateNumericObject(m_nPos, x, scale);
396 0 : }
397 :
398 0 : void ODataColumn::updateObject(const Any& x) throw( SQLException, RuntimeException, std::exception )
399 : {
400 0 : MutexGuard aGuard( m_aMutex );
401 0 : ::connectivity::checkDisposed(!m_xRowUpdate.is());
402 :
403 0 : m_xRowUpdate->updateObject(m_nPos, x);
404 0 : }
405 :
406 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|