[Libreoffice-commits] core.git: chart2/qa oox/source

Bisal Singh Nayal bisal.nayal at synerzip.com
Tue May 20 03:12:32 PDT 2014


 chart2/qa/extras/chart2export.cxx                                   |   40 ++++++++++
 chart2/qa/extras/data/docx/fdo78290_Combination_Chart_Marker_x.docx |binary
 chart2/qa/extras/data/docx/fdo78290_Line_Chart_Marker_x.docx        |binary
 chart2/qa/extras/data/docx/fdo78290_Scatter_Chart_Marker_x.docx     |binary
 oox/source/export/chartexport.cxx                                   |    5 -
 5 files changed, 43 insertions(+), 2 deletions(-)

New commits:
commit ee0bb265c90a135afa53c0fa6a586996e67640fa
Author: Bisal Singh Nayal <bisal.nayal at synerzip.com>
Date:   Wed May 7 20:03:11 2014 +0530

    fdo#78290 : The File gets corrupted when saved in LO
    
    Problem Description: Docx file containing a chart (line chart / scatter chart)which has used a builtin
    marker'x' gets corrupted when we save it in LO.The reason was that while exporting LO was writing the
    marker information 'x' as 'X' which MS Word doesn't recognize.‒<c:marker><c:symbol val="X" />. Also
    the size of the marker was coming 1 less than the actual value. Ex: if size is 7 then it was being
    written as  6.
    
    Solution: During export I have made changes so that now LO writes 'x' in the tag information
    ‒<c:marker> <c:symbol val="x" />. Now the size of the marker is also being correctly exported.
    
    Change-Id: I26b747f9576625bf3acb941322ae418a0bbc6b64
    Reviewed-on: https://gerrit.libreoffice.org/9273
    Tested-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx
index 30a252a..c75b5c2 100644
--- a/chart2/qa/extras/chart2export.cxx
+++ b/chart2/qa/extras/chart2export.cxx
@@ -57,6 +57,9 @@ public:
     void testGapWidthXLSX();
     void testSmoothedLines();
     void testLabelStringODS();
+    void testfdo78290_Line_Chart_Marker_x();
+    void testfdo78290_Scatter_Chart_Marker_x();
+    void testfdo78290_Combination_Chart_Marker_x();
 
     CPPUNIT_TEST_SUITE(Chart2ExportTest);
     CPPUNIT_TEST(test);
@@ -86,6 +89,9 @@ public:
     CPPUNIT_TEST(testGapWidthXLSX);
     CPPUNIT_TEST(testSmoothedLines);
     CPPUNIT_TEST(testLabelStringODS);
+    CPPUNIT_TEST(testfdo78290_Line_Chart_Marker_x);
+    CPPUNIT_TEST(testfdo78290_Scatter_Chart_Marker_x);
+    CPPUNIT_TEST(testfdo78290_Combination_Chart_Marker_x);
     CPPUNIT_TEST_SUITE_END();
 
 protected:
@@ -629,6 +635,40 @@ void Chart2ExportTest::testFdo74115WallBitmapFill()
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:spPr/a:blipFill");
 }
 
+//The below test case tests the built in marker 'x' for Office 2010 in Line charts
+
+void Chart2ExportTest::testfdo78290_Line_Chart_Marker_x()
+{
+    load("/chart2/qa/extras/data/docx/", "fdo78290_Line_Chart_Marker_x.docx");
+    xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
+    CPPUNIT_ASSERT(pXmlDoc);
+    assertXPath(pXmlDoc, "/c:chartSpace[1]/c:chart[1]/c:plotArea[1]/c:lineChart[1]/c:ser[1]/c:marker[1]/c:symbol[1]","val","x");
+    assertXPath(pXmlDoc, "/c:chartSpace[1]/c:chart[1]/c:plotArea[1]/c:lineChart[1]/c:ser[1]/c:marker[1]/c:size[1]","val","7");
+}
+
+// We can also use the built in marker 'x' in scatter chart, hence writing the test case for the same.
+
+void Chart2ExportTest::testfdo78290_Scatter_Chart_Marker_x()
+{
+    load("/chart2/qa/extras/data/docx/", "fdo78290_Scatter_Chart_Marker_x.docx");
+    xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
+    CPPUNIT_ASSERT(pXmlDoc);
+    assertXPath(pXmlDoc, "/c:chartSpace[1]/c:chart[1]/c:plotArea[1]/c:scatterChart[1]/c:ser[1]/c:marker[1]/c:symbol[1]","val","x");
+    assertXPath(pXmlDoc, "/c:chartSpace[1]/c:chart[1]/c:plotArea[1]/c:scatterChart[1]/c:ser[1]/c:marker[1]/c:size[1]","val","7");
+}
+
+// Also in a combination of charts like a column chart and line chart, we can use the built in marker 'x'
+// for the line chart too. hence put a test case for the combination chart also.
+
+void Chart2ExportTest::testfdo78290_Combination_Chart_Marker_x()
+{
+    load("/chart2/qa/extras/data/docx/", "fdo78290_Combination_Chart_Marker_x.docx");
+    xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
+    CPPUNIT_ASSERT(pXmlDoc);
+    assertXPath(pXmlDoc, "/c:chartSpace[1]/c:chart[1]/c:plotArea[1]/c:lineChart[1]/c:ser[1]/c:marker[1]/c:symbol[1]","val","x");
+    assertXPath(pXmlDoc, "/c:chartSpace[1]/c:chart[1]/c:plotArea[1]/c:lineChart[1]/c:ser[1]/c:marker[1]/c:size[1]","val","7");
+}
+
 void Chart2ExportTest::testBarChartRotation()
 {
     load ("/chart2/qa/extras/data/docx/", "barChartRotation.docx");
diff --git a/chart2/qa/extras/data/docx/fdo78290_Combination_Chart_Marker_x.docx b/chart2/qa/extras/data/docx/fdo78290_Combination_Chart_Marker_x.docx
new file mode 100644
index 0000000..ee2489d
Binary files /dev/null and b/chart2/qa/extras/data/docx/fdo78290_Combination_Chart_Marker_x.docx differ
diff --git a/chart2/qa/extras/data/docx/fdo78290_Line_Chart_Marker_x.docx b/chart2/qa/extras/data/docx/fdo78290_Line_Chart_Marker_x.docx
new file mode 100644
index 0000000..7e4b096
Binary files /dev/null and b/chart2/qa/extras/data/docx/fdo78290_Line_Chart_Marker_x.docx differ
diff --git a/chart2/qa/extras/data/docx/fdo78290_Scatter_Chart_Marker_x.docx b/chart2/qa/extras/data/docx/fdo78290_Scatter_Chart_Marker_x.docx
new file mode 100644
index 0000000..2edc8f0
Binary files /dev/null and b/chart2/qa/extras/data/docx/fdo78290_Scatter_Chart_Marker_x.docx differ
diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx
index 68bb9f0..48c8fc5 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -3000,7 +3000,7 @@ void ChartExport::exportMarker(Reference< chart2::XDataSeries > xSeries)
             pSymbolType = "star";
             break;
         case 10:
-            pSymbolType = "X";
+            pSymbolType = "x"; // in MS office 2010 built in symbol marker 'X' is represented as 'x'
             break;
         case 11:
             pSymbolType = "plus";
@@ -3023,7 +3023,8 @@ void ChartExport::exportMarker(Reference< chart2::XDataSeries > xSeries)
     awt::Size aSymbolSize = aSymbol.Size;
     sal_Int32 nSize = std::max( aSymbolSize.Width, aSymbolSize.Height );
 
-    nSize = nSize/250.0*7.0; // just guessed based on some test cases
+    nSize = nSize/250.0*7.0 + 1; // just guessed based on some test cases,
+                                //the value is always 1 less than the actual value.
     nSize = std::min<sal_Int32>( 72, std::max<sal_Int32>( 2, nSize ) );
     pFS->singleElement( FSNS( XML_c, XML_size),
             XML_val, I32S(nSize),


More information about the Libreoffice-commits mailing list