chart2/qa/extras/chart2export.cxx        |   38 +++++++++++++++++++++++++++++++
 chart2/qa/extras/data/docx/fdo77216.docx |binary
 oox/source/export/chartexport.cxx        |   17 +++++++++++++
 3 files changed, 54 insertions(+), 1 deletion(-)

New commits:
commit a211c754003f98bc8f7761224a0b265bd224f61f
Author: Sourav <sourav.maha...@synerzip.com>
Date:   Tue Apr 15 16:39:52 2014 +0530

    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.mohrh...@googlemail.com>
    Reviewed-by: Markus Mohrhard <markus.mohrh...@googlemail.com>

diff --git a/chart2/qa/extras/chart2export.cxx 
b/chart2/qa/extras/chart2export.cxx
index bc1dcd3..eded887 100644
--- a/chart2/qa/extras/chart2export.cxx
+++ b/chart2/qa/extras/chart2export.cxx
@@ -36,6 +36,7 @@ public:
     void testStockChart();
     void testBarChart();
     void testCrosses();
+    void testScatterChart();
     void testChartDataTable();
     void testChartExternalData();
     void testEmbeddingsGrabBag();
@@ -64,6 +65,7 @@ public:
     CPPUNIT_TEST(testStockChart);
     CPPUNIT_TEST(testBarChart);
     CPPUNIT_TEST(testCrosses);
+    CPPUNIT_TEST(testScatterChart);
     CPPUNIT_TEST(testChartDataTable);
     CPPUNIT_TEST(testChartExternalData);
     CPPUNIT_TEST(testEmbeddingsGrabBag);
@@ -117,6 +119,14 @@ protected:
      * Same as the assertXPath(), but don't assert: return the string instead.
      */
     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:
 };
@@ -211,6 +221,24 @@ void Chart2ExportTest::assertXPath(xmlDocPtr pXmlDoc, 
const OString& rXPath, int
         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)
 {
     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");
 }
 
+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()
 {
     load("/chart2/qa/extras/data/docx/", "testChartDataTable.docx");
diff --git a/chart2/qa/extras/data/docx/fdo77216.docx 
b/chart2/qa/extras/data/docx/fdo77216.docx
new file mode 100644
index 0000000..b741bbc
Binary files /dev/null and b/chart2/qa/extras/data/docx/fdo77216.docx differ
diff --git a/oox/source/export/chartexport.cxx 
b/oox/source/export/chartexport.cxx
index f6e02db..9b12eb7 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -2008,6 +2008,14 @@ void ChartExport::exportSeriesValues( const Reference< 
chart2::data::XDataSequen
     pFS->singleElement( FSNS( XML_c, XML_ptCount ),
             XML_val, I32S( ptCount ),
             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++ )
     {
         pFS->startElement( FSNS( XML_c, XML_pt ),
@@ -2015,8 +2023,15 @@ void ChartExport::exportSeriesValues( const Reference< 
chart2::data::XDataSequen
             FSEND );
         pFS->startElement( FSNS( XML_c, XML_v ),
             FSEND );
-        if (!rtl::math::isNan(aValues[i]))
+        if (bIsNumberValue && !rtl::math::isNan(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_pt ) );
     }
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to