[Libreoffice-commits] core.git: sd/CppunitTest_sd_filter_eppt.mk sd/Module_sd.mk sd/qa sd/source

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Fri Nov 20 12:27:30 UTC 2020


 sd/CppunitTest_sd_filter_eppt.mk                     |   45 ++++++++++
 sd/Module_sd.mk                                      |    1 
 sd/qa/filter/eppt/data/custom-shape-bitmap-fill.pptx |binary
 sd/qa/filter/eppt/eppt.cxx                           |   83 +++++++++++++++++++
 sd/source/filter/eppt/epptso.cxx                     |   18 +++-
 5 files changed, 146 insertions(+), 1 deletion(-)

New commits:
commit 7032be2e9edd82dad2d67f1582aaa57676bda4a1
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Fri Nov 20 12:03:21 2020 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Fri Nov 20 13:26:49 2020 +0100

    tdf#127086 PPT export: fix lost bitmap fill for OOXML custom shapes
    
    PPT can't store an OOXML custom shape with fill bitmap, PowerPoint
    generates a fallback bitmap when saving to PPT.
    
    We used to keep the bitmap and loose the custom shape geometry, but that
    was changed with commit f4ba484183a1e7b9824f10580d633466c266828f (ooxml
    import: supprt cropping to shape, 2019-05-13).
    
    Fix the regression by going back to keeping the bitmap, a full fallback
    bitmap (ala PowerPoint), would be more work, taking e.g. blurry shadows
    (changing the shape position and size) into account.
    
    Change-Id: I7192f912077f2de026573855dbebbdf576e39ebc
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106219
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
    Tested-by: Jenkins

diff --git a/sd/CppunitTest_sd_filter_eppt.mk b/sd/CppunitTest_sd_filter_eppt.mk
new file mode 100644
index 000000000000..1a58e113643e
--- /dev/null
+++ b/sd/CppunitTest_sd_filter_eppt.mk
@@ -0,0 +1,45 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#*************************************************************************
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+#*************************************************************************
+
+$(eval $(call gb_CppunitTest_CppunitTest,sd_filter_eppt))
+
+$(eval $(call gb_CppunitTest_use_externals,sd_filter_eppt,\
+	boost_headers \
+))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,sd_filter_eppt, \
+    sd/qa/filter/eppt/eppt \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,sd_filter_eppt, \
+    comphelper \
+    cppu \
+    sdfilt \
+    sal \
+    test \
+    unotest \
+    utl \
+))
+
+$(eval $(call gb_CppunitTest_use_sdk_api,sd_filter_eppt))
+
+$(eval $(call gb_CppunitTest_use_ure,sd_filter_eppt))
+$(eval $(call gb_CppunitTest_use_vcl,sd_filter_eppt))
+
+$(eval $(call gb_CppunitTest_use_rdb,sd_filter_eppt,services))
+
+$(eval $(call gb_CppunitTest_use_custom_headers,sd_filter_eppt,\
+	officecfg/registry \
+))
+
+$(eval $(call gb_CppunitTest_use_configuration,sd_filter_eppt))
+
+# vim: set noet sw=4 ts=4:
diff --git a/sd/Module_sd.mk b/sd/Module_sd.mk
index 7ded538d3be0..2aa512f0fa29 100644
--- a/sd/Module_sd.mk
+++ b/sd/Module_sd.mk
@@ -41,6 +41,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,sd,\
     CppunitTest_sd_html_export_tests \
     CppunitTest_sd_activex_controls_tests \
     CppunitTest_sd_pdf_import_test \
+    CppunitTest_sd_filter_eppt \
 ))
 endif
 
diff --git a/sd/qa/filter/eppt/data/custom-shape-bitmap-fill.pptx b/sd/qa/filter/eppt/data/custom-shape-bitmap-fill.pptx
new file mode 100644
index 000000000000..b37d7b6a8853
Binary files /dev/null and b/sd/qa/filter/eppt/data/custom-shape-bitmap-fill.pptx differ
diff --git a/sd/qa/filter/eppt/eppt.cxx b/sd/qa/filter/eppt/eppt.cxx
new file mode 100644
index 000000000000..d1d7cdd029c3
--- /dev/null
+++ b/sd/qa/filter/eppt/eppt.cxx
@@ -0,0 +1,83 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/bootstrapfixture.hxx>
+#include <unotest/macros_test.hxx>
+
+#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
+#include <com/sun/star/frame/Desktop.hpp>
+#include <com/sun/star/frame/XStorable.hpp>
+
+#include <unotools/mediadescriptor.hxx>
+#include <unotools/tempfile.hxx>
+
+using namespace ::com::sun::star;
+
+namespace
+{
+/// Covers sd/source/filter/eppt/ fixes.
+class Test : public test::BootstrapFixture, public unotest::MacrosTest
+{
+private:
+    uno::Reference<lang::XComponent> mxComponent;
+
+public:
+    void setUp() override;
+    void tearDown() override;
+    uno::Reference<lang::XComponent>& getComponent() { return mxComponent; }
+};
+
+void Test::setUp()
+{
+    test::BootstrapFixture::setUp();
+
+    mxDesktop.set(frame::Desktop::create(mxComponentContext));
+}
+
+void Test::tearDown()
+{
+    if (mxComponent.is())
+        mxComponent->dispose();
+
+    test::BootstrapFixture::tearDown();
+}
+
+char const DATA_DIRECTORY[] = "/sd/qa/filter/eppt/data/";
+
+CPPUNIT_TEST_FIXTURE(Test, testOOXMLCustomShapeBitmapFill)
+{
+    // Save the bugdoc to PPT.
+    OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "custom-shape-bitmap-fill.pptx";
+    getComponent() = loadFromDesktop(aURL);
+    utl::TempFile aTempFile;
+    aTempFile.EnableKillingFile();
+    uno::Reference<frame::XStorable> xStorable(getComponent(), uno::UNO_QUERY);
+    utl::MediaDescriptor aMediaDescriptor;
+    aMediaDescriptor["FilterName"] <<= OUString("MS PowerPoint 97");
+    xStorable->storeToURL(aTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList());
+    getComponent()->dispose();
+    getComponent() = loadFromDesktop(aTempFile.GetURL());
+
+    // Check if the bitmap shape was lost.
+    uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(getComponent(), uno::UNO_QUERY);
+    uno::Reference<drawing::XDrawPages> xDrawPages = xDrawPagesSupplier->getDrawPages();
+    uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPages->getByIndex(0), uno::UNO_QUERY);
+    uno::Reference<drawing::XShape> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
+    // Without the accompanying fix in place, this test would have failed with:
+    // - Expected: com.sun.star.drawing.GraphicObjectShape
+    // - Actual  : com.sun.star.drawing.CustomShape
+    // i.e. the custom shape geometry was kept, but the actual bitmap was lost.
+    CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.drawing.GraphicObjectShape"),
+                         xShape->getShapeType());
+}
+}
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/filter/eppt/epptso.cxx b/sd/source/filter/eppt/epptso.cxx
index 92ee21a6f5c6..b17dc66364e9 100644
--- a/sd/source/filter/eppt/epptso.cxx
+++ b/sd/source/filter/eppt/epptso.cxx
@@ -1666,6 +1666,7 @@ void PPTWriter::ImplWritePage( const PHLayout& rLayout, EscherSolverContainer& a
             bool bClosedBezier = mType == "drawing.ClosedBezier";
             bool bPolyPolygon  = mType == "drawing.PolyPolygon";
             bool bPolyLine = mType == "drawing.PolyLine";
+            OUString aGraphicPropertyName("Graphic");
 
             const css::awt::Size   aSize100thmm( mXShape->getSize() );
             const css::awt::Point  aPoint100thmm( mXShape->getPosition() );
@@ -1700,6 +1701,20 @@ void PPTWriter::ImplWritePage( const PHLayout& rLayout, EscherSolverContainer& a
                     css::drawing::FillStyle eFS;
                     aAny >>= eFS;
                     bIsHatching = eFS == css::drawing::FillStyle_HATCH;
+                    if (mType == "drawing.Custom" && eFS == drawing::FillStyle_BITMAP)
+                    {
+                        ShapeFlag nMirrorFlags;
+                        OUString sCustomShapeType;
+                        MSO_SPT eShapeType = EscherPropertyContainer::GetCustomShapeType(
+                            mXShape, nMirrorFlags, sCustomShapeType);
+                        if (eShapeType == mso_sptMax)
+                        {
+                            // We can't map this custom shape to a PPT preset and it has a bitmap
+                            // fill. Make sure that at least the bitmap fill is not lost.
+                            mType = "drawing.GraphicObject";
+                            aGraphicPropertyName = "FillBitmap";
+                        }
+                    }
                 }
                 if ( bIsHatching || bIsFontwork || ( mType == "drawing.Measure" ) || ( mType == "drawing.Caption" ) )
                 {
@@ -2216,7 +2231,8 @@ void PPTWriter::ImplWritePage( const PHLayout& rLayout, EscherSolverContainer& a
                                          ShapeFlag::HaveAnchor | ShapeFlag::HaveShapeProperty,
                                          aSolverContainer );
 
-                        if ( aPropOpt.CreateGraphicProperties( mXPropSet, "Graphic", false, true ) )
+                        if (aPropOpt.CreateGraphicProperties(mXPropSet, aGraphicPropertyName, false,
+                                                             true))
                         {
                             aPropOpt.AddOpt( ESCHER_Prop_LockAgainstGrouping, 0x800080 );
                         }


More information about the Libreoffice-commits mailing list