diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2020-11-20 12:03:21 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-11-20 20:46:08 +0100 |
commit | 4d0464dab81628cf7a6ea81e430091e321c034d0 (patch) | |
tree | 7d80bd6ed889fc166fbf857f94a32dc0c26a4be8 /sd | |
parent | 5893f56dc318d00385f7e201731ba3cf61c79e45 (diff) |
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/+/106281
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/CppunitTest_sd_filter_eppt.mk | 45 | ||||
-rw-r--r-- | sd/Module_sd.mk | 1 | ||||
-rw-r--r-- | sd/qa/filter/eppt/data/custom-shape-bitmap-fill.pptx | bin | 0 -> 24802 bytes | |||
-rw-r--r-- | sd/qa/filter/eppt/eppt.cxx | 86 | ||||
-rw-r--r-- | sd/source/filter/eppt/epptso.cxx | 18 |
5 files changed, 149 insertions, 1 deletions
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 Binary files differnew file mode 100644 index 000000000000..b37d7b6a8853 --- /dev/null +++ b/sd/qa/filter/eppt/data/custom-shape-bitmap-fill.pptx diff --git a/sd/qa/filter/eppt/eppt.cxx b/sd/qa/filter/eppt/eppt.cxx new file mode 100644 index 000000000000..ab08af760a6e --- /dev/null +++ b/sd/qa/filter/eppt/eppt.cxx @@ -0,0 +1,86 @@ +/* -*- 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> +#include <comphelper/processfactory.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(); + + uno::Reference<uno::XComponentContext> xComponentContext + = comphelper::getProcessComponentContext(); + mxDesktop.set(frame::Desktop::create(xComponentContext)); +} + +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 14b0fe6f1959..785a777b46a2 100644 --- a/sd/source/filter/eppt/epptso.cxx +++ b/sd/source/filter/eppt/epptso.cxx @@ -1675,6 +1675,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() ); @@ -1709,6 +1710,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" ) ) { @@ -2225,7 +2240,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 ); } |