canvas/inc/spriteredrawmanager.hxx | 96 - canvas/source/cairo/cairo_canvashelper.cxx | 28 canvas/source/tools/canvastools.cxx | 30 chart2/source/controller/main/ChartController_TextEdit.cxx | 40 chart2/source/controller/main/ChartFrameloader.cxx | 72 - chart2/source/tools/AxisHelper.cxx | 62 - chart2/source/view/charttypes/PieChart.cxx | 83 - chart2/source/view/main/ChartView.cxx | 57 - codemaker/source/cppumaker/cpputype.cxx | 121 +- comphelper/source/container/embeddedobjectcontainer.cxx | 74 - comphelper/source/misc/backupfilehelper.cxx | 488 ++++------ comphelper/source/misc/namedvaluecollection.cxx | 40 comphelper/source/officeinstdir/officeinstallationdirectories.cxx | 40 configmgr/source/valueparser.cxx | 29 connectivity/source/drivers/calc/CDatabaseMetaData.cxx | 52 - connectivity/source/drivers/calc/CTable.cxx | 35 connectivity/source/drivers/firebird/ResultSetMetaData.cxx | 102 +- connectivity/source/drivers/firebird/StatementCommonBase.cxx | 28 connectivity/source/drivers/hsqldb/HStorageAccess.cxx | 40 connectivity/source/drivers/hsqldb/StorageFileAccess.cxx | 46 connectivity/source/manager/mdrivermanager.cxx | 30 connectivity/source/parse/sqlnode.cxx | 155 +-- cppu/source/threadpool/current.cxx | 34 cppu/source/typelib/typelib.cxx | 398 ++++---- cppuhelper/source/servicemanager.cxx | 63 - cui/source/customize/acccfg.cxx | 29 cui/source/customize/cfg.cxx | 28 cui/source/options/cfgchart.cxx | 59 - cui/source/options/treeopt.cxx | 36 cui/source/tabpages/backgrnd.cxx | 52 - cui/source/tabpages/swpossizetabpage.cxx | 97 - cui/source/tabpages/textattr.cxx | 44 cui/source/tabpages/themepage.cxx | 64 - 33 files changed, 1319 insertions(+), 1333 deletions(-)
New commits: commit 25298930bc86d1a449a7e5b139d65e49f695f8c1 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Tue Dec 21 13:42:35 2021 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Tue Dec 21 15:55:46 2021 +0100 loplugin:flatten in canvas..cui Change-Id: I208767eaa60d913fe2882403f1f9351eb08256f7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127224 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/canvas/inc/spriteredrawmanager.hxx b/canvas/inc/spriteredrawmanager.hxx index 87c692f6d7dc..cf2b86e0a8cc 100644 --- a/canvas/inc/spriteredrawmanager.hxx +++ b/canvas/inc/spriteredrawmanager.hxx @@ -286,64 +286,64 @@ namespace canvas { // check whether this area contains changed sprites at all // (if not, just ignore it) - if( areSpritesChanged( rUpdateArea ) ) + if( !areSpritesChanged( rUpdateArea ) ) + return; + + // at least one of the sprites actually needs an + // update - process whole area. + + // check whether this area could be handled special + // (background paint, direct update, scroll, etc.) + ::basegfx::B2DRange aMoveStart; + ::basegfx::B2DRange aMoveEnd; + if( rUpdateArea.maComponentList.empty() ) + { + rFunc.backgroundPaint( rUpdateArea.maTotalBounds ); + } + else { - // at least one of the sprites actually needs an - // update - process whole area. - - // check whether this area could be handled special - // (background paint, direct update, scroll, etc.) - ::basegfx::B2DRange aMoveStart; - ::basegfx::B2DRange aMoveEnd; - if( rUpdateArea.maComponentList.empty() ) + // cache number of sprites in this area (it's a + // list, and both isAreaUpdateScroll() and + // isAreaUpdateOpaque() need it). + const ::std::size_t nNumSprites( + rUpdateArea.maComponentList.size() ); + + if( isAreaUpdateScroll( aMoveStart, + aMoveEnd, + rUpdateArea, + nNumSprites ) ) { - rFunc.backgroundPaint( rUpdateArea.maTotalBounds ); + rFunc.scrollUpdate( aMoveStart, + aMoveEnd, + rUpdateArea ); } else { - // cache number of sprites in this area (it's a - // list, and both isAreaUpdateScroll() and - // isAreaUpdateOpaque() need it). - const ::std::size_t nNumSprites( - rUpdateArea.maComponentList.size() ); - - if( isAreaUpdateScroll( aMoveStart, - aMoveEnd, - rUpdateArea, + // potentially, more than a single sprite + // involved. Have to sort component lists for + // sprite prio. + VectorOfSprites aSortedUpdateSprites; + for (auto const& elem : rUpdateArea.maComponentList) + { + const Sprite::Reference& rSprite( elem.second.getSprite() ); + if( rSprite.is() ) + aSortedUpdateSprites.push_back( rSprite ); + } + + ::std::sort( aSortedUpdateSprites.begin(), + aSortedUpdateSprites.end(), + SpriteWeakOrder() ); + + if( isAreaUpdateOpaque( rUpdateArea, nNumSprites ) ) { - rFunc.scrollUpdate( aMoveStart, - aMoveEnd, - rUpdateArea ); + rFunc.opaqueUpdate( rUpdateArea.maTotalBounds, + aSortedUpdateSprites ); } else { - // potentially, more than a single sprite - // involved. Have to sort component lists for - // sprite prio. - VectorOfSprites aSortedUpdateSprites; - for (auto const& elem : rUpdateArea.maComponentList) - { - const Sprite::Reference& rSprite( elem.second.getSprite() ); - if( rSprite.is() ) - aSortedUpdateSprites.push_back( rSprite ); - } - - ::std::sort( aSortedUpdateSprites.begin(), - aSortedUpdateSprites.end(), - SpriteWeakOrder() ); - - if( isAreaUpdateOpaque( rUpdateArea, - nNumSprites ) ) - { - rFunc.opaqueUpdate( rUpdateArea.maTotalBounds, - aSortedUpdateSprites ); - } - else - { - rFunc.genericUpdate( rUpdateArea.maTotalBounds, - aSortedUpdateSprites ); - } + rFunc.genericUpdate( rUpdateArea.maTotalBounds, + aSortedUpdateSprites ); } } } diff --git a/canvas/source/cairo/cairo_canvashelper.cxx b/canvas/source/cairo/cairo_canvashelper.cxx index 2ee30cfc3740..e9aafabe7e63 100644 --- a/canvas/source/cairo/cairo_canvashelper.cxx +++ b/canvas/source/cairo/cairo_canvashelper.cxx @@ -2015,25 +2015,25 @@ constexpr OUStringLiteral PARAMETRICPOLYPOLYGON_IMPLEMENTATION_NAME = u"Canvas:: { SAL_INFO( "canvas.cairo", "CanvasHelper::repaint"); - if( mpCairo ) - { - cairo_save( mpCairo.get() ); + if( !mpCairo ) + return true; - cairo_rectangle( mpCairo.get(), 0, 0, maSize.getX(), maSize.getY() ); - cairo_clip( mpCairo.get() ); + cairo_save( mpCairo.get() ); - useStates( viewState, renderState, true ); + cairo_rectangle( mpCairo.get(), 0, 0, maSize.getX(), maSize.getY() ); + cairo_clip( mpCairo.get() ); - cairo_matrix_t aMatrix; + useStates( viewState, renderState, true ); - cairo_get_matrix( mpCairo.get(), &aMatrix ); - aMatrix.xx = aMatrix.yy = 1; - cairo_set_matrix( mpCairo.get(), &aMatrix ); + cairo_matrix_t aMatrix; - cairo_set_source_surface( mpCairo.get(), pSurface->getCairoSurface().get(), 0, 0 ); - cairo_paint( mpCairo.get() ); - cairo_restore( mpCairo.get() ); - } + cairo_get_matrix( mpCairo.get(), &aMatrix ); + aMatrix.xx = aMatrix.yy = 1; + cairo_set_matrix( mpCairo.get(), &aMatrix ); + + cairo_set_source_surface( mpCairo.get(), pSurface->getCairoSurface().get(), 0, 0 ); + cairo_paint( mpCairo.get() ); + cairo_restore( mpCairo.get() ); return true; } diff --git a/canvas/source/tools/canvastools.cxx b/canvas/source/tools/canvastools.cxx index f6182ae9b7b3..048a99407c68 100644 --- a/canvas/source/tools/canvastools.cxx +++ b/canvas/source/tools/canvastools.cxx @@ -1080,25 +1080,25 @@ namespace canvas::tools { o_rxParams.realloc( 0 ); - if( i_rxCanvas.is() ) + if( !i_rxCanvas.is() ) + return o_rxParams; + + try { - try - { - uno::Reference< rendering::XGraphicDevice > xDevice( i_rxCanvas->getDevice(), - uno::UNO_SET_THROW ); + uno::Reference< rendering::XGraphicDevice > xDevice( i_rxCanvas->getDevice(), + uno::UNO_SET_THROW ); - uno::Reference< lang::XServiceInfo > xServiceInfo( xDevice, - uno::UNO_QUERY_THROW ); - uno::Reference< beans::XPropertySet > xPropSet( xDevice, + uno::Reference< lang::XServiceInfo > xServiceInfo( xDevice, uno::UNO_QUERY_THROW ); + uno::Reference< beans::XPropertySet > xPropSet( xDevice, + uno::UNO_QUERY_THROW ); - o_rxParams = { uno::Any(xServiceInfo->getImplementationName()), - xPropSet->getPropertyValue( "DeviceHandle" ) }; - } - catch( const uno::Exception& ) - { - // ignore, but return empty sequence - } + o_rxParams = { uno::Any(xServiceInfo->getImplementationName()), + xPropSet->getPropertyValue( "DeviceHandle" ) }; + } + catch( const uno::Exception& ) + { + // ignore, but return empty sequence } return o_rxParams; diff --git a/chart2/source/controller/main/ChartController_TextEdit.cxx b/chart2/source/controller/main/ChartController_TextEdit.cxx index 23b590907f67..524d57762292 100644 --- a/chart2/source/controller/main/ChartController_TextEdit.cxx +++ b/chart2/source/controller/main/ChartController_TextEdit.cxx @@ -121,32 +121,32 @@ bool ChartController::EndTextEdit() SdrOutliner* pOutliner = m_pDrawViewWrapper->getOutliner(); OutlinerParaObject* pParaObj = pTextObject->GetOutlinerParaObject(); - if( pParaObj && pOutliner ) - { - pOutliner->SetText( *pParaObj ); + if( !pParaObj || !pOutliner ) + return true; - OUString aString = pOutliner->GetText( - pOutliner->GetParagraph( 0 ), - pOutliner->GetParagraphCount() ); + pOutliner->SetText( *pParaObj ); - OUString aObjectCID = m_aSelection.getSelectedCID(); - if ( !aObjectCID.isEmpty() ) - { - uno::Reference< beans::XPropertySet > xPropSet = - ObjectIdentifier::getObjectPropertySet( aObjectCID, getModel() ); + OUString aString = pOutliner->GetText( + pOutliner->GetParagraph( 0 ), + pOutliner->GetParagraphCount() ); - // lock controllers till end of block - ControllerLockGuardUNO aCLGuard( getModel() ); + OUString aObjectCID = m_aSelection.getSelectedCID(); + if ( !aObjectCID.isEmpty() ) + { + uno::Reference< beans::XPropertySet > xPropSet = + ObjectIdentifier::getObjectPropertySet( aObjectCID, getModel() ); - TitleHelper::setCompleteString( aString, uno::Reference< - css::chart2::XTitle >::query( xPropSet ), m_xCC ); + // lock controllers till end of block + ControllerLockGuardUNO aCLGuard( getModel() ); - OSL_ENSURE(m_pTextActionUndoGuard, "ChartController::EndTextEdit: no TextUndoGuard!"); - if (m_pTextActionUndoGuard) - m_pTextActionUndoGuard->commit(); - } - m_pTextActionUndoGuard.reset(); + TitleHelper::setCompleteString( aString, uno::Reference< + css::chart2::XTitle >::query( xPropSet ), m_xCC ); + + OSL_ENSURE(m_pTextActionUndoGuard, "ChartController::EndTextEdit: no TextUndoGuard!"); + if (m_pTextActionUndoGuard) + m_pTextActionUndoGuard->commit(); } + m_pTextActionUndoGuard.reset(); return true; } diff --git a/chart2/source/controller/main/ChartFrameloader.cxx b/chart2/source/controller/main/ChartFrameloader.cxx index f598a7fff4a7..991c6a87e00f 100644 --- a/chart2/source/controller/main/ChartFrameloader.cxx +++ b/chart2/source/controller/main/ChartFrameloader.cxx @@ -134,49 +134,51 @@ sal_Bool SAL_CALL ChartFrameLoader::load( const uno::Sequence< beans::PropertyVa } // call initNew() or load() at XLoadable - if(!bHaveLoadedModel) - try + if(bHaveLoadedModel) + return true; + + try + { + utl::MediaDescriptor::const_iterator aIt( aMediaDescriptor.find( utl::MediaDescriptor::PROP_URL)); + if( aIt != aMediaDescriptor.end()) { - utl::MediaDescriptor::const_iterator aIt( aMediaDescriptor.find( utl::MediaDescriptor::PROP_URL)); - if( aIt != aMediaDescriptor.end()) + OUString aURL( (*aIt).second.get< OUString >()); + if( aURL.startsWith( "private:factory/schart" ) ) + { + // create new file + uno::Reference< frame::XLoadable > xLoadable( xModel, uno::UNO_QUERY_THROW ); + xLoadable->initNew(); + } + else { - OUString aURL( (*aIt).second.get< OUString >()); - if( aURL.startsWith( "private:factory/schart" ) ) + // use the URL as BaseURL, similar to what SfxBaseModel effectively does + if (!aURL.isEmpty()) { - // create new file - uno::Reference< frame::XLoadable > xLoadable( xModel, uno::UNO_QUERY_THROW ); - xLoadable->initNew(); + aMediaDescriptor[utl::MediaDescriptor::PROP_DOCUMENTBASEURL] <<= aURL; } - else + aMediaDescriptor.addInputStream(); + uno::Sequence< beans::PropertyValue > aCompleteMediaDescriptor; + aMediaDescriptor >> aCompleteMediaDescriptor; + apphelper::MediaDescriptorHelper aMDHelper( aCompleteMediaDescriptor ); + + // load file + // @todo: replace: aMediaDescriptorHelper.getReducedForModel() + uno::Reference< frame::XLoadable > xLoadable( xModel, uno::UNO_QUERY_THROW ); + xLoadable->load( aCompleteMediaDescriptor ); + + //resize standalone files to get correct size: + if( xComponentWindow.is() && aMDHelper.ISSET_FilterName && aMDHelper.FilterName == "StarChart 5.0" ) { - // use the URL as BaseURL, similar to what SfxBaseModel effectively does - if (!aURL.isEmpty()) - { - aMediaDescriptor[utl::MediaDescriptor::PROP_DOCUMENTBASEURL] <<= aURL; - } - aMediaDescriptor.addInputStream(); - uno::Sequence< beans::PropertyValue > aCompleteMediaDescriptor; - aMediaDescriptor >> aCompleteMediaDescriptor; - apphelper::MediaDescriptorHelper aMDHelper( aCompleteMediaDescriptor ); - - // load file - // @todo: replace: aMediaDescriptorHelper.getReducedForModel() - uno::Reference< frame::XLoadable > xLoadable( xModel, uno::UNO_QUERY_THROW ); - xLoadable->load( aCompleteMediaDescriptor ); - - //resize standalone files to get correct size: - if( xComponentWindow.is() && aMDHelper.ISSET_FilterName && aMDHelper.FilterName == "StarChart 5.0" ) - { - awt::Rectangle aRect( xComponentWindow->getPosSize() ); - xComponentWindow->setPosSize( aRect.X, aRect.Y, aRect.Width, aRect.Height, 0 ); - } + awt::Rectangle aRect( xComponentWindow->getPosSize() ); + xComponentWindow->setPosSize( aRect.X, aRect.Y, aRect.Width, aRect.Height, 0 ); } } } - catch( const uno::Exception & ) - { - DBG_UNHANDLED_EXCEPTION("chart2"); - } + } + catch( const uno::Exception & ) + { + DBG_UNHANDLED_EXCEPTION("chart2"); + } return true; } diff --git a/chart2/source/tools/AxisHelper.cxx b/chart2/source/tools/AxisHelper.cxx index 4c6c5dd0e8cd..276abb5dbc47 100644 --- a/chart2/source/tools/AxisHelper.cxx +++ b/chart2/source/tools/AxisHelper.cxx @@ -743,23 +743,23 @@ bool AxisHelper::getIndicesForAxis( rOutDimensionIndex = -1; rOutAxisIndex = -1; - if( xCooSys.is() && xAxis.is() ) + if( !xCooSys || !xAxis ) + return false; + + Reference< XAxis > xCurrentAxis; + sal_Int32 nDimensionCount( xCooSys->getDimension() ); + for( sal_Int32 nDimensionIndex = 0; nDimensionIndex < nDimensionCount; nDimensionIndex++ ) { - Reference< XAxis > xCurrentAxis; - sal_Int32 nDimensionCount( xCooSys->getDimension() ); - for( sal_Int32 nDimensionIndex = 0; nDimensionIndex < nDimensionCount; nDimensionIndex++ ) + sal_Int32 nMaxAxisIndex = xCooSys->getMaximumAxisIndexByDimension(nDimensionIndex); + for( sal_Int32 nAxisIndex = 0; nAxisIndex <= nMaxAxisIndex; nAxisIndex++ ) { - sal_Int32 nMaxAxisIndex = xCooSys->getMaximumAxisIndexByDimension(nDimensionIndex); - for( sal_Int32 nAxisIndex = 0; nAxisIndex <= nMaxAxisIndex; nAxisIndex++ ) - { - xCurrentAxis = xCooSys->getAxisByDimension(nDimensionIndex,nAxisIndex); - if( xCurrentAxis == xAxis ) - { - rOutDimensionIndex = nDimensionIndex; - rOutAxisIndex = nAxisIndex; - return true; - } - } + xCurrentAxis = xCooSys->getAxisByDimension(nDimensionIndex,nAxisIndex); + if( xCurrentAxis == xAxis ) + { + rOutDimensionIndex = nDimensionIndex; + rOutAxisIndex = nAxisIndex; + return true; + } } } return false; @@ -904,25 +904,25 @@ void AxisHelper::getAxisOrGridPossibilities( Sequence< sal_Bool >& rPossibilityL bool AxisHelper::isSecondaryYAxisNeeded( const Reference< XCoordinateSystem >& xCooSys ) { Reference< chart2::XChartTypeContainer > xCTCnt( xCooSys, uno::UNO_QUERY ); - if( xCTCnt.is() ) + if( !xCTCnt.is() ) + return false; + + const Sequence< Reference< chart2::XChartType > > aChartTypes( xCTCnt->getChartTypes() ); + for( Reference< chart2::XChartType > const & chartType : aChartTypes ) { - const Sequence< Reference< chart2::XChartType > > aChartTypes( xCTCnt->getChartTypes() ); - for( Reference< chart2::XChartType > const & chartType : aChartTypes ) - { - Reference< XDataSeriesContainer > xSeriesContainer( chartType, uno::UNO_QUERY ); - if( !xSeriesContainer.is() ) - continue; + Reference< XDataSeriesContainer > xSeriesContainer( chartType, uno::UNO_QUERY ); + if( !xSeriesContainer.is() ) + continue; - Sequence< Reference< XDataSeries > > aSeriesList( xSeriesContainer->getDataSeries() ); - for( sal_Int32 nS = aSeriesList.getLength(); nS-- ; ) + Sequence< Reference< XDataSeries > > aSeriesList( xSeriesContainer->getDataSeries() ); + for( sal_Int32 nS = aSeriesList.getLength(); nS-- ; ) + { + Reference< beans::XPropertySet > xProp( aSeriesList[nS], uno::UNO_QUERY ); + if(xProp.is()) { - Reference< beans::XPropertySet > xProp( aSeriesList[nS], uno::UNO_QUERY ); - if(xProp.is()) - { - sal_Int32 nAttachedAxisIndex = 0; - if( ( xProp->getPropertyValue( "AttachedAxisIndex" ) >>= nAttachedAxisIndex ) && nAttachedAxisIndex>0 ) - return true; - } + sal_Int32 nAttachedAxisIndex = 0; + if( ( xProp->getPropertyValue( "AttachedAxisIndex" ) >>= nAttachedAxisIndex ) && nAttachedAxisIndex>0 ) + return true; } } } diff --git a/chart2/source/view/charttypes/PieChart.cxx b/chart2/source/view/charttypes/PieChart.cxx index 57dbab089e00..331b5e4da107 100644 --- a/chart2/source/view/charttypes/PieChart.cxx +++ b/chart2/source/view/charttypes/PieChart.cxx @@ -914,48 +914,49 @@ bool PieChart::PieLabelInfo::moveAwayFrom( const PieChart::PieLabelInfo* pFix, c ///boxes (`aOverlap`). ::basegfx::B2IRectangle aOverlap( lcl_getRect( xLabelGroupShape ) ); aOverlap.intersect( lcl_getRect( pFix->xLabelGroupShape ) ); - if( !aOverlap.isEmpty() ) - { - //TODO: alternative move direction - - ///the label is shifted along the direction orthogonal to the vector - ///starting at the pie/donut center and ending at this label anchor - ///point; - - ///named `aTangentialDirection` the unit vector related to such a - ///direction, the magnitude of the shift along such a direction is - ///calculated in this way: if the horizontal component of - ///`aTangentialDirection` is greater than the vertical component, - ///the magnitude of the shift is equal to `aOverlap.Width` else to - ///`aOverlap.Height`; - basegfx::B2IVector aRadiusDirection = aFirstPosition - aOrigin; - aRadiusDirection.setLength(1.0); - basegfx::B2IVector aTangentialDirection( -aRadiusDirection.getY(), aRadiusDirection.getX() ); - bool bShiftHorizontal = abs(aTangentialDirection.getX()) > abs(aTangentialDirection.getY()); - sal_Int32 nShift = bShiftHorizontal ? static_cast<sal_Int32>(aOverlap.getWidth()) : static_cast<sal_Int32>(aOverlap.getHeight()); - ///the magnitude of the shift is also increased by 1/50-th of the width - ///or the height of the document page; - nShift += (bShiftHorizontal ? nLabelDistanceX : nLabelDistanceY); - ///in case the `bMoveHalfWay` parameter is true the magnitude of - ///the shift is halved. - if( bMoveHalfWay ) - nShift/=2; - ///in case the `bMoveClockwise` parameter is false the direction of - ///`aTangentialDirection` is reversed; - if(!bMoveClockwise) - nShift*=-1; - awt::Point aOldPos( xLabelGroupShape->getPosition() ); - basegfx::B2IVector aNewPos = basegfx::B2IVector( aOldPos.X, aOldPos.Y ) + nShift*aTangentialDirection; - - ///a final check is performed in order to be sure that the moved label - ///is still inside the page document; - awt::Point aNewAWTPos( aNewPos.getX(), aNewPos.getY() ); - if( !lcl_isInsidePage( aNewAWTPos, xLabelGroupShape->getSize(), rPageSize ) ) - return false; + if( aOverlap.isEmpty() ) + return true; + + //TODO: alternative move direction + + ///the label is shifted along the direction orthogonal to the vector + ///starting at the pie/donut center and ending at this label anchor + ///point; + + ///named `aTangentialDirection` the unit vector related to such a + ///direction, the magnitude of the shift along such a direction is + ///calculated in this way: if the horizontal component of + ///`aTangentialDirection` is greater than the vertical component, + ///the magnitude of the shift is equal to `aOverlap.Width` else to + ///`aOverlap.Height`; + basegfx::B2IVector aRadiusDirection = aFirstPosition - aOrigin; + aRadiusDirection.setLength(1.0); + basegfx::B2IVector aTangentialDirection( -aRadiusDirection.getY(), aRadiusDirection.getX() ); + bool bShiftHorizontal = abs(aTangentialDirection.getX()) > abs(aTangentialDirection.getY()); + sal_Int32 nShift = bShiftHorizontal ? static_cast<sal_Int32>(aOverlap.getWidth()) : static_cast<sal_Int32>(aOverlap.getHeight()); + ///the magnitude of the shift is also increased by 1/50-th of the width + ///or the height of the document page; + nShift += (bShiftHorizontal ? nLabelDistanceX : nLabelDistanceY); + ///in case the `bMoveHalfWay` parameter is true the magnitude of + ///the shift is halved. + if( bMoveHalfWay ) + nShift/=2; + ///in case the `bMoveClockwise` parameter is false the direction of + ///`aTangentialDirection` is reversed; + if(!bMoveClockwise) + nShift*=-1; + awt::Point aOldPos( xLabelGroupShape->getPosition() ); + basegfx::B2IVector aNewPos = basegfx::B2IVector( aOldPos.X, aOldPos.Y ) + nShift*aTangentialDirection; + + ///a final check is performed in order to be sure that the moved label + ///is still inside the page document; + awt::Point aNewAWTPos( aNewPos.getX(), aNewPos.getY() ); + if( !lcl_isInsidePage( aNewAWTPos, xLabelGroupShape->getSize(), rPageSize ) ) + return false; + + xLabelGroupShape->setPosition( aNewAWTPos ); + bMoved = true; - xLabelGroupShape->setPosition( aNewAWTPos ); - bMoved = true; - } return true; ///note that no further test is performed in order to check that the diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index 2387e297b54e..bc76dcf585ca 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -1684,39 +1684,38 @@ bool ChartView::getExplicitValuesForAxis( sal_Int32 nDimensionIndex=-1; sal_Int32 nAxisIndex=-1; - if( AxisHelper::getIndicesForAxis( xAxis, xCooSys, nDimensionIndex, nAxisIndex ) ) + if( !AxisHelper::getIndicesForAxis( xAxis, xCooSys, nDimensionIndex, nAxisIndex ) ) + return false; + + rExplicitScale = pVCooSys->getExplicitScale(nDimensionIndex,nAxisIndex); + rExplicitIncrement = pVCooSys->getExplicitIncrement(nDimensionIndex,nAxisIndex); + if( !rExplicitScale.m_bShiftedCategoryPosition ) + return true; + + //remove 'one' from max + if( rExplicitScale.AxisType == css::chart2::AxisType::DATE ) { - rExplicitScale = pVCooSys->getExplicitScale(nDimensionIndex,nAxisIndex); - rExplicitIncrement = pVCooSys->getExplicitIncrement(nDimensionIndex,nAxisIndex); - if( rExplicitScale.m_bShiftedCategoryPosition ) + Date aMaxDate(rExplicitScale.NullDate); aMaxDate.AddDays(::rtl::math::approxFloor(rExplicitScale.Maximum)); + //for explicit scales with shifted categories we need one interval more + switch( rExplicitScale.TimeResolution ) { - //remove 'one' from max - if( rExplicitScale.AxisType == css::chart2::AxisType::DATE ) - { - Date aMaxDate(rExplicitScale.NullDate); aMaxDate.AddDays(::rtl::math::approxFloor(rExplicitScale.Maximum)); - //for explicit scales with shifted categories we need one interval more - switch( rExplicitScale.TimeResolution ) - { - case css::chart::TimeUnit::DAY: - --aMaxDate; - break; - case css::chart::TimeUnit::MONTH: - aMaxDate = DateHelper::GetDateSomeMonthsAway(aMaxDate,-1); - break; - case css::chart::TimeUnit::YEAR: - aMaxDate = DateHelper::GetDateSomeYearsAway(aMaxDate,-1); - break; - } - rExplicitScale.Maximum = aMaxDate - rExplicitScale.NullDate; - } - else if( rExplicitScale.AxisType == css::chart2::AxisType::CATEGORY ) - rExplicitScale.Maximum -= 1.0; - else if( rExplicitScale.AxisType == css::chart2::AxisType::SERIES ) - rExplicitScale.Maximum -= 1.0; + case css::chart::TimeUnit::DAY: + --aMaxDate; + break; + case css::chart::TimeUnit::MONTH: + aMaxDate = DateHelper::GetDateSomeMonthsAway(aMaxDate,-1); + break; + case css::chart::TimeUnit::YEAR: + aMaxDate = DateHelper::GetDateSomeYearsAway(aMaxDate,-1); + break; } - return true; + rExplicitScale.Maximum = aMaxDate - rExplicitScale.NullDate; } - return false; + else if( rExplicitScale.AxisType == css::chart2::AxisType::CATEGORY ) + rExplicitScale.Maximum -= 1.0; + else if( rExplicitScale.AxisType == css::chart2::AxisType::SERIES ) + rExplicitScale.Maximum -= 1.0; + return true; } SdrPage* ChartView::getSdrPage() diff --git a/codemaker/source/cppumaker/cpputype.cxx b/codemaker/source/cppumaker/cpputype.cxx index 221fee39acfc..dab77fa42292 100644 --- a/codemaker/source/cppumaker/cpputype.cxx +++ b/codemaker/source/cppumaker/cpputype.cxx @@ -2088,33 +2088,33 @@ void PlainStructType::dumpComprehensiveGetCppuType(FileStream & out) bool PlainStructType::dumpBaseMembers( FileStream & out, OUString const & base, bool withType) { - bool hasMember = false; - if (!base.isEmpty()) { - rtl::Reference< unoidl::Entity > ent; - codemaker::UnoType::Sort sort = m_typeMgr->getSort(base, &ent); - if (sort != codemaker::UnoType::Sort::PlainStruct) { - throw CannotDumpException( - "plain struct type base " + base - + " is not a plain struct type"); - } - rtl::Reference< unoidl::PlainStructTypeEntity > ent2( - dynamic_cast< unoidl::PlainStructTypeEntity * >(ent.get())); - assert(ent2.is()); - if (!ent2.is()) { - return false; + if (base.isEmpty()) + return false; + + rtl::Reference< unoidl::Entity > ent; + codemaker::UnoType::Sort sort = m_typeMgr->getSort(base, &ent); + if (sort != codemaker::UnoType::Sort::PlainStruct) { + throw CannotDumpException( + "plain struct type base " + base + + " is not a plain struct type"); + } + rtl::Reference< unoidl::PlainStructTypeEntity > ent2( + dynamic_cast< unoidl::PlainStructTypeEntity * >(ent.get())); + assert(ent2.is()); + if (!ent2.is()) { + return false; + } + bool hasMember = dumpBaseMembers(out, ent2->getDirectBase(), withType); + for (const unoidl::PlainStructTypeEntity::Member& member : ent2->getDirectMembers()) { + if (hasMember) { + out << ", "; } - hasMember = dumpBaseMembers(out, ent2->getDirectBase(), withType); - for (const unoidl::PlainStructTypeEntity::Member& member : ent2->getDirectMembers()) { - if (hasMember) { - out << ", "; - } - if (withType) { - dumpType(out, member.type, true, true); - out << " "; - } - out << member.name << "_"; - hasMember = true; + if (withType) { + dumpType(out, member.type, true, true); + out << " "; } + out << member.name << "_"; + hasMember = true; } return hasMember; } @@ -3198,45 +3198,46 @@ void ExceptionType::dumpDeclaration(FileStream & out) bool ExceptionType::dumpBaseMembers( FileStream & out, OUString const & base, bool withType, bool eligibleForDefaults) { + if (base.isEmpty()) + return false; + bool hasMember = false; - if (!base.isEmpty()) { - rtl::Reference< unoidl::Entity > ent; - codemaker::UnoType::Sort sort = m_typeMgr->getSort(base, &ent); - if (sort != codemaker::UnoType::Sort::Exception) { - throw CannotDumpException( - "exception type base " + base + " is not an exception type"); + rtl::Reference< unoidl::Entity > ent; + codemaker::UnoType::Sort sort = m_typeMgr->getSort(base, &ent); + if (sort != codemaker::UnoType::Sort::Exception) { + throw CannotDumpException( + "exception type base " + base + " is not an exception type"); + } + rtl::Reference< unoidl::ExceptionTypeEntity > ent2( + dynamic_cast< unoidl::ExceptionTypeEntity * >(ent.get())); + assert(ent2.is()); + if (!ent2.is()) { + return false; + } + hasMember = dumpBaseMembers( out, ent2->getDirectBase(), withType, + eligibleForDefaults && ent2->getDirectMembers().empty() ); + int memberCount = 0; + for (const unoidl::ExceptionTypeEntity::Member& member : ent2->getDirectMembers()) { + if (hasMember) { + out << ", "; } - rtl::Reference< unoidl::ExceptionTypeEntity > ent2( - dynamic_cast< unoidl::ExceptionTypeEntity * >(ent.get())); - assert(ent2.is()); - if (!ent2.is()) { - return false; + if (withType) { + dumpType(out, member.type, true, true); + out << " "; } - hasMember = dumpBaseMembers( out, ent2->getDirectBase(), withType, - eligibleForDefaults && ent2->getDirectMembers().empty() ); - int memberCount = 0; - for (const unoidl::ExceptionTypeEntity::Member& member : ent2->getDirectMembers()) { - if (hasMember) { - out << ", "; - } - if (withType) { - dumpType(out, member.type, true, true); - out << " "; - } - out << member.name << "_"; - // We want to provide a default parameter value for uno::Exception subtype - // constructors, since most of the time we don't pass a Context object in to the exception - // throw sites. - if (eligibleForDefaults - && base == "com.sun.star.uno.Exception" - && memberCount == 1 - && member.name == "Context" - && member.type == "com.sun.star.uno.XInterface") { - out << " = ::css::uno::Reference< ::css::uno::XInterface >()"; - } - hasMember = true; - ++memberCount; + out << member.name << "_"; + // We want to provide a default parameter value for uno::Exception subtype + // constructors, since most of the time we don't pass a Context object in to the exception + // throw sites. + if (eligibleForDefaults + && base == "com.sun.star.uno.Exception" + && memberCount == 1 + && member.name == "Context" + && member.type == "com.sun.star.uno.XInterface") { + out << " = ::css::uno::Reference< ::css::uno::XInterface >()"; } + hasMember = true; + ++memberCount; } return hasMember; } diff --git a/comphelper/source/container/embeddedobjectcontainer.cxx b/comphelper/source/container/embeddedobjectcontainer.cxx index ac85e9cfdc70..2d85b73f44ba 100644 --- a/comphelper/source/container/embeddedobjectcontainer.cxx +++ b/comphelper/source/container/embeddedobjectcontainer.cxx @@ -135,31 +135,31 @@ void EmbeddedObjectContainer::SwitchPersistence( const uno::Reference < embed::X bool EmbeddedObjectContainer::CommitImageSubStorage() { - if ( pImpl->mxImageStorage.is() ) + if ( !pImpl->mxImageStorage ) + return true; + + try { - try + bool bReadOnlyMode = true; + uno::Reference < beans::XPropertySet > xSet(pImpl->mxImageStorage,uno::UNO_QUERY); + if ( xSet.is() ) { - bool bReadOnlyMode = true; - uno::Reference < beans::XPropertySet > xSet(pImpl->mxImageStorage,uno::UNO_QUERY); - if ( xSet.is() ) - { - // get the open mode from the parent storage - sal_Int32 nMode = 0; - uno::Any aAny = xSet->getPropertyValue("OpenMode"); - if ( aAny >>= nMode ) - bReadOnlyMode = !(nMode & embed::ElementModes::WRITE ); - } // if ( xSet.is() ) - if ( !bReadOnlyMode ) - { - uno::Reference< embed::XTransactedObject > xTransact( pImpl->mxImageStorage, uno::UNO_QUERY_THROW ); - xTransact->commit(); - } - } - catch (const uno::Exception&) + // get the open mode from the parent storage + sal_Int32 nMode = 0; + uno::Any aAny = xSet->getPropertyValue("OpenMode"); + if ( aAny >>= nMode ) + bReadOnlyMode = !(nMode & embed::ElementModes::WRITE ); + } // if ( xSet.is() ) + if ( !bReadOnlyMode ) { - return false; + uno::Reference< embed::XTransactedObject > xTransact( pImpl->mxImageStorage, uno::UNO_QUERY_THROW ); + xTransact->commit(); } } + catch (const uno::Exception&) + { + return false; + } return true; } @@ -969,26 +969,26 @@ bool EmbeddedObjectContainer::RemoveEmbeddedObject( const uno::Reference < embed else SAL_WARN( "comphelper.container", "Object not found for removal!" ); - if ( xPersist.is() && bKeepToTempStorage ) // #i119941# - { - // remove replacement image (if there is one) - RemoveGraphicStream( aName ); + if ( !xPersist || !bKeepToTempStorage ) // #i119941# + return true; - // now it's time to remove the storage from the container storage - try - { + // remove replacement image (if there is one) + RemoveGraphicStream( aName ); + + // now it's time to remove the storage from the container storage + try + { #if OSL_DEBUG_LEVEL > 1 - // if the object has a persistence and the object is not a link than it must have persistence entry in storage - OSL_ENSURE( bIsNotEmbedded || pImpl->mxStorage->hasByName( aName ), "The object has no persistence entry in the storage!" ); + // if the object has a persistence and the object is not a link than it must have persistence entry in storage + OSL_ENSURE( bIsNotEmbedded || pImpl->mxStorage->hasByName( aName ), "The object has no persistence entry in the storage!" ); #endif - if ( xPersist.is() && pImpl->mxStorage->hasByName( aName ) ) - pImpl->mxStorage->removeElement( aName ); - } - catch (const uno::Exception&) - { - SAL_WARN( "comphelper.container", "Failed to remove object from storage!" ); - return false; - } + if ( xPersist.is() && pImpl->mxStorage->hasByName( aName ) ) + pImpl->mxStorage->removeElement( aName ); + } + catch (const uno::Exception&) + { + SAL_WARN( "comphelper.container", "Failed to remove object from storage!" ); + return false; } return true; diff --git a/comphelper/source/misc/backupfilehelper.cxx b/comphelper/source/misc/backupfilehelper.cxx index d03662381939..c091ee7ab06b 100644 --- a/comphelper/source/misc/backupfilehelper.cxx +++ b/comphelper/source/misc/backupfilehelper.cxx @@ -806,197 +806,191 @@ namespace bool copy_content_straight(oslFileHandle& rTargetHandle) { - if (maFile && osl::File::E_None == maFile->open(osl_File_OpenFlag_Read)) - { - sal_uInt8 aArray[BACKUP_FILE_HELPER_BLOCK_SIZE]; - sal_uInt64 nBytesTransfer(0); - sal_uInt64 nSize(getPackFileSize()); + if (!maFile || osl::File::E_None != maFile->open(osl_File_OpenFlag_Read)) + return false; - // set offset in source file - when this is zero, a new file is to be added - if (osl::File::E_None == maFile->setPos(osl_Pos_Absolut, sal_Int64(getOffset()))) - { - while (nSize != 0) - { - const sal_uInt64 nToTransfer(std::min(nSize, sal_uInt64(BACKUP_FILE_HELPER_BLOCK_SIZE))); + sal_uInt8 aArray[BACKUP_FILE_HELPER_BLOCK_SIZE]; + sal_uInt64 nBytesTransfer(0); + sal_uInt64 nSize(getPackFileSize()); - if (osl::File::E_None != maFile->read(static_cast<void*>(aArray), nToTransfer, nBytesTransfer) || nBytesTransfer != nToTransfer) - { - break; - } + // set offset in source file - when this is zero, a new file is to be added + if (osl::File::E_None == maFile->setPos(osl_Pos_Absolut, sal_Int64(getOffset()))) + { + while (nSize != 0) + { + const sal_uInt64 nToTransfer(std::min(nSize, sal_uInt64(BACKUP_FILE_HELPER_BLOCK_SIZE))); - if (osl_File_E_None != osl_writeFile(rTargetHandle, static_cast<const void*>(aArray), nToTransfer, &nBytesTransfer) || nBytesTransfer != nToTransfer) - { - break; - } + if (osl::File::E_None != maFile->read(static_cast<void*>(aArray), nToTransfer, nBytesTransfer) || nBytesTransfer != nToTransfer) + { + break; + } - nSize -= nToTransfer; + if (osl_File_E_None != osl_writeFile(rTargetHandle, static_cast<const void*>(aArray), nToTransfer, &nBytesTransfer) || nBytesTransfer != nToTransfer) + { + break; } - } - maFile->close(); - return (0 == nSize); + nSize -= nToTransfer; + } } - return false; + maFile->close(); + return (0 == nSize); } bool copy_content_compress(oslFileHandle& rTargetHandle) { - if (maFile && osl::File::E_None == maFile->open(osl_File_OpenFlag_Read)) - { - sal_uInt8 aArray[BACKUP_FILE_HELPER_BLOCK_SIZE]; - sal_uInt8 aBuffer[BACKUP_FILE_HELPER_BLOCK_SIZE]; - sal_uInt64 nBytesTransfer(0); - sal_uInt64 nSize(getPackFileSize()); - z_stream zstream; - memset(&zstream, 0, sizeof(zstream)); + if (!maFile || osl::File::E_None != maFile->open(osl_File_OpenFlag_Read)) + return false; - if (Z_OK == deflateInit(&zstream, Z_BEST_COMPRESSION)) + sal_uInt8 aArray[BACKUP_FILE_HELPER_BLOCK_SIZE]; + sal_uInt8 aBuffer[BACKUP_FILE_HELPER_BLOCK_SIZE]; + sal_uInt64 nBytesTransfer(0); + sal_uInt64 nSize(getPackFileSize()); + z_stream zstream; + memset(&zstream, 0, sizeof(zstream)); + + if (Z_OK == deflateInit(&zstream, Z_BEST_COMPRESSION)) + { + // set offset in source file - when this is zero, a new file is to be added + if (osl::File::E_None == maFile->setPos(osl_Pos_Absolut, sal_Int64(getOffset()))) { - // set offset in source file - when this is zero, a new file is to be added - if (osl::File::E_None == maFile->setPos(osl_Pos_Absolut, sal_Int64(getOffset()))) + bool bOkay(true); + + while (bOkay && nSize != 0) { - bool bOkay(true); + const sal_uInt64 nToTransfer(std::min(nSize, sal_uInt64(BACKUP_FILE_HELPER_BLOCK_SIZE))); - while (bOkay && nSize != 0) + if (osl::File::E_None != maFile->read(static_cast<void*>(aArray), nToTransfer, nBytesTransfer) || nBytesTransfer != nToTransfer) { - const sal_uInt64 nToTransfer(std::min(nSize, sal_uInt64(BACKUP_FILE_HELPER_BLOCK_SIZE))); - - if (osl::File::E_None != maFile->read(static_cast<void*>(aArray), nToTransfer, nBytesTransfer) || nBytesTransfer != nToTransfer) - { - break; - } + break; + } - zstream.avail_in = nToTransfer; - zstream.next_in = reinterpret_cast<unsigned char*>(aArray); + zstream.avail_in = nToTransfer; + zstream.next_in = reinterpret_cast<unsigned char*>(aArray); - do { - zstream.avail_out = BACKUP_FILE_HELPER_BLOCK_SIZE; - zstream.next_out = reinterpret_cast<unsigned char*>(aBuffer); + do { + zstream.avail_out = BACKUP_FILE_HELPER_BLOCK_SIZE; + zstream.next_out = reinterpret_cast<unsigned char*>(aBuffer); #if !defined Z_PREFIX - const sal_Int64 nRetval(deflate(&zstream, nSize == nToTransfer ? Z_FINISH : Z_NO_FLUSH)); + const sal_Int64 nRetval(deflate(&zstream, nSize == nToTransfer ? Z_FINISH : Z_NO_FLUSH)); #else - const sal_Int64 nRetval(z_deflate(&zstream, nSize == nToTransfer ? Z_FINISH : Z_NO_FLUSH)); + const sal_Int64 nRetval(z_deflate(&zstream, nSize == nToTransfer ? Z_FINISH : Z_NO_FLUSH)); #endif - if (Z_STREAM_ERROR == nRetval) + if (Z_STREAM_ERROR == nRetval) + { + bOkay = false; + } + else + { + const sal_uInt64 nAvailable(BACKUP_FILE_HELPER_BLOCK_SIZE - zstream.avail_out); + + if (osl_File_E_None != osl_writeFile(rTargetHandle, static_cast<const void*>(aBuffer), nAvailable, &nBytesTransfer) || nBytesTransfer != nAvailable) { bOkay = false; } - else - { - const sal_uInt64 nAvailable(BACKUP_FILE_HELPER_BLOCK_SIZE - zstream.avail_out); - - if (osl_File_E_None != osl_writeFile(rTargetHandle, static_cast<const void*>(aBuffer), nAvailable, &nBytesTransfer) || nBytesTransfer != nAvailable) - { - bOkay = false; - } - } - } while (bOkay && 0 == zstream.avail_out); - - if (!bOkay) - { - break; } + } while (bOkay && 0 == zstream.avail_out); - nSize -= nToTransfer; + if (!bOkay) + { + break; } + nSize -= nToTransfer; + } + #if !defined Z_PREFIX - deflateEnd(&zstream); + deflateEnd(&zstream); #else - z_deflateEnd(&zstream); + z_deflateEnd(&zstream); #endif - } } + } - maFile->close(); + maFile->close(); - // get compressed size and add to entry - if (mnFullFileSize == mnPackFileSize && mnFullFileSize == zstream.total_in) - { - mnPackFileSize = zstream.total_out; - } - - return (0 == nSize); + // get compressed size and add to entry + if (mnFullFileSize == mnPackFileSize && mnFullFileSize == zstream.total_in) + { + mnPackFileSize = zstream.total_out; } - return false; + return (0 == nSize); } bool copy_content_uncompress(oslFileHandle& rTargetHandle) { - if (maFile && osl::File::E_None == maFile->open(osl_File_OpenFlag_Read)) - { - sal_uInt8 aArray[BACKUP_FILE_HELPER_BLOCK_SIZE]; - sal_uInt8 aBuffer[BACKUP_FILE_HELPER_BLOCK_SIZE]; - sal_uInt64 nBytesTransfer(0); - sal_uInt64 nSize(getPackFileSize()); - z_stream zstream; - memset(&zstream, 0, sizeof(zstream)); + if (!maFile || osl::File::E_None != maFile->open(osl_File_OpenFlag_Read)) + return false; - if (Z_OK == inflateInit(&zstream)) + sal_uInt8 aArray[BACKUP_FILE_HELPER_BLOCK_SIZE]; + sal_uInt8 aBuffer[BACKUP_FILE_HELPER_BLOCK_SIZE]; + sal_uInt64 nBytesTransfer(0); + sal_uInt64 nSize(getPackFileSize()); + z_stream zstream; + memset(&zstream, 0, sizeof(zstream)); + + if (Z_OK == inflateInit(&zstream)) + { + // set offset in source file - when this is zero, a new file is to be added + if (osl::File::E_None == maFile->setPos(osl_Pos_Absolut, sal_Int64(getOffset()))) { - // set offset in source file - when this is zero, a new file is to be added - if (osl::File::E_None == maFile->setPos(osl_Pos_Absolut, sal_Int64(getOffset()))) + bool bOkay(true); + + while (bOkay && nSize != 0) { - bool bOkay(true); + const sal_uInt64 nToTransfer(std::min(nSize, sal_uInt64(BACKUP_FILE_HELPER_BLOCK_SIZE))); - while (bOkay && nSize != 0) + if (osl::File::E_None != maFile->read(static_cast<void*>(aArray), nToTransfer, nBytesTransfer) || nBytesTransfer != nToTransfer) { - const sal_uInt64 nToTransfer(std::min(nSize, sal_uInt64(BACKUP_FILE_HELPER_BLOCK_SIZE))); - - if (osl::File::E_None != maFile->read(static_cast<void*>(aArray), nToTransfer, nBytesTransfer) || nBytesTransfer != nToTransfer) - { - break; - } + break; + } - zstream.avail_in = nToTransfer; - zstream.next_in = reinterpret_cast<unsigned char*>(aArray); + zstream.avail_in = nToTransfer; + zstream.next_in = reinterpret_cast<unsigned char*>(aArray); - do { - zstream.avail_out = BACKUP_FILE_HELPER_BLOCK_SIZE; - zstream.next_out = reinterpret_cast<unsigned char*>(aBuffer); + do { + zstream.avail_out = BACKUP_FILE_HELPER_BLOCK_SIZE; + zstream.next_out = reinterpret_cast<unsigned char*>(aBuffer); #if !defined Z_PREFIX - const sal_Int64 nRetval(inflate(&zstream, Z_NO_FLUSH)); + const sal_Int64 nRetval(inflate(&zstream, Z_NO_FLUSH)); #else - const sal_Int64 nRetval(z_inflate(&zstream, Z_NO_FLUSH)); + const sal_Int64 nRetval(z_inflate(&zstream, Z_NO_FLUSH)); #endif - if (Z_STREAM_ERROR == nRetval) + if (Z_STREAM_ERROR == nRetval) + { + bOkay = false; + } + else + { + const sal_uInt64 nAvailable(BACKUP_FILE_HELPER_BLOCK_SIZE - zstream.avail_out); + + if (osl_File_E_None != osl_writeFile(rTargetHandle, static_cast<const void*>(aBuffer), nAvailable, &nBytesTransfer) || nBytesTransfer != nAvailable) { bOkay = false; } - else - { - const sal_uInt64 nAvailable(BACKUP_FILE_HELPER_BLOCK_SIZE - zstream.avail_out); - - if (osl_File_E_None != osl_writeFile(rTargetHandle, static_cast<const void*>(aBuffer), nAvailable, &nBytesTransfer) || nBytesTransfer != nAvailable) - { - bOkay = false; - } - } - } while (bOkay && 0 == zstream.avail_out); - - if (!bOkay) - { - break; } + } while (bOkay && 0 == zstream.avail_out); - nSize -= nToTransfer; + if (!bOkay) + { + break; } + nSize -= nToTransfer; + } + #if !defined Z_PREFIX - deflateEnd(&zstream); + deflateEnd(&zstream); #else - z_deflateEnd(&zstream); + z_deflateEnd(&zstream); #endif - } } - - maFile->close(); - return (0 == nSize); } - return false; + maFile->close(); + return (0 == nSize); } @@ -1421,26 +1415,24 @@ namespace bool tryPop(oslFileHandle& rHandle) { - if (!maPackedFileEntryVector.empty()) - { - // already backups there, check if different from last entry - PackedFileEntry& aLastEntry = maPackedFileEntryVector.back(); + if (maPackedFileEntryVector.empty()) + return false; - // here the uncompress flag has to be determined, true - // means to add the file compressed, false means to add it - // uncompressed - bool bRetval = aLastEntry.copy_content(rHandle, true); + // already backups there, check if different from last entry + PackedFileEntry& aLastEntry = maPackedFileEntryVector.back(); - if (bRetval) - { - maPackedFileEntryVector.pop_back(); - mbChanged = true; - } + // here the uncompress flag has to be determined, true + // means to add the file compressed, false means to add it + // uncompressed + bool bRetval = aLastEntry.copy_content(rHandle, true); - return bRetval; + if (bRetval) + { + maPackedFileEntryVector.pop_back(); + mbChanged = true; } - return false; + return bRetval; } void tryReduceToNumBackups(sal_uInt16 nNumBackups) @@ -2227,46 +2219,44 @@ namespace comphelper { const OUString aFileURL(createFileURL(rSourceURL, rName, rExt)); - if (DirectoryHelper::fileExists(aFileURL)) - { - // try Pop for base file - const OUString aPackURL(createPackURL(rTargetURL, rName)); - PackedFile aPackedFile(aPackURL); + if (!DirectoryHelper::fileExists(aFileURL)) + return false; - if (!aPackedFile.empty()) - { - oslFileHandle aHandle; - OUString aTempURL; + // try Pop for base file + const OUString aPackURL(createPackURL(rTargetURL, rName)); + PackedFile aPackedFile(aPackURL); - // open target temp file - it exists until deleted - if (osl::File::E_None == osl::FileBase::createTempFile(nullptr, &aHandle, &aTempURL)) - { - bool bRetval(aPackedFile.tryPop(aHandle)); + if (aPackedFile.empty()) + return false; - // close temp file (in all cases) - it exists until deleted - osl_closeFile(aHandle); + oslFileHandle aHandle; + OUString aTempURL; - if (bRetval) - { - // copy over existing file by first deleting original - // and moving the temp file to old original - osl::File::remove(aFileURL); - osl::File::move(aTempURL, aFileURL); - - // reduce to allowed number and flush - aPackedFile.tryReduceToNumBackups(mnNumBackups); - aPackedFile.flush(); - } + // open target temp file - it exists until deleted + if (osl::File::E_None != osl::FileBase::createTempFile(nullptr, &aHandle, &aTempURL)) + return false; - // delete temp file (in all cases - it may be moved already) - osl::File::remove(aTempURL); + bool bRetval(aPackedFile.tryPop(aHandle)); - return bRetval; - } - } + // close temp file (in all cases) - it exists until deleted + osl_closeFile(aHandle); + + if (bRetval) + { + // copy over existing file by first deleting original + // and moving the temp file to old original + osl::File::remove(aFileURL); + osl::File::move(aTempURL, aFileURL); + + // reduce to allowed number and flush + aPackedFile.tryReduceToNumBackups(mnNumBackups); + aPackedFile.flush(); } - return false; + // delete temp file (in all cases - it may be moved already) + osl::File::remove(aTempURL); + + return bRetval; } /////////////////// ExtensionInfo helpers /////////////////////// @@ -2319,103 +2309,101 @@ namespace comphelper const OUString aPackURL(createPackURL(rTargetURL, u"ExtensionInfo")); PackedFile aPackedFile(aPackURL); - if (!aPackedFile.empty()) - { - oslFileHandle aHandle; - OUString aTempURL; + if (aPackedFile.empty()) + return false; - // open target temp file - it exists until deleted - if (osl::File::E_None == osl::FileBase::createTempFile(nullptr, &aHandle, &aTempURL)) - { - bool bRetval(aPackedFile.tryPop(aHandle)); + oslFileHandle aHandle; + OUString aTempURL; - // close temp file (in all cases) - it exists until deleted - osl_closeFile(aHandle); + // open target temp file - it exists until deleted + if (osl::File::E_None != osl::FileBase::createTempFile(nullptr, &aHandle, &aTempURL)) + return false; - if (bRetval) - { - // last config is in temp file, load it to ExtensionInfo - ExtensionInfo aLoadedExtensionInfo; - FileSharedPtr aBaseFile = std::make_shared<osl::File>(aTempURL); + bool bRetval(aPackedFile.tryPop(aHandle)); - if (osl::File::E_None == aBaseFile->open(osl_File_OpenFlag_Read)) - { - if (aLoadedExtensionInfo.read_entries(aBaseFile)) - { - // get current extension info, but from XML config files - ExtensionInfo aCurrentExtensionInfo; + // close temp file (in all cases) - it exists until deleted + osl_closeFile(aHandle); - aCurrentExtensionInfo.createUserExtensionRegistryEntriesFromXML(maUserConfigWorkURL); + if (bRetval) + { + // last config is in temp file, load it to ExtensionInfo + ExtensionInfo aLoadedExtensionInfo; + FileSharedPtr aBaseFile = std::make_shared<osl::File>(aTempURL); - // now we have loaded last_working (aLoadedExtensionInfo) and - // current (aCurrentExtensionInfo) ExtensionInfo and may react on - // differences by de/activating these as needed - const ExtensionInfoEntryVector& aUserEntries = aCurrentExtensionInfo.getExtensionInfoEntryVector(); - const ExtensionInfoEntryVector& rLoadedVector = aLoadedExtensionInfo.getExtensionInfoEntryVector(); - ExtensionInfoEntryVector aToBeDisabled; - ExtensionInfoEntryVector aToBeEnabled; + if (osl::File::E_None == aBaseFile->open(osl_File_OpenFlag_Read)) + { + if (aLoadedExtensionInfo.read_entries(aBaseFile)) + { + // get current extension info, but from XML config files + ExtensionInfo aCurrentExtensionInfo; - for (const auto& rCurrentInfo : aUserEntries) - { - const ExtensionInfoEntry* pLoadedInfo = nullptr; + aCurrentExtensionInfo.createUserExtensionRegistryEntriesFromXML(maUserConfigWorkURL); - for (const auto& rLoadedInfo : rLoadedVector) - { - if (rCurrentInfo.isSameExtension(rLoadedInfo)) - { - pLoadedInfo = &rLoadedInfo; - break; - } - } + // now we have loaded last_working (aLoadedExtensionInfo) and + // current (aCurrentExtensionInfo) ExtensionInfo and may react on + // differences by de/activating these as needed + const ExtensionInfoEntryVector& aUserEntries = aCurrentExtensionInfo.getExtensionInfoEntryVector(); + const ExtensionInfoEntryVector& rLoadedVector = aLoadedExtensionInfo.getExtensionInfoEntryVector(); + ExtensionInfoEntryVector aToBeDisabled; + ExtensionInfoEntryVector aToBeEnabled; - if (nullptr != pLoadedInfo) - { - // loaded info contains information about the Extension rCurrentInfo - const bool bCurrentEnabled(rCurrentInfo.isEnabled()); - const bool bLoadedEnabled(pLoadedInfo->isEnabled()); + for (const auto& rCurrentInfo : aUserEntries) + { + const ExtensionInfoEntry* pLoadedInfo = nullptr; - if (bCurrentEnabled && !bLoadedEnabled) - { - aToBeDisabled.push_back(rCurrentInfo); - } - else if (!bCurrentEnabled && bLoadedEnabled) - { - aToBeEnabled.push_back(rCurrentInfo); - } - } - else - { - // There is no loaded info about the Extension rCurrentInfo. - // It needs to be disabled - if (rCurrentInfo.isEnabled()) - { - aToBeDisabled.push_back(rCurrentInfo); - } - } + for (const auto& rLoadedInfo : rLoadedVector) + { + if (rCurrentInfo.isSameExtension(rLoadedInfo)) + { + pLoadedInfo = &rLoadedInfo; + break; } + } - if (!aToBeDisabled.empty() || !aToBeEnabled.empty()) + if (nullptr != pLoadedInfo) + { + // loaded info contains information about the Extension rCurrentInfo + const bool bCurrentEnabled(rCurrentInfo.isEnabled()); + const bool bLoadedEnabled(pLoadedInfo->isEnabled()); + + if (bCurrentEnabled && !bLoadedEnabled) { - ExtensionInfo::changeEnableDisableStateInXML(maUserConfigWorkURL, aToBeEnabled, aToBeDisabled); + aToBeDisabled.push_back(rCurrentInfo); + } + else if (!bCurrentEnabled && bLoadedEnabled) + { + aToBeEnabled.push_back(rCurrentInfo); + } + } + else + { + // There is no loaded info about the Extension rCurrentInfo. + // It needs to be disabled + if (rCurrentInfo.isEnabled()) + { + aToBeDisabled.push_back(rCurrentInfo); } - - bRetval = true; } } - // reduce to allowed number and flush - aPackedFile.tryReduceToNumBackups(mnNumBackups); - aPackedFile.flush(); - } - - // delete temp file (in all cases - it may be moved already) - osl::File::remove(aTempURL); + if (!aToBeDisabled.empty() || !aToBeEnabled.empty()) + { + ExtensionInfo::changeEnableDisableStateInXML(maUserConfigWorkURL, aToBeEnabled, aToBeDisabled); + } - return bRetval; + bRetval = true; + } } + + // reduce to allowed number and flush + aPackedFile.tryReduceToNumBackups(mnNumBackups); + aPackedFile.flush(); } - return false; + // delete temp file (in all cases - it may be moved already) + osl::File::remove(aTempURL); + + return bRetval; } /////////////////// FileDirInfo helpers /////////////////////// diff --git a/comphelper/source/misc/namedvaluecollection.cxx b/comphelper/source/misc/namedvaluecollection.cxx index c56e6979a3a0..574f8e0a1898 100644 --- a/comphelper/source/misc/namedvaluecollection.cxx +++ b/comphelper/source/misc/namedvaluecollection.cxx @@ -179,28 +179,26 @@ namespace comphelper bool NamedValueCollection::get_ensureType( const OUString& _rValueName, void* _pValueLocation, const Type& _rExpectedValueType ) const { auto pos = maValues.find( _rValueName ); - if ( pos != maValues.end() ) - { - if ( uno_type_assignData( - _pValueLocation, _rExpectedValueType.getTypeLibType(), - const_cast< void* >( pos->second.getValue() ), pos->second.getValueType().getTypeLibType(), - reinterpret_cast< uno_QueryInterfaceFunc >( cpp_queryInterface ), - reinterpret_cast< uno_AcquireFunc >( cpp_acquire ), - reinterpret_cast< uno_ReleaseFunc >( cpp_release ) - ) ) - // argument exists, and could be extracted - return true; - - // argument exists, but is of wrong type - throw IllegalArgumentException( - "Invalid value type for '" + _rValueName - + "'.\nExpected: " + _rExpectedValueType.getTypeName() - + "\nFound: " + pos->second.getValueType().getTypeName(), - nullptr, 0 ); - } + if ( pos == maValues.end() ) + // argument does not exist + return false; - // argument does not exist - return false; + if ( uno_type_assignData( + _pValueLocation, _rExpectedValueType.getTypeLibType(), + const_cast< void* >( pos->second.getValue() ), pos->second.getValueType().getTypeLibType(), + reinterpret_cast< uno_QueryInterfaceFunc >( cpp_queryInterface ), + reinterpret_cast< uno_AcquireFunc >( cpp_acquire ), + reinterpret_cast< uno_ReleaseFunc >( cpp_release ) + ) ) + // argument exists, and could be extracted + return true; + + // argument exists, but is of wrong type + throw IllegalArgumentException( + "Invalid value type for '" + _rValueName + + "'.\nExpected: " + _rExpectedValueType.getTypeName() + + "\nFound: " + pos->second.getValueType().getTypeName(), + nullptr, 0 ); } const Any& NamedValueCollection::impl_get( const OUString& _rValueName ) const diff --git a/comphelper/source/officeinstdir/officeinstallationdirectories.cxx b/comphelper/source/officeinstdir/officeinstallationdirectories.cxx index 385f61680e1c..de6b284c5f68 100644 --- a/comphelper/source/officeinstdir/officeinstallationdirectories.cxx +++ b/comphelper/source/officeinstdir/officeinstallationdirectories.cxx @@ -44,30 +44,30 @@ static bool makeCanonicalFileURL( OUString & rURL ) if ( osl::FileBase::getAbsoluteFileURL( OUString(), rURL, aNormalizedURL ) + != osl::DirectoryItem::E_None ) + return false; + + osl::DirectoryItem aDirItem; + if ( osl::DirectoryItem::get( aNormalizedURL, aDirItem ) + != osl::DirectoryItem::E_None ) + return false; + + osl::FileStatus aFileStatus( osl_FileStatus_Mask_FileURL ); + + if ( aDirItem.getFileStatus( aFileStatus ) == osl::DirectoryItem::E_None ) { - osl::DirectoryItem aDirItem; - if ( osl::DirectoryItem::get( aNormalizedURL, aDirItem ) - == osl::DirectoryItem::E_None ) + aNormalizedURL = aFileStatus.getFileURL(); + + if ( !aNormalizedURL.isEmpty() ) { - osl::FileStatus aFileStatus( osl_FileStatus_Mask_FileURL ); + if ( !aNormalizedURL.endsWith("/") ) + rURL = aNormalizedURL; + else + rURL = aNormalizedURL + .copy( 0, aNormalizedURL.getLength() - 1 ); - if ( aDirItem.getFileStatus( aFileStatus ) - == osl::DirectoryItem::E_None ) - { - aNormalizedURL = aFileStatus.getFileURL(); - - if ( !aNormalizedURL.isEmpty() ) - { - if ( !aNormalizedURL.endsWith("/") ) - rURL = aNormalizedURL; - else - rURL = aNormalizedURL - .copy( 0, aNormalizedURL.getLength() - 1 ); - - return true; - } - } + return true; } } return false; diff --git a/configmgr/source/valueparser.cxx b/configmgr/source/valueparser.cxx index a70c3231b702..82778e6c823b 100644 --- a/configmgr/source/valueparser.cxx +++ b/configmgr/source/valueparser.cxx @@ -252,22 +252,23 @@ ValueParser::ValueParser(int layer): type_(TYPE_ERROR), layer_(layer), state_() ValueParser::~ValueParser() {} xmlreader::XmlReader::Text ValueParser::getTextMode() const { - if (node_.is()) { - switch (state_) { - case State::Text: - if (!items_.empty()) { - break; - } - [[fallthrough]]; - case State::IT: - return - (type_ == TYPE_STRING || type_ == TYPE_STRING_LIST || - !separator_.isEmpty()) - ? xmlreader::XmlReader::Text::Raw - : xmlreader::XmlReader::Text::Normalized; - default: + if (!node_) + return xmlreader::XmlReader::Text::NONE; + + switch (state_) { + case State::Text: + if (!items_.empty()) { break; } + [[fallthrough]]; + case State::IT: + return + (type_ == TYPE_STRING || type_ == TYPE_STRING_LIST || + !separator_.isEmpty()) + ? xmlreader::XmlReader::Text::Raw + : xmlreader::XmlReader::Text::Normalized; + default: + break; } return xmlreader::XmlReader::Text::NONE; } diff --git a/connectivity/source/drivers/calc/CDatabaseMetaData.cxx b/connectivity/source/drivers/calc/CDatabaseMetaData.cxx index 31798f5bafd0..159349cacd6f 100644 --- a/connectivity/source/drivers/calc/CDatabaseMetaData.cxx +++ b/connectivity/source/drivers/calc/CDatabaseMetaData.cxx @@ -59,37 +59,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; } } diff --git a/connectivity/source/drivers/calc/CTable.cxx b/connectivity/source/drivers/calc/CTable.cxx index 8e37cdd99071..90e7c4e08bed 100644 --- a/connectivity/source/drivers/calc/CTable.cxx +++ b/connectivity/source/drivers/calc/CTable.cxx @@ -191,24 +191,23 @@ static bool lcl_HasTextInColumn( const Reference<XSpreadsheet>& xSheet, sal_Int3 // look for any text cell or text result in the column 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()) - { - // are there text cells in the column? - Reference<XSheetCellRanges> xTextContent = xQuery->queryContentCells( CellFlags::STRING ); - if ( xTextContent.is() && xTextContent->hasElements() ) - return true; - - // are there formulas with text results in the column? - Reference<XSheetCellRanges> xTextFormula = xQuery->queryFormulaCells( FormulaResult::STRING ); - if ( xTextFormula.is() && xTextFormula->hasElements() ) - return true; - } - } + if (!xAddr) + return false; + CellRangeAddress aTotalRange = xAddr->getRangeAddress(); + sal_Int32 nLastRow = aTotalRange.EndRow; + Reference<XCellRangesQuery> xQuery( xSheet->getCellRangeByPosition( nDocColumn, nDocRow, nDocColumn, nLastRow ), UNO_QUERY ); + if (!xQuery) + return false; + + // are there text cells in the column? + Reference<XSheetCellRanges> xTextContent = xQuery->queryContentCells( CellFlags::STRING ); + if ( xTextContent.is() && xTextContent->hasElements() ) + return true; + + // are there formulas with text results in the column? + Reference<XSheetCellRanges> xTextFormula = xQuery->queryFormulaCells( FormulaResult::STRING ); + if ( xTextFormula.is() && xTextFormula->hasElements() ) + return true; return false; } diff --git a/connectivity/source/drivers/firebird/ResultSetMetaData.cxx b/connectivity/source/drivers/firebird/ResultSetMetaData.cxx index 2ed46bae9b34..78d684a725a2 100644 --- a/connectivity/source/drivers/firebird/ResultSetMetaData.cxx +++ b/connectivity/source/drivers/firebird/ResultSetMetaData.cxx @@ -184,34 +184,34 @@ sal_Bool SAL_CALL OResultSetMetaData::isCurrency(sal_Int32) sal_Bool SAL_CALL OResultSetMetaData::isAutoIncrement(sal_Int32 column) { OUString sTable = getTableName(column); - if( !sTable.isEmpty() ) - { - OUString sColumnName = getColumnName( column ); + if( sTable.isEmpty() ) + return false; - OUString sSql = "SELECT RDB$IDENTITY_TYPE FROM RDB$RELATION_FIELDS " - "WHERE RDB$RELATION_NAME = '" - + escapeWith(sTable, '\'', '\'') + "' AND " - "RDB$FIELD_NAME = '"+ escapeWith(sColumnName, '\'', '\'') +"'"; + OUString sColumnName = getColumnName( column ); - Reference<XStatement> xStmt =m_pConnection ->createStatement(); + OUString sSql = "SELECT RDB$IDENTITY_TYPE FROM RDB$RELATION_FIELDS " + "WHERE RDB$RELATION_NAME = '" + + escapeWith(sTable, '\'', '\'') + "' AND " + "RDB$FIELD_NAME = '"+ escapeWith(sColumnName, '\'', '\'') +"'"; - Reference<XResultSet> xRes = - xStmt->executeQuery(sSql); - Reference<XRow> xRow ( xRes, UNO_QUERY); - if(xRes->next()) - { - int iType = xRow->getShort(1); - if(iType == 1) // IDENTITY - return true; - } - else - { - SAL_WARN("connectivity.firebird","Column '" - << sColumnName - << "' not found in database"); + Reference<XStatement> xStmt =m_pConnection ->createStatement(); - return false; - } + Reference<XResultSet> xRes = + xStmt->executeQuery(sSql); + Reference<XRow> xRow ( xRes, UNO_QUERY); + if(xRes->next()) + { + int iType = xRow->getShort(1); + if(iType == 1) // IDENTITY + return true; + } + else + { + SAL_WARN("connectivity.firebird","Column '" + << sColumnName + << "' not found in database"); + + return false; } return false; } @@ -226,34 +226,34 @@ sal_Bool SAL_CALL OResultSetMetaData::isSigned(sal_Int32) sal_Int32 SAL_CALL OResultSetMetaData::getPrecision(sal_Int32 column) { sal_Int32 nType = getColumnType(column); - if( nType == DataType::NUMERIC || nType == DataType::DECIMAL ) + if( nType != DataType::NUMERIC && nType != DataType::DECIMAL ) + return 0; + + OUString sColumnName = getColumnName( column ); + + // RDB$FIELD_SOURCE is a unique name of column per database + OUString sSql = "SELECT RDB$FIELD_PRECISION FROM RDB$FIELDS " + " INNER JOIN RDB$RELATION_FIELDS " + " ON RDB$RELATION_FIELDS.RDB$FIELD_SOURCE = RDB$FIELDS.RDB$FIELD_NAME " + "WHERE RDB$RELATION_FIELDS.RDB$RELATION_NAME = '" + + escapeWith(getTableName(column), '\'', '\'') + "' AND " + "RDB$RELATION_FIELDS.RDB$FIELD_NAME = '" + + escapeWith(sColumnName, '\'', '\'') +"'"; + Reference<XStatement> xStmt= m_pConnection->createStatement(); + + Reference<XResultSet> xRes = + xStmt->executeQuery(sSql); + Reference<XRow> xRow ( xRes, UNO_QUERY); + if(xRes->next()) { - OUString sColumnName = getColumnName( column ); - - // RDB$FIELD_SOURCE is a unique name of column per database - OUString sSql = "SELECT RDB$FIELD_PRECISION FROM RDB$FIELDS " - " INNER JOIN RDB$RELATION_FIELDS " - " ON RDB$RELATION_FIELDS.RDB$FIELD_SOURCE = RDB$FIELDS.RDB$FIELD_NAME " - "WHERE RDB$RELATION_FIELDS.RDB$RELATION_NAME = '" - + escapeWith(getTableName(column), '\'', '\'') + "' AND " - "RDB$RELATION_FIELDS.RDB$FIELD_NAME = '" - + escapeWith(sColumnName, '\'', '\'') +"'"; - Reference<XStatement> xStmt= m_pConnection->createStatement(); - - Reference<XResultSet> xRes = - xStmt->executeQuery(sSql); - Reference<XRow> xRow ( xRes, UNO_QUERY); - if(xRes->next()) - { - return static_cast<sal_Int32>(xRow->getShort(1)); - } - else - { - SAL_WARN("connectivity.firebird","Column '" - << sColumnName - << "' not found in database"); - return 0; - } + return static_cast<sal_Int32>(xRow->getShort(1)); + } + else + { + SAL_WARN("connectivity.firebird","Column '" + << sColumnName + << "' not found in database"); + return 0; } return 0; } diff --git a/connectivity/source/drivers/firebird/StatementCommonBase.cxx b/connectivity/source/drivers/firebird/StatementCommonBase.cxx index 61f57f330516..01ed3f8fc854 100644 --- a/connectivity/source/drivers/firebird/StatementCommonBase.cxx +++ b/connectivity/source/drivers/firebird/StatementCommonBase.cxx @@ -421,24 +421,24 @@ sal_Int32 OStatementCommonBase::getStatementChangeCount() } char* pResults = aResultsBuffer; - if (static_cast<short>(*pResults++) == isc_info_sql_records) - { -// const short aTotalLength = (short) isc_vax_integer(pResults, 2); - pResults += 2; + if (static_cast<short>(*pResults++) != isc_info_sql_records) + return 0; - // Seems to be of form TOKEN (1 byte), LENGTH (2 bytes), DATA (LENGTH bytes) - while (*pResults != isc_info_rsb_end) - { - const char aToken = *pResults; - const short aLength = static_cast<short>(isc_vax_integer(pResults+1, 2)); +// const short aTotalLength = (short) isc_vax_integer(pResults, 2); + pResults += 2; - if (aToken == aDesiredInfoType) - { - return isc_vax_integer(pResults + 3, aLength); - } + // Seems to be of form TOKEN (1 byte), LENGTH (2 bytes), DATA (LENGTH bytes) + while (*pResults != isc_info_rsb_end) + { + const char aToken = *pResults; + const short aLength = static_cast<short>(isc_vax_integer(pResults+1, 2)); - pResults += (3 + aLength); + if (aToken == aDesiredInfoType) + { + return isc_vax_integer(pResults + 3, aLength); } + + pResults += (3 + aLength); } return 0; diff --git a/connectivity/source/drivers/hsqldb/HStorageAccess.cxx b/connectivity/source/drivers/hsqldb/HStorageAccess.cxx index 09ab485d9fd7..f4f67a8e394a 100644 --- a/connectivity/source/drivers/hsqldb/HStorageAccess.cxx +++ b/connectivity/source/drivers/hsqldb/HStorageAccess.cxx @@ -148,28 +148,28 @@ jint read_from_storage_stream( JNIEnv * env, jstring name, jstring key ) std::shared_ptr<StreamHelper> pHelper = StorageContainer::getRegisteredStream(env,name,key); Reference< XInputStream> xIn = pHelper ? pHelper->getInputStream() : Reference< XInputStream>(); OSL_ENSURE(xIn.is(),"Input stream is NULL!"); - if ( xIn.is() ) + if ( !xIn.is() ) + return -1; + + Sequence< ::sal_Int8 > aData(1); + sal_Int32 nBytesRead = -1; + try { - Sequence< ::sal_Int8 > aData(1); - sal_Int32 nBytesRead = -1; - try - { - nBytesRead = xIn->readBytes(aData,1); - } - catch(const Exception& e) - { - StorageContainer::throwJavaException(e,env); - return -1; + nBytesRead = xIn->readBytes(aData,1); + } + catch(const Exception& e) + { + StorageContainer::throwJavaException(e,env); + return -1; - } - if (nBytesRead <= 0) - { - return -1; - } - else - { - return static_cast<unsigned char>(aData[0]); - } + } + if (nBytesRead <= 0) + { + return -1; + } + else + { + return static_cast<unsigned char>(aData[0]); } return -1; } diff --git a/connectivity/source/drivers/hsqldb/StorageFileAccess.cxx b/connectivity/source/drivers/hsqldb/StorageFileAccess.cxx index 65457ab1d129..46866df04b33 100644 --- a/connectivity/source/drivers/hsqldb/StorageFileAccess.cxx +++ b/connectivity/source/drivers/hsqldb/StorageFileAccess.cxx @@ -44,42 +44,42 @@ extern "C" SAL_JNI_EXPORT jboolean JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_S { TStorages::mapped_type aStoragePair = StorageContainer::getRegisteredStorage(StorageContainer::jstring2ustring(env,key)); auto storage = aStoragePair.mapStorage(); - if ( storage.is() ) + if ( !storage ) + return JNI_FALSE; + + try { + OUString sName = StorageContainer::jstring2ustring(env,name); try { - OUString sName = StorageContainer::jstring2ustring(env,name); - try + OUString sOldName = StorageContainer::removeOldURLPrefix(sName); + if ( storage->isStreamElement(sOldName) ) { - OUString sOldName = StorageContainer::removeOldURLPrefix(sName); - if ( storage->isStreamElement(sOldName) ) + try + { + storage->renameElement(sOldName,StorageContainer::removeURLPrefix(sName,aStoragePair.url)); + } + catch(const Exception&) { - try - { - storage->renameElement(sOldName,StorageContainer::removeURLPrefix(sName,aStoragePair.url)); - } - catch(const Exception&) - { - } } } - catch(const NoSuchElementException&) - { - } - catch(const IllegalArgumentException&) - { - } - return storage->isStreamElement(StorageContainer::removeURLPrefix(sName,aStoragePair.url)); } catch(const NoSuchElementException&) { } - catch(const Exception&) + catch(const IllegalArgumentException&) { - TOOLS_WARN_EXCEPTION("connectivity.hsqldb", "forwarding"); - if (env->ExceptionCheck()) - env->ExceptionClear(); } + return storage->isStreamElement(StorageContainer::removeURLPrefix(sName,aStoragePair.url)); + } + catch(const NoSuchElementException&) + { + } + catch(const Exception&) + { + TOOLS_WARN_EXCEPTION("connectivity.hsqldb", "forwarding"); + if (env->ExceptionCheck()) + env->ExceptionClear(); } return JNI_FALSE; } diff --git a/connectivity/source/manager/mdrivermanager.cxx b/connectivity/source/manager/mdrivermanager.cxx index bef3c8d74eaa..b30007667ec3 100644 --- a/connectivity/source/manager/mdrivermanager.cxx +++ b/connectivity/source/manager/mdrivermanager.cxx @@ -113,23 +113,23 @@ Any SAL_CALL ODriverEnumeration::nextElement( ) const DriverAccess& operator()( const DriverAccess& _rDescriptor ) const { // we did not load this driver, yet - if (!_rDescriptor.xDriver.is()) + if (_rDescriptor.xDriver.is()) + return _rDescriptor; + + // we have a factory for it + if (_rDescriptor.xComponentFactory.is()) { - // we have a factory for it - if (_rDescriptor.xComponentFactory.is()) + DriverAccess& rDesc = const_cast<DriverAccess&>(_rDescriptor); + try { - DriverAccess& rDesc = const_cast<DriverAccess&>(_rDescriptor); - try - { - //load driver - rDesc.xDriver.set( - rDesc.xComponentFactory->createInstanceWithContext(mxContext), css::uno::UNO_QUERY); - } - catch (const Exception&) - { - //failure, abandon driver - rDesc.xComponentFactory.clear(); - } + //load driver + rDesc.xDriver.set( + rDesc.xComponentFactory->createInstanceWithContext(mxContext), css::uno::UNO_QUERY); + } + catch (const Exception&) + { + //failure, abandon driver + rDesc.xComponentFactory.clear(); } } return _rDescriptor; diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx index 02056253c300..424f016db9ca 100644 --- a/connectivity/source/parse/sqlnode.cxx +++ b/connectivity/source/parse/sqlnode.cxx @@ -147,41 +147,41 @@ namespace { } - if(pSubTree->count()) + if(!pSubTree->count()) + return false; + + const OSQLParseNode* pCol = pSubTree->getChild(pSubTree->count()-1); + if (SQL_ISRULE(pCol,column_val)) { - const OSQLParseNode* pCol = pSubTree->getChild(pSubTree->count()-1); - if (SQL_ISRULE(pCol,column_val)) - { - assert(pCol->count() == 1); - pCol = pCol->getChild(0); - } - const OSQLParseNode* pTable(nullptr); - switch (pSubTree->count()) - { - case 1: - break; - case 3: - pTable = pSubTree->getChild(0); - break; - case 5: - case 7: - SAL_WARN("connectivity.parse", "SQL: catalog and/or schema in column_ref in predicate"); - break; - default: - SAL_WARN("connectivity.parse", "columnMatchP: SQL grammar changed; column_ref has " << pSubTree->count() << " children"); - assert(false); - break; - } - // TODO: not all DBMS match column names case-insensitively... - // see XDatabaseMetaData::supportsMixedCaseIdentifiers() - // and XDatabaseMetaData::supportsMixedCaseQuotedIdentifiers() - if ( // table name matches (or no table name)? - ( !pTable || pTable->getTokenValue().equalsIgnoreAsciiCase(rParam.sPredicateTableAlias) ) - && // column name matches? - pCol->getTokenValue().equalsIgnoreAsciiCase(aFieldName) - ) - return true; + assert(pCol->count() == 1); + pCol = pCol->getChild(0); + } + const OSQLParseNode* pTable(nullptr); + switch (pSubTree->count()) + { + case 1: + break; + case 3: + pTable = pSubTree->getChild(0); + break; + case 5: + case 7: + SAL_WARN("connectivity.parse", "SQL: catalog and/or schema in column_ref in predicate"); + break; + default: + SAL_WARN("connectivity.parse", "columnMatchP: SQL grammar changed; column_ref has " << pSubTree->count() << " children"); + assert(false); + break; } + // TODO: not all DBMS match column names case-insensitively... + // see XDatabaseMetaData::supportsMixedCaseIdentifiers() + // and XDatabaseMetaData::supportsMixedCaseQuotedIdentifiers() + if ( // table name matches (or no table name)? + ( !pTable || pTable->getTokenValue().equalsIgnoreAsciiCase(rParam.sPredicateTableAlias) ) + && // column name matches? + pCol->getTokenValue().equalsIgnoreAsciiCase(aFieldName) + ) + return true; return false; } } @@ -1703,54 +1703,53 @@ void OSQLParseNode::append(OSQLParseNode* pNewNode) bool OSQLParseNode::addDateValue(OUStringBuffer& rString, const SQLParseNodeParameter& rParam) const { // special display for date/time values - if (SQL_ISRULE(this,set_fct_spec) && SQL_ISPUNCTUATION(m_aChildren[0],"{")) - { - const OSQLParseNode* pODBCNode = m_aChildren[1].get(); - const OSQLParseNode* pODBCNodeChild = pODBCNode->m_aChildren[0].get(); + if (!SQL_ISRULE(this,set_fct_spec) || !SQL_ISPUNCTUATION(m_aChildren[0],"{")) + return false; - if (pODBCNodeChild->getNodeType() == SQLNodeType::Keyword && ( - SQL_ISTOKEN(pODBCNodeChild, D) || - SQL_ISTOKEN(pODBCNodeChild, T) || - SQL_ISTOKEN(pODBCNodeChild, TS) )) - { - OUString suQuote("'"); - if (rParam.bPredicate) - { - if (rParam.aMetaData.shouldEscapeDateTime()) - { - suQuote = "#"; - } - } - else - { - if (rParam.aMetaData.shouldEscapeDateTime()) - { - // suQuote = "'"; - return false; - } - } + const OSQLParseNode* pODBCNode = m_aChildren[1].get(); + const OSQLParseNode* pODBCNodeChild = pODBCNode->m_aChildren[0].get(); - if (!rString.isEmpty()) - rString.append(" "); - rString.append(suQuote); - const OUString sTokenValue = pODBCNode->m_aChildren[1]->getTokenValue(); - if (SQL_ISTOKEN(pODBCNodeChild, D)) - { - rString.append(rParam.bPredicate ? convertDateString(rParam, sTokenValue) : sTokenValue); - } - else if (SQL_ISTOKEN(pODBCNodeChild, T)) - { - rString.append(rParam.bPredicate ? convertTimeString(rParam, sTokenValue) : sTokenValue); - } - else - { - rString.append(rParam.bPredicate ? convertDateTimeString(rParam, sTokenValue) : sTokenValue); - } - rString.append(suQuote); - return true; - } + if (pODBCNodeChild->getNodeType() != SQLNodeType::Keyword || !( + SQL_ISTOKEN(pODBCNodeChild, D) || + SQL_ISTOKEN(pODBCNodeChild, T) || + SQL_ISTOKEN(pODBCNodeChild, TS) )) + return false; + + OUString suQuote("'"); + if (rParam.bPredicate) + { + if (rParam.aMetaData.shouldEscapeDateTime()) + { + suQuote = "#"; + } } - return false; + else + { + if (rParam.aMetaData.shouldEscapeDateTime()) + { + // suQuote = "'"; + return false; + } + } + + if (!rString.isEmpty()) + rString.append(" "); + rString.append(suQuote); + const OUString sTokenValue = pODBCNode->m_aChildren[1]->getTokenValue(); + if (SQL_ISTOKEN(pODBCNodeChild, D)) + { + rString.append(rParam.bPredicate ? convertDateString(rParam, sTokenValue) : sTokenValue); + } + else if (SQL_ISTOKEN(pODBCNodeChild, T)) + { + rString.append(rParam.bPredicate ? convertTimeString(rParam, sTokenValue) : sTokenValue); + } + else + { + rString.append(rParam.bPredicate ? convertDateTimeString(rParam, sTokenValue) : sTokenValue); + } + rString.append(suQuote); + return true; } void OSQLParseNode::replaceNodeValue(const OUString& rTableAlias, const OUString& rColumnName) diff --git a/cppu/source/threadpool/current.cxx b/cppu/source/threadpool/current.cxx index d085cb4a5092..64e6bfb8f64c 100644 --- a/cppu/source/threadpool/current.cxx +++ b/cppu/source/threadpool/current.cxx @@ -133,31 +133,31 @@ extern "C" sal_Bool SAL_CALL uno_setCurrentContext( id.pCurrentContext = nullptr; } - if (pCurrentContext) + if (!pCurrentContext) + return true; + + uno_Environment * pEnv = nullptr; + ::uno_getEnvironment( &pEnv, pEnvTypeName, pEnvContext ); + OSL_ASSERT( pEnv && pEnv->pExtEnv ); + if (pEnv) { - uno_Environment * pEnv = nullptr; - ::uno_getEnvironment( &pEnv, pEnvTypeName, pEnvContext ); - OSL_ASSERT( pEnv && pEnv->pExtEnv ); - if (pEnv) + if (pEnv->pExtEnv) { - if (pEnv->pExtEnv) - { - id.pCurrentContextEnv = pEnv->pExtEnv; - (*id.pCurrentContextEnv->acquireInterface)( - id.pCurrentContextEnv, pCurrentContext ); - id.pCurrentContext = pCurrentContext; - } - else - { - (*pEnv->release)( pEnv ); - return false; - } + id.pCurrentContextEnv = pEnv->pExtEnv; + (*id.pCurrentContextEnv->acquireInterface)( + id.pCurrentContextEnv, pCurrentContext ); + id.pCurrentContext = pCurrentContext; } else { + (*pEnv->release)( pEnv ); return false; } } + else + { + return false; + } return true; } diff --git a/cppu/source/typelib/typelib.cxx b/cppu/source/typelib/typelib.cxx ... etc. - the rest is truncated