[Libreoffice-commits] core.git: Branch 'libreoffice-6-3' - chart2/qa oox/source
Balazs Varga (via logerrit)
logerrit at kemper.freedesktop.org
Mon Sep 2 14:07:37 UTC 2019
chart2/qa/extras/chart2export.cxx | 16 ++++++++++++++++
chart2/qa/extras/data/odt/tdf114657.odt |binary
oox/source/export/chartexport.cxx | 24 ++++++------------------
3 files changed, 22 insertions(+), 18 deletions(-)
New commits:
commit e61d2bc5be81c482f5243fdc86b35b724e679d46
Author: Balazs Varga <balazs.varga991 at gmail.com>
AuthorDate: Wed Aug 28 11:27:52 2019 +0200
Commit: Xisco Faulí <xiscofauli at libreoffice.org>
CommitDate: Mon Sep 2 16:06:59 2019 +0200
tdf#114657 OOXML chart export: fix broken chart with NaN X value
Export c:pt elements only for numbers instead of replace the correct
X values with the sequence 1, 2, 3..., when the X values contain a NaN
value.
This reverts commit a211c754003f98bc8f7761224a0b265bd224f61f
"fdo77216-Charts-Scattered chart: Chart gets distorted on RT"
Change-Id: I6d0bec870b5317575d93eff407b3ec2ada56431e
Reviewed-on: https://gerrit.libreoffice.org/78221
Reviewed-by: László Németh <nemeth at numbertext.org>
Tested-by: László Németh <nemeth at numbertext.org>
(cherry picked from commit 2bd8e41a0fc10974f81695c1b2e32dc07c569d97)
Reviewed-on: https://gerrit.libreoffice.org/78398
Tested-by: Jenkins
Reviewed-by: Xisco Faulí <xiscofauli at libreoffice.org>
diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx
index c6aaf0e02509..28bc0f34b53e 100644
--- a/chart2/qa/extras/chart2export.cxx
+++ b/chart2/qa/extras/chart2export.cxx
@@ -48,6 +48,7 @@ public:
void testBarChart();
void testCrosses();
void testScatterChartTextXValues();
+ void testScatterXAxisValues();
void testChartDataTable();
void testChartExternalData();
void testEmbeddingsGrabBag();
@@ -146,6 +147,7 @@ public:
CPPUNIT_TEST(testBarChart);
CPPUNIT_TEST(testCrosses);
CPPUNIT_TEST(testScatterChartTextXValues);
+ CPPUNIT_TEST(testScatterXAxisValues);
CPPUNIT_TEST(testChartDataTable);
CPPUNIT_TEST(testChartExternalData);
CPPUNIT_TEST(testEmbeddingsGrabBag);
@@ -646,6 +648,20 @@ void Chart2ExportTest::testScatterChartTextXValues()
assertXPathContent(pXmlDoc, "//c:scatterChart/c:ser[1]/c:xVal[1]/c:numRef[1]/c:numCache[1]/c:pt[1]/c:v[1]", "1");
}
+void Chart2ExportTest::testScatterXAxisValues()
+{
+ load("/chart2/qa/extras/data/odt/", "tdf114657.odt");
+
+ xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
+ CPPUNIT_ASSERT(pXmlDoc);
+
+ assertXPath(pXmlDoc, "//c:scatterChart/c:ser/c:xVal/c:numRef/c:numCache/c:ptCount", "val", "5");
+ assertXPathContent(pXmlDoc, "//c:scatterChart/c:ser/c:xVal/c:numRef/c:numCache/c:pt[1]/c:v", "15");
+ assertXPathContent(pXmlDoc, "//c:scatterChart/c:ser/c:xVal/c:numRef/c:numCache/c:pt[2]/c:v", "11");
+ assertXPathContent(pXmlDoc, "//c:scatterChart/c:ser/c:xVal/c:numRef/c:numCache/c:pt[3]/c:v", "20");
+ assertXPathContent(pXmlDoc, "//c:scatterChart/c:ser/c:xVal/c:numRef/c:numCache/c:pt[4]/c:v", "16");
+}
+
void Chart2ExportTest::testChartDataTable()
{
load("/chart2/qa/extras/data/docx/", "testChartDataTable.docx");
diff --git a/chart2/qa/extras/data/odt/tdf114657.odt b/chart2/qa/extras/data/odt/tdf114657.odt
new file mode 100644
index 000000000000..4c99963b0d4f
Binary files /dev/null and b/chart2/qa/extras/data/odt/tdf114657.odt differ
diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx
index 4f2e9c61846a..512d8187af41 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -2180,28 +2180,16 @@ void ChartExport::exportSeriesValues( const Reference< chart2::data::XDataSequen
pFS->endElement( FSNS( XML_c, XML_formatCode ) );
pFS->singleElement(FSNS(XML_c, XML_ptCount), XML_val, OString::number(ptCount));
- bool bIsNumberValue = true;
- bool bXSeriesValue = false;
- double Value = 1.0;
-
- if(nValueType == XML_xVal)
- bXSeriesValue = true;
-
for( sal_Int32 i = 0; i < ptCount; i++ )
{
- pFS->startElement(FSNS(XML_c, XML_pt), XML_idx, OString::number(i));
- pFS->startElement(FSNS(XML_c, XML_v));
- if (bIsNumberValue && !rtl::math::isNan(aValues[i]))
- pFS->write( aValues[i] );
- else if(bXSeriesValue)
+ if (!rtl::math::isNan(aValues[i]))
{
- //In Case aValues is not a number for X Values...We write X values as 1,2,3....MS Word does the same thing.
- pFS->write( Value );
- Value = Value + 1;
- bIsNumberValue = false;
+ pFS->startElement(FSNS(XML_c, XML_pt), XML_idx, OString::number(i));
+ pFS->startElement(FSNS(XML_c, XML_v));
+ pFS->write(aValues[i]);
+ pFS->endElement(FSNS(XML_c, XML_v));
+ pFS->endElement(FSNS(XML_c, XML_pt));
}
- pFS->endElement( FSNS( XML_c, XML_v ) );
- pFS->endElement( FSNS( XML_c, XML_pt ) );
}
pFS->endElement( FSNS( XML_c, XML_numCache ) );
More information about the Libreoffice-commits
mailing list