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 :
21 : #include "ParameterSubstitution.hxx"
22 : #include "FDatabaseMetaDataResultSet.hxx"
23 : #include "FDatabaseMetaDataResultSetMetaData.hxx"
24 : #include <com/sun/star/sdbc/DataType.hpp>
25 : #include <com/sun/star/sdbc/ColumnSearch.hpp>
26 : #include <com/sun/star/sdbc/KeyRule.hpp>
27 : #include <com/sun/star/sdbc/ProcedureResult.hpp>
28 : #include <com/sun/star/sdbc/IndexType.hpp>
29 : #include <comphelper/property.hxx>
30 : #include <com/sun/star/lang/DisposedException.hpp>
31 : #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
32 : #include <com/sun/star/sdbc/ResultSetType.hpp>
33 : #include <com/sun/star/sdbc/FetchDirection.hpp>
34 : #include <com/sun/star/beans/PropertyAttribute.hpp>
35 : #include <cppuhelper/typeprovider.hxx>
36 : #include <comphelper/sequence.hxx>
37 : #include <cppuhelper/factory.hxx>
38 : #include <cppuhelper/implementationentry.hxx>
39 : #include <cppuhelper/supportsservice.hxx>
40 : #include <connectivity/dbexception.hxx>
41 : #include "resource/common_res.hrc"
42 : #include "TConnection.hxx"
43 :
44 : using namespace connectivity;
45 : using namespace dbtools;
46 : using namespace cppu;
47 :
48 : using namespace ::com::sun::star::beans;
49 : using namespace ::com::sun::star::uno;
50 : using namespace ::com::sun::star::sdbcx;
51 : using namespace ::com::sun::star::sdbc;
52 : using namespace ::com::sun::star::container;
53 : using namespace ::com::sun::star::lang;
54 :
55 0 : ODatabaseMetaDataResultSet::ODatabaseMetaDataResultSet()
56 : :ODatabaseMetaDataResultSet_BASE(m_aMutex)
57 : ,::comphelper::OPropertyContainer(ODatabaseMetaDataResultSet_BASE::rBHelper)
58 : ,m_aStatement(NULL)
59 : ,m_xMetaData(NULL)
60 : ,m_nColPos(0)
61 : ,m_bBOF(true)
62 0 : ,m_bEOF(true)
63 : {
64 0 : construct();
65 0 : }
66 :
67 :
68 464 : ODatabaseMetaDataResultSet::ODatabaseMetaDataResultSet( MetaDataResultSetType _eType )
69 : :ODatabaseMetaDataResultSet_BASE(m_aMutex)
70 : ,::comphelper::OPropertyContainer(ODatabaseMetaDataResultSet_BASE::rBHelper)
71 : ,m_aStatement(NULL)
72 : ,m_xMetaData(NULL)
73 : ,m_nColPos(0)
74 : ,m_bBOF(true)
75 464 : ,m_bEOF(true)
76 : {
77 464 : construct();
78 :
79 464 : setType(_eType);
80 464 : }
81 :
82 :
83 926 : ODatabaseMetaDataResultSet::~ODatabaseMetaDataResultSet()
84 : {
85 926 : }
86 :
87 464 : void ODatabaseMetaDataResultSet::construct()
88 : {
89 464 : registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHSIZE), PROPERTY_ID_FETCHSIZE, 0,&m_nFetchSize, ::cppu::UnoType<sal_Int32>::get());
90 464 : registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETTYPE), PROPERTY_ID_RESULTSETTYPE, PropertyAttribute::READONLY,&m_nResultSetType, ::cppu::UnoType<sal_Int32>::get());
91 464 : registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHDIRECTION), PROPERTY_ID_FETCHDIRECTION, 0, &m_nFetchDirection, ::cppu::UnoType<sal_Int32>::get());
92 464 : registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETCONCURRENCY), PROPERTY_ID_RESULTSETCONCURRENCY, PropertyAttribute::READONLY,&m_nResultSetConcurrency, ::cppu::UnoType<sal_Int32>::get());
93 464 : }
94 :
95 464 : void ODatabaseMetaDataResultSet::setType(MetaDataResultSetType _eType)
96 : {
97 464 : switch( _eType )
98 : {
99 0 : case eCatalogs: setCatalogsMap(); break;
100 0 : case eSchemas: setSchemasMap(); break;
101 0 : case eColumnPrivileges: setColumnPrivilegesMap(); break;
102 154 : case eColumns: setColumnsMap(); break;
103 160 : case eTables: setTablesMap(); break;
104 66 : case eTableTypes: setTableTypes(); break;
105 0 : case eProcedureColumns: setProcedureColumnsMap(); break;
106 0 : case eProcedures: setProceduresMap(); break;
107 0 : case eExportedKeys: setExportedKeysMap(); break;
108 2 : case eImportedKeys: setImportedKeysMap(); break;
109 2 : case ePrimaryKeys: setPrimaryKeysMap(); break;
110 0 : case eIndexInfo: setIndexInfoMap(); break;
111 2 : case eTablePrivileges: setTablePrivilegesMap(); break;
112 0 : case eCrossReference: setCrossReferenceMap(); break;
113 16 : case eTypeInfo: setTypeInfoMap(); break;
114 0 : case eBestRowIdentifier: setBestRowIdentifierMap(); break;
115 62 : case eVersionColumns: setVersionColumnsMap(); break;
116 0 : case eUDTs: setUDTsMap(); break;
117 : default:
118 : OSL_FAIL("Wrong type!");
119 : }
120 464 : }
121 :
122 464 : void ODatabaseMetaDataResultSet::disposing(void)
123 : {
124 464 : OPropertySetHelper::disposing();
125 :
126 464 : ::osl::MutexGuard aGuard(m_aMutex);
127 464 : m_aStatement = NULL;
128 464 : m_xMetaData.clear();
129 464 : m_aRowsIter = m_aRows.end();
130 464 : m_aRows.clear();
131 464 : m_aRowsIter = m_aRows.end();
132 464 : }
133 :
134 3654 : void SAL_CALL ODatabaseMetaDataResultSet::acquire() throw()
135 : {
136 3654 : ODatabaseMetaDataResultSet_BASE::acquire();
137 3654 : }
138 :
139 3654 : void SAL_CALL ODatabaseMetaDataResultSet::release() throw()
140 : {
141 3654 : ODatabaseMetaDataResultSet_BASE::release();
142 3654 : }
143 :
144 956 : Any SAL_CALL ODatabaseMetaDataResultSet::queryInterface( const Type & rType ) throw(RuntimeException, std::exception)
145 : {
146 956 : Any aRet = OPropertySetHelper::queryInterface(rType);
147 956 : return aRet.hasValue() ? aRet : ODatabaseMetaDataResultSet_BASE::queryInterface(rType);
148 : }
149 :
150 0 : Sequence< Type > SAL_CALL ODatabaseMetaDataResultSet::getTypes( ) throw(RuntimeException, std::exception)
151 : {
152 0 : ::cppu::OTypeCollection aTypes( cppu::UnoType<com::sun::star::beans::XMultiPropertySet>::get(),
153 0 : cppu::UnoType<com::sun::star::beans::XFastPropertySet>::get(),
154 0 : cppu::UnoType<com::sun::star::beans::XPropertySet>::get());
155 :
156 0 : return ::comphelper::concatSequences(aTypes.getTypes(),ODatabaseMetaDataResultSet_BASE::getTypes());
157 : }
158 :
159 396 : void ODatabaseMetaDataResultSet::setRows(const ORows& _rRows)
160 : {
161 396 : m_aRows = _rRows;
162 396 : m_bBOF = true;
163 396 : m_bEOF = m_aRows.empty();
164 396 : }
165 :
166 0 : sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::findColumn( const OUString& columnName ) throw(SQLException, RuntimeException, std::exception)
167 : {
168 0 : ::osl::MutexGuard aGuard( m_aMutex );
169 0 : checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed );
170 :
171 :
172 0 : Reference< XResultSetMetaData > xMeta = getMetaData();
173 0 : sal_Int32 nLen = xMeta->getColumnCount();
174 0 : sal_Int32 i = 1;
175 0 : for(;i<=nLen;++i)
176 : {
177 0 : if(xMeta->isCaseSensitive(i) ? columnName == xMeta->getColumnName(i) :
178 0 : columnName.equalsIgnoreAsciiCase(xMeta->getColumnName(i))
179 : )
180 0 : return i;
181 : }
182 :
183 0 : ::dbtools::throwInvalidColumnException( columnName, *this );
184 : assert(false);
185 0 : return 0; // Never reached
186 : }
187 :
188 3958 : void ODatabaseMetaDataResultSet::checkIndex(sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException)
189 : {
190 3958 : if(columnIndex >= (sal_Int32)(*m_aRowsIter).size() || columnIndex < 1)
191 0 : ::dbtools::throwInvalidIndexException(*this);
192 3958 : }
193 :
194 0 : Reference< ::com::sun::star::io::XInputStream > SAL_CALL ODatabaseMetaDataResultSet::getBinaryStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException, std::exception)
195 : {
196 0 : return NULL;
197 : }
198 :
199 0 : Reference< ::com::sun::star::io::XInputStream > SAL_CALL ODatabaseMetaDataResultSet::getCharacterStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException, std::exception)
200 : {
201 0 : return NULL;
202 : }
203 :
204 :
205 300 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
206 : {
207 300 : return getValue(columnIndex);
208 : }
209 :
210 :
211 0 : sal_Int8 SAL_CALL ODatabaseMetaDataResultSet::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
212 : {
213 0 : return getValue(columnIndex);
214 : }
215 :
216 :
217 0 : Sequence< sal_Int8 > SAL_CALL ODatabaseMetaDataResultSet::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
218 : {
219 0 : return getValue(columnIndex);
220 : }
221 :
222 :
223 0 : ::com::sun::star::util::Date SAL_CALL ODatabaseMetaDataResultSet::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
224 : {
225 0 : return getValue(columnIndex);
226 : }
227 :
228 :
229 0 : double SAL_CALL ODatabaseMetaDataResultSet::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
230 : {
231 0 : return getValue(columnIndex);
232 : }
233 :
234 :
235 0 : float SAL_CALL ODatabaseMetaDataResultSet::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
236 : {
237 0 : return getValue(columnIndex);
238 : }
239 :
240 :
241 1680 : sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
242 : {
243 1680 : return getValue(columnIndex);
244 : }
245 :
246 :
247 :
248 0 : sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::getRow( ) throw(SQLException, RuntimeException, std::exception)
249 : {
250 0 : return 0;
251 : }
252 :
253 :
254 0 : sal_Int64 SAL_CALL ODatabaseMetaDataResultSet::getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
255 : {
256 0 : return getValue(columnIndex);
257 : }
258 :
259 :
260 0 : Reference< XResultSetMetaData > SAL_CALL ODatabaseMetaDataResultSet::getMetaData( ) throw(SQLException, RuntimeException, std::exception)
261 : {
262 0 : ::osl::MutexGuard aGuard( m_aMutex );
263 0 : checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed );
264 :
265 :
266 0 : if(!m_xMetaData.is())
267 0 : m_xMetaData = new ODatabaseMetaDataResultSetMetaData();
268 :
269 0 : return m_xMetaData;
270 : }
271 :
272 0 : Reference< XArray > SAL_CALL ODatabaseMetaDataResultSet::getArray( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException, std::exception)
273 : {
274 0 : return NULL;
275 : }
276 :
277 :
278 :
279 0 : Reference< XClob > SAL_CALL ODatabaseMetaDataResultSet::getClob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException, std::exception)
280 : {
281 0 : return NULL;
282 : }
283 :
284 0 : Reference< XBlob > SAL_CALL ODatabaseMetaDataResultSet::getBlob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException, std::exception)
285 : {
286 0 : return NULL;
287 : }
288 :
289 :
290 0 : Reference< XRef > SAL_CALL ODatabaseMetaDataResultSet::getRef( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException, std::exception)
291 : {
292 0 : return NULL;
293 : }
294 :
295 :
296 0 : Any SAL_CALL ODatabaseMetaDataResultSet::getObject( sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException, std::exception)
297 : {
298 0 : return getValue(columnIndex).makeAny();
299 : }
300 :
301 :
302 176 : sal_Int16 SAL_CALL ODatabaseMetaDataResultSet::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
303 : {
304 176 : return getValue(columnIndex);
305 : }
306 :
307 :
308 1802 : OUString SAL_CALL ODatabaseMetaDataResultSet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
309 : {
310 1802 : return getValue(columnIndex);
311 : }
312 :
313 :
314 :
315 :
316 0 : ::com::sun::star::util::Time SAL_CALL ODatabaseMetaDataResultSet::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
317 : {
318 0 : return getValue(columnIndex);
319 : }
320 :
321 :
322 :
323 0 : ::com::sun::star::util::DateTime SAL_CALL ODatabaseMetaDataResultSet::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
324 : {
325 0 : return getValue(columnIndex);
326 : }
327 :
328 :
329 3958 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isAfterLast( ) throw(SQLException, RuntimeException, std::exception)
330 : {
331 3958 : return m_bEOF;
332 : }
333 :
334 :
335 : SAL_WNOUNREACHABLE_CODE_PUSH
336 :
337 0 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isFirst( ) throw(SQLException, RuntimeException, std::exception)
338 : {
339 0 : ::dbtools::throwFunctionSequenceException(*this);
340 0 : return sal_False;
341 : }
342 :
343 0 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isLast( ) throw(SQLException, RuntimeException, std::exception)
344 : {
345 0 : ::dbtools::throwFunctionSequenceException(*this);
346 0 : return sal_False;
347 : }
348 :
349 : SAL_WNOUNREACHABLE_CODE_POP
350 :
351 :
352 0 : void SAL_CALL ODatabaseMetaDataResultSet::beforeFirst( ) throw(SQLException, RuntimeException, std::exception)
353 : {
354 0 : ::dbtools::throwFunctionSequenceException(*this);
355 0 : }
356 :
357 0 : void SAL_CALL ODatabaseMetaDataResultSet::afterLast( ) throw(SQLException, RuntimeException, std::exception)
358 : {
359 0 : ::dbtools::throwFunctionSequenceException(*this);
360 0 : }
361 :
362 :
363 4 : void SAL_CALL ODatabaseMetaDataResultSet::close( ) throw(SQLException, RuntimeException, std::exception)
364 : {
365 : {
366 4 : ::osl::MutexGuard aGuard( m_aMutex );
367 4 : checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed );
368 :
369 : }
370 4 : dispose();
371 4 : }
372 :
373 :
374 : SAL_WNOUNREACHABLE_CODE_PUSH
375 :
376 0 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::first( ) throw(SQLException, RuntimeException, std::exception)
377 : {
378 0 : ::dbtools::throwFunctionSequenceException(*this);
379 0 : return sal_False;
380 : }
381 :
382 :
383 0 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::last( ) throw(SQLException, RuntimeException, std::exception)
384 : {
385 0 : ::dbtools::throwFunctionSequenceException(*this);
386 0 : return sal_False;
387 : }
388 :
389 0 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::absolute( sal_Int32 /*row*/ ) throw(SQLException, RuntimeException, std::exception)
390 : {
391 0 : ::dbtools::throwFunctionSequenceException(*this);
392 0 : return sal_False;
393 : }
394 :
395 0 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::relative( sal_Int32 /*row*/ ) throw(SQLException, RuntimeException, std::exception)
396 : {
397 0 : ::dbtools::throwFunctionSequenceException(*this);
398 0 : return sal_False;
399 : }
400 :
401 0 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::previous( ) throw(SQLException, RuntimeException, std::exception)
402 : {
403 0 : ::dbtools::throwFunctionSequenceException(*this);
404 0 : return sal_False;
405 : }
406 :
407 : SAL_WNOUNREACHABLE_CODE_POP
408 :
409 :
410 0 : Reference< XInterface > SAL_CALL ODatabaseMetaDataResultSet::getStatement( ) throw(SQLException, RuntimeException, std::exception)
411 : {
412 0 : return m_aStatement.get();
413 : }
414 :
415 :
416 : SAL_WNOUNREACHABLE_CODE_PUSH
417 :
418 0 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowDeleted( ) throw(SQLException, RuntimeException, std::exception)
419 : {
420 0 : ::dbtools::throwFunctionSequenceException(*this);
421 0 : return sal_False;
422 : }
423 :
424 0 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowInserted( ) throw(SQLException, RuntimeException, std::exception)
425 : {
426 0 : ::dbtools::throwFunctionSequenceException(*this);
427 0 : return sal_False;
428 : }
429 :
430 0 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowUpdated( ) throw(SQLException, RuntimeException, std::exception)
431 : {
432 0 : ::dbtools::throwFunctionSequenceException(*this);
433 0 : return sal_False;
434 : }
435 :
436 : SAL_WNOUNREACHABLE_CODE_POP
437 :
438 :
439 :
440 3958 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isBeforeFirst( ) throw(SQLException, RuntimeException, std::exception)
441 : {
442 3958 : return m_bBOF;
443 : }
444 :
445 :
446 900 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::next( ) throw(SQLException, RuntimeException, std::exception)
447 : {
448 900 : ::osl::MutexGuard aGuard( m_aMutex );
449 900 : checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed );
450 :
451 900 : if ( m_bBOF )
452 : {
453 462 : m_aRowsIter = m_aRows.begin();
454 462 : m_bBOF = false;
455 : }
456 : else
457 : {
458 438 : if ( m_bEOF )
459 0 : throwFunctionSequenceException( *this );
460 : else
461 438 : if ( m_aRowsIter != m_aRows.end() )
462 438 : ++m_aRowsIter;
463 : }
464 :
465 900 : bool bSuccess = m_aRowsIter != m_aRows.end();
466 900 : if ( !bSuccess )
467 : {
468 300 : m_bEOF = true;
469 300 : m_bBOF = m_aRows.empty();
470 : }
471 900 : return bSuccess;
472 : }
473 :
474 :
475 428 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::wasNull( ) throw(SQLException, RuntimeException, std::exception)
476 : {
477 428 : ::osl::MutexGuard aGuard( m_aMutex );
478 428 : checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed );
479 :
480 :
481 428 : if(m_aRowsIter == m_aRows.end() || !(*m_aRowsIter)[m_nColPos].is())
482 0 : return sal_True;
483 :
484 428 : return (*m_aRowsIter)[m_nColPos]->getValue().isNull();
485 : }
486 :
487 0 : void SAL_CALL ODatabaseMetaDataResultSet::refreshRow( ) throw(SQLException, RuntimeException, std::exception)
488 : {
489 0 : }
490 :
491 :
492 0 : void SAL_CALL ODatabaseMetaDataResultSet::cancel( ) throw(RuntimeException, std::exception)
493 : {
494 0 : }
495 :
496 0 : void SAL_CALL ODatabaseMetaDataResultSet::clearWarnings( ) throw(SQLException, RuntimeException, std::exception)
497 : {
498 0 : }
499 :
500 0 : Any SAL_CALL ODatabaseMetaDataResultSet::getWarnings( ) throw(SQLException, RuntimeException, std::exception)
501 : {
502 0 : return Any();
503 : }
504 :
505 0 : ::cppu::IPropertyArrayHelper* ODatabaseMetaDataResultSet::createArrayHelper( ) const
506 : {
507 0 : Sequence< Property > aProps;
508 0 : describeProperties(aProps);
509 0 : return new ::cppu::OPropertyArrayHelper(aProps);
510 : }
511 :
512 0 : ::cppu::IPropertyArrayHelper & ODatabaseMetaDataResultSet::getInfoHelper()
513 : {
514 0 : return *const_cast<ODatabaseMetaDataResultSet*>(this)->getArrayHelper();
515 : }
516 :
517 0 : void ODatabaseMetaDataResultSet::setProceduresMap()
518 : {
519 0 : ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
520 0 : pMetaData->setProceduresMap();
521 0 : m_xMetaData = pMetaData;
522 0 : }
523 :
524 0 : void ODatabaseMetaDataResultSet::setCatalogsMap()
525 : {
526 0 : ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
527 0 : pMetaData->setCatalogsMap();
528 0 : m_xMetaData = pMetaData;
529 0 : }
530 :
531 0 : void ODatabaseMetaDataResultSet::setSchemasMap()
532 : {
533 0 : ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
534 0 : pMetaData->setSchemasMap();
535 0 : m_xMetaData = pMetaData;
536 0 : }
537 :
538 0 : void ODatabaseMetaDataResultSet::setColumnPrivilegesMap()
539 : {
540 0 : ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
541 0 : pMetaData->setColumnPrivilegesMap();
542 0 : m_xMetaData = pMetaData;
543 0 : }
544 :
545 154 : void ODatabaseMetaDataResultSet::setColumnsMap()
546 : {
547 :
548 154 : ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
549 154 : pMetaData->setColumnsMap();
550 154 : m_xMetaData = pMetaData;
551 154 : }
552 :
553 160 : void ODatabaseMetaDataResultSet::setTablesMap()
554 : {
555 :
556 160 : ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
557 160 : pMetaData->setTablesMap();
558 160 : m_xMetaData = pMetaData;
559 160 : }
560 :
561 0 : void ODatabaseMetaDataResultSet::setProcedureColumnsMap()
562 : {
563 0 : ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
564 0 : pMetaData->setProcedureColumnsMap();
565 0 : m_xMetaData = pMetaData;
566 0 : }
567 :
568 2 : void ODatabaseMetaDataResultSet::setPrimaryKeysMap()
569 : {
570 2 : ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
571 2 : pMetaData->setPrimaryKeysMap();
572 2 : m_xMetaData = pMetaData;
573 2 : }
574 :
575 0 : void ODatabaseMetaDataResultSet::setIndexInfoMap()
576 : {
577 0 : ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
578 0 : pMetaData->setIndexInfoMap();
579 0 : m_xMetaData = pMetaData;
580 0 : }
581 :
582 2 : void ODatabaseMetaDataResultSet::setTablePrivilegesMap()
583 : {
584 2 : ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
585 2 : pMetaData->setTablePrivilegesMap();
586 2 : m_xMetaData = pMetaData;
587 2 : }
588 :
589 0 : void ODatabaseMetaDataResultSet::setCrossReferenceMap()
590 : {
591 0 : ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
592 0 : pMetaData->setCrossReferenceMap();
593 0 : m_xMetaData = pMetaData;
594 0 : }
595 :
596 62 : void ODatabaseMetaDataResultSet::setVersionColumnsMap()
597 : {
598 62 : ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
599 62 : pMetaData->setVersionColumnsMap();
600 62 : m_xMetaData = pMetaData;
601 62 : }
602 :
603 0 : void ODatabaseMetaDataResultSet::setBestRowIdentifierMap()
604 : {
605 0 : ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
606 0 : pMetaData->setBestRowIdentifierMap();
607 0 : m_xMetaData = pMetaData;
608 0 : }
609 :
610 16 : void ODatabaseMetaDataResultSet::setTypeInfoMap()
611 : {
612 16 : ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
613 16 : pMetaData->setTypeInfoMap();
614 16 : m_xMetaData = pMetaData;
615 16 : }
616 :
617 0 : void ODatabaseMetaDataResultSet::setUDTsMap()
618 : {
619 0 : ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
620 0 : pMetaData->setUDTsMap();
621 0 : m_xMetaData = pMetaData;
622 0 : }
623 :
624 66 : void ODatabaseMetaDataResultSet::setTableTypes()
625 : {
626 66 : ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
627 66 : pMetaData->setTableTypes();
628 66 : m_xMetaData = pMetaData;
629 66 : }
630 :
631 0 : void ODatabaseMetaDataResultSet::setExportedKeysMap()
632 : {
633 0 : ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
634 0 : pMetaData->setExportedKeysMap();
635 0 : m_xMetaData = pMetaData;
636 0 : }
637 :
638 2 : void ODatabaseMetaDataResultSet::setImportedKeysMap()
639 : {
640 2 : ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
641 2 : pMetaData->setImportedKeysMap();
642 2 : m_xMetaData = pMetaData;
643 2 : }
644 :
645 0 : Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL ODatabaseMetaDataResultSet::getPropertySetInfo( ) throw(RuntimeException, std::exception)
646 : {
647 0 : return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
648 : }
649 :
650 23652 : ORowSetValueDecorator& ORowSetValueDecorator::operator=(const ORowSetValue& _aValue)
651 : {
652 23652 : m_aValue = _aValue;
653 23652 : return *this;
654 : }
655 :
656 3958 : const ORowSetValue& ODatabaseMetaDataResultSet::getValue(sal_Int32 columnIndex)
657 : {
658 3958 : ::osl::MutexGuard aGuard( m_aMutex );
659 3958 : checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed );
660 :
661 3958 : if ( isBeforeFirst() || isAfterLast() )
662 0 : ::dbtools::throwFunctionSequenceException( *this );
663 :
664 3958 : checkIndex(columnIndex );
665 3958 : m_nColPos = columnIndex;
666 :
667 3958 : if(m_aRowsIter != m_aRows.end() && (*m_aRowsIter)[columnIndex].is())
668 3958 : return *(*m_aRowsIter)[columnIndex];
669 0 : return m_aEmptyValue;
670 : }
671 :
672 : /// return an empty ORowSetValueDecorator
673 942 : ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getEmptyValue()
674 : {
675 942 : static ORowSetValueDecoratorRef aEmptyValueRef = new ORowSetValueDecorator();
676 942 : return aEmptyValueRef;
677 : }
678 :
679 : /// return an ORowSetValueDecorator with 0 as value
680 36 : ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::get0Value()
681 : {
682 36 : static ORowSetValueDecoratorRef a0ValueRef = new ORowSetValueDecorator((sal_Int32)0);
683 36 : return a0ValueRef;
684 : }
685 :
686 : /// return an ORowSetValueDecorator with 1 as value
687 6 : ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::get1Value()
688 : {
689 6 : static ORowSetValueDecoratorRef a1ValueRef = new ORowSetValueDecorator((sal_Int32)1);
690 6 : return a1ValueRef;
691 : }
692 :
693 : /// return an ORowSetValueDecorator with ColumnSearch::BASIC as value
694 2 : ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getBasicValue()
695 : {
696 2 : static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(ColumnSearch::BASIC);
697 2 : return aValueRef;
698 : }
699 :
700 2 : ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getSelectValue()
701 : {
702 2 : static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(OUString("SELECT"));
703 2 : return aValueRef;
704 : }
705 :
706 2 : ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getInsertValue()
707 : {
708 2 : static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(OUString("INSERT"));
709 2 : return aValueRef;
710 : }
711 :
712 2 : ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getDeleteValue()
713 : {
714 2 : static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(OUString("DELETE"));
715 2 : return aValueRef;
716 : }
717 :
718 2 : ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getUpdateValue()
719 : {
720 2 : static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(OUString("UPDATE"));
721 2 : return aValueRef;
722 : }
723 :
724 2 : ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getCreateValue()
725 : {
726 2 : static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(OUString("CREATE"));
727 2 : return aValueRef;
728 : }
729 :
730 2 : ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getReadValue()
731 : {
732 2 : static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(OUString("READ"));
733 2 : return aValueRef;
734 : }
735 :
736 2 : ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getAlterValue()
737 : {
738 2 : static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(OUString("ALTER"));
739 2 : return aValueRef;
740 : }
741 :
742 2 : ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getDropValue()
743 : {
744 2 : static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(OUString("DROP"));
745 2 : return aValueRef;
746 : }
747 :
748 8 : ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getQuoteValue()
749 : {
750 8 : static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(OUString("'"));
751 8 : return aValueRef;
752 : }
753 :
754 0 : void SAL_CALL ODatabaseMetaDataResultSet::initialize( const Sequence< Any >& _aArguments ) throw (Exception, RuntimeException, std::exception)
755 : {
756 0 : if ( _aArguments.getLength() == 2 )
757 : {
758 0 : sal_Int32 nResultSetType = 0;
759 0 : if ( _aArguments[0] >>= nResultSetType)
760 : {
761 0 : setType(static_cast<MetaDataResultSetType>(nResultSetType));
762 0 : Sequence< Sequence<Any> > aRows;
763 0 : if ( _aArguments[1] >>= aRows )
764 : {
765 0 : ORows aRowsToSet;
766 0 : const Sequence<Any>* pRowsIter = aRows.getConstArray();
767 0 : const Sequence<Any>* pRowsEnd = pRowsIter + aRows.getLength();
768 0 : for (; pRowsIter != pRowsEnd;++pRowsIter)
769 : {
770 0 : ORow aRowToSet;
771 0 : const Any* pRowIter = pRowsIter->getConstArray();
772 0 : const Any* pRowEnd = pRowIter + pRowsIter->getLength();
773 0 : for (; pRowIter != pRowEnd;++pRowIter)
774 : {
775 0 : ORowSetValueDecoratorRef aValue;
776 0 : switch( pRowIter->getValueTypeClass() )
777 : {
778 : case TypeClass_BOOLEAN:
779 : {
780 0 : bool bValue = false;
781 0 : *pRowIter >>= bValue;
782 0 : aValue = new ORowSetValueDecorator(ORowSetValue(bValue));
783 : }
784 0 : break;
785 : case TypeClass_BYTE:
786 : {
787 0 : sal_Int8 nValue(0);
788 0 : *pRowIter >>= nValue;
789 0 : aValue = new ORowSetValueDecorator(ORowSetValue(nValue));
790 : }
791 0 : break;
792 : case TypeClass_SHORT:
793 : case TypeClass_UNSIGNED_SHORT:
794 : {
795 0 : sal_Int16 nValue(0);
796 0 : *pRowIter >>= nValue;
797 0 : aValue = new ORowSetValueDecorator(ORowSetValue(nValue));
798 : }
799 0 : break;
800 : case TypeClass_LONG:
801 : case TypeClass_UNSIGNED_LONG:
802 : {
803 0 : sal_Int32 nValue(0);
804 0 : *pRowIter >>= nValue;
805 0 : aValue = new ORowSetValueDecorator(ORowSetValue(nValue));
806 : }
807 0 : break;
808 : case TypeClass_HYPER:
809 : case TypeClass_UNSIGNED_HYPER:
810 : {
811 0 : sal_Int64 nValue(0);
812 0 : *pRowIter >>= nValue;
813 0 : aValue = new ORowSetValueDecorator(ORowSetValue(nValue));
814 : }
815 0 : break;
816 : case TypeClass_FLOAT:
817 : {
818 0 : float nValue(0.0);
819 0 : *pRowIter >>= nValue;
820 0 : aValue = new ORowSetValueDecorator(ORowSetValue(nValue));
821 : }
822 0 : break;
823 : case TypeClass_DOUBLE:
824 : {
825 0 : double nValue(0.0);
826 0 : *pRowIter >>= nValue;
827 0 : aValue = new ORowSetValueDecorator(ORowSetValue(nValue));
828 : }
829 0 : break;
830 : case TypeClass_STRING:
831 : {
832 0 : OUString sValue;
833 0 : *pRowIter >>= sValue;
834 0 : aValue = new ORowSetValueDecorator(ORowSetValue(sValue));
835 : }
836 0 : break;
837 : default:
838 0 : break;
839 : }
840 0 : aRowToSet.push_back(aValue);
841 0 : }
842 0 : aRowsToSet.push_back(aRowToSet);
843 0 : } // for (; pRowsIter != pRowsEnd;++pRowsIter
844 0 : setRows(aRowsToSet);
845 0 : }
846 : }
847 : }
848 0 : }
849 : // XServiceInfo
850 :
851 :
852 0 : OUString ODatabaseMetaDataResultSet::getImplementationName_Static( ) throw(RuntimeException)
853 : {
854 0 : return OUString("org.openoffice.comp.helper.DatabaseMetaDataResultSet");
855 : }
856 :
857 0 : Sequence< OUString > ODatabaseMetaDataResultSet::getSupportedServiceNames_Static( ) throw (RuntimeException)
858 : {
859 0 : Sequence< OUString > aSNS( 1 );
860 0 : aSNS[0] = "com.sun.star.sdbc.ResultSet";
861 0 : return aSNS;
862 : }
863 :
864 0 : OUString SAL_CALL ODatabaseMetaDataResultSet::getImplementationName( ) throw(RuntimeException, std::exception)
865 : {
866 0 : return getImplementationName_Static();
867 : }
868 :
869 0 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::supportsService( const OUString& _rServiceName ) throw(RuntimeException, std::exception)
870 : {
871 0 : return cppu::supportsService(this, _rServiceName);
872 : }
873 :
874 0 : Sequence< OUString > SAL_CALL ODatabaseMetaDataResultSet::getSupportedServiceNames( ) throw(RuntimeException, std::exception)
875 : {
876 0 : return getSupportedServiceNames_Static();
877 : }
878 :
879 : namespace connectivity
880 : {
881 0 : Reference< XInterface > SAL_CALL ODatabaseMetaDataResultSet_CreateInstance(const Reference< XComponentContext >& ) throw( Exception )
882 : {
883 0 : return *(new ODatabaseMetaDataResultSet());
884 : }
885 : }
886 :
887 :
888 : namespace
889 : {
890 : cppu::ImplementationEntry entries[] = {
891 : { &ODatabaseMetaDataResultSet_CreateInstance, &ODatabaseMetaDataResultSet::getImplementationName_Static, &ODatabaseMetaDataResultSet::getSupportedServiceNames_Static,
892 : &cppu::createSingleComponentFactory, 0, 0 },
893 : { &ParameterSubstitution::create, &ParameterSubstitution::getImplementationName_Static, &ParameterSubstitution::getSupportedServiceNames_Static,
894 : &cppu::createSingleComponentFactory, 0, 0 },
895 : { 0, 0, 0, 0, 0, 0 }
896 : };
897 : }
898 : using ::com::sun::star::uno::Reference;
899 : using ::com::sun::star::uno::Sequence;
900 : using ::com::sun::star::registry::XRegistryKey;
901 : using ::com::sun::star::registry::InvalidRegistryException;
902 : using ::com::sun::star::registry::InvalidValueException;
903 : using ::com::sun::star::lang::XMultiServiceFactory;
904 :
905 :
906 : //= registration
907 :
908 : extern "C"
909 : {
910 :
911 :
912 0 : SAL_DLLPUBLIC_EXPORT void* SAL_CALL dbtools_component_getFactory(const sal_Char* implName, ::com::sun::star::lang::XMultiServiceFactory* serviceManager, void* registryKey)
913 : {
914 0 : return cppu::component_getFactoryHelper(implName, serviceManager, registryKey, entries);
915 : }
916 :
917 : } // extern "C"
918 :
919 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|