1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_connectivity.hxx"
30 
31 
32 #include "calc/CDatabaseMetaData.hxx"
33 #include "calc/CConnection.hxx"
34 #include <com/sun/star/sdbc/DataType.hpp>
35 #include <com/sun/star/sdbc/ResultSetType.hpp>
36 #include <com/sun/star/sdbc/ColumnValue.hpp>
37 #include <com/sun/star/beans/XPropertySet.hpp>
38 #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
39 #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
40 #include <com/sun/star/sdbcx/XIndexesSupplier.hpp>
41 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
42 #include <com/sun/star/sheet/XSpreadsheet.hpp>
43 #include <com/sun/star/sheet/XCellRangesQuery.hpp>
44 #include <com/sun/star/sheet/XCellRangeAddressable.hpp>
45 #include <com/sun/star/sheet/XDatabaseRanges.hpp>
46 #include <com/sun/star/sheet/XDatabaseRange.hpp>
47 #include <tools/urlobj.hxx>
48 #include "FDatabaseMetaDataResultSet.hxx"
49 #include <com/sun/star/lang/XUnoTunnel.hpp>
50 #include <comphelper/types.hxx>
51 #include <rtl/logfile.hxx>
52 
53 using namespace connectivity::calc;
54 using namespace connectivity::file;
55 using namespace ::com::sun::star::uno;
56 using namespace ::com::sun::star::beans;
57 using namespace ::com::sun::star::sdbcx;
58 using namespace ::com::sun::star::sdbc;
59 using namespace ::com::sun::star::container;
60 using namespace ::com::sun::star::table;
61 using namespace ::com::sun::star::sheet;
62 
63 // -------------------------------------------------------------------------
64 
65 OCalcDatabaseMetaData::OCalcDatabaseMetaData(OConnection* _pCon) 	:ODatabaseMetaData(_pCon)
66 {
67     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcDatabaseMetaData::OCalcDatabaseMetaData" );
68 }
69 
70 // -------------------------------------------------------------------------
71 
72 OCalcDatabaseMetaData::~OCalcDatabaseMetaData()
73 {
74 }
75 
76 // -------------------------------------------------------------------------
77 Reference< XResultSet > OCalcDatabaseMetaData::impl_getTypeInfo_throw(  )
78 {
79     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcDatabaseMetaData::impl_getTypeInfo_throw" );
80 	::osl::MutexGuard aGuard( m_aMutex );
81 
82 	ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTypeInfo);
83     Reference< XResultSet > xRef = pResult;
84 
85 	static ODatabaseMetaDataResultSet::ORows aRows;
86 	if(aRows.empty())
87 	{
88 		ODatabaseMetaDataResultSet::ORow aRow;
89 
90 		aRows.reserve(6);
91 		aRow.reserve(18);
92 
93 		aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
94 		aRow.push_back(new ORowSetValueDecorator(::rtl::OUString::createFromAscii("VARCHAR")));
95 		aRow.push_back(new ORowSetValueDecorator(DataType::VARCHAR));
96 		aRow.push_back(new ORowSetValueDecorator((sal_Int32)65535));
97 		aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue());
98 		aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue());
99 		aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
100 		aRow.push_back(ODatabaseMetaDataResultSet::get1Value()); // ORowSetValue((sal_Int32)ColumnValue::NULLABLE)
101 		aRow.push_back(ODatabaseMetaDataResultSet::get1Value());
102 		aRow.push_back(new ORowSetValueDecorator((sal_Int32)ColumnSearch::CHAR));
103 		aRow.push_back(ODatabaseMetaDataResultSet::get1Value());
104 		aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
105 		aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
106 		aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
107 		aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
108 		aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
109 		aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
110 		aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
111 		aRow.push_back(new ORowSetValueDecorator((sal_Int32)10));
112 
113 
114 		aRows.push_back(aRow);
115 
116 		aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("DECIMAL"));
117 		aRow[2] = new ORowSetValueDecorator(DataType::DECIMAL);
118 		aRow[3] = ODatabaseMetaDataResultSet::get0Value();
119 		aRow[9] = ODatabaseMetaDataResultSet::getBasicValue();
120 		aRow[15] = ODatabaseMetaDataResultSet::get0Value();
121 		aRows.push_back(aRow);
122 
123 		aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("BOOL"));
124 		aRow[2] = new ORowSetValueDecorator(DataType::BIT);
125 		aRow[3] = new ORowSetValueDecorator((sal_Int32)20);
126 		aRow[9] = ODatabaseMetaDataResultSet::getBasicValue();
127 		aRow[15] = new ORowSetValueDecorator((sal_Int32)15);
128 		aRows.push_back(aRow);
129 
130 		aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("DATE"));
131 		aRow[2] = new ORowSetValueDecorator(DataType::DATE);
132 		aRow[3] = ODatabaseMetaDataResultSet::get0Value();
133 		aRow[9] = ODatabaseMetaDataResultSet::getBasicValue();
134 		aRow[15] = ODatabaseMetaDataResultSet::get0Value();
135 		aRows.push_back(aRow);
136 
137 		aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("TIME"));
138 		aRow[2] = new ORowSetValueDecorator(DataType::TIME);
139 		aRow[3] = ODatabaseMetaDataResultSet::get0Value();
140 		aRow[9] = ODatabaseMetaDataResultSet::getBasicValue();
141 		aRow[15] = ODatabaseMetaDataResultSet::get0Value();
142 		aRows.push_back(aRow);
143 
144 		aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("TIMESTAMP"));
145 		aRow[2] = new ORowSetValueDecorator(DataType::TIMESTAMP);
146 		aRow[3] = ODatabaseMetaDataResultSet::get0Value();
147 		aRow[9] = ODatabaseMetaDataResultSet::getBasicValue();
148 		aRow[15] = ODatabaseMetaDataResultSet::get0Value();
149 		aRows.push_back(aRow);
150 	}
151 
152 	pResult->setRows(aRows);
153 	return xRef;
154 }
155 
156 // -------------------------------------------------------------------------
157 
158 Reference< XResultSet > SAL_CALL OCalcDatabaseMetaData::getColumns(
159 	const Any& /*catalog*/, const ::rtl::OUString& /*schemaPattern*/, const ::rtl::OUString& tableNamePattern,
160         const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException)
161 {
162     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcDatabaseMetaData::getColumns" );
163 	::osl::MutexGuard aGuard( m_aMutex );
164 
165 
166     Reference< XTablesSupplier > xTables = m_pConnection->createCatalog();
167 	if(!xTables.is())
168         throw SQLException();
169 
170 	Reference< XNameAccess> xNames = xTables->getTables();
171 	if(!xNames.is())
172         throw SQLException();
173 
174 	ODatabaseMetaDataResultSet::ORows aRows;
175 	ODatabaseMetaDataResultSet::ORow  aRow(19);
176 
177 	aRow[10] = new ORowSetValueDecorator((sal_Int32)10);
178 
179 	Sequence< ::rtl::OUString> aTabNames(xNames->getElementNames());
180 	const ::rtl::OUString* pTabIter	= aTabNames.getConstArray();
181 	const ::rtl::OUString* pTabEnd		= pTabIter + aTabNames.getLength();
182 	for(;pTabIter != pTabEnd;++pTabIter)
183 	{
184 		if(match(tableNamePattern,*pTabIter,'\0'))
185 		{
186 			const Reference< XColumnsSupplier> xTable(xNames->getByName(*pTabIter),UNO_QUERY_THROW);
187 			OSL_ENSURE(xTable.is(),"Table not found! Normallya exception had to be thrown here!");
188 			aRow[3] = new ORowSetValueDecorator(*pTabIter);
189 
190 			const Reference< XNameAccess> xColumns = xTable->getColumns();
191 			if(!xColumns.is())
192                 throw SQLException();
193 
194 			const Sequence< ::rtl::OUString> aColNames(xColumns->getElementNames());
195 
196 			const ::rtl::OUString* pColumnIter = aColNames.getConstArray();
197 			const ::rtl::OUString* pEnd = pColumnIter + aColNames.getLength();
198 			Reference< XPropertySet> xColumn;
199 			for(sal_Int32 i=1;pColumnIter != pEnd;++pColumnIter,++i)
200 			{
201 				if(match(columnNamePattern,*pColumnIter,'\0'))
202 				{
203 					aRow[4]  = new ORowSetValueDecorator( *pColumnIter);
204 
205 					xColumns->getByName(*pColumnIter) >>= xColumn;
206 					OSL_ENSURE(xColumn.is(),"Columns contains a column who isn't a fastpropertyset!");
207 					aRow[5] = new ORowSetValueDecorator(::comphelper::getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE))));
208 					aRow[6] = new ORowSetValueDecorator(::comphelper::getString(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME))));
209 					aRow[7] = new ORowSetValueDecorator(::comphelper::getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION))));
210 					//	aRow[8] = xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME));
211 					aRow[9] = new ORowSetValueDecorator(::comphelper::getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE))));
212 					aRow[11] = new ORowSetValueDecorator(::comphelper::getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE))));
213 					//	aRow[12] = xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME));
214 					aRow[13] = new ORowSetValueDecorator(::comphelper::getString(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE))));
215 					//	aRow[14] = xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME));
216 					//	aRow[15] = xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME));
217 					switch(sal_Int32(aRow[5]->getValue()))
218 					{
219 					case DataType::CHAR:
220 					case DataType::VARCHAR:
221 						aRow[16] = new ORowSetValueDecorator((sal_Int32)254);
222 						break;
223 					case DataType::LONGVARCHAR:
224 						aRow[16] = new ORowSetValueDecorator((sal_Int32)65535);
225 						break;
226 					default:
227 						aRow[16] = new ORowSetValueDecorator((sal_Int32)0);
228 					}
229 					aRow[17] = new ORowSetValueDecorator(i);
230 					switch(sal_Int32(aRow[11]->getValue()))
231 					{
232 					case ColumnValue::NO_NULLS:
233 						aRow[18]  = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("NO"));
234 						break;
235 					case ColumnValue::NULLABLE:
236 						aRow[18]  = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("YES"));
237 						break;
238 					default:
239 						aRow[18]  = new ORowSetValueDecorator(::rtl::OUString());
240 					}
241 					aRows.push_back(aRow);
242 				}
243 			}
244 		}
245 	}
246 
247 	ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eColumns);
248     Reference< XResultSet > xRef = pResult;
249 	pResult->setRows(aRows);
250 
251 	return xRef;
252 }
253 
254 // -------------------------------------------------------------------------
255 
256 ::rtl::OUString SAL_CALL OCalcDatabaseMetaData::getURL(  ) throw(SQLException, RuntimeException)
257 {
258     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcDatabaseMetaData::getURL" );
259 	::osl::MutexGuard aGuard( m_aMutex );
260 
261 	return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:calc:")) + m_pConnection->getURL();
262 }
263 
264 // -------------------------------------------------------------------------
265 
266 sal_Int32 SAL_CALL OCalcDatabaseMetaData::getMaxBinaryLiteralLength(  ) throw(SQLException, RuntimeException)
267 {
268     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcDatabaseMetaData::getMaxBinaryLiteralLength" );
269 	return STRING_MAXLEN;
270 }
271 
272 // -------------------------------------------------------------------------
273 
274 sal_Int32 SAL_CALL OCalcDatabaseMetaData::getMaxCharLiteralLength(  ) throw(SQLException, RuntimeException)
275 {
276     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcDatabaseMetaData::getMaxCharLiteralLength" );
277 	return STRING_MAXLEN;
278 }
279 // -------------------------------------------------------------------------
280 sal_Int32 SAL_CALL OCalcDatabaseMetaData::getMaxColumnNameLength(  ) throw(SQLException, RuntimeException)
281 {
282     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcDatabaseMetaData::getMaxColumnNameLength" );
283 	return STRING_MAXLEN;
284 }
285 // -------------------------------------------------------------------------
286 sal_Int32 SAL_CALL OCalcDatabaseMetaData::getMaxColumnsInIndex(  ) throw(SQLException, RuntimeException)
287 {
288     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcDatabaseMetaData::getMaxColumnsInIndex" );
289 	return 1;
290 }
291 // -------------------------------------------------------------------------
292 sal_Int32 SAL_CALL OCalcDatabaseMetaData::getMaxColumnsInTable(  ) throw(SQLException, RuntimeException)
293 {
294     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcDatabaseMetaData::getMaxColumnsInTable" );
295 	return 256;
296 }
297 
298 // -------------------------------------------------------------------------
299 
300 sal_Bool lcl_IsEmptyOrHidden( const Reference<XSpreadsheets>& xSheets, const ::rtl::OUString& rName )
301 {
302 	Any aAny = xSheets->getByName( rName );
303 	Reference<XSpreadsheet> xSheet;
304 	if ( aAny >>= xSheet )
305 	{
306 		//	test if sheet is hidden
307 
308 		Reference<XPropertySet> xProp( xSheet, UNO_QUERY );
309 		if (xProp.is())
310 		{
311 			sal_Bool bVisible = sal_Bool();
312 			Any aVisAny = xProp->getPropertyValue( ::rtl::OUString::createFromAscii("IsVisible") );
313 			if ( aVisAny >>= bVisible )
314 				if (!bVisible)
315 					return sal_True;				// hidden
316 		}
317 
318 #if 0
319 		//	test if whole sheet is empty
320 
321 		Reference<XCellRangeAddressable> xAddr( xSheet, UNO_QUERY );
322 		Reference<XCellRangesQuery> xQuery( xSheet, UNO_QUERY );
323 		if ( xAddr.is() && xQuery.is() )
324 		{
325 			CellRangeAddress aTotalRange = xAddr->getRangeAddress();
326 			// queryIntersection to get a ranges object
327 			Reference<XSheetCellRanges> xRanges = xQuery->queryIntersection( aTotalRange );
328 			if (xRanges.is())
329 			{
330 				Reference<XEnumerationAccess> xCells = xRanges->getCells();
331 				if (xCells.is())
332 				{
333 					if ( !xCells->hasElements() )
334 						return sal_True;			// empty
335 				}
336 			}
337 		}
338 #endif
339 
340 		//	use the same data area as in OCalcTable to test for empty table
341 
342 		Reference<XSheetCellCursor> xCursor = xSheet->createCursor();
343 		Reference<XCellRangeAddressable> xRange( xCursor, UNO_QUERY );
344 		if ( xRange.is() )
345 		{
346 			xCursor->collapseToSize( 1, 1 );		// single (first) cell
347 			xCursor->collapseToCurrentRegion();		// contiguous data area
348 
349 			CellRangeAddress aRangeAddr = xRange->getRangeAddress();
350 			if ( aRangeAddr.StartColumn == aRangeAddr.EndColumn &&
351 				 aRangeAddr.StartRow == aRangeAddr.EndRow )
352 			{
353 				//	single cell -> check content
354 				Reference<XCell> xCell = xCursor->getCellByPosition( 0, 0 );
355 				if ( xCell.is() && xCell->getType() == CellContentType_EMPTY )
356 					return sal_True;
357 			}
358 		}
359 	}
360 
361 	return sal_False;
362 }
363 
364 sal_Bool lcl_IsUnnamed( const Reference<XDatabaseRanges>& xRanges, const ::rtl::OUString& rName )
365 {
366 	sal_Bool bUnnamed = sal_False;
367 
368 	Any aAny = xRanges->getByName( rName );
369 	Reference<XDatabaseRange> xRange;
370 	if ( aAny >>= xRange )
371 	{
372 		Reference<XPropertySet> xRangeProp( xRange, UNO_QUERY );
373 		if ( xRangeProp.is() )
374 		{
375 			try
376 			{
377 				Any aUserAny = xRangeProp->getPropertyValue( ::rtl::OUString::createFromAscii("IsUserDefined") );
378 				sal_Bool bUserDefined = sal_Bool();
379 				if ( aUserAny >>= bUserDefined )
380 					bUnnamed = !bUserDefined;
381 			}
382 			catch ( UnknownPropertyException& )
383 			{
384 				// optional property
385 			}
386 		}
387 	}
388 
389 	return bUnnamed;
390 }
391 
392 // -------------------------------------------------------------------------
393 
394 Reference< XResultSet > SAL_CALL OCalcDatabaseMetaData::getTables(
395         const Any& /*catalog*/, const ::rtl::OUString& /*schemaPattern*/,
396         const ::rtl::OUString& tableNamePattern, const Sequence< ::rtl::OUString >& types )
397         throw(SQLException, RuntimeException)
398 {
399     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcDatabaseMetaData::getTables" );
400 	::osl::MutexGuard aGuard( m_aMutex );
401 
402     ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTables);
403     Reference< XResultSet > xRef = pResult;
404 
405 	// check if ORowSetValue type is given
406 	// when no types are given then we have to return all tables e.g. TABLE
407 
408 	::rtl::OUString aTable(::rtl::OUString::createFromAscii("TABLE"));
409 
410 	sal_Bool bTableFound = sal_True;
411 	sal_Int32 nLength = types.getLength();
412 	if(nLength)
413 	{
414 		bTableFound = sal_False;
415 
416 		const ::rtl::OUString* pIter = types.getConstArray();
417 		const ::rtl::OUString* pEnd	= pIter + nLength;
418 		for(;pIter != pEnd;++pIter)
419 		{
420 			if(*pIter == aTable)
421 			{
422 				bTableFound = sal_True;
423 				break;
424 			}
425 		}
426 	}
427 	if(!bTableFound)
428 		return xRef;
429 
430 	// get the sheet names from the document
431 
432     OCalcConnection::ODocHolder aDocHodler(((OCalcConnection*)m_pConnection));
433 	Reference<XSpreadsheetDocument> xDoc = aDocHodler.getDoc();
434 	if ( !xDoc.is() )
435 		throw SQLException();
436 	Reference<XSpreadsheets> xSheets = xDoc->getSheets();
437 	if ( !xSheets.is() )
438 		throw SQLException();
439 	Sequence< ::rtl::OUString > aSheetNames = xSheets->getElementNames();
440 
441 	ODatabaseMetaDataResultSet::ORows aRows;
442 	sal_Int32 nSheetCount = aSheetNames.getLength();
443 	for (sal_Int32 nSheet=0; nSheet<nSheetCount; nSheet++)
444 	{
445 		::rtl::OUString aName = aSheetNames[nSheet];
446 		if ( !lcl_IsEmptyOrHidden( xSheets, aName ) && match(tableNamePattern,aName,'\0') )
447 		{
448 			ODatabaseMetaDataResultSet::ORow aRow(3);
449 			aRow.reserve(6);
450 			aRow.push_back(new ORowSetValueDecorator(aName));
451 			aRow.push_back(new ORowSetValueDecorator(aTable));
452 			aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
453 			aRows.push_back(aRow);
454 		}
455 	}
456 
457 	// also use database ranges
458 
459 	Reference<XPropertySet> xDocProp( xDoc, UNO_QUERY );
460 	if ( xDocProp.is() )
461 	{
462 		Any aRangesAny = xDocProp->getPropertyValue( ::rtl::OUString::createFromAscii("DatabaseRanges") );
463 		Reference<XDatabaseRanges> xRanges;
464 		if ( aRangesAny >>= xRanges )
465 		{
466 			Sequence< ::rtl::OUString > aDBNames = xRanges->getElementNames();
467 			sal_Int32 nDBCount = aDBNames.getLength();
468 			for (sal_Int32 nRange=0; nRange<nDBCount; nRange++)
469 			{
470 				::rtl::OUString aName = aDBNames[nRange];
471 				if ( !lcl_IsUnnamed( xRanges, aName ) && match(tableNamePattern,aName,'\0') )
472 				{
473 					ODatabaseMetaDataResultSet::ORow aRow(3);
474 					aRow.reserve(6);
475 					aRow.push_back(new ORowSetValueDecorator(aName));
476 					aRow.push_back(new ORowSetValueDecorator(aTable));
477 					aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
478 					aRows.push_back(aRow);
479 				}
480 			}
481 		}
482 	}
483 
484 	pResult->setRows(aRows);
485 
486 	return xRef;
487 }
488 // -----------------------------------------------------------------------------
489 
490 
491