1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_connectivity.hxx"
26 #include <comphelper/sequence.hxx>
27 #include "ado/ADatabaseMetaDataResultSet.hxx"
28 #include "ado/ADatabaseMetaDataResultSetMetaData.hxx"
29 #include <com/sun/star/sdbc/DataType.hpp>
30 #include <com/sun/star/sdbc/ColumnValue.hpp>
31 #include <com/sun/star/sdbc/KeyRule.hpp>
32 #include <com/sun/star/sdbc/ProcedureResult.hpp>
33 #include <com/sun/star/sdbc/IndexType.hpp>
34 #include <comphelper/property.hxx>
35 #include <com/sun/star/lang/DisposedException.hpp>
36 #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
37 #include <com/sun/star/sdbc/ResultSetType.hpp>
38 #include <com/sun/star/sdbc/FetchDirection.hpp>
39 #include <cppuhelper/typeprovider.hxx>
40 #include <comphelper/seqstream.hxx>
41 #include "connectivity/dbexception.hxx"
42
43
44 #include <oledb.h>
45
46 using namespace dbtools;
47 using namespace connectivity::ado;
48 using namespace cppu;
49 using namespace ::comphelper;
50 //------------------------------------------------------------------------------
51 using namespace ::com::sun::star::lang;
52 using namespace com::sun::star::uno;
53 using namespace com::sun::star::lang;
54 using namespace com::sun::star::beans;
55 using namespace com::sun::star::sdbc;
56
57 // -------------------------------------------------------------------------
ODatabaseMetaDataResultSet(ADORecordset * _pRecordSet)58 ODatabaseMetaDataResultSet::ODatabaseMetaDataResultSet(ADORecordset* _pRecordSet)
59 :ODatabaseMetaDataResultSet_BASE(m_aMutex)
60 ,OPropertySetHelper(ODatabaseMetaDataResultSet_BASE::rBHelper)
61 ,m_aStatement(NULL)
62 ,m_xMetaData(NULL)
63 ,m_pRecordSet(_pRecordSet)
64 ,m_bEOF(sal_False)
65 {
66 osl_incrementInterlockedCount( &m_refCount );
67 m_aColMapping.push_back(-1);
68 if(_pRecordSet)
69 {
70 m_pRecordSet->AddRef();
71 VARIANT_BOOL bIsAtBOF;
72 m_pRecordSet->get_BOF(&bIsAtBOF);
73 m_bOnFirstAfterOpen = bIsAtBOF != VARIANT_TRUE;
74 }
75 else
76 m_bOnFirstAfterOpen = sal_False;
77 osl_decrementInterlockedCount( &m_refCount );
78 // allocBuffer();
79 }
80
81 // -------------------------------------------------------------------------
~ODatabaseMetaDataResultSet()82 ODatabaseMetaDataResultSet::~ODatabaseMetaDataResultSet()
83 {
84 if(m_pRecordSet)
85 m_pRecordSet->Release();
86 }
87 // -------------------------------------------------------------------------
disposing(void)88 void ODatabaseMetaDataResultSet::disposing(void)
89 {
90 OPropertySetHelper::disposing();
91
92 ::osl::MutexGuard aGuard(m_aMutex);
93 if(m_pRecordSet)
94 m_pRecordSet->Close();
95 m_aStatement = NULL;
96 m_xMetaData.clear();
97 }
98 // -------------------------------------------------------------------------
queryInterface(const Type & rType)99 Any SAL_CALL ODatabaseMetaDataResultSet::queryInterface( const Type & rType ) throw(RuntimeException)
100 {
101 Any aRet = OPropertySetHelper::queryInterface(rType);
102 return aRet.hasValue() ? aRet : ODatabaseMetaDataResultSet_BASE::queryInterface(rType);
103 }
104 // -------------------------------------------------------------------------
getTypes()105 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL ODatabaseMetaDataResultSet::getTypes( ) throw(::com::sun::star::uno::RuntimeException)
106 {
107 ::cppu::OTypeCollection aTypes( ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XMultiPropertySet > *)0 ),
108 ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XFastPropertySet > *)0 ),
109 ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > *)0 ));
110
111 return ::comphelper::concatSequences(aTypes.getTypes(),ODatabaseMetaDataResultSet_BASE::getTypes());
112 }
113 // -----------------------------------------------------------------------------
checkRecordSet()114 void ODatabaseMetaDataResultSet::checkRecordSet() throw(SQLException)
115 {
116 if(!m_pRecordSet)
117 throwFunctionSequenceException(*this);
118 }
119 // -------------------------------------------------------------------------
120
findColumn(const::rtl::OUString & columnName)121 sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::findColumn( const ::rtl::OUString& columnName ) throw(SQLException, RuntimeException)
122 {
123 ::osl::MutexGuard aGuard( m_aMutex );
124 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed );
125
126
127 Reference< XResultSetMetaData > xMeta = getMetaData();
128 sal_Int32 nLen = xMeta->getColumnCount();
129 sal_Int32 i = 1;
130 for(;i<=nLen;++i)
131 if(xMeta->isCaseSensitive(i) ? columnName == xMeta->getColumnName(i) :
132 columnName.equalsIgnoreAsciiCase(xMeta->getColumnName(i)))
133 break;
134 return i;
135 }
136 #define BLOCK_SIZE 256
137 // -------------------------------------------------------------------------
getBinaryStream(sal_Int32 columnIndex)138 Reference< ::com::sun::star::io::XInputStream > SAL_CALL ODatabaseMetaDataResultSet::getBinaryStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
139 {
140 ::osl::MutexGuard aGuard( m_aMutex );
141 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
142
143 checkRecordSet();
144
145
146 columnIndex = mapColumn(columnIndex);
147 WpADOField aField = ADOS::getField(m_pRecordSet,columnIndex);
148 if((aField.GetAttributes() & adFldLong) == adFldLong)
149 {
150 //Copy the data only up to the Actual Size of Field.
151 sal_Int32 nSize = aField.GetActualSize();
152 Sequence<sal_Int8> aData(nSize);
153 long index = 0;
154 while(index < nSize)
155 {
156 m_aValue = aField.GetChunk(BLOCK_SIZE);
157 if(m_aValue.isNull())
158 break;
159 UCHAR chData;
160 for(long index2 = 0;index2 < BLOCK_SIZE;++index2)
161 {
162 HRESULT hr = ::SafeArrayGetElement(m_aValue.parray,&index2,&chData);
163 if(SUCCEEDED(hr))
164 {
165 //Take BYTE by BYTE and advance Memory Location
166 aData.getArray()[index++] = chData;
167 }
168 else
169 break;
170 }
171 }
172 return index ? Reference< ::com::sun::star::io::XInputStream >(new SequenceInputStream(aData)) : Reference< ::com::sun::star::io::XInputStream >();
173 }
174 // else we ask for a bytesequence
175 aField.get_Value(m_aValue);
176 if(m_aValue.isNull())
177 return NULL;
178 return new SequenceInputStream(m_aValue);
179 }
180 // -------------------------------------------------------------------------
getCharacterStream(sal_Int32)181 Reference< ::com::sun::star::io::XInputStream > SAL_CALL ODatabaseMetaDataResultSet::getCharacterStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
182 {
183 ::dbtools::throwFeatureNotImplementedException( "XRow::getCharacterStream", *this );
184 return NULL;
185 }
186
187 // -------------------------------------------------------------------------
getBoolean(sal_Int32 columnIndex)188 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
189 {
190 ::osl::MutexGuard aGuard( m_aMutex );
191
192 if ( !m_aValueRange.empty() && columnIndex == 11 && (m_aValueRangeIter = m_aValueRange.find(columnIndex)) != m_aValueRange.end() )
193 {
194 getValue(2);
195 if ( static_cast<sal_Int16>(m_aValue) != adCurrency )
196 return sal_False;
197 }
198 return getValue(columnIndex);
199 }
200 // -------------------------------------------------------------------------
201
getByte(sal_Int32 columnIndex)202 sal_Int8 SAL_CALL ODatabaseMetaDataResultSet::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
203 {
204 ::osl::MutexGuard aGuard( m_aMutex );
205
206 getValue(columnIndex);
207
208 columnIndex = mapColumn(columnIndex);
209
210 if(m_aValue.isNull())
211 return 0;
212 if ( !m_aValueRange.empty() && (m_aValueRangeIter = m_aValueRange.find(columnIndex)) != m_aValueRange.end())
213 return (sal_Int8)(*m_aValueRangeIter).second[(sal_Int32)m_aValue];
214 else if(m_aStrValueRange.size() && (m_aStrValueRangeIter = m_aStrValueRange.find(columnIndex)) != m_aStrValueRange.end())
215 return (sal_Int8)(*m_aStrValueRangeIter).second[m_aValue];
216
217 return m_aValue;
218 }
219 // -------------------------------------------------------------------------
220
getBytes(sal_Int32 columnIndex)221 Sequence< sal_Int8 > SAL_CALL ODatabaseMetaDataResultSet::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
222 {
223 return getValue(columnIndex);
224 }
225 // -------------------------------------------------------------------------
226
getDate(sal_Int32 columnIndex)227 ::com::sun::star::util::Date SAL_CALL ODatabaseMetaDataResultSet::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
228 {
229 return getValue(columnIndex);
230 }
231 // -------------------------------------------------------------------------
232
getDouble(sal_Int32 columnIndex)233 double SAL_CALL ODatabaseMetaDataResultSet::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
234 {
235 return getValue(columnIndex);
236 }
237 // -------------------------------------------------------------------------
238
getFloat(sal_Int32 columnIndex)239 float SAL_CALL ODatabaseMetaDataResultSet::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
240 {
241 return getValue(columnIndex);
242 }
243 // -------------------------------------------------------------------------
244
getInt(sal_Int32 columnIndex)245 sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
246 {
247 ::osl::MutexGuard aGuard( m_aMutex );
248
249
250 getValue(columnIndex);
251
252 columnIndex = mapColumn(columnIndex);
253 if(m_aValue.isNull())
254 return 0;
255
256 if(m_aValueRange.size() && (m_aValueRangeIter = m_aValueRange.find(columnIndex)) != m_aValueRange.end())
257 return (*m_aValueRangeIter).second[(sal_Int32)m_aValue];
258 else if(m_aStrValueRange.size() && (m_aStrValueRangeIter = m_aStrValueRange.find(columnIndex)) != m_aStrValueRange.end())
259 return (*m_aStrValueRangeIter).second[m_aValue];
260
261 return m_aValue;
262 }
263 // -------------------------------------------------------------------------
264
getRow()265 sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::getRow( ) throw(SQLException, RuntimeException)
266 {
267 ::dbtools::throwFeatureNotImplementedException( "XResultSet::getRow", *this );
268 return 0;
269 }
270 // -------------------------------------------------------------------------
271
getLong(sal_Int32)272 sal_Int64 SAL_CALL ODatabaseMetaDataResultSet::getLong( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
273 {
274 ::dbtools::throwFeatureNotImplementedException( "XRow::getLong", *this );
275 return sal_Int64(0);
276 }
277 // -------------------------------------------------------------------------
278
getMetaData()279 Reference< XResultSetMetaData > SAL_CALL ODatabaseMetaDataResultSet::getMetaData( ) throw(SQLException, RuntimeException)
280 {
281 ::osl::MutexGuard aGuard( m_aMutex );
282 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
283
284 checkRecordSet();
285
286
287 if(!m_xMetaData.is())
288 m_xMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this);
289
290 return m_xMetaData;
291 }
292 // -------------------------------------------------------------------------
getArray(sal_Int32)293 Reference< XArray > SAL_CALL ODatabaseMetaDataResultSet::getArray( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
294 {
295 ::dbtools::throwFeatureNotImplementedException( "XRow::getRow", *this );
296 return NULL;
297 }
298
299 // -------------------------------------------------------------------------
300
getClob(sal_Int32)301 Reference< XClob > SAL_CALL ODatabaseMetaDataResultSet::getClob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
302 {
303 ::dbtools::throwFeatureNotImplementedException( "XRow::getRow", *this );
304 return NULL;
305 }
306 // -------------------------------------------------------------------------
getBlob(sal_Int32)307 Reference< XBlob > SAL_CALL ODatabaseMetaDataResultSet::getBlob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
308 {
309 ::dbtools::throwFeatureNotImplementedException( "XRow::getRow", *this );
310 return NULL;
311 }
312 // -------------------------------------------------------------------------
313
getRef(sal_Int32)314 Reference< XRef > SAL_CALL ODatabaseMetaDataResultSet::getRef( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
315 {
316 ::dbtools::throwFeatureNotImplementedException( "XRow::getRow", *this );
317 return NULL;
318 }
319 // -------------------------------------------------------------------------
320
getObject(sal_Int32 columnIndex,const Reference<::com::sun::star::container::XNameAccess> &)321 Any SAL_CALL ODatabaseMetaDataResultSet::getObject( sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException)
322 {
323 ::osl::MutexGuard aGuard( m_aMutex );
324 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
325
326 checkRecordSet();
327
328
329 columnIndex = mapColumn(columnIndex);
330 return Any();
331 }
332 // -------------------------------------------------------------------------
333
getShort(sal_Int32 columnIndex)334 sal_Int16 SAL_CALL ODatabaseMetaDataResultSet::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
335 {
336 ::osl::MutexGuard aGuard( m_aMutex );
337
338 getValue(columnIndex);
339
340 columnIndex = mapColumn(columnIndex);
341 if(m_aValue.isNull())
342 return 0;
343
344 if(m_aValueRange.size() && (m_aValueRangeIter = m_aValueRange.find(columnIndex)) != m_aValueRange.end())
345 return (sal_Int16)(*m_aValueRangeIter).second[(sal_Int32)m_aValue];
346 else if(m_aStrValueRange.size() && (m_aStrValueRangeIter = m_aStrValueRange.find(columnIndex)) != m_aStrValueRange.end())
347 return (sal_Int16)(*m_aStrValueRangeIter).second[m_aValue];
348
349 return m_aValue;
350 }
351 // -------------------------------------------------------------------------
352
getString(sal_Int32 columnIndex)353 ::rtl::OUString SAL_CALL ODatabaseMetaDataResultSet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
354 {
355 ::osl::MutexGuard aGuard( m_aMutex );
356
357 getValue(columnIndex);
358
359
360 columnIndex = mapColumn(columnIndex);
361 if(m_aValue.isNull())
362 return ::rtl::OUString();
363 if(m_aIntValueRange.size() && (m_aIntValueRangeIter = m_aIntValueRange.find(columnIndex)) != m_aIntValueRange.end())
364 return (*m_aIntValueRangeIter).second[m_aValue];
365
366 return m_aValue;
367 }
368
369 // -------------------------------------------------------------------------
370
371
getTime(sal_Int32 columnIndex)372 ::com::sun::star::util::Time SAL_CALL ODatabaseMetaDataResultSet::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
373 {
374 return getValue(columnIndex);
375 }
376 // -------------------------------------------------------------------------
377
378
getTimestamp(sal_Int32 columnIndex)379 ::com::sun::star::util::DateTime SAL_CALL ODatabaseMetaDataResultSet::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
380 {
381 return getValue(columnIndex);
382 }
383 // -------------------------------------------------------------------------
384
isAfterLast()385 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isAfterLast( ) throw(SQLException, RuntimeException)
386 {
387 ::osl::MutexGuard aGuard( m_aMutex );
388 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
389
390 checkRecordSet();
391
392
393 VARIANT_BOOL bIsAtEOF;
394 m_pRecordSet->get_EOF(&bIsAtEOF);
395 return bIsAtEOF == VARIANT_TRUE;
396 }
397 // -------------------------------------------------------------------------
isFirst()398 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isFirst( ) throw(SQLException, RuntimeException)
399 {
400 ::osl::MutexGuard aGuard( m_aMutex );
401 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
402
403 checkRecordSet();
404
405
406 return m_nRowPos == 1;
407 }
408 // -------------------------------------------------------------------------
isLast()409 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isLast( ) throw(SQLException, RuntimeException)
410 {
411 ::osl::MutexGuard aGuard( m_aMutex );
412 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
413
414 checkRecordSet();
415
416
417 return sal_True;
418 }
419 // -------------------------------------------------------------------------
beforeFirst()420 void SAL_CALL ODatabaseMetaDataResultSet::beforeFirst( ) throw(SQLException, RuntimeException)
421 {
422 ::osl::MutexGuard aGuard( m_aMutex );
423 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
424
425 checkRecordSet();
426
427
428 if(first())
429 previous();
430 }
431 // -------------------------------------------------------------------------
afterLast()432 void SAL_CALL ODatabaseMetaDataResultSet::afterLast( ) throw(SQLException, RuntimeException)
433 {
434 ::osl::MutexGuard aGuard( m_aMutex );
435 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
436
437 checkRecordSet();
438
439
440 if(last())
441 next();
442 m_bEOF = sal_True;
443 }
444 // -------------------------------------------------------------------------
445
close()446 void SAL_CALL ODatabaseMetaDataResultSet::close( ) throw(SQLException, RuntimeException)
447 {
448 {
449 ::osl::MutexGuard aGuard( m_aMutex );
450 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
451
452 }
453 dispose();
454 }
455 // -------------------------------------------------------------------------
456
first()457 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::first( ) throw(SQLException, RuntimeException)
458 {
459 ::osl::MutexGuard aGuard( m_aMutex );
460 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
461
462
463 if(!m_pRecordSet)
464 return sal_False;
465
466 sal_Bool bRet = SUCCEEDED(m_pRecordSet->MoveFirst());
467 if ( bRet )
468 m_nRowPos = 1;
469 return bRet;
470 }
471 // -------------------------------------------------------------------------
472
last()473 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::last( ) throw(SQLException, RuntimeException)
474 {
475 ::osl::MutexGuard aGuard( m_aMutex );
476 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed );
477
478
479 return m_pRecordSet && SUCCEEDED(m_pRecordSet->MoveLast()) ? sal_True : sal_False;
480 }
481 // -------------------------------------------------------------------------
absolute(sal_Int32 row)482 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::absolute( sal_Int32 row ) throw(SQLException, RuntimeException)
483 {
484 ::osl::MutexGuard aGuard( m_aMutex );
485 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
486
487
488 if(first())
489 {
490 OLEVariant aEmpty;
491 aEmpty.setNoArg();
492 sal_Bool bRet = SUCCEEDED(m_pRecordSet->Move(row,aEmpty));
493 if(bRet)
494 m_nRowPos = row;
495 return bRet;
496 }
497 return sal_False;
498 }
499 // -------------------------------------------------------------------------
relative(sal_Int32 row)500 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::relative( sal_Int32 row ) throw(SQLException, RuntimeException)
501 {
502 ::osl::MutexGuard aGuard( m_aMutex );
503 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
504
505
506 if(!m_pRecordSet)
507 return sal_False;
508
509 OLEVariant aEmpty;
510 aEmpty.setNoArg();
511 sal_Bool bRet = SUCCEEDED(m_pRecordSet->Move(row,aEmpty));
512 if(bRet)
513 m_nRowPos += row;
514 return bRet;
515 }
516 // -------------------------------------------------------------------------
previous()517 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::previous( ) throw(SQLException, RuntimeException)
518 {
519 ::osl::MutexGuard aGuard( m_aMutex );
520 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
521
522
523 if(!m_pRecordSet)
524 return sal_False;
525
526 sal_Bool bRet = SUCCEEDED(m_pRecordSet->MovePrevious());
527 if(bRet)
528 --m_nRowPos;
529 return bRet;
530 }
531 // -------------------------------------------------------------------------
getStatement()532 Reference< XInterface > SAL_CALL ODatabaseMetaDataResultSet::getStatement( ) throw(SQLException, RuntimeException)
533 {
534 return m_aStatement.get();
535 }
536 // -------------------------------------------------------------------------
537
rowDeleted()538 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowDeleted( ) throw(SQLException, RuntimeException)
539 {
540 ::osl::MutexGuard aGuard( m_aMutex );
541 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
542
543 checkRecordSet();
544
545
546 RecordStatusEnum eRec;
547 m_pRecordSet->get_Status((sal_Int32*)&eRec);
548 return (eRec & adRecDeleted) == adRecDeleted;
549 }
550 // -------------------------------------------------------------------------
rowInserted()551 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowInserted( ) throw(SQLException, RuntimeException)
552 { ::osl::MutexGuard aGuard( m_aMutex );
553 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
554
555 checkRecordSet();
556
557
558 RecordStatusEnum eRec;
559 m_pRecordSet->get_Status((sal_Int32*)&eRec);
560 return (eRec & adRecNew) == adRecNew;
561 }
562 // -------------------------------------------------------------------------
rowUpdated()563 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowUpdated( ) throw(SQLException, RuntimeException)
564 {
565 ::osl::MutexGuard aGuard( m_aMutex );
566 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
567
568 checkRecordSet();
569
570
571 RecordStatusEnum eRec;
572 m_pRecordSet->get_Status((sal_Int32*)&eRec);
573 return (eRec & adRecModified) == adRecModified;
574 }
575 // -------------------------------------------------------------------------
576
isBeforeFirst()577 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isBeforeFirst( ) throw(SQLException, RuntimeException)
578 {
579 ::osl::MutexGuard aGuard( m_aMutex );
580 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
581
582
583 if(!m_pRecordSet)
584 return sal_True;
585
586 VARIANT_BOOL bIsAtBOF;
587 m_pRecordSet->get_BOF(&bIsAtBOF);
588 return bIsAtBOF == VARIANT_TRUE;
589 }
590 // -------------------------------------------------------------------------
591
next()592 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::next( ) throw(SQLException, RuntimeException)
593 {
594 ::osl::MutexGuard aGuard( m_aMutex );
595 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
596
597
598 if(!m_pRecordSet)
599 return sal_False;
600
601 if(m_bOnFirstAfterOpen)
602 {
603 m_bOnFirstAfterOpen = sal_False;
604 return sal_True;
605 }
606 else
607 return SUCCEEDED(m_pRecordSet->MoveNext());
608 }
609 // -------------------------------------------------------------------------
610
wasNull()611 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::wasNull( ) throw(SQLException, RuntimeException)
612 {
613 ::osl::MutexGuard aGuard( m_aMutex );
614 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
615
616 checkRecordSet();
617
618
619 return m_aValue.isNull();
620 }
621 // -------------------------------------------------------------------------
refreshRow()622 void SAL_CALL ODatabaseMetaDataResultSet::refreshRow( ) throw(SQLException, RuntimeException)
623 {
624 ::osl::MutexGuard aGuard( m_aMutex );
625 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
626
627 checkRecordSet();
628
629
630 m_pRecordSet->Resync(adAffectCurrent,adResyncAllValues);
631 }
632 // -------------------------------------------------------------------------
633
cancel()634 void SAL_CALL ODatabaseMetaDataResultSet::cancel( ) throw(RuntimeException)
635 {
636 ::osl::MutexGuard aGuard( m_aMutex );
637 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
638
639 checkRecordSet();
640
641
642 m_pRecordSet->Cancel();
643 }
644 // -------------------------------------------------------------------------
clearWarnings()645 void SAL_CALL ODatabaseMetaDataResultSet::clearWarnings( ) throw(SQLException, RuntimeException)
646 {
647 }
648 // -------------------------------------------------------------------------
getWarnings()649 Any SAL_CALL ODatabaseMetaDataResultSet::getWarnings( ) throw(SQLException, RuntimeException)
650 {
651 return Any();
652 }
653 //------------------------------------------------------------------------------
getResultSetConcurrency() const654 sal_Int32 ODatabaseMetaDataResultSet::getResultSetConcurrency() const
655 throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
656 {
657 return ResultSetConcurrency::READ_ONLY;
658 }
659 //------------------------------------------------------------------------------
getResultSetType() const660 sal_Int32 ODatabaseMetaDataResultSet::getResultSetType() const
661 throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
662 {
663 return ResultSetType::FORWARD_ONLY;
664 }
665 //------------------------------------------------------------------------------
getFetchDirection() const666 sal_Int32 ODatabaseMetaDataResultSet::getFetchDirection() const
667 throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
668 {
669 return FetchDirection::FORWARD;
670 }
671 //------------------------------------------------------------------------------
getFetchSize() const672 sal_Int32 ODatabaseMetaDataResultSet::getFetchSize() const
673 throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
674 {
675 sal_Int32 nValue=-1;
676 if(m_pRecordSet)
677 m_pRecordSet->get_CacheSize(&nValue);
678 return nValue;
679 }
680 //------------------------------------------------------------------------------
getCursorName() const681 ::rtl::OUString ODatabaseMetaDataResultSet::getCursorName() const
682 throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
683 {
684 return ::rtl::OUString();
685 }
686
687 //------------------------------------------------------------------------------
setFetchDirection(sal_Int32)688 void ODatabaseMetaDataResultSet::setFetchDirection(sal_Int32 /*_par0*/)
689 throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
690 {
691 ::dbtools::throwFeatureNotImplementedException( "ResultSet::FetchDirection", *this );
692 }
693 //------------------------------------------------------------------------------
setFetchSize(sal_Int32 _par0)694 void ODatabaseMetaDataResultSet::setFetchSize(sal_Int32 _par0)
695 throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
696 {
697 if(m_pRecordSet)
698 m_pRecordSet->put_CacheSize(_par0);
699 }
700 // -------------------------------------------------------------------------
createArrayHelper() const701 ::cppu::IPropertyArrayHelper* ODatabaseMetaDataResultSet::createArrayHelper( ) const
702 {
703
704 Sequence< com::sun::star::beans::Property > aProps(5);
705 com::sun::star::beans::Property* pProperties = aProps.getArray();
706 sal_Int32 nPos = 0;
707 DECL_PROP0(CURSORNAME, ::rtl::OUString);
708 DECL_PROP0(FETCHDIRECTION, sal_Int32);
709 DECL_PROP0(FETCHSIZE, sal_Int32);
710 DECL_PROP0(RESULTSETCONCURRENCY,sal_Int32);
711 DECL_PROP0(RESULTSETTYPE, sal_Int32);
712
713 return new ::cppu::OPropertyArrayHelper(aProps);
714 }
715 // -------------------------------------------------------------------------
getInfoHelper()716 ::cppu::IPropertyArrayHelper & ODatabaseMetaDataResultSet::getInfoHelper()
717 {
718 return *const_cast<ODatabaseMetaDataResultSet*>(this)->getArrayHelper();
719 }
720 // -------------------------------------------------------------------------
convertFastPropertyValue(Any & rConvertedValue,Any & rOldValue,sal_Int32 nHandle,const Any & rValue)721 sal_Bool ODatabaseMetaDataResultSet::convertFastPropertyValue(
722 Any & rConvertedValue,
723 Any & rOldValue,
724 sal_Int32 nHandle,
725 const Any& rValue )
726 throw (::com::sun::star::lang::IllegalArgumentException)
727 {
728 switch(nHandle)
729 {
730 case PROPERTY_ID_CURSORNAME:
731 case PROPERTY_ID_RESULTSETCONCURRENCY:
732 case PROPERTY_ID_RESULTSETTYPE:
733 throw ::com::sun::star::lang::IllegalArgumentException();
734 break;
735 case PROPERTY_ID_FETCHDIRECTION:
736 return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchDirection());
737 case PROPERTY_ID_FETCHSIZE:
738 return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchSize());
739 default:
740 ;
741 }
742 return sal_False;
743 }
744 // -------------------------------------------------------------------------
setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any &)745 void ODatabaseMetaDataResultSet::setFastPropertyValue_NoBroadcast(
746 sal_Int32 nHandle,
747 const Any& /*rValue*/
748 )
749 throw (Exception)
750 {
751 switch(nHandle)
752 {
753 case PROPERTY_ID_CURSORNAME:
754 case PROPERTY_ID_RESULTSETCONCURRENCY:
755 case PROPERTY_ID_RESULTSETTYPE:
756 case PROPERTY_ID_FETCHDIRECTION:
757 case PROPERTY_ID_FETCHSIZE:
758 throw Exception();
759 break;
760 default:
761 OSL_ENSURE(0,"setFastPropertyValue_NoBroadcast: Illegal handle value!");
762 }
763 }
764 // -------------------------------------------------------------------------
getFastPropertyValue(Any & rValue,sal_Int32 nHandle) const765 void ODatabaseMetaDataResultSet::getFastPropertyValue(
766 Any& rValue,
767 sal_Int32 nHandle
768 ) const
769 {
770 switch(nHandle)
771 {
772 case PROPERTY_ID_CURSORNAME:
773 rValue <<= getCursorName();
774 break;
775 case PROPERTY_ID_RESULTSETCONCURRENCY:
776 rValue <<= getResultSetConcurrency();
777 break;
778 case PROPERTY_ID_RESULTSETTYPE:
779 rValue <<= getResultSetType();
780 break;
781 case PROPERTY_ID_FETCHDIRECTION:
782 rValue <<= getFetchDirection();
783 break;
784 case PROPERTY_ID_FETCHSIZE:
785 rValue <<= getFetchSize();
786 break;
787 }
788 }
789 // -------------------------------------------------------------------------
setProceduresMap()790 void ODatabaseMetaDataResultSet::setProceduresMap()
791 {
792
793 for(sal_Int32 i=1;i<4;i++)
794 m_aColMapping.push_back(i);
795 m_aColMapping.push_back(5);
796 m_aColMapping.push_back(7);
797 m_aColMapping.push_back(8);
798 m_aColMapping.push_back(6);
799 m_aColMapping.push_back(4);
800
801 TInt2IntMap aMap;
802 aMap[DB_PT_UNKNOWN] = ProcedureResult::UNKNOWN;
803 aMap[DB_PT_PROCEDURE] = ProcedureResult::NONE;
804 aMap[DB_PT_FUNCTION] = ProcedureResult::RETURN;
805 m_aValueRange[4] = aMap;
806
807 ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this);
808 pMetaData->setProceduresMap();
809 m_xMetaData = pMetaData;
810 }
811 // -------------------------------------------------------------------------
setCatalogsMap()812 void ODatabaseMetaDataResultSet::setCatalogsMap()
813 {
814 m_aColMapping.push_back(1);
815
816 m_xMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this);
817 }
818 // -------------------------------------------------------------------------
setSchemasMap()819 void ODatabaseMetaDataResultSet::setSchemasMap()
820 {
821 m_aColMapping.push_back(2);
822
823 m_xMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this);
824 }
825 // -------------------------------------------------------------------------
setColumnPrivilegesMap()826 void ODatabaseMetaDataResultSet::setColumnPrivilegesMap()
827 {
828
829 m_aColMapping.push_back(3);
830 m_aColMapping.push_back(4);
831 m_aColMapping.push_back(5);
832 m_aColMapping.push_back(6);
833 m_aColMapping.push_back(2);
834 m_aColMapping.push_back(9);
835 m_aColMapping.push_back(10);
836
837 ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this);
838 pMetaData->setColumnPrivilegesMap();
839 m_xMetaData = pMetaData;
840 }
841 // -------------------------------------------------------------------------
setColumnsMap()842 void ODatabaseMetaDataResultSet::setColumnsMap()
843 {
844
845 for(sal_Int32 i=1;i<5;++i)
846 m_aColMapping.push_back(i);
847
848 m_aColMapping.push_back(12);
849 m_aColMapping.push_back(12); // is used as TYPE_NAME
850
851 m_aColMapping.push_back(14);
852 m_aColMapping.push_back(6);
853 m_aColMapping.push_back(17);
854 m_aColMapping.push_back(18);
855
856 m_aColMapping.push_back(11);
857 m_aColMapping.push_back(29);
858 m_aColMapping.push_back(9);
859 m_aColMapping.push_back(18);
860 m_aColMapping.push_back(18);
861
862 m_aColMapping.push_back(15);
863 m_aColMapping.push_back(7);
864 m_aColMapping.push_back(11);
865
866 TInt2IntMap aMap;
867 aMap[adEmpty] = ADOS::MapADOType2Jdbc(adEmpty);
868 aMap[adTinyInt] = ADOS::MapADOType2Jdbc(adTinyInt);
869 aMap[adSmallInt] = ADOS::MapADOType2Jdbc(adSmallInt);
870 aMap[adInteger] = ADOS::MapADOType2Jdbc(adInteger);
871 aMap[adBigInt] = ADOS::MapADOType2Jdbc(adBigInt);
872 aMap[adUnsignedTinyInt] = ADOS::MapADOType2Jdbc(adUnsignedTinyInt);
873 aMap[adUnsignedSmallInt]= ADOS::MapADOType2Jdbc(adUnsignedSmallInt);
874 aMap[adUnsignedInt] = ADOS::MapADOType2Jdbc(adUnsignedInt);
875 aMap[adUnsignedBigInt] = ADOS::MapADOType2Jdbc(adUnsignedBigInt);
876 aMap[adSingle] = ADOS::MapADOType2Jdbc(adSingle);
877 aMap[adDouble] = ADOS::MapADOType2Jdbc(adDouble);
878 aMap[adCurrency] = ADOS::MapADOType2Jdbc(adCurrency);
879 aMap[adDecimal] = ADOS::MapADOType2Jdbc(adDecimal);
880 aMap[adNumeric] = ADOS::MapADOType2Jdbc(adNumeric);
881 aMap[adBoolean] = ADOS::MapADOType2Jdbc(adBoolean);
882 aMap[adError] = ADOS::MapADOType2Jdbc(adError);
883 aMap[adUserDefined] = ADOS::MapADOType2Jdbc(adUserDefined);
884 aMap[adVariant] = ADOS::MapADOType2Jdbc(adVariant);
885 aMap[adIDispatch] = ADOS::MapADOType2Jdbc(adIDispatch);
886 aMap[adIUnknown] = ADOS::MapADOType2Jdbc(adIUnknown);
887 aMap[adGUID] = ADOS::MapADOType2Jdbc(adGUID);
888 aMap[adDate] = ADOS::MapADOType2Jdbc(adDate);
889 aMap[adDBDate] = ADOS::MapADOType2Jdbc(adDBDate);
890 aMap[adDBTime] = ADOS::MapADOType2Jdbc(adDBTime);
891 aMap[adDBTimeStamp] = ADOS::MapADOType2Jdbc(adDBTimeStamp);
892 aMap[adBSTR] = ADOS::MapADOType2Jdbc(adBSTR);
893 aMap[adChar] = ADOS::MapADOType2Jdbc(adChar);
894 aMap[adVarChar] = ADOS::MapADOType2Jdbc(adVarChar);
895 aMap[adLongVarChar] = ADOS::MapADOType2Jdbc(adLongVarChar);
896 aMap[adWChar] = ADOS::MapADOType2Jdbc(adWChar);
897 aMap[adVarWChar] = ADOS::MapADOType2Jdbc(adVarWChar);
898 aMap[adLongVarWChar] = ADOS::MapADOType2Jdbc(adLongVarWChar);
899 aMap[adBinary] = ADOS::MapADOType2Jdbc(adBinary);
900 aMap[adVarBinary] = ADOS::MapADOType2Jdbc(adVarBinary);
901 aMap[adLongVarBinary] = ADOS::MapADOType2Jdbc(adLongVarBinary);
902 aMap[adChapter] = ADOS::MapADOType2Jdbc(adChapter);
903 aMap[adFileTime] = ADOS::MapADOType2Jdbc(adFileTime);
904 aMap[adPropVariant] = ADOS::MapADOType2Jdbc(adPropVariant);
905 aMap[adVarNumeric] = ADOS::MapADOType2Jdbc(adVarNumeric);
906 // aMap[adArray] = ADOS::MapADOType2Jdbc(adArray);
907
908 m_aValueRange[12] = aMap;
909
910 ::std::map< sal_Int32,::rtl::OUString> aMap2;
911 aMap2[0] = ::rtl::OUString::createFromAscii("YES");
912 aMap2[1] = ::rtl::OUString::createFromAscii("NO");
913 m_aIntValueRange[18] = aMap2;
914
915 ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this);
916 pMetaData->setColumnsMap();
917 m_xMetaData = pMetaData;
918 }
919 // -------------------------------------------------------------------------
setTablesMap()920 void ODatabaseMetaDataResultSet::setTablesMap()
921 {
922
923 for(sal_Int32 i=1;i<5;i++)
924 m_aColMapping.push_back(i);
925 m_aColMapping.push_back(6);
926
927 ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this);
928 pMetaData->setTablesMap();
929 m_xMetaData = pMetaData;
930 }
931 // -------------------------------------------------------------------------
setProcedureColumnsMap()932 void ODatabaseMetaDataResultSet::setProcedureColumnsMap()
933 {
934
935 for(sal_Int32 i=1;i<5;i++)
936 m_aColMapping.push_back(i);
937 m_aColMapping.push_back(6);
938 m_aColMapping.push_back(10);
939 m_aColMapping.push_back(16);
940 m_aColMapping.push_back(13);
941 m_aColMapping.push_back(11);
942 m_aColMapping.push_back(12);
943
944 m_aColMapping.push_back(9);
945 m_aColMapping.push_back(14);
946
947 TInt2IntMap aMap;
948 aMap[DBTYPE_EMPTY] = DataType::SQLNULL;
949 aMap[DBTYPE_NULL] = DataType::SQLNULL;
950 aMap[DBTYPE_I2] = DataType::SMALLINT;
951 aMap[DBTYPE_I4] = DataType::INTEGER;
952 aMap[DBTYPE_R4] = DataType::FLOAT;
953 aMap[DBTYPE_R8] = DataType::DOUBLE;
954 aMap[DBTYPE_CY] = DataType::BIGINT;
955 aMap[DBTYPE_DATE] = DataType::DATE;
956 aMap[DBTYPE_BSTR] = DataType::VARCHAR;
957 aMap[DBTYPE_IDISPATCH] = DataType::OBJECT;
958 aMap[DBTYPE_ERROR] = DataType::OTHER;
959 aMap[DBTYPE_BOOL] = DataType::BIT;
960 aMap[DBTYPE_VARIANT] = DataType::STRUCT;
961 aMap[DBTYPE_IUNKNOWN] = DataType::OTHER;
962 aMap[DBTYPE_DECIMAL] = DataType::DECIMAL;
963 aMap[DBTYPE_UI1] = DataType::TINYINT;
964 aMap[DBTYPE_ARRAY] = DataType::ARRAY;
965 aMap[DBTYPE_BYREF] = DataType::REF;
966 aMap[DBTYPE_I1] = DataType::CHAR;
967 aMap[DBTYPE_UI2] = DataType::SMALLINT;
968 aMap[DBTYPE_UI4] = DataType::INTEGER;
969
970 // aMap[The] = ;
971 // aMap[in] = ;
972 aMap[DBTYPE_I8] = DataType::BIGINT;
973 aMap[DBTYPE_UI8] = DataType::BIGINT;
974 aMap[DBTYPE_GUID] = DataType::OTHER;
975 aMap[DBTYPE_VECTOR] = DataType::OTHER;
976 aMap[DBTYPE_FILETIME] = DataType::OTHER;
977 aMap[DBTYPE_RESERVED] = DataType::OTHER;
978
979 // aMap[The] = ;
980 aMap[DBTYPE_BYTES] = DataType::VARBINARY;
981 aMap[DBTYPE_STR] = DataType::LONGVARCHAR;
982 aMap[DBTYPE_WSTR] = DataType::LONGVARCHAR;
983 aMap[DBTYPE_NUMERIC] = DataType::NUMERIC;
984 aMap[DBTYPE_UDT] = DataType::OTHER;
985 aMap[DBTYPE_DBDATE] = DataType::DATE;
986 aMap[DBTYPE_DBTIME] = DataType::TIME;
987 aMap[DBTYPE_DBTIMESTAMP] = DataType::TIMESTAMP;
988 aMap[DBTYPE_HCHAPTER] = DataType::OTHER;
989 aMap[DBTYPE_PROPVARIANT] = DataType::OTHER;
990 aMap[DBTYPE_VARNUMERIC] = DataType::NUMERIC;
991
992 m_aValueRange[10] = aMap;
993
994 ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this);
995 pMetaData->setProcedureColumnsMap();
996 m_xMetaData = pMetaData;
997 }
998 // -------------------------------------------------------------------------
setPrimaryKeysMap()999 void ODatabaseMetaDataResultSet::setPrimaryKeysMap()
1000 {
1001
1002 sal_Int32 i=1;
1003 for(;i<5;i++)
1004 m_aColMapping.push_back(i);
1005 m_aColMapping.push_back(7);
1006 m_aColMapping.push_back(8);
1007
1008 ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this);
1009 pMetaData->setProcedureColumnsMap();
1010 m_xMetaData = pMetaData;
1011 }
1012 // -------------------------------------------------------------------------
setIndexInfoMap()1013 void ODatabaseMetaDataResultSet::setIndexInfoMap()
1014 {
1015
1016 sal_Int32 i=1;
1017 for(;i<4;i++)
1018 m_aColMapping.push_back(i);
1019 m_aColMapping.push_back(8);
1020 m_aColMapping.push_back(4);
1021 m_aColMapping.push_back(6);
1022 m_aColMapping.push_back(10);
1023 m_aColMapping.push_back(17);
1024 m_aColMapping.push_back(18);
1025 m_aColMapping.push_back(21);
1026 m_aColMapping.push_back(22);
1027 m_aColMapping.push_back(23);
1028 m_aColMapping.push_back(24);
1029
1030 TInt2IntMap aMap;
1031 aMap[DBPROPVAL_IT_HASH] = IndexType::HASHED;
1032 aMap[DBPROPVAL_IT_CONTENT] = IndexType::OTHER;
1033 aMap[DBPROPVAL_IT_OTHER] = IndexType::OTHER;
1034 aMap[DBPROPVAL_IT_BTREE] = IndexType::OTHER;
1035
1036 m_aValueRange[10] = aMap;
1037
1038 TInt2IntMap aMap2;
1039 aMap[0] = 1;
1040 aMap[1] = 0;
1041 m_aValueRange[8] = aMap2;
1042
1043 ::std::map< sal_Int32,::rtl::OUString> aMap3;
1044 aMap3[0] = ::rtl::OUString();
1045 aMap3[DB_COLLATION_ASC] = ::rtl::OUString::createFromAscii("A");
1046 aMap3[DB_COLLATION_DESC] = ::rtl::OUString::createFromAscii("D");
1047
1048 m_aIntValueRange[21] = aMap3;
1049
1050 ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this);
1051 pMetaData->setIndexInfoMap();
1052 m_xMetaData = pMetaData;
1053 }
1054 // -------------------------------------------------------------------------
setTablePrivilegesMap()1055 void ODatabaseMetaDataResultSet::setTablePrivilegesMap()
1056 {
1057
1058 sal_Int32 i=3;
1059 for(;i<6;i++)
1060 m_aColMapping.push_back(i);
1061 m_aColMapping.push_back(1);
1062 m_aColMapping.push_back(2);
1063 m_aColMapping.push_back(6);
1064 m_aColMapping.push_back(7);
1065
1066 ::std::map< sal_Int32,::rtl::OUString> aMap;
1067 aMap[0] = ::rtl::OUString::createFromAscii("YES");
1068 aMap[1] = ::rtl::OUString::createFromAscii("NO");
1069 m_aIntValueRange[7] = aMap;
1070
1071
1072 ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this);
1073 pMetaData->setTablePrivilegesMap();
1074 m_xMetaData = pMetaData;
1075 }
1076 // -------------------------------------------------------------------------
setCrossReferenceMap()1077 void ODatabaseMetaDataResultSet::setCrossReferenceMap()
1078 {
1079
1080 sal_Int32 i=1;
1081 for(;i<5;i++)
1082 m_aColMapping.push_back(i);
1083 for(i=7;i<11;i++)
1084 m_aColMapping.push_back(i);
1085
1086 m_aColMapping.push_back(13);
1087 m_aColMapping.push_back(14);
1088 m_aColMapping.push_back(15);
1089 m_aColMapping.push_back(17);
1090 m_aColMapping.push_back(16);
1091 m_aColMapping.push_back(18);
1092
1093 ::std::map< ::rtl::OUString,sal_Int32> aMap;
1094 aMap[ ::rtl::OUString::createFromAscii("CASCADE")] = KeyRule::CASCADE;
1095 aMap[ ::rtl::OUString::createFromAscii("RESTRICT")] = KeyRule::RESTRICT;
1096 aMap[ ::rtl::OUString::createFromAscii("SET NULL")] = KeyRule::SET_NULL;
1097 aMap[ ::rtl::OUString::createFromAscii("SET DEFAULT")] = KeyRule::SET_DEFAULT;
1098 aMap[ ::rtl::OUString::createFromAscii("NO ACTION")] = KeyRule::NO_ACTION;
1099
1100 m_aStrValueRange[14] = aMap;
1101 m_aStrValueRange[15] = aMap;
1102
1103 ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this);
1104 pMetaData->setCrossReferenceMap();
1105 m_xMetaData = pMetaData;
1106 }
1107 // -------------------------------------------------------------------------
setTypeInfoMap(sal_Bool _bJetEngine)1108 void ODatabaseMetaDataResultSet::setTypeInfoMap(sal_Bool _bJetEngine)
1109 {
1110 sal_Int32 i=1;
1111 for(;i<19;i++)
1112 m_aColMapping.push_back(i);
1113
1114 ::std::map< ::rtl::OUString,sal_Int32> aMap1;
1115 aMap1[ ::rtl::OUString()] = 10;
1116
1117 m_aStrValueRange[18] = aMap1;
1118
1119 TInt2IntMap aMap;
1120 aMap[adEmpty] = ADOS::MapADOType2Jdbc(adEmpty);
1121 aMap[adTinyInt] = ADOS::MapADOType2Jdbc(adTinyInt);
1122 aMap[adSmallInt] = ADOS::MapADOType2Jdbc(adSmallInt);
1123 aMap[adInteger] = ADOS::MapADOType2Jdbc(adInteger);
1124 aMap[adBigInt] = ADOS::MapADOType2Jdbc(adBigInt);
1125 aMap[adUnsignedTinyInt] = ADOS::MapADOType2Jdbc(adUnsignedTinyInt);
1126 aMap[adUnsignedSmallInt]= ADOS::MapADOType2Jdbc(adUnsignedSmallInt);
1127 aMap[adUnsignedInt] = ADOS::MapADOType2Jdbc(adUnsignedInt);
1128 aMap[adUnsignedBigInt] = ADOS::MapADOType2Jdbc(adUnsignedBigInt);
1129 aMap[adSingle] = ADOS::MapADOType2Jdbc(adSingle);
1130 aMap[adDouble] = ADOS::MapADOType2Jdbc(adDouble);
1131 aMap[adCurrency] = ADOS::MapADOType2Jdbc(adCurrency);
1132 aMap[adDecimal] = ADOS::MapADOType2Jdbc(adDecimal);
1133 aMap[adNumeric] = ADOS::MapADOType2Jdbc(adNumeric);
1134 aMap[adBoolean] = ADOS::MapADOType2Jdbc(adBoolean);
1135 aMap[adError] = ADOS::MapADOType2Jdbc(adError);
1136 aMap[adUserDefined] = ADOS::MapADOType2Jdbc(adUserDefined);
1137 aMap[adVariant] = ADOS::MapADOType2Jdbc(adVariant);
1138 aMap[adIDispatch] = ADOS::MapADOType2Jdbc(adIDispatch);
1139 aMap[adIUnknown] = ADOS::MapADOType2Jdbc(adIUnknown);
1140 aMap[adGUID] = ADOS::MapADOType2Jdbc(adGUID);
1141 aMap[adDate] = _bJetEngine ? ADOS::MapADOType2Jdbc(adDBTimeStamp) : ADOS::MapADOType2Jdbc(adDate);
1142 aMap[adDBDate] = ADOS::MapADOType2Jdbc(adDBDate);
1143 aMap[adDBTime] = ADOS::MapADOType2Jdbc(adDBTime);
1144 aMap[adDBTimeStamp] = ADOS::MapADOType2Jdbc(adDBTimeStamp);
1145 aMap[adBSTR] = ADOS::MapADOType2Jdbc(adBSTR);
1146 aMap[adChar] = ADOS::MapADOType2Jdbc(adChar);
1147 aMap[adVarChar] = ADOS::MapADOType2Jdbc(adVarChar);
1148 aMap[adLongVarChar] = ADOS::MapADOType2Jdbc(adLongVarChar);
1149 aMap[adWChar] = ADOS::MapADOType2Jdbc(adWChar);
1150 aMap[adVarWChar] = ADOS::MapADOType2Jdbc(adVarWChar);
1151 aMap[adLongVarWChar] = ADOS::MapADOType2Jdbc(adLongVarWChar);
1152 aMap[adBinary] = ADOS::MapADOType2Jdbc(adBinary);
1153 aMap[adVarBinary] = ADOS::MapADOType2Jdbc(adVarBinary);
1154 aMap[adLongVarBinary] = ADOS::MapADOType2Jdbc(adLongVarBinary);
1155 aMap[adChapter] = ADOS::MapADOType2Jdbc(adChapter);
1156 aMap[adFileTime] = ADOS::MapADOType2Jdbc(adFileTime);
1157 aMap[adPropVariant] = ADOS::MapADOType2Jdbc(adPropVariant);
1158 aMap[adVarNumeric] = ADOS::MapADOType2Jdbc(adVarNumeric);
1159 // aMap[adArray] = ADOS::MapADOType2Jdbc(adArray);
1160
1161 m_aValueRange[2] = aMap;
1162
1163 TInt2IntMap aColumnValueMapping;
1164 aColumnValueMapping[VARIANT_FALSE] = ColumnValue::NO_NULLS;
1165 aColumnValueMapping[VARIANT_TRUE] = ColumnValue::NULLABLE;
1166 m_aValueRange[7] = aColumnValueMapping;
1167
1168 // now adjust the column mapping
1169 // OJ 24.01.2002 96860
1170 TInt2IntMap aSerachMapping;
1171 aSerachMapping[DB_UNSEARCHABLE] = ColumnSearch::NONE;
1172 aSerachMapping[DB_LIKE_ONLY] = ColumnSearch::CHAR;
1173 aSerachMapping[DB_ALL_EXCEPT_LIKE] = ColumnSearch::BASIC;
1174 aSerachMapping[DB_SEARCHABLE] = ColumnSearch::FULL;
1175
1176 m_aValueRange[9] = aSerachMapping;
1177
1178 TInt2IntMap aCurrencyMapping;
1179 m_aValueRange[11] = aCurrencyMapping;
1180
1181 ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this);
1182 pMetaData->setTypeInfoMap();
1183 m_xMetaData = pMetaData;
1184 }
1185 // -----------------------------------------------------------------------------
acquire()1186 void SAL_CALL ODatabaseMetaDataResultSet::acquire() throw()
1187 {
1188 ODatabaseMetaDataResultSet_BASE::acquire();
1189 }
1190 // -----------------------------------------------------------------------------
release()1191 void SAL_CALL ODatabaseMetaDataResultSet::release() throw()
1192 {
1193 ODatabaseMetaDataResultSet_BASE::release();
1194 }
1195 // -----------------------------------------------------------------------------
getPropertySetInfo()1196 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL ODatabaseMetaDataResultSet::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException)
1197 {
1198 return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
1199 }
1200 // -----------------------------------------------------------------------------
getValue(sal_Int32 columnIndex)1201 OLEVariant ODatabaseMetaDataResultSet::getValue(sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
1202 {
1203 ::osl::MutexGuard aGuard( m_aMutex );
1204 checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
1205
1206 checkRecordSet();
1207
1208 WpADOField aField = ADOS::getField(m_pRecordSet,columnIndex);
1209 aField.get_Value(m_aValue);
1210 return m_aValue;
1211 }
1212 // -----------------------------------------------------------------------------
1213
1214
1215