LibreOffice Module connectivity (master) 1
calc/CTable.cxx
Go to the documentation of this file.
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/CTable.hxx>
21#include <com/sun/star/sdbc/ColumnValue.hpp>
22#include <com/sun/star/sdbc/DataType.hpp>
23#include <com/sun/star/sdbc/SQLException.hpp>
24#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
25#include <com/sun/star/sheet/XSpreadsheet.hpp>
26#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
27#include <com/sun/star/sheet/XCellRangesQuery.hpp>
28#include <com/sun/star/sheet/XDatabaseRanges.hpp>
29#include <com/sun/star/sheet/XDatabaseRange.hpp>
30#include <com/sun/star/sheet/XCellRangeReferrer.hpp>
31#include <com/sun/star/sheet/XUsedAreaCursor.hpp>
32#include <com/sun/star/sheet/CellFlags.hpp>
33#include <com/sun/star/sheet/FormulaResult.hpp>
34#include <com/sun/star/util/NumberFormat.hpp>
35#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
36#include <com/sun/star/text/XText.hpp>
37#include <calc/CConnection.hxx>
39#include <rtl/ustrbuf.hxx>
40#include <sal/log.hxx>
41#include <rtl/math.hxx>
42#include <tools/time.hxx>
44
45using namespace connectivity;
46using namespace connectivity::calc;
47using namespace connectivity::file;
48using namespace ::cppu;
49using namespace ::dbtools;
50using namespace ::com::sun::star::uno;
51using namespace ::com::sun::star::beans;
52using namespace ::com::sun::star::sdbcx;
53using namespace ::com::sun::star::sdbc;
54using namespace ::com::sun::star::container;
55using namespace ::com::sun::star::lang;
56using namespace ::com::sun::star::sheet;
57using namespace ::com::sun::star::table;
58using namespace ::com::sun::star::text;
59using namespace ::com::sun::star::util;
60
61
62static void lcl_UpdateArea( const Reference<XCellRange>& xUsedRange, sal_Int32& rEndCol, sal_Int32& rEndRow )
63{
64 // update rEndCol, rEndRow if any non-empty cell in xUsedRange is right/below
65
66 const Reference<XCellRangesQuery> xUsedQuery( xUsedRange, UNO_QUERY );
67 if ( !xUsedQuery.is() )
68 return;
69
70 const sal_Int16 nContentFlags =
71 CellFlags::STRING | CellFlags::VALUE | CellFlags::DATETIME | CellFlags::FORMULA | CellFlags::ANNOTATION;
72
73 const Reference<XSheetCellRanges> xUsedRanges = xUsedQuery->queryContentCells( nContentFlags );
74 const Sequence<CellRangeAddress> aAddresses = xUsedRanges->getRangeAddresses();
75
76 const sal_Int32 nCount = aAddresses.getLength();
77 const CellRangeAddress* pData = aAddresses.getConstArray();
78 for ( sal_Int32 i=0; i<nCount; i++ )
79 {
80 rEndCol = std::max(pData[i].EndColumn, rEndCol);
81 rEndRow = std::max(pData[i].EndRow, rEndRow);
82 }
83}
84
85static void lcl_GetDataArea( const Reference<XSpreadsheet>& xSheet, sal_Int32& rColumnCount, sal_Int32& rRowCount )
86{
87 Reference<XSheetCellCursor> xCursor = xSheet->createCursor();
88 Reference<XCellRangeAddressable> xRange( xCursor, UNO_QUERY );
89 if ( !xRange.is() )
90 {
91 rColumnCount = rRowCount = 0;
92 return;
93 }
94
95 // first find the contiguous cell area starting at A1
96
97 xCursor->collapseToSize( 1, 1 ); // single (first) cell
98 xCursor->collapseToCurrentRegion(); // contiguous data area
99
100 CellRangeAddress aRegionAddr = xRange->getRangeAddress();
101 sal_Int32 nEndCol = aRegionAddr.EndColumn;
102 sal_Int32 nEndRow = aRegionAddr.EndRow;
103
104 Reference<XUsedAreaCursor> xUsed( xCursor, UNO_QUERY );
105 if ( xUsed.is() )
106 {
107 // The used area from XUsedAreaCursor includes visible attributes.
108 // If the used area is larger than the contiguous cell area, find non-empty
109 // cells in that area.
110
111 xUsed->gotoEndOfUsedArea( false );
112 CellRangeAddress aUsedAddr = xRange->getRangeAddress();
113
114 if ( aUsedAddr.EndColumn > aRegionAddr.EndColumn )
115 {
116 Reference<XCellRange> xUsedRange = xSheet->getCellRangeByPosition(
117 aRegionAddr.EndColumn + 1, 0, aUsedAddr.EndColumn, aUsedAddr.EndRow );
118 lcl_UpdateArea( xUsedRange, nEndCol, nEndRow );
119 }
120
121 if ( aUsedAddr.EndRow > aRegionAddr.EndRow )
122 {
123 // only up to the last column of aRegionAddr, the other columns are handled above
124 Reference<XCellRange> xUsedRange = xSheet->getCellRangeByPosition(
125 0, aRegionAddr.EndRow + 1, aRegionAddr.EndColumn, aUsedAddr.EndRow );
126 lcl_UpdateArea( xUsedRange, nEndCol, nEndRow );
127 }
128 }
129
130 rColumnCount = nEndCol + 1; // number of columns
131 rRowCount = nEndRow; // first row (headers) is not counted
132}
133
134static CellContentType lcl_GetContentOrResultType( const Reference<XCell>& xCell )
135{
136 CellContentType eCellType = xCell->getType();
137 if ( eCellType == CellContentType_FORMULA )
138 {
139 Reference<XPropertySet> xProp( xCell, UNO_QUERY );
140 try
141 {
142 xProp->getPropertyValue( "CellContentType" ) >>= eCellType; // type of cell content
143 }
144 catch (UnknownPropertyException&)
145 {
146 eCellType = CellContentType_VALUE; // if CellContentType property not available
147 }
148 }
149 return eCellType;
150}
151
152static Reference<XCell> lcl_GetUsedCell( const Reference<XSpreadsheet>& xSheet, sal_Int32 nDocColumn, sal_Int32 nDocRow )
153{
154 Reference<XCell> xCell = xSheet->getCellByPosition( nDocColumn, nDocRow );
155 if ( xCell.is() && xCell->getType() == CellContentType_EMPTY )
156 {
157 // get first non-empty cell
158
159 Reference<XCellRangeAddressable> xAddr( xSheet, UNO_QUERY );
160 if (xAddr.is())
161 {
162 CellRangeAddress aTotalRange = xAddr->getRangeAddress();
163 sal_Int32 nLastRow = aTotalRange.EndRow;
164 Reference<XCellRangesQuery> xQuery( xSheet->getCellRangeByPosition( nDocColumn, nDocRow, nDocColumn, nLastRow ), UNO_QUERY );
165 if (xQuery.is())
166 {
167 // queryIntersection to get a ranges object
168 Reference<XSheetCellRanges> xRanges = xQuery->queryIntersection( aTotalRange );
169 if (xRanges.is())
170 {
171 Reference<XEnumerationAccess> xCells = xRanges->getCells();
172 if (xCells.is())
173 {
174 Reference<XEnumeration> xEnum = xCells->createEnumeration();
175 if ( xEnum.is() && xEnum->hasMoreElements() )
176 {
177 // get first non-empty cell from enumeration
178 xCell.set(xEnum->nextElement(),UNO_QUERY);
179 }
180 // otherwise, keep empty cell
181 }
182 }
183 }
184 }
185 }
186 return xCell;
187}
188
189static bool lcl_HasTextInColumn( const Reference<XSpreadsheet>& xSheet, sal_Int32 nDocColumn, sal_Int32 nDocRow )
190{
191 // look for any text cell or text result in the column
192
193 Reference<XCellRangeAddressable> xAddr( xSheet, UNO_QUERY );
194 if (!xAddr)
195 return false;
196 CellRangeAddress aTotalRange = xAddr->getRangeAddress();
197 sal_Int32 nLastRow = aTotalRange.EndRow;
198 Reference<XCellRangesQuery> xQuery( xSheet->getCellRangeByPosition( nDocColumn, nDocRow, nDocColumn, nLastRow ), UNO_QUERY );
199 if (!xQuery)
200 return false;
201
202 // are there text cells in the column?
203 Reference<XSheetCellRanges> xTextContent = xQuery->queryContentCells( CellFlags::STRING );
204 if ( xTextContent.is() && xTextContent->hasElements() )
205 return true;
206
207 // are there formulas with text results in the column?
208 Reference<XSheetCellRanges> xTextFormula = xQuery->queryFormulaCells( FormulaResult::STRING );
209 if ( xTextFormula.is() && xTextFormula->hasElements() )
210 return true;
211
212 return false;
213}
214
215static void lcl_GetColumnInfo( const Reference<XSpreadsheet>& xSheet, const Reference<XNumberFormats>& xFormats,
216 sal_Int32 nDocColumn, sal_Int32 nStartRow, bool bHasHeaders,
217 OUString& rName, sal_Int32& rDataType, bool& rCurrency )
218{
220
221 // get column name from first row, if range contains headers
222
223 if ( bHasHeaders )
224 {
225 Reference<XText> xHeaderText( xSheet->getCellByPosition( nDocColumn, nStartRow ), UNO_QUERY );
226 if ( xHeaderText.is() )
227 rName = xHeaderText->getString();
228 }
229
230 // get column type from first data row
231
232 sal_Int32 nDataRow = nStartRow;
233 if ( bHasHeaders )
234 ++nDataRow;
235 Reference<XCell> xDataCell = lcl_GetUsedCell( xSheet, nDocColumn, nDataRow );
236
237 Reference<XPropertySet> xProp( xDataCell, UNO_QUERY );
238 if ( !xProp.is() )
239 return;
240
241 rCurrency = false; // set to true for currency below
242
243 const CellContentType eCellType = lcl_GetContentOrResultType( xDataCell );
244 // #i35178# use "text" type if there is any text cell in the column
245 if ( eCellType == CellContentType_TEXT || lcl_HasTextInColumn( xSheet, nDocColumn, nDataRow ) )
246 rDataType = DataType::VARCHAR;
247 else if ( eCellType == CellContentType_VALUE )
248 {
249 // get number format to distinguish between different types
250
251 sal_Int16 nNumType = NumberFormat::NUMBER;
252 try
253 {
254 sal_Int32 nKey = 0;
255
256 if ( xProp->getPropertyValue( "NumberFormat" ) >>= nKey )
257 {
258 const Reference<XPropertySet> xFormat = xFormats->getByKey( nKey );
259 if ( xFormat.is() )
260 {
261 xFormat->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE) ) >>= nNumType;
262 }
263 }
264 }
265 catch ( Exception& )
266 {
267 }
268
269 if ( nNumType & NumberFormat::TEXT )
270 rDataType = DataType::VARCHAR;
271 else if ( nNumType & NumberFormat::NUMBER )
272 rDataType = DataType::DECIMAL;
273 else if ( nNumType & NumberFormat::CURRENCY )
274 {
275 rCurrency = true;
276 rDataType = DataType::DECIMAL;
277 }
278 else if ( ( nNumType & NumberFormat::DATETIME ) == NumberFormat::DATETIME )
279 {
280 // NumberFormat::DATETIME is DATE | TIME
281 rDataType = DataType::TIMESTAMP;
282 }
283 else if ( nNumType & NumberFormat::DATE )
284 rDataType = DataType::DATE;
285 else if ( nNumType & NumberFormat::TIME )
286 rDataType = DataType::TIME;
287 else if ( nNumType & NumberFormat::LOGICAL )
288 rDataType = DataType::BIT;
289 else
290 rDataType = DataType::DECIMAL;
291 }
292 else
293 {
294 // whole column empty
295 rDataType = DataType::VARCHAR;
296 }
297}
298
299
300static void lcl_SetValue( ORowSetValue& rValue, const Reference<XSpreadsheet>& xSheet,
301 sal_Int32 nStartCol, sal_Int32 nStartRow, bool bHasHeaders,
302 const ::Date& rNullDate,
303 sal_Int32 nDBRow, sal_Int32 nDBColumn, sal_Int32 nType )
304{
305 sal_Int32 nDocColumn = nStartCol + nDBColumn - 1; // database counts from 1
306 sal_Int32 nDocRow = nStartRow + nDBRow - 1;
307 if (bHasHeaders)
308 ++nDocRow;
309
310 const Reference<XCell> xCell = xSheet->getCellByPosition( nDocColumn, nDocRow );
311 if ( !xCell.is() )
312 return;
313
314 CellContentType eCellType = lcl_GetContentOrResultType( xCell );
315 switch (nType)
316 {
317 case DataType::VARCHAR:
318 if ( eCellType == CellContentType_EMPTY )
319 rValue.setNull();
320 else
321 {
322 // #i25840# still let Calc convert numbers to text
323 const Reference<XText> xText( xCell, UNO_QUERY );
324 if ( xText.is() )
325 rValue = xText->getString();
326 }
327 break;
328 case DataType::DECIMAL:
329 if ( eCellType == CellContentType_VALUE )
330 rValue = xCell->getValue(); // double
331 else
332 rValue.setNull();
333 break;
334 case DataType::BIT:
335 if ( eCellType == CellContentType_VALUE )
336 rValue = xCell->getValue() != 0.0;
337 else
338 rValue.setNull();
339 break;
340 case DataType::DATE:
341 if ( eCellType == CellContentType_VALUE )
342 {
343 ::Date aDate( rNullDate );
344 aDate.AddDays(::rtl::math::approxFloor( xCell->getValue() ));
345 rValue = aDate.GetUNODate();
346 }
347 else
348 rValue.setNull();
349 break;
350 case DataType::TIME:
351 if ( eCellType == CellContentType_VALUE )
352 {
353 double fCellVal = xCell->getValue();
354 double fTime = fCellVal - rtl::math::approxFloor( fCellVal );
355 sal_Int64 nIntTime = static_cast<sal_Int64>(rtl::math::round( fTime * static_cast<double>(::tools::Time::nanoSecPerDay) ));
356 if ( nIntTime == ::tools::Time::nanoSecPerDay)
357 nIntTime = 0; // 23:59:59.9999999995 and above is 00:00:00.00
358 css::util::Time aTime;
359 aTime.NanoSeconds = static_cast<sal_uInt32>( nIntTime % ::tools::Time::nanoSecPerSec );
361 aTime.Seconds = static_cast<sal_uInt16>( nIntTime % 60 );
362 nIntTime /= 60;
363 aTime.Minutes = static_cast<sal_uInt16>( nIntTime % 60 );
364 nIntTime /= 60;
365 OSL_ENSURE( nIntTime < 24, "error in time calculation" );
366 aTime.Hours = static_cast<sal_uInt16>(nIntTime);
367 rValue = aTime;
368 }
369 else
370 rValue.setNull();
371 break;
372 case DataType::TIMESTAMP:
373 if ( eCellType == CellContentType_VALUE )
374 {
375 double fCellVal = xCell->getValue();
376 double fDays = ::rtl::math::approxFloor( fCellVal );
377 double fTime = fCellVal - fDays;
378 tools::Long nIntDays = static_cast<tools::Long>(fDays);
379 sal_Int64 nIntTime = ::rtl::math::round( fTime * static_cast<double>(::tools::Time::nanoSecPerDay) );
380 if ( nIntTime == ::tools::Time::nanoSecPerDay )
381 {
382 nIntTime = 0; // 23:59:59.9999999995 and above is 00:00:00.00
383 ++nIntDays; // (next day)
384 }
385
386 css::util::DateTime aDateTime;
387
388 aDateTime.NanoSeconds = static_cast<sal_uInt16>( nIntTime % ::tools::Time::nanoSecPerSec );
390 aDateTime.Seconds = static_cast<sal_uInt16>( nIntTime % 60 );
391 nIntTime /= 60;
392 aDateTime.Minutes = static_cast<sal_uInt16>( nIntTime % 60 );
393 nIntTime /= 60;
394 OSL_ENSURE( nIntTime < 24, "error in time calculation" );
395 aDateTime.Hours = static_cast<sal_uInt16>(nIntTime);
396
397 ::Date aDate( rNullDate );
398 aDate.AddDays( nIntDays );
399 aDateTime.Day = aDate.GetDay();
400 aDateTime.Month = aDate.GetMonth();
401 aDateTime.Year = aDate.GetYear();
402
403 rValue = aDateTime;
404 }
405 else
406 rValue.setNull();
407 break;
408 } // switch (nType)
409
410// rValue.setTypeKind(nType);
411}
412
413
414static OUString lcl_GetColumnStr( sal_Int32 nColumn )
415{
416 if ( nColumn < 26 )
417 return OUString( static_cast<sal_Unicode>( 'A' + nColumn ) );
418 else
419 {
420 OUStringBuffer aBuffer(2);
421 aBuffer.setLength( 2 );
422 aBuffer[0] = static_cast<sal_Unicode>( 'A' + ( nColumn / 26 ) - 1 );
423 aBuffer[1] = static_cast<sal_Unicode>( 'A' + ( nColumn % 26 ) );
424 return aBuffer.makeStringAndClear();
425 }
426}
427
428void OCalcTable::fillColumns()
429{
430 if ( !m_xSheet.is() )
431 throw SQLException();
432
433 OUString aTypeName;
434 ::comphelper::UStringMixEqual aCase(m_pConnection->getMetaData()->supportsMixedCaseQuotedIdentifiers());
435 const bool bStoresMixedCaseQuotedIdentifiers = getConnection()->getMetaData()->supportsMixedCaseQuotedIdentifiers();
436
437 for (sal_Int32 i = 0; i < m_nDataCols; i++)
438 {
439 OUString aColumnName;
440 sal_Int32 eType = DataType::OTHER;
441 bool bCurrency = false;
442
444 aColumnName, eType, bCurrency );
445
446 if ( aColumnName.isEmpty() )
447 aColumnName = lcl_GetColumnStr( i );
448
449 sal_Int32 nPrecision = 0;
450 sal_Int32 nDecimals = 0;
451
452 switch ( eType )
453 {
454 case DataType::VARCHAR:
455 aTypeName = "VARCHAR";
456 break;
457 case DataType::DECIMAL:
458 aTypeName = "DECIMAL";
459 break;
460 case DataType::BIT:
461 aTypeName = "BOOL";
462 break;
463 case DataType::DATE:
464 aTypeName = "DATE";
465 break;
466 case DataType::TIME:
467 aTypeName = "TIME";
468 break;
469 case DataType::TIMESTAMP:
470 aTypeName = "TIMESTAMP";
471 break;
472 default:
473 SAL_WARN( "connectivity.drivers","missing type name");
474 aTypeName.clear();
475 }
476
477 // check if the column name already exists
478 OUString aAlias = aColumnName;
479 OSQLColumns::const_iterator aFind = connectivity::find(m_aColumns->begin(),m_aColumns->end(),aAlias,aCase);
480 sal_Int32 nExprCnt = 0;
481 while(aFind != m_aColumns->end())
482 {
483 aAlias = aColumnName + OUString::number(++nExprCnt);
484 aFind = connectivity::find(m_aColumns->begin(),m_aColumns->end(),aAlias,aCase);
485 }
486
487 rtl::Reference<sdbcx::OColumn> pColumn = new sdbcx::OColumn( aAlias, aTypeName, OUString(),OUString(),
488 ColumnValue::NULLABLE, nPrecision, nDecimals,
489 eType, false, false, bCurrency,
490 bStoresMixedCaseQuotedIdentifiers,
492 m_aColumns->push_back(pColumn);
493 m_aTypes.push_back(eType);
494 }
495}
496
497
499 const OUString& Name,
500 const OUString& Type,
501 const OUString& Description ,
502 const OUString& SchemaName,
503 const OUString& CatalogName
504 ) : OCalcTable_BASE(_pTables,_pConnection,Name,
505 Type,
506 Description,
507 SchemaName,
508 CatalogName)
509 ,m_pCalcConnection(_pConnection)
510 ,m_nStartCol(0)
511 ,m_nStartRow(0)
512 ,m_nDataCols(0)
513 ,m_bHasHeaders(false)
514 ,m_aNullDate(::Date::EMPTY)
515{
516}
517
519{
520 // get sheet object
522 if (xDoc.is())
523 {
524 Reference<XSpreadsheets> xSheets = xDoc->getSheets();
525 if ( xSheets.is() && xSheets->hasByName( m_Name ) )
526 {
527 m_xSheet.set(xSheets->getByName( m_Name ),UNO_QUERY);
528 if ( m_xSheet.is() )
529 {
531 m_bHasHeaders = true;
532 // whole sheet is always assumed to include a header row
533 }
534 }
535 else // no sheet -> try database range
536 {
537 Reference<XPropertySet> xDocProp( xDoc, UNO_QUERY );
538 if ( xDocProp.is() )
539 {
540 Reference<XDatabaseRanges> xRanges(xDocProp->getPropertyValue("DatabaseRanges"),UNO_QUERY);
541
542 if ( xRanges.is() && xRanges->hasByName( m_Name ) )
543 {
544 Reference<XDatabaseRange> xDBRange(xRanges->getByName( m_Name ),UNO_QUERY);
545 Reference<XCellRangeReferrer> xRefer( xDBRange, UNO_QUERY );
546 if ( xRefer.is() )
547 {
548 // Header flag is always stored with database range
549 // Get flag from FilterDescriptor
550
551 bool bRangeHeader = true;
552 Reference<XPropertySet> xFiltProp( xDBRange->getFilterDescriptor(), UNO_QUERY );
553 if ( xFiltProp.is() )
554 xFiltProp->getPropertyValue("ContainsHeader") >>= bRangeHeader;
555
556 Reference<XSheetCellRange> xSheetRange( xRefer->getReferredCells(), UNO_QUERY );
557 Reference<XCellRangeAddressable> xAddr( xSheetRange, UNO_QUERY );
558 if ( xSheetRange.is() && xAddr.is() )
559 {
560 m_xSheet = xSheetRange->getSpreadsheet();
561 CellRangeAddress aRangeAddr = xAddr->getRangeAddress();
562 m_nStartCol = aRangeAddr.StartColumn;
563 m_nStartRow = aRangeAddr.StartRow;
564 m_nDataCols = aRangeAddr.EndColumn - m_nStartCol + 1;
565 // m_nDataRows is excluding header row
566 m_nDataRows = aRangeAddr.EndRow - m_nStartRow;
567 if ( !bRangeHeader )
568 {
569 // m_nDataRows counts the whole range
570 m_nDataRows += 1;
571 }
572
573 m_bHasHeaders = bRangeHeader;
574 }
575 }
576 }
577 }
578 }
579
580 Reference<XNumberFormatsSupplier> xSupp( xDoc, UNO_QUERY );
581 if (xSupp.is())
582 m_xFormats = xSupp->getNumberFormats();
583
584 Reference<XPropertySet> xProp( xDoc, UNO_QUERY );
585 if (xProp.is())
586 {
587 css::util::Date aDateStruct;
588 if ( xProp->getPropertyValue("NullDate") >>= aDateStruct )
589 m_aNullDate = ::Date( aDateStruct.Day, aDateStruct.Month, aDateStruct.Year );
590 }
591 }
592
594
595 fillColumns();
596
598}
599
601{
602 OFileTable::disposing();
603 ::osl::MutexGuard aGuard(m_aMutex);
604 m_aColumns = nullptr;
605 if ( m_pCalcConnection )
607 m_pCalcConnection = nullptr;
608
609}
610
611bool OCalcTable::fetchRow( OValueRefRow& _rRow, const OSQLColumns & _rCols,
612 bool bRetrieveData )
613{
614 // read the bookmark
615
616 _rRow->setDeleted(false);
617 *(*_rRow)[0] = m_nFilePos;
618
619 if (!bRetrieveData)
620 return true;
621
622 // fields
623
624 const OValueRefVector::size_type nCount = std::min(_rRow->size(), _rCols.size() + 1);
625 for (OValueRefVector::size_type i = 1; i < nCount; i++)
626 {
627 if ( (*_rRow)[i]->isBound() )
628 {
629 sal_Int32 nType = m_aTypes[i-1];
630
633 }
634 }
635 return true;
636}
637
638/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static CellContentType lcl_GetContentOrResultType(const Reference< XCell > &xCell)
static bool lcl_HasTextInColumn(const Reference< XSpreadsheet > &xSheet, sal_Int32 nDocColumn, sal_Int32 nDocRow)
static OUString lcl_GetColumnStr(sal_Int32 nColumn)
static Reference< XCell > lcl_GetUsedCell(const Reference< XSpreadsheet > &xSheet, sal_Int32 nDocColumn, sal_Int32 nDocRow)
static void lcl_GetColumnInfo(const Reference< XSpreadsheet > &xSheet, const Reference< XNumberFormats > &xFormats, sal_Int32 nDocColumn, sal_Int32 nStartRow, bool bHasHeaders, OUString &rName, sal_Int32 &rDataType, bool &rCurrency)
static void lcl_UpdateArea(const Reference< XCellRange > &xUsedRange, sal_Int32 &rEndCol, sal_Int32 &rEndRow)
Definition: calc/CTable.cxx:62
static void lcl_SetValue(ORowSetValue &rValue, const Reference< XSpreadsheet > &xSheet, sal_Int32 nStartCol, sal_Int32 nStartRow, bool bHasHeaders, const ::Date &rNullDate, sal_Int32 nDBRow, sal_Int32 nDBColumn, sal_Int32 nType)
static void lcl_GetDataArea(const Reference< XSpreadsheet > &xSheet, sal_Int32 &rColumnCount, sal_Int32 &rRowCount)
Definition: calc/CTable.cxx:85
css::util::Date GetUNODate() const
void AddDays(sal_Int32 nAddDays)
sal_Int16 GetYear() const
sal_uInt16 GetDay() const
sal_uInt16 GetMonth() const
css::uno::Reference< css::sheet::XSpreadsheetDocument > const & acquireDoc()
Definition: CConnection.cxx:99
css::uno::Reference< css::util::XNumberFormats > m_xFormats
Definition: calc/CTable.hxx:49
virtual bool fetchRow(OValueRefRow &_rRow, const OSQLColumns &_rCols, bool bRetrieveData) override
virtual void SAL_CALL disposing() override
OCalcTable(sdbcx::OCollection *_pTables, OCalcConnection *_pConnection, const OUString &Name, const OUString &Type, const OUString &Description=OUString(), const OUString &SchemaName=OUString(), const OUString &CatalogName=OUString())
std::vector< sal_Int32 > m_aTypes
Definition: calc/CTable.hxx:42
css::uno::Reference< css::sheet::XSpreadsheet > m_xSheet
Definition: calc/CTable.hxx:43
OCalcConnection * m_pCalcConnection
Definition: calc/CTable.hxx:44
Shared Table base class for Writer tables and Calc sheets.
virtual css::uno::Reference< css::sdbc::XDatabaseMetaData > SAL_CALL getMetaData() override
OConnection * m_pConnection
Definition: FTable.hxx:36
const OUString & getSchema() const
Definition: FTable.hxx:83
OUString SAL_CALL getName() override
Definition: FTable.hxx:81
::rtl::Reference< OSQLColumns > m_aColumns
Definition: FTable.hxx:38
OConnection * getConnection() const
Definition: FTable.hxx:66
mutable::osl::Mutex m_aMutex
static const sal_Int64 nanoSecPerDay
static const sal_Int64 nanoSecPerSec
int nCount
DocumentType eType
sal_Int16 nNumType
#define SAL_WARN(area, stream)
std::unique_ptr< sal_Int32[]> pData
@ Exception
Type
OSQLColumns::const_iterator find(const OSQLColumns::const_iterator &first, const OSQLColumns::const_iterator &last, std::u16string_view _rVal, const ::comphelper::UStringMixEqual &_rCase)
Definition: dbtools.cxx:1958
int i
constexpr OUStringLiteral EMPTY
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
long Long
#define PROPERTY_ID_TYPE
Definition: propertyids.hxx:51
QPRO_FUNC_TYPE nType
OUString Name
sal_uInt16 sal_Unicode
std::unique_ptr< char[]> aBuffer