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 f4ba484183
(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
This commit is contained in:
parent
1bad449a6a
commit
7032be2e9e
5 changed files with 146 additions and 1 deletions
45
sd/CppunitTest_sd_filter_eppt.mk
Normal file
45
sd/CppunitTest_sd_filter_eppt.mk
Normal file
|
@ -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:
|
|
@ -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
|
||||
|
||||
|
|
BIN
sd/qa/filter/eppt/data/custom-shape-bitmap-fill.pptx
Normal file
BIN
sd/qa/filter/eppt/data/custom-shape-bitmap-fill.pptx
Normal file
Binary file not shown.
83
sd/qa/filter/eppt/eppt.cxx
Normal file
83
sd/qa/filter/eppt/eppt.cxx
Normal file
|
@ -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: */
|
|
@ -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 );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue