summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2022-11-24 11:22:49 +0100
committerJan Holesovsky <kendy@collabora.com>2022-11-24 21:58:46 +0100
commitab080ab1ab3100d9702a745287566b78b8d59e54 (patch)
tree8c66009ac87ce5a121ab07a09663b09ae32ef303 /oox
parent1e9ace4c35e4206c24ded230433915850a1f04d1 (diff)
tdf#152199: Don't crop twice
We have a "GraphicCrop" property that is supposed to roundtrip the cropping in OOXML, but there is no core feature backing it (ie. the image is not shown cropped when this is imported and set). Instead, to show the image "cropped", we crop the image physically on import (throw away pixels that are 'outside' of the cropped area). But - the "GraphicCrop" is then saved on export, together with the image already physically cropped, which leads to garbled DOCX on re-import. Given that the core feature to show image cropped when the "GraphicCrop" is set, let's avoid setting it when we physically crop the image. Change-Id: Ia1090ea9c6d22e60c77d52bf65281f6588d07d4e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143216 Tested-by: Jenkins Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Diffstat (limited to 'oox')
-rw-r--r--oox/source/drawingml/fillproperties.cxx6
1 files changed, 5 insertions, 1 deletions
diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx
index 75da3836b6f5..329d5d3bb4b1 100644
--- a/oox/source/drawingml/fillproperties.cxx
+++ b/oox/source/drawingml/fillproperties.cxx
@@ -853,7 +853,6 @@ void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap,
aGraphCrop.Right = static_cast< sal_Int32 >( ( static_cast< double >( aOriginalSize.Width ) * aFillRect.X2 ) / 100000 );
if ( aFillRect.Y2 )
aGraphCrop.Bottom = static_cast< sal_Int32 >( ( static_cast< double >( aOriginalSize.Height ) * aFillRect.Y2 ) / 100000 );
- rPropMap.setProperty(PROP_GraphicCrop, aGraphCrop);
bool bHasCropValues = aGraphCrop.Left != 0 || aGraphCrop.Right !=0 || aGraphCrop.Top != 0 || aGraphCrop.Bottom != 0;
// Negative GraphicCrop values means "crop" here.
@@ -861,12 +860,17 @@ void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap,
if(bIsCustomShape && bHasCropValues && bNeedCrop)
{
+ // Physically crop the image
+ // In this case, don't set the PROP_GraphicCrop because that
+ // would lead to applying the crop twice after roundtrip
xGraphic = lclCropGraphic(xGraphic, CropQuotientsFromFillRect(aFillRect));
if (rPropMap.supportsProperty(ShapeProperty::FillBitmapName))
rPropMap.setProperty(ShapeProperty::FillBitmapName, xGraphic);
else
rPropMap.setProperty(ShapeProperty::FillBitmap, xGraphic);
}
+ else
+ rPropMap.setProperty(PROP_GraphicCrop, aGraphCrop);
}
}
}