svx/source/unodraw/UnoGraphicExporter.cxx |   24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

New commits:
commit 5a67220831b994c4ecb83d93333eb76bffb88015
Author:     Armin Le Grand (Allotropia) <armin.le.gr...@me.com>
AuthorDate: Wed Jan 26 18:02:27 2022 +0100
Commit:     Armin Le Grand <armin.le.gr...@me.com>
CommitDate: Fri Jan 28 09:45:35 2022 +0100

    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 <armin.le.gr...@me.com>

diff --git a/svx/source/unodraw/UnoGraphicExporter.cxx 
b/svx/source/unodraw/UnoGraphicExporter.cxx
index 823beeaaea79..6c158e936684 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);

Reply via email to