[Libreoffice-commits] core.git: Branch 'distro/nisz/libreoffice-7-0' - chart2/source sw/qa

Tünde Tóth (via logerrit) logerrit at kemper.freedesktop.org
Wed Jan 6 10:49:51 UTC 2021


 chart2/source/view/charttypes/VSeriesPlotter.cxx |    8 +++++++-
 sw/qa/extras/layout/data/tdf134866.docx          |binary
 sw/qa/extras/layout/layout.cxx                   |   16 ++++++++++++++++
 3 files changed, 23 insertions(+), 1 deletion(-)

New commits:
commit 9497f402dbbb642578a23ffc372d59e440edff7c
Author:     Tünde Tóth <tundeth at gmail.com>
AuthorDate: Fri Jul 24 10:06:40 2020 +0200
Commit:     Gabor Kelemen <kelemen.gabor2 at nisz.hu>
CommitDate: Wed Jan 6 11:49:15 2021 +0100

    tdf#134866 Chart OOXML import: fix percentage in custom pie chart label
    
    Custom pie chart label showed incorrect percentage value.
    
    Follow-up of commit 8c1dc30cc9fc96ef3d3ab0c4445959473248ae4d
    (tdf#125444 Percentage as custom chart label).
    
    Change-Id: I2fe9cbca876da26a7c3a371c1e711b9e1fc33b1e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99353
    Tested-by: László Németh <nemeth at numbertext.org>
    Reviewed-by: László Németh <nemeth at numbertext.org>
    (cherry picked from commit c0fac974cefffb16e811259fbc66148712533190)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108856
    Tested-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
    Reviewed-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>

diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx
index bbc1788ec148..28630c34b2e0 100644
--- a/chart2/source/view/charttypes/VSeriesPlotter.cxx
+++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx
@@ -533,7 +533,13 @@ uno::Reference< drawing::XShape > VSeriesPlotter::createDataLabel( const uno::Re
                     }
                     case DataPointCustomLabelFieldType_PERCENTAGE:
                     {
-                        aTextList[i] = getLabelTextForValue( rDataSeries, nPointIndex, fValue, true );
+                        if(fSumValue == 0.0)
+                           fSumValue = 1.0;
+                        fValue /= fSumValue;
+                        if(fValue < 0)
+                           fValue *= -1.0;
+
+                        aTextList[i] = getLabelTextForValue(rDataSeries, nPointIndex, fValue, true);
                         break;
                     }
                     case DataPointCustomLabelFieldType_CELLREF:
diff --git a/sw/qa/extras/layout/data/tdf134866.docx b/sw/qa/extras/layout/data/tdf134866.docx
new file mode 100644
index 000000000000..3358b527133c
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf134866.docx differ
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index 63b950abf0f7..f3854db62f0b 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -2830,6 +2830,22 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf129173)
         pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/textarray[22]/text", "56");
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf134866)
+{
+    SwDoc* pDoc = createDoc("tdf134866.docx");
+    SwDocShell* pShell = pDoc->GetDocShell();
+
+    // Dump the rendering of the first page as an XML file.
+    std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile();
+    MetafileXmlDump dumper;
+    xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile);
+    CPPUNIT_ASSERT(pXmlDoc);
+
+    // Check the data label of pie chart.
+    assertXPathContent(
+        pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/textarray[2]/text", "100%");
+}
+
 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf130031)
 {
     SwDoc* pDoc = createDoc("tdf130031.docx");


More information about the Libreoffice-commits mailing list