summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2019-02-22 17:12:04 +0100
committerAndras Timar <andras.timar@collabora.com>2019-03-05 10:27:12 +0100
commitc38c9139b4b5a5e8a52197733f3cefdc89c86364 (patch)
tree1a0bb5d7e0b4abd67be8a1a5ad5e1df9825c8e73 /sd
parent592c6893156615695b7f95f53d71624a87650bf6 (diff)
Related: tdf#117761 oox smartart: backport fixes related to picture strip
This is a combination of 7 commits. This is the 1st commit: oox smartart, picture strip: handle bitmap fill of pres nodes There were two problems here: 1) We did not import bitmap fill from presentation nodes. 2) Presentation nodes contained properties with reference semantics, so if you set a bitmap fill for a first and a second shape, then at the end both shapes contained the second bitmap. With this, both bitmaps are imported exactly once. (cherry picked from commit 333e9ea15bb57cf1c87ac2ea150de1e3fd79cfcb) This is the commit #2: oox smartart, picture strip: fetch # of children only once in snake algo No functional changes intended. (cherry picked from commit 90372d52fdcc378473b89f4e6f2de0e206c110ef) This is the commit #3: oox smartart, picture strip: expose aspect ratio of children for snake algo The aspect ratio request of the Shape is not yet used in AlgAtom::layoutShape(), though. The heavy-lifting is needed, because the number of cols/rows in the snake algorithm depends on the aspect ratio request from the child algorithm, so need to transfer the aspect ratio from child algorithm -> layout node -> shape -> parent algorithm. Still no functional changes intended. (cherry picked from commit a1e10b7968fbf4dba962349be8a6dfb0cb1d3176) This is the commit #4: oox smartart, picture strip: fix too many columns with aspect ratio request The bugdoc has 3 items in the picture strip and PowerPoint laid this out as a single column with 3 rows (as a snake algorithm). We used to put the first two items to the first row and the third item to the second row. Improve out layout by taking into account what aspect ratio the child algorithms request: this way it's obvious that we should use a single column in case we have a large enough aspect ratio and few enough items. (PowerPoint also uses multiple columns without the aspect ratio request.) (cherry picked from commit 159e33ec661b2ce038b2642b2f30600ce7901d1b) This is the commit #5: oox smartart, picture strip: fix lack of spacing around the picture list The snake algorithm in PowerPoint seem to interpret spacing as follows: if you have N elements, then there should be the requested amount of spacing between the elements, and also double amount of spacing around the actual list of elements. With this, the SmartArt and the title shape in the bugdoc no longer overlaps. (cherry picked from commit 0a29c928afa74123bca05dc089c751603d368467) This is the commit #6: oox smartart, picture strip: fix lack of margin in text shapes Shape text has two kind of spacing inside the shape's bounding box: the shape-level margin and the paragraph-level one. Only the second was handled in the tx algorithm so far, add support for the first. The margins taken from constraints were way large by default: the only explanation I found for that is that SmartArt layout sometimes calculates in MMs, sometimes in Points, and the ratio between the two is exactly the Impress / PowerPoint margin. So assume that indeed that unit difference is the reason for the smaller in-PowerPoint margin values and do the same on our side. (cherry picked from commit 279c7f83a57c4d3991930ee80e9d9c287c21270a) This is the commit #7: oox smartart, picture strip: fix too wide child shapes Once the constraints determine the size, the aspect ratio may shrink one dimension to achieve the requested ratio. Implement the case where a >1 ratio shrinks the width, so the container of the image-text shape pair has correct aspect ratio. (cherry picked from commit f4fbb127897ea6afe27055d3b6cfcb0441080902) Change-Id: I7bac764c031e80bac532c4f97ebd5b5096401096 Reviewed-on: https://gerrit.libreoffice.org/68679 Tested-by: Jenkins Reviewed-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'sd')
-rw-r--r--sd/qa/unit/data/pptx/smartart-picture-strip.pptxbin0 -> 52395 bytes
-rw-r--r--sd/qa/unit/import-tests-smartart.cxx85
2 files changed, 85 insertions, 0 deletions
diff --git a/sd/qa/unit/data/pptx/smartart-picture-strip.pptx b/sd/qa/unit/data/pptx/smartart-picture-strip.pptx
new file mode 100644
index 000000000000..bfb8d4f2c1bd
--- /dev/null
+++ b/sd/qa/unit/data/pptx/smartart-picture-strip.pptx
Binary files differ
diff --git a/sd/qa/unit/import-tests-smartart.cxx b/sd/qa/unit/import-tests-smartart.cxx
index 68fed33c8c03..e4a2fafd9df3 100644
--- a/sd/qa/unit/import-tests-smartart.cxx
+++ b/sd/qa/unit/import-tests-smartart.cxx
@@ -15,6 +15,7 @@
#include <com/sun/star/text/XText.hpp>
#include <comphelper/sequenceashashmap.hxx>
+#include <oox/drawingml/drawingmltypes.hxx>
using namespace ::com::sun::star;
@@ -66,6 +67,7 @@ public:
void testContinuousBlockProcess();
void testOrgChart();
void testCycleMatrix();
+ void testPictureStrip();
CPPUNIT_TEST_SUITE(SdImportTestSmartArt);
@@ -97,6 +99,7 @@ public:
CPPUNIT_TEST(testContinuousBlockProcess);
CPPUNIT_TEST(testOrgChart);
CPPUNIT_TEST(testCycleMatrix);
+ CPPUNIT_TEST(testPictureStrip);
CPPUNIT_TEST_SUITE_END();
};
@@ -814,6 +817,88 @@ void SdImportTestSmartArt::testCycleMatrix()
xDocShRef->DoClose();
}
+void SdImportTestSmartArt::testPictureStrip()
+{
+ sd::DrawDocShellRef xDocShRef = loadURL(
+ m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-picture-strip.pptx"), PPTX);
+ uno::Reference<drawing::XShape> xGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xGroup.is());
+
+ uno::Reference<beans::XPropertySet> xFirstImage(getChildShape(getChildShape(xGroup, 0), 1),
+ uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xFirstImage.is());
+ drawing::FillStyle eFillStyle = drawing::FillStyle_NONE;
+ xFirstImage->getPropertyValue("FillStyle") >>= eFillStyle;
+ // Without the accompanying fix in place, this test would have failed: fill style was solid, not
+ // bitmap.
+ CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_BITMAP, eFillStyle);
+
+ uno::Reference<graphic::XGraphic> xGraphic;
+ xFirstImage->getPropertyValue("FillBitmap") >>= xGraphic;
+ Graphic aFirstGraphic(xGraphic);
+
+ uno::Reference<beans::XPropertySet> xSecondImage(getChildShape(getChildShape(xGroup, 1), 1),
+ uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xSecondImage.is());
+ eFillStyle = drawing::FillStyle_NONE;
+ xSecondImage->getPropertyValue("FillStyle") >>= eFillStyle;
+ CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_BITMAP, eFillStyle);
+
+ xSecondImage->getPropertyValue("FillBitmap") >>= xGraphic;
+ Graphic aSecondGraphic(xGraphic);
+ // Without the accompanying fix in place, this test would have failed: both xFirstImage and
+ // xSecondImage had the bitmap fill from the second shape.
+ CPPUNIT_ASSERT(aFirstGraphic.GetChecksum() != aSecondGraphic.GetChecksum());
+
+ // Test that the 3 images are in a single column, in 3 rows.
+ uno::Reference<drawing::XShape> xFirstImageShape(xFirstImage, uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xFirstImage.is());
+ uno::Reference<drawing::XShape> xSecondImageShape(xSecondImage, uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xSecondImage.is());
+ uno::Reference<drawing::XShape> xThirdImageShape(getChildShape(getChildShape(xGroup, 2), 1),
+ uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xThirdImageShape.is());
+ // Without the accompanying fix in place, this test would have failed: the first and the second
+ // image were in the same row.
+ CPPUNIT_ASSERT_EQUAL(xFirstImageShape->getPosition().X, xSecondImageShape->getPosition().X);
+ CPPUNIT_ASSERT_EQUAL(xSecondImageShape->getPosition().X, xThirdImageShape->getPosition().X);
+ CPPUNIT_ASSERT_GREATER(xFirstImageShape->getPosition().Y, xSecondImageShape->getPosition().Y);
+ CPPUNIT_ASSERT_GREATER(xSecondImageShape->getPosition().Y, xThirdImageShape->getPosition().Y);
+
+ // Make sure that the title shape doesn't overlap with the diagram.
+ // Note that real "no overlap" is asserted here, though in fact what we want is a less strict
+ // condition: that no text part of the title shape and the diagram overlaps.
+ uno::Reference<drawing::XShape> xTitle(getShapeFromPage(1, 0, xDocShRef), uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xTitle.is());
+ // Without the accompanying fix in place, this test would have failed with 'Expected greater
+ // than: 2873; Actual : 2320', i.e. the title shape and the diagram overlapped.
+ CPPUNIT_ASSERT_GREATER(xTitle->getPosition().Y + xTitle->getSize().Height,
+ xGroup->getPosition().Y);
+
+ // Make sure that left margin is 60% of width (if you count width in points and margin in mms).
+ uno::Reference<beans::XPropertySet> xFirstText(getChildShape(getChildShape(xGroup, 0), 0),
+ uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xFirstText.is());
+ sal_Int32 nTextLeftDistance = 0;
+ xFirstText->getPropertyValue("TextLeftDistance") >>= nTextLeftDistance;
+ uno::Reference<drawing::XShape> xFirstTextShape(xFirstText, uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xFirstTextShape.is());
+ sal_Int32 nWidth = xFirstTextShape->getSize().Width;
+ double fFactor = oox::drawingml::convertPointToMms(0.6);
+ // Without the accompanying fix in place, this test would have failed with 'Expected: 3440,
+ // Actual : 263', i.e. the left margin was too small.
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(nWidth * fFactor), nTextLeftDistance);
+
+ // Make sure that aspect ratio is not ignored, i.e. width is not larger than height 3 times.
+ uno::Reference<drawing::XShape> xFirstPair = getChildShape(xGroup, 0);
+ awt::Size aFirstPairSize = xFirstPair->getSize();
+ // Without the accompanying fix in place, this test would have failed: bad width was 16932, good
+ // width is 12540, but let's accept 12541 as well.
+ CPPUNIT_ASSERT_LESSEQUAL(aFirstPairSize.Height * 3 + 1, aFirstPairSize.Width);
+
+ xDocShRef->DoClose();
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTestSmartArt);
CPPUNIT_PLUGIN_IMPLEMENT();