diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-06-07 13:03:58 +0200 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2018-06-08 01:29:32 +0200 |
commit | 5708534b942c1d0ce384f6a8473da6bb569410e7 (patch) | |
tree | 2ec4fe87624541c15bf89c8b839e8f8dba8a89f4 /chart2/source | |
parent | 1e55a47e89a9d9d6cf9cb3993484022aaf2c097b (diff) |
look for unnecessary calls to Reference::is() after an UNO_QUERY_THROW
Since the previous call would throw if there was nothing to be assigned
to the value.
Idea from tml.
Used the following script to find places:
git grep -A3 -n UNO_QUERY_THROW | grep -B3 -F 'is()'
Change-Id: I36ba7b00bcd014bdf16c0455ab91056f82194969
Reviewed-on: https://gerrit.libreoffice.org/55417
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'chart2/source')
-rw-r--r-- | chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx | 42 | ||||
-rw-r--r-- | chart2/source/model/main/ChartModel_Persistence.cxx | 1 | ||||
-rw-r--r-- | chart2/source/model/template/StockDataInterpreter.cxx | 1 | ||||
-rw-r--r-- | chart2/source/tools/AxisHelper.cxx | 75 | ||||
-rw-r--r-- | chart2/source/tools/ChartTypeHelper.cxx | 3 | ||||
-rw-r--r-- | chart2/source/tools/DiagramHelper.cxx | 2 | ||||
-rw-r--r-- | chart2/source/view/main/ChartView.cxx | 3 |
7 files changed, 56 insertions, 71 deletions
diff --git a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx index 94d74b0eefe3..5a80655bae99 100644 --- a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx @@ -1253,25 +1253,22 @@ uno::Reference< uno::XInterface > SAL_CALL ChartDocumentWrapper::createInstance( { Reference< lang::XMultiServiceFactory > xFact( m_spChart2ModelContact->m_xContext->getServiceManager(), uno::UNO_QUERY_THROW ); - if( xFact.is() ) + Reference< lang::XInitialization > xViewInit( xFact->createInstance( + CHART_VIEW_SERVICE_NAME ), uno::UNO_QUERY ); + if(xViewInit.is()) { - Reference< lang::XInitialization > xViewInit( xFact->createInstance( - CHART_VIEW_SERVICE_NAME ), uno::UNO_QUERY ); - if(xViewInit.is()) + try { - try - { - m_xChartView = xViewInit; - - Sequence< Any > aArguments(2); - aArguments[0] <<= Reference<frame::XModel>(this); - aArguments[1] <<= true; // bRefreshAddIn - xViewInit->initialize(aArguments); - } - catch (const uno::Exception&) - { - DBG_UNHANDLED_EXCEPTION("chart2"); - } + m_xChartView = xViewInit; + + Sequence< Any > aArguments(2); + aArguments[0] <<= Reference<frame::XModel>(this); + aArguments[1] <<= true; // bRefreshAddIn + xViewInit->initialize(aArguments); + } + catch (const uno::Exception&) + { + DBG_UNHANDLED_EXCEPTION("chart2"); } } } @@ -1316,14 +1313,11 @@ uno::Reference< uno::XInterface > SAL_CALL ChartDocumentWrapper::createInstance( { Reference< lang::XMultiServiceFactory > xFact( m_spChart2ModelContact->m_xContext->getServiceManager(), uno::UNO_QUERY_THROW ); - if( xFact.is() ) + uno::Reference< util::XRefreshable > xAddIn( + xFact->createInstance( aServiceSpecifier ), uno::UNO_QUERY ); + if( xAddIn.is() ) { - uno::Reference< util::XRefreshable > xAddIn( - xFact->createInstance( aServiceSpecifier ), uno::UNO_QUERY ); - if( xAddIn.is() ) - { - xResult = xAddIn; - } + xResult = xAddIn; } } catch (const uno::Exception&) diff --git a/chart2/source/model/main/ChartModel_Persistence.cxx b/chart2/source/model/main/ChartModel_Persistence.cxx index cdc0d0338a02..dabde5d32ba4 100644 --- a/chart2/source/model/main/ChartModel_Persistence.cxx +++ b/chart2/source/model/main/ChartModel_Persistence.cxx @@ -129,7 +129,6 @@ Reference< embed::XStorage > lcl_createStorage( aStorageArgs[2] <<= rMediaDescriptor; xStorage.set( xStorageFact->createInstanceWithArguments( aStorageArgs ), uno::UNO_QUERY_THROW ); - OSL_ENSURE( xStorage.is(), "No Storage" ); } catch(const css::ucb::ContentCreationException&) { diff --git a/chart2/source/model/template/StockDataInterpreter.cxx b/chart2/source/model/template/StockDataInterpreter.cxx index f766d41aaed9..a6db346a44ea 100644 --- a/chart2/source/model/template/StockDataInterpreter.cxx +++ b/chart2/source/model/template/StockDataInterpreter.cxx @@ -240,7 +240,6 @@ InterpretedData SAL_CALL StockDataInterpreter::interpretDataSource( xSeries.set( new DataSeries ); OSL_ASSERT( xSeries.is() ); Reference< data::XDataSink > xSink( xSeries, uno::UNO_QUERY_THROW ); - OSL_ASSERT( xSink.is() ); xSink->setData( aSequences[nGroupIndex][nSeriesIdx] ); aResultSeries[nGroupIndex][nSeriesIdx].set( xSeries ); } diff --git a/chart2/source/tools/AxisHelper.cxx b/chart2/source/tools/AxisHelper.cxx index 84c008612332..4a9cf9218641 100644 --- a/chart2/source/tools/AxisHelper.cxx +++ b/chart2/source/tools/AxisHelper.cxx @@ -239,52 +239,49 @@ sal_Int32 AxisHelper::getExplicitNumberFormatKeyForAxis( try { Reference< XChartTypeContainer > xCTCnt( xCorrespondingCoordinateSystem, uno::UNO_QUERY_THROW ); - if( xCTCnt.is() ) + OUString aRoleToMatch; + if( nDimensionIndex == 0 ) + aRoleToMatch = "values-x"; + Sequence< Reference< XChartType > > aChartTypes( xCTCnt->getChartTypes()); + for( sal_Int32 nCTIdx=0; nCTIdx<aChartTypes.getLength(); ++nCTIdx ) { - OUString aRoleToMatch; - if( nDimensionIndex == 0 ) - aRoleToMatch = "values-x"; - Sequence< Reference< XChartType > > aChartTypes( xCTCnt->getChartTypes()); - for( sal_Int32 nCTIdx=0; nCTIdx<aChartTypes.getLength(); ++nCTIdx ) + if( nDimensionIndex != 0 ) + aRoleToMatch = ChartTypeHelper::getRoleOfSequenceForYAxisNumberFormatDetection( aChartTypes[nCTIdx] ); + Reference< XDataSeriesContainer > xDSCnt( aChartTypes[nCTIdx], uno::UNO_QUERY_THROW ); + Sequence< Reference< XDataSeries > > aDataSeriesSeq( xDSCnt->getDataSeries()); + for( sal_Int32 nSeriesIdx=0; nSeriesIdx<aDataSeriesSeq.getLength(); ++nSeriesIdx ) { - if( nDimensionIndex != 0 ) - aRoleToMatch = ChartTypeHelper::getRoleOfSequenceForYAxisNumberFormatDetection( aChartTypes[nCTIdx] ); - Reference< XDataSeriesContainer > xDSCnt( aChartTypes[nCTIdx], uno::UNO_QUERY_THROW ); - Sequence< Reference< XDataSeries > > aDataSeriesSeq( xDSCnt->getDataSeries()); - for( sal_Int32 nSeriesIdx=0; nSeriesIdx<aDataSeriesSeq.getLength(); ++nSeriesIdx ) - { - Reference< chart2::XDataSeries > xDataSeries(aDataSeriesSeq[nSeriesIdx]); - Reference< data::XDataSource > xSource( xDataSeries, uno::UNO_QUERY_THROW ); + Reference< chart2::XDataSeries > xDataSeries(aDataSeriesSeq[nSeriesIdx]); + Reference< data::XDataSource > xSource( xDataSeries, uno::UNO_QUERY_THROW ); - if( nDimensionIndex == 1 ) - { - //only take those series into account that are attached to this axis - sal_Int32 nAttachedAxisIndex = DataSeriesHelper::getAttachedAxisIndex(xDataSeries); - if( nAttachedAxisIndex != nAxisIndex ) - continue; - } + if( nDimensionIndex == 1 ) + { + //only take those series into account that are attached to this axis + sal_Int32 nAttachedAxisIndex = DataSeriesHelper::getAttachedAxisIndex(xDataSeries); + if( nAttachedAxisIndex != nAxisIndex ) + continue; + } - Reference< data::XLabeledDataSequence > xLabeledSeq( - DataSeriesHelper::getDataSequenceByRole( xSource, aRoleToMatch ) ); + Reference< data::XLabeledDataSequence > xLabeledSeq( + DataSeriesHelper::getDataSequenceByRole( xSource, aRoleToMatch ) ); - if( !xLabeledSeq.is() && nDimensionIndex==0 ) - { - ScaleData aData = xAxis->getScaleData(); - xLabeledSeq = aData.Categories; - } + if( !xLabeledSeq.is() && nDimensionIndex==0 ) + { + ScaleData aData = xAxis->getScaleData(); + xLabeledSeq = aData.Categories; + } - if( xLabeledSeq.is() ) + if( xLabeledSeq.is() ) + { + Reference< data::XDataSequence > xSeq( xLabeledSeq->getValues()); + if( xSeq.is() ) { - Reference< data::XDataSequence > xSeq( xLabeledSeq->getValues()); - if( xSeq.is() ) - { - sal_Int32 nKey = xSeq->getNumberFormatKeyByIndex( -1 ); - // initialize the value - if( aKeyMap.find( nKey ) == aKeyMap.end()) - aKeyMap[ nKey ] = 0; - // increase frequency - aKeyMap[ nKey ] = (aKeyMap[ nKey ] + 1); - } + sal_Int32 nKey = xSeq->getNumberFormatKeyByIndex( -1 ); + // initialize the value + if( aKeyMap.find( nKey ) == aKeyMap.end()) + aKeyMap[ nKey ] = 0; + // increase frequency + aKeyMap[ nKey ] = (aKeyMap[ nKey ] + 1); } } } diff --git a/chart2/source/tools/ChartTypeHelper.cxx b/chart2/source/tools/ChartTypeHelper.cxx index 23aa42efed73..658855d6380b 100644 --- a/chart2/source/tools/ChartTypeHelper.cxx +++ b/chart2/source/tools/ChartTypeHelper.cxx @@ -248,8 +248,7 @@ uno::Sequence < sal_Int32 > ChartTypeHelper::getSupportedLabelPlacements( const { bool bDonut = false; uno::Reference< beans::XPropertySet > xChartTypeProp( xChartType, uno::UNO_QUERY_THROW ); - if(xChartTypeProp.is()) - xChartTypeProp->getPropertyValue( "UseRings") >>= bDonut; + xChartTypeProp->getPropertyValue( "UseRings") >>= bDonut; if(!bDonut) { diff --git a/chart2/source/tools/DiagramHelper.cxx b/chart2/source/tools/DiagramHelper.cxx index 801c40e2ce52..652a4e468841 100644 --- a/chart2/source/tools/DiagramHelper.cxx +++ b/chart2/source/tools/DiagramHelper.cxx @@ -578,8 +578,6 @@ bool DiagramHelper::attachSeriesToAxis( bool bAttachToMainAxis //set property at axis Reference< beans::XPropertySet > xProp( xDataSeries, uno::UNO_QUERY_THROW ); - if( !xProp.is() ) - return bChanged; sal_Int32 nNewAxisIndex = bAttachToMainAxis ? 0 : 1; sal_Int32 nOldAxisIndex = DataSeriesHelper::getAttachedAxisIndex(xDataSeries); diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index 22f268b19a4a..259b58ce7779 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -1808,8 +1808,7 @@ awt::Rectangle ChartView::impl_createDiagramAndContent( const CreateShapeParam2D bool bPosSizeExcludeAxesProperty = true; uno::Reference< beans::XPropertySet > xDiaProps( xDiagram, uno::UNO_QUERY_THROW ); - if( xDiaProps.is() ) - xDiaProps->getPropertyValue("PosSizeExcludeAxes") >>= bPosSizeExcludeAxesProperty; + xDiaProps->getPropertyValue("PosSizeExcludeAxes") >>= bPosSizeExcludeAxesProperty; if (rParam.mbUseFixedInnerSize || bPosSizeExcludeAxesProperty) { aPos = awt::Point( m_aResultingDiagramRectangleExcludingAxes.X, m_aResultingDiagramRectangleExcludingAxes.Y ); |