From b3712c66978012ea49479bf3ac04bf8355d2a885 Mon Sep 17 00:00:00 2001 From: "Armin Le Grand (Allotropia)" Date: Wed, 26 Jan 2022 18:02:27 +0100 Subject: tdf#126319 Correct area(s) on selection export For shapes like TextFrames the export of the selected object(s) to Bitmap needed to be adapted. It should not reduce to minimal geometric necessary size. While reduction seems good initially as an idea this may change aspect ratio and expected size of the result by cutting off visually empty areas, e.g. the text distance areas to the shape's logical bounds. This also needed to be adapted to multi-selections accordingly. Change-Id: I85bffe60fcfc2e8da87f69936af30f64c26deead Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129002 Tested-by: Jenkins Reviewed-by: Armin Le Grand Signed-off-by: Xisco Fauli Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129809 --- svx/source/unodraw/UnoGraphicExporter.cxx | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'svx') diff --git a/svx/source/unodraw/UnoGraphicExporter.cxx b/svx/source/unodraw/UnoGraphicExporter.cxx index 73d77cb54ea8..d6029dde6d29 100644 --- a/svx/source/unodraw/UnoGraphicExporter.cxx +++ b/svx/source/unodraw/UnoGraphicExporter.cxx @@ -224,25 +224,29 @@ namespace { const Size aHalfPixelInMtf( (aOnePixelInMtf.getWidth() + 1) / 2, (aOnePixelInMtf.getHeight() + 1) / 2); - const bool bHairlineBR( - !aHairlineRect.IsEmpty() && (aRect.Right() == aHairlineRect.Right() || aRect.Bottom() == aHairlineRect.Bottom())); - // Move the content to (0,0), usually TopLeft ist slightly - // negative. For better visualization, add a half pixel, too + // tdf#126319 take bounds into account individually + const bool bHairlineRight(!aHairlineRect.IsEmpty() && aRect.Right() == aHairlineRect.Right()); + const bool bHairlineBottom(!aHairlineRect.IsEmpty() && aRect.Bottom() == aHairlineRect.Bottom()); + const bool bHairlineLeft(!aHairlineRect.IsEmpty() && aRect.Left() == aHairlineRect.Left()); + const bool bHairlineTop(!aHairlineRect.IsEmpty() && aRect.Top() == aHairlineRect.Top()); + + // tdf#126319 Move the content dependent on Top/Left hairline aMtf.Move( - aHalfPixelInMtf.getWidth() - aRect.Left(), - aHalfPixelInMtf.getHeight() - aRect.Top()); + (bHairlineLeft ? -aHalfPixelInMtf.getWidth() : aHalfPixelInMtf.getWidth()), + (bHairlineTop ? -aHalfPixelInMtf.getHeight() : aHalfPixelInMtf.getHeight())); // Do not Scale, but set the PrefSize. Some levels deeper the // MetafilePrimitive will add a mapping to the decomposition // (and possibly a clipping) to map the graphic content to // a unit coordinate system. - // Size is the measured size plus one pixel if needed (bHairlineBR) - // and the moved half pixwel from above + // tdf#126319 Size is the previous already correct size plus one + // pixel if needed (dependent on Righ/Bottom hairline) and the + // already moved half pixel from above aMtf.SetPrefSize( Size( - aRect.getWidth() + (bHairlineBR ? aOnePixelInMtf.getWidth() : 0) + aHalfPixelInMtf.getWidth(), - aRect.getHeight() + (bHairlineBR ? aOnePixelInMtf.getHeight() : 0) + aHalfPixelInMtf.getHeight())); + aMtf.GetPrefSize().Width() + (bHairlineRight ? aHalfPixelInMtf.getWidth() : 0), + aMtf.GetPrefSize().Height() + (bHairlineBottom ? aHalfPixelInMtf.getHeight() : 0))); } return convertMetafileToBitmapEx(aMtf, aRange, nMaximumQuadraticPixels); -- cgit