diff options
Diffstat (limited to 'connectivity/source/drivers/calc/CDatabaseMetaData.cxx')
-rw-r--r-- | connectivity/source/drivers/calc/CDatabaseMetaData.cxx | 77 |
1 files changed, 36 insertions, 41 deletions
diff --git a/connectivity/source/drivers/calc/CDatabaseMetaData.cxx b/connectivity/source/drivers/calc/CDatabaseMetaData.cxx index 04945e71de6c..6d77b8c4b2f3 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(u"IsVisible"_ustr); + 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; } } @@ -109,7 +108,7 @@ static bool lcl_IsUnnamed( const Reference<XDatabaseRanges>& xRanges, const OUSt { try { - Any aUserAny = xRangeProp->getPropertyValue("IsUserDefined"); + Any aUserAny = xRangeProp->getPropertyValue(u"IsUserDefined"_ustr); bool bUserDefined; if ( aUserAny >>= bUserDefined ) bUnnamed = !bUserDefined; @@ -135,27 +134,23 @@ Reference< XResultSet > SAL_CALL OCalcDatabaseMetaData::getTables( // check if ORowSetValue type is given // when no types are given then we have to return all tables e.g. TABLE - OUString aTable("TABLE"); + static constexpr OUString aTable(u"TABLE"_ustr); - bool bTableFound = true; - sal_Int32 nLength = types.getLength(); - if(nLength) + if (types.hasElements()) { - bTableFound = false; + bool bTableFound = false; - const OUString* pIter = types.getConstArray(); - const OUString* pEnd = pIter + nLength; - for(;pIter != pEnd;++pIter) + for (auto& type : types) { - if(*pIter == aTable) + if (type == aTable) { bTableFound = true; break; } } + if (!bTableFound) + return pResult; } - if(!bTableFound) - return pResult; // get the sheet names from the document @@ -188,7 +183,7 @@ Reference< XResultSet > SAL_CALL OCalcDatabaseMetaData::getTables( Reference<XPropertySet> xDocProp( xDoc, UNO_QUERY ); if ( xDocProp.is() ) { - Any aRangesAny = xDocProp->getPropertyValue("DatabaseRanges"); + Any aRangesAny = xDocProp->getPropertyValue(u"DatabaseRanges"_ustr); Reference<XDatabaseRanges> xRanges; if ( aRangesAny >>= xRanges ) { @@ -209,7 +204,7 @@ Reference< XResultSet > SAL_CALL OCalcDatabaseMetaData::getTables( } } - pResult->setRows(aRows); + pResult->setRows(std::move(aRows)); return pResult; } |