fdo77216-Charts-Scattered chart: Chart gets distorted on RT
In case there is some text entered in place of X coordinates for scatter chart then x coordinates should be taken as 1,2,3.... MS Word does the same thing Change-Id: I1db0fd64c6ac0f4d5e77a9676812f5e26577ecf6 Reviewed-on: https://gerrit.libreoffice.org/9011 Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com> Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
This commit is contained in:
@@ -36,6 +36,7 @@ public:
|
|||||||
void testStockChart();
|
void testStockChart();
|
||||||
void testBarChart();
|
void testBarChart();
|
||||||
void testCrosses();
|
void testCrosses();
|
||||||
|
void testScatterChart();
|
||||||
void testChartDataTable();
|
void testChartDataTable();
|
||||||
void testChartExternalData();
|
void testChartExternalData();
|
||||||
void testEmbeddingsGrabBag();
|
void testEmbeddingsGrabBag();
|
||||||
@@ -64,6 +65,7 @@ public:
|
|||||||
CPPUNIT_TEST(testStockChart);
|
CPPUNIT_TEST(testStockChart);
|
||||||
CPPUNIT_TEST(testBarChart);
|
CPPUNIT_TEST(testBarChart);
|
||||||
CPPUNIT_TEST(testCrosses);
|
CPPUNIT_TEST(testCrosses);
|
||||||
|
CPPUNIT_TEST(testScatterChart);
|
||||||
CPPUNIT_TEST(testChartDataTable);
|
CPPUNIT_TEST(testChartDataTable);
|
||||||
CPPUNIT_TEST(testChartExternalData);
|
CPPUNIT_TEST(testChartExternalData);
|
||||||
CPPUNIT_TEST(testEmbeddingsGrabBag);
|
CPPUNIT_TEST(testEmbeddingsGrabBag);
|
||||||
@@ -117,6 +119,14 @@ protected:
|
|||||||
* Same as the assertXPath(), but don't assert: return the string instead.
|
* Same as the assertXPath(), but don't assert: return the string instead.
|
||||||
*/
|
*/
|
||||||
OUString getXPath(xmlDocPtr pXmlDoc, const OString& rXPath, const OString& rAttribute);
|
OUString getXPath(xmlDocPtr pXmlDoc, const OString& rXPath, const OString& rAttribute);
|
||||||
|
/**
|
||||||
|
Assert that rXPath exists, and its content equals rContent.
|
||||||
|
*/
|
||||||
|
void assertXPathContent(xmlDocPtr pXmlDoc, const OString& rXPath, const OUString& rContent);
|
||||||
|
/**
|
||||||
|
Same as the assertXPathContent(), but don't assert: return the string instead.
|
||||||
|
*/
|
||||||
|
OUString getXPathContent(xmlDocPtr pXmlDoc, const OString& rXPath);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
@@ -211,6 +221,24 @@ void Chart2ExportTest::assertXPath(xmlDocPtr pXmlDoc, const OString& rXPath, int
|
|||||||
nNumberOfNodes, xmlXPathNodeSetGetLength(pXmlNodes));
|
nNumberOfNodes, xmlXPathNodeSetGetLength(pXmlNodes));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Chart2ExportTest::assertXPathContent(xmlDocPtr pXmlDoc, const OString& rXPath, const OUString& rContent)
|
||||||
|
{
|
||||||
|
CPPUNIT_ASSERT_EQUAL_MESSAGE("XPath contents of child does not match", rContent, getXPathContent(pXmlDoc, rXPath));
|
||||||
|
}
|
||||||
|
|
||||||
|
OUString Chart2ExportTest::getXPathContent(xmlDocPtr pXmlDoc, const OString& rXPath)
|
||||||
|
{
|
||||||
|
xmlNodeSetPtr pXmlNodes = getXPathNode(pXmlDoc, rXPath);
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT_MESSAGE(OString("XPath '" + rXPath + "' not found").getStr(),
|
||||||
|
xmlXPathNodeSetGetLength(pXmlNodes) > 0);
|
||||||
|
|
||||||
|
xmlNodePtr pXmlNode = pXmlNodes->nodeTab[0];
|
||||||
|
|
||||||
|
_xmlNode *pNode = &(pXmlNode->children[0]);
|
||||||
|
return pNode ? OUString::createFromAscii((const char*)((pXmlNode->children[0]).content)) : OUString();
|
||||||
|
}
|
||||||
|
|
||||||
OUString Chart2ExportTest::getXPath(xmlDocPtr pXmlDoc, const OString& rXPath, const OString& rAttribute)
|
OUString Chart2ExportTest::getXPath(xmlDocPtr pXmlDoc, const OString& rXPath, const OString& rAttribute)
|
||||||
{
|
{
|
||||||
xmlNodeSetPtr pXmlNodes = getXPathNode(pXmlDoc, rXPath);
|
xmlNodeSetPtr pXmlNodes = getXPathNode(pXmlDoc, rXPath);
|
||||||
@@ -479,6 +507,16 @@ void Chart2ExportTest::testCrosses()
|
|||||||
assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:catAx/c:crosses", "val", "autoZero");
|
assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:catAx/c:crosses", "val", "autoZero");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Chart2ExportTest::testScatterChart()
|
||||||
|
{
|
||||||
|
load("/chart2/qa/extras/data/docx/", "fdo77216.docx");
|
||||||
|
xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
|
||||||
|
if (!pXmlDoc)
|
||||||
|
return;
|
||||||
|
|
||||||
|
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::testChartDataTable()
|
void Chart2ExportTest::testChartDataTable()
|
||||||
{
|
{
|
||||||
load("/chart2/qa/extras/data/docx/", "testChartDataTable.docx");
|
load("/chart2/qa/extras/data/docx/", "testChartDataTable.docx");
|
||||||
|
BIN
chart2/qa/extras/data/docx/fdo77216.docx
Normal file
BIN
chart2/qa/extras/data/docx/fdo77216.docx
Normal file
Binary file not shown.
@@ -2008,6 +2008,14 @@ void ChartExport::exportSeriesValues( const Reference< chart2::data::XDataSequen
|
|||||||
pFS->singleElement( FSNS( XML_c, XML_ptCount ),
|
pFS->singleElement( FSNS( XML_c, XML_ptCount ),
|
||||||
XML_val, I32S( ptCount ),
|
XML_val, I32S( ptCount ),
|
||||||
FSEND );
|
FSEND );
|
||||||
|
|
||||||
|
sal_Bool bIsNumberValue = sal_True;
|
||||||
|
sal_Bool bXSeriesValue = sal_False;
|
||||||
|
double Value = 1.0;
|
||||||
|
|
||||||
|
if(nValueType == XML_xVal)
|
||||||
|
bXSeriesValue = sal_True;
|
||||||
|
|
||||||
for( sal_Int32 i = 0; i < ptCount; i++ )
|
for( sal_Int32 i = 0; i < ptCount; i++ )
|
||||||
{
|
{
|
||||||
pFS->startElement( FSNS( XML_c, XML_pt ),
|
pFS->startElement( FSNS( XML_c, XML_pt ),
|
||||||
@@ -2015,8 +2023,15 @@ void ChartExport::exportSeriesValues( const Reference< chart2::data::XDataSequen
|
|||||||
FSEND );
|
FSEND );
|
||||||
pFS->startElement( FSNS( XML_c, XML_v ),
|
pFS->startElement( FSNS( XML_c, XML_v ),
|
||||||
FSEND );
|
FSEND );
|
||||||
if (!rtl::math::isNan(aValues[i]))
|
if (bIsNumberValue && !rtl::math::isNan(aValues[i]))
|
||||||
pFS->write( aValues[i] );
|
pFS->write( aValues[i] );
|
||||||
|
else if(bXSeriesValue)
|
||||||
|
{
|
||||||
|
//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 = sal_False;
|
||||||
|
}
|
||||||
pFS->endElement( FSNS( XML_c, XML_v ) );
|
pFS->endElement( FSNS( XML_c, XML_v ) );
|
||||||
pFS->endElement( FSNS( XML_c, XML_pt ) );
|
pFS->endElement( FSNS( XML_c, XML_pt ) );
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user