Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx
- index 4d17b16e7ecd..d81a6c7eb0dd 100644
- --- a/chart2/source/view/charttypes/VSeriesPlotter.cxx
- +++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx
- @@ -393,11 +393,24 @@ OUString VSeriesPlotter::getLabelTextForValue( VDataSeries& rDataSeries
- }
- else
- {
- - if( rDataSeries.shouldLabelNumberFormatKeyBeDetectedFromYAxis() && m_aAxesNumberFormats.hasFormat(1,rDataSeries.getAttachedAxisIndex()) ) //y-axis
- + // tdf#111936: Should not consider Y axis format if it is a percent stacked chart type
- + if(!m_bIsPercentStacked && rDataSeries.shouldLabelNumberFormatKeyBeDetectedFromYAxis()
- + && m_aAxesNumberFormats.hasFormat(1,rDataSeries.getAttachedAxisIndex()) ) //y-axis
- nNumberFormatKey = m_aAxesNumberFormats.getFormat(1,rDataSeries.getAttachedAxisIndex());
- else
- - nNumberFormatKey = rDataSeries.detectNumberFormatKey( nPointIndex );
- + nNumberFormatKey = rDataSeries.detectNumberFormatKey(nPointIndex);
- +
- + if (m_bIsPercentStacked)
- + {
- + OUString nPropName = OUString(CHART_UNONAME_NUMFMT);
- + uno::Reference< beans::XPropertySet > xPointProp(rDataSeries.getPropertiesOfPoint(nPointIndex));
- + if (xPointProp.is())
- + {
- + xPointProp->setPropertyValue(nPropName, uno::Any(nNumberFormatKey));
- + }
- + }
- }
- +
- if(nNumberFormatKey<0)
- nNumberFormatKey=0;
- @@ -1637,6 +1650,12 @@ void VSeriesPlotter::setExplicitCategoriesProvider( ExplicitCategoriesProvider*
- m_pExplicitCategoriesProvider = pExplicitCategoriesProvider;
- }
- +
- +void VSeriesPlotter::setIsPercentStacked(const bool aIsPercentStacked)
- +{
- + m_bIsPercentStacked = aIsPercentStacked;
- +}
- +
- sal_Int32 VDataSeriesGroup::getPointCount() const
- {
- if(!m_bMaxPointCountDirty)
- diff --git a/chart2/source/view/inc/VSeriesPlotter.hxx b/chart2/source/view/inc/VSeriesPlotter.hxx
- index fb4ffbb8c6af..10cfab9a6d80 100644
- --- a/chart2/source/view/inc/VSeriesPlotter.hxx
- +++ b/chart2/source/view/inc/VSeriesPlotter.hxx
- @@ -237,12 +237,15 @@ public:
- ...skipping...
- commit 78472e97a16bcc7001d8b6c42236b7fb7b9a5e20
- Author: Dimitri BOURON <dbouron@linagora.com>
- Date: Tue Aug 22 15:25:05 2017 +0200
- tdf#111936: Fix data label format in stacked percent chart type
- Change-Id: Id4aaffcd49bba6c23f0e815328d066e38e68eb86
- diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx
- index 4d17b16e7ecd..d81a6c7eb0dd 100644
- --- a/chart2/source/view/charttypes/VSeriesPlotter.cxx
- +++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx
- @@ -393,11 +393,24 @@ OUString VSeriesPlotter::getLabelTextForValue( VDataSeries& rDataSeries
- }
- else
- {
- - if( rDataSeries.shouldLabelNumberFormatKeyBeDetectedFromYAxis() && m_aAxesNumberFormats.hasFormat(1,rDataSeries.getAttachedAxisIndex()) ) //y-axis
- + // tdf#111936: Should not consider Y axis format if it is a percent stacked chart type
- + if(!m_bIsPercentStacked && rDataSeries.shouldLabelNumberFormatKeyBeDetectedFromYAxis()
- + && m_aAxesNumberFormats.hasFormat(1,rDataSeries.getAttachedAxisIndex()) ) //y-axis
- nNumberFormatKey = m_aAxesNumberFormats.getFormat(1,rDataSeries.getAttachedAxisIndex());
- else
- - nNumberFormatKey = rDataSeries.detectNumberFormatKey( nPointIndex );
- + nNumberFormatKey = rDataSeries.detectNumberFormatKey(nPointIndex);
- +
- + if (m_bIsPercentStacked)
- + {
- + OUString nPropName = OUString(CHART_UNONAME_NUMFMT);
- + uno::Reference< beans::XPropertySet > xPointProp(rDataSeries.getPropertiesOfPoint(nPointIndex));
- + if (xPointProp.is())
- + {
- + xPointProp->setPropertyValue(nPropName, uno::Any(nNumberFormatKey));
- + }
- + }
- }
- +
- if(nNumberFormatKey<0)
- nNumberFormatKey=0;
- @@ -1637,6 +1650,12 @@ void VSeriesPlotter::setExplicitCategoriesProvider( ExplicitCategoriesProvider*
- m_pExplicitCategoriesProvider = pExplicitCategoriesProvider;
- }
- +
- +void VSeriesPlotter::setIsPercentStacked(const bool aIsPercentStacked)
- +{
- + m_bIsPercentStacked = aIsPercentStacked;
- +}
- +
- sal_Int32 VDataSeriesGroup::getPointCount() const
- {
- if(!m_bMaxPointCountDirty)
- diff --git a/chart2/source/view/inc/VSeriesPlotter.hxx b/chart2/source/view/inc/VSeriesPlotter.hxx
- index fb4ffbb8c6af..10cfab9a6d80 100644
- --- a/chart2/source/view/inc/VSeriesPlotter.hxx
- +++ b/chart2/source/view/inc/VSeriesPlotter.hxx
- @@ -237,12 +237,15 @@ public:
- void setExplicitCategoriesProvider( ExplicitCategoriesProvider* pExplicitCategoriesProvider );
- + void setIsPercentStacked(const bool aIsPercentStacked);
- +
- //get series names for the z axis labels
- css::uno::Sequence< OUString > getSeriesNames() const;
- void setPageReferenceSize( const css::awt::Size & rPageRefSize );
- //better performance for big data
- void setCoordinateSystemResolution( const css::uno::Sequence< sal_Int32 >& rCoordinateSystemResolution );
- +
- bool PointsWereSkipped() const { return m_bPointsWereSkipped;}
- //return the depth for a logic 1
- @@ -401,6 +404,7 @@ protected:
- std::unique_ptr< NumberFormatterWrapper > m_apNumberFormatterWrapper;
- AxesNumberFormats m_aAxesNumberFormats;//direct numberformats on axes, if empty ask the data series instead
- + bool m_bIsPercentStacked; // If true, chart type is Percent Stacked
- css::uno::Reference< css::chart2::XColorScheme > m_xColorScheme;
- diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx
- index 56c7a59e795b..e46e4c87c6aa 100644
- --- a/chart2/source/view/main/ChartView.cxx
- +++ b/chart2/source/view/main/ChartView.cxx
- @@ -48,6 +48,7 @@
- #include "BaseGFXHelper.hxx"
- #include "DataSeriesHelper.hxx"
- #include "DateHelper.hxx"
- +#include "StackMode.hxx"
- #include "defines.hxx"
- #include <unonames.hxx>
- #if HAVE_FEATURE_OPENGL
- @@ -331,7 +332,7 @@ public:
- */
- void setScalesFromCooSysToPlotter();
- - void setNumberFormatsFromAxes();
- + void setNumberFormatsFromAxes(const bool aIsPercentStacked);
- drawing::Direction3D getPreferredAspectRatio();
- SeriesPlottersType& getSeriesPlotterList() { return m_aSeriesPlotterList; }
- @@ -613,7 +614,6 @@ void SeriesPlotterContainer::initializeCooSysAndSeriesPlotter(
- }
- }
- }
- -
- //transport seriesnames to the coordinatesystems if needed
- if( !m_aSeriesPlotterList.empty() )
- {
- @@ -738,7 +738,7 @@ void SeriesPlotterContainer::setScalesFromCooSysToPlotter()
- }
- }
- -void SeriesPlotterContainer::setNumberFormatsFromAxes()
- +void SeriesPlotterContainer::setNumberFormatsFromAxes(const bool aIsPercentStacked)
- {
- //set numberformats to plotter to enable them to display the data labels in the numberformat of the axis
- for( std::unique_ptr<VSeriesPlotter>& aPlotter : m_aSeriesPlotterList )
- @@ -763,6 +763,7 @@ void SeriesPlotterContainer::setNumberFormatsFromAxes()
- sal_Int32 nNumberFormatKey(0);
- if( xAxisProp->getPropertyValue(CHART_UNONAME_NUMFMT) >>= nNumberFormatKey )
- {
- + pSeriesPlotter->setIsPercentStacked(aIsPercentStacked);
- aAxesNumberFormats.setFormat( nNumberFormatKey, nDimensionIndex, nAxisIndex );
- }
- else if( nDimensionIndex==0 )
- @@ -1612,12 +1613,24 @@ awt::Rectangle ChartView::impl_createDiagramAndContent( const CreateShapeParam2D
- pVCooSys->createVAxisList(xChartDoc, rPageSize, rParam.maRemainingSpace);
- }
- + Reference< chart2::XChartType > xChartType( DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) );
- + uno::Reference< XCoordinateSystemContainer > xCooSysContainer( xDiagram, uno::UNO_QUERY );
- + bool bIsPercentStacked = false;
- + bool bFound = false;
- + bool bAmbiguous = false;
- + if( xCooSysContainer.is() )
- + {
- + uno::Sequence< uno::Reference< XCoordinateSystem > > aCooSysList( xCooSysContainer->getCoordinateSystems() );
- + if (DiagramHelper::getStackModeFromChartType(xChartType, bFound, bAmbiguous, aCooSysList[0]) == StackMode::StackMode_Y_STACKED_PERCENT)
- + bIsPercentStacked = true;
- + }
- +
- // - prepare list of all axis and how they are used
- Date aNullDate = NumberFormatterWrapper( xNumberFormatsSupplier ).getNullDate();
- rParam.mpSeriesPlotterContainer->initAxisUsageList(aNullDate);
- rParam.mpSeriesPlotterContainer->doAutoScaling( mrChartModel );
- rParam.mpSeriesPlotterContainer->setScalesFromCooSysToPlotter();
- - rParam.mpSeriesPlotterContainer->setNumberFormatsFromAxes();
- + rParam.mpSeriesPlotterContainer->setNumberFormatsFromAxes(bIsPercentStacked);
- //create shapes
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement