summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2021-01-12 10:13:14 +0100
committerXisco Fauli <xiscofauli@libreoffice.org>2021-01-13 08:53:38 +0100
commit21755f2ab58cc053f9555c3d77241689c225d233 (patch)
treee8d6c85597df5e61986946d4641dab4b11af54ef /sd
parentcd4b646040b56c1b75dd9913c6d1f5b2751f155f (diff)
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/+/109120 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sd')
-rw-r--r--sd/qa/unit/data/pptx/smartart-pyramid-1child.pptxbin0 -> 40059 bytes
-rw-r--r--sd/qa/unit/import-tests-smartart.cxx15
2 files changed, 15 insertions, 0 deletions
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
--- /dev/null
+++ b/sd/qa/unit/data/pptx/smartart-pyramid-1child.pptx
Binary files differ
diff --git a/sd/qa/unit/import-tests-smartart.cxx b/sd/qa/unit/import-tests-smartart.cxx
index 4fe544a86000..b243a2bc395f 100644
--- a/sd/qa/unit/import-tests-smartart.cxx
+++ b/sd/qa/unit/import-tests-smartart.cxx
@@ -75,6 +75,7 @@ public:
void testRotation();
void testTextAutoRotation();
void testPyramid();
+ void testPyramidOneChild();
void testChevron();
void testCycle();
void testvenndiagram();
@@ -125,6 +126,7 @@ public:
CPPUNIT_TEST(testRotation);
CPPUNIT_TEST(testTextAutoRotation);
CPPUNIT_TEST(testPyramid);
+ CPPUNIT_TEST(testPyramidOneChild);
CPPUNIT_TEST(testChevron);
CPPUNIT_TEST(testCycle);
CPPUNIT_TEST(testHierarchy);
@@ -429,6 +431,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 = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/smartart-chevron.pptx"), PPTX);