tdf#140489 fix chart display in xlsx

Commit 1147383:
tdf#114181 XLSX combined chart: fix swapped primary and secondary axes etc.

introduced regression by applying axis swaping not only
for combined charts.

Change-Id: I764399579ff922ddd495540fdd2a39675f2a8da5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113836
Tested-by: Jenkins
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
This commit is contained in:
Szymon Kłos
2021-04-08 15:08:38 +02:00
parent 0b527b7fe7
commit be82f6313f
3 changed files with 41 additions and 2 deletions

View File

@@ -119,6 +119,7 @@ public:
void testAxisTitleRotationXLSX();
void testAxisTitlePositionDOCX();
void testCombinedChartAttachedAxisXLSX();
void testTdf140489MultiSeriesChartAxisXLSX();
void testTdf90510(); // Pie chart label placement settings(XLS)
void testTdf109858(); // Pie chart label placement settings(XLSX)
@@ -243,6 +244,7 @@ public:
CPPUNIT_TEST(testAxisTitleRotationXLSX);
CPPUNIT_TEST(testAxisTitlePositionDOCX);
CPPUNIT_TEST(testCombinedChartAttachedAxisXLSX);
CPPUNIT_TEST(testTdf140489MultiSeriesChartAxisXLSX);
CPPUNIT_TEST(testTdf90510);
CPPUNIT_TEST(testTdf109858);
CPPUNIT_TEST(testTdf130105);
@@ -1759,6 +1761,39 @@ void Chart2ImportTest::testCombinedChartAttachedAxisXLSX()
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nAxisIndex);
}
void Chart2ImportTest::testTdf140489MultiSeriesChartAxisXLSX()
{
load(u"/chart2/qa/extras/data/xlsx/", "tdf140489.xlsx");
Reference< chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
// First series
Reference<chart2::XDataSeries> xSeries = getDataSeriesFromDoc(xChartDoc, 0);
CPPUNIT_ASSERT(xSeries.is());
Reference<beans::XPropertySet> xPropSet(xSeries, uno::UNO_QUERY_THROW);
sal_Int32 nAxisIndex = -1;
uno::Any aAny = xPropSet->getPropertyValue("AttachedAxisIndex");
CPPUNIT_ASSERT(aAny >>= nAxisIndex);
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nAxisIndex);
// Second series
xSeries = getDataSeriesFromDoc(xChartDoc, 0, 1);
CPPUNIT_ASSERT(xSeries.is());
xPropSet.set(xSeries, uno::UNO_QUERY_THROW);
aAny = xPropSet->getPropertyValue("AttachedAxisIndex");
CPPUNIT_ASSERT(aAny >>= nAxisIndex);
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nAxisIndex);
// Third series
xSeries = getDataSeriesFromDoc(xChartDoc, 0, 2);
CPPUNIT_ASSERT(xSeries.is());
xPropSet.set(xSeries, uno::UNO_QUERY_THROW);
aAny = xPropSet->getPropertyValue("AttachedAxisIndex");
CPPUNIT_ASSERT(aAny >>= nAxisIndex);
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), nAxisIndex);
}
void Chart2ImportTest::testInternalDataProvider() {
uno::Reference< chart2::XChartDocument > xChartDoc(getChartDocFromImpress(u"/chart2/qa/extras/data/odp/", "chart.odp"), uno::UNO_QUERY_THROW);
const uno::Reference< chart2::data::XDataProvider >& rxDataProvider = xChartDoc->getDataProvider();

Binary file not shown.

View File

@@ -420,9 +420,13 @@ void PlotAreaConverter::convertFromModel( View3DModel& rView3DModel )
// varying point colors only for single series in single chart type
bool bSupportsVaryColorsByPoint = mrModel.maTypeGroups.size() == 1;
bool bIsCombinedChart = mrModel.maTypeGroups.size() == 2 &&
mrModel.maTypeGroups[0]->mnTypeId != mrModel.maTypeGroups[1]->mnTypeId;
// convert all axes sets, and check which axis is attached to the first maTypeGroups
sal_Int32 nStartAxesSetIdx = (rValAxisIds.size() > 1 && aAxesSets.size() > 0 && aAxesSets[0]->maAxes.count( API_Y_AXIS )
&& aAxesSets[0]->maAxes[ API_Y_AXIS ]->mnAxisId != rValAxisIds[0] ) ? 1 : 0;
sal_Int32 nStartAxesSetIdx = bIsCombinedChart ? ((rValAxisIds.size() > 1 && aAxesSets.size() > 0 && aAxesSets[0]->maAxes.count( API_Y_AXIS )
&& aAxesSets[0]->maAxes[ API_Y_AXIS ]->mnAxisId != rValAxisIds[0] ) ? 1 : 0)
: 0;
sal_Int32 nAxesSetIdx = nStartAxesSetIdx;
bool bUseFixedInnerSize = false;