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