tdf#124466 XLSX: fix broken export by removing chart type data redundancy
XLSX import created a redundant series container for data series with the same chart type, when they were attached to a different axis. Modifying the loaded chart by the user, ie. attaching one of its data series to a different axis resulted broken OOXML export later, because based on the new axis, splitDataSeriesByAxis splitted the first or the redundant series container further. Now the import creates only a single series container for the series with the same chart type, preventing potential export problems. Change-Id: If951feaca3cb3b5df7718e9d7bfd59620ef3c4d3 Reviewed-on: https://gerrit.libreoffice.org/70141 Reviewed-by: László Németh <nemeth@numbertext.org> Tested-by: László Németh <nemeth@numbertext.org>
This commit is contained in:
committed by
László Németh
parent
69b5da3929
commit
a3881a66b8
@@ -113,6 +113,7 @@ public:
|
|||||||
void testBarChartVaryColorsXLSX();
|
void testBarChartVaryColorsXLSX();
|
||||||
void testMultipleAxisXLSX();
|
void testMultipleAxisXLSX();
|
||||||
void testSecondaryAxisXLSX();
|
void testSecondaryAxisXLSX();
|
||||||
|
void testSetSeriesToSecondaryAxisXLSX();
|
||||||
void testAxisTitleRotationXLSX();
|
void testAxisTitleRotationXLSX();
|
||||||
void testAxisCrossBetweenXSLX();
|
void testAxisCrossBetweenXSLX();
|
||||||
void testPieChartDataPointExplosionXLSX();
|
void testPieChartDataPointExplosionXLSX();
|
||||||
@@ -206,6 +207,7 @@ public:
|
|||||||
CPPUNIT_TEST(testBarChartVaryColorsXLSX);
|
CPPUNIT_TEST(testBarChartVaryColorsXLSX);
|
||||||
CPPUNIT_TEST(testMultipleAxisXLSX);
|
CPPUNIT_TEST(testMultipleAxisXLSX);
|
||||||
CPPUNIT_TEST(testSecondaryAxisXLSX);
|
CPPUNIT_TEST(testSecondaryAxisXLSX);
|
||||||
|
CPPUNIT_TEST(testSetSeriesToSecondaryAxisXLSX);
|
||||||
CPPUNIT_TEST(testAxisTitleRotationXLSX);
|
CPPUNIT_TEST(testAxisTitleRotationXLSX);
|
||||||
CPPUNIT_TEST(testAxisCrossBetweenXSLX);
|
CPPUNIT_TEST(testAxisCrossBetweenXSLX);
|
||||||
CPPUNIT_TEST(testPieChartDataPointExplosionXLSX);
|
CPPUNIT_TEST(testPieChartDataPointExplosionXLSX);
|
||||||
@@ -1760,6 +1762,25 @@ void Chart2ExportTest::testSecondaryAxisXLSX()
|
|||||||
assertXPathContent(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart[2]/c:ser[1]/c:tx/c:strRef/c:strCache/c:pt/c:v", "a");
|
assertXPathContent(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart[2]/c:ser[1]/c:tx/c:strRef/c:strCache/c:pt/c:v", "a");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Chart2ExportTest::testSetSeriesToSecondaryAxisXLSX()
|
||||||
|
{
|
||||||
|
load("/chart2/qa/extras/data/xlsx/", "add_series_secondary_axis.xlsx");
|
||||||
|
Reference< chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
|
||||||
|
// Second series
|
||||||
|
Reference<chart2::XDataSeries> xSeries = getDataSeriesFromDoc(xChartDoc, 1);
|
||||||
|
CPPUNIT_ASSERT(xSeries.is());
|
||||||
|
|
||||||
|
Reference<beans::XPropertySet> xPropSet(xSeries, uno::UNO_QUERY_THROW);
|
||||||
|
sal_Int32 AxisIndex = 1;
|
||||||
|
// Attach the second series to the secondary axis. (The third series is already attached.)
|
||||||
|
xPropSet->setPropertyValue("AttachedAxisIndex", uno::Any(AxisIndex));
|
||||||
|
|
||||||
|
xmlDocPtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML");
|
||||||
|
CPPUNIT_ASSERT(pXmlDoc);
|
||||||
|
// Check there are only two <lineChart> tag in the XML, one for the primary and one for the secondary axis.
|
||||||
|
assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart", 2);
|
||||||
|
}
|
||||||
|
|
||||||
void Chart2ExportTest::testAxisTitleRotationXLSX()
|
void Chart2ExportTest::testAxisTitleRotationXLSX()
|
||||||
{
|
{
|
||||||
load("/chart2/qa/extras/data/xlsx/", "axis_title_rotation.xlsx");
|
load("/chart2/qa/extras/data/xlsx/", "axis_title_rotation.xlsx");
|
||||||
|
BIN
chart2/qa/extras/data/xlsx/add_series_secondary_axis.xlsx
Executable file
BIN
chart2/qa/extras/data/xlsx/add_series_secondary_axis.xlsx
Executable file
Binary file not shown.
@@ -312,6 +312,10 @@ void TypeGroupConverter::convertFromModel( const Reference< XDiagram >& rxDiagra
|
|||||||
OUString aService = OUString::createFromAscii( maTypeInfo.mpcServiceName );
|
OUString aService = OUString::createFromAscii( maTypeInfo.mpcServiceName );
|
||||||
Reference< XChartType > xChartType( createInstance( aService ), UNO_QUERY_THROW );
|
Reference< XChartType > xChartType( createInstance( aService ), UNO_QUERY_THROW );
|
||||||
|
|
||||||
|
Reference< XChartTypeContainer > xChartTypeContOld( rxCoordSystem, UNO_QUERY_THROW );
|
||||||
|
Sequence< Reference< XChartType > > xOldChartTypes( xChartTypeContOld->getChartTypes() );
|
||||||
|
sal_Int32 nOldChartTypeIdx = -1;
|
||||||
|
|
||||||
// additional properties
|
// additional properties
|
||||||
PropertySet aDiaProp( rxDiagram );
|
PropertySet aDiaProp( rxDiagram );
|
||||||
PropertySet aTypeProp( xChartType );
|
PropertySet aTypeProp( xChartType );
|
||||||
@@ -419,11 +423,19 @@ void TypeGroupConverter::convertFromModel( const Reference< XDiagram >& rxDiagra
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
for( sal_Int32 nCTIdx=0; nCTIdx<xOldChartTypes.getLength(); ++nCTIdx )
|
||||||
|
{
|
||||||
|
if ( xChartType->getChartType() == xOldChartTypes[nCTIdx]->getChartType() )
|
||||||
|
{
|
||||||
|
nOldChartTypeIdx = nCTIdx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (auto const& elem : aSeries)
|
for (auto const& elem : aSeries)
|
||||||
{
|
{
|
||||||
SeriesConverter& rSeriesConv = *elem;
|
SeriesConverter& rSeriesConv = *elem;
|
||||||
Reference< XDataSeries > xDataSeries = rSeriesConv.createDataSeries( *this, bVaryColorsByPoint );
|
Reference< XDataSeries > xDataSeries = rSeriesConv.createDataSeries( *this, bVaryColorsByPoint );
|
||||||
insertDataSeries( xChartType, xDataSeries, nAxesSetIdx );
|
insertDataSeries( nOldChartTypeIdx == -1 ? xChartType : xOldChartTypes[nOldChartTypeIdx], xDataSeries, nAxesSetIdx );
|
||||||
|
|
||||||
/* Excel does not use the value of the c:smooth element of the
|
/* Excel does not use the value of the c:smooth element of the
|
||||||
chart type to set a default line smoothing for the data
|
chart type to set a default line smoothing for the data
|
||||||
@@ -440,7 +452,10 @@ void TypeGroupConverter::convertFromModel( const Reference< XDiagram >& rxDiagra
|
|||||||
|
|
||||||
// add chart type object to coordinate system
|
// add chart type object to coordinate system
|
||||||
Reference< XChartTypeContainer > xChartTypeCont( rxCoordSystem, UNO_QUERY_THROW );
|
Reference< XChartTypeContainer > xChartTypeCont( rxCoordSystem, UNO_QUERY_THROW );
|
||||||
xChartTypeCont->addChartType( xChartType );
|
if (nOldChartTypeIdx == -1)
|
||||||
|
{
|
||||||
|
xChartTypeCont->addChartType(xChartType);
|
||||||
|
}
|
||||||
|
|
||||||
// set existence of bar connector lines at diagram (only in stacked 2D bar charts)
|
// set existence of bar connector lines at diagram (only in stacked 2D bar charts)
|
||||||
if( mrModel.mxSerLines.is() && !mb3dChart && (maTypeInfo.meTypeCategory == TYPECATEGORY_BAR) && (isStacked() || isPercent()) )
|
if( mrModel.mxSerLines.is() && !mb3dChart && (maTypeInfo.meTypeCategory == TYPECATEGORY_BAR) && (isStacked() || isPercent()) )
|
||||||
|
Reference in New Issue
Block a user