Kaydet (Commit) f4fbb127 authored tarafından Miklos Vajna's avatar Miklos Vajna

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/68510Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
üst 609ea85b
...@@ -985,7 +985,14 @@ void AlgAtom::layoutShape( const ShapePtr& rShape, ...@@ -985,7 +985,14 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
nNumSpaces += 4; nNumSpaces += 4;
sal_Int32 nHeight sal_Int32 nHeight
= rShape->getSize().Height / (nRow + (nRow + nNumSpaces) * fSpace); = 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); awt::Point aCurrPos(0, 0);
......
...@@ -980,6 +980,13 @@ void SdImportTestSmartArt::testPictureStrip() ...@@ -980,6 +980,13 @@ void SdImportTestSmartArt::testPictureStrip()
// Actual : 263', i.e. the left margin was too small. // Actual : 263', i.e. the left margin was too small.
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(nWidth * fFactor), nTextLeftDistance); 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(); xDocShRef->DoClose();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment