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

Rohit Deshmukh rohit.deshmukh at synerzip.com
Fri Oct 11 15:25:46 PDT 2013


 oox/source/export/chartexport.cxx |   80 +++++++++++++++++++++++++++-----------
 1 file changed, 57 insertions(+), 23 deletions(-)

New commits:
commit f7ff594a9c879ea3ae437e0f7602ef26642e6fc7
Author: Rohit Deshmukh <rohit.deshmukh at synerzip.com>
Date:   Mon Sep 30 16:06:09 2013 +0530

    Fix for Corruption of chart due to Data Lables in Writer, Impress and Calc
    
    Chart file gets corrupted, if we save file in Libreoffice and open in MS office.
    MS Office gives error, file is Corrupt.
    
    Following charts get fixed
    
    1. Radar chart
    2. Area chart without data labels
    3. Line chart
    4. Bubble chart
    
    Area chart with data label file gets courrputed after roundtrip in Libreoffice.
    
    Change-Id: Ib03ad49aae268b53aa18bdc21c723e2a7777eb45

diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx
index 7e56305..2dc837b 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -2275,6 +2275,11 @@ void ChartExport::exportDataLabels(
         pFS->startElement( FSNS( XML_c, XML_dLbls ),
                     FSEND );
 
+        bool showLegendSymbol = false;
+        bool showNumber = false;
+        bool showCategoryName = false;
+        bool showNumberInPercent = false;
+
         sal_Int32 nElem;
         for( nElem = 0; nElem < nSeriesLength; ++nElem)
         {
@@ -2319,34 +2324,63 @@ void ChartExport::exportDataLabels(
                        case csscd::AVOID_OVERLAP: aPlacement = "bestFit";  break;
                    }
 
-                   pFS->startElement( FSNS( XML_c, XML_dLbl ), FSEND);
-                   pFS->singleElement( FSNS( XML_c, XML_idx), XML_val, I32S(nElem), FSEND);
-                   pFS->singleElement( FSNS( XML_c, XML_dLblPos), XML_val, aPlacement, FSEND);
-
-                   pFS->singleElement( FSNS( XML_c, XML_showLegendKey), XML_val,
-                                       aLabel.ShowLegendSymbol ? "1" : "0", FSEND);
-                   pFS->singleElement( FSNS( XML_c, XML_showVal), XML_val,
-                                       aLabel.ShowNumber ? "1" : "0", FSEND);
-                   pFS->singleElement( FSNS( XML_c, XML_showCatName), XML_val,
-                                       aLabel.ShowCategoryName ? "1" : "0", FSEND);
-                   // MSO somehow assumes series name to be on (=displayed) by default.
-                   // Let's put false here and switch it off then, since we have no UI means
-                   // in LibO to toggle it on anyway
-                   pFS->singleElement( FSNS( XML_c, XML_showSerName), XML_val, "0", FSEND);
-                   pFS->singleElement( FSNS( XML_c, XML_showPercent), XML_val,
-                                       aLabel.ShowNumberInPercent ? "1" : "0", FSEND);
-
-                   if (GetProperty( xPropSet, "LabelSeparator"))
+                   if(aLabel.ShowLegendSymbol || aLabel.ShowNumber || aLabel.ShowCategoryName || aLabel.ShowNumberInPercent)
                    {
-                       mAny >>= aSep;
-                       pFS->startElement( FSNS( XML_c, XML_separator), FSEND);
-                       pFS->writeEscaped(aSep);
-                       pFS->endElement( FSNS( XML_c, XML_separator) );
+                       pFS->startElement( FSNS( XML_c, XML_dLbl ), FSEND);
+                       pFS->singleElement( FSNS( XML_c, XML_idx), XML_val, I32S(nElem), FSEND);
+                       pFS->singleElement( FSNS( XML_c, XML_dLblPos), XML_val, aPlacement, FSEND);
+
+                       pFS->singleElement( FSNS( XML_c, XML_showLegendKey), XML_val, aLabel.ShowLegendSymbol ? "1": "0", FSEND);
+                       if (aLabel.ShowLegendSymbol)
+                       {
+                           showLegendSymbol = true;
+                       }
+
+                       pFS->singleElement( FSNS( XML_c, XML_showVal), XML_val,aLabel.ShowNumber ? "1": "0", FSEND);
+                       if(aLabel.ShowNumber)
+                       {
+                           showNumber = true;
+                       }
+
+                       pFS->singleElement( FSNS( XML_c, XML_showCatName), XML_val, aLabel.ShowCategoryName ? "1": "0", FSEND);
+                       if(aLabel.ShowCategoryName)
+                       {
+                           showCategoryName =  true;
+                       }
+
+                       // MSO somehow assumes series name to be on (=displayed) by default.
+                       // Let's put false here and switch it off then, since we have no UI means
+                       // in LibO to toggle it on anyway
+                       pFS->singleElement( FSNS( XML_c, XML_showSerName), XML_val, "0", FSEND);
+
+                       pFS->singleElement( FSNS( XML_c, XML_showPercent), XML_val,aLabel.ShowNumberInPercent ? "1": "0", FSEND);
+                       if(aLabel.ShowNumberInPercent)
+                       {
+                           showNumberInPercent = true;
+                       }
+
+                       if (GetProperty( xPropSet, "LabelSeparator"))
+                       {
+                           mAny >>= aSep;
+                           pFS->startElement( FSNS( XML_c, XML_separator), FSEND);
+                           pFS->writeEscaped(aSep);
+                           pFS->endElement( FSNS( XML_c, XML_separator) );
+                       }
+                       pFS->endElement( FSNS( XML_c, XML_dLbl ));
                    }
-                   pFS->endElement( FSNS( XML_c, XML_dLbl ));
+
                }
             }
         }
+
+        pFS->singleElement( FSNS( XML_c, XML_showLegendKey), XML_val, showLegendSymbol ? "1": "0", FSEND);
+        pFS->singleElement( FSNS( XML_c, XML_showVal), XML_val, showNumber ? "1": "0", FSEND);
+        pFS->singleElement( FSNS( XML_c, XML_showCatName), XML_val, showCategoryName ? "1": "0", FSEND);
+
+        pFS->singleElement( FSNS( XML_c, XML_showSerName), XML_val, "0", FSEND);
+
+        pFS->singleElement( FSNS( XML_c, XML_showPercent), XML_val, showNumberInPercent ? "1": "0", FSEND);
+
         pFS->endElement( FSNS( XML_c, XML_dLbls ) );
     }
 }


More information about the Libreoffice-commits mailing list