diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-10-18 14:43:23 +0200 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2018-11-13 15:54:41 +0100 |
commit | 4f727bb76b61648511112adb59439a99b5e27629 (patch) | |
tree | e1ea0f03bb55562896ead4b055a78791e78e5ecb /sd | |
parent | 8d2abb388b0a2423c9b7e1f52373e1b06dd9786f (diff) |
Related: tdf#117761 oox smartart: backport fixes related to list types
This is a combination of 7 commits.
This is the 1st commit:
oox: ignore SmartArt "fallback" with empty shape list
This way at least something shows up in the import result. Far from
perfect, though.
(cherry picked from commit a7e86beb00e9635ea4556ef4f8f8e24ff9965391)
Conflicts:
sd/qa/unit/import-tests-smartart.cxx
This is the commit #2:
oox smartart: fix width of shapes with agl=lin, linDir=fromT
Smaller width only makes sense in the fromL/fromR cases, I think.
(cherry picked from commit b61d2784271bf8b042642c378f50e8b446682548)
This is the commit #3:
oox smartart: work towards accessing parent constraints
The "Vertical Box List" preset in PowerPoint contains two linear
layouts, the inner one nested in the outer one. All the constraints are
stated on the parent layout. This commit doesn't actually read those
constraints yet, but adds infrastructure to look up parents of layout
nodes and also to get the constraints of a layout node.
No functional changes intended.
(cherry picked from commit 923061d17d4b5b8bf0d4a8111b270c99a7c649a9)
This is the commit #4:
oox smartart, linear layout: take width from constraints
Finally the "parent text" of the test document now has correct width.
(cherry picked from commit b083b0808121d19f398a9f6ead195ae7e14ed047)
This is the commit #5:
oox smartart, linear layout: take horizontal position from constraints
Both horizontal size and position looks sane now.
(cherry picked from commit 397b64afc62a5632a6648598558a4d2c3ca0d283)
This is the commit #6:
oox smartart, vertical bracket list: fix node counter condition
The visible effect of this was that the 2nd level text nodes were
missing from the layout result.
The cause is that when it comes to counting nodes of a condition, we
assumed that the current layout node is a presentation of a model node,
but this is not necessarily true.
Fix the problem doing a "first presentation child of", then a "presentation
of" navigation in that case, which leads us to the correct model node,
so counting its children works.
(An alternative way of getting non-zero children would be a
"presentation parent of" navigation, followed by a "presentation of"
navigation, but that would lead us to the document root, so we would
count the number of 1st level elements, not the correct 2nd level
elements.)
(cherry picked from commit e49c42d17f50c8b0cac9db08dedc375dd5aa8a98)
This is the commit #7:
oox smartart, table list: fix too large width of children
It's possible all children request 100% of space, need to scale down in
that case. This means that children other than the first one is now
readable in the layout result.
(cherry picked from commit c753a896aa32577e780d531032a08a699b960229)
Change-Id: Iae5a073d458598e7b5059ebdf435d50ce7c7df80
Reviewed-on: https://gerrit.libreoffice.org/63115
Tested-by: Jenkins
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/qa/unit/data/pptx/smartart-vertial-box-list.pptx | bin | 0 -> 43018 bytes | |||
-rw-r--r-- | sd/qa/unit/data/pptx/table-list.pptx | bin | 0 -> 52249 bytes | |||
-rw-r--r-- | sd/qa/unit/data/pptx/vertical-bracket-list.pptx | bin | 0 -> 42124 bytes | |||
-rw-r--r-- | sd/qa/unit/import-tests-smartart.cxx | 91 |
4 files changed, 91 insertions, 0 deletions
diff --git a/sd/qa/unit/data/pptx/smartart-vertial-box-list.pptx b/sd/qa/unit/data/pptx/smartart-vertial-box-list.pptx Binary files differnew file mode 100644 index 000000000000..b67d99e700c3 --- /dev/null +++ b/sd/qa/unit/data/pptx/smartart-vertial-box-list.pptx diff --git a/sd/qa/unit/data/pptx/table-list.pptx b/sd/qa/unit/data/pptx/table-list.pptx Binary files differnew file mode 100644 index 000000000000..bc5fe7418e02 --- /dev/null +++ b/sd/qa/unit/data/pptx/table-list.pptx diff --git a/sd/qa/unit/data/pptx/vertical-bracket-list.pptx b/sd/qa/unit/data/pptx/vertical-bracket-list.pptx Binary files differnew file mode 100644 index 000000000000..bef9d7481dfc --- /dev/null +++ b/sd/qa/unit/data/pptx/vertical-bracket-list.pptx diff --git a/sd/qa/unit/import-tests-smartart.cxx b/sd/qa/unit/import-tests-smartart.cxx index e86dab7f4745..d561f138f16f 100644 --- a/sd/qa/unit/import-tests-smartart.cxx +++ b/sd/qa/unit/import-tests-smartart.cxx @@ -26,6 +26,9 @@ public: void testDir(); void testMaxDepth(); void testRotation(); + void testVertialBoxList(); + void testVertialBracketList(); + void testTableList(); CPPUNIT_TEST_SUITE(SdImportTestSmartArt); @@ -36,6 +39,9 @@ public: CPPUNIT_TEST(testDir); CPPUNIT_TEST(testMaxDepth); CPPUNIT_TEST(testRotation); + CPPUNIT_TEST(testVertialBoxList); + CPPUNIT_TEST(testVertialBracketList); + CPPUNIT_TEST(testTableList); CPPUNIT_TEST_SUITE_END(); }; @@ -185,6 +191,91 @@ void SdImportTestSmartArt::testRotation() xDocShRef->DoClose(); } +void SdImportTestSmartArt::testVertialBoxList() +{ + sd::DrawDocShellRef xDocShRef = loadURL( + m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-vertial-box-list.pptx"), PPTX); + uno::Reference<drawing::XShapes> xShapeGroup(getShapeFromPage(0, 0, xDocShRef), + uno::UNO_QUERY_THROW); + // Without the accompanying fix in place, this test would have failed with + // 'actual: 0'. + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), xShapeGroup->getCount()); + + uno::Reference<drawing::XShapes> xFirstChild(xShapeGroup->getByIndex(0), uno::UNO_QUERY); + CPPUNIT_ASSERT(xFirstChild.is()); + uno::Reference<drawing::XShape> xParentText(xFirstChild->getByIndex(1), uno::UNO_QUERY); + CPPUNIT_ASSERT(xParentText.is()); + // Without the accompanying fix in place, this test would have failed with + // 'actual: 7361', i.e. the width was not the 70% of the parent as the + // constraint wanted. + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(11852), xParentText->getSize().Width); + + uno::Reference<drawing::XShape> xChildText(xShapeGroup->getByIndex(1), uno::UNO_QUERY); + CPPUNIT_ASSERT(xChildText.is()); + // Without the accompanying fix in place, this test would have failed with + // 'actual: 7361' (and with the fix: 'actual: 16932', i.e. the width of the + // parent). + CPPUNIT_ASSERT_GREATER(static_cast<sal_Int32>(10000), xChildText->getSize().Width); + + // Assert that the right edge of the parent text is closer to the slide + // boundary than the right edge of the parent text. + // Without the accompanying fix in place, this test would have failed with + // 'Expected greater than: 25656, Actual : 21165'. + CPPUNIT_ASSERT_GREATER(xParentText->getPosition().X + xParentText->getSize().Width, + xChildText->getPosition().X + xChildText->getSize().Width); + + xDocShRef->DoClose(); +} + +void SdImportTestSmartArt::testVertialBracketList() +{ + sd::DrawDocShellRef xDocShRef = loadURL( + m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/vertical-bracket-list.pptx"), PPTX); + uno::Reference<drawing::XShapes> xShapeGroup(getShapeFromPage(0, 0, xDocShRef), + uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), xShapeGroup->getCount()); + + uno::Reference<drawing::XShapes> xFirstChild(xShapeGroup->getByIndex(0), uno::UNO_QUERY); + CPPUNIT_ASSERT(xFirstChild.is()); + // Without the accompanying fix in place, this test would have failed with + // 'actual: 2', i.e. one child shape (with its "A" text) was missing. + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(3), xFirstChild->getCount()); + + xDocShRef->DoClose(); +} + +void SdImportTestSmartArt::testTableList() +{ + sd::DrawDocShellRef xDocShRef = loadURL( + m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/table-list.pptx"), PPTX); + uno::Reference<drawing::XShapes> xShapeGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY); + CPPUNIT_ASSERT(xShapeGroup.is()); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(3), xShapeGroup->getCount()); + + uno::Reference<text::XText> xParentText(xShapeGroup->getByIndex(0), uno::UNO_QUERY); + CPPUNIT_ASSERT(xParentText.is()); + CPPUNIT_ASSERT_EQUAL(OUString("Parent"), xParentText->getString()); + uno::Reference<drawing::XShape> xParent(xParentText, uno::UNO_QUERY); + CPPUNIT_ASSERT(xParent.is()); + int nParentRight = xParent->getPosition().X + xParent->getSize().Width; + + uno::Reference<drawing::XShapes> xChildren(xShapeGroup->getByIndex(1), uno::UNO_QUERY); + CPPUNIT_ASSERT(xChildren.is()); + uno::Reference<text::XText> xChild2Text(xChildren->getByIndex(1), uno::UNO_QUERY); + CPPUNIT_ASSERT(xChild2Text.is()); + CPPUNIT_ASSERT_EQUAL(OUString("Child 2"), xChild2Text->getString()); + uno::Reference<drawing::XShape> xChild2(xChild2Text, uno::UNO_QUERY); + CPPUNIT_ASSERT(xChild2.is()); + int nChild2Right = xChild2->getPosition().X + xChild2->getSize().Width; + + // Without the accompanying fix in place, this test would have failed with + // 'Expected less than: 100, Actual : 22014', i.e. the second child was + // shifted to the right too much. + CPPUNIT_ASSERT_LESS(100, abs(nChild2Right - nParentRight)); + + xDocShRef->DoClose(); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTestSmartArt); CPPUNIT_PLUGIN_IMPLEMENT(); |