diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-04-18 14:08:51 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-04-19 11:01:18 +0200 |
commit | 9df2821e61979dab32390d5c64dd49bee868adbb (patch) | |
tree | 5b827e29e73ac2300c164b0a389a784a358956e6 /chart2/source/model/template | |
parent | 8b0a69498b025e13d9772689e9e4fa3d6b05e609 (diff) |
loplugin:flatten in chart2
Change-Id: Iadc4da6515a7d82e7a92b33d74d589b61fa2c64f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92480
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'chart2/source/model/template')
-rw-r--r-- | chart2/source/model/template/BarChartTypeTemplate.cxx | 24 | ||||
-rw-r--r-- | chart2/source/model/template/ChartTypeTemplate.cxx | 176 | ||||
-rw-r--r-- | chart2/source/model/template/DataInterpreter.cxx | 26 |
3 files changed, 113 insertions, 113 deletions
diff --git a/chart2/source/model/template/BarChartTypeTemplate.cxx b/chart2/source/model/template/BarChartTypeTemplate.cxx index 48a2b53f8be4..ffc694fbd5df 100644 --- a/chart2/source/model/template/BarChartTypeTemplate.cxx +++ b/chart2/source/model/template/BarChartTypeTemplate.cxx @@ -251,19 +251,19 @@ void SAL_CALL BarChartTypeTemplate::applyStyle( { ChartTypeTemplate::applyStyle( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount ); DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, "BorderStyle", uno::Any( drawing::LineStyle_NONE ) ); - if( getDimension() == 3 ) + if( getDimension() != 3 ) + return; + + try { - try - { - //apply Geometry3D - uno::Any aAGeometry3D; - getFastPropertyValue( aAGeometry3D, PROP_BAR_TEMPLATE_GEOMETRY3D ); - DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, "Geometry3D", aAGeometry3D ); - } - catch( const uno::Exception & ) - { - DBG_UNHANDLED_EXCEPTION("chart2"); - } + //apply Geometry3D + uno::Any aAGeometry3D; + getFastPropertyValue( aAGeometry3D, PROP_BAR_TEMPLATE_GEOMETRY3D ); + DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, "Geometry3D", aAGeometry3D ); + } + catch( const uno::Exception & ) + { + DBG_UNHANDLED_EXCEPTION("chart2"); } } diff --git a/chart2/source/model/template/ChartTypeTemplate.cxx b/chart2/source/model/template/ChartTypeTemplate.cxx index afd9eb0f048a..646560d04adb 100644 --- a/chart2/source/model/template/ChartTypeTemplate.cxx +++ b/chart2/source/model/template/ChartTypeTemplate.cxx @@ -69,26 +69,26 @@ void lcl_applyDefaultStyle( void lcl_ensureCorrectLabelPlacement( const Reference< beans::XPropertySet >& xProp, const uno::Sequence < sal_Int32 >& rAvailablePlacements ) { sal_Int32 nLabelPlacement=0; - if( xProp.is() && (xProp->getPropertyValue( "LabelPlacement" ) >>= nLabelPlacement) ) + if( !(xProp.is() && (xProp->getPropertyValue( "LabelPlacement" ) >>= nLabelPlacement)) ) + return; + + bool bValid = false; + for( sal_Int32 nN = 0; nN < rAvailablePlacements.getLength(); nN++ ) { - bool bValid = false; - for( sal_Int32 nN = 0; nN < rAvailablePlacements.getLength(); nN++ ) - { - if( rAvailablePlacements[nN] == nLabelPlacement ) - { - bValid = true; - break; - } - } - if( !bValid ) + if( rAvailablePlacements[nN] == nLabelPlacement ) { - uno::Any aNewValue; - //otherwise use the first supported one - if( rAvailablePlacements.hasElements() ) - aNewValue <<=rAvailablePlacements[0]; - xProp->setPropertyValue( "LabelPlacement", aNewValue ); + bValid = true; + break; } } + if( !bValid ) + { + uno::Any aNewValue; + //otherwise use the first supported one + if( rAvailablePlacements.hasElements() ) + aNewValue <<=rAvailablePlacements[0]; + xProp->setPropertyValue( "LabelPlacement", aNewValue ); + } } void lcl_resetLabelPlacementIfDefault( const Reference< beans::XPropertySet >& xProp, sal_Int32 nDefaultPlacement ) @@ -381,37 +381,37 @@ void SAL_CALL ChartTypeTemplate::applyStyle( { // sset stacking mode Reference< beans::XPropertySet > xSeriesProp( xSeries, uno::UNO_QUERY ); - if( xSeriesProp.is()) + if( !xSeriesProp.is()) + return; + + try { - try + StackMode eStackMode = getStackMode( nChartTypeIndex ); + const uno::Any aPropValue( + ( (eStackMode == StackMode::YStacked) || + (eStackMode == StackMode::YStackedPercent) ) + ? chart2::StackingDirection_Y_STACKING + : (eStackMode == StackMode::ZStacked ) + ? chart2::StackingDirection_Z_STACKING + : chart2::StackingDirection_NO_STACKING ); + xSeriesProp->setPropertyValue( "StackingDirection", aPropValue ); + + //ensure valid label placement { - StackMode eStackMode = getStackMode( nChartTypeIndex ); - const uno::Any aPropValue( - ( (eStackMode == StackMode::YStacked) || - (eStackMode == StackMode::YStackedPercent) ) - ? chart2::StackingDirection_Y_STACKING - : (eStackMode == StackMode::ZStacked ) - ? chart2::StackingDirection_Z_STACKING - : chart2::StackingDirection_NO_STACKING ); - xSeriesProp->setPropertyValue( "StackingDirection", aPropValue ); - - //ensure valid label placement - { - uno::Sequence < sal_Int32 > aAvailablePlacements( ChartTypeHelper::getSupportedLabelPlacements( - getChartTypeForIndex( nChartTypeIndex ), isSwapXAndY(), xSeries ) ); - lcl_ensureCorrectLabelPlacement( xSeriesProp, aAvailablePlacements ); - - uno::Sequence< sal_Int32 > aAttributedDataPointIndexList; - if( xSeriesProp->getPropertyValue( "AttributedDataPoints" ) >>= aAttributedDataPointIndexList ) - for(sal_Int32 nN=aAttributedDataPointIndexList.getLength();nN--;) - lcl_ensureCorrectLabelPlacement( xSeries->getDataPointByIndex(aAttributedDataPointIndexList[nN]), aAvailablePlacements ); - } - } - catch( const uno::Exception & ) - { - DBG_UNHANDLED_EXCEPTION("chart2"); + uno::Sequence < sal_Int32 > aAvailablePlacements( ChartTypeHelper::getSupportedLabelPlacements( + getChartTypeForIndex( nChartTypeIndex ), isSwapXAndY(), xSeries ) ); + lcl_ensureCorrectLabelPlacement( xSeriesProp, aAvailablePlacements ); + + uno::Sequence< sal_Int32 > aAttributedDataPointIndexList; + if( xSeriesProp->getPropertyValue( "AttributedDataPoints" ) >>= aAttributedDataPointIndexList ) + for(sal_Int32 nN=aAttributedDataPointIndexList.getLength();nN--;) + lcl_ensureCorrectLabelPlacement( xSeries->getDataPointByIndex(aAttributedDataPointIndexList[nN]), aAvailablePlacements ); } } + catch( const uno::Exception & ) + { + DBG_UNHANDLED_EXCEPTION("chart2"); + } } void ChartTypeTemplate::applyStyles( const Reference< chart2::XDiagram >& xDiagram ) @@ -685,30 +685,30 @@ void ChartTypeTemplate::createAxes( const Sequence< Reference< XCoordinateSystem > > & rCoordSys ) { //create missing axes - if( rCoordSys.hasElements() ) - { - Reference< XCoordinateSystem > xCooSys( rCoordSys[0] ); - if(!xCooSys.is()) - return; + if( !rCoordSys.hasElements() ) + return; - //create main axis in first coordinate system - sal_Int32 nDimCount = xCooSys->getDimension(); - sal_Int32 nDim=0; - for( nDim=0; nDim<nDimCount; ++nDim ) + Reference< XCoordinateSystem > xCooSys( rCoordSys[0] ); + if(!xCooSys.is()) + return; + + //create main axis in first coordinate system + sal_Int32 nDimCount = xCooSys->getDimension(); + sal_Int32 nDim=0; + for( nDim=0; nDim<nDimCount; ++nDim ) + { + sal_Int32 nAxisCount = getAxisCountByDimension( nDim ); + if( nDim == 1 && + nAxisCount < 2 && AxisHelper::isSecondaryYAxisNeeded( xCooSys )) + nAxisCount = 2; + for( sal_Int32 nAxisIndex = 0; nAxisIndex < nAxisCount; ++nAxisIndex ) { - sal_Int32 nAxisCount = getAxisCountByDimension( nDim ); - if( nDim == 1 && - nAxisCount < 2 && AxisHelper::isSecondaryYAxisNeeded( xCooSys )) - nAxisCount = 2; - for( sal_Int32 nAxisIndex = 0; nAxisIndex < nAxisCount; ++nAxisIndex ) + Reference< XAxis > xAxis = AxisHelper::getAxis( nDim, nAxisIndex, xCooSys ); + if( !xAxis.is()) { - Reference< XAxis > xAxis = AxisHelper::getAxis( nDim, nAxisIndex, xCooSys ); - if( !xAxis.is()) - { - // create and add axis - xAxis.set( AxisHelper::createAxis( - nDim, nAxisIndex, xCooSys, GetComponentContext() )); - } + // create and add axis + xAxis.set( AxisHelper::createAxis( + nDim, nAxisIndex, xCooSys, GetComponentContext() )); } } } @@ -719,36 +719,36 @@ void ChartTypeTemplate::adaptAxes( { //adapt properties of existing axes and remove superfluous axes - if( rCoordSys.hasElements() ) + if( !rCoordSys.hasElements() ) + return; + + for( sal_Int32 nCooSysIdx=0; nCooSysIdx < rCoordSys.getLength(); ++nCooSysIdx ) { - for( sal_Int32 nCooSysIdx=0; nCooSysIdx < rCoordSys.getLength(); ++nCooSysIdx ) + Reference< XCoordinateSystem > xCooSys( rCoordSys[nCooSysIdx] ); + if( !xCooSys.is() ) + continue; + sal_Int32 nDimCount = xCooSys->getDimension(); + for( sal_Int32 nDim=0; nDim<nDimCount; ++nDim ) { - Reference< XCoordinateSystem > xCooSys( rCoordSys[nCooSysIdx] ); - if( !xCooSys.is() ) - continue; - sal_Int32 nDimCount = xCooSys->getDimension(); - for( sal_Int32 nDim=0; nDim<nDimCount; ++nDim ) + sal_Int32 nMaxAxisIndex = xCooSys->getMaximumAxisIndexByDimension( nDim ); + for( sal_Int32 nAxisIndex=0; nAxisIndex<=nMaxAxisIndex; nAxisIndex++ ) { - sal_Int32 nMaxAxisIndex = xCooSys->getMaximumAxisIndexByDimension( nDim ); - for( sal_Int32 nAxisIndex=0; nAxisIndex<=nMaxAxisIndex; nAxisIndex++ ) - { - Reference< XAxis > xAxis( AxisHelper::getAxis( nDim, nAxisIndex, xCooSys ) ); - if( !xAxis.is() ) - continue; + Reference< XAxis > xAxis( AxisHelper::getAxis( nDim, nAxisIndex, xCooSys ) ); + if( !xAxis.is() ) + continue; - if( nAxisIndex == MAIN_AXIS_INDEX || nAxisIndex == SECONDARY_AXIS_INDEX ) + if( nAxisIndex == MAIN_AXIS_INDEX || nAxisIndex == SECONDARY_AXIS_INDEX ) + { + // adapt scales + bool bPercent = (getStackMode(0) == StackMode::YStackedPercent); + if( bPercent && nDim == 1 ) { - // adapt scales - bool bPercent = (getStackMode(0) == StackMode::YStackedPercent); - if( bPercent && nDim == 1 ) + Reference< beans::XPropertySet > xAxisProp( xAxis, uno::UNO_QUERY ); + if( xAxisProp.is()) { - Reference< beans::XPropertySet > xAxisProp( xAxis, uno::UNO_QUERY ); - if( xAxisProp.is()) - { - // set number format to source format - xAxisProp->setPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT, uno::Any(true)); - xAxisProp->setPropertyValue(CHART_UNONAME_NUMFMT, uno::Any()); - } + // set number format to source format + xAxisProp->setPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT, uno::Any(true)); + xAxisProp->setPropertyValue(CHART_UNONAME_NUMFMT, uno::Any()); } } } diff --git a/chart2/source/model/template/DataInterpreter.cxx b/chart2/source/model/template/DataInterpreter.cxx index 8fa5ea448bf1..5832612ba91d 100644 --- a/chart2/source/model/template/DataInterpreter.cxx +++ b/chart2/source/model/template/DataInterpreter.cxx @@ -215,21 +215,21 @@ struct lcl_LabeledSequenceEquals m_bHasLabels ( false ), m_bHasValues ( false ) { - if( xLSeqToCmp.is()) + if( !xLSeqToCmp.is()) + return; + + Reference< data::XDataSequence > xSeq( xLSeqToCmp->getValues()); + if( xSeq.is()) { - Reference< data::XDataSequence > xSeq( xLSeqToCmp->getValues()); - if( xSeq.is()) - { - m_bHasValues = true; - m_aValuesRangeRep = xSeq->getSourceRangeRepresentation(); - } + m_bHasValues = true; + m_aValuesRangeRep = xSeq->getSourceRangeRepresentation(); + } - xSeq.set( xLSeqToCmp->getLabel()); - if( xSeq.is()) - { - m_bHasLabels = true; - m_aLabelRangeRep = xSeq->getSourceRangeRepresentation(); - } + xSeq.set( xLSeqToCmp->getLabel()); + if( xSeq.is()) + { + m_bHasLabels = true; + m_aLabelRangeRep = xSeq->getSourceRangeRepresentation(); } } |