diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2020-11-20 12:03:21 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-11-20 13:26:49 +0100 |
commit | 7032be2e9edd82dad2d67f1582aaa57676bda4a1 (patch) | |
tree | d98a2a0321750662247d7dfb18aa3f0caf808b0c /sd/qa | |
parent | 1bad449a6a2427a2c9d217a3f84d9b350b28c0b3 (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.
Change-Id: I7192f912077f2de026573855dbebbdf576e39ebc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106219
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'sd/qa')
-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 |
2 files changed, 83 insertions, 0 deletions
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: */ |