/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
Reference<XUsedAreaCursor> xUsed( xCursor, UNO_QUERY ); if ( xUsed.is() )
{ // The used area from XUsedAreaCursor includes visible attributes. // If the used area is larger than the contiguous cell area, find non-empty // cells in that area.
if ( aUsedAddr.EndRow > aRegionAddr.EndRow )
{ // only up to the last column of aRegionAddr, the other columns are handled above
Reference<XCellRange> xUsedRange = xSheet->getCellRangeByPosition(
0, aRegionAddr.EndRow + 1, aRegionAddr.EndColumn, aUsedAddr.EndRow );
lcl_UpdateArea( xUsedRange, nEndCol, nEndRow );
}
}
rColumnCount = nEndCol + 1; // number of columns
rRowCount = nEndRow; // first row (headers) is not counted
}
static CellContentType lcl_GetContentOrResultType( const Reference<XCell>& xCell )
{
CellContentType eCellType = xCell->getType(); if ( eCellType == CellContentType_FORMULA )
{
Reference<XPropertySet> xProp( xCell, UNO_QUERY ); try
{
xProp->getPropertyValue( u"CellContentType"_ustr ) >>= eCellType; // type of cell content
} catch (UnknownPropertyException&)
{
eCellType = CellContentType_VALUE; // if CellContentType property not available
}
} return eCellType;
}
Reference<XCellRangeAddressable> xAddr( xSheet, UNO_QUERY ); if (xAddr.is())
{
CellRangeAddress aTotalRange = xAddr->getRangeAddress();
sal_Int32 nLastRow = aTotalRange.EndRow;
Reference<XCellRangesQuery> xQuery( xSheet->getCellRangeByPosition( nDocColumn, nDocRow, nDocColumn, nLastRow ), UNO_QUERY ); if (xQuery.is())
{ // queryIntersection to get a ranges object
Reference<XSheetCellRanges> xRanges = xQuery->queryIntersection( aTotalRange ); if (xRanges.is())
{
Reference<XEnumerationAccess> xCells = xRanges->getCells(); if (xCells.is())
{
Reference<XEnumeration> xEnum = xCells->createEnumeration(); if ( xEnum.is() && xEnum->hasMoreElements() )
{ // get first non-empty cell from enumeration
xCell.set(xEnum->nextElement(),UNO_QUERY);
} // otherwise, keep empty cell
}
}
}
}
} return xCell;
}
staticbool lcl_HasTextInColumn( const Reference<XSpreadsheet>& xSheet, sal_Int32 nDocColumn, sal_Int32 nDocRow )
{ // look for any text cell or text result in the column
// are there text cells in the column?
Reference<XSheetCellRanges> xTextContent = xQuery->queryContentCells( CellFlags::STRING ); if ( xTextContent.is() && xTextContent->hasElements() ) returntrue;
// are there formulas with text results in the column?
Reference<XSheetCellRanges> xTextFormula = xQuery->queryFormulaCells( FormulaResult::STRING ); if ( xTextFormula.is() && xTextFormula->hasElements() ) returntrue;
Reference<XPropertySet> xProp( xDataCell, UNO_QUERY ); if ( !xProp.is() ) return;
rCurrency = false; // set to true for currency below
const CellContentType eCellType = lcl_GetContentOrResultType( xDataCell ); // #i35178# use "text" type if there is any text cell in the column if ( eCellType == CellContentType_TEXT || lcl_HasTextInColumn( xSheet, nDocColumn, nDataRow ) )
rDataType = DataType::VARCHAR; elseif ( eCellType == CellContentType_VALUE )
{ // get number format to distinguish between different types
void OCalcTable::construct()
{ // get sheet object
Reference< XSpreadsheetDocument> xDoc = m_pCalcConnection->acquireDoc(); if (xDoc.is())
{
Reference<XSpreadsheets> xSheets = xDoc->getSheets(); if ( xSheets.is() && xSheets->hasByName( m_Name ) )
{
m_xSheet.set(xSheets->getByName( m_Name ),UNO_QUERY); if ( m_xSheet.is() )
{
lcl_GetDataArea( m_xSheet, m_nDataCols, m_nDataRows );
m_bHasHeaders = true; // whole sheet is always assumed to include a header row
}
} else// no sheet -> try database range
{
Reference<XPropertySet> xDocProp( xDoc, UNO_QUERY ); if ( xDocProp.is() )
{
Reference<XDatabaseRanges> xRanges(xDocProp->getPropertyValue(u"DatabaseRanges"_ustr),UNO_QUERY);
if ( xRanges.is() && xRanges->hasByName( m_Name ) )
{
Reference<XDatabaseRange> xDBRange(xRanges->getByName( m_Name ),UNO_QUERY);
Reference<XCellRangeReferrer> xRefer( xDBRange, UNO_QUERY ); if ( xRefer.is() )
{ // Header flag is always stored with database range // Get flag from FilterDescriptor
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.