From 8753e4e3ac000d325aedc9bb004c271f2e18e8c2 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 19 Oct 2020 21:07:10 +0200 Subject: tdf#137417 oox smartart: avoid considering rules in vertical linear layouts Regression from commit 0024c48b4822062995effed7db4f1281196384bb (oox smartart: consider rules when scaling in linear layout, 2020-07-31), the problem is that I only tested horizontal layouts and this is not working for vertical layouts. Just disable the vertical case for now, to avoid unwanted side effects. (cherry picked from commit c719db99166a7b4770855a9599ec65c70cd256c5) Change-Id: I31a894157996a2371b8d0ec482ee91dc4d5b053e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104550 Tested-by: Jenkins Reviewed-by: Xisco Fauli --- .../drawingml/diagram/diagramlayoutatoms.cxx | 6 ++++++ .../unit/data/pptx/smartart-linear-rule-vert.pptx | Bin 0 -> 73085 bytes sd/qa/unit/import-tests-smartart.cxx | 22 +++++++++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 sd/qa/unit/data/pptx/smartart-linear-rule-vert.pptx diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx index 5de660a3b6e4..7f926cc9a5e8 100644 --- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx +++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx @@ -1045,6 +1045,12 @@ void AlgAtom::layoutShape(const ShapePtr& rShape, const std::vector& aChildrenToShrink.insert(rRule.msForName); } + if (nDir == XML_fromT || nDir == XML_fromB) + { + // TODO consider rules for vertical linear layout as well. + aChildrenToShrink.clear(); + } + if (!aChildrenToShrink.empty()) { // Have scaling info from rules: then only count scaled children. diff --git a/sd/qa/unit/data/pptx/smartart-linear-rule-vert.pptx b/sd/qa/unit/data/pptx/smartart-linear-rule-vert.pptx new file mode 100644 index 000000000000..cf1a23a6151e Binary files /dev/null and b/sd/qa/unit/data/pptx/smartart-linear-rule-vert.pptx differ diff --git a/sd/qa/unit/import-tests-smartart.cxx b/sd/qa/unit/import-tests-smartart.cxx index cd59f646a5e4..4fe544a86000 100644 --- a/sd/qa/unit/import-tests-smartart.cxx +++ b/sd/qa/unit/import-tests-smartart.cxx @@ -110,6 +110,7 @@ public: void testTdf131553(); void testFillColorList(); void testLinearRule(); + void testLinearRuleVert(); void testAutofitSync(); void testSnakeRows(); @@ -159,6 +160,7 @@ public: CPPUNIT_TEST(testTdf131553); CPPUNIT_TEST(testFillColorList); CPPUNIT_TEST(testLinearRule); + CPPUNIT_TEST(testLinearRuleVert); CPPUNIT_TEST(testAutofitSync); CPPUNIT_TEST(testSnakeRows); @@ -1552,6 +1554,26 @@ void SdImportTestSmartArt::testLinearRule() xDocShRef->DoClose(); } +void SdImportTestSmartArt::testLinearRuleVert() +{ + sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-linear-rule-vert.pptx"), PPTX); + + uno::Reference xGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY); + // Get the P1 shape. + uno::Reference xShape = getChildShape(getChildShape(xGroup, 1), 1); + uno::Reference xShapeText(xShape, uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("P1"), xShapeText->getString()); + + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 2020 + // - Actual : 10308 + // i.e. the first item on the vertical linear layout used ~all space, the other items were not + // visible. + CPPUNIT_ASSERT_EQUAL(static_cast(2020), xShape->getSize().Height); + + xDocShRef->DoClose(); +} + void SdImportTestSmartArt::testAutofitSync() { sd::DrawDocShellRef xDocShRef = loadURL( -- cgit