summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorGülşah Köse <gulsah.kose@collabora.com>2021-01-20 00:52:56 +0300
committerGülşah Köse <gulsah.kose@collabora.com>2021-01-21 16:05:24 +0100
commit9ac58bf3a6d0a72c5452a9cc162554b3a667d2e0 (patch)
tree8dcf4e8a94309dcb54672df49715c6da059e5330 /oox
parentf37ce0a08bc73d4d1e3cdee6553e637bd965ec1e (diff)
tdf#134210 Import support for custom stretch values.
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109658 Tested-by: Jenkins Reviewed-by: Gülşah Köse <gulsah.kose@collabora.com> (cherry picked from commit 2c96bd26ec488d865370fe9d394e7c4e228e05ab) Change-Id: I33ced8d667e37b7fb79f4c87b689f45966ac0097 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109739 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Gülşah Köse <gulsah.kose@collabora.com>
Diffstat (limited to 'oox')
-rw-r--r--oox/inc/drawingml/fillproperties.hxx3
-rw-r--r--oox/source/drawingml/fillproperties.cxx34
-rw-r--r--oox/source/drawingml/shape.cxx2
3 files changed, 36 insertions, 3 deletions
diff --git a/oox/inc/drawingml/fillproperties.hxx b/oox/inc/drawingml/fillproperties.hxx
index 45f5c4b40272..e77885058d24 100644
--- a/oox/inc/drawingml/fillproperties.hxx
+++ b/oox/inc/drawingml/fillproperties.hxx
@@ -148,7 +148,8 @@ struct OOX_DLLPUBLIC FillProperties
sal_Int32 nShapeRotation = 0,
::Color nPhClr = API_RGB_TRANSPARENT,
bool bFlipH = false,
- bool bFlipV = false ) const;
+ bool bFlipV = false,
+ bool bIsCustomShape = false ) const;
};
} // namespace drawingml
diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx
index 863d3b846c60..b508f0f2ba77 100644
--- a/oox/source/drawingml/fillproperties.cxx
+++ b/oox/source/drawingml/fillproperties.cxx
@@ -93,6 +93,32 @@ Reference< XGraphic > lclRotateGraphic(uno::Reference<graphic::XGraphic> const &
return aReturnGraphic.GetXGraphic();
}
+Reference< XGraphic > lclCropGraphic(uno::Reference<graphic::XGraphic> const & xGraphic, geometry::IntegerRectangle2D aFillRect)
+{
+ ::Graphic aGraphic(xGraphic);
+ ::Graphic aReturnGraphic;
+
+ assert (aGraphic.GetType() == GraphicType::Bitmap);
+
+ BitmapEx aBitmapEx(aGraphic.GetBitmapEx());
+
+ sal_Int32 nOrigHeight = aBitmapEx.GetSizePixel().Height();
+ sal_Int32 nHeight = nOrigHeight;
+ sal_Int32 nTopCorr = nOrigHeight * -1 * static_cast<double>(aFillRect.Y1) / 100000;
+ nHeight += nTopCorr;
+ sal_Int32 nBottomCorr = nOrigHeight * -1 * static_cast<double>(aFillRect.Y2) / 100000;
+ nHeight += nBottomCorr;
+
+ aBitmapEx.Scale(Size(aBitmapEx.GetSizePixel().Width(), nHeight));
+ aBitmapEx.Crop(tools::Rectangle(Point(0, nTopCorr), Size(aBitmapEx.GetSizePixel().Width(), nOrigHeight)));
+
+ aReturnGraphic = ::Graphic(aBitmapEx);
+ aReturnGraphic.setOriginURL(aGraphic.getOriginURL());
+
+ return aReturnGraphic.GetXGraphic();
+}
+
+
Reference< XGraphic > lclCheckAndApplyChangeColorTransform(const BlipFillProperties &aBlipProps, uno::Reference<graphic::XGraphic> const & xGraphic,
const GraphicHelper& rGraphicHelper, const ::Color nPhClr)
{
@@ -278,7 +304,7 @@ Color FillProperties::getBestSolidColor() const
void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap,
const GraphicHelper& rGraphicHelper, sal_Int32 nShapeRotation, ::Color nPhClr,
- bool bFlipH, bool bFlipV ) const
+ bool bFlipH, bool bFlipV, bool bIsCustomShape) const
{
if( moFillType.has() )
{
@@ -668,6 +694,12 @@ void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap,
if ( aFillRect.Y2 )
aGraphCrop.Bottom = static_cast< sal_Int32 >( ( static_cast< double >( aOriginalSize.Height ) * aFillRect.Y2 ) / 100000 );
rPropMap.setProperty(PROP_GraphicCrop, aGraphCrop);
+
+ if(bIsCustomShape)
+ {
+ xGraphic = lclCropGraphic(xGraphic, aFillRect);
+ rPropMap.setProperty(ShapeProperty::FillBitmap, xGraphic);
+ }
}
}
}
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index bf75f2e5f8df..6deae9f4992d 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -1065,7 +1065,7 @@ Reference< XShape > const & Shape::createAndInsert(
if (getFillProperties().moFillType.has() && getFillProperties().moFillType.get() == XML_grpFill)
getFillProperties().assignUsed(aFillProperties);
if(!bIsCroppedGraphic)
- aFillProperties.pushToPropMap( aShapeProps, rGraphicHelper, mnRotation, nFillPhClr, mbFlipH, mbFlipV );
+ aFillProperties.pushToPropMap( aShapeProps, rGraphicHelper, mnRotation, nFillPhClr, mbFlipH, mbFlipV, bIsCustomShape );
LineProperties aLineProperties = getActualLineProperties(pTheme);
aLineProperties.pushToPropMap( aShapeProps, rGraphicHelper, nLinePhClr );
EffectProperties aEffectProperties = getActualEffectProperties(pTheme);