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

YogeshBharate yogesh.bharate at synerzip.com
Mon Mar 3 04:41:46 PST 2014


 chart2/qa/extras/chart2export.cxx                  |   10 ++++++++++
 chart2/qa/extras/data/docx/testSeriesIdxOrder.docx |binary
 include/oox/export/chartexport.hxx                 |    1 +
 oox/source/export/chartexport.cxx                  |    7 +++++--
 4 files changed, 16 insertions(+), 2 deletions(-)

New commits:
commit 9ca4fa05eb5ec7d0d7c3f4a83489013e140d2f0b
Author: YogeshBharate <yogesh.bharate at synerzip.com>
Date:   Fri Feb 21 11:03:35 2014 +0530

    fdo#74826: File corruption-Issue related to Series idx & order val.
    
    Problem Description:
    - If the document contains more than one charts together.
      ex.Bar & Line chart
    - In that case, LO writes idx & order val equal to 0,
      instead of 1 for second chart series.
    - After roundtrip, the document get corrupted.
    
    Implementation:
    - Added varible to take the series count
      in case of multiple chart.
    
    Note:
    - Some of the UT's are failing when --enable-dbgutil is enabled.
    
    Change-Id: I40606b4d69026939fa19ae534dd7b2bb36ec97fc

diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx
index 8c7e7b3..e3554e5 100644
--- a/chart2/qa/extras/chart2export.cxx
+++ b/chart2/qa/extras/chart2export.cxx
@@ -48,6 +48,7 @@ public:
     void testBarChartRotation();
     void testShapeFollowedByChart();
     void testPieChartDataLabels();
+    void testSeriesIdxOrder();
 
     CPPUNIT_TEST_SUITE(Chart2ExportTest);
     CPPUNIT_TEST(test);
@@ -68,6 +69,7 @@ public:
     CPPUNIT_TEST(testBarChartRotation);
     CPPUNIT_TEST(testShapeFollowedByChart);
     CPPUNIT_TEST(testPieChartDataLabels);
+    CPPUNIT_TEST(testSeriesIdxOrder);
     CPPUNIT_TEST_SUITE_END();
 
 protected:
@@ -610,6 +612,14 @@ void Chart2ExportTest::testPieChartDataLabels()
     assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:pie3DChart/c:ser[1]/c:dLbls/c:dLbl[1]/c:dLblPos", "val", "bestFit");
 }
 
+void Chart2ExportTest::testSeriesIdxOrder()
+{
+    load("/chart2/qa/extras/data/docx/", "testSeriesIdxOrder.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:idx[1]", "val", "1");
+    assertXPath(pXmlDoc, "/c:chartSpace[1]/c:chart[1]/c:plotArea[1]/c:lineChart[1]/c:ser[1]/c:order[1]", "val", "1");
+}
 CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ExportTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/chart2/qa/extras/data/docx/testSeriesIdxOrder.docx b/chart2/qa/extras/data/docx/testSeriesIdxOrder.docx
new file mode 100644
index 0000000..9274e2c
Binary files /dev/null and b/chart2/qa/extras/data/docx/testSeriesIdxOrder.docx differ
diff --git a/include/oox/export/chartexport.hxx b/include/oox/export/chartexport.hxx
index 04a5e20..b95fc58 100644
--- a/include/oox/export/chartexport.hxx
+++ b/include/oox/export/chartexport.hxx
@@ -83,6 +83,7 @@ public:
 
 private:
     sal_Int32           mnXmlNamespace;
+    sal_Int32           mnSeriesCount;
     Fraction            maFraction;
     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > mxChartModel;
     com::sun::star::uno::Reference< com::sun::star::chart::XDiagram > mxDiagram;
diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx
index 4250cb7..9f8df56 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -438,6 +438,7 @@ sal_Int32 lcl_generateRandomValue()
 ChartExport::ChartExport( sal_Int32 nXmlNamespace, FSHelperPtr pFS, Reference< frame::XModel >& xModel, XmlFilterBase* pFB, DocumentType eDocumentType )
     : DrawingML( pFS, pFB, eDocumentType )
     , mnXmlNamespace( nXmlNamespace )
+    , mnSeriesCount(0)
     , maFraction( 1, 576 )
     , mxChartModel( xModel )
     , mbHasCategoryLabels( sal_False )
@@ -1041,9 +1042,11 @@ void ChartExport::exportPlotArea( )
         aCooSysSeq( xBCooSysCnt->getCoordinateSystems());
     for( sal_Int32 nCSIdx=0; nCSIdx<aCooSysSeq.getLength(); ++nCSIdx )
     {
+
         Reference< chart2::XChartTypeContainer > xCTCnt( aCooSysSeq[nCSIdx], uno::UNO_QUERY );
         if( ! xCTCnt.is())
             continue;
+        mnSeriesCount=0;
         Sequence< Reference< chart2::XChartType > > aCTSeq( xCTCnt->getChartTypes());
         for( sal_Int32 nCTIdx=0; nCTIdx<aCTSeq.getLength(); ++nCTIdx )
         {
@@ -1689,10 +1692,10 @@ void ChartExport::exportSeries( Reference< chart2::XChartType > xChartType, sal_
 
                     // TODO: idx and order
                     pFS->singleElement( FSNS( XML_c, XML_idx ),
-                        XML_val, I32S(nSeriesIdx),
+                        XML_val, I32S(mnSeriesCount),
                         FSEND );
                     pFS->singleElement( FSNS( XML_c, XML_order ),
-                        XML_val, I32S(nSeriesIdx),
+                        XML_val, I32S(mnSeriesCount++),
                         FSEND );
 
                     // export label


More information about the Libreoffice-commits mailing list