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/view | |
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/view')
-rw-r--r-- | chart2/source/view/axes/ScaleAutomatism.cxx | 60 | ||||
-rw-r--r-- | chart2/source/view/axes/Tickmarks_Equidistant.cxx | 28 | ||||
-rw-r--r-- | chart2/source/view/axes/VAxisBase.cxx | 16 | ||||
-rw-r--r-- | chart2/source/view/axes/VAxisProperties.cxx | 56 | ||||
-rw-r--r-- | chart2/source/view/axes/VCartesianAxis.cxx | 120 | ||||
-rw-r--r-- | chart2/source/view/axes/VPolarAngleAxis.cxx | 32 | ||||
-rw-r--r-- | chart2/source/view/charttypes/BarChart.cxx | 38 | ||||
-rw-r--r-- | chart2/source/view/charttypes/PieChart.cxx | 35 | ||||
-rw-r--r-- | chart2/source/view/charttypes/VSeriesPlotter.cxx | 212 | ||||
-rw-r--r-- | chart2/source/view/diagram/VDiagram.cxx | 286 | ||||
-rw-r--r-- | chart2/source/view/main/ChartView.cxx | 401 | ||||
-rw-r--r-- | chart2/source/view/main/VButton.cxx | 22 | ||||
-rw-r--r-- | chart2/source/view/main/VDataSeries.cxx | 108 | ||||
-rw-r--r-- | chart2/source/view/main/VLegend.cxx | 84 |
14 files changed, 752 insertions, 746 deletions
diff --git a/chart2/source/view/axes/ScaleAutomatism.cxx b/chart2/source/view/axes/ScaleAutomatism.cxx index 1adcfe64d652..10fc3ccd4f56 100644 --- a/chart2/source/view/axes/ScaleAutomatism.cxx +++ b/chart2/source/view/axes/ScaleAutomatism.cxx @@ -695,40 +695,40 @@ void ScaleAutomatism::calculateExplicitIncrementAndScaleForDateTimeAxis( if( nDayCount/nIntervalDayCount > nMaxMainIncrementCount ) bAutoMinor = true; } - if( bAutoMinor ) + if( !bAutoMinor ) + return; + + rExplicitIncrement.MinorTimeInterval.TimeUnit = rExplicitIncrement.MajorTimeInterval.TimeUnit; + rExplicitIncrement.MinorTimeInterval.Number = 1; + if( nMainIncrementCount > 100 ) + rExplicitIncrement.MinorTimeInterval.Number = rExplicitIncrement.MajorTimeInterval.Number; + else { - rExplicitIncrement.MinorTimeInterval.TimeUnit = rExplicitIncrement.MajorTimeInterval.TimeUnit; - rExplicitIncrement.MinorTimeInterval.Number = 1; - if( nMainIncrementCount > 100 ) - rExplicitIncrement.MinorTimeInterval.Number = rExplicitIncrement.MajorTimeInterval.Number; + if( rExplicitIncrement.MajorTimeInterval.Number >= 2 ) + { + if( !(rExplicitIncrement.MajorTimeInterval.Number%2) ) + rExplicitIncrement.MinorTimeInterval.Number = rExplicitIncrement.MajorTimeInterval.Number/2; + else if( !(rExplicitIncrement.MajorTimeInterval.Number%3) ) + rExplicitIncrement.MinorTimeInterval.Number = rExplicitIncrement.MajorTimeInterval.Number/3; + else if( !(rExplicitIncrement.MajorTimeInterval.Number%5) ) + rExplicitIncrement.MinorTimeInterval.Number = rExplicitIncrement.MajorTimeInterval.Number/5; + else if( rExplicitIncrement.MajorTimeInterval.Number > 50 ) + rExplicitIncrement.MinorTimeInterval.Number = rExplicitIncrement.MajorTimeInterval.Number; + } else { - if( rExplicitIncrement.MajorTimeInterval.Number >= 2 ) + switch( rExplicitIncrement.MajorTimeInterval.TimeUnit ) { - if( !(rExplicitIncrement.MajorTimeInterval.Number%2) ) - rExplicitIncrement.MinorTimeInterval.Number = rExplicitIncrement.MajorTimeInterval.Number/2; - else if( !(rExplicitIncrement.MajorTimeInterval.Number%3) ) - rExplicitIncrement.MinorTimeInterval.Number = rExplicitIncrement.MajorTimeInterval.Number/3; - else if( !(rExplicitIncrement.MajorTimeInterval.Number%5) ) - rExplicitIncrement.MinorTimeInterval.Number = rExplicitIncrement.MajorTimeInterval.Number/5; - else if( rExplicitIncrement.MajorTimeInterval.Number > 50 ) - rExplicitIncrement.MinorTimeInterval.Number = rExplicitIncrement.MajorTimeInterval.Number; - } - else - { - switch( rExplicitIncrement.MajorTimeInterval.TimeUnit ) - { - case DAY: - break; - case MONTH: - if( rExplicitScale.TimeResolution == DAY ) - rExplicitIncrement.MinorTimeInterval.TimeUnit = DAY; - break; - case YEAR: - if( rExplicitScale.TimeResolution <= MONTH ) - rExplicitIncrement.MinorTimeInterval.TimeUnit = MONTH; - break; - } + case DAY: + break; + case MONTH: + if( rExplicitScale.TimeResolution == DAY ) + rExplicitIncrement.MinorTimeInterval.TimeUnit = DAY; + break; + case YEAR: + if( rExplicitScale.TimeResolution <= MONTH ) + rExplicitIncrement.MinorTimeInterval.TimeUnit = MONTH; + break; } } } diff --git a/chart2/source/view/axes/Tickmarks_Equidistant.cxx b/chart2/source/view/axes/Tickmarks_Equidistant.cxx index d678b58e56ad..60f6e63311ad 100644 --- a/chart2/source/view/axes/Tickmarks_Equidistant.cxx +++ b/chart2/source/view/axes/Tickmarks_Equidistant.cxx @@ -105,23 +105,23 @@ EquidistantTickFactory::EquidistantTickFactory( m_fOuterMajorTickBorderMin_Scaled = m_fOuterMajorTickBorderMin; m_fOuterMajorTickBorderMax_Scaled = m_fOuterMajorTickBorderMax; - if(!m_rIncrement.PostEquidistant && m_xInverseScaling.is() ) + if(!(!m_rIncrement.PostEquidistant && m_xInverseScaling.is()) ) + return; + + m_fOuterMajorTickBorderMin_Scaled = m_rScale.Scaling->doScaling(m_fOuterMajorTickBorderMin); + m_fOuterMajorTickBorderMax_Scaled = m_rScale.Scaling->doScaling(m_fOuterMajorTickBorderMax); + + //check validity of new range: m_fOuterMajorTickBorderMin <-> m_fOuterMajorTickBorderMax + //it is assumed here, that the original range in the given Scale is valid + if( !std::isfinite(m_fOuterMajorTickBorderMin_Scaled) ) { + m_fOuterMajorTickBorderMin += m_rIncrement.Distance; m_fOuterMajorTickBorderMin_Scaled = m_rScale.Scaling->doScaling(m_fOuterMajorTickBorderMin); + } + if( !std::isfinite(m_fOuterMajorTickBorderMax_Scaled) ) + { + m_fOuterMajorTickBorderMax -= m_rIncrement.Distance; m_fOuterMajorTickBorderMax_Scaled = m_rScale.Scaling->doScaling(m_fOuterMajorTickBorderMax); - - //check validity of new range: m_fOuterMajorTickBorderMin <-> m_fOuterMajorTickBorderMax - //it is assumed here, that the original range in the given Scale is valid - if( !std::isfinite(m_fOuterMajorTickBorderMin_Scaled) ) - { - m_fOuterMajorTickBorderMin += m_rIncrement.Distance; - m_fOuterMajorTickBorderMin_Scaled = m_rScale.Scaling->doScaling(m_fOuterMajorTickBorderMin); - } - if( !std::isfinite(m_fOuterMajorTickBorderMax_Scaled) ) - { - m_fOuterMajorTickBorderMax -= m_rIncrement.Distance; - m_fOuterMajorTickBorderMax_Scaled = m_rScale.Scaling->doScaling(m_fOuterMajorTickBorderMax); - } } } diff --git a/chart2/source/view/axes/VAxisBase.cxx b/chart2/source/view/axes/VAxisBase.cxx index 16d951bdb5ad..164a9147cc4f 100644 --- a/chart2/source/view/axes/VAxisBase.cxx +++ b/chart2/source/view/axes/VAxisBase.cxx @@ -212,17 +212,17 @@ size_t VAxisBase::getIndexOfLongestLabel( const uno::Sequence<OUString>& rLabels void VAxisBase::removeTextShapesFromTicks() { - if( m_xTextTarget.is() ) + if( !m_xTextTarget.is() ) + return; + + for (auto & tickInfos : m_aAllTickInfos) { - for (auto & tickInfos : m_aAllTickInfos) + for (auto & tickInfo : tickInfos) { - for (auto & tickInfo : tickInfos) + if(tickInfo.xTextShape.is()) { - if(tickInfo.xTextShape.is()) - { - m_xTextTarget->remove(tickInfo.xTextShape); - tickInfo.xTextShape = nullptr; - } + m_xTextTarget->remove(tickInfo.xTextShape); + tickInfo.xTextShape = nullptr; } } } diff --git a/chart2/source/view/axes/VAxisProperties.cxx b/chart2/source/view/axes/VAxisProperties.cxx index d35bc04a0d24..27a4950a886b 100644 --- a/chart2/source/view/axes/VAxisProperties.cxx +++ b/chart2/source/view/axes/VAxisProperties.cxx @@ -349,38 +349,38 @@ void AxisLabelProperties::init( const uno::Reference< XAxis >& xAxisModel ) { uno::Reference< beans::XPropertySet > xProp = uno::Reference<beans::XPropertySet>::query( xAxisModel ); - if(xProp.is()) + if(!xProp.is()) + return; + + try { - try + xProp->getPropertyValue( "TextBreak" ) >>= bLineBreakAllowed; + xProp->getPropertyValue( "TextOverlap" ) >>= bOverlapAllowed; + xProp->getPropertyValue( "StackCharacters" ) >>= bStackCharacters; + xProp->getPropertyValue( "TextRotation" ) >>= fRotationAngleDegree; + + css::chart::ChartAxisArrangeOrderType eArrangeOrder; + xProp->getPropertyValue( "ArrangeOrder" ) >>= eArrangeOrder; + switch(eArrangeOrder) { - xProp->getPropertyValue( "TextBreak" ) >>= bLineBreakAllowed; - xProp->getPropertyValue( "TextOverlap" ) >>= bOverlapAllowed; - xProp->getPropertyValue( "StackCharacters" ) >>= bStackCharacters; - xProp->getPropertyValue( "TextRotation" ) >>= fRotationAngleDegree; - - css::chart::ChartAxisArrangeOrderType eArrangeOrder; - xProp->getPropertyValue( "ArrangeOrder" ) >>= eArrangeOrder; - switch(eArrangeOrder) - { - case css::chart::ChartAxisArrangeOrderType_SIDE_BY_SIDE: - eStaggering = AxisLabelStaggering::SideBySide; - break; - case css::chart::ChartAxisArrangeOrderType_STAGGER_EVEN: - eStaggering = AxisLabelStaggering::StaggerEven; - break; - case css::chart::ChartAxisArrangeOrderType_STAGGER_ODD: - eStaggering = AxisLabelStaggering::StaggerOdd; - break; - default: - eStaggering = AxisLabelStaggering::StaggerAuto; - break; - } - } - catch( const uno::Exception& ) - { - TOOLS_WARN_EXCEPTION("chart2", "" ); + case css::chart::ChartAxisArrangeOrderType_SIDE_BY_SIDE: + eStaggering = AxisLabelStaggering::SideBySide; + break; + case css::chart::ChartAxisArrangeOrderType_STAGGER_EVEN: + eStaggering = AxisLabelStaggering::StaggerEven; + break; + case css::chart::ChartAxisArrangeOrderType_STAGGER_ODD: + eStaggering = AxisLabelStaggering::StaggerOdd; + break; + default: + eStaggering = AxisLabelStaggering::StaggerAuto; + break; } } + catch( const uno::Exception& ) + { + TOOLS_WARN_EXCEPTION("chart2", "" ); + } } bool AxisLabelProperties::isStaggered() const diff --git a/chart2/source/view/axes/VCartesianAxis.cxx b/chart2/source/view/axes/VCartesianAxis.cxx index dbf360ad8ab0..d4183118cca5 100644 --- a/chart2/source/view/axes/VCartesianAxis.cxx +++ b/chart2/source/view/axes/VCartesianAxis.cxx @@ -105,18 +105,18 @@ static void lcl_ResizeTextShapeToFitAvailableSpace( Reference< drawing::XShape > nNewLen = ( rLabel.getLength() >= sDots.getLength() ) ? sDots.getLength() : rLabel.getLength(); bool bCrop = nCharsToRemove > 0; - if( bCrop ) - { - OUString aNewLabel = rLabel.copy( 0, nNewLen ); - if( nNewLen > sDots.getLength() ) - aNewLabel += sDots; - xTextRange->setString( aNewLabel ); + if( !bCrop ) + return; - uno::Reference< beans::XPropertySet > xProp( xTextRange, uno::UNO_QUERY ); - if( xProp.is() ) - { - PropertyMapper::setMultiProperties( rPropNames, rPropValues, xProp ); - } + OUString aNewLabel = rLabel.copy( 0, nNewLen ); + if( nNewLen > sDots.getLength() ) + aNewLabel += sDots; + xTextRange->setString( aNewLabel ); + + uno::Reference< beans::XPropertySet > xProp( xTextRange, uno::UNO_QUERY ); + if( xProp.is() ) + { + PropertyMapper::setMultiProperties( rPropNames, rPropValues, xProp ); } } @@ -1448,65 +1448,65 @@ void VCartesianAxis::get2DAxisMainLine( if(m_nDimension==3 && !AxisHelper::isAxisPositioningEnabled() ) rAlignment.mfInnerTickDirection = rAlignment.mfLabelDirection;//to behave like before - if(m_nDimension==3 && AxisHelper::isAxisPositioningEnabled() ) - { - double fDeltaX = rEnd.getX() - rStart.getX(); - double fDeltaY = rEnd.getY() - rStart.getY(); - - if( m_nDimensionIndex==2 ) - { - if( m_eLeftWallPos != CuboidPlanePosition_Left ) - { - rAlignment.mfLabelDirection *= -1.0; - rAlignment.mfInnerTickDirection *= -1.0; - } + if(!(m_nDimension==3 && AxisHelper::isAxisPositioningEnabled()) ) + return; - rAlignment.meAlignment = - (rAlignment.mfLabelDirection < 0) ? - LABEL_ALIGN_LEFT : LABEL_ALIGN_RIGHT; + double fDeltaX = rEnd.getX() - rStart.getX(); + double fDeltaY = rEnd.getY() - rStart.getY(); - if( ( fDeltaY<0 && m_aScale.Orientation == chart2::AxisOrientation_REVERSE ) || - ( fDeltaY>0 && m_aScale.Orientation == chart2::AxisOrientation_MATHEMATICAL ) ) - rAlignment.meAlignment = - (rAlignment.meAlignment == LABEL_ALIGN_RIGHT) ? - LABEL_ALIGN_LEFT : LABEL_ALIGN_RIGHT; - } - else if( fabs(fDeltaY) > fabs(fDeltaX) ) + if( m_nDimensionIndex==2 ) + { + if( m_eLeftWallPos != CuboidPlanePosition_Left ) { - if( m_eBackWallPos != CuboidPlanePosition_Back ) - { - rAlignment.mfLabelDirection *= -1.0; - rAlignment.mfInnerTickDirection *= -1.0; - } + rAlignment.mfLabelDirection *= -1.0; + rAlignment.mfInnerTickDirection *= -1.0; + } + rAlignment.meAlignment = + (rAlignment.mfLabelDirection < 0) ? + LABEL_ALIGN_LEFT : LABEL_ALIGN_RIGHT; + + if( ( fDeltaY<0 && m_aScale.Orientation == chart2::AxisOrientation_REVERSE ) || + ( fDeltaY>0 && m_aScale.Orientation == chart2::AxisOrientation_MATHEMATICAL ) ) rAlignment.meAlignment = - (rAlignment.mfLabelDirection < 0) ? + (rAlignment.meAlignment == LABEL_ALIGN_RIGHT) ? LABEL_ALIGN_LEFT : LABEL_ALIGN_RIGHT; - - if( ( fDeltaY<0 && m_aScale.Orientation == chart2::AxisOrientation_REVERSE ) || - ( fDeltaY>0 && m_aScale.Orientation == chart2::AxisOrientation_MATHEMATICAL ) ) - rAlignment.meAlignment = - (rAlignment.meAlignment == LABEL_ALIGN_RIGHT) ? - LABEL_ALIGN_LEFT : LABEL_ALIGN_RIGHT; - } - else + } + else if( fabs(fDeltaY) > fabs(fDeltaX) ) + { + if( m_eBackWallPos != CuboidPlanePosition_Back ) { - if( m_eBackWallPos != CuboidPlanePosition_Back ) - { - rAlignment.mfLabelDirection *= -1.0; - rAlignment.mfInnerTickDirection *= -1.0; - } + rAlignment.mfLabelDirection *= -1.0; + rAlignment.mfInnerTickDirection *= -1.0; + } + rAlignment.meAlignment = + (rAlignment.mfLabelDirection < 0) ? + LABEL_ALIGN_LEFT : LABEL_ALIGN_RIGHT; + + if( ( fDeltaY<0 && m_aScale.Orientation == chart2::AxisOrientation_REVERSE ) || + ( fDeltaY>0 && m_aScale.Orientation == chart2::AxisOrientation_MATHEMATICAL ) ) rAlignment.meAlignment = - (rAlignment.mfLabelDirection < 0) ? - LABEL_ALIGN_TOP : LABEL_ALIGN_BOTTOM; - - if( ( fDeltaX>0 && m_aScale.Orientation == chart2::AxisOrientation_REVERSE ) || - ( fDeltaX<0 && m_aScale.Orientation == chart2::AxisOrientation_MATHEMATICAL ) ) - rAlignment.meAlignment = - (rAlignment.meAlignment == LABEL_ALIGN_TOP) ? - LABEL_ALIGN_BOTTOM : LABEL_ALIGN_TOP; + (rAlignment.meAlignment == LABEL_ALIGN_RIGHT) ? + LABEL_ALIGN_LEFT : LABEL_ALIGN_RIGHT; + } + else + { + if( m_eBackWallPos != CuboidPlanePosition_Back ) + { + rAlignment.mfLabelDirection *= -1.0; + rAlignment.mfInnerTickDirection *= -1.0; } + + rAlignment.meAlignment = + (rAlignment.mfLabelDirection < 0) ? + LABEL_ALIGN_TOP : LABEL_ALIGN_BOTTOM; + + if( ( fDeltaX>0 && m_aScale.Orientation == chart2::AxisOrientation_REVERSE ) || + ( fDeltaX<0 && m_aScale.Orientation == chart2::AxisOrientation_MATHEMATICAL ) ) + rAlignment.meAlignment = + (rAlignment.meAlignment == LABEL_ALIGN_TOP) ? + LABEL_ALIGN_BOTTOM : LABEL_ALIGN_TOP; } } diff --git a/chart2/source/view/axes/VPolarAngleAxis.cxx b/chart2/source/view/axes/VPolarAngleAxis.cxx index cc2427a87581..f9b7399694b0 100644 --- a/chart2/source/view/axes/VPolarAngleAxis.cxx +++ b/chart2/source/view/axes/VPolarAngleAxis.cxx @@ -160,26 +160,26 @@ void VPolarAngleAxis::createLabels() double fLogicRadius = m_pPosHelper->getOuterLogicRadius(); - if( m_aAxisProperties.m_bDisplayLabels ) - { - //create tick mark text shapes - //@todo: iterate through all tick depth which should be labeled + if( !m_aAxisProperties.m_bDisplayLabels ) + return; - EquidistantTickIter aTickIter( m_aAllTickInfos, m_aIncrement, 0 ); - updateUnscaledValuesAtTicks( aTickIter ); + //create tick mark text shapes + //@todo: iterate through all tick depth which should be labeled - removeTextShapesFromTicks(); + EquidistantTickIter aTickIter( m_aAllTickInfos, m_aIncrement, 0 ); + updateUnscaledValuesAtTicks( aTickIter ); - AxisLabelProperties aAxisLabelProperties( m_aAxisLabelProperties ); - aAxisLabelProperties.bOverlapAllowed = true; - double const fLogicZ = 1.0;//as defined - createTextShapes_ForAngleAxis( m_xTextTarget, aTickIter - , aAxisLabelProperties - , fLogicRadius, fLogicZ - ); + removeTextShapesFromTicks(); - //no staggering for polar angle axis - } + AxisLabelProperties aAxisLabelProperties( m_aAxisLabelProperties ); + aAxisLabelProperties.bOverlapAllowed = true; + double const fLogicZ = 1.0;//as defined + createTextShapes_ForAngleAxis( m_xTextTarget, aTickIter + , aAxisLabelProperties + , fLogicRadius, fLogicZ + ); + + //no staggering for polar angle axis } void VPolarAngleAxis::createShapes() diff --git a/chart2/source/view/charttypes/BarChart.cxx b/chart2/source/view/charttypes/BarChart.cxx index 88e8f6e4b502..3641e67b4657 100644 --- a/chart2/source/view/charttypes/BarChart.cxx +++ b/chart2/source/view/charttypes/BarChart.cxx @@ -415,27 +415,27 @@ void BarChart::adaptOverlapAndGapwidthForGroupBarsPerAxis() //thus the different series use the same settings VDataSeries* pFirstSeries = getFirstSeries(); - if(pFirstSeries && !pFirstSeries->getGroupBarsPerAxis() ) + if(!(pFirstSeries && !pFirstSeries->getGroupBarsPerAxis()) ) + return; + + sal_Int32 nAxisIndex = pFirstSeries->getAttachedAxisIndex(); + sal_Int32 nN = 0; + sal_Int32 nUseThisIndex = nAxisIndex; + if( nUseThisIndex < 0 || nUseThisIndex >= m_aOverlapSequence.getLength() ) + nUseThisIndex = 0; + for( nN = 0; nN < m_aOverlapSequence.getLength(); nN++ ) { - sal_Int32 nAxisIndex = pFirstSeries->getAttachedAxisIndex(); - sal_Int32 nN = 0; - sal_Int32 nUseThisIndex = nAxisIndex; - if( nUseThisIndex < 0 || nUseThisIndex >= m_aOverlapSequence.getLength() ) - nUseThisIndex = 0; - for( nN = 0; nN < m_aOverlapSequence.getLength(); nN++ ) - { - if(nN!=nUseThisIndex) - m_aOverlapSequence[nN] = m_aOverlapSequence[nUseThisIndex]; - } + if(nN!=nUseThisIndex) + m_aOverlapSequence[nN] = m_aOverlapSequence[nUseThisIndex]; + } - nUseThisIndex = nAxisIndex; - if( nUseThisIndex < 0 || nUseThisIndex >= m_aGapwidthSequence.getLength() ) - nUseThisIndex = 0; - for( nN = 0; nN < m_aGapwidthSequence.getLength(); nN++ ) - { - if(nN!=nUseThisIndex) - m_aGapwidthSequence[nN] = m_aGapwidthSequence[nUseThisIndex]; - } + nUseThisIndex = nAxisIndex; + if( nUseThisIndex < 0 || nUseThisIndex >= m_aGapwidthSequence.getLength() ) + nUseThisIndex = 0; + for( nN = 0; nN < m_aGapwidthSequence.getLength(); nN++ ) + { + if(nN!=nUseThisIndex) + m_aGapwidthSequence[nN] = m_aGapwidthSequence[nUseThisIndex]; } } diff --git a/chart2/source/view/charttypes/PieChart.cxx b/chart2/source/view/charttypes/PieChart.cxx index 0214d0f6a0eb..0e3829c00ab2 100644 --- a/chart2/source/view/charttypes/PieChart.cxx +++ b/chart2/source/view/charttypes/PieChart.cxx @@ -182,7 +182,10 @@ PieChart::PieChart( const uno::Reference<XChartType>& xChartTypeModel m_pPosHelper->m_fRingDistance = 0.0; uno::Reference< beans::XPropertySet > xChartTypeProps( xChartTypeModel, uno::UNO_QUERY ); - if( xChartTypeProps.is() ) try + if( !xChartTypeProps.is() ) + return; + + try { xChartTypeProps->getPropertyValue( "UseRings") >>= m_bUseRings; if( m_bUseRings ) @@ -1573,21 +1576,21 @@ void PieChart::performLabelBestFit(ShapeParam& rShapeParam, PieLabelInfo const & if( m_bUseRings ) return; - if( !performLabelBestFitInnerPlacement(rShapeParam, rPieLabelInfo) ) - { - // If it does not fit inside, let's put it outside - PolarLabelPositionHelper aPolarPosHelper(m_pPosHelper.get(),m_nDimension,m_xLogicTarget,m_pShapeFactory); - auto eAlignment = LABEL_ALIGN_CENTER; - awt::Point aScreenPosition2D( - aPolarPosHelper.getLabelScreenPositionAndAlignmentForUnitCircleValues(eAlignment, css::chart::DataLabelPlacement::OUTSIDE - , rShapeParam.mfUnitCircleStartAngleDegree, rShapeParam.mfUnitCircleWidthAngleDegree - , rShapeParam.mfUnitCircleInnerRadius, rShapeParam.mfUnitCircleOuterRadius, rShapeParam.mfLogicZ+0.5, 0 )); - basegfx::B2IVector aTranslationVector = rPieLabelInfo.aFirstPosition - rPieLabelInfo.aOrigin; - aTranslationVector.setLength(150); - aScreenPosition2D.X += aTranslationVector.getX(); - aScreenPosition2D.Y += aTranslationVector.getY(); - rPieLabelInfo.xLabelGroupShape->setPosition(aScreenPosition2D); - } + if( performLabelBestFitInnerPlacement(rShapeParam, rPieLabelInfo) ) + return; + + // If it does not fit inside, let's put it outside + PolarLabelPositionHelper aPolarPosHelper(m_pPosHelper.get(),m_nDimension,m_xLogicTarget,m_pShapeFactory); + auto eAlignment = LABEL_ALIGN_CENTER; + awt::Point aScreenPosition2D( + aPolarPosHelper.getLabelScreenPositionAndAlignmentForUnitCircleValues(eAlignment, css::chart::DataLabelPlacement::OUTSIDE + , rShapeParam.mfUnitCircleStartAngleDegree, rShapeParam.mfUnitCircleWidthAngleDegree + , rShapeParam.mfUnitCircleInnerRadius, rShapeParam.mfUnitCircleOuterRadius, rShapeParam.mfLogicZ+0.5, 0 )); + basegfx::B2IVector aTranslationVector = rPieLabelInfo.aFirstPosition - rPieLabelInfo.aOrigin; + aTranslationVector.setLength(150); + aScreenPosition2D.X += aTranslationVector.getX(); + aScreenPosition2D.Y += aTranslationVector.getY(); + rPieLabelInfo.xLabelGroupShape->setPosition(aScreenPosition2D); } } //namespace chart diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx index 492dcc8a00da..0696efc9dcbb 100644 --- a/chart2/source/view/charttypes/VSeriesPlotter.cxx +++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx @@ -1504,129 +1504,129 @@ void VSeriesPlotter::createRegressionCurveEquationShapes( bool bShowEquation = false; bool bShowCorrCoeff = false; - if(( xEquationProperties->getPropertyValue( "ShowEquation") >>= bShowEquation ) && - ( xEquationProperties->getPropertyValue( "ShowCorrelationCoefficient") >>= bShowCorrCoeff )) - { - if( ! (bShowEquation || bShowCorrCoeff)) - return; + if(!(( xEquationProperties->getPropertyValue( "ShowEquation") >>= bShowEquation ) && + ( xEquationProperties->getPropertyValue( "ShowCorrelationCoefficient") >>= bShowCorrCoeff ))) + return; - OUStringBuffer aFormula; - sal_Int32 nNumberFormatKey = 0; - sal_Int32 nFormulaWidth = 0; - xEquationProperties->getPropertyValue(CHART_UNONAME_NUMFMT) >>= nNumberFormatKey; - bool bResizeEquation = true; - sal_Int32 nMaxIteration = 2; - if ( bShowEquation ) - { - OUString aXName, aYName; - if ( !(xEquationProperties->getPropertyValue( "XName" ) >>= aXName) ) - aXName = OUString( "x" ); - if ( !(xEquationProperties->getPropertyValue( "YName" ) >>= aYName) ) - aYName = OUString( "f(x)" ); - xRegressionCurveCalculator->setXYNames( aXName, aYName ); - } + if( ! (bShowEquation || bShowCorrCoeff)) + return; - for ( sal_Int32 nCountIteration = 0; bResizeEquation && nCountIteration < nMaxIteration ; nCountIteration++ ) - { - bResizeEquation = false; - if( bShowEquation ) + OUStringBuffer aFormula; + sal_Int32 nNumberFormatKey = 0; + sal_Int32 nFormulaWidth = 0; + xEquationProperties->getPropertyValue(CHART_UNONAME_NUMFMT) >>= nNumberFormatKey; + bool bResizeEquation = true; + sal_Int32 nMaxIteration = 2; + if ( bShowEquation ) + { + OUString aXName, aYName; + if ( !(xEquationProperties->getPropertyValue( "XName" ) >>= aXName) ) + aXName = OUString( "x" ); + if ( !(xEquationProperties->getPropertyValue( "YName" ) >>= aYName) ) + aYName = OUString( "f(x)" ); + xRegressionCurveCalculator->setXYNames( aXName, aYName ); + } + + for ( sal_Int32 nCountIteration = 0; bResizeEquation && nCountIteration < nMaxIteration ; nCountIteration++ ) + { + bResizeEquation = false; + if( bShowEquation ) + { + if (m_apNumberFormatterWrapper) + { // iteration 0: default representation (no wrap) + // iteration 1: expected width (nFormulaWidth) is calculated + aFormula = xRegressionCurveCalculator->getFormattedRepresentation( + m_apNumberFormatterWrapper->getNumberFormatsSupplier(), + nNumberFormatKey, nFormulaWidth ); + nFormulaWidth = lcl_getOUStringMaxLineLength( aFormula ); + } + else { - if (m_apNumberFormatterWrapper) - { // iteration 0: default representation (no wrap) - // iteration 1: expected width (nFormulaWidth) is calculated - aFormula = xRegressionCurveCalculator->getFormattedRepresentation( - m_apNumberFormatterWrapper->getNumberFormatsSupplier(), - nNumberFormatKey, nFormulaWidth ); - nFormulaWidth = lcl_getOUStringMaxLineLength( aFormula ); - } - else - { - aFormula = xRegressionCurveCalculator->getRepresentation(); - } - - if( bShowCorrCoeff ) - { - aFormula.append( "\n" ); - } + aFormula = xRegressionCurveCalculator->getRepresentation(); } + if( bShowCorrCoeff ) { - aFormula.append( "R" ).append( OUStringChar( aSuperscriptFigures[2] ) ).append( " = " ); - double fR( xRegressionCurveCalculator->getCorrelationCoefficient()); - if (m_apNumberFormatterWrapper) - { - Color nLabelCol; - bool bColChanged; - aFormula.append( - m_apNumberFormatterWrapper->getFormattedString( - nNumberFormatKey, fR*fR, nLabelCol, bColChanged )); - //@todo: change color of label if bColChanged is true - } - else - { - const LocaleDataWrapper& rLocaleDataWrapper = Application::GetSettings().GetLocaleDataWrapper(); - const OUString& aNumDecimalSep = rLocaleDataWrapper.getNumDecimalSep(); - sal_Unicode aDecimalSep = aNumDecimalSep[0]; - aFormula.append( ::rtl::math::doubleToUString( - fR*fR, rtl_math_StringFormat_G, 4, aDecimalSep, true )); - } + aFormula.append( "\n" ); } - - awt::Point aScreenPosition2D; - chart2::RelativePosition aRelativePosition; - if( xEquationProperties->getPropertyValue( "RelativePosition") >>= aRelativePosition ) + } + if( bShowCorrCoeff ) + { + aFormula.append( "R" ).append( OUStringChar( aSuperscriptFigures[2] ) ).append( " = " ); + double fR( xRegressionCurveCalculator->getCorrelationCoefficient()); + if (m_apNumberFormatterWrapper) { - //@todo decide whether x is primary or secondary - double fX = aRelativePosition.Primary*m_aPageReferenceSize.Width; - double fY = aRelativePosition.Secondary*m_aPageReferenceSize.Height; - aScreenPosition2D.X = static_cast< sal_Int32 >( ::rtl::math::round( fX )); - aScreenPosition2D.Y = static_cast< sal_Int32 >( ::rtl::math::round( fY )); + Color nLabelCol; + bool bColChanged; + aFormula.append( + m_apNumberFormatterWrapper->getFormattedString( + nNumberFormatKey, fR*fR, nLabelCol, bColChanged )); + //@todo: change color of label if bColChanged is true } else - aScreenPosition2D = aDefaultPos; - - if( !aFormula.isEmpty()) { - // set fill and line properties on creation - tNameSequence aNames; - tAnySequence aValues; - PropertyMapper::getPreparedTextShapePropertyLists( xEquationProperties, aNames, aValues ); + const LocaleDataWrapper& rLocaleDataWrapper = Application::GetSettings().GetLocaleDataWrapper(); + const OUString& aNumDecimalSep = rLocaleDataWrapper.getNumDecimalSep(); + sal_Unicode aDecimalSep = aNumDecimalSep[0]; + aFormula.append( ::rtl::math::doubleToUString( + fR*fR, rtl_math_StringFormat_G, 4, aDecimalSep, true )); + } + } - uno::Reference< drawing::XShape > xTextShape = m_pShapeFactory->createText( - xEquationTarget, aFormula.makeStringAndClear(), - aNames, aValues, ShapeFactory::makeTransformation( aScreenPosition2D )); + awt::Point aScreenPosition2D; + chart2::RelativePosition aRelativePosition; + if( xEquationProperties->getPropertyValue( "RelativePosition") >>= aRelativePosition ) + { + //@todo decide whether x is primary or secondary + double fX = aRelativePosition.Primary*m_aPageReferenceSize.Width; + double fY = aRelativePosition.Secondary*m_aPageReferenceSize.Height; + aScreenPosition2D.X = static_cast< sal_Int32 >( ::rtl::math::round( fX )); + aScreenPosition2D.Y = static_cast< sal_Int32 >( ::rtl::math::round( fY )); + } + else + aScreenPosition2D = aDefaultPos; + + if( !aFormula.isEmpty()) + { + // set fill and line properties on creation + tNameSequence aNames; + tAnySequence aValues; + PropertyMapper::getPreparedTextShapePropertyLists( xEquationProperties, aNames, aValues ); - OSL_ASSERT( xTextShape.is()); - if( xTextShape.is()) + uno::Reference< drawing::XShape > xTextShape = m_pShapeFactory->createText( + xEquationTarget, aFormula.makeStringAndClear(), + aNames, aValues, ShapeFactory::makeTransformation( aScreenPosition2D )); + + OSL_ASSERT( xTextShape.is()); + if( xTextShape.is()) + { + ShapeFactory::setShapeName( xTextShape, rEquationCID ); + awt::Size aSize( xTextShape->getSize() ); + awt::Point aPos( RelativePositionHelper::getUpperLeftCornerOfAnchoredObject( + aScreenPosition2D, aSize, aRelativePosition.Anchor ) ); + //ensure that the equation is fully placed within the page (if possible) + if( (aPos.X + aSize.Width) > m_aPageReferenceSize.Width ) + aPos.X = m_aPageReferenceSize.Width - aSize.Width; + if( aPos.X < 0 ) { - ShapeFactory::setShapeName( xTextShape, rEquationCID ); - awt::Size aSize( xTextShape->getSize() ); - awt::Point aPos( RelativePositionHelper::getUpperLeftCornerOfAnchoredObject( - aScreenPosition2D, aSize, aRelativePosition.Anchor ) ); - //ensure that the equation is fully placed within the page (if possible) - if( (aPos.X + aSize.Width) > m_aPageReferenceSize.Width ) - aPos.X = m_aPageReferenceSize.Width - aSize.Width; - if( aPos.X < 0 ) + aPos.X = 0; + if ( nFormulaWidth > 0 ) { - aPos.X = 0; - if ( nFormulaWidth > 0 ) - { - bResizeEquation = true; - if ( nCountIteration < nMaxIteration-1 ) - xEquationTarget->remove( xTextShape ); // remove equation - nFormulaWidth *= m_aPageReferenceSize.Width / static_cast< double >(aSize.Width); - nFormulaWidth -= nCountIteration; - if ( nFormulaWidth < 0 ) - nFormulaWidth = 0; - } + bResizeEquation = true; + if ( nCountIteration < nMaxIteration-1 ) + xEquationTarget->remove( xTextShape ); // remove equation + nFormulaWidth *= m_aPageReferenceSize.Width / static_cast< double >(aSize.Width); + nFormulaWidth -= nCountIteration; + if ( nFormulaWidth < 0 ) + nFormulaWidth = 0; } - if( (aPos.Y + aSize.Height) > m_aPageReferenceSize.Height ) - aPos.Y = m_aPageReferenceSize.Height - aSize.Height; - if( aPos.Y < 0 ) - aPos.Y = 0; - if ( !bResizeEquation || nCountIteration == nMaxIteration-1 ) - xTextShape->setPosition(aPos); // if equation was not removed } + if( (aPos.Y + aSize.Height) > m_aPageReferenceSize.Height ) + aPos.Y = m_aPageReferenceSize.Height - aSize.Height; + if( aPos.Y < 0 ) + aPos.Y = 0; + if ( !bResizeEquation || nCountIteration == nMaxIteration-1 ) + xTextShape->setPosition(aPos); // if equation was not removed } } } diff --git a/chart2/source/view/diagram/VDiagram.cxx b/chart2/source/view/diagram/VDiagram.cxx index a1fc30442898..bf9b9b70d343 100644 --- a/chart2/source/view/diagram/VDiagram.cxx +++ b/chart2/source/view/diagram/VDiagram.cxx @@ -53,20 +53,20 @@ VDiagram::VDiagram( , m_fZAnglePi(0) , m_bRightAngledAxes(false) { - if( m_nDimensionCount == 3) + if( m_nDimensionCount != 3) + return; + + uno::Reference< beans::XPropertySet > xSourceProp( m_xDiagram, uno::UNO_QUERY ); + ThreeDHelper::getRotationAngleFromDiagram( xSourceProp, m_fXAnglePi, m_fYAnglePi, m_fZAnglePi ); + if( ChartTypeHelper::isSupportingRightAngledAxes( + DiagramHelper::getChartTypeByIndex( m_xDiagram, 0 ) ) ) { - uno::Reference< beans::XPropertySet > xSourceProp( m_xDiagram, uno::UNO_QUERY ); - ThreeDHelper::getRotationAngleFromDiagram( xSourceProp, m_fXAnglePi, m_fYAnglePi, m_fZAnglePi ); - if( ChartTypeHelper::isSupportingRightAngledAxes( - DiagramHelper::getChartTypeByIndex( m_xDiagram, 0 ) ) ) + if(xSourceProp.is()) + xSourceProp->getPropertyValue("RightAngledAxes") >>= m_bRightAngledAxes; + if( m_bRightAngledAxes ) { - if(xSourceProp.is()) - xSourceProp->getPropertyValue("RightAngledAxes") >>= m_bRightAngledAxes; - if( m_bRightAngledAxes ) - { - ThreeDHelper::adaptRadAnglesForRightAngledAxes( m_fXAnglePi, m_fYAnglePi ); - m_fZAnglePi=0.0; - } + ThreeDHelper::adaptRadAnglesForRightAngledAxes( m_fXAnglePi, m_fYAnglePi ); + m_fZAnglePi=0.0; } } } @@ -290,150 +290,150 @@ void lcl_ensureScaleValue( double& rfScale ) void VDiagram::adjustAspectRatio3d( const awt::Size& rAvailableSize ) { OSL_PRECOND(m_xAspectRatio3D.is(), "created shape offers no XPropertySet"); - if( m_xAspectRatio3D.is()) + if( !m_xAspectRatio3D.is()) + return; + + try { - try + double fScaleX = m_aPreferredAspectRatio.DirectionX; + double fScaleY = m_aPreferredAspectRatio.DirectionY; + double fScaleZ = m_aPreferredAspectRatio.DirectionZ; + + //normalize scale factors { - double fScaleX = m_aPreferredAspectRatio.DirectionX; - double fScaleY = m_aPreferredAspectRatio.DirectionY; - double fScaleZ = m_aPreferredAspectRatio.DirectionZ; + double fMax = std::max( std::max( fScaleX, fScaleY) , fScaleZ ); + fScaleX/=fMax; + fScaleY/=fMax; + fScaleZ/=fMax; + } - //normalize scale factors - { - double fMax = std::max( std::max( fScaleX, fScaleY) , fScaleZ ); - fScaleX/=fMax; - fScaleY/=fMax; - fScaleZ/=fMax; - } + if( fScaleX<0 || fScaleY<0 || fScaleZ<0 ) + { + //calculate automatic 3D aspect ratio that fits good into the given 2D area + double fW = rAvailableSize.Width; + double fH = rAvailableSize.Height; - if( fScaleX<0 || fScaleY<0 || fScaleZ<0 ) - { - //calculate automatic 3D aspect ratio that fits good into the given 2D area - double fW = rAvailableSize.Width; - double fH = rAvailableSize.Height; + double sx = fabs(sin(m_fXAnglePi)); + double sy = fabs(sin(m_fYAnglePi)); + double cz = fabs(cos(m_fZAnglePi)); + double sz = fabs(sin(m_fZAnglePi)); - double sx = fabs(sin(m_fXAnglePi)); - double sy = fabs(sin(m_fYAnglePi)); - double cz = fabs(cos(m_fZAnglePi)); - double sz = fabs(sin(m_fZAnglePi)); + if(m_bRightAngledAxes) + { + //base equations: + //fH*zoomfactor == sx*fScaleZ + fScaleY; + //fW*zoomfactor == sy*fScaleZ + fScaleX; - if(m_bRightAngledAxes) + if( fScaleX>0 && fScaleZ>0 ) { - //base equations: - //fH*zoomfactor == sx*fScaleZ + fScaleY; - //fW*zoomfactor == sy*fScaleZ + fScaleX; - - if( fScaleX>0 && fScaleZ>0 ) - { - //calculate fScaleY: - if( !::basegfx::fTools::equalZero(fW) ) - { - fScaleY = (fH/fW)*(sy*fScaleZ+fScaleX)-(sx*fScaleZ); - lcl_ensureScaleValue( fScaleY ); - } - else - fScaleY = 1.0;//looking from top or bottom the height is irrelevant - } - else if( fScaleY>0 && fScaleZ>0 ) + //calculate fScaleY: + if( !::basegfx::fTools::equalZero(fW) ) { - //calculate fScaleX: - if( !::basegfx::fTools::equalZero(fH) ) - { - fScaleX = (fW/fH)*(sx*fScaleZ+fScaleY)-(sy*fScaleZ); - lcl_ensureScaleValue(fScaleX); - } - else - fScaleX = 1.0;//looking from top or bottom height is irrelevant + fScaleY = (fH/fW)*(sy*fScaleZ+fScaleX)-(sx*fScaleZ); + lcl_ensureScaleValue( fScaleY ); } else + fScaleY = 1.0;//looking from top or bottom the height is irrelevant + } + else if( fScaleY>0 && fScaleZ>0 ) + { + //calculate fScaleX: + if( !::basegfx::fTools::equalZero(fH) ) { - //todo - OSL_FAIL("not implemented yet"); - - if( fScaleX<0 ) - fScaleX = 1.0; - if( fScaleY<0 ) - fScaleY = 1.0; - if( fScaleZ<0 ) - fScaleZ = 1.0; + fScaleX = (fW/fH)*(sx*fScaleZ+fScaleY)-(sy*fScaleZ); + lcl_ensureScaleValue(fScaleX); } + else + fScaleX = 1.0;//looking from top or bottom height is irrelevant } else { - //base equations: - //fH*zoomfactor == cz*fScaleY + sz*fScaleX; - //fW*zoomfactor == cz*fScaleX + sz*fScaleY; - //==> fScaleY*(fH*sz-fW*cz) == fScaleX*(fW*sz-fH*cz); - if( fScaleX>0 && fScaleZ>0 ) - { - //calculate fScaleY: - double fDivide = fH*sz-fW*cz; - if( !::basegfx::fTools::equalZero(fDivide) ) - { - fScaleY = fScaleX*(fW*sz-fH*cz) / fDivide; - lcl_ensureScaleValue(fScaleY); - } - else - fScaleY = 1.0;//looking from top or bottom the height is irrelevant - - } - else if( fScaleY>0 && fScaleZ>0 ) + //todo + OSL_FAIL("not implemented yet"); + + if( fScaleX<0 ) + fScaleX = 1.0; + if( fScaleY<0 ) + fScaleY = 1.0; + if( fScaleZ<0 ) + fScaleZ = 1.0; + } + } + else + { + //base equations: + //fH*zoomfactor == cz*fScaleY + sz*fScaleX; + //fW*zoomfactor == cz*fScaleX + sz*fScaleY; + //==> fScaleY*(fH*sz-fW*cz) == fScaleX*(fW*sz-fH*cz); + if( fScaleX>0 && fScaleZ>0 ) + { + //calculate fScaleY: + double fDivide = fH*sz-fW*cz; + if( !::basegfx::fTools::equalZero(fDivide) ) { - //calculate fScaleX: - double fDivide = fW*sz-fH*cz; - if( !::basegfx::fTools::equalZero(fDivide) ) - { - fScaleX = fScaleY*(fH*sz-fW*cz) / fDivide; - lcl_ensureScaleValue(fScaleX); - } - else - fScaleX = 1.0;//looking from top or bottom height is irrelevant + fScaleY = fScaleX*(fW*sz-fH*cz) / fDivide; + lcl_ensureScaleValue(fScaleY); } else + fScaleY = 1.0;//looking from top or bottom the height is irrelevant + + } + else if( fScaleY>0 && fScaleZ>0 ) + { + //calculate fScaleX: + double fDivide = fW*sz-fH*cz; + if( !::basegfx::fTools::equalZero(fDivide) ) { - //todo - OSL_FAIL("not implemented yet"); - - if( fScaleX<0 ) - fScaleX = 1.0; - if( fScaleY<0 ) - fScaleY = 1.0; - if( fScaleZ<0 ) - fScaleZ = 1.0; + fScaleX = fScaleY*(fH*sz-fW*cz) / fDivide; + lcl_ensureScaleValue(fScaleX); } + else + fScaleX = 1.0;//looking from top or bottom height is irrelevant + } + else + { + //todo + OSL_FAIL("not implemented yet"); + + if( fScaleX<0 ) + fScaleX = 1.0; + if( fScaleY<0 ) + fScaleY = 1.0; + if( fScaleZ<0 ) + fScaleZ = 1.0; } } - - //normalize scale factors - { - double fMax = std::max( std::max( fScaleX, fScaleY) , fScaleZ ); - fScaleX/=fMax; - fScaleY/=fMax; - fScaleZ/=fMax; - } - - // identity matrix - ::basegfx::B3DHomMatrix aResult; - aResult.translate( -FIXED_SIZE_FOR_3D_CHART_VOLUME/2.0, - -FIXED_SIZE_FOR_3D_CHART_VOLUME/2.0, - -FIXED_SIZE_FOR_3D_CHART_VOLUME/2.0 ); - aResult.scale( fScaleX, fScaleY, fScaleZ ); - aResult.translate( FIXED_SIZE_FOR_3D_CHART_VOLUME/2.0, - FIXED_SIZE_FOR_3D_CHART_VOLUME/2.0, - FIXED_SIZE_FOR_3D_CHART_VOLUME/2.0 ); - - // To get the 3D aspect ratio's effect on the 2D scene size, the scene's 2D size needs to be adapted to - // 3D content changes here. The tooling class remembers the current 3D transformation stack - // and in its destructor, calculates a new 2D SnapRect for the scene and it's modified 3D geometry. - E3DModifySceneSnapRectUpdater aUpdater(lcl_getE3dScene(m_xOuterGroupShape)); - - m_xAspectRatio3D->setPropertyValue( UNO_NAME_3D_TRANSFORM_MATRIX - , uno::Any(BaseGFXHelper::B3DHomMatrixToHomogenMatrix( aResult )) ); } - catch( const uno::Exception& ) + + //normalize scale factors { - TOOLS_WARN_EXCEPTION("chart2", "" ); + double fMax = std::max( std::max( fScaleX, fScaleY) , fScaleZ ); + fScaleX/=fMax; + fScaleY/=fMax; + fScaleZ/=fMax; } + + // identity matrix + ::basegfx::B3DHomMatrix aResult; + aResult.translate( -FIXED_SIZE_FOR_3D_CHART_VOLUME/2.0, + -FIXED_SIZE_FOR_3D_CHART_VOLUME/2.0, + -FIXED_SIZE_FOR_3D_CHART_VOLUME/2.0 ); + aResult.scale( fScaleX, fScaleY, fScaleZ ); + aResult.translate( FIXED_SIZE_FOR_3D_CHART_VOLUME/2.0, + FIXED_SIZE_FOR_3D_CHART_VOLUME/2.0, + FIXED_SIZE_FOR_3D_CHART_VOLUME/2.0 ); + + // To get the 3D aspect ratio's effect on the 2D scene size, the scene's 2D size needs to be adapted to + // 3D content changes here. The tooling class remembers the current 3D transformation stack + // and in its destructor, calculates a new 2D SnapRect for the scene and it's modified 3D geometry. + E3DModifySceneSnapRectUpdater aUpdater(lcl_getE3dScene(m_xOuterGroupShape)); + + m_xAspectRatio3D->setPropertyValue( UNO_NAME_3D_TRANSFORM_MATRIX + , uno::Any(BaseGFXHelper::B3DHomMatrixToHomogenMatrix( aResult )) ); + } + catch( const uno::Exception& ) + { + TOOLS_WARN_EXCEPTION("chart2", "" ); } } @@ -669,20 +669,20 @@ basegfx::B2IRectangle VDiagram::getCurrentRectangle() const void VDiagram::reduceToMimimumSize() { - if( m_xOuterGroupShape.is() ) - { - awt::Size aMaxSize( m_aAvailableSizeIncludingAxes ); - awt::Point aMaxPos( m_aAvailablePosIncludingAxes ); + if( !m_xOuterGroupShape.is() ) + return; - sal_Int32 nNewWidth = aMaxSize.Width/3; - sal_Int32 nNewHeight = aMaxSize.Height/3; - awt::Size aNewSize( nNewWidth, nNewHeight ); - awt::Point aNewPos( aMaxPos ); - aNewPos.X += nNewWidth; - aNewPos.Y += nNewHeight; + awt::Size aMaxSize( m_aAvailableSizeIncludingAxes ); + awt::Point aMaxPos( m_aAvailablePosIncludingAxes ); - adjustPosAndSize( aNewPos, aNewSize ); - } + sal_Int32 nNewWidth = aMaxSize.Width/3; + sal_Int32 nNewHeight = aMaxSize.Height/3; + awt::Size aNewSize( nNewWidth, nNewHeight ); + awt::Point aNewPos( aMaxPos ); + aNewPos.X += nNewWidth; + aNewPos.Y += nNewHeight; + + adjustPosAndSize( aNewPos, aNewSize ); } ::basegfx::B2IRectangle VDiagram::adjustInnerSize( const ::basegfx::B2IRectangle& rConsumedOuterRect ) diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index 547295155b12..c9fa8ebd4d30 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -605,21 +605,21 @@ void SeriesPlotterContainer::initializeCooSysAndSeriesPlotter( } //transport seriesnames to the coordinatesystems if needed - if( !m_aSeriesPlotterList.empty() ) + if( m_aSeriesPlotterList.empty() ) + return; + + uno::Sequence< OUString > aSeriesNames; + bool bSeriesNamesInitialized = false; + for(auto & pVCooSys : m_rVCooSysList) { - uno::Sequence< OUString > aSeriesNames; - bool bSeriesNamesInitialized = false; - for(auto & pVCooSys : m_rVCooSysList) + if( pVCooSys->needSeriesNamesForAxis() ) { - if( pVCooSys->needSeriesNamesForAxis() ) + if(!bSeriesNamesInitialized) { - if(!bSeriesNamesInitialized) - { - aSeriesNames = m_aSeriesPlotterList[0]->getSeriesNames(); - bSeriesNamesInitialized = true; - } - pVCooSys->setSeriesNamesForAxis( aSeriesNames ); + aSeriesNames = m_aSeriesPlotterList[0]->getSeriesNames(); + bSeriesNamesInitialized = true; } + pVCooSys->setSeriesNamesForAxis( aSeriesNames ); } } } @@ -914,45 +914,45 @@ void SeriesPlotterContainer::AdaptScaleOfYAxisWithoutAttachedSeries( ChartModel& } } - if( AxisHelper::isAxisPositioningEnabled() ) + if( !AxisHelper::isAxisPositioningEnabled() ) + return; + + //correct origin for y main axis (the origin is where the other main axis crosses) + sal_Int32 nAxisIndex=0; + sal_Int32 nDimensionIndex=1; + for (auto & axisUsage : m_aAxisUsageList) { - //correct origin for y main axis (the origin is where the other main axis crosses) - sal_Int32 nAxisIndex=0; - sal_Int32 nDimensionIndex=1; - for (auto & axisUsage : m_aAxisUsageList) + AxisUsage& rAxisUsage = axisUsage.second; + std::vector< VCoordinateSystem* > aVCooSysList = rAxisUsage.getCoordinateSystems(nDimensionIndex,nAxisIndex); + size_t nC; + for( nC=0; nC < aVCooSysList.size(); nC++) { - AxisUsage& rAxisUsage = axisUsage.second; - std::vector< VCoordinateSystem* > aVCooSysList = rAxisUsage.getCoordinateSystems(nDimensionIndex,nAxisIndex); - size_t nC; - for( nC=0; nC < aVCooSysList.size(); nC++) - { - ExplicitScaleData aExplicitScale( aVCooSysList[nC]->getExplicitScale( nDimensionIndex, nAxisIndex ) ); - ExplicitIncrementData aExplicitIncrement( aVCooSysList[nC]->getExplicitIncrement( nDimensionIndex, nAxisIndex ) ); + ExplicitScaleData aExplicitScale( aVCooSysList[nC]->getExplicitScale( nDimensionIndex, nAxisIndex ) ); + ExplicitIncrementData aExplicitIncrement( aVCooSysList[nC]->getExplicitIncrement( nDimensionIndex, nAxisIndex ) ); - Reference< chart2::XCoordinateSystem > xCooSys( aVCooSysList[nC]->getModel() ); - Reference< XAxis > xAxis( xCooSys->getAxisByDimension( nDimensionIndex, nAxisIndex ) ); - Reference< beans::XPropertySet > xCrossingMainAxis( AxisHelper::getCrossingMainAxis( xAxis, xCooSys ), uno::UNO_QUERY ); + Reference< chart2::XCoordinateSystem > xCooSys( aVCooSysList[nC]->getModel() ); + Reference< XAxis > xAxis( xCooSys->getAxisByDimension( nDimensionIndex, nAxisIndex ) ); + Reference< beans::XPropertySet > xCrossingMainAxis( AxisHelper::getCrossingMainAxis( xAxis, xCooSys ), uno::UNO_QUERY ); - css::chart::ChartAxisPosition eCrossingMainAxisPos( css::chart::ChartAxisPosition_ZERO ); - if( xCrossingMainAxis.is() ) + css::chart::ChartAxisPosition eCrossingMainAxisPos( css::chart::ChartAxisPosition_ZERO ); + if( xCrossingMainAxis.is() ) + { + xCrossingMainAxis->getPropertyValue("CrossoverPosition") >>= eCrossingMainAxisPos; + if( eCrossingMainAxisPos == css::chart::ChartAxisPosition_VALUE ) { - xCrossingMainAxis->getPropertyValue("CrossoverPosition") >>= eCrossingMainAxisPos; - if( eCrossingMainAxisPos == css::chart::ChartAxisPosition_VALUE ) - { - double fValue = 0.0; - xCrossingMainAxis->getPropertyValue("CrossoverValue") >>= fValue; - aExplicitScale.Origin = fValue; - } - else if( eCrossingMainAxisPos == css::chart::ChartAxisPosition_ZERO ) - aExplicitScale.Origin = 0.0; - else if( eCrossingMainAxisPos == css::chart::ChartAxisPosition_START ) - aExplicitScale.Origin = aExplicitScale.Minimum; - else if( eCrossingMainAxisPos == css::chart::ChartAxisPosition_END ) - aExplicitScale.Origin = aExplicitScale.Maximum; + double fValue = 0.0; + xCrossingMainAxis->getPropertyValue("CrossoverValue") >>= fValue; + aExplicitScale.Origin = fValue; } - - aVCooSysList[nC]->setExplicitScaleAndIncrement( nDimensionIndex, nAxisIndex, aExplicitScale, aExplicitIncrement ); + else if( eCrossingMainAxisPos == css::chart::ChartAxisPosition_ZERO ) + aExplicitScale.Origin = 0.0; + else if( eCrossingMainAxisPos == css::chart::ChartAxisPosition_START ) + aExplicitScale.Origin = aExplicitScale.Minimum; + else if( eCrossingMainAxisPos == css::chart::ChartAxisPosition_END ) + aExplicitScale.Origin = aExplicitScale.Maximum; } + + aVCooSysList[nC]->setExplicitScaleAndIncrement( nDimensionIndex, nAxisIndex, aExplicitScale, aExplicitIncrement ); } } } @@ -1278,136 +1278,136 @@ bool lcl_IsPieOrDonut( const uno::Reference< XDiagram >& xDiagram ) void lcl_setDefaultWritingMode( const std::shared_ptr< DrawModelWrapper >& pDrawModelWrapper, ChartModel& rModel) { //get writing mode from parent document: - if( SvtLanguageOptions().IsCTLFontEnabled() ) + if( !SvtLanguageOptions().IsCTLFontEnabled() ) + return; + + try { - try + sal_Int16 nWritingMode=-1; + uno::Reference< beans::XPropertySet > xParentProps( rModel.getParent(), uno::UNO_QUERY ); + uno::Reference< style::XStyleFamiliesSupplier > xStyleFamiliesSupplier( xParentProps, uno::UNO_QUERY ); + if( xStyleFamiliesSupplier.is() ) { - sal_Int16 nWritingMode=-1; - uno::Reference< beans::XPropertySet > xParentProps( rModel.getParent(), uno::UNO_QUERY ); - uno::Reference< style::XStyleFamiliesSupplier > xStyleFamiliesSupplier( xParentProps, uno::UNO_QUERY ); - if( xStyleFamiliesSupplier.is() ) + uno::Reference< container::XNameAccess > xStylesFamilies( xStyleFamiliesSupplier->getStyleFamilies() ); + if( xStylesFamilies.is() ) { - uno::Reference< container::XNameAccess > xStylesFamilies( xStyleFamiliesSupplier->getStyleFamilies() ); - if( xStylesFamilies.is() ) + if( !xStylesFamilies->hasByName( "PageStyles" ) ) { - if( !xStylesFamilies->hasByName( "PageStyles" ) ) + //draw/impress is parent document + uno::Reference< lang::XMultiServiceFactory > xFatcory( xParentProps, uno::UNO_QUERY ); + if( xFatcory.is() ) { - //draw/impress is parent document - uno::Reference< lang::XMultiServiceFactory > xFatcory( xParentProps, uno::UNO_QUERY ); - if( xFatcory.is() ) - { - uno::Reference< beans::XPropertySet > xDrawDefaults( xFatcory->createInstance( "com.sun.star.drawing.Defaults" ), uno::UNO_QUERY ); - if( xDrawDefaults.is() ) - xDrawDefaults->getPropertyValue( "WritingMode" ) >>= nWritingMode; - } + uno::Reference< beans::XPropertySet > xDrawDefaults( xFatcory->createInstance( "com.sun.star.drawing.Defaults" ), uno::UNO_QUERY ); + if( xDrawDefaults.is() ) + xDrawDefaults->getPropertyValue( "WritingMode" ) >>= nWritingMode; } - else + } + else + { + uno::Reference< container::XNameAccess > xPageStyles( xStylesFamilies->getByName( "PageStyles" ), uno::UNO_QUERY ); + if( xPageStyles.is() ) { - uno::Reference< container::XNameAccess > xPageStyles( xStylesFamilies->getByName( "PageStyles" ), uno::UNO_QUERY ); - if( xPageStyles.is() ) + OUString aPageStyle; + + uno::Reference< text::XTextDocument > xTextDocument( xParentProps, uno::UNO_QUERY ); + if( xTextDocument.is() ) { - OUString aPageStyle; + //writer is parent document + //retrieve the current page style from the text cursor property PageStyleName - uno::Reference< text::XTextDocument > xTextDocument( xParentProps, uno::UNO_QUERY ); - if( xTextDocument.is() ) + uno::Reference< text::XTextEmbeddedObjectsSupplier > xTextEmbeddedObjectsSupplier( xTextDocument, uno::UNO_QUERY ); + if( xTextEmbeddedObjectsSupplier.is() ) { - //writer is parent document - //retrieve the current page style from the text cursor property PageStyleName - - uno::Reference< text::XTextEmbeddedObjectsSupplier > xTextEmbeddedObjectsSupplier( xTextDocument, uno::UNO_QUERY ); - if( xTextEmbeddedObjectsSupplier.is() ) + uno::Reference< container::XNameAccess > xEmbeddedObjects( xTextEmbeddedObjectsSupplier->getEmbeddedObjects() ); + if( xEmbeddedObjects.is() ) { - uno::Reference< container::XNameAccess > xEmbeddedObjects( xTextEmbeddedObjectsSupplier->getEmbeddedObjects() ); - if( xEmbeddedObjects.is() ) - { - uno::Sequence< OUString > aNames( xEmbeddedObjects->getElementNames() ); + uno::Sequence< OUString > aNames( xEmbeddedObjects->getElementNames() ); - sal_Int32 nCount = aNames.getLength(); - for( sal_Int32 nN=0; nN<nCount; nN++ ) + sal_Int32 nCount = aNames.getLength(); + for( sal_Int32 nN=0; nN<nCount; nN++ ) + { + uno::Reference< beans::XPropertySet > xEmbeddedProps( xEmbeddedObjects->getByName( aNames[nN] ), uno::UNO_QUERY ); + if( xEmbeddedProps.is() ) { - uno::Reference< beans::XPropertySet > xEmbeddedProps( xEmbeddedObjects->getByName( aNames[nN] ), uno::UNO_QUERY ); - if( xEmbeddedProps.is() ) + static OUString aChartCLSID = SvGlobalName( SO3_SCH_CLASSID ).GetHexName(); + OUString aCLSID; + xEmbeddedProps->getPropertyValue( "CLSID" ) >>= aCLSID; + if( aCLSID == aChartCLSID ) { - static OUString aChartCLSID = SvGlobalName( SO3_SCH_CLASSID ).GetHexName(); - OUString aCLSID; - xEmbeddedProps->getPropertyValue( "CLSID" ) >>= aCLSID; - if( aCLSID == aChartCLSID ) + uno::Reference< text::XTextContent > xEmbeddedObject( xEmbeddedProps, uno::UNO_QUERY ); + if( xEmbeddedObject.is() ) { - uno::Reference< text::XTextContent > xEmbeddedObject( xEmbeddedProps, uno::UNO_QUERY ); - if( xEmbeddedObject.is() ) + uno::Reference< text::XTextRange > xAnchor( xEmbeddedObject->getAnchor() ); + if( xAnchor.is() ) { - uno::Reference< text::XTextRange > xAnchor( xEmbeddedObject->getAnchor() ); - if( xAnchor.is() ) + uno::Reference< beans::XPropertySet > xAnchorProps( xAnchor, uno::UNO_QUERY ); + if( xAnchorProps.is() ) { - uno::Reference< beans::XPropertySet > xAnchorProps( xAnchor, uno::UNO_QUERY ); - if( xAnchorProps.is() ) - { - xAnchorProps->getPropertyValue( "WritingMode" ) >>= nWritingMode; - } - uno::Reference< text::XText > xText( xAnchor->getText() ); - if( xText.is() ) - { - uno::Reference< beans::XPropertySet > xTextCursorProps( xText->createTextCursor(), uno::UNO_QUERY ); - if( xTextCursorProps.is() ) - xTextCursorProps->getPropertyValue( "PageStyleName" ) >>= aPageStyle; - } + xAnchorProps->getPropertyValue( "WritingMode" ) >>= nWritingMode; + } + uno::Reference< text::XText > xText( xAnchor->getText() ); + if( xText.is() ) + { + uno::Reference< beans::XPropertySet > xTextCursorProps( xText->createTextCursor(), uno::UNO_QUERY ); + if( xTextCursorProps.is() ) + xTextCursorProps->getPropertyValue( "PageStyleName" ) >>= aPageStyle; } } - break; } + break; } } } } - if( aPageStyle.isEmpty() ) - { - uno::Reference< text::XText > xText( xTextDocument->getText() ); - if( xText.is() ) - { - uno::Reference< beans::XPropertySet > xTextCursorProps( xText->createTextCursor(), uno::UNO_QUERY ); - if( xTextCursorProps.is() ) - xTextCursorProps->getPropertyValue( "PageStyleName" ) >>= aPageStyle; - } - } - if(aPageStyle.isEmpty()) - aPageStyle = "Standard"; } - else + if( aPageStyle.isEmpty() ) { - //Calc is parent document - Reference< com::sun::star::beans::XPropertySetInfo > xInfo = xParentProps->getPropertySetInfo(); - if (xInfo->hasPropertyByName("PageStyle")) + uno::Reference< text::XText > xText( xTextDocument->getText() ); + if( xText.is() ) { - xParentProps->getPropertyValue( "PageStyle" ) >>= aPageStyle; + uno::Reference< beans::XPropertySet > xTextCursorProps( xText->createTextCursor(), uno::UNO_QUERY ); + if( xTextCursorProps.is() ) + xTextCursorProps->getPropertyValue( "PageStyleName" ) >>= aPageStyle; } - if(aPageStyle.isEmpty()) - aPageStyle = "Default"; } - if( nWritingMode == -1 || nWritingMode == text::WritingMode2::PAGE ) + if(aPageStyle.isEmpty()) + aPageStyle = "Standard"; + } + else + { + //Calc is parent document + Reference< com::sun::star::beans::XPropertySetInfo > xInfo = xParentProps->getPropertySetInfo(); + if (xInfo->hasPropertyByName("PageStyle")) { - uno::Reference< beans::XPropertySet > xPageStyle( xPageStyles->getByName( aPageStyle ), uno::UNO_QUERY ); - Reference< com::sun::star::beans::XPropertySetInfo > xInfo = xPageStyle->getPropertySetInfo(); - if (xInfo->hasPropertyByName("WritingMode")) - { - if( xPageStyle.is() ) - xPageStyle->getPropertyValue( "WritingMode" ) >>= nWritingMode; - } + xParentProps->getPropertyValue( "PageStyle" ) >>= aPageStyle; + } + if(aPageStyle.isEmpty()) + aPageStyle = "Default"; + } + if( nWritingMode == -1 || nWritingMode == text::WritingMode2::PAGE ) + { + uno::Reference< beans::XPropertySet > xPageStyle( xPageStyles->getByName( aPageStyle ), uno::UNO_QUERY ); + Reference< com::sun::star::beans::XPropertySetInfo > xInfo = xPageStyle->getPropertySetInfo(); + if (xInfo->hasPropertyByName("WritingMode")) + { + if( xPageStyle.is() ) + xPageStyle->getPropertyValue( "WritingMode" ) >>= nWritingMode; } } } } } - if( nWritingMode != -1 && nWritingMode != text::WritingMode2::PAGE ) - { - if( pDrawModelWrapper.get() ) - pDrawModelWrapper->GetItemPool().SetPoolDefaultItem(SvxFrameDirectionItem(static_cast<SvxFrameDirection>(nWritingMode), EE_PARA_WRITINGDIR) ); - } } - catch( const uno::Exception& ) + if( nWritingMode != -1 && nWritingMode != text::WritingMode2::PAGE ) { - DBG_UNHANDLED_EXCEPTION("chart2" ); + if( pDrawModelWrapper.get() ) + pDrawModelWrapper->GetItemPool().SetPoolDefaultItem(SvxFrameDirectionItem(static_cast<SvxFrameDirection>(nWritingMode), EE_PARA_WRITINGDIR) ); } } + catch( const uno::Exception& ) + { + DBG_UNHANDLED_EXCEPTION("chart2" ); + } } sal_Int16 lcl_getDefaultWritingModeFromPool( const std::shared_ptr<DrawModelWrapper>& pDrawModelWrapper ) @@ -2284,33 +2284,33 @@ void lcl_createButtons(const uno::Reference<drawing::XShapes>& xPageShapes, aSize = awt::Size(3000, 700); // size of the button - if (xPivotTableDataProvider->getRowFields().hasElements()) + if (!xPivotTableDataProvider->getRowFields().hasElements()) + return; + + x = 200; + const css::uno::Sequence<chart2::data::PivotTableFieldEntry> aPivotFieldEntries = xPivotTableDataProvider->getRowFields(); + for (css::chart2::data::PivotTableFieldEntry const & rRowFieldEntry : aPivotFieldEntries) { - x = 200; - const css::uno::Sequence<chart2::data::PivotTableFieldEntry> aPivotFieldEntries = xPivotTableDataProvider->getRowFields(); - for (css::chart2::data::PivotTableFieldEntry const & rRowFieldEntry : aPivotFieldEntries) - { - std::unique_ptr<VButton> pButton(new VButton); - pButton->init(xPageShapes, xShapeFactory); - awt::Point aNewPosition(rRemainingSpace.X + x + 100, - rRemainingSpace.Y + rRemainingSpace.Height - aSize.Height - 100); - pButton->setLabel(rRowFieldEntry.Name); - pButton->setCID("FieldButton.Row." + OUString::number(rRowFieldEntry.DimensionIndex)); - pButton->setPosition(aNewPosition); - pButton->setSize(aSize); - if ( rRowFieldEntry.Name == "Data" ) - { - pButton->setBGColor( Color(0x00F6F6F6) ); - pButton->showArrow( false ); - } - else if (rRowFieldEntry.HasHiddenMembers) - pButton->setArrowColor(Color(0x0000FF)); - pButton->createShapes(xModelPage); - x += aSize.Width + 100; + std::unique_ptr<VButton> pButton(new VButton); + pButton->init(xPageShapes, xShapeFactory); + awt::Point aNewPosition(rRemainingSpace.X + x + 100, + rRemainingSpace.Y + rRemainingSpace.Height - aSize.Height - 100); + pButton->setLabel(rRowFieldEntry.Name); + pButton->setCID("FieldButton.Row." + OUString::number(rRowFieldEntry.DimensionIndex)); + pButton->setPosition(aNewPosition); + pButton->setSize(aSize); + if ( rRowFieldEntry.Name == "Data" ) + { + pButton->setBGColor( Color(0x00F6F6F6) ); + pButton->showArrow( false ); } - rRemainingSpace.Height -= (aSize.Height + 100 + 100); + else if (rRowFieldEntry.HasHiddenMembers) + pButton->setArrowColor(Color(0x0000FF)); + pButton->createShapes(xModelPage); + x += aSize.Width + 100; } + rRemainingSpace.Height -= (aSize.Height + 100 + 100); } void formatPage( @@ -2388,7 +2388,10 @@ void ChartView::impl_refreshAddIn() return; uno::Reference< beans::XPropertySet > xProp( static_cast< ::cppu::OWeakObject* >( &mrChartModel ), uno::UNO_QUERY ); - if( xProp.is()) try + if( !xProp.is()) + return; + + try { uno::Reference< util::XRefreshable > xAddIn; xProp->getPropertyValue( "AddIn" ) >>= xAddIn; @@ -2480,60 +2483,60 @@ void ChartView::impl_updateView( bool bCheckLockedCtrler ) if (bCheckLockedCtrler && mrChartModel.hasControllersLocked()) return; - if( m_bViewDirty && !m_bInViewUpdate ) + if( !(m_bViewDirty && !m_bInViewUpdate) ) + return; + + m_bInViewUpdate = true; + //bool bOldRefreshAddIn = m_bRefreshAddIn; + //m_bRefreshAddIn = false; + try { - m_bInViewUpdate = true; - //bool bOldRefreshAddIn = m_bRefreshAddIn; - //m_bRefreshAddIn = false; - try + impl_notifyModeChangeListener("invalid"); + + //prepare draw model { - impl_notifyModeChangeListener("invalid"); + SolarMutexGuard aSolarGuard; + m_pDrawModelWrapper->lockControllers(); + } - //prepare draw model - { - SolarMutexGuard aSolarGuard; - m_pDrawModelWrapper->lockControllers(); - } + //create chart view + { + m_bViewDirty = false; + m_bViewUpdatePending = false; + createShapes(); - //create chart view + if( m_bViewDirty ) { + //avoid recursions due to add-in + m_bRefreshAddIn = false; m_bViewDirty = false; m_bViewUpdatePending = false; + //delete old chart view createShapes(); - - if( m_bViewDirty ) - { - //avoid recursions due to add-in - m_bRefreshAddIn = false; - m_bViewDirty = false; - m_bViewUpdatePending = false; - //delete old chart view - createShapes(); - m_bRefreshAddIn = true; - } + m_bRefreshAddIn = true; } - - m_bViewDirty = m_bViewUpdatePending; - m_bViewUpdatePending = false; - m_bInViewUpdate = false; - } - catch( const uno::Exception& ) - { - DBG_UNHANDLED_EXCEPTION("chart2" ); - m_bViewDirty = m_bViewUpdatePending; - m_bViewUpdatePending = false; - m_bInViewUpdate = false; - } - - { - SolarMutexGuard aSolarGuard; - m_pDrawModelWrapper->unlockControllers(); } - impl_notifyModeChangeListener("valid"); + m_bViewDirty = m_bViewUpdatePending; + m_bViewUpdatePending = false; + m_bInViewUpdate = false; + } + catch( const uno::Exception& ) + { + DBG_UNHANDLED_EXCEPTION("chart2" ); + m_bViewDirty = m_bViewUpdatePending; + m_bViewUpdatePending = false; + m_bInViewUpdate = false; + } - //m_bRefreshAddIn = bOldRefreshAddIn; + { + SolarMutexGuard aSolarGuard; + m_pDrawModelWrapper->unlockControllers(); } + + impl_notifyModeChangeListener("valid"); + + //m_bRefreshAddIn = bOldRefreshAddIn; } // ____ XModifyListener ____ diff --git a/chart2/source/view/main/VButton.cxx b/chart2/source/view/main/VButton.cxx index bd8c5f9749eb..088df5850416 100644 --- a/chart2/source/view/main/VButton.cxx +++ b/chart2/source/view/main/VButton.cxx @@ -134,18 +134,18 @@ void VButton::createShapes(const uno::Reference<beans::XPropertySet>& xTextProp) xEntry->setSize(m_aSize); } - if (m_bShowArrow) + if (!m_bShowArrow) + return; + + awt::Size aPolySize {280, 180}; + + uno::Reference<drawing::XShape> xPoly = createTriangle(aPolySize); + if (xPoly.is()) { - awt::Size aPolySize {280, 180}; - - uno::Reference<drawing::XShape> xPoly = createTriangle(aPolySize); - if (xPoly.is()) - { - xPoly->setSize(aPolySize); - xPoly->setPosition({ sal_Int32(m_aPosition.X + m_aSize.Width - aPolySize.Width - 100), - sal_Int32(m_aPosition.Y + (m_aSize.Height / 2.0) - (aPolySize.Height / 2.0)) }); - xContainer->add(xPoly); - } + xPoly->setSize(aPolySize); + xPoly->setPosition({ sal_Int32(m_aPosition.X + m_aSize.Width - aPolySize.Width - 100), + sal_Int32(m_aPosition.Y + (m_aSize.Height / 2.0) - (aPolySize.Height / 2.0)) }); + xContainer->add(xPoly); } } diff --git a/chart2/source/view/main/VDataSeries.cxx b/chart2/source/view/main/VDataSeries.cxx index b6c4adc013fa..7c7509635bf5 100644 --- a/chart2/source/view/main/VDataSeries.cxx +++ b/chart2/source/view/main/VDataSeries.cxx @@ -242,23 +242,23 @@ VDataSeries::VDataSeries( const uno::Reference< XDataSeries >& xDataSeries ) } uno::Reference<beans::XPropertySet> xProp(xDataSeries, uno::UNO_QUERY ); - if( xProp.is()) + if( !xProp.is()) + return; + + try { - try - { - //get AttributedDataPoints - xProp->getPropertyValue("AttributedDataPoints") >>= m_aAttributedDataPointIndexList; + //get AttributedDataPoints + xProp->getPropertyValue("AttributedDataPoints") >>= m_aAttributedDataPointIndexList; - xProp->getPropertyValue("StackingDirection") >>= m_eStackingDirection; + xProp->getPropertyValue("StackingDirection") >>= m_eStackingDirection; - xProp->getPropertyValue("AttachedAxisIndex") >>= m_nAxisIndex; - if(m_nAxisIndex<0) - m_nAxisIndex=0; - } - catch( const uno::Exception& ) - { - TOOLS_WARN_EXCEPTION("chart2", "" ); - } + xProp->getPropertyValue("AttachedAxisIndex") >>= m_nAxisIndex; + if(m_nAxisIndex<0) + m_nAxisIndex=0; + } + catch( const uno::Exception& ) + { + TOOLS_WARN_EXCEPTION("chart2", "" ); } } @@ -268,33 +268,33 @@ VDataSeries::~VDataSeries() void VDataSeries::doSortByXValues() { - if( m_aValues_X.is() && m_aValues_X.Doubles.hasElements() ) + if( !(m_aValues_X.is() && m_aValues_X.Doubles.hasElements()) ) + return; + + //prepare a vector for sorting + std::vector< std::vector< double > > aTmp;//outer vector are points, inner vector are the different values of the point + double fNan; + ::rtl::math::setNan( & fNan ); + sal_Int32 nPointIndex = 0; + for( nPointIndex=0; nPointIndex < m_nPointCount; nPointIndex++ ) { - //prepare a vector for sorting - std::vector< std::vector< double > > aTmp;//outer vector are points, inner vector are the different values of the point - double fNan; - ::rtl::math::setNan( & fNan ); - sal_Int32 nPointIndex = 0; - for( nPointIndex=0; nPointIndex < m_nPointCount; nPointIndex++ ) - { - std::vector< double > aSinglePoint; - aSinglePoint.push_back( (nPointIndex < m_aValues_X.Doubles.getLength()) ? m_aValues_X.Doubles[nPointIndex] : fNan ); - aSinglePoint.push_back( (nPointIndex < m_aValues_Y.Doubles.getLength()) ? m_aValues_Y.Doubles[nPointIndex] : fNan ); - aTmp.push_back( aSinglePoint ); - } + std::vector< double > aSinglePoint; + aSinglePoint.push_back( (nPointIndex < m_aValues_X.Doubles.getLength()) ? m_aValues_X.Doubles[nPointIndex] : fNan ); + aSinglePoint.push_back( (nPointIndex < m_aValues_Y.Doubles.getLength()) ? m_aValues_Y.Doubles[nPointIndex] : fNan ); + aTmp.push_back( aSinglePoint ); + } - //do sort - std::stable_sort( aTmp.begin(), aTmp.end(), lcl_LessXOfPoint() ); + //do sort + std::stable_sort( aTmp.begin(), aTmp.end(), lcl_LessXOfPoint() ); - //fill the sorted points back to the members - m_aValues_X.Doubles.realloc( m_nPointCount ); - m_aValues_Y.Doubles.realloc( m_nPointCount ); + //fill the sorted points back to the members + m_aValues_X.Doubles.realloc( m_nPointCount ); + m_aValues_Y.Doubles.realloc( m_nPointCount ); - for( nPointIndex=0; nPointIndex < m_nPointCount; nPointIndex++ ) - { - m_aValues_X.Doubles[nPointIndex]=aTmp[nPointIndex][0]; - m_aValues_Y.Doubles[nPointIndex]=aTmp[nPointIndex][1]; - } + for( nPointIndex=0; nPointIndex < m_nPointCount; nPointIndex++ ) + { + m_aValues_X.Doubles[nPointIndex]=aTmp[nPointIndex][0]; + m_aValues_Y.Doubles[nPointIndex]=aTmp[nPointIndex][1]; } } @@ -498,25 +498,25 @@ void VDataSeries::getMinMaxXValue(double& fMin, double& fMax) const uno::Sequence< double > aValuesX = getAllX(); - if(aValuesX.hasElements()) - { - sal_Int32 i = 0; - while ( i < aValuesX.getLength() && std::isnan(aValuesX[i]) ) - i++; - if ( i < aValuesX.getLength() ) - fMax = fMin = aValuesX[i++]; + if(!aValuesX.hasElements()) + return; - for ( ; i < aValuesX.getLength(); i++) + sal_Int32 i = 0; + while ( i < aValuesX.getLength() && std::isnan(aValuesX[i]) ) + i++; + if ( i < aValuesX.getLength() ) + fMax = fMin = aValuesX[i++]; + + for ( ; i < aValuesX.getLength(); i++) + { + const double aValue = aValuesX[i]; + if ( aValue > fMax) { - const double aValue = aValuesX[i]; - if ( aValue > fMax) - { - fMax = aValue; - } - else if ( aValue < fMin) - { - fMin = aValue; - } + fMax = aValue; + } + else if ( aValue < fMin) + { + fMin = aValue; } } } diff --git a/chart2/source/view/main/VLegend.cxx b/chart2/source/view/main/VLegend.cxx index 0fa0b3552d88..d7928b08e756 100644 --- a/chart2/source/view/main/VLegend.cxx +++ b/chart2/source/view/main/VLegend.cxx @@ -95,54 +95,54 @@ void lcl_getProperties( const awt::Size & rReferenceSize ) { // Get Line- and FillProperties from model legend - if( xLegendProp.is()) + if( !xLegendProp.is()) + return; + + // set rOutLineFillProperties + ::chart::tPropertyNameValueMap aLineFillValueMap; + ::chart::PropertyMapper::getValueMap( aLineFillValueMap, ::chart::PropertyMapper::getPropertyNameMapForFillAndLineProperties(), xLegendProp ); + + aLineFillValueMap[ "LineJoint" ] <<= drawing::LineJoint_ROUND; + + ::chart::PropertyMapper::getMultiPropertyListsFromValueMap( + rOutLineFillProperties.first, rOutLineFillProperties.second, aLineFillValueMap ); + + // set rOutTextProperties + ::chart::tPropertyNameValueMap aTextValueMap; + ::chart::PropertyMapper::getValueMap( aTextValueMap, ::chart::PropertyMapper::getPropertyNameMapForCharacterProperties(), xLegendProp ); + + aTextValueMap[ "TextAutoGrowHeight" ] <<= true; + aTextValueMap[ "TextAutoGrowWidth" ] <<= true; + aTextValueMap[ "TextHorizontalAdjust" ] <<= drawing::TextHorizontalAdjust_LEFT; + aTextValueMap[ "TextMaximumFrameWidth" ] <<= rReferenceSize.Width; //needs to be overwritten by actual available space in the legend + + // recalculate font size + awt::Size aPropRefSize; + float fFontHeight( 0.0 ); + if( (xLegendProp->getPropertyValue( "ReferencePageSize") >>= aPropRefSize) && + (aPropRefSize.Height > 0) && + (aTextValueMap[ "CharHeight" ] >>= fFontHeight) ) { - // set rOutLineFillProperties - ::chart::tPropertyNameValueMap aLineFillValueMap; - ::chart::PropertyMapper::getValueMap( aLineFillValueMap, ::chart::PropertyMapper::getPropertyNameMapForFillAndLineProperties(), xLegendProp ); - - aLineFillValueMap[ "LineJoint" ] <<= drawing::LineJoint_ROUND; - - ::chart::PropertyMapper::getMultiPropertyListsFromValueMap( - rOutLineFillProperties.first, rOutLineFillProperties.second, aLineFillValueMap ); - - // set rOutTextProperties - ::chart::tPropertyNameValueMap aTextValueMap; - ::chart::PropertyMapper::getValueMap( aTextValueMap, ::chart::PropertyMapper::getPropertyNameMapForCharacterProperties(), xLegendProp ); - - aTextValueMap[ "TextAutoGrowHeight" ] <<= true; - aTextValueMap[ "TextAutoGrowWidth" ] <<= true; - aTextValueMap[ "TextHorizontalAdjust" ] <<= drawing::TextHorizontalAdjust_LEFT; - aTextValueMap[ "TextMaximumFrameWidth" ] <<= rReferenceSize.Width; //needs to be overwritten by actual available space in the legend - - // recalculate font size - awt::Size aPropRefSize; - float fFontHeight( 0.0 ); - if( (xLegendProp->getPropertyValue( "ReferencePageSize") >>= aPropRefSize) && - (aPropRefSize.Height > 0) && - (aTextValueMap[ "CharHeight" ] >>= fFontHeight) ) + aTextValueMap[ "CharHeight" ] <<= + static_cast< float >( + ::chart::RelativeSizeHelper::calculate( fFontHeight, aPropRefSize, rReferenceSize )); + + if( aTextValueMap[ "CharHeightAsian" ] >>= fFontHeight ) { - aTextValueMap[ "CharHeight" ] <<= + aTextValueMap[ "CharHeightAsian" ] <<= + static_cast< float >( + ::chart::RelativeSizeHelper::calculate( fFontHeight, aPropRefSize, rReferenceSize )); + } + if( aTextValueMap[ "CharHeightComplex" ] >>= fFontHeight ) + { + aTextValueMap[ "CharHeightComplex" ] <<= static_cast< float >( ::chart::RelativeSizeHelper::calculate( fFontHeight, aPropRefSize, rReferenceSize )); - - if( aTextValueMap[ "CharHeightAsian" ] >>= fFontHeight ) - { - aTextValueMap[ "CharHeightAsian" ] <<= - static_cast< float >( - ::chart::RelativeSizeHelper::calculate( fFontHeight, aPropRefSize, rReferenceSize )); - } - if( aTextValueMap[ "CharHeightComplex" ] >>= fFontHeight ) - { - aTextValueMap[ "CharHeightComplex" ] <<= - static_cast< float >( - ::chart::RelativeSizeHelper::calculate( fFontHeight, aPropRefSize, rReferenceSize )); - } } - - ::chart::PropertyMapper::getMultiPropertyListsFromValueMap( - rOutTextProperties.first, rOutTextProperties.second, aTextValueMap ); } + + ::chart::PropertyMapper::getMultiPropertyListsFromValueMap( + rOutTextProperties.first, rOutTextProperties.second, aTextValueMap ); } awt::Size lcl_createTextShapes( |