diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx index 53f4a2d30e19..c0850820acc3 100644 --- a/chart2/qa/extras/chart2import.cxx +++ b/chart2/qa/extras/chart2import.cxx @@ -129,6 +129,7 @@ public: void testTdf114179(); void testTdf124243(); + void testTdf127393(); void testDeletedDataLabel(); void testDataPointInheritedColorDOCX(); void testExternalStrRefsXLSX(); @@ -218,6 +219,7 @@ public: CPPUNIT_TEST(testTdf114179); CPPUNIT_TEST(testTdf124243); + CPPUNIT_TEST(testTdf127393); CPPUNIT_TEST(testDeletedDataLabel); CPPUNIT_TEST(testDataPointInheritedColorDOCX); CPPUNIT_TEST(testExternalStrRefsXLSX); @@ -1929,6 +1931,33 @@ void Chart2ImportTest::testTdf124243() CPPUNIT_ASSERT(!bShow); } +void Chart2ImportTest::testTdf127393() +{ + load("/chart2/qa/extras/data/pptx/", "tdf127393.pptx"); + + // 1st chart + Reference xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY); + CPPUNIT_ASSERT(xChartDoc.is()); + + Reference xAxis = getAxisFromDoc(xChartDoc, 0, 0, 0); + CPPUNIT_ASSERT(xAxis.is()); + + chart2::ScaleData aScaleData1 = xAxis->getScaleData(); + CPPUNIT_ASSERT(aScaleData1.Categories.is()); + CPPUNIT_ASSERT(aScaleData1.ShiftedCategoryPosition); + + // 2nd chart + xChartDoc.set(getChartDocFromDrawImpress(1, 0), uno::UNO_QUERY); + CPPUNIT_ASSERT(xChartDoc.is()); + + xAxis.set(getAxisFromDoc(xChartDoc, 0, 0, 0)); + CPPUNIT_ASSERT(xAxis.is()); + + chart2::ScaleData aScaleData2 = xAxis->getScaleData(); + CPPUNIT_ASSERT(aScaleData2.Categories.is()); + CPPUNIT_ASSERT(!aScaleData2.ShiftedCategoryPosition); +} + namespace { void checkDataLabelProperties(const Reference& xDataSeries, sal_Int32 nDataPointIndex, bool bValueVisible) diff --git a/chart2/qa/extras/data/pptx/tdf127393.pptx b/chart2/qa/extras/data/pptx/tdf127393.pptx new file mode 100644 index 000000000000..7c4047817a2f Binary files /dev/null and b/chart2/qa/extras/data/pptx/tdf127393.pptx differ diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index 200b4b4e9823..238069cdf2e1 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -325,7 +325,7 @@ public: void AdaptScaleOfYAxisWithoutAttachedSeries( ChartModel& rModel ); bool isCategoryPositionShifted( - const chart2::ScaleData& rSourceScale, bool bHasComplexCategories ) const; + const chart2::ScaleData& rSourceScale, bool bHasComplexCategories, bool bShiftedCategoryPosition) const; private: /** A vector of series plotters. @@ -631,12 +631,12 @@ void SeriesPlotterContainer::initializeCooSysAndSeriesPlotter( } bool SeriesPlotterContainer::isCategoryPositionShifted( - const chart2::ScaleData& rSourceScale, bool bHasComplexCategories ) const + const chart2::ScaleData& rSourceScale, bool bHasComplexCategories, bool bShiftedCategoryPosition) const { - if (rSourceScale.AxisType == AxisType::CATEGORY && m_bChartTypeUsesShiftedCategoryPositionPerDefault) + if (rSourceScale.AxisType == AxisType::CATEGORY && (m_bChartTypeUsesShiftedCategoryPositionPerDefault || bShiftedCategoryPosition)) return true; - if (rSourceScale.AxisType==AxisType::CATEGORY && bHasComplexCategories) + if (rSourceScale.AxisType == AxisType::CATEGORY && bHasComplexCategories) return true; if (rSourceScale.AxisType == AxisType::DATE) @@ -683,7 +683,9 @@ void SeriesPlotterContainer::initAxisUsageList(const Date& rNullDate) AxisHelper::checkDateAxis( aSourceScale, pCatProvider, bDateAxisAllowed ); bool bHasComplexCat = pCatProvider && pCatProvider->hasComplexCategories(); - aSourceScale.ShiftedCategoryPosition = isCategoryPositionShifted(aSourceScale, bHasComplexCat); + // Come from CrossBetween OOXML tag + bool bShiftedCategoryPosition = aSourceScale.ShiftedCategoryPosition; + aSourceScale.ShiftedCategoryPosition = isCategoryPositionShifted(aSourceScale, bHasComplexCat, bShiftedCategoryPosition); m_aAxisUsageList[xAxis].aAutoScaling = ScaleAutomatism(aSourceScale, rNullDate); } diff --git a/oox/source/drawingml/chart/axiscontext.cxx b/oox/source/drawingml/chart/axiscontext.cxx index b3181d8a6cda..45f61a9a019c 100644 --- a/oox/source/drawingml/chart/axiscontext.cxx +++ b/oox/source/drawingml/chart/axiscontext.cxx @@ -281,7 +281,7 @@ ContextHandlerRef ValAxisContext::onCreateContext( sal_Int32 nElement, const Att if( isRootElement() ) switch( nElement ) { case C_TOKEN( crossBetween ): - mrModel.mnCrossBetween = rAttribs.getToken( XML_val, XML_between ); + mrModel.mnCrossBetween = rAttribs.getToken( XML_val, -1 ); return nullptr; case C_TOKEN( dispUnits ): return new AxisDispUnitsContext( *this, mrModel.mxDispUnits.create() ); diff --git a/oox/source/drawingml/chart/axisconverter.cxx b/oox/source/drawingml/chart/axisconverter.cxx index a98e1b51223e..9f2cc0f715dc 100644 --- a/oox/source/drawingml/chart/axisconverter.cxx +++ b/oox/source/drawingml/chart/axisconverter.cxx @@ -213,6 +213,7 @@ void AxisConverter::convertFromModel( aScaleData.AxisType = (bDateAxis && !mrModel.mbAuto) ? cssc2::AxisType::DATE : cssc2::AxisType::CATEGORY; aScaleData.AutoDateAxis = mrModel.mbAuto; aScaleData.Categories = rTypeGroups.front()->createCategorySequence(); + aScaleData.ShiftedCategoryPosition = pCrossingAxis->mnCrossBetween == XML_between; } else { diff --git a/oox/source/drawingml/chart/axismodel.cxx b/oox/source/drawingml/chart/axismodel.cxx index b09e9e879b9d..6659990cca21 100644 --- a/oox/source/drawingml/chart/axismodel.cxx +++ b/oox/source/drawingml/chart/axismodel.cxx @@ -36,7 +36,7 @@ AxisModel::AxisModel( sal_Int32 nTypeId, bool bMSO2007Doc ) : mnAxisId( -1 ), mnAxisPos( XML_TOKEN_INVALID ), mnCrossAxisId( -1 ), - mnCrossBetween( XML_between ), + mnCrossBetween( -1 ), mnCrossMode( XML_autoZero ), mnLabelAlign( XML_ctr ), mnLabelOffset( 100 ),