File bsc1174928.diff of Package libreoffice
From 714cced53b2937f88a085ee7a20bdb7f55d7d26a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?G=C3=BCl=C5=9Fah=20K=C3=B6se?= <gulsah.kose@collabora.com>
Date: Sun, 23 Aug 2020 22:32:53 +0300
Subject: [PATCH] bsc1174928.diff
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
tdf#134174 Fix the rotation of bitmap filled custom shapes.
During import we were rotating only custom shape. Not its bitmap.
Custom shape and its bitmap rotated with same rotation value
in that commit.
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101255
Tested-by: Jenkins
Reviewed-by: Gülşah Köse <gulsah.kose@collabora.com>
(cherry picked from commit 9fe881410909c5273cef517433411bc4eceee294)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101161
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Change-Id: I02d19c820670df7b4d1622836156c6bf8ed1c154
---
oox/source/drawingml/fillproperties.cxx | 26 +++++++++++++++++++++++++
oox/source/drawingml/shape.cxx | 2 ++
2 files changed, 28 insertions(+)
diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx
index 681bf10a3e67..4b8ca636500a 100644
--- a/oox/source/drawingml/fillproperties.cxx
+++ b/oox/source/drawingml/fillproperties.cxx
@@ -22,6 +22,7 @@
#include <iterator>
#include <drawingml/graphicproperties.hxx>
+#include <vcl/graph.hxx>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
@@ -75,6 +76,22 @@ Reference< XGraphic > lclCheckAndApplyDuotoneTransform(const BlipFillProperties&
return xGraphic;
}
+Reference< XGraphic > lclRotateGraphic(uno::Reference<graphic::XGraphic> const & xGraphic, long nRotation)
+{
+ ::Graphic aGraphic(xGraphic);
+ ::Graphic aReturnGraphic;
+
+ assert (aGraphic.GetType() == GraphicType::Bitmap);
+
+ BitmapEx aBitmapEx(aGraphic.GetBitmapEx());
+ const ::Color& aColor = ::Color(0x00);
+ aBitmapEx.Rotate(nRotation, aColor);
+ 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)
{
@@ -808,6 +825,15 @@ void GraphicProperties::pushToPropMap( PropertyMap& rPropMap, const GraphicHelpe
// it is a cropped graphic.
rPropMap.setProperty(PROP_FillStyle, FillStyle_BITMAP);
rPropMap.setProperty(PROP_FillBitmapMode, BitmapMode_STRETCH);
+
+ // It is a bitmap filled and rotated graphic.
+ // When custom shape is rotated, bitmap have to be rotated too.
+ if(rPropMap.hasProperty(PROP_RotateAngle))
+ {
+ long nAngle = rPropMap.getProperty(PROP_RotateAngle).get<long>();
+ xGraphic = lclRotateGraphic(xGraphic, nAngle/10 );
+ }
+
rPropMap.setProperty(PROP_FillBitmap, xGraphic);
}
else
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 8cb3d00df231..2e100a41c309 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -1036,6 +1036,8 @@ Reference< XShape > const & Shape::createAndInsert(
// applying properties
aShapeProps.assignUsed( getShapeProperties() );
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 ( mpTablePropertiesPtr.get() && aServiceName == "com.sun.star.drawing.TableShape" )
--
2.26.2