summaryrefslogtreecommitdiffstats
path: root/oox
diff options
context:
space:
mode:
authorGülşah Köse <gulsah.kose@collabora.com>2021-01-28 09:37:58 +0300
committerMiklos Vajna <vmiklos@collabora.com>2021-02-11 15:10:14 +0100
commit3b7fa9b723bf4377077517b4e09cdba647a26a90 (patch)
tree0fcfc7a6d7777696fc65f1325fc72001dc66fc6c /oox
parentDon't shrink row height when deleting cell contents interactively either (diff)
downloadcore-3b7fa9b723bf4377077517b4e09cdba647a26a90.tar.gz
core-3b7fa9b723bf4377077517b4e09cdba647a26a90.zip
tdf#134210 Apply mirror property to custom cropped graphic.
Change-Id: I5bf2ba8fa432af8b6a560cc60c18bef799834fd0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110039 Tested-by: Jenkins Reviewed-by: Gülşah Köse <gulsah.kose@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110663 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'oox')
-rw-r--r--oox/inc/drawingml/graphicproperties.hxx4
-rw-r--r--oox/source/drawingml/fillproperties.cxx29
-rw-r--r--oox/source/drawingml/shape.cxx9
3 files changed, 38 insertions, 4 deletions
diff --git a/oox/inc/drawingml/graphicproperties.hxx b/oox/inc/drawingml/graphicproperties.hxx
index 7a227f8cc949..4dc4ff0b90a3 100644
--- a/oox/inc/drawingml/graphicproperties.hxx
+++ b/oox/inc/drawingml/graphicproperties.hxx
@@ -46,7 +46,9 @@ struct GraphicProperties
/** Writes the properties to the passed property map. */
void pushToPropMap(
PropertyMap& rPropMap,
- const GraphicHelper& rGraphicHelper) const;
+ const GraphicHelper& rGraphicHelper,
+ bool bFlipH = false,
+ bool bFlipV = false) const;
};
} // namespace drawingml
diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx
index b508f0f2ba77..f17a613b444e 100644
--- a/oox/source/drawingml/fillproperties.cxx
+++ b/oox/source/drawingml/fillproperties.cxx
@@ -118,6 +118,28 @@ Reference< XGraphic > lclCropGraphic(uno::Reference<graphic::XGraphic> const & x
return aReturnGraphic.GetXGraphic();
}
+Reference< XGraphic > lclMirrorGraphic(uno::Reference<graphic::XGraphic> const & xGraphic, bool bFlipH, bool bFlipV)
+{
+ ::Graphic aGraphic(xGraphic);
+ ::Graphic aReturnGraphic;
+
+ assert (aGraphic.GetType() == GraphicType::Bitmap);
+
+ BitmapEx aBitmapEx(aGraphic.GetBitmapEx());
+ BmpMirrorFlags nMirrorFlags = BmpMirrorFlags::NONE;
+
+ if(bFlipH)
+ nMirrorFlags |= BmpMirrorFlags::Horizontal;
+ if(bFlipV)
+ nMirrorFlags |= BmpMirrorFlags::Vertical;
+
+ aBitmapEx.Mirror(nMirrorFlags);
+
+ 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)
@@ -749,7 +771,7 @@ void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap,
}
}
-void GraphicProperties::pushToPropMap( PropertyMap& rPropMap, const GraphicHelper& rGraphicHelper) const
+void GraphicProperties::pushToPropMap( PropertyMap& rPropMap, const GraphicHelper& rGraphicHelper, bool bFlipH, bool bFlipV) const
{
sal_Int16 nBrightness = getLimitedValue< sal_Int16, sal_Int32 >( maBlipProps.moBrightness.get( 0 ) / PER_PERCENT, -100, 100 );
sal_Int16 nContrast = getLimitedValue< sal_Int16, sal_Int32 >( maBlipProps.moContrast.get( 0 ) / PER_PERCENT, -100, 100 );
@@ -799,6 +821,11 @@ void GraphicProperties::pushToPropMap( PropertyMap& rPropMap, const GraphicHelpe
xGraphic = lclRotateGraphic(xGraphic, nAngle/10 );
}
+ // We have not core feature that flips graphic in the shape.
+ // Here we are applying flip property to bitmap directly.
+ if(bFlipH || bFlipV)
+ xGraphic = lclMirrorGraphic(xGraphic, bFlipH, bFlipV );
+
rPropMap.setProperty(PROP_FillBitmap, xGraphic);
}
else
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 6deae9f4992d..ec29618dd8f9 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -1056,8 +1056,13 @@ Reference< XShape > const & Shape::createAndInsert(
aShapeProps.assignUsed( maDefaultShapeProperties );
if(mnRotation != 0 && bIsCustomShape)
aShapeProps.setProperty( PROP_RotateAngle, sal_Int32( NormAngle36000( mnRotation / -600 ) ));
- if ( bIsEmbMedia || aServiceName == "com.sun.star.drawing.GraphicObjectShape" || aServiceName == "com.sun.star.drawing.OLE2Shape" || bIsCustomShape )
- mpGraphicPropertiesPtr->pushToPropMap( aShapeProps, rGraphicHelper );
+ if ( bIsEmbMedia ||
+ bIsCustomShape ||
+ aServiceName == "com.sun.star.drawing.GraphicObjectShape" ||
+ aServiceName == "com.sun.star.drawing.OLE2Shape")
+ {
+ mpGraphicPropertiesPtr->pushToPropMap( aShapeProps, rGraphicHelper, mbFlipH, mbFlipV );
+ }
if ( mpTablePropertiesPtr.get() && aServiceName == "com.sun.star.drawing.TableShape" )
mpTablePropertiesPtr->pushToPropSet( rFilterBase, xSet, mpMasterTextListStyle );