diff options
author | Balazs Varga <balazs.varga991@gmail.com> | 2019-10-03 20:31:44 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2019-10-07 12:36:28 +0200 |
commit | 111c260ab2883b7906f1a66e222dbf4dc3c58c4f (patch) | |
tree | 1f558e1da5379fdc2103157f371307077d9a4d4a /chart2 | |
parent | 0a3704d172f3c721d7b217f9bafe026c457dab55 (diff) |
tdf#127777 OOXML chart export: fix "CrossBetween" for not imported charts
Newly created or ODF charts were still exported incorrectly, because
ShiftedCategoryPosition was stored in the view code. Now it is removed
to the model using ChartTypeTemplate::adaptScales.
See also commit 6027ec08fd5df2e09e34ff61b3777ad2cc8304b3 'tdf#127777
OOXML chart export: fix X axis position setting "CrossBetween"'
Change-Id: I7cd69e311833bf9f24f3a600ee7c6312285a7738
Reviewed-on: https://gerrit.libreoffice.org/80160
Reviewed-by: László Németh <nemeth@numbertext.org>
Tested-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'chart2')
-rw-r--r-- | chart2/qa/extras/chart2export.cxx | 11 | ||||
-rw-r--r-- | chart2/qa/extras/data/ods/test_CrossBetween.ods | bin | 0 -> 12365 bytes | |||
-rw-r--r-- | chart2/source/model/template/ChartTypeTemplate.cxx | 7 | ||||
-rw-r--r-- | chart2/source/tools/AxisHelper.cxx | 2 | ||||
-rw-r--r-- | chart2/source/view/main/ChartView.cxx | 17 |
5 files changed, 22 insertions, 15 deletions
diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx index 2589428831bc..8a0705f7d140 100644 --- a/chart2/qa/extras/chart2export.cxx +++ b/chart2/qa/extras/chart2export.cxx @@ -121,6 +121,7 @@ public: void testCombinedChartSecondaryAxisXLSX(); void testCombinedChartSecondaryAxisODS(); void testCrossBetweenXLSX(); + void testCrossBetweenODS(); void testAxisTitleRotationXLSX(); void testAxisCrossBetweenXSLX(); void testPieChartDataPointExplosionXLSX(); @@ -225,6 +226,7 @@ public: CPPUNIT_TEST(testCombinedChartSecondaryAxisXLSX); CPPUNIT_TEST(testCombinedChartSecondaryAxisODS); CPPUNIT_TEST(testCrossBetweenXLSX); + CPPUNIT_TEST(testCrossBetweenODS); CPPUNIT_TEST(testAxisTitleRotationXLSX); CPPUNIT_TEST(testAxisCrossBetweenXSLX); CPPUNIT_TEST(testPieChartDataPointExplosionXLSX); @@ -1912,6 +1914,15 @@ void Chart2ExportTest::testCrossBetweenXLSX() assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:crossBetween", "val", "between"); } +void Chart2ExportTest::testCrossBetweenODS() +{ + // Original file was created with LibreOffice + load("/chart2/qa/extras/data/ods/", "test_CrossBetween.ods"); + xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); + CPPUNIT_ASSERT(pXmlDoc); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:crossBetween", "val", "between"); +} + void Chart2ExportTest::testAxisTitleRotationXLSX() { load("/chart2/qa/extras/data/xlsx/", "axis_title_rotation.xlsx"); diff --git a/chart2/qa/extras/data/ods/test_CrossBetween.ods b/chart2/qa/extras/data/ods/test_CrossBetween.ods Binary files differnew file mode 100644 index 000000000000..e59546b3d0cd --- /dev/null +++ b/chart2/qa/extras/data/ods/test_CrossBetween.ods diff --git a/chart2/source/model/template/ChartTypeTemplate.cxx b/chart2/source/model/template/ChartTypeTemplate.cxx index c3710e45d7d4..c18851796ada 100644 --- a/chart2/source/model/template/ChartTypeTemplate.cxx +++ b/chart2/source/model/template/ChartTypeTemplate.cxx @@ -623,8 +623,11 @@ void ChartTypeTemplate::adaptScales( aData.Categories = xCategories; if(bSupportsCategories) { - - Reference< XChartType > xChartType( getChartTypeForNewSeries(Sequence< Reference< XChartType > >() )); + Reference< XChartType > xChartType(getChartTypeForNewSeries(Sequence< Reference< XChartType > >())); + if( aData.AxisType == AxisType::CATEGORY ) + { + aData.ShiftedCategoryPosition = ::chart::ChartTypeHelper::shiftCategoryPosAtXAxisPerDefault(xChartType); + } bool bSupportsDates = ::chart::ChartTypeHelper::isSupportingDateAxis( xChartType, nDimensionX ); if( aData.AxisType != AxisType::CATEGORY && ( aData.AxisType != AxisType::DATE || !bSupportsDates) ) { diff --git a/chart2/source/tools/AxisHelper.cxx b/chart2/source/tools/AxisHelper.cxx index 25d481bff352..6ec3d44f48d4 100644 --- a/chart2/source/tools/AxisHelper.cxx +++ b/chart2/source/tools/AxisHelper.cxx @@ -73,7 +73,7 @@ ScaleData AxisHelper::createDefaultScale() ScaleData aScaleData; aScaleData.AxisType = chart2::AxisType::REALNUMBER; aScaleData.AutoDateAxis = true; - aScaleData.ShiftedCategoryPosition = false;//this is adapted in the view code currently + aScaleData.ShiftedCategoryPosition = false; Sequence< SubIncrement > aSubIncrements(1); aSubIncrements[0] = SubIncrement(); aScaleData.IncrementData.SubIncrements = aSubIncrements; diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index 5fc24786e5ab..6824c4f516c9 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -324,8 +324,8 @@ public: void AdaptScaleOfYAxisWithoutAttachedSeries( ChartModel& rModel ); - bool isCategoryPositionShifted( - const chart2::ScaleData& rSourceScale, bool bHasComplexCategories, bool bShiftedCategoryPosition) const; + static bool isCategoryPositionShifted( + const chart2::ScaleData& rSourceScale, bool bHasComplexCategories ); private: /** A vector of series plotters. @@ -349,14 +349,12 @@ 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) { } @@ -520,9 +518,6 @@ 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 ) @@ -631,9 +626,9 @@ void SeriesPlotterContainer::initializeCooSysAndSeriesPlotter( } bool SeriesPlotterContainer::isCategoryPositionShifted( - const chart2::ScaleData& rSourceScale, bool bHasComplexCategories, bool bShiftedCategoryPosition) const + const chart2::ScaleData& rSourceScale, bool bHasComplexCategories ) { - if (rSourceScale.AxisType == AxisType::CATEGORY && (m_bChartTypeUsesShiftedCategoryPositionPerDefault || bShiftedCategoryPosition)) + if (rSourceScale.AxisType == AxisType::CATEGORY && rSourceScale.ShiftedCategoryPosition) return true; if (rSourceScale.AxisType == AxisType::CATEGORY && bHasComplexCategories) @@ -683,9 +678,7 @@ void SeriesPlotterContainer::initAxisUsageList(const Date& rNullDate) AxisHelper::checkDateAxis( aSourceScale, pCatProvider, bDateAxisAllowed ); bool bHasComplexCat = pCatProvider && pCatProvider->hasComplexCategories(); - // Come from CrossBetween OOXML tag - bool bShiftedCategoryPosition = aSourceScale.ShiftedCategoryPosition; - aSourceScale.ShiftedCategoryPosition = isCategoryPositionShifted(aSourceScale, bHasComplexCat, bShiftedCategoryPosition); + aSourceScale.ShiftedCategoryPosition = isCategoryPositionShifted(aSourceScale, bHasComplexCat); m_aAxisUsageList[xAxis].aAutoScaling = ScaleAutomatism(aSourceScale, rNullDate); } |