From d0efd878dc41e3913a2d91ff4b5c335c1d71a85c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toma=C5=BE=20Vajngerl?= Date: Wed, 23 Sep 2020 23:28:30 +0200 Subject: [PATCH] fix Graphic duplication in import and add GraphicMapper MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When importing writerfilter, we change to oox when importing images. This transition doesn't store any previous contexts and all instances are reset. The problem occurs when we have identical images because the transition erases all caches we have to determine if an image has already been imported or not, which causes that we import the same image multiple times which create unnecessary copies. This introduces the XGraphicMapper, which can be used to store the XGraphic for a key and can be transferred between writerfilter to oox. With this we can remember which images were already imported and don't create unnecessary internal copies which decreases memory. This also includes a test which checks that the import and export doesn't produce unnecessary copies of identical images. The test checks that for OOXML, ODF and MS Binary formats. Change-Id: I33dc19218c565937fab77e132b3a996c51358b6e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103283 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl --- include/oox/helper/graphichelper.hxx | 6 +- include/oox/shape/ShapeFilterBase.hxx | 7 ++ offapi/UnoApi_offapi.mk | 2 + offapi/com/sun/star/graphic/GraphicMapper.idl | 30 ++++++ .../com/sun/star/graphic/XGraphicMapper.idl | 35 +++++++ .../star/xml/sax/XFastShapeContextHandler.idl | 11 ++- oox/source/helper/graphichelper.cxx | 52 ++++++++--- oox/source/shape/ShapeContextHandler.cxx | 6 ++ oox/source/shape/ShapeContextHandler.hxx | 2 + oox/source/shape/ShapeFilterBase.cxx | 5 +- .../data/multiple_identical_graphics.odt | Bin 0 -> 13826 bytes sw/qa/extras/globalfilter/globalfilter.cxx | 83 +++++++++++++++++ vcl/Library_vcl.mk | 1 + vcl/source/graphic/UnoGraphicMapper.cxx | 87 ++++++++++++++++++ vcl/vcl.common.component | 4 + .../source/ooxml/OOXMLDocumentImpl.cxx | 2 + .../source/ooxml/OOXMLDocumentImpl.hxx | 9 ++ .../source/ooxml/OOXMLFastContextHandler.cxx | 5 + 18 files changed, 331 insertions(+), 16 deletions(-) create mode 100644 offapi/com/sun/star/graphic/GraphicMapper.idl create mode 100644 offapi/com/sun/star/graphic/XGraphicMapper.idl create mode 100644 sw/qa/extras/globalfilter/data/multiple_identical_graphics.odt create mode 100644 vcl/source/graphic/UnoGraphicMapper.cxx diff --git a/include/oox/helper/graphichelper.hxx b/include/oox/helper/graphichelper.hxx index 301bc37e27af..9a99647589b2 100644 --- a/include/oox/helper/graphichelper.hxx +++ b/include/oox/helper/graphichelper.hxx @@ -31,6 +31,7 @@ #include #include #include +#include struct WmfExternal; @@ -133,9 +134,10 @@ public: @return The original Graphic size in 100thmm */ css::awt::Size getOriginalSize( const css::uno::Reference< css::graphic::XGraphic >& rxGraphic ) const; + void setGraphicMapper(css::uno::Reference const & rxGraphicMapper); + void initializeGraphicMapperIfNeeded() const; private: - typedef ::std::map< OUString, css::uno::Reference< css::graphic::XGraphic > > EmbeddedGraphicMap; css::uno::Reference< css::uno::XComponentContext > mxContext; css::uno::Reference< css::graphic::XGraphicProvider2 > mxGraphicProvider; @@ -143,9 +145,9 @@ private: css::awt::DeviceInfo maDeviceInfo; ///< Current output device info. ::std::map< sal_Int32, ::Color > maSystemPalette; ///< Maps system colors (XML tokens) to RGB color values. StorageRef mxStorage; ///< Storage containing embedded graphics. - mutable EmbeddedGraphicMap maEmbeddedGraphics; ///< Maps all embedded graphics by their storage path. double mfPixelPerHmmX; ///< Number of screen pixels per 1/100 mm in X direction. double mfPixelPerHmmY; ///< Number of screen pixels per 1/100 mm in Y direction. + css::uno::Reference mxGraphicMapper; }; diff --git a/include/oox/shape/ShapeFilterBase.hxx b/include/oox/shape/ShapeFilterBase.hxx index fc4c8f7836f7..bfd5cea6d16e 100644 --- a/include/oox/shape/ShapeFilterBase.hxx +++ b/include/oox/shape/ShapeFilterBase.hxx @@ -25,6 +25,7 @@ #include #include #include +#include namespace oox::drawingml::table { @@ -66,6 +67,11 @@ public: void importTheme(); + void setGraphicMapper(css::uno::Reference const & rxGraphicMapper) + { + mxGraphicMapper = rxGraphicMapper; + } + private: virtual ::oox::ole::VbaProject* implCreateVbaProject() const override; virtual OUString SAL_CALL getImplementationName() override; @@ -73,6 +79,7 @@ private: std::shared_ptr< ::oox::drawingml::chart::ChartConverter > mxChartConv; ::oox::drawingml::ThemePtr mpTheme; + css::uno::Reference mxGraphicMapper; }; } // namespace oox::shape diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk index 23138250b9d4..0eaefbcca348 100644 --- a/offapi/UnoApi_offapi.mk +++ b/offapi/UnoApi_offapi.mk @@ -210,6 +210,7 @@ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,com/sun/star/frame,\ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,com/sun/star/graphic,\ GraphicObject \ GraphicProvider \ + GraphicMapper \ Primitive2DTools \ SvgTools \ EmfTools \ @@ -2719,6 +2720,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/graphic,\ XGraphicRasterizer \ XGraphicRenderer \ XGraphicTransformer \ + XGraphicMapper \ XPrimitive2D \ XPrimitive2DRenderer \ XPrimitive3D \ diff --git a/offapi/com/sun/star/graphic/GraphicMapper.idl b/offapi/com/sun/star/graphic/GraphicMapper.idl new file mode 100644 index 000000000000..f74abd45ff62 --- /dev/null +++ b/offapi/com/sun/star/graphic/GraphicMapper.idl @@ -0,0 +1,30 @@ +/* -*- 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/. + * + */ + +#ifndef com_sun_star_graphic_GraphicMapper_idl +#define com_sun_star_graphic_GraphicMapper_idl + +#include + +module com { module sun { module star { module graphic +{ + +/** implementation of the XGraphicMapper interface + + @see XGraphicMapper + @since LibreOffice 7.1 +*/ +service GraphicMapper : XGraphicMapper; + +} ; } ; } ; } ; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/offapi/com/sun/star/graphic/XGraphicMapper.idl b/offapi/com/sun/star/graphic/XGraphicMapper.idl new file mode 100644 index 000000000000..f1c933b12e38 --- /dev/null +++ b/offapi/com/sun/star/graphic/XGraphicMapper.idl @@ -0,0 +1,35 @@ +/* -*- 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/. + */ + +#ifndef com_sun_star_graphic_XGraphicCache_idl +#define com_sun_star_graphic_XGraphicCache_idl + +#include + +module com { module sun { module star { module graphic +{ + +/** This interface allows mapping of XGraphics for a certain string key + + @since LibreOffice 7.1 + */ +interface XGraphicMapper +{ + /** Find if we have the XGraphic for the certain key */ + com::sun::star::graphic::XGraphic findGraphic([in] string Id); + + /** Insert a new entry to map an id/key to the XGraphic */ + void putGraphic([in] string Id, [in] com::sun::star::graphic::XGraphic Graphic); +}; + +}; }; }; }; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/offapi/com/sun/star/xml/sax/XFastShapeContextHandler.idl b/offapi/com/sun/star/xml/sax/XFastShapeContextHandler.idl index 301971a2141d..1475db6479b1 100644 --- a/offapi/com/sun/star/xml/sax/XFastShapeContextHandler.idl +++ b/offapi/com/sun/star/xml/sax/XFastShapeContextHandler.idl @@ -1,4 +1,4 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ + /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * @@ -25,7 +25,7 @@ #include #include #include - +#include module com { module sun { module star { module xml { module sax { @@ -45,6 +45,13 @@ interface XFastShapeContextHandler: com::sun::star::xml::sax::XFastContextHandle [attribute] com::sun::star::awt::Point Position; [attribute] com::sun::star::document::XDocumentProperties DocumentProperties; [attribute] sequence< com::sun::star::beans::PropertyValue > MediaDescriptor; + + /** Graphic mapper to map a key/id string to a XGraphic. This is needed to + remember for XGraphics for a path in the document storage + + @since LibreOffice 7.1 + */ + void setGraphicMapper([in] com::sun::star::graphic::XGraphicMapper xGraphicMapper); }; diff --git a/oox/source/helper/graphichelper.cxx b/oox/source/helper/graphichelper.cxx index 85490fb43a8e..e8a1c94326a7 100644 --- a/oox/source/helper/graphichelper.cxx +++ b/oox/source/helper/graphichelper.cxx @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -316,16 +317,24 @@ void GraphicHelper::importEmbeddedGraphics(const std::vector& rStreamN std::vector aMissingStreamNames; std::vector< uno::Reference > aMissingStreams; + initializeGraphicMapperIfNeeded(); + + SAL_WARN_IF(!mxGraphicMapper.is(), "oox", "GraphicHelper::importEmbeddedGraphic - graphic mapper not available"); + for (const auto& rStreamName : rStreamNames) { - if(rStreamName.isEmpty()) + + if (rStreamName.isEmpty()) { SAL_WARN("oox", "GraphicHelper::importEmbeddedGraphics - empty stream name"); continue; } - EmbeddedGraphicMap::const_iterator aIt = maEmbeddedGraphics.find(rStreamName); - if (aIt == maEmbeddedGraphics.end()) + Reference xGraphic; + + xGraphic = mxGraphicMapper->findGraphic(rStreamName); + + if (!xGraphic.is()) { aMissingStreamNames.push_back(rStreamName); aMissingStreams.push_back(mxStorage->openInputStream(rStreamName)); @@ -334,11 +343,14 @@ void GraphicHelper::importEmbeddedGraphics(const std::vector& rStreamN std::vector< uno::Reference > aGraphics = importGraphics(aMissingStreams); + assert(aGraphics.size() == aMissingStreamNames.size()); for (size_t i = 0; i < aGraphics.size(); ++i) { if (aGraphics[i].is()) - maEmbeddedGraphics[aMissingStreamNames[i]] = aGraphics[i]; + { + mxGraphicMapper->putGraphic(aMissingStreamNames[i], aGraphics[i]); + } } } @@ -346,22 +358,26 @@ Reference< XGraphic > GraphicHelper::importEmbeddedGraphic( const OUString& rStr { Reference< XGraphic > xGraphic; OSL_ENSURE( !rStreamName.isEmpty(), "GraphicHelper::importEmbeddedGraphic - empty stream name" ); + if( !rStreamName.isEmpty() ) { - EmbeddedGraphicMap::const_iterator aIt = maEmbeddedGraphics.find( rStreamName ); - if( aIt == maEmbeddedGraphics.end() ) + initializeGraphicMapperIfNeeded(); + + SAL_WARN_IF(!mxGraphicMapper.is(), "oox", "GraphicHelper::importEmbeddedGraphic - graphic mapper not available"); + + xGraphic = mxGraphicMapper->findGraphic(rStreamName); + if (!xGraphic.is()) { // Lazy-loading doesn't work with TIFF or WMF at the moment. WmfExternal aHeader; if ( (rStreamName.endsWith(".tiff") || rStreamName.endsWith(".wmf") ) && !pExtHeader) pExtHeader = &aHeader; - xGraphic = importGraphic(mxStorage->openInputStream(rStreamName), pExtHeader); - if( xGraphic.is() ) - maEmbeddedGraphics[ rStreamName ] = xGraphic; + auto xStream = mxStorage->openInputStream(rStreamName); + xGraphic = importGraphic(xStream, pExtHeader); + if (xGraphic.is()) + mxGraphicMapper->putGraphic(rStreamName, xGraphic); } - else - xGraphic = aIt->second; } return xGraphic; } @@ -379,6 +395,20 @@ awt::Size GraphicHelper::getOriginalSize( const Reference< XGraphic >& xGraphic return aSizeHmm; } +void GraphicHelper::setGraphicMapper(css::uno::Reference const & rGraphicMapper) +{ + mxGraphicMapper = rGraphicMapper; +} + +void GraphicHelper::initializeGraphicMapperIfNeeded() const +{ + if (!mxGraphicMapper.is()) + { + auto* pNonConstThis = const_cast(this); + pNonConstThis->mxGraphicMapper = graphic::GraphicMapper::create(mxContext); + } +} + } // namespace oox /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/shape/ShapeContextHandler.cxx b/oox/source/shape/ShapeContextHandler.cxx index 0684814bc7cc..c1cc28129eb0 100644 --- a/oox/source/shape/ShapeContextHandler.cxx +++ b/oox/source/shape/ShapeContextHandler.cxx @@ -593,6 +593,12 @@ void SAL_CALL ShapeContextHandler::setMediaDescriptor(const uno::Sequence const & rxGraphicMapper) +{ + auto pShapeFilterBase = static_cast(mxFilterBase.get()); + pShapeFilterBase->setGraphicMapper(rxGraphicMapper); +} + OUString ShapeContextHandler::getImplementationName() { return "com.sun.star.comp.oox.ShapeContextHandler"; diff --git a/oox/source/shape/ShapeContextHandler.hxx b/oox/source/shape/ShapeContextHandler.hxx index abda9c94a913..a633fac2f028 100644 --- a/oox/source/shape/ShapeContextHandler.hxx +++ b/oox/source/shape/ShapeContextHandler.hxx @@ -119,6 +119,8 @@ public: virtual css::uno::Sequence SAL_CALL getMediaDescriptor() override; virtual void SAL_CALL setMediaDescriptor(const css::uno::Sequence& rMediaDescriptor) override; + void SAL_CALL setGraphicMapper(css::uno::Reference const & rGraphicMapper) override; + private: ShapeContextHandler(ShapeContextHandler const &) = delete; void operator =(ShapeContextHandler const &) = delete; diff --git a/oox/source/shape/ShapeFilterBase.cxx b/oox/source/shape/ShapeFilterBase.cxx index 6505b91a16e5..33c9da8bb0ed 100644 --- a/oox/source/shape/ShapeFilterBase.cxx +++ b/oox/source/shape/ShapeFilterBase.cxx @@ -104,7 +104,10 @@ ShapeGraphicHelper::ShapeGraphicHelper( const ShapeFilterBase& rFilter ) : GraphicHelper* ShapeFilterBase::implCreateGraphicHelper() const { - return new ShapeGraphicHelper( *this ); + GraphicHelper* pGraphicHelper = new ShapeGraphicHelper(*this); + if (mxGraphicMapper.is()) + pGraphicHelper->setGraphicMapper(mxGraphicMapper); + return pGraphicHelper; } ::Color ShapeFilterBase::getSchemeColor( sal_Int32 nToken ) const diff --git a/sw/qa/extras/globalfilter/data/multiple_identical_graphics.odt b/sw/qa/extras/globalfilter/data/multiple_identical_graphics.odt new file mode 100644 index 0000000000000000000000000000000000000000..20f40798edfe6ce786ce683c07274449b99f7d41 GIT binary patch literal 13826 zcmbWe1y~%*);2n52=2ilgS)%Cy9Rf+;2K zbTl(^bhNcHF>R@kfW#Q`dFBoSQMk5m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T;kD1T1I_-CBI_6Z&G ze_xwFk~97X<#(j{=gfm&Wbr>l>ILQBE6Yo=#_vJ=Tl3EZ^k10?e@NI1G43T<=wEpX z|Ecw7I^JK~Yk66-|4dc?t@(TP{!hBzAMI_t0R0nr?>EYCtN$Ex|9TtvhYXVZ`Q6}u z>iyZP{EEo`5MS!Q#OJ>if1CZEPUjEB>0e?0{~s6hyNTa@`tt(y%Q5^R2`{9_zjYHz VvM|5A76AR_Gw`ymkum=|`#%e> + lcl_getGraphics(const uno::Reference& xComponent) +{ + std::vector> aGraphics; + uno::Reference xShape; + + uno::Reference xDrawPageSupplier(xComponent, uno::UNO_QUERY); + uno::Reference xDrawPage = xDrawPageSupplier->getDrawPage(); + for (sal_Int32 i = 0; i < xDrawPage->getCount(); ++i) + { + uno::Reference xShapeProperties(xDrawPage->getByIndex(i), uno::UNO_QUERY); + uno::Reference xGraphic; + xShapeProperties->getPropertyValue("Graphic") >>= xGraphic; + if (xGraphic.is()) + { + aGraphics.push_back(xGraphic); + } + } + + return aGraphics; +} + +} + +void Test::testMultipleIdenticalGraphics() +{ + // We have multiple identical graphics. When we save them we want + // them to be saved de-duplicated and the same should still be true + // after loading them again. This test check that the de-duplication + // works as expected. + + const OUString aFilterNames[] { + "writer8", + //"Rich Text Format", // doesn't work correctly for now + "MS Word 97", + "Office Open XML Text", + }; + + for (OUString const & rFilterName : aFilterNames) + { + if (mxComponent.is()) + mxComponent->dispose(); + + mxComponent = loadFromDesktop(m_directories.getURLFromSrc("/sw/qa/extras/globalfilter/data/multiple_identical_graphics.odt"), "com.sun.star.text.TextDocument"); + + // Export the document and import again for a check + utl::MediaDescriptor aMediaDescriptor; + aMediaDescriptor["FilterName"] <<= rFilterName; + utl::TempFile aTempFile; + aTempFile.EnableKillingFile(); + uno::Reference xStorable(mxComponent, uno::UNO_QUERY); + xStorable->storeToURL(aTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList()); + mxComponent->dispose(); + + mxComponent = loadFromDesktop(aTempFile.GetURL(), "com.sun.star.text.TextDocument"); + + // Check whether graphic exported well + const OString sFailedMessage = OStringLiteral("Failed on filter: ") + rFilterName.toUtf8(); + auto aGraphics = lcl_getGraphics(mxComponent); + + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), size_t(5), aGraphics.size()); + + // Get all GfxLink addresses, we expect all of them to be the same + // indicating we use the same graphic instance for all shapes + std::vector aGfxLinkAddresses; + for (auto const & rxGraphic : aGraphics) + { + GfxLink* pLink = Graphic(rxGraphic).GetSharedGfxLink().get(); + aGfxLinkAddresses.emplace_back(reinterpret_cast(pLink)); + } + + // Check all addresses are the same + bool bResult = std::equal(aGfxLinkAddresses.begin() + 1, aGfxLinkAddresses.end(), aGfxLinkAddresses.begin()); + const OString sGraphicNotTheSameFailedMessage = OStringLiteral("Graphics not the same for filter: '") + rFilterName.toUtf8() + OStringLiteral("'"); + CPPUNIT_ASSERT_EQUAL_MESSAGE(sGraphicNotTheSameFailedMessage.getStr(), true, bResult); + } +} + void Test::testCharHighlightBody() { // MS Word has two kind of character backgrounds called character shading and highlighting diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk index ac63bb3606b7..ee68260fbd50 100644 --- a/vcl/Library_vcl.mk +++ b/vcl/Library_vcl.mk @@ -330,6 +330,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\ vcl/source/graphic/grfattr \ vcl/source/graphic/Manager \ vcl/source/graphic/UnoGraphic \ + vcl/source/graphic/UnoGraphicMapper \ vcl/source/graphic/UnoGraphicDescriptor \ vcl/source/graphic/UnoGraphicObject \ vcl/source/graphic/UnoGraphicProvider \ diff --git a/vcl/source/graphic/UnoGraphicMapper.cxx b/vcl/source/graphic/UnoGraphicMapper.cxx new file mode 100644 index 000000000000..6bde78097681 --- /dev/null +++ b/vcl/source/graphic/UnoGraphicMapper.cxx @@ -0,0 +1,87 @@ +/* -*- 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 +#include +#include +#include +#include +#include +#include + +#include +#include + +using namespace css; + +namespace +{ +class GraphicMapper : public cppu::WeakImplHelper +{ +private: + std::unordered_map> maGraphicMap; + +public: + GraphicMapper() = default; + +protected: + // XServiceInfo + OUString SAL_CALL getImplementationName() override + { + return "com.sun.star.comp.graphic.GraphicMapper"; + } + sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override + { + return cppu::supportsService(this, ServiceName); + } + css::uno::Sequence SAL_CALL getSupportedServiceNames() override + { + return { "com.sun.star.graphic.GraphicMapper" }; + } + + // XTypeProvider + css::uno::Sequence SAL_CALL getTypes() override + { + static const uno::Sequence aTypes{ + cppu::UnoType::get(), cppu::UnoType::get(), + cppu::UnoType::get() + }; + return aTypes; + } + css::uno::Sequence SAL_CALL getImplementationId() override + { + return css::uno::Sequence(); + } + + // XGraphicMapper + css::uno::Reference SAL_CALL findGraphic(const OUString& rId) override + { + auto aIterator = maGraphicMap.find(rId); + + if (aIterator == maGraphicMap.end()) + return css::uno::Reference(); + + return aIterator->second; + } + void SAL_CALL putGraphic(const OUString& rId, + css::uno::Reference const& rGraphic) override + { + maGraphicMap.emplace(rId, rGraphic); + } +}; +} + +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +com_sun_star_comp_graphic_GraphicMapper_get_implementation(css::uno::XComponentContext*, + css::uno::Sequence const&) +{ + return cppu::acquire(new GraphicMapper); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/vcl.common.component b/vcl/vcl.common.component index a884f6bd8c2e..2665a136afcc 100644 --- a/vcl/vcl.common.component +++ b/vcl/vcl.common.component @@ -27,6 +27,10 @@ constructor="com_sun_star_graphic_GraphicObject_get_implementation"> + + + diff --git a/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx b/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx index db4990cc6497..fba694b5b77b 100644 --- a/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx +++ b/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx @@ -23,6 +23,7 @@ #include #include #include +#include #include #include "OOXMLStreamImpl.hxx" #include "OOXMLDocumentImpl.hxx" @@ -60,6 +61,7 @@ OOXMLDocumentImpl::OOXMLDocumentImpl(OOXMLStream::Pointer_t const & pStream, con , mnProgressEndPos(0) , m_rBaseURL(utl::MediaDescriptor(rDescriptor).getUnpackedValueOrDefault("DocumentBaseURL", OUString())) , maMediaDescriptor(rDescriptor) + , mxGraphicMapper(graphic::GraphicMapper::create(mpStream->getContext())) { pushShapeContext(); } diff --git a/writerfilter/source/ooxml/OOXMLDocumentImpl.hxx b/writerfilter/source/ooxml/OOXMLDocumentImpl.hxx index efaefd5f7d2a..1848f8971766 100644 --- a/writerfilter/source/ooxml/OOXMLDocumentImpl.hxx +++ b/writerfilter/source/ooxml/OOXMLDocumentImpl.hxx @@ -22,6 +22,7 @@ #include #include +#include #include "OOXMLPropertySet.hxx" @@ -63,6 +64,8 @@ class OOXMLDocumentImpl : public OOXMLDocument /// DocumentBaseURL OUString m_rBaseURL; css::uno::Sequence maMediaDescriptor; + /// Graphic mapper + css::uno::Reference mxGraphicMapper; private: void resolveFastSubStream(Stream & rStream, @@ -134,7 +137,13 @@ public: bool IsSkipImages() const { return mbSkipImages; }; OUString const& GetDocumentBaseURL() const { return m_rBaseURL; }; const css::uno::Sequence& getMediaDescriptor() const; + + const css::uno::Reference& getGraphicMapper() const + { + return mxGraphicMapper; + } }; + } #endif // OOXML_DOCUMENT_IMPL_HXX diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx index 938cbdf88812..104d3ad6a660 100644 --- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx +++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx @@ -1670,6 +1670,11 @@ void OOXMLFastContextHandlerShape::setToken(Token_t nToken) mrShapeContext->setRelationFragmentPath(mpParserState->getTarget()); + auto xGraphicMapper = getDocument()->getGraphicMapper(); + + if (xGraphicMapper.is()) + mrShapeContext->setGraphicMapper(xGraphicMapper); + OOXMLFastContextHandler::setToken(nToken); if (mrShapeContext.is())