summaryrefslogtreecommitdiff
path: root/include/oox
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2020-09-23 23:28:30 +0200
committerTomaž Vajngerl <quikee@gmail.com>2020-09-25 18:57:46 +0200
commit3de1b009bd187afa1dd49b10644c1920641e1596 (patch)
tree0f8d41b037809f0e2fd801daada1d47a4f9b6004 /include/oox
parent0120fecc22b36a55a2a25573a7a9632319b2b0ff (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. Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103283 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> (cherry picked from commit d0efd878dc41e3913a2d91ff4b5c335c1d71a85c) Change-Id: I33dc19218c565937fab77e132b3a996c51358b6e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103407 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'include/oox')
-rw-r--r--include/oox/helper/graphichelper.hxx6
-rw-r--r--include/oox/shape/ShapeFilterBase.hxx7
2 files changed, 11 insertions, 2 deletions
diff --git a/include/oox/helper/graphichelper.hxx b/include/oox/helper/graphichelper.hxx
index 4854985d1014..d9d274b70377 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 b5b90ddafa37..35118a15d35c 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 { namespace drawingml { namespace table {
@@ -67,6 +68,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;
@@ -74,6 +80,7 @@ private:
std::shared_ptr< ::oox::drawingml::chart::ChartConverter > mxChartConv;
::oox::drawingml::ThemePtr mpTheme;
+ css::uno::Reference<css::graphic::XGraphicMapper> mxGraphicMapper;
};
} // namespace shape