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 e403d8416ade9aeaf86468a3e1413677026d9dce Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Fri Nov 20 12:03:21 2020 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Fri Nov 20 21:30:51 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. (cherry picked from commit 7032be2e9edd82dad2d67f1582aaa57676bda4a1) Change-Id: I7192f912077f2de026573855dbebbdf576e39ebc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106264 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> 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 d5c6b2ecab23..3da4952cc947 100644 --- a/sd/Module_sd.mk +++ b/sd/Module_sd.mk @@ -40,6 +40,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 2f1b959e00df..b29c9c9d9e5f 100644 --- a/sd/source/filter/eppt/epptso.cxx +++ b/sd/source/filter/eppt/epptso.cxx @@ -1665,6 +1665,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() ); @@ -1699,6 +1700,20 @@ void PPTWriter::ImplWritePage( const PHLayout& rLayout, EscherSolverContainer& a { 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" ) ) { @@ -2215,7 +2230,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 ); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits