chart2/source/inc/ChartTypeHelper.hxx | 1 + chart2/source/tools/ChartTypeHelper.cxx | 13 +++++++++++++ chart2/source/view/main/ChartView.cxx | 9 +++++++-- 3 files changed, 21 insertions(+), 2 deletions(-)
New commits: commit 80ada110c56398e984d3f2d1f0ae1f30e8a73690 Author: Andras Timar <andras.ti...@collabora.com> AuthorDate: Tue Nov 9 23:36:32 2021 +0100 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Mon Nov 15 12:37:02 2021 +0100 tdf#136111 fix scaling problem on chart driven by a macro Change-Id: I9a55bcfceb9259f0d5dc944c00a34b3e4a891e0e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124940 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Dennis Francis <dennis.fran...@collabora.com> (cherry picked from commit 0644f44daef7caa8a246221d762fbc0f6af3672c) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124864 Tested-by: Jenkins Reviewed-by: Andras Timar <andras.ti...@collabora.com> (cherry picked from commit 453363ae1384a6d6f2c77052170b39a1ebf567a6) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124970 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/chart2/source/inc/ChartTypeHelper.hxx b/chart2/source/inc/ChartTypeHelper.hxx index 1a6345321825..d4917be283fb 100644 --- a/chart2/source/inc/ChartTypeHelper.hxx +++ b/chart2/source/inc/ChartTypeHelper.hxx @@ -49,6 +49,7 @@ public: static bool isSupportingDateAxis( const css::uno::Reference< css::chart2::XChartType >& xChartType, sal_Int32 nDimensionIndex ); static bool isSupportingComplexCategory( const css::uno::Reference< css::chart2::XChartType >& xChartType ); static bool isSupportingCategoryPositioning( const css::uno::Reference< css::chart2::XChartType >& xChartType, sal_Int32 nDimensionCount ); + static bool shiftCategoryPosAtXAxisPerDefault( const css::uno::Reference< css::chart2::XChartType >& xChartType ); //returns sequence of css::chart::DataLabelPlacement static css::uno::Sequence < sal_Int32 > getSupportedLabelPlacements( diff --git a/chart2/source/tools/ChartTypeHelper.cxx b/chart2/source/tools/ChartTypeHelper.cxx index a4b8059ffb19..a260636a0604 100644 --- a/chart2/source/tools/ChartTypeHelper.cxx +++ b/chart2/source/tools/ChartTypeHelper.cxx @@ -464,6 +464,19 @@ bool ChartTypeHelper::isSupportingCategoryPositioning( const uno::Reference< cha return false; } +bool ChartTypeHelper::shiftCategoryPosAtXAxisPerDefault( const uno::Reference< chart2::XChartType >& xChartType ) +{ + if(xChartType.is()) + { + OUString aChartTypeName = xChartType->getChartType(); + if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_COLUMN) + || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BAR) + || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK) ) + return true; + } + return false; +} + bool ChartTypeHelper::noBordersForSimpleScheme( const uno::Reference< chart2::XChartType >& xChartType ) { if(xChartType.is()) diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index f6642c920968..5cfee64f0641 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -323,7 +323,7 @@ public: void AdaptScaleOfYAxisWithoutAttachedSeries( ChartModel& rModel ); - static bool isCategoryPositionShifted( + bool isCategoryPositionShifted( const chart2::ScaleData& rSourceScale, bool bHasComplexCategories ); private: @@ -348,12 +348,14 @@ private: */ sal_Int32 m_nMaxAxisIndex; + bool m_bChartTypeUsesShiftedCategoryPositionPerDefault; sal_Int32 m_nDefaultDateNumberFormat; }; SeriesPlotterContainer::SeriesPlotterContainer( std::vector< std::unique_ptr<VCoordinateSystem> >& rVCooSysList ) : m_rVCooSysList( rVCooSysList ) , m_nMaxAxisIndex(0) + , m_bChartTypeUsesShiftedCategoryPositionPerDefault(false) , m_nDefaultDateNumberFormat(0) { } @@ -517,6 +519,9 @@ void SeriesPlotterContainer::initializeCooSysAndSeriesPlotter( } } + if(nT==0) + m_bChartTypeUsesShiftedCategoryPositionPerDefault = ChartTypeHelper::shiftCategoryPosAtXAxisPerDefault( xChartType ); + bool bExcludingPositioning = DiagramHelper::getDiagramPositioningMode( xDiagram ) == DiagramPositioningMode_EXCLUDING; VSeriesPlotter* pPlotter = VSeriesPlotter::createSeriesPlotter( xChartType, nDimensionCount, bExcludingPositioning ); if( !pPlotter ) @@ -628,7 +633,7 @@ bool SeriesPlotterContainer::isCategoryPositionShifted( const chart2::ScaleData& rSourceScale, bool bHasComplexCategories ) { if (rSourceScale.AxisType == AxisType::CATEGORY) - return bHasComplexCategories || rSourceScale.ShiftedCategoryPosition; + return bHasComplexCategories || rSourceScale.ShiftedCategoryPosition || m_bChartTypeUsesShiftedCategoryPositionPerDefault; if (rSourceScale.AxisType == AxisType::DATE) return rSourceScale.ShiftedCategoryPosition;