summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2019-02-07 16:26:31 +0100
committerAndras Timar <andras.timar@collabora.com>2019-02-21 22:32:23 +0100
commitabab6e096839838e60222c635cf51629d7ce48d5 (patch)
treef05cc0f193b3f0262edc29cfdeb90f913dc1bb93 /sd
parent6676952d319e032a631bfe9d8ce23ebcb4c92f5b (diff)
Related: tdf#117761 oox smartart: backport fixes related to cycle matrix
This is a combination of 6 commits. This is the 1st commit: oox smartart, cycle matrix: fix counting presentation children The markup is: <dgm:if name="Name6" axis="ch ch" ptType="node node" st="1 1" cnt="1 0" func="cnt" op="gte" val="1"> Where PowerPoint evaluated the condition to true, but Impress evaluated to false. This means that the undocumented relation between the child lists is "OR" (not "AND"). Also, our code assumed that "node" has to be a data node (not presentation node), but it seems the only way this condition can be true if presentation children is also counted. (The presentation node in question is not a presentation of anything.) (cherry picked from commit e3c6f249c10f7f1bcc528e643f5723288c514b29) This is the commit #2: oox smartart, cycle matrix: handle left/bottom constraint in composite algo The bugdoc has 3 shapes in the "outer" circle which have a position where either x or y is not 0. But these are defined using constraints talking about the right or bottom edge of the shape. Map that to top/left, given that we already know the shape size. (cherry picked from commit b9b4e9223b6c0d6e0b48b694c9aabbe54a250660) This is the commit #3: oox smartart, cycle matrix: fix too large height in composite algo The user-level problem was that the height of the entire smartart was too large. The reason for this was that: - composite algorithm gets the constraint height should be 77% of width, this means 6096000 -> 4693920 EMUs - at the same time the parent container is already smaller, 4064000 EMUs - a few lines later we already limit the max height with std::min(), but in the meantime an incorrect y position is calculated, exactly due to the lack of early limited height Solve the problem by making sure composite algorithm never works with a height (even when using it to calculate vertical center) that exceeds the height of the parent. (cherry picked from commit 5b2e38e0cfc7006d6982f741cf158a8a98dc8630) This is the commit #4: oox smartart, cycle matrix: handle aspect ratio in composite algo This way the 4 quadrant shapes in the center of the SmartArt form a circle, as width is shrinking. It's not height growing, as OOXML spec clearly says "ar" always just shrinks one axis. (>1 and <1 "ar" is to be handled when they are seen in action in an actual document.) (cherry picked from commit 34383064ac061497b0c46c449313877c6b6a2087) This is the commit #5: oox smartart, cycle matrix: handle destination order in connections It is possible to have connections from multiple data nodes to the same presentation node with a presOf type. We use to order these based on as they appear in the data XML, but we need to order them according to the destOrd attribute. Introduce an std::map for that, so get ordering automatically as we iterate. Turn the std::pair into a struct to make the code a bit more readable. (cherry picked from commit ecb733da58b74714eb66d2063a2835ce5c471870) Conflicts: oox/source/drawingml/diagram/diagramlayoutatoms.cxx This is the commit #6: oox smartart, cycle matrix: fix fill and line props of shape The topmost shape may not have 0 depth, but something larger. In that case at least it's safe to still use fill & line properties. The B1 quadrant of the test file now has the proper orange background, and B2's border is also properly orange. (cherry picked from commit 8193e697d286595aa62859011761adeb002244e3) Conflicts: oox/source/drawingml/diagram/diagramlayoutatoms.cxx Change-Id: Iccc5f6993693a0f1cf8f50d163003c24d3ad690e Reviewed-on: https://gerrit.libreoffice.org/68149 Tested-by: Jenkins Reviewed-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'sd')
-rw-r--r--sd/qa/unit/data/pptx/smartart-cycle-matrix.pptxbin0 -> 56986 bytes
-rw-r--r--sd/qa/unit/import-tests-smartart.cxx93
2 files changed, 93 insertions, 0 deletions
diff --git a/sd/qa/unit/data/pptx/smartart-cycle-matrix.pptx b/sd/qa/unit/data/pptx/smartart-cycle-matrix.pptx
new file mode 100644
index 000000000000..fb1cb7ea2c2e
--- /dev/null
+++ b/sd/qa/unit/data/pptx/smartart-cycle-matrix.pptx
Binary files differ
diff --git a/sd/qa/unit/import-tests-smartart.cxx b/sd/qa/unit/import-tests-smartart.cxx
index 9de4061a072b..29f998ce6f43 100644
--- a/sd/qa/unit/import-tests-smartart.cxx
+++ b/sd/qa/unit/import-tests-smartart.cxx
@@ -51,6 +51,7 @@ public:
void testAccentProcess();
void testContinuousBlockProcess();
void testOrgChart();
+ void testCycleMatrix();
CPPUNIT_TEST_SUITE(SdImportTestSmartArt);
@@ -67,6 +68,7 @@ public:
CPPUNIT_TEST(testAccentProcess);
CPPUNIT_TEST(testContinuousBlockProcess);
CPPUNIT_TEST(testOrgChart);
+ CPPUNIT_TEST(testCycleMatrix);
CPPUNIT_TEST_SUITE_END();
};
@@ -547,6 +549,97 @@ void SdImportTestSmartArt::testOrgChart()
xDocShRef->DoClose();
}
+void SdImportTestSmartArt::testCycleMatrix()
+{
+ sd::DrawDocShellRef xDocShRef = loadURL(
+ m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-cycle-matrix.pptx"), PPTX);
+ uno::Reference<drawing::XShape> xGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xGroup.is());
+
+ // Without the accompanying fix in place, this test would have failed: the height was 12162,
+ // which is not the mm100 equivalent of the 4064000 EMU in the input file.
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(11287), xGroup->getSize().Height);
+
+ uno::Reference<text::XText> xA1(getChildShape(getChildShape(xGroup, 1), 0), uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xA1.is());
+ CPPUNIT_ASSERT_EQUAL(OUString("A1"), xA1->getString());
+
+ // Test fill color of B1, should be orange.
+ uno::Reference<text::XText> xB1(getChildShape(getChildShape(xGroup, 1), 1), uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xB1.is());
+ CPPUNIT_ASSERT_EQUAL(OUString("B1"), xB1->getString());
+
+ uno::Reference<beans::XPropertySet> xB1Props(xB1, uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xB1Props.is());
+ sal_Int32 nFillColor = 0;
+ xB1Props->getPropertyValue("FillColor") >>= nFillColor;
+ // Without the accompanying fix in place, this test would have failed: the background color was
+ // 0x4f81bd, i.e. blue, not orange.
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0xf79646), nFillColor);
+
+ // Without the accompanying fix in place, this test would have failed: the
+ // content of the "A2" shape was lost.
+ uno::Reference<text::XText> xA2(getChildShape(getChildShape(getChildShape(xGroup, 0), 0), 1),
+ uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xA2.is());
+ CPPUNIT_ASSERT_EQUAL(OUString("A2"), xA2->getString());
+
+ // Test that the layout of shapes is like this:
+ // A2 B2
+ // D2 C2
+
+ uno::Reference<drawing::XShape> xA2Shape(xA2, uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xA2Shape.is());
+
+ uno::Reference<text::XText> xB2(getChildShape(getChildShape(getChildShape(xGroup, 0), 1), 1),
+ uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xB2.is());
+ CPPUNIT_ASSERT_EQUAL(OUString("B2"), xB2->getString());
+ uno::Reference<drawing::XShape> xB2Shape(xB2, uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xB2Shape.is());
+
+ // Test line color of B2, should be orange.
+ uno::Reference<beans::XPropertySet> xB2Props(xB2, uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xB2Props.is());
+ sal_Int32 nLineColor = 0;
+ xB2Props->getPropertyValue("LineColor") >>= nLineColor;
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0xf79646), nLineColor);
+
+ uno::Reference<text::XText> xC2(getChildShape(getChildShape(getChildShape(xGroup, 0), 2), 1),
+ uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xC2.is());
+ // Without the accompanying fix in place, this test would have failed, i.e. the order of the
+ // lines in the shape were wrong: C2-1\nC2-4\nC2-3\nC2-2.
+ CPPUNIT_ASSERT_EQUAL(OUString("C2-1\nC2-2\nC2-3\nC2-4"), xC2->getString());
+ uno::Reference<drawing::XShape> xC2Shape(xC2, uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xC2Shape.is());
+
+ uno::Reference<text::XText> xD2(getChildShape(getChildShape(getChildShape(xGroup, 0), 3), 1),
+ uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xD2.is());
+ CPPUNIT_ASSERT_EQUAL(OUString("D2"), xD2->getString());
+ uno::Reference<drawing::XShape> xD2Shape(xD2, uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xD2Shape.is());
+
+ // Without the accompanying fix in place, this test would have failed, i.e.
+ // the A2 and B2 shapes had the same horizontal position, while B2 should
+ // be on the right of A2.
+ CPPUNIT_ASSERT_GREATER(xA2Shape->getPosition().X, xB2Shape->getPosition().X);
+ CPPUNIT_ASSERT_EQUAL(xA2Shape->getPosition().Y, xB2Shape->getPosition().Y);
+ CPPUNIT_ASSERT_GREATER(xA2Shape->getPosition().X, xC2Shape->getPosition().X);
+ CPPUNIT_ASSERT_GREATER(xA2Shape->getPosition().Y, xC2Shape->getPosition().Y);
+ CPPUNIT_ASSERT_EQUAL(xA2Shape->getPosition().X, xD2Shape->getPosition().X);
+ CPPUNIT_ASSERT_GREATER(xA2Shape->getPosition().Y, xD2Shape->getPosition().Y);
+
+ // Without the accompanying fix in place, this test would have failed: width was expected to be
+ // 4887, was actually 7331.
+ uno::Reference<drawing::XShape> xA1Shape(xA1, uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xA1Shape.is());
+ CPPUNIT_ASSERT_EQUAL(xA1Shape->getSize().Height, xA1Shape->getSize().Width);
+
+ xDocShRef->DoClose();
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTestSmartArt);
CPPUNIT_PLUGIN_IMPLEMENT();