diff options
Diffstat (limited to 'connectivity/source/drivers/calc/CDatabaseMetaData.cxx')
-rw-r--r-- | connectivity/source/drivers/calc/CDatabaseMetaData.cxx | 84 |
1 files changed, 40 insertions, 44 deletions
diff --git a/connectivity/source/drivers/calc/CDatabaseMetaData.cxx b/connectivity/source/drivers/calc/CDatabaseMetaData.cxx index cea1b32c7a94..aad5b4e50193 100644 --- a/connectivity/source/drivers/calc/CDatabaseMetaData.cxx +++ b/connectivity/source/drivers/calc/CDatabaseMetaData.cxx @@ -34,7 +34,6 @@ using namespace connectivity::file; using namespace connectivity::component; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::sdbcx; using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::container; using namespace ::com::sun::star::table; @@ -59,37 +58,37 @@ static bool lcl_IsEmptyOrHidden( const Reference<XSpreadsheets>& xSheets, const { Any aAny = xSheets->getByName( rName ); Reference<XSpreadsheet> xSheet; - if ( aAny >>= xSheet ) + if ( !(aAny >>= xSheet) ) + return false; + + // test if sheet is hidden + + Reference<XPropertySet> xProp( xSheet, UNO_QUERY ); + if (xProp.is()) { - // test if sheet is hidden + bool bVisible; + Any aVisAny = xProp->getPropertyValue("IsVisible"); + if ( (aVisAny >>= bVisible) && !bVisible) + return true; // hidden + } - Reference<XPropertySet> xProp( xSheet, UNO_QUERY ); - if (xProp.is()) - { - bool bVisible; - Any aVisAny = xProp->getPropertyValue("IsVisible"); - if ( (aVisAny >>= bVisible) && !bVisible) - return true; // hidden - } + // use the same data area as in OCalcTable to test for empty table - // use the same data area as in OCalcTable to test for empty table + Reference<XSheetCellCursor> xCursor = xSheet->createCursor(); + Reference<XCellRangeAddressable> xRange( xCursor, UNO_QUERY ); + if ( xRange.is() ) + { + xCursor->collapseToSize( 1, 1 ); // single (first) cell + xCursor->collapseToCurrentRegion(); // contiguous data area - Reference<XSheetCellCursor> xCursor = xSheet->createCursor(); - Reference<XCellRangeAddressable> xRange( xCursor, UNO_QUERY ); - if ( xRange.is() ) + CellRangeAddress aRangeAddr = xRange->getRangeAddress(); + if ( aRangeAddr.StartColumn == aRangeAddr.EndColumn && + aRangeAddr.StartRow == aRangeAddr.EndRow ) { - xCursor->collapseToSize( 1, 1 ); // single (first) cell - xCursor->collapseToCurrentRegion(); // contiguous data area - - CellRangeAddress aRangeAddr = xRange->getRangeAddress(); - if ( aRangeAddr.StartColumn == aRangeAddr.EndColumn && - aRangeAddr.StartRow == aRangeAddr.EndRow ) - { - // single cell -> check content - Reference<XCell> xCell = xCursor->getCellByPosition( 0, 0 ); - if ( xCell.is() && xCell->getType() == CellContentType_EMPTY ) - return true; - } + // single cell -> check content + Reference<XCell> xCell = xCursor->getCellByPosition( 0, 0 ); + if ( xCell.is() && xCell->getType() == CellContentType_EMPTY ) + return true; } } @@ -130,8 +129,7 @@ Reference< XResultSet > SAL_CALL OCalcDatabaseMetaData::getTables( { ::osl::MutexGuard aGuard( m_aMutex ); - ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTables); - Reference< XResultSet > xRef = pResult; + rtl::Reference<ODatabaseMetaDataResultSet> pResult = new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTables); // check if ORowSetValue type is given // when no types are given then we have to return all tables e.g. TABLE @@ -156,7 +154,7 @@ Reference< XResultSet > SAL_CALL OCalcDatabaseMetaData::getTables( } } if(!bTableFound) - return xRef; + return pResult; // get the sheet names from the document @@ -176,12 +174,11 @@ Reference< XResultSet > SAL_CALL OCalcDatabaseMetaData::getTables( OUString aName = aSheetNames[nSheet]; if ( !lcl_IsEmptyOrHidden( xSheets, aName ) && match(tableNamePattern,aName,'\0') ) { - ODatabaseMetaDataResultSet::ORow aRow { nullptr, nullptr, nullptr }; - aRow.reserve(6); - aRow.push_back(new ORowSetValueDecorator(aName)); - aRow.push_back(new ORowSetValueDecorator(aTable)); - aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); - aRows.push_back(aRow); + aRows.push_back( { nullptr, nullptr, nullptr, + new ORowSetValueDecorator(aName), + new ORowSetValueDecorator(aTable), + ODatabaseMetaDataResultSet::getEmptyValue() + } ); } } @@ -201,20 +198,19 @@ Reference< XResultSet > SAL_CALL OCalcDatabaseMetaData::getTables( OUString aName = aDBNames[nRange]; if ( !lcl_IsUnnamed( xRanges, aName ) && match(tableNamePattern,aName,'\0') ) { - ODatabaseMetaDataResultSet::ORow aRow { nullptr, nullptr, nullptr }; - aRow.reserve(6); - aRow.push_back(new ORowSetValueDecorator(aName)); - aRow.push_back(new ORowSetValueDecorator(aTable)); - aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); - aRows.push_back(aRow); + aRows.push_back( { nullptr, nullptr, nullptr, + new ORowSetValueDecorator(aName), + new ORowSetValueDecorator(aTable), + ODatabaseMetaDataResultSet::getEmptyValue() + } ); } } } } - pResult->setRows(aRows); + pResult->setRows(std::move(aRows)); - return xRef; + return pResult; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |