chart2/source/tools/ChartTypeHelper.cxx | 20 ++++++++++++++++++-- sw/qa/extras/layout/data/tdf130242.odt |binary sw/qa/extras/layout/layout.cxx | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 2 deletions(-)
New commits: commit be936c5896045794b251a63ab1175ac06a36eee5 Author: Tünde Tóth <tund...@gmail.com> AuthorDate: Thu Jan 30 14:22:51 2020 +0100 Commit: László Németh <nem...@numbertext.org> CommitDate: Tue Feb 4 11:22:30 2020 +0100 tdf#130242 chart: default center label placement in stacked area charts instead of top label placement, like MSO does (or LO has already done in stacked bar charts) for readability. Change-Id: Icac6e8703d0d04122f9cc28254b053ee9fd434ec Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87846 Reviewed-by: László Németh <nem...@numbertext.org> Tested-by: László Németh <nem...@numbertext.org> diff --git a/chart2/source/tools/ChartTypeHelper.cxx b/chart2/source/tools/ChartTypeHelper.cxx index b7b3e889e1a1..b54e410bcb73 100644 --- a/chart2/source/tools/ChartTypeHelper.cxx +++ b/chart2/source/tools/ChartTypeHelper.cxx @@ -314,10 +314,26 @@ uno::Sequence < sal_Int32 > ChartTypeHelper::getSupportedLabelPlacements( const } else if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_AREA) ) { + bool bStacked = false; + { + uno::Reference<beans::XPropertySet> xSeriesProp(xSeries, uno::UNO_QUERY); + chart2::StackingDirection eStacking = chart2::StackingDirection_NO_STACKING; + xSeriesProp->getPropertyValue("StackingDirection") >>= eStacking; + bStacked = (eStacking == chart2::StackingDirection_Y_STACKING); + } + aRet.realloc(2); sal_Int32* pSeq = aRet.getArray(); - *pSeq++ = css::chart::DataLabelPlacement::TOP; - *pSeq++ = css::chart::DataLabelPlacement::CENTER; + if (bStacked) + { + *pSeq++ = css::chart::DataLabelPlacement::CENTER; + *pSeq++ = css::chart::DataLabelPlacement::TOP; + } + else + { + *pSeq++ = css::chart::DataLabelPlacement::TOP; + *pSeq++ = css::chart::DataLabelPlacement::CENTER; + } } else if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_NET) ) { diff --git a/sw/qa/extras/layout/data/tdf130242.odt b/sw/qa/extras/layout/data/tdf130242.odt new file mode 100644 index 000000000000..3e97bd3e5fe1 Binary files /dev/null and b/sw/qa/extras/layout/data/tdf130242.odt differ diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx index b6bdd958cbed..c1c43399c9f4 100644 --- a/sw/qa/extras/layout/layout.cxx +++ b/sw/qa/extras/layout/layout.cxx @@ -2515,9 +2515,41 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf130031) xmlDocPtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); CPPUNIT_ASSERT(pXmlDoc); sal_Int32 nY = getXPath(pXmlDoc, "//textarray[11]", "y").toInt32(); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 4339 + // - Actual : 2182 + // - Delta : 50 + // i.e. the data label appeared above the data point. CPPUNIT_ASSERT_DOUBLES_EQUAL(4339, nY, 50); } +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf130242) +{ + SwDoc* pDoc = createDoc("tdf130242.odt"); + 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, "//textarray[11]", "y").toInt32(); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 4958 + // - Actual : 3352 + // - Delta : 50 + // i.e. the data label appeared above the data point. + CPPUNIT_ASSERT_DOUBLES_EQUAL(4958, nY, 50); + + nY = getXPath(pXmlDoc, "//textarray[13]", "y").toInt32(); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 3018 + // - Actual : 2343 + // - Delta : 50 + // i.e. the data label appeared above the data point. + CPPUNIT_ASSERT_DOUBLES_EQUAL(3018, 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