diff options
author | Andras Timar <andras.timar@collabora.com> | 2021-11-09 23:36:32 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2021-11-10 11:29:45 +0100 |
commit | 0644f44daef7caa8a246221d762fbc0f6af3672c (patch) | |
tree | 6c417484f5b4a9a77f5feddaae880aa6dbc09734 | |
parent | 5f90820949ed208b5b46bcb4ba3cd08d2783ae4f (diff) |
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 <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Dennis Francis <dennis.francis@collabora.com>
-rw-r--r-- | chart2/source/inc/ChartTypeHelper.hxx | 1 | ||||
-rw-r--r-- | chart2/source/tools/ChartTypeHelper.cxx | 13 | ||||
-rw-r--r-- | chart2/source/view/main/ChartView.cxx | 9 |
3 files changed, 21 insertions, 2 deletions
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 56a64d349e6f..052e2f370f3f 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -325,7 +325,7 @@ public: void AdaptScaleOfYAxisWithoutAttachedSeries( ChartModel& rModel ); - static bool isCategoryPositionShifted( + bool isCategoryPositionShifted( const chart2::ScaleData& rSourceScale, bool bHasComplexCategories ); private: @@ -350,12 +350,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) { } @@ -519,6 +521,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 ) @@ -630,7 +635,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; |