[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - oox/source sd/qa

Gülşah Köse (via logerrit) logerrit at kemper.freedesktop.org
Tue Aug 25 12:27:28 UTC 2020


 oox/source/drawingml/fillproperties.cxx |   26 ++++++++++++++++++++++++++
 oox/source/drawingml/shape.cxx          |    2 ++
 sd/qa/unit/data/pptx/tdf134174.pptx     |binary
 sd/qa/unit/import-tests.cxx             |   19 +++++++++++++++++++
 4 files changed, 47 insertions(+)

New commits:
commit 5f305e6792c1c166b2a44a1e5085f42f53db50ea
Author:     Gülşah Köse <gulsah.kose at collabora.com>
AuthorDate: Sun Aug 23 22:32:53 2020 +0300
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Tue Aug 25 14:26:42 2020 +0200

    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.
    
    Change-Id: I02d19c820670df7b4d1622836156c6bf8ed1c154
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101255
    Tested-by: Jenkins
    Reviewed-by: Gülşah Köse <gulsah.kose at collabora.com>
    (cherry picked from commit 9fe881410909c5273cef517433411bc4eceee294)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101164
    Reviewed-by: Andras Timar <andras.timar at collabora.com>

diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx
index 7082cbee0186..d62aa714da50 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/beans/XPropertySet.hpp>
 #include <com/sun/star/awt/Gradient.hpp>
@@ -71,6 +72,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)
 {
@@ -748,6 +765,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 3fedf4dbb761..3e919af5be80 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -1034,6 +1034,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 && aServiceName == "com.sun.star.drawing.TableShape" )
diff --git a/sd/qa/unit/data/pptx/tdf134174.pptx b/sd/qa/unit/data/pptx/tdf134174.pptx
new file mode 100644
index 000000000000..ef722dc501a8
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf134174.pptx differ
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index cec91cfb6387..632872f40084 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -199,6 +199,7 @@ public:
     void testTdf100065();
     void testTdf90626();
     void testTdf114488();
+    void testTdf134174();
     void testTdf114913();
     void testTdf114821();
     void testTdf115394();
@@ -308,6 +309,7 @@ public:
     CPPUNIT_TEST(testTdf100065);
     CPPUNIT_TEST(testTdf90626);
     CPPUNIT_TEST(testTdf114488);
+    CPPUNIT_TEST(testTdf134174);
     CPPUNIT_TEST(testTdf114913);
     CPPUNIT_TEST(testTdf114821);
     CPPUNIT_TEST(testTdf115394);
@@ -2611,6 +2613,23 @@ void SdImportTest::testTdf114488()
     xDocShRef->DoClose();
 }
 
+void SdImportTest::testTdf134174()
+{
+    sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/tdf134174.pptx"), PPTX);
+    uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(0, 0, xDocShRef), uno::UNO_SET_THROW);
+    CPPUNIT_ASSERT(xShape.is());
+
+    uno::Reference<graphic::XGraphic> xGraphic;
+    xShape->getPropertyValue("FillBitmap") >>= xGraphic;
+    CPPUNIT_ASSERT(xGraphic.is());
+
+    Graphic aGraphic(xGraphic);
+    BitmapEx aBitmap(aGraphic.GetBitmapEx());
+    CPPUNIT_ASSERT_EQUAL( Color(9118171), aBitmap.GetPixelColor( 0, 0 ));
+
+    xDocShRef->DoClose();
+}
+
 void SdImportTest::testTdf114913()
 {
     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/tdf114913.pptx"), PPTX);


More information about the Libreoffice-commits mailing list