diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2020-09-23 23:28:30 +0200 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2020-09-25 12:01:07 +0200 |
commit | d0efd878dc41e3913a2d91ff4b5c335c1d71a85c (patch) | |
tree | 11eec3a4e334cec5f8739e99f3bd991a1ea2f80d /include | |
parent | 40c731726b583cdb3a8884e90f17637f35aa3ef8 (diff) |
fix Graphic duplication in import and add GraphicMapper
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 <quikee@gmail.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/oox/helper/graphichelper.hxx | 6 | ||||
-rw-r--r-- | include/oox/shape/ShapeFilterBase.hxx | 7 |
2 files changed, 11 insertions, 2 deletions
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 <rtl/ustring.hxx> #include <sal/types.h> #include <com/sun/star/graphic/XGraphicProvider2.hpp> +#include <com/sun/star/graphic/XGraphicMapper.hpp> 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<css::graphic::XGraphicMapper> 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<css::graphic::XGraphicMapper> 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 <oox/vml/vmldrawing.hxx> #include <oox/core/xmlfilterbase.hxx> #include <oox/drawingml/drawingmltypes.hxx> +#include <com/sun/star/graphic/XGraphicMapper.hpp> namespace oox::drawingml::table { @@ -66,6 +67,11 @@ public: void importTheme(); + void setGraphicMapper(css::uno::Reference<css::graphic::XGraphicMapper> 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<css::graphic::XGraphicMapper> mxGraphicMapper; }; } // namespace oox::shape |