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 
27 #include "MacabDatabaseMetaData.hxx"
28 #include "MacabAddressBook.hxx"
29 #include "MacabHeader.hxx"
30 #include "MacabGroup.hxx"
31 #include "macabutilities.hxx"
32 
33 #ifndef CONNECTIVITY_MACAB_DRIVER_HXX_
34 #include "MacabDriver.hxx"
35 #endif
36 #include "FDatabaseMetaDataResultSet.hxx"
37 #include "OTypeInfo.hxx"
38 #include <com/sun/star/sdbc/ColumnValue.hpp>
39 #include <com/sun/star/sdbc/ResultSetType.hpp>
40 #include <com/sun/star/sdbc/TransactionIsolation.hpp>
41 
42 #include <vector>
43 
44 using namespace connectivity::macab;
45 using namespace com::sun::star::uno;
46 using namespace com::sun::star::lang;
47 using namespace com::sun::star::beans;
48 using namespace com::sun::star::sdbc;
49 
MacabDatabaseMetaData(MacabConnection * _pCon)50 MacabDatabaseMetaData::MacabDatabaseMetaData(MacabConnection* _pCon)
51 		: m_xConnection(_pCon),
52 		  m_bUseCatalog(sal_True)
53 {
54 	OSL_ENSURE(_pCon,"MacabDatabaseMetaData::MacabDatabaseMetaData: No connection set!");
55 
56 	osl_incrementInterlockedCount( &m_refCount );
57 	m_bUseCatalog	= !(usesLocalFiles() || usesLocalFilePerTable());
58 	osl_decrementInterlockedCount( &m_refCount );
59 }
60 // -------------------------------------------------------------------------
~MacabDatabaseMetaData()61 MacabDatabaseMetaData::~MacabDatabaseMetaData()
62 {
63 }
64 // -------------------------------------------------------------------------
getCatalogSeparator()65 ::rtl::OUString SAL_CALL MacabDatabaseMetaData::getCatalogSeparator(  ) throw(SQLException, RuntimeException)
66 {
67 	::rtl::OUString aVal;
68 	if (m_bUseCatalog)
69 	{ // do some special here for you database
70 	}
71 
72 	return aVal;
73 }
74 // -------------------------------------------------------------------------
getMaxBinaryLiteralLength()75 sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxBinaryLiteralLength(  ) throw(SQLException, RuntimeException)
76 {
77 	sal_Int32 nValue = 0; // 0 means no limit
78 	return nValue;
79 }
80 // -------------------------------------------------------------------------
getMaxRowSize()81 sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxRowSize(  ) throw(SQLException, RuntimeException)
82 {
83 	sal_Int32 nValue = 0; // 0 means no limit
84 	return nValue;
85 }
86 // -------------------------------------------------------------------------
getMaxCatalogNameLength()87 sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxCatalogNameLength(  ) throw(SQLException, RuntimeException)
88 {
89 	sal_Int32 nValue = 0; // 0 means no limit
90 	return nValue;
91 }
92 // -------------------------------------------------------------------------
getMaxCharLiteralLength()93 sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxCharLiteralLength(  ) throw(SQLException, RuntimeException)
94 {
95 	sal_Int32 nValue = 0; // 0 means no limit
96 	return nValue;
97 }
98 // -------------------------------------------------------------------------
getMaxColumnNameLength()99 sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxColumnNameLength(  ) throw(SQLException, RuntimeException)
100 {
101 	sal_Int32 nValue = 0; // 0 means no limit
102 	return nValue;
103 }
104 // -------------------------------------------------------------------------
getMaxColumnsInIndex()105 sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxColumnsInIndex(  ) throw(SQLException, RuntimeException)
106 {
107 	sal_Int32 nValue = 0; // 0 means no limit
108 	return nValue;
109 }
110 // -------------------------------------------------------------------------
getMaxCursorNameLength()111 sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxCursorNameLength(  ) throw(SQLException, RuntimeException)
112 {
113 	sal_Int32 nValue = 0; // 0 means no limit
114 	return nValue;
115 }
116 // -------------------------------------------------------------------------
getMaxConnections()117 sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxConnections(  ) throw(SQLException, RuntimeException)
118 {
119 	sal_Int32 nValue = 0; // 0 means no limit
120 	return nValue;
121 }
122 // -------------------------------------------------------------------------
getMaxColumnsInTable()123 sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxColumnsInTable(  ) throw(SQLException, RuntimeException)
124 {
125 	sal_Int32 nValue = 0; // 0 means no limit
126 	return nValue;
127 }
128 // -------------------------------------------------------------------------
getMaxStatementLength()129 sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxStatementLength(  ) throw(SQLException, RuntimeException)
130 {
131 	sal_Int32 nValue = 0; // 0 means no limit
132 	return nValue;
133 }
134 // -------------------------------------------------------------------------
getMaxTableNameLength()135 sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxTableNameLength(  ) throw(SQLException, RuntimeException)
136 {
137 	sal_Int32 nValue = 0; // 0 means no limit
138 	return nValue;
139 }
140 // -------------------------------------------------------------------------
getMaxTablesInSelect()141 sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxTablesInSelect(  ) throw(SQLException, RuntimeException)
142 {
143 	// MaxTablesInSelect describes how many tables can participate in the FROM part of a given SELECT statement,
144 	// currently, the resultset/statement implementations can cope with one table only
145 	sal_Int32 nValue = 1;
146 	return nValue;
147 }
148 // -------------------------------------------------------------------------
doesMaxRowSizeIncludeBlobs()149 sal_Bool SAL_CALL MacabDatabaseMetaData::doesMaxRowSizeIncludeBlobs(  ) throw(SQLException, RuntimeException)
150 {
151 	return sal_False;
152 }
153 // -------------------------------------------------------------------------
storesLowerCaseQuotedIdentifiers()154 sal_Bool SAL_CALL MacabDatabaseMetaData::storesLowerCaseQuotedIdentifiers(  ) throw(SQLException, RuntimeException)
155 {
156 	return sal_False;
157 }
158 // -------------------------------------------------------------------------
storesLowerCaseIdentifiers()159 sal_Bool SAL_CALL MacabDatabaseMetaData::storesLowerCaseIdentifiers(  ) throw(SQLException, RuntimeException)
160 {
161 	return sal_False;
162 }
163 // -------------------------------------------------------------------------
storesMixedCaseQuotedIdentifiers()164 sal_Bool SAL_CALL MacabDatabaseMetaData::storesMixedCaseQuotedIdentifiers(  ) throw(SQLException, RuntimeException)
165 {
166 	return sal_False;
167 }
168 // -------------------------------------------------------------------------
storesMixedCaseIdentifiers()169 sal_Bool SAL_CALL MacabDatabaseMetaData::storesMixedCaseIdentifiers(  ) throw(SQLException, RuntimeException)
170 {
171 	return sal_False;
172 }
173 // -------------------------------------------------------------------------
storesUpperCaseQuotedIdentifiers()174 sal_Bool SAL_CALL MacabDatabaseMetaData::storesUpperCaseQuotedIdentifiers(  ) throw(SQLException, RuntimeException)
175 {
176 	return sal_False;
177 }
178 // -------------------------------------------------------------------------
storesUpperCaseIdentifiers()179 sal_Bool SAL_CALL MacabDatabaseMetaData::storesUpperCaseIdentifiers(  ) throw(SQLException, RuntimeException)
180 {
181 	return sal_False;
182 }
183 // -------------------------------------------------------------------------
supportsAlterTableWithAddColumn()184 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsAlterTableWithAddColumn(  ) throw(SQLException, RuntimeException)
185 {
186 	return sal_False;
187 }
188 // -------------------------------------------------------------------------
supportsAlterTableWithDropColumn()189 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsAlterTableWithDropColumn(  ) throw(SQLException, RuntimeException)
190 {
191 	return sal_False;
192 }
193 // -------------------------------------------------------------------------
getMaxIndexLength()194 sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxIndexLength(  ) throw(SQLException, RuntimeException)
195 {
196 	sal_Int32 nValue = 0; // 0 means no limit
197 	return nValue;
198 }
199 // -------------------------------------------------------------------------
supportsNonNullableColumns()200 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsNonNullableColumns(  ) throw(SQLException, RuntimeException)
201 {
202 	return sal_False;
203 }
204 // -------------------------------------------------------------------------
getCatalogTerm()205 ::rtl::OUString SAL_CALL MacabDatabaseMetaData::getCatalogTerm(  ) throw(SQLException, RuntimeException)
206 {
207 	::rtl::OUString aVal;
208 	if (m_bUseCatalog)
209 	{
210 	}
211 	return aVal;
212 }
213 // -------------------------------------------------------------------------
getIdentifierQuoteString()214 ::rtl::OUString SAL_CALL MacabDatabaseMetaData::getIdentifierQuoteString(  ) throw(SQLException, RuntimeException)
215 {
216 	// normally this is "
217 	::rtl::OUString aVal = ::rtl::OUString::createFromAscii("\"");
218 	return aVal;
219 }
220 // -------------------------------------------------------------------------
getExtraNameCharacters()221 ::rtl::OUString SAL_CALL MacabDatabaseMetaData::getExtraNameCharacters(  ) throw(SQLException, RuntimeException)
222 {
223 	::rtl::OUString aVal;
224 	return aVal;
225 }
226 // -------------------------------------------------------------------------
supportsDifferentTableCorrelationNames()227 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsDifferentTableCorrelationNames(  ) throw(SQLException, RuntimeException)
228 {
229 	return sal_False;
230 }
231 // -------------------------------------------------------------------------
isCatalogAtStart()232 sal_Bool SAL_CALL MacabDatabaseMetaData::isCatalogAtStart(  ) throw(SQLException, RuntimeException)
233 {
234 	sal_Bool bValue = sal_False;
235 	if (m_bUseCatalog)
236 	{
237 	}
238 	return bValue;
239 }
240 // -------------------------------------------------------------------------
dataDefinitionIgnoredInTransactions()241 sal_Bool SAL_CALL MacabDatabaseMetaData::dataDefinitionIgnoredInTransactions(  ) throw(SQLException, RuntimeException)
242 {
243 	return sal_True;
244 }
245 // -------------------------------------------------------------------------
dataDefinitionCausesTransactionCommit()246 sal_Bool SAL_CALL MacabDatabaseMetaData::dataDefinitionCausesTransactionCommit(  ) throw(SQLException, RuntimeException)
247 {
248 	return sal_True;
249 }
250 // -------------------------------------------------------------------------
supportsDataManipulationTransactionsOnly()251 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsDataManipulationTransactionsOnly(  ) throw(SQLException, RuntimeException)
252 {
253 	return sal_True;
254 }
255 // -------------------------------------------------------------------------
supportsDataDefinitionAndDataManipulationTransactions()256 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsDataDefinitionAndDataManipulationTransactions(  ) throw(SQLException, RuntimeException)
257 {
258 	return sal_True;
259 }
260 // -------------------------------------------------------------------------
supportsPositionedDelete()261 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsPositionedDelete(  ) throw(SQLException, RuntimeException)
262 {
263 	return sal_False;
264 }
265 // -------------------------------------------------------------------------
supportsPositionedUpdate()266 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsPositionedUpdate(  ) throw(SQLException, RuntimeException)
267 {
268 	return sal_False;
269 }
270 // -------------------------------------------------------------------------
supportsOpenStatementsAcrossRollback()271 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsOpenStatementsAcrossRollback(  ) throw(SQLException, RuntimeException)
272 {
273 	return sal_False;
274 }
275 // -------------------------------------------------------------------------
supportsOpenStatementsAcrossCommit()276 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsOpenStatementsAcrossCommit(  ) throw(SQLException, RuntimeException)
277 {
278 	return sal_False;
279 }
280 // -------------------------------------------------------------------------
supportsOpenCursorsAcrossCommit()281 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsOpenCursorsAcrossCommit(  ) throw(SQLException, RuntimeException)
282 {
283 	return sal_False;
284 }
285 // -------------------------------------------------------------------------
supportsOpenCursorsAcrossRollback()286 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsOpenCursorsAcrossRollback(  ) throw(SQLException, RuntimeException)
287 {
288 	return sal_False;
289 }
290 // -------------------------------------------------------------------------
supportsTransactionIsolationLevel(sal_Int32)291 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsTransactionIsolationLevel( sal_Int32 ) throw(SQLException, RuntimeException)
292 {
293 	return sal_False;
294 }
295 // -------------------------------------------------------------------------
supportsSchemasInDataManipulation()296 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsSchemasInDataManipulation(  ) throw(SQLException, RuntimeException)
297 {
298 	return sal_False;
299 }
300 // -------------------------------------------------------------------------
supportsANSI92FullSQL()301 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsANSI92FullSQL(  ) throw(SQLException, RuntimeException)
302 {
303 	return sal_False;
304 }
305 // -------------------------------------------------------------------------
supportsANSI92EntryLevelSQL()306 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsANSI92EntryLevelSQL(  ) throw(SQLException, RuntimeException)
307 {
308 	return sal_True; // should be supported at least
309 }
310 // -------------------------------------------------------------------------
supportsIntegrityEnhancementFacility()311 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsIntegrityEnhancementFacility(  ) throw(SQLException, RuntimeException)
312 {
313 	return sal_False;
314 }
315 // -------------------------------------------------------------------------
supportsSchemasInIndexDefinitions()316 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsSchemasInIndexDefinitions(  ) throw(SQLException, RuntimeException)
317 {
318 	return sal_False;
319 }
320 // -------------------------------------------------------------------------
supportsSchemasInTableDefinitions()321 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsSchemasInTableDefinitions(  ) throw(SQLException, RuntimeException)
322 {
323 	return sal_False;
324 }
325 // -------------------------------------------------------------------------
supportsCatalogsInTableDefinitions()326 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsCatalogsInTableDefinitions(  ) throw(SQLException, RuntimeException)
327 {
328 	return sal_False;
329 }
330 // -------------------------------------------------------------------------
supportsCatalogsInIndexDefinitions()331 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsCatalogsInIndexDefinitions(  ) throw(SQLException, RuntimeException)
332 {
333 	return sal_False;
334 }
335 // -------------------------------------------------------------------------
supportsCatalogsInDataManipulation()336 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsCatalogsInDataManipulation(  ) throw(SQLException, RuntimeException)
337 {
338 	return sal_False;
339 }
340 // -------------------------------------------------------------------------
supportsOuterJoins()341 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsOuterJoins(  ) throw(SQLException, RuntimeException)
342 {
343 	return sal_False;
344 }
345 // -------------------------------------------------------------------------
getMaxStatements()346 sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxStatements(  ) throw(SQLException, RuntimeException)
347 {
348 	sal_Int32 nValue = 0; // 0 means no limit
349 	return nValue;
350 }
351 // -------------------------------------------------------------------------
getMaxProcedureNameLength()352 sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxProcedureNameLength(  ) throw(SQLException, RuntimeException)
353 {
354 	sal_Int32 nValue = 0; // 0 means no limit
355 	return nValue;
356 }
357 // -------------------------------------------------------------------------
getMaxSchemaNameLength()358 sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxSchemaNameLength(  ) throw(SQLException, RuntimeException)
359 {
360 	sal_Int32 nValue = 0; // 0 means no limit
361 	return nValue;
362 }
363 // -------------------------------------------------------------------------
supportsTransactions()364 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsTransactions(  ) throw(SQLException, RuntimeException)
365 {
366 	return sal_False;
367 }
368 // -------------------------------------------------------------------------
allProceduresAreCallable()369 sal_Bool SAL_CALL MacabDatabaseMetaData::allProceduresAreCallable(  ) throw(SQLException, RuntimeException)
370 {
371 	return sal_False;
372 }
373 // -------------------------------------------------------------------------
supportsStoredProcedures()374 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsStoredProcedures(  ) throw(SQLException, RuntimeException)
375 {
376 	return sal_False;
377 }
378 // -------------------------------------------------------------------------
supportsSelectForUpdate()379 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsSelectForUpdate(  ) throw(SQLException, RuntimeException)
380 {
381 	return sal_False;
382 }
383 // -------------------------------------------------------------------------
allTablesAreSelectable()384 sal_Bool SAL_CALL MacabDatabaseMetaData::allTablesAreSelectable(  ) throw(SQLException, RuntimeException)
385 {
386 	return sal_False;
387 }
388 // -------------------------------------------------------------------------
isReadOnly()389 sal_Bool SAL_CALL MacabDatabaseMetaData::isReadOnly(  ) throw(SQLException, RuntimeException)
390 {
391 	// for the moment, we have read-only addresses, but this might change in the future
392 	return sal_True;
393 }
394 // -------------------------------------------------------------------------
usesLocalFiles()395 sal_Bool SAL_CALL MacabDatabaseMetaData::usesLocalFiles(  ) throw(SQLException, RuntimeException)
396 {
397 	return sal_False;
398 }
399 // -------------------------------------------------------------------------
usesLocalFilePerTable()400 sal_Bool SAL_CALL MacabDatabaseMetaData::usesLocalFilePerTable(  ) throw(SQLException, RuntimeException)
401 {
402 	return sal_False;
403 }
404 // -------------------------------------------------------------------------
supportsTypeConversion()405 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsTypeConversion(  ) throw(SQLException, RuntimeException)
406 {
407 	return sal_False;
408 }
409 // -------------------------------------------------------------------------
nullPlusNonNullIsNull()410 sal_Bool SAL_CALL MacabDatabaseMetaData::nullPlusNonNullIsNull(  ) throw(SQLException, RuntimeException)
411 {
412 	return sal_False;
413 }
414 // -------------------------------------------------------------------------
supportsColumnAliasing()415 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsColumnAliasing(  ) throw(SQLException, RuntimeException)
416 {
417 	return sal_False;
418 }
419 // -------------------------------------------------------------------------
supportsTableCorrelationNames()420 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsTableCorrelationNames(  ) throw(SQLException, RuntimeException)
421 {
422 	return sal_False;
423 }
424 // -------------------------------------------------------------------------
supportsConvert(sal_Int32,sal_Int32)425 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsConvert( sal_Int32, sal_Int32 ) throw(SQLException, RuntimeException)
426 {
427 	return sal_False;
428 }
429 // -------------------------------------------------------------------------
supportsExpressionsInOrderBy()430 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsExpressionsInOrderBy(  ) throw(SQLException, RuntimeException)
431 {
432 	return sal_False;
433 }
434 // -------------------------------------------------------------------------
supportsGroupBy()435 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsGroupBy(  ) throw(SQLException, RuntimeException)
436 {
437 	return sal_False;
438 }
439 // -------------------------------------------------------------------------
supportsGroupByBeyondSelect()440 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsGroupByBeyondSelect(  ) throw(SQLException, RuntimeException)
441 {
442 	return sal_False;
443 }
444 // -------------------------------------------------------------------------
supportsGroupByUnrelated()445 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsGroupByUnrelated(  ) throw(SQLException, RuntimeException)
446 {
447 	return sal_False;
448 }
449 // -------------------------------------------------------------------------
supportsMultipleTransactions()450 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsMultipleTransactions(  ) throw(SQLException, RuntimeException)
451 {
452 	return sal_False;
453 }
454 // -------------------------------------------------------------------------
supportsMultipleResultSets()455 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsMultipleResultSets(  ) throw(SQLException, RuntimeException)
456 {
457 	return sal_False;
458 }
459 // -------------------------------------------------------------------------
supportsLikeEscapeClause()460 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsLikeEscapeClause(  ) throw(SQLException, RuntimeException)
461 {
462 	return sal_False;
463 }
464 // -------------------------------------------------------------------------
supportsOrderByUnrelated()465 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsOrderByUnrelated(  ) throw(SQLException, RuntimeException)
466 {
467 	return sal_False;
468 }
469 // -------------------------------------------------------------------------
supportsUnion()470 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsUnion(  ) throw(SQLException, RuntimeException)
471 {
472 	return sal_False;
473 }
474 // -------------------------------------------------------------------------
supportsUnionAll()475 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsUnionAll(  ) throw(SQLException, RuntimeException)
476 {
477 	return sal_False;
478 }
479 // -------------------------------------------------------------------------
supportsMixedCaseIdentifiers()480 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsMixedCaseIdentifiers(  ) throw(SQLException, RuntimeException)
481 {
482 	return sal_False;
483 }
484 // -------------------------------------------------------------------------
supportsMixedCaseQuotedIdentifiers()485 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsMixedCaseQuotedIdentifiers(  ) throw(SQLException, RuntimeException)
486 {
487 	return sal_False;
488 }
489 // -------------------------------------------------------------------------
nullsAreSortedAtEnd()490 sal_Bool SAL_CALL MacabDatabaseMetaData::nullsAreSortedAtEnd(  ) throw(SQLException, RuntimeException)
491 {
492 	return sal_False;
493 }
494 // -------------------------------------------------------------------------
nullsAreSortedAtStart()495 sal_Bool SAL_CALL MacabDatabaseMetaData::nullsAreSortedAtStart(  ) throw(SQLException, RuntimeException)
496 {
497 	return sal_False;
498 }
499 // -------------------------------------------------------------------------
nullsAreSortedHigh()500 sal_Bool SAL_CALL MacabDatabaseMetaData::nullsAreSortedHigh(  ) throw(SQLException, RuntimeException)
501 {
502 	return sal_False;
503 }
504 // -------------------------------------------------------------------------
nullsAreSortedLow()505 sal_Bool SAL_CALL MacabDatabaseMetaData::nullsAreSortedLow(  ) throw(SQLException, RuntimeException)
506 {
507 	return sal_False;
508 }
509 // -------------------------------------------------------------------------
supportsSchemasInProcedureCalls()510 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsSchemasInProcedureCalls(  ) throw(SQLException, RuntimeException)
511 {
512 	return sal_False;
513 }
514 // -------------------------------------------------------------------------
supportsSchemasInPrivilegeDefinitions()515 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsSchemasInPrivilegeDefinitions(  ) throw(SQLException, RuntimeException)
516 {
517 	return sal_False;
518 }
519 // -------------------------------------------------------------------------
supportsCatalogsInProcedureCalls()520 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsCatalogsInProcedureCalls(  ) throw(SQLException, RuntimeException)
521 {
522 	return sal_False;
523 }
524 // -------------------------------------------------------------------------
supportsCatalogsInPrivilegeDefinitions()525 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsCatalogsInPrivilegeDefinitions(  ) throw(SQLException, RuntimeException)
526 {
527 	return sal_False;
528 }
529 // -------------------------------------------------------------------------
supportsCorrelatedSubqueries()530 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsCorrelatedSubqueries(  ) throw(SQLException, RuntimeException)
531 {
532 	return sal_False;
533 }
534 // -------------------------------------------------------------------------
supportsSubqueriesInComparisons()535 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsSubqueriesInComparisons(  ) throw(SQLException, RuntimeException)
536 {
537 	return sal_False;
538 }
539 // -------------------------------------------------------------------------
supportsSubqueriesInExists()540 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsSubqueriesInExists(  ) throw(SQLException, RuntimeException)
541 {
542 	return sal_False;
543 }
544 // -------------------------------------------------------------------------
supportsSubqueriesInIns()545 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsSubqueriesInIns(  ) throw(SQLException, RuntimeException)
546 {
547 	return sal_False;
548 }
549 // -------------------------------------------------------------------------
supportsSubqueriesInQuantifieds()550 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsSubqueriesInQuantifieds(  ) throw(SQLException, RuntimeException)
551 {
552 	return sal_False;
553 }
554 // -------------------------------------------------------------------------
supportsANSI92IntermediateSQL()555 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsANSI92IntermediateSQL(  ) throw(SQLException, RuntimeException)
556 {
557 	return sal_False;
558 }
559 // -------------------------------------------------------------------------
getURL()560 ::rtl::OUString SAL_CALL MacabDatabaseMetaData::getURL(  ) throw(SQLException, RuntimeException)
561 {
562 	// if someday we support more than the default address book,
563 	// this method should return the URL which was used to create it
564 	::rtl::OUString aValue = ::rtl::OUString::createFromAscii("sdbc:address:macab:");
565 	return aValue;
566 }
567 // -------------------------------------------------------------------------
getUserName()568 ::rtl::OUString SAL_CALL MacabDatabaseMetaData::getUserName(  ) throw(SQLException, RuntimeException)
569 {
570 	::rtl::OUString aValue;
571 	return aValue;
572 }
573 // -------------------------------------------------------------------------
getDriverName()574 ::rtl::OUString SAL_CALL MacabDatabaseMetaData::getDriverName(  ) throw(SQLException, RuntimeException)
575 {
576 	::rtl::OUString aValue = ::rtl::OUString::createFromAscii("macab");
577 	return aValue;
578 }
579 // -------------------------------------------------------------------------
getDriverVersion()580 ::rtl::OUString SAL_CALL MacabDatabaseMetaData::getDriverVersion() throw(SQLException, RuntimeException)
581 {
582 	::rtl::OUString aValue = ::rtl::OUString::createFromAscii(MACAB_DRIVER_VERSION);
583 	return aValue;
584 }
585 // -------------------------------------------------------------------------
getDatabaseProductVersion()586 ::rtl::OUString SAL_CALL MacabDatabaseMetaData::getDatabaseProductVersion(  ) throw(SQLException, RuntimeException)
587 {
588 	::rtl::OUString aValue;
589 	return aValue;
590 }
591 // -------------------------------------------------------------------------
getDatabaseProductName()592 ::rtl::OUString SAL_CALL MacabDatabaseMetaData::getDatabaseProductName(  ) throw(SQLException, RuntimeException)
593 {
594 	::rtl::OUString aValue;
595 	return aValue;
596 }
597 // -------------------------------------------------------------------------
getProcedureTerm()598 ::rtl::OUString SAL_CALL MacabDatabaseMetaData::getProcedureTerm(  ) throw(SQLException, RuntimeException)
599 {
600 	::rtl::OUString aValue;
601 	return aValue;
602 }
603 // -------------------------------------------------------------------------
getSchemaTerm()604 ::rtl::OUString SAL_CALL MacabDatabaseMetaData::getSchemaTerm(  ) throw(SQLException, RuntimeException)
605 {
606 	::rtl::OUString aValue;
607 	return aValue;
608 }
609 // -------------------------------------------------------------------------
getDriverMajorVersion()610 sal_Int32 SAL_CALL MacabDatabaseMetaData::getDriverMajorVersion(  ) throw(RuntimeException)
611 {
612 	return MACAB_DRIVER_VERSION_MAJOR;
613 }
614 // -------------------------------------------------------------------------
getDefaultTransactionIsolation()615 sal_Int32 SAL_CALL MacabDatabaseMetaData::getDefaultTransactionIsolation(  ) throw(SQLException, RuntimeException)
616 {
617 	return TransactionIsolation::NONE;
618 }
619 // -------------------------------------------------------------------------
getDriverMinorVersion()620 sal_Int32 SAL_CALL MacabDatabaseMetaData::getDriverMinorVersion(  ) throw(RuntimeException)
621 {
622 	return MACAB_DRIVER_VERSION_MINOR;
623 }
624 // -------------------------------------------------------------------------
getSQLKeywords()625 ::rtl::OUString SAL_CALL MacabDatabaseMetaData::getSQLKeywords(  ) throw(SQLException, RuntimeException)
626 {
627 	::rtl::OUString aValue;
628 	return aValue;
629 }
630 // -------------------------------------------------------------------------
getSearchStringEscape()631 ::rtl::OUString SAL_CALL MacabDatabaseMetaData::getSearchStringEscape(  ) throw(SQLException, RuntimeException)
632 {
633 	::rtl::OUString aValue;
634 	return aValue;
635 }
636 // -------------------------------------------------------------------------
getStringFunctions()637 ::rtl::OUString SAL_CALL MacabDatabaseMetaData::getStringFunctions(  ) throw(SQLException, RuntimeException)
638 {
639 	return ::rtl::OUString();
640 }
641 // -------------------------------------------------------------------------
getTimeDateFunctions()642 ::rtl::OUString SAL_CALL MacabDatabaseMetaData::getTimeDateFunctions(  ) throw(SQLException, RuntimeException)
643 {
644 	return ::rtl::OUString();
645 }
646 // -------------------------------------------------------------------------
getSystemFunctions()647 ::rtl::OUString SAL_CALL MacabDatabaseMetaData::getSystemFunctions(  ) throw(SQLException, RuntimeException)
648 {
649 	return ::rtl::OUString();
650 }
651 // -------------------------------------------------------------------------
getNumericFunctions()652 ::rtl::OUString SAL_CALL MacabDatabaseMetaData::getNumericFunctions(  ) throw(SQLException, RuntimeException)
653 {
654 	return ::rtl::OUString();
655 }
656 // -------------------------------------------------------------------------
supportsExtendedSQLGrammar()657 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsExtendedSQLGrammar(  ) throw(SQLException, RuntimeException)
658 {
659 	return sal_False;
660 }
661 // -------------------------------------------------------------------------
supportsCoreSQLGrammar()662 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsCoreSQLGrammar(  ) throw(SQLException, RuntimeException)
663 {
664 	return sal_False;
665 }
666 // -------------------------------------------------------------------------
supportsMinimumSQLGrammar()667 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsMinimumSQLGrammar(  ) throw(SQLException, RuntimeException)
668 {
669 	return sal_True;
670 }
671 // -------------------------------------------------------------------------
supportsFullOuterJoins()672 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsFullOuterJoins(  ) throw(SQLException, RuntimeException)
673 {
674 	return sal_False;
675 }
676 // -------------------------------------------------------------------------
supportsLimitedOuterJoins()677 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsLimitedOuterJoins(  ) throw(SQLException, RuntimeException)
678 {
679 	return sal_False;
680 }
681 // -------------------------------------------------------------------------
getMaxColumnsInGroupBy()682 sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxColumnsInGroupBy(  ) throw(SQLException, RuntimeException)
683 {
684 	sal_Int32 nValue = 0; // 0 means no limit
685 	return nValue;
686 }
687 // -------------------------------------------------------------------------
getMaxColumnsInOrderBy()688 sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxColumnsInOrderBy(  ) throw(SQLException, RuntimeException)
689 {
690 	sal_Int32 nValue = 0; // 0 means no limit
691 	return nValue;
692 }
693 // -------------------------------------------------------------------------
getMaxColumnsInSelect()694 sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxColumnsInSelect(  ) throw(SQLException, RuntimeException)
695 {
696 	sal_Int32 nValue = 0; // 0 means no limit
697 	return nValue;
698 }
699 // -------------------------------------------------------------------------
getMaxUserNameLength()700 sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxUserNameLength(  ) throw(SQLException, RuntimeException)
701 {
702 	sal_Int32 nValue = 0; // 0 means no limit
703 	return nValue;
704 }
705 // -------------------------------------------------------------------------
supportsResultSetType(sal_Int32 setType)706 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsResultSetType( sal_Int32 setType ) throw(SQLException, RuntimeException)
707 {
708 	switch (setType)
709 	{
710 		case ResultSetType::FORWARD_ONLY:
711 		case ResultSetType::SCROLL_INSENSITIVE:
712 			return sal_True;
713 	}
714 	return sal_False;
715 }
716 // -------------------------------------------------------------------------
supportsResultSetConcurrency(sal_Int32 setType,sal_Int32)717 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsResultSetConcurrency( sal_Int32 setType, sal_Int32 ) throw(SQLException, RuntimeException)
718 {
719 	switch (setType)
720 	{
721 		case ResultSetType::FORWARD_ONLY:
722 		case ResultSetType::SCROLL_INSENSITIVE:
723 			return sal_True;
724 	}
725 	return sal_False;
726 }
727 // -------------------------------------------------------------------------
ownUpdatesAreVisible(sal_Int32)728 sal_Bool SAL_CALL MacabDatabaseMetaData::ownUpdatesAreVisible( sal_Int32 ) throw(SQLException, RuntimeException)
729 {
730 	return sal_False;
731 }
732 // -------------------------------------------------------------------------
ownDeletesAreVisible(sal_Int32)733 sal_Bool SAL_CALL MacabDatabaseMetaData::ownDeletesAreVisible( sal_Int32 ) throw(SQLException, RuntimeException)
734 {
735 	return sal_False;
736 }
737 // -------------------------------------------------------------------------
ownInsertsAreVisible(sal_Int32)738 sal_Bool SAL_CALL MacabDatabaseMetaData::ownInsertsAreVisible( sal_Int32 ) throw(SQLException, RuntimeException)
739 {
740 	return sal_False;
741 }
742 // -------------------------------------------------------------------------
othersUpdatesAreVisible(sal_Int32)743 sal_Bool SAL_CALL MacabDatabaseMetaData::othersUpdatesAreVisible( sal_Int32 ) throw(SQLException, RuntimeException)
744 {
745 	return sal_False;
746 }
747 // -------------------------------------------------------------------------
othersDeletesAreVisible(sal_Int32)748 sal_Bool SAL_CALL MacabDatabaseMetaData::othersDeletesAreVisible( sal_Int32 ) throw(SQLException, RuntimeException)
749 {
750 	return sal_False;
751 }
752 // -------------------------------------------------------------------------
othersInsertsAreVisible(sal_Int32)753 sal_Bool SAL_CALL MacabDatabaseMetaData::othersInsertsAreVisible( sal_Int32 ) throw(SQLException, RuntimeException)
754 {
755 	return sal_False;
756 }
757 // -------------------------------------------------------------------------
updatesAreDetected(sal_Int32)758 sal_Bool SAL_CALL MacabDatabaseMetaData::updatesAreDetected( sal_Int32 ) throw(SQLException, RuntimeException)
759 {
760 	return sal_False;
761 }
762 // -------------------------------------------------------------------------
deletesAreDetected(sal_Int32)763 sal_Bool SAL_CALL MacabDatabaseMetaData::deletesAreDetected( sal_Int32 ) throw(SQLException, RuntimeException)
764 {
765 	return sal_False;
766 }
767 // -------------------------------------------------------------------------
insertsAreDetected(sal_Int32)768 sal_Bool SAL_CALL MacabDatabaseMetaData::insertsAreDetected( sal_Int32 ) throw(SQLException, RuntimeException)
769 {
770 	return sal_False;
771 }
772 // -------------------------------------------------------------------------
supportsBatchUpdates()773 sal_Bool SAL_CALL MacabDatabaseMetaData::supportsBatchUpdates(  ) throw(SQLException, RuntimeException)
774 {
775 	return sal_False;
776 }
777 // -------------------------------------------------------------------------
getConnection()778 Reference< XConnection > SAL_CALL MacabDatabaseMetaData::getConnection(  ) throw(SQLException, RuntimeException)
779 {
780 	return (Reference< XConnection >) m_xConnection.get();
781 }
782 // -------------------------------------------------------------------------
getTableTypes()783 Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getTableTypes(  ) throw(SQLException, RuntimeException)
784 {
785 	::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTableTypes);
786 	Reference< XResultSet > xRef = pResult;
787 
788 	static ODatabaseMetaDataResultSet::ORows aRows;
789 	static const ::rtl::OUString aTable(::rtl::OUString::createFromAscii("TABLE"));
790 
791 	if (aRows.empty())
792 	{
793 		ODatabaseMetaDataResultSet::ORow aRow(2);
794 		aRow[0] = ODatabaseMetaDataResultSet::getEmptyValue();
795 		aRow[1] = new ORowSetValueDecorator(aTable);
796 		aRows.push_back(aRow);
797 	}
798 	pResult->setRows(aRows);
799 	return xRef;
800 }
801 // -------------------------------------------------------------------------
getTypeInfo()802 Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getTypeInfo(  ) throw(SQLException, RuntimeException)
803 {
804 	ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTypeInfo);
805 	Reference< XResultSet > xRef = pResult;
806 
807 	static ODatabaseMetaDataResultSet::ORows aRows;
808 	if (aRows.empty())
809 	{
810 		ODatabaseMetaDataResultSet::ORow aRow(19);
811 
812 		// We support four types: char, timestamp, integer, float
813 		aRow[0] = ODatabaseMetaDataResultSet::getEmptyValue();
814 		aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("CHAR"));
815 		aRow[2] = new ORowSetValueDecorator(DataType::CHAR);
816 		aRow[3] = new ORowSetValueDecorator((sal_Int32) 254);
817 		aRow[4] = ODatabaseMetaDataResultSet::getQuoteValue();
818 		aRow[5] = ODatabaseMetaDataResultSet::getQuoteValue();
819 		aRow[6] = ODatabaseMetaDataResultSet::getEmptyValue();
820 		aRow[7] = new ORowSetValueDecorator((sal_Int32) ColumnValue::NULLABLE);
821 		aRow[8] = ODatabaseMetaDataResultSet::get1Value();
822 		aRow[9] = new ORowSetValueDecorator((sal_Int32) ColumnSearch::CHAR);
823 		aRow[10] = ODatabaseMetaDataResultSet::get1Value();
824 		aRow[11] = ODatabaseMetaDataResultSet::get0Value();
825 		aRow[12] = ODatabaseMetaDataResultSet::get0Value();
826 		aRow[13] = ODatabaseMetaDataResultSet::getEmptyValue();
827 		aRow[14] = ODatabaseMetaDataResultSet::get0Value();
828 		aRow[15] = ODatabaseMetaDataResultSet::get0Value();
829 		aRow[16] = ODatabaseMetaDataResultSet::getEmptyValue();
830 		aRow[17] = ODatabaseMetaDataResultSet::getEmptyValue();
831 		aRow[18] = new ORowSetValueDecorator((sal_Int32) 10);
832 
833 		aRows.push_back(aRow);
834 
835 		aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("TIMESTAMP"));
836 		aRow[2] = new ORowSetValueDecorator(DataType::TIMESTAMP);
837 		aRow[3] = new ORowSetValueDecorator((sal_Int32)19);
838 		aRow[4] = ODatabaseMetaDataResultSet::getQuoteValue();
839 		aRow[5] = ODatabaseMetaDataResultSet::getQuoteValue();
840 		aRows.push_back(aRow);
841 
842 		aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("INTEGER"));
843 		aRow[2] = new ORowSetValueDecorator(DataType::INTEGER);
844 		aRow[3] = new ORowSetValueDecorator((sal_Int32)20);
845 		aRow[15] = new ORowSetValueDecorator((sal_Int32)20);
846 		aRows.push_back(aRow);
847 
848 		aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("FLOAT"));
849 		aRow[2] = new ORowSetValueDecorator(DataType::FLOAT);
850 		aRow[3] = new ORowSetValueDecorator((sal_Int32)20);
851 		aRow[15] = new ORowSetValueDecorator((sal_Int32)15);
852 		aRows.push_back(aRow);
853 	}
854 	pResult->setRows(aRows);
855 	return xRef;
856 }
857 // -------------------------------------------------------------------------
getCatalogs()858 Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getCatalogs(  ) throw(SQLException, RuntimeException)
859 {
860     return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eCatalogs );
861 }
862 // -----------------------------------------------------------------------------
getSchemas()863 Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getSchemas(  ) throw(SQLException, RuntimeException)
864 {
865     return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eSchemas );
866 }
867 // -------------------------------------------------------------------------
getColumnPrivileges(const Any &,const::rtl::OUString &,const::rtl::OUString &,const::rtl::OUString &)868 Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getColumnPrivileges(
869 	const Any&, const ::rtl::OUString&, const ::rtl::OUString&,
870 	const ::rtl::OUString& ) throw(SQLException, RuntimeException)
871 {
872     return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eColumnPrivileges );
873 }
874 // -------------------------------------------------------------------------
getColumns(const Any &,const::rtl::OUString &,const::rtl::OUString & tableNamePattern,const::rtl::OUString & columnNamePattern)875 Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getColumns(
876 	const Any&,
877 	const ::rtl::OUString&,
878 	const ::rtl::OUString& tableNamePattern,
879 	const ::rtl::OUString& columnNamePattern) throw(SQLException, RuntimeException)
880 {
881 	::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eColumns);
882 	Reference< XResultSet > xRef = pResult;
883 	MacabRecords *aRecords;
884 	::rtl::OUString sTableName;
885 
886 	aRecords = m_xConnection->getAddressBook()->getMacabRecordsMatch(tableNamePattern);
887 
888 	ODatabaseMetaDataResultSet::ORows aRows;
889 	if(aRecords != NULL)
890 	{
891 		MacabHeader *aHeader = aRecords->getHeader();
892 		sTableName = aRecords->getName();
893 
894 		ODatabaseMetaDataResultSet::ORow aRow(19);
895 
896 		aRow[0] = ODatabaseMetaDataResultSet::getEmptyValue();
897 		aRow[1] = ODatabaseMetaDataResultSet::getEmptyValue();
898 		aRow[2] = ODatabaseMetaDataResultSet::getEmptyValue();
899 		aRow[3] = new ORowSetValueDecorator(sTableName);
900 		aRow[8] = ODatabaseMetaDataResultSet::getEmptyValue();
901 		aRow[9] = ODatabaseMetaDataResultSet::get0Value();
902 		aRow[10] = new ORowSetValueDecorator((sal_Int32) 10);
903 		aRow[11] = ODatabaseMetaDataResultSet::get1Value();
904 		aRow[12] = ODatabaseMetaDataResultSet::getEmptyValue();
905 		aRow[13] = ODatabaseMetaDataResultSet::getEmptyValue();
906 		aRow[14] = ODatabaseMetaDataResultSet::getEmptyValue();
907 		aRow[15] = ODatabaseMetaDataResultSet::getEmptyValue();
908 		aRow[16] = new ORowSetValueDecorator((sal_Int32) 254);
909 		aRow[18] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("YES"));
910 
911 		sal_Int32 nPosition = 1;
912 		::rtl::OUString sName;
913 
914 		MacabHeader::iterator aField;
915 
916 		for (	aField = aHeader->begin();
917 				aField != aHeader->end();
918 				++aField, ++nPosition)
919 		{
920 
921 			sName = CFStringToOUString((CFStringRef) (*aField)->value);
922 			if (match(columnNamePattern, sName, '\0'))
923 			{
924 				aRow[4] = new ORowSetValueDecorator(sName);
925 				aRow[17] = new ORowSetValueDecorator(nPosition);
926 				switch((*aField)->type)
927 				{
928 					case kABStringProperty:
929 						aRow[5] = new ORowSetValueDecorator(DataType::CHAR);
930 						aRow[6] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("CHAR"));
931 						aRow[7] = new ORowSetValueDecorator((sal_Int32) 256);
932 						aRows.push_back(aRow);
933 						break;
934 					case kABDateProperty:
935 						aRow[5] = new ORowSetValueDecorator(DataType::TIMESTAMP);
936 						aRow[6] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("TIMESTAMP"));
937 						aRows.push_back(aRow);
938 						break;
939 					case kABIntegerProperty:
940 						aRow[5] = new ORowSetValueDecorator(DataType::INTEGER);
941 						aRow[6] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("INTEGER"));
942 						aRow[7] = new ORowSetValueDecorator((sal_Int32) 20);
943 						aRows.push_back(aRow);
944 						break;
945 					case kABRealProperty:
946 						aRow[5] = new ORowSetValueDecorator(DataType::FLOAT);
947 						aRow[6] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("FLOAT"));
948 						aRow[7] = new ORowSetValueDecorator((sal_Int32) 15);
949 						aRows.push_back(aRow);
950 						break;
951 					default:
952 						;
953 						// shouldn't happen -- throw an error...?
954 				}
955 			}
956 		}
957 	}
958 	pResult->setRows(aRows);
959 	return xRef;
960 }
961 // -------------------------------------------------------------------------
getTables(const Any &,const::rtl::OUString &,const::rtl::OUString &,const Sequence<::rtl::OUString> & types)962 Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getTables(
963 	const Any&,
964 	const ::rtl::OUString&,
965 	const ::rtl::OUString&,
966 	const Sequence< ::rtl::OUString >& types) throw(SQLException, RuntimeException)
967 {
968 	ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTables);
969 	Reference< XResultSet > xRef = pResult;
970 
971 	// check whether we have tables in the requested types
972 	// for the moment, we answer only the "TABLE" table type
973 	// when no types are given at all, we return all the tables
974 	static const ::rtl::OUString aTable(::rtl::OUString::createFromAscii("TABLE"));
975 	sal_Bool bTableFound = sal_False;
976 	const ::rtl::OUString* p = types.getConstArray(),
977 	                     * pEnd = p + types.getLength();
978 
979 	if (p == pEnd)
980 	{
981 		bTableFound = sal_True;
982 	}
983 	else while (p < pEnd)
984 	{
985 		if (match(*p, aTable, '\0'))
986 		{
987 			bTableFound = sal_True;
988 			break;
989 		}
990 		p++;
991 	}
992 	if (!bTableFound)
993 		return xRef;
994 
995 	static ODatabaseMetaDataResultSet::ORows aRows;
996 
997 	if (aRows.empty())
998 	{
999 		ODatabaseMetaDataResultSet::ORow aRow(6);
1000 
1001 		MacabRecords *xRecords = m_xConnection->getAddressBook()->getMacabRecords();
1002 		::std::vector<MacabGroup *> xGroups = m_xConnection->getAddressBook()->getMacabGroups();
1003 		sal_Int32 i, nGroups;
1004 		nGroups = xGroups.size();
1005 
1006 		aRow[0] = ODatabaseMetaDataResultSet::getEmptyValue();
1007 		aRow[1] = ODatabaseMetaDataResultSet::getEmptyValue();
1008 		aRow[2] = ODatabaseMetaDataResultSet::getEmptyValue();
1009 		aRow[3] = new ORowSetValueDecorator(xRecords->getName());
1010 		aRow[4] = new ORowSetValueDecorator(aTable);
1011 		aRow[5] = ODatabaseMetaDataResultSet::getEmptyValue();
1012 		aRows.push_back(aRow);
1013 
1014 		for(i = 0; i < nGroups; i++)
1015 		{
1016 			aRow[3] = new ORowSetValueDecorator(xGroups[i]->getName());
1017 			aRows.push_back(aRow);
1018 		}
1019 	}
1020 	pResult->setRows(aRows);
1021 	return xRef;
1022 }
1023 // -------------------------------------------------------------------------
getProcedureColumns(const Any &,const::rtl::OUString &,const::rtl::OUString &,const::rtl::OUString &)1024 Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getProcedureColumns(
1025 	const Any&, const ::rtl::OUString&,
1026 	const ::rtl::OUString&, const ::rtl::OUString& ) throw(SQLException, RuntimeException)
1027 {
1028     return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eProcedureColumns );
1029 }
1030 // -------------------------------------------------------------------------
getProcedures(const Any &,const::rtl::OUString &,const::rtl::OUString &)1031 Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getProcedures(
1032 	const Any&, const ::rtl::OUString&,
1033 	const ::rtl::OUString& ) throw(SQLException, RuntimeException)
1034 {
1035     return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eProcedures );
1036 }
1037 // -------------------------------------------------------------------------
getVersionColumns(const Any &,const::rtl::OUString &,const::rtl::OUString & table)1038 Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getVersionColumns(
1039 	const Any&, const ::rtl::OUString&, const ::rtl::OUString& table ) throw(SQLException, RuntimeException)
1040 {
1041     return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eVersionColumns );
1042 
1043 	::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eVersionColumns);
1044 	Reference< XResultSet > xRef = pResult;
1045 
1046 	ODatabaseMetaDataResultSet::ORows aRows;
1047 
1048 	if (m_xConnection->getAddressBook()->getMacabRecords(table) != NULL)
1049 	{
1050 		ODatabaseMetaDataResultSet::ORow aRow( 9 );
1051 
1052 		::rtl::OUString sName = CFStringToOUString(kABModificationDateProperty);
1053 
1054 		aRow[0] = ODatabaseMetaDataResultSet::getEmptyValue();
1055 		aRow[1] = ODatabaseMetaDataResultSet::getEmptyValue();
1056 		aRow[2] = new ORowSetValueDecorator(sName);
1057 		aRow[3] = new ORowSetValueDecorator(DataType::TIMESTAMP);
1058 		aRow[4] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("TIMESTAMP"));
1059 
1060 		aRow[5] = ODatabaseMetaDataResultSet::getEmptyValue();
1061 		aRow[6] = ODatabaseMetaDataResultSet::getEmptyValue();
1062 		aRow[7] = ODatabaseMetaDataResultSet::getEmptyValue();
1063 		aRow[8] = ODatabaseMetaDataResultSet::getEmptyValue();
1064 
1065 		aRows.push_back(aRow);
1066 	}
1067 	pResult->setRows(aRows);
1068 	return xRef;
1069 }
1070 // -------------------------------------------------------------------------
getExportedKeys(const Any &,const::rtl::OUString &,const::rtl::OUString &)1071 Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getExportedKeys(
1072 	const Any&, const ::rtl::OUString&, const ::rtl::OUString& ) throw(SQLException, RuntimeException)
1073 {
1074     return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eExportedKeys );
1075 }
1076 // -------------------------------------------------------------------------
getImportedKeys(const Any &,const::rtl::OUString &,const::rtl::OUString &)1077 Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getImportedKeys(
1078 	const Any&, const ::rtl::OUString&, const ::rtl::OUString& ) throw(SQLException, RuntimeException)
1079 {
1080     return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eImportedKeys );
1081 }
1082 // -------------------------------------------------------------------------
getPrimaryKeys(const Any &,const::rtl::OUString &,const::rtl::OUString &)1083 Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getPrimaryKeys(
1084 	const Any&, const ::rtl::OUString&, const ::rtl::OUString& ) throw(SQLException, RuntimeException)
1085 {
1086     return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::ePrimaryKeys );
1087 }
1088 // -------------------------------------------------------------------------
getIndexInfo(const Any &,const::rtl::OUString &,const::rtl::OUString &,sal_Bool,sal_Bool)1089 Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getIndexInfo(
1090 	const Any&, const ::rtl::OUString&, const ::rtl::OUString&,
1091 	sal_Bool, sal_Bool ) throw(SQLException, RuntimeException)
1092 {
1093     return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eIndexInfo );
1094 }
1095 // -------------------------------------------------------------------------
getBestRowIdentifier(const Any &,const::rtl::OUString &,const::rtl::OUString &,sal_Int32,sal_Bool)1096 Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getBestRowIdentifier(
1097 	const Any&, const ::rtl::OUString&, const ::rtl::OUString&, sal_Int32,
1098 	sal_Bool ) throw(SQLException, RuntimeException)
1099 {
1100     return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eBestRowIdentifier );
1101 }
1102 // -------------------------------------------------------------------------
getTablePrivileges(const Any &,const::rtl::OUString &,const::rtl::OUString &)1103 Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getTablePrivileges(
1104 	const Any&, const ::rtl::OUString&, const ::rtl::OUString& ) throw(SQLException, RuntimeException)
1105 {
1106     return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eTablePrivileges );
1107 }
1108 // -------------------------------------------------------------------------
getCrossReference(const Any &,const::rtl::OUString &,const::rtl::OUString &,const Any &,const::rtl::OUString &,const::rtl::OUString &)1109 Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getCrossReference(
1110 	const Any&, const ::rtl::OUString&,
1111 	const ::rtl::OUString&, const Any&,
1112 	const ::rtl::OUString&, const ::rtl::OUString& ) throw(SQLException, RuntimeException)
1113 {
1114     return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eCrossReference );
1115 }
1116 // -------------------------------------------------------------------------
getUDTs(const Any &,const::rtl::OUString &,const::rtl::OUString &,const Sequence<sal_Int32> &)1117 Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getUDTs( const Any&, const ::rtl::OUString&, const ::rtl::OUString&, const Sequence< sal_Int32 >& ) throw(SQLException, RuntimeException)
1118 {
1119 	OSL_ENSURE(0,"Not implemented yet!");
1120 	throw SQLException();
1121 }
1122 // -----------------------------------------------------------------------------
1123