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