diff options
-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 | 83 | ||||
-rw-r--r-- | sd/source/filter/eppt/epptso.cxx | 18 |
5 files changed, 146 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 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 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..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 ); } |