[Libreoffice-commits] core.git: Branch 'libreoffice-7-1' - oox/source sd/qa
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Thu Jan 14 07:37:16 UTC 2021
oox/source/drawingml/diagram/diagramlayoutatoms.cxx | 5 ++++-
sd/qa/unit/data/pptx/smartart-pyramid-1child.pptx |binary
sd/qa/unit/import-tests-smartart.cxx | 15 +++++++++++++++
3 files changed, 19 insertions(+), 1 deletion(-)
New commits:
commit ecee82e2368002fc3cabc00ec89ec7d757c48c64
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Tue Jan 12 10:13:14 2021 +0100
Commit: Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Thu Jan 14 08:36:42 2021 +0100
oox smartart: fix crash in pyra algorithm with a single child shape
Regression from commit 14a56533ff2c9c859d22cd3039ada75b99e94bc0
(SmartArt Pyramid: Now lays out shapes, 2018-07-10), the added pyramid
algorithm by first centering the topmost children, then decrementing the
horizontal postion of each additional shape, with the end goal of having
0 horizontal position of the last children.
This means that simply avoiding the division in the 1-child case leads
to correct results, because in this case the only child is also the last
child at the sane time.
(cherry picked from commit f2e04fe98e313cffa3f98d55eae641415142a431)
Change-Id: Ifd0027e9616b0909dbfde43e1555427b50de4dad
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109183
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli at libreoffice.org>
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index 5071a7bd52d4..c76a3d0bd9ab 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -1617,7 +1617,10 @@ void AlgAtom::layoutShape(const ShapePtr& rShape, const std::vector<Constraint>&
for (auto & aCurrShape : rShape->getChildren())
{
aCurrShape->setPosition(aCurrPos);
- aCurrPos.X -= aChildSize.Height/(nCount-1);
+ if (nCount > 1)
+ {
+ aCurrPos.X -= aChildSize.Height / (nCount - 1);
+ }
aChildSize.Width += aChildSize.Height;
aCurrShape->setSize(aChildSize);
aCurrShape->setChildSize(aChildSize);
diff --git a/sd/qa/unit/data/pptx/smartart-pyramid-1child.pptx b/sd/qa/unit/data/pptx/smartart-pyramid-1child.pptx
new file mode 100644
index 000000000000..42e43c54bbc4
Binary files /dev/null and b/sd/qa/unit/data/pptx/smartart-pyramid-1child.pptx differ
diff --git a/sd/qa/unit/import-tests-smartart.cxx b/sd/qa/unit/import-tests-smartart.cxx
index 2a3dcda08983..36007bc7c6e5 100644
--- a/sd/qa/unit/import-tests-smartart.cxx
+++ b/sd/qa/unit/import-tests-smartart.cxx
@@ -76,6 +76,7 @@ public:
void testRotation();
void testTextAutoRotation();
void testPyramid();
+ void testPyramidOneChild();
void testChevron();
void testCycle();
void testvenndiagram();
@@ -127,6 +128,7 @@ public:
CPPUNIT_TEST(testRotation);
CPPUNIT_TEST(testTextAutoRotation);
CPPUNIT_TEST(testPyramid);
+ CPPUNIT_TEST(testPyramidOneChild);
CPPUNIT_TEST(testChevron);
CPPUNIT_TEST(testCycle);
CPPUNIT_TEST(testHierarchy);
@@ -451,6 +453,19 @@ void SdImportTestSmartArt::testPyramid()
//FIXME : so far this only introduce the test document, but the actual importer was not fixed yet.
}
+void SdImportTestSmartArt::testPyramidOneChild()
+{
+ // Load a document with a pyra algorithm in it.
+ // Without the accompanying fix in place, this test would have crashed.
+ sd::DrawDocShellRef xDocShRef = loadURL(
+ m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/smartart-pyramid-1child.pptx"), PPTX);
+ uno::Reference<drawing::XShape> xGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xText(getChildShape(getChildShape(xGroup, 1), 1),
+ uno::UNO_QUERY);
+ // Verify that the text of the only child is imported correctly.
+ CPPUNIT_ASSERT_EQUAL(OUString("A"), xText->getString());
+}
+
void SdImportTestSmartArt::testChevron()
{
sd::DrawDocShellRef xDocShRef
More information about the Libreoffice-commits
mailing list