chart2/source/view/axes/VCartesianAxis.cxx | 7 ++++++ sw/qa/extras/layout/data/tdf159443.odt |binary sw/qa/extras/layout/layout3.cxx | 30 +++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+)
New commits: commit f856733ed18353b8ac7d7e19348cf9b1107cc14b Author: Balazs Varga <balazs.varga.ext...@allotropia.de> AuthorDate: Wed Mar 6 14:54:22 2024 +0100 Commit: Balazs Varga <balazs.varga.ext...@allotropia.de> CommitDate: Fri Mar 8 09:40:14 2024 +0100 tdf#159443 - chart view: fix Data table is not rendered below chart If we have 1 dataseries we will have no tickmarks, in that case the distance between two tickmarks is the width of the chart. Change-Id: Ifea11329f1dcb80e8e390c1408306d1df7d49ded Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164471 Tested-by: Jenkins Reviewed-by: Balazs Varga <balazs.varga.ext...@allotropia.de> diff --git a/chart2/source/view/axes/VCartesianAxis.cxx b/chart2/source/view/axes/VCartesianAxis.cxx index 8163058ad5e0..a0c4a329d76d 100644 --- a/chart2/source/view/axes/VCartesianAxis.cxx +++ b/chart2/source/view/axes/VCartesianAxis.cxx @@ -1687,6 +1687,13 @@ void VCartesianAxis::createDataTableShape(std::unique_ptr<TickFactory2D> const& nDistance *= 2; } + if (nDistance <= 0) + { + // we only have one data series so we have no TickMarks, therefor calculate and use the table size + auto rDelta = aEnd - aStart; + nDistance = basegfx::fround(rDelta.getX()); + } + if (nDistance > 0) { m_pDataTableView->createShapes(aStart, aEnd, nDistance); diff --git a/sw/qa/extras/layout/data/tdf159443.odt b/sw/qa/extras/layout/data/tdf159443.odt new file mode 100644 index 000000000000..8ec733aedb06 Binary files /dev/null and b/sw/qa/extras/layout/data/tdf159443.odt differ diff --git a/sw/qa/extras/layout/layout3.cxx b/sw/qa/extras/layout/layout3.cxx index de11ac7d788d..f96b786cc093 100644 --- a/sw/qa/extras/layout/layout3.cxx +++ b/sw/qa/extras/layout/layout3.cxx @@ -2389,6 +2389,36 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testPageBreakInHiddenSection) assertXPath(pXmlDoc, "//page[4]/body/section/infos/bounds"_ostr, "height"_ostr, u"0"_ustr); } +CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf159443) +{ + // Given a document with chart, which have a datatable + createSwDoc("tdf159443.odt"); + SwDoc* pDoc = getSwDoc(); + 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); + //// Without the fix, this would fail: + //// - Expected: DataSeries1 + //// - Actual : 1.25 + //// - In <>, XPath contents of child does not match + assertXPathContent( + pXmlDoc, + "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/push[1]/push[1]/push[47]/textarray/text"_ostr, + "DataSeries1"); + assertXPathContent( + pXmlDoc, + "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/push[1]/push[1]/push[49]/textarray/text"_ostr, + "Category1"); + assertXPathContent( + pXmlDoc, + "/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/push[1]/push[1]/push[51]/textarray/text"_ostr, + "4.3"); +} + } // end of anonymous namespace CPPUNIT_PLUGIN_IMPLEMENT();