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

Tünde Tóth (via logerrit) logerrit at kemper.freedesktop.org
Mon Oct 19 12:20:12 UTC 2020


 chart2/qa/extras/chart2export.cxx    |   22 +++++++++++++++++++++-
 xmloff/source/chart/SchXMLExport.cxx |   12 ++++++++++++
 2 files changed, 33 insertions(+), 1 deletion(-)

New commits:
commit f1d798151048dde3f48b124ef406416668d1e9c5
Author:     Tünde Tóth <toth.tunde at nisz.hu>
AuthorDate: Fri Oct 16 13:41:28 2020 +0200
Commit:     László Németh <nemeth at numbertext.org>
CommitDate: Mon Oct 19 14:19:34 2020 +0200

    tdf#137585 Chart ODF: fix export of DataLabelPlacement::CUSTOM
    
    Saving .ods, the DataLabelPlacement::CUSTOM converted to
    the default "avoid-overlap" instead of the requested "outside".
    
    Follow-up of commit 20da1a5dd37c7edac620566c992d5a53b23a5f12
    (tdf#134978 Chart OOXML Import: fix pie chart label custom position)
    
    Change-Id: Ib15c7f24e0a650c84e6afce08b84e7eece8dafea
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104430
    Tested-by: László Németh <nemeth at numbertext.org>
    Reviewed-by: László Németh <nemeth at numbertext.org>

diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx
index e9d154d4ade1..d86fa14ef84c 100644
--- a/chart2/qa/extras/chart2export.cxx
+++ b/chart2/qa/extras/chart2export.cxx
@@ -180,6 +180,7 @@ public:
     void testTdf134977();
     void testTdf123647();
     void testTdf136267();
+    void testDataLabelPlacementPieChart();
 
     CPPUNIT_TEST_SUITE(Chart2ExportTest);
     CPPUNIT_TEST(testErrorBarXLSX);
@@ -322,6 +323,7 @@ public:
     CPPUNIT_TEST(testTdf134977);
     CPPUNIT_TEST(testTdf123647);
     CPPUNIT_TEST(testTdf136267);
+    CPPUNIT_TEST(testDataLabelPlacementPieChart);
 
     CPPUNIT_TEST_SUITE_END();
 
@@ -1432,7 +1434,7 @@ void Chart2ExportTest::testPieChartDataLabels()
     load("/chart2/qa/extras/data/docx/", "PieChartDataLabels.docx");
     xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
     CPPUNIT_ASSERT(pXmlDoc);
-    assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:pie3DChart/c:ser[1]/c:dLbls/c:dLbl[1]/c:dLblPos", "val", "bestFit");
+    assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:pie3DChart/c:ser[1]/c:dLbls/c:dLbl[1]/c:dLblPos", "val", "outEnd");
 }
 
 void Chart2ExportTest::testSeriesIdxOrder()
@@ -2949,6 +2951,24 @@ void Chart2ExportTest::testTdf136267()
     assertXPathContent(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:cat/c:strRef/c:strCache/c:pt/c:v", "John");
 }
 
+void Chart2ExportTest::testDataLabelPlacementPieChart()
+{
+    load("/chart2/qa/extras/data/xlsx/", "tdf134978.xlsx");
+    reload("calc8");
+    uno::Reference<chart::XChartDocument> xChartDoc(getChartCompFromSheet(0, mxComponent),
+                                                     UNO_QUERY_THROW);
+    // test the placement of the manually positioned label
+    Reference<beans::XPropertySet>
+            xDataPointPropSet(xChartDoc->getDiagram()->getDataPointProperties(2, 0),
+                              uno::UNO_SET_THROW);
+    uno::Any aAny = xDataPointPropSet->getPropertyValue("LabelPlacement");
+    CPPUNIT_ASSERT(aAny.hasValue());
+    sal_Int32 nLabelPlacement = 0;
+    CPPUNIT_ASSERT(aAny >>= nLabelPlacement);
+    CPPUNIT_ASSERT_EQUAL(chart::DataLabelPlacement::OUTSIDE, nLabelPlacement);
+
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ExportTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx
index 07a1019ccc71..723c07fe15c4 100644
--- a/xmloff/source/chart/SchXMLExport.cxx
+++ b/xmloff/source/chart/SchXMLExport.cxx
@@ -63,6 +63,7 @@
 #include <com/sun/star/chart/ChartLegendExpansion.hpp>
 #include <com/sun/star/chart/ChartDataRowSource.hpp>
 #include <com/sun/star/chart/ChartAxisAssign.hpp>
+#include <com/sun/star/chart/DataLabelPlacement.hpp>
 #include <com/sun/star/chart/TimeIncrement.hpp>
 #include <com/sun/star/chart/TimeInterval.hpp>
 #include <com/sun/star/chart/TimeUnit.hpp>
@@ -3407,6 +3408,17 @@ void SchXMLExportHelper_Impl::exportDataPoints(
                                                   mxExpPropMapper);
                 }
 
+                if (nCurrentODFVersion & SvtSaveOptions::ODFSVER_EXTENDED)
+                {
+                    sal_Int32 nPlacement = 0;
+                    xPropSet->getPropertyValue("LabelPlacement") >>= nPlacement;
+                    if (nPlacement == chart::DataLabelPlacement::CUSTOM)
+                    {
+                        xPropSet->setPropertyValue("LabelPlacement",
+                                                  uno::Any(chart::DataLabelPlacement::OUTSIDE));
+                    }
+                }
+
                 aPropertyStates = mxExpPropMapper->Filter(xPropSet);
                 if (!aPropertyStates.empty() || !aDataLabelPropertyStates.empty())
                 {


More information about the Libreoffice-commits mailing list