[Libreoffice-commits] core.git: oox/source sd/qa
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Thu Feb 28 19:27:38 UTC 2019
oox/source/drawingml/diagram/diagramlayoutatoms.cxx | 9 ++++++++-
sd/qa/unit/import-tests-smartart.cxx | 7 +++++++
2 files changed, 15 insertions(+), 1 deletion(-)
New commits:
commit f4fbb127897ea6afe27055d3b6cfcb0441080902
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Thu Feb 28 15:00:01 2019 +0100
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Thu Feb 28 20:27:12 2019 +0100
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.
Change-Id: I7bac764c031e80bac532c4f97ebd5b5096401096
Reviewed-on: https://gerrit.libreoffice.org/68510
Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
Tested-by: Jenkins
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index 7dc6e7622cb0..336760575339 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -985,7 +985,14 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
nNumSpaces += 4;
sal_Int32 nHeight
= rShape->getSize().Height / (nRow + (nRow + nNumSpaces) * fSpace);
- aChildSize = awt::Size(rShape->getSize().Width, nHeight);
+
+ if (fChildAspectRatio > 1)
+ {
+ // Shrink width if the aspect ratio requires it.
+ nWidth = std::min(rShape->getSize().Width,
+ static_cast<sal_Int32>(nHeight * fChildAspectRatio));
+ aChildSize = awt::Size(nWidth, nHeight);
+ }
}
awt::Point aCurrPos(0, 0);
diff --git a/sd/qa/unit/import-tests-smartart.cxx b/sd/qa/unit/import-tests-smartart.cxx
index 3a98496735ef..22513adc312a 100644
--- a/sd/qa/unit/import-tests-smartart.cxx
+++ b/sd/qa/unit/import-tests-smartart.cxx
@@ -980,6 +980,13 @@ void SdImportTestSmartArt::testPictureStrip()
// 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();
}
More information about the Libreoffice-commits
mailing list