chart2/source/view/charttypes/AreaChart.cxx |    5 ++++-
 sw/qa/extras/layout/data/tdf130380.docx     |binary
 sw/qa/extras/layout/layout.cxx              |   23 +++++++++++++++++++++++
 3 files changed, 27 insertions(+), 1 deletion(-)

New commits:
commit a979047eefec607b311773c7e2a71bb3ee2c6362
Author:     Tünde Tóth <tund...@gmail.com>
AuthorDate: Mon Feb 3 15:51:52 2020 +0100
Commit:     László Németh <nem...@numbertext.org>
CommitDate: Fri Feb 7 18:36:18 2020 +0100

    tdf#130380 Chart: Fix area chart data labels position
    
    Regression from commit: f8966bb398cf0623be841c618b123866801a063c
    (tdf#130031 Chart OOXML import: fix area chart data label position)
    
    Change-Id: Iafcbacb0ecf6f8a175adbf0782ee3e3a1185a726
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87881
    Tested-by: Jenkins
    Reviewed-by: László Németh <nem...@numbertext.org>
    Tested-by: László Németh <nem...@numbertext.org>

diff --git a/chart2/source/view/charttypes/AreaChart.cxx 
b/chart2/source/view/charttypes/AreaChart.cxx
index 158d3f21bca6..f6101c15917c 100644
--- a/chart2/source/view/charttypes/AreaChart.cxx
+++ b/chart2/source/view/charttypes/AreaChart.cxx
@@ -903,7 +903,10 @@ void AreaChart::createShapes()
 
                             if (m_bArea && nLabelPlacement == 
css::chart::DataLabelPlacement::CENTER)
                             {
-                                fLogicY -= (fLogicY - fPreviousYValue) / 2.0;
+                                if (fPreviousYValue)
+                                    fLogicY -= (fLogicY - fPreviousYValue) / 
2.0;
+                                else
+                                    fLogicY = (fLogicY + 
rPosHelper.getLogicMinY()) / 2.0;
                                 aScenePosition = 
rPosHelper.transformLogicToScene(fLogicX, fLogicY, fLogicZ, false);
                             }
 
diff --git a/sw/qa/extras/layout/data/tdf130380.docx 
b/sw/qa/extras/layout/data/tdf130380.docx
new file mode 100644
index 000000000000..b76c5efd1405
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf130380.docx differ
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index bd1e609fdce1..ae3548737210 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -2550,6 +2550,29 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf130242)
     CPPUNIT_ASSERT_DOUBLES_EQUAL(3018, nY, 50);
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf130380)
+{
+    SwDoc* pDoc = createDoc("tdf130380.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;
+    xmlDocPtr pXmlDoc = dumpAndParse(dumper, *xMetaFile);
+    CPPUNIT_ASSERT(pXmlDoc);
+    sal_Int32 nY = getXPath(pXmlDoc,
+                            
"/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/push[1]/polypolygon/"
+                            "polygon/point[1]",
+                            "y")
+                       .toInt32();
+    // Without the accompanying fix in place, this test would have failed with:
+    // - Expected: 6727
+    // - Actual  : 4411
+    // - Delta   : 50
+    // i.e. the area chart shrank.
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(6727, nY, 50);
+}
+
 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf116925)
 {
     SwDoc* pDoc = createDoc("tdf116925.docx");
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to