From 7517ec45b928fff56ba4526d5877a9ed71d500a7 Mon Sep 17 00:00:00 2001 From: Tünde Tóth Date: Tue, 5 Jan 2021 09:19:40 +0100 Subject: tdf138773 Chart OOXML import: set text overlap to false MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit of category axis label, if the rotation is undefined in xml, to avoid e.g. missing rotation of them. Regression from commit: 21620f9d2f50e66dffc45a5afb539edb8d54434c (tdf#138194 Chart OOXML import: set text break to true) Change-Id: I5b03614eca547a206afc0d8118e3f6c055ed5348 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108792 Tested-by: László Németh Reviewed-by: László Németh (cherry picked from commit 2752fd1b665694a4db3a4e34c7fdc8780a86492e) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108992 Tested-by: Jenkins Reviewed-by: Xisco Fauli --- oox/source/drawingml/chart/axisconverter.cxx | 7 ++++++- sw/qa/extras/layout/data/tdf138773.docx | Bin 0 -> 26209 bytes sw/qa/extras/layout/layout2.cxx | 18 ++++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 sw/qa/extras/layout/data/tdf138773.docx diff --git a/oox/source/drawingml/chart/axisconverter.cxx b/oox/source/drawingml/chart/axisconverter.cxx index 8f062d001eeb..1a8e23024612 100644 --- a/oox/source/drawingml/chart/axisconverter.cxx +++ b/oox/source/drawingml/chart/axisconverter.cxx @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -270,7 +271,11 @@ void AxisConverter::convertFromModel(const Reference& rxCoord } else { - aAxisProp.setProperty(PROP_TextOverlap, true); + // do not overlap text when the rotation is undefined in xml + bool bTextOverlap + = mrModel.mxTextProp.is() + && mrModel.mxTextProp->getTextProperties().moRotation.has(); + aAxisProp.setProperty(PROP_TextOverlap, bTextOverlap); /* do not break text into several lines unless the rotation is 0 degree, or the rotation is 90 degree and the inner size of the chart is not fixed, or the rotation is 270 degree and the inner size of the chart is not fixed */ diff --git a/sw/qa/extras/layout/data/tdf138773.docx b/sw/qa/extras/layout/data/tdf138773.docx new file mode 100644 index 000000000000..656c596bc458 Binary files /dev/null and b/sw/qa/extras/layout/data/tdf138773.docx differ diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx index 14492f240e4e..46ce68a04572 100644 --- a/sw/qa/extras/layout/layout2.cxx +++ b/sw/qa/extras/layout/layout2.cxx @@ -735,6 +735,24 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf138194) assertXPath(pXmlDoc, "//textarray", 8); } +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf138773) +{ + SwDoc* pDoc = createDoc("tdf138773.docx"); + SwDocShell* pShell = pDoc->GetDocShell(); + + // Dump the rendering of the first page as an XML file. + std::shared_ptr xMetaFile = pShell->GetPreviewMetaFile(); + MetafileXmlDump dumper; + xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); + CPPUNIT_ASSERT(pXmlDoc); + + const sal_Int32 nFirstLabelLines + = getXPathContent(pXmlDoc, "count(//text[contains(text(),\"2000-01\")])").toInt32(); + + // This failed, if the first X axis label broke to multiple lines. + CPPUNIT_ASSERT_EQUAL(static_cast(1), nFirstLabelLines); +} + CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf124796) { SwDoc* pDoc = createDoc("tdf124796.odt"); -- cgit