Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2017
340
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 9.17 KB | None | 0 0
  1. diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx
  2. index 4d17b16e7ecd..d81a6c7eb0dd 100644
  3. --- a/chart2/source/view/charttypes/VSeriesPlotter.cxx
  4. +++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx
  5. @@ -393,11 +393,24 @@ OUString VSeriesPlotter::getLabelTextForValue( VDataSeries& rDataSeries
  6.          }
  7.          else
  8.          {
  9. -            if( rDataSeries.shouldLabelNumberFormatKeyBeDetectedFromYAxis() && m_aAxesNumberFormats.hasFormat(1,rDataSeries.getAttachedAxisIndex()) ) //y-axis
  10. +            // tdf#111936: Should not consider Y axis format if it is a percent stacked chart type
  11. +            if(!m_bIsPercentStacked && rDataSeries.shouldLabelNumberFormatKeyBeDetectedFromYAxis()
  12. +               && m_aAxesNumberFormats.hasFormat(1,rDataSeries.getAttachedAxisIndex()) ) //y-axis
  13.                  nNumberFormatKey = m_aAxesNumberFormats.getFormat(1,rDataSeries.getAttachedAxisIndex());
  14.              else
  15. -                nNumberFormatKey = rDataSeries.detectNumberFormatKey( nPointIndex );
  16. +                nNumberFormatKey = rDataSeries.detectNumberFormatKey(nPointIndex);
  17. +
  18. +            if (m_bIsPercentStacked)
  19. +            {
  20. +                OUString nPropName = OUString(CHART_UNONAME_NUMFMT);
  21. +                uno::Reference< beans::XPropertySet > xPointProp(rDataSeries.getPropertiesOfPoint(nPointIndex));
  22. +                if (xPointProp.is())
  23. +                {
  24. +                    xPointProp->setPropertyValue(nPropName, uno::Any(nNumberFormatKey));
  25. +                }
  26. +            }
  27.          }
  28. +
  29.          if(nNumberFormatKey<0)
  30.              nNumberFormatKey=0;
  31.  
  32. @@ -1637,6 +1650,12 @@ void VSeriesPlotter::setExplicitCategoriesProvider( ExplicitCategoriesProvider*
  33.      m_pExplicitCategoriesProvider = pExplicitCategoriesProvider;
  34.  }
  35.  
  36. +
  37. +void VSeriesPlotter::setIsPercentStacked(const bool aIsPercentStacked)
  38. +{
  39. +    m_bIsPercentStacked = aIsPercentStacked;
  40. +}
  41. +
  42.  sal_Int32 VDataSeriesGroup::getPointCount() const
  43.  {
  44.      if(!m_bMaxPointCountDirty)
  45. diff --git a/chart2/source/view/inc/VSeriesPlotter.hxx b/chart2/source/view/inc/VSeriesPlotter.hxx
  46. index fb4ffbb8c6af..10cfab9a6d80 100644
  47. --- a/chart2/source/view/inc/VSeriesPlotter.hxx
  48. +++ b/chart2/source/view/inc/VSeriesPlotter.hxx
  49. @@ -237,12 +237,15 @@ public:
  50. ...skipping...
  51. commit 78472e97a16bcc7001d8b6c42236b7fb7b9a5e20
  52. Author: Dimitri BOURON <dbouron@linagora.com>
  53. Date:   Tue Aug 22 15:25:05 2017 +0200
  54.  
  55.     tdf#111936: Fix data label format in stacked percent chart type
  56.  
  57.     Change-Id: Id4aaffcd49bba6c23f0e815328d066e38e68eb86
  58.  
  59. diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx
  60. index 4d17b16e7ecd..d81a6c7eb0dd 100644
  61. --- a/chart2/source/view/charttypes/VSeriesPlotter.cxx
  62. +++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx
  63. @@ -393,11 +393,24 @@ OUString VSeriesPlotter::getLabelTextForValue( VDataSeries& rDataSeries
  64.          }
  65.          else
  66.          {
  67. -            if( rDataSeries.shouldLabelNumberFormatKeyBeDetectedFromYAxis() && m_aAxesNumberFormats.hasFormat(1,rDataSeries.getAttachedAxisIndex()) ) //y-axis
  68. +            // tdf#111936: Should not consider Y axis format if it is a percent stacked chart type
  69. +            if(!m_bIsPercentStacked && rDataSeries.shouldLabelNumberFormatKeyBeDetectedFromYAxis()
  70. +               && m_aAxesNumberFormats.hasFormat(1,rDataSeries.getAttachedAxisIndex()) ) //y-axis
  71.                  nNumberFormatKey = m_aAxesNumberFormats.getFormat(1,rDataSeries.getAttachedAxisIndex());
  72.              else
  73. -                nNumberFormatKey = rDataSeries.detectNumberFormatKey( nPointIndex );
  74. +                nNumberFormatKey = rDataSeries.detectNumberFormatKey(nPointIndex);
  75. +
  76. +            if (m_bIsPercentStacked)
  77. +            {
  78. +                OUString nPropName = OUString(CHART_UNONAME_NUMFMT);
  79. +                uno::Reference< beans::XPropertySet > xPointProp(rDataSeries.getPropertiesOfPoint(nPointIndex));
  80. +                if (xPointProp.is())
  81. +                {
  82. +                    xPointProp->setPropertyValue(nPropName, uno::Any(nNumberFormatKey));
  83. +                }
  84. +            }
  85.          }
  86. +
  87.          if(nNumberFormatKey<0)
  88.              nNumberFormatKey=0;
  89.  
  90. @@ -1637,6 +1650,12 @@ void VSeriesPlotter::setExplicitCategoriesProvider( ExplicitCategoriesProvider*
  91.      m_pExplicitCategoriesProvider = pExplicitCategoriesProvider;
  92.  }
  93.  
  94. +
  95. +void VSeriesPlotter::setIsPercentStacked(const bool aIsPercentStacked)
  96. +{
  97. +    m_bIsPercentStacked = aIsPercentStacked;
  98. +}
  99. +
  100.  sal_Int32 VDataSeriesGroup::getPointCount() const
  101.  {
  102.      if(!m_bMaxPointCountDirty)
  103. diff --git a/chart2/source/view/inc/VSeriesPlotter.hxx b/chart2/source/view/inc/VSeriesPlotter.hxx
  104. index fb4ffbb8c6af..10cfab9a6d80 100644
  105. --- a/chart2/source/view/inc/VSeriesPlotter.hxx
  106. +++ b/chart2/source/view/inc/VSeriesPlotter.hxx
  107. @@ -237,12 +237,15 @@ public:
  108.  
  109.      void setExplicitCategoriesProvider( ExplicitCategoriesProvider* pExplicitCategoriesProvider );
  110.  
  111. +    void setIsPercentStacked(const bool aIsPercentStacked);
  112. +
  113.      //get series names for the z axis labels
  114.      css::uno::Sequence< OUString > getSeriesNames() const;
  115.  
  116.      void setPageReferenceSize( const css::awt::Size & rPageRefSize );
  117.      //better performance for big data
  118.      void setCoordinateSystemResolution( const css::uno::Sequence< sal_Int32 >& rCoordinateSystemResolution );
  119. +
  120.      bool PointsWereSkipped() const { return m_bPointsWereSkipped;}
  121.  
  122.      //return the depth for a logic 1
  123. @@ -401,6 +404,7 @@ protected:
  124.  
  125.      std::unique_ptr< NumberFormatterWrapper > m_apNumberFormatterWrapper;
  126.      AxesNumberFormats                         m_aAxesNumberFormats;//direct numberformats on axes, if empty ask the data series instead
  127. +    bool m_bIsPercentStacked; // If true, chart type is Percent Stacked
  128.  
  129.      css::uno::Reference< css::chart2::XColorScheme >    m_xColorScheme;
  130.  
  131. diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx
  132. index 56c7a59e795b..e46e4c87c6aa 100644
  133. --- a/chart2/source/view/main/ChartView.cxx
  134. +++ b/chart2/source/view/main/ChartView.cxx
  135. @@ -48,6 +48,7 @@
  136.  #include "BaseGFXHelper.hxx"
  137.  #include "DataSeriesHelper.hxx"
  138.  #include "DateHelper.hxx"
  139. +#include "StackMode.hxx"
  140.  #include "defines.hxx"
  141.  #include <unonames.hxx>
  142.  #if HAVE_FEATURE_OPENGL
  143. @@ -331,7 +332,7 @@ public:
  144.       */
  145.      void setScalesFromCooSysToPlotter();
  146.  
  147. -    void setNumberFormatsFromAxes();
  148. +    void setNumberFormatsFromAxes(const bool aIsPercentStacked);
  149.      drawing::Direction3D getPreferredAspectRatio();
  150.  
  151.      SeriesPlottersType& getSeriesPlotterList() { return m_aSeriesPlotterList; }
  152. @@ -613,7 +614,6 @@ void SeriesPlotterContainer::initializeCooSysAndSeriesPlotter(
  153.              }
  154.          }
  155.      }
  156. -
  157.      //transport seriesnames to the coordinatesystems if needed
  158.      if( !m_aSeriesPlotterList.empty() )
  159.      {
  160. @@ -738,7 +738,7 @@ void SeriesPlotterContainer::setScalesFromCooSysToPlotter()
  161.      }
  162.  }
  163.  
  164. -void SeriesPlotterContainer::setNumberFormatsFromAxes()
  165. +void SeriesPlotterContainer::setNumberFormatsFromAxes(const bool aIsPercentStacked)
  166.  {
  167.      //set numberformats to plotter to enable them to display the data labels in the numberformat of the axis
  168.      for( std::unique_ptr<VSeriesPlotter>& aPlotter : m_aSeriesPlotterList )
  169. @@ -763,6 +763,7 @@ void SeriesPlotterContainer::setNumberFormatsFromAxes()
  170.                              sal_Int32 nNumberFormatKey(0);
  171.                              if( xAxisProp->getPropertyValue(CHART_UNONAME_NUMFMT) >>= nNumberFormatKey )
  172.                              {
  173. +                                pSeriesPlotter->setIsPercentStacked(aIsPercentStacked);
  174.                                  aAxesNumberFormats.setFormat( nNumberFormatKey, nDimensionIndex, nAxisIndex );
  175.                              }
  176.                              else if( nDimensionIndex==0 )
  177. @@ -1612,12 +1613,24 @@ awt::Rectangle ChartView::impl_createDiagramAndContent( const CreateShapeParam2D
  178.          pVCooSys->createVAxisList(xChartDoc, rPageSize, rParam.maRemainingSpace);
  179.      }
  180.  
  181. +    Reference< chart2::XChartType > xChartType( DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) );
  182. +    uno::Reference< XCoordinateSystemContainer > xCooSysContainer( xDiagram, uno::UNO_QUERY );
  183. +    bool bIsPercentStacked = false;
  184. +    bool bFound = false;
  185. +    bool bAmbiguous = false;
  186. +    if( xCooSysContainer.is() )
  187. +    {
  188. +        uno::Sequence< uno::Reference< XCoordinateSystem > > aCooSysList( xCooSysContainer->getCoordinateSystems() );
  189. +        if (DiagramHelper::getStackModeFromChartType(xChartType, bFound, bAmbiguous, aCooSysList[0]) == StackMode::StackMode_Y_STACKED_PERCENT)
  190. +            bIsPercentStacked = true;
  191. +    }
  192. +
  193.      // - prepare list of all axis and how they are used
  194.      Date aNullDate = NumberFormatterWrapper( xNumberFormatsSupplier ).getNullDate();
  195.      rParam.mpSeriesPlotterContainer->initAxisUsageList(aNullDate);
  196.      rParam.mpSeriesPlotterContainer->doAutoScaling( mrChartModel );
  197.      rParam.mpSeriesPlotterContainer->setScalesFromCooSysToPlotter();
  198. -    rParam.mpSeriesPlotterContainer->setNumberFormatsFromAxes();
  199. +    rParam.mpSeriesPlotterContainer->setNumberFormatsFromAxes(bIsPercentStacked);
  200.  
  201.      //create shapes
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement