summaryrefslogtreecommitdiff
path: root/offapi
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 /offapi
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 'offapi')
-rw-r--r--offapi/UnoApi_offapi.mk2
-rw-r--r--offapi/com/sun/star/graphic/GraphicMapper.idl30
-rw-r--r--offapi/com/sun/star/graphic/XGraphicMapper.idl35
-rw-r--r--offapi/com/sun/star/xml/sax/XFastShapeContextHandler.idl11
4 files changed, 76 insertions, 2 deletions
diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk
index 3cbd23756281..2f9f6e266f24 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 <com/sun/star/graphic/XGraphicMapper.idl>
+
+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 <com/sun/star/graphic/XGraphic.idl>
+
+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 <com/sun/star/frame/XModel.idl>
#include <com/sun/star/io/XInputStream.idl>
#include <com/sun/star/document/XDocumentProperties.idl>
-
+#include <com/sun/star/graphic/XGraphicMapper.idl>
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);
};