[Libreoffice-commits] core.git: Branch 'libreoffice-6-0' - 3 commits - filter/source sw/CppunitTest_sw_fodfexport.mk sw/Module_sw.mk sw/qa xmloff/source
Samuel Mehrbrodt
Samuel.Mehrbrodt at cib.de
Mon Dec 4 08:21:01 UTC 2017
filter/source/xslt/odf2xhtml/export/xhtml/body.xsl | 41 ++++++++-------
sw/CppunitTest_sw_fodfexport.mk | 57 +++++++++++++++++++++
sw/Module_sw.mk | 1
sw/qa/extras/fodfexport/data/tdf113696.odt |binary
sw/qa/extras/fodfexport/fodfexport.cxx | 44 ++++++++++++++++
sw/qa/extras/inc/swmodeltestbase.hxx | 11 ++++
xmloff/source/draw/shapeexport.cxx | 8 ++
7 files changed, 144 insertions(+), 18 deletions(-)
New commits:
commit b89834591f83058649dfa839297346ccc6ed689d
Author: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
Date: Thu Nov 30 10:28:33 2017 +0100
Unit test for tdf#113696
Change-Id: I566cd5d38cf86547b664f0ae9a1c2f8c37edc0ca
Reviewed-on: https://gerrit.libreoffice.org/45560
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
Reviewed-on: https://gerrit.libreoffice.org/45680
diff --git a/sw/CppunitTest_sw_fodfexport.mk b/sw/CppunitTest_sw_fodfexport.mk
new file mode 100644
index 000000000000..4703b85435f7
--- /dev/null
+++ b/sw/CppunitTest_sw_fodfexport.mk
@@ -0,0 +1,57 @@
+# -*- 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,sw_fodfexport))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,sw_fodfexport, \
+ sw/qa/extras/fodfexport/fodfexport \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,sw_fodfexport, \
+ comphelper \
+ cppu \
+ cppuhelper \
+ sal \
+ sfx \
+ sw \
+ test \
+ tl \
+ unotest \
+ utl \
+ vcl \
+))
+
+$(eval $(call gb_CppunitTest_use_externals,sw_fodfexport,\
+ boost_headers \
+ libxml2 \
+))
+
+$(eval $(call gb_CppunitTest_set_include,sw_fodfexport,\
+ -I$(SRCDIR)/sw/inc \
+ -I$(SRCDIR)/sw/source/core/inc \
+ -I$(SRCDIR)/sw/qa/extras/inc \
+ $$(INCLUDE) \
+))
+
+$(eval $(call gb_CppunitTest_use_sdk_api,sw_fodfexport))
+
+$(eval $(call gb_CppunitTest_use_ure,sw_fodfexport))
+$(eval $(call gb_CppunitTest_use_vcl,sw_fodfexport))
+
+$(eval $(call gb_CppunitTest_use_rdb,sw_fodfexport,services))
+
+$(eval $(call gb_CppunitTest_use_custom_headers,sw_fodfexport,\
+ officecfg/registry \
+))
+
+$(eval $(call gb_CppunitTest_use_configuration,sw_fodfexport))
+
+# vim: set noet sw=4 ts=4:
diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk
index 39772b8b930e..966c71d097fd 100644
--- a/sw/Module_sw.mk
+++ b/sw/Module_sw.mk
@@ -52,6 +52,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,sw,\
$(if $(and $(filter $(COM),MSC),$(MERGELIBS)),, \
CppunitTest_sw_uwriter) \
CppunitTest_sw_docbookexport \
+ CppunitTest_sw_fodfexport \
CppunitTest_sw_htmlexport \
CppunitTest_sw_htmlimport \
CppunitTest_sw_macros_test \
diff --git a/sw/qa/extras/fodfexport/data/tdf113696.odt b/sw/qa/extras/fodfexport/data/tdf113696.odt
new file mode 100644
index 000000000000..03e0612a3d14
Binary files /dev/null and b/sw/qa/extras/fodfexport/data/tdf113696.odt differ
diff --git a/sw/qa/extras/fodfexport/fodfexport.cxx b/sw/qa/extras/fodfexport/fodfexport.cxx
new file mode 100644
index 000000000000..6cd00b49ba47
--- /dev/null
+++ b/sw/qa/extras/fodfexport/fodfexport.cxx
@@ -0,0 +1,44 @@
+/* -*- 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 <swmodeltestbase.hxx>
+
+class Test : public SwModelTestBase
+{
+public:
+ Test()
+ : SwModelTestBase("/sw/qa/extras/fodfexport/data/", "OpenDocument Text Flat XML")
+ {
+ }
+
+ /**
+ * Blacklist handling
+ */
+ bool mustTestImportOf(const char* filename) const override
+ {
+ // Only test import of .fodt document
+ return OString(filename).endsWith(".odt") || OString(filename).endsWith(".fodt");
+ }
+};
+
+DECLARE_FODFEXPORT_TEST(testTdf113696, "tdf113696.odt")
+{
+ // Test that an image which is written in svm format (image/x-vclgraphic)
+ // is accompanied by a png fallback graphic.
+ if (xmlDocPtr pXmlDoc = parseExportedFile())
+ {
+ assertXPath(pXmlDoc, "/office:document/office:body/office:text/text:p/draw:frame/"
+ "draw:image[@loext:mime-type='image/x-vclgraphic']");
+ assertXPath(pXmlDoc, "/office:document/office:body/office:text/text:p/draw:frame/"
+ "draw:image[@loext:mime-type='image/png']");
+ }
+}
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/extras/inc/swmodeltestbase.hxx b/sw/qa/extras/inc/swmodeltestbase.hxx
index 3d791eca7a47..4d5ff8dae901 100644
--- a/sw/qa/extras/inc/swmodeltestbase.hxx
+++ b/sw/qa/extras/inc/swmodeltestbase.hxx
@@ -94,6 +94,7 @@ using namespace css;
#define DECLARE_RTFEXPORT_TEST(TestName, filename) DECLARE_SW_ROUNDTRIP_TEST(TestName, filename, nullptr, Test)
#define DECLARE_ODFIMPORT_TEST(TestName, filename) DECLARE_SW_IMPORT_TEST(TestName, filename, nullptr, Test)
#define DECLARE_ODFEXPORT_TEST(TestName, filename) DECLARE_SW_ROUNDTRIP_TEST(TestName, filename, nullptr, Test)
+#define DECLARE_FODFEXPORT_TEST(TestName, filename) DECLARE_SW_ROUNDTRIP_TEST(TestName, filename, nullptr, Test)
#define DECLARE_WW8EXPORT_TEST(TestName, filename) DECLARE_SW_ROUNDTRIP_TEST(TestName, filename, nullptr, Test)
#define DECLARE_SW_IMPORT_TEST(TestName, filename, password, BaseClass) \
@@ -783,6 +784,16 @@ protected:
return parseExportInternal( maTempFile.GetURL(), rStreamName );
}
+ /**
+ * Returns an xml stream of a an exported file.
+ * To be used when the exporter doesn't create zip archives, but single files
+ * (like Flat ODF Export)
+ */
+ xmlDocPtr parseExportedFile()
+ {
+ return parseXmlStream(maTempFile.GetStream(StreamMode::READ));
+ }
+
xmlDocPtr parseExportInternal( const OUString& url, const OUString& rStreamName )
{
// Read the XML stream we're interested in.
commit e96f95fd70c4293f85a022257c757dded6f1ec84
Author: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
Date: Thu Nov 30 15:37:02 2017 +0100
tdf#113696 XHTML Export: Prefer fallback graphic
Which is usually png and browsers can read that,
but they can't read our internal metafile format (svm)
Change-Id: Idfd82da630ead69f508b74285081e32315030825
Reviewed-on: https://gerrit.libreoffice.org/45590
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
Reviewed-on: https://gerrit.libreoffice.org/45679
diff --git a/filter/source/xslt/odf2xhtml/export/xhtml/body.xsl b/filter/source/xslt/odf2xhtml/export/xhtml/body.xsl
index 1172e7efdbc3..9719932fcf2d 100644
--- a/filter/source/xslt/odf2xhtml/export/xhtml/body.xsl
+++ b/filter/source/xslt/odf2xhtml/export/xhtml/body.xsl
@@ -1483,27 +1483,32 @@
<xsl:template match="draw:image | draw:object-ole">
<xsl:param name="globalData"/>
- <xsl:choose>
- <xsl:when test="ancestor::text:p or parent::text:span or parent::text:h or parent::draw:a or parent::text:a or text:ruby-base">
- <!-- XHTML does not allow the mapped elements to contain paragraphs -->
- <xsl:call-template name="create-image-element">
- <xsl:with-param name="globalData" select="$globalData"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <!-- images are embedded in a paragraph, but are in CSS not able to express a horizontal alignment for themself.
- A 'div' element taking over the image style would solve that problem, but is invalid as child of a paragraph -->
- <xsl:element name="p">
- <xsl:apply-templates select="@draw:style-name">
- <xsl:with-param name="globalData" select="$globalData"/>
- </xsl:apply-templates>
-
+ <!-- If there is a replacement graphic, we take it.
+ It is a png which browsers are more likely able to render than the original graphic
+ which might have arbitrary formats. -->
+ <xsl:if test="not(following-sibling::draw:image)">
+ <xsl:choose>
+ <xsl:when test="ancestor::text:p or parent::text:span or parent::text:h or parent::draw:a or parent::text:a or text:ruby-base">
+ <!-- XHTML does not allow the mapped elements to contain paragraphs -->
<xsl:call-template name="create-image-element">
<xsl:with-param name="globalData" select="$globalData"/>
</xsl:call-template>
- </xsl:element>
- </xsl:otherwise>
- </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <!-- images are embedded in a paragraph, but are in CSS not able to express a horizontal alignment for themself.
+ A 'div' element taking over the image style would solve that problem, but is invalid as child of a paragraph -->
+ <xsl:element name="p">
+ <xsl:apply-templates select="@draw:style-name">
+ <xsl:with-param name="globalData" select="$globalData"/>
+ </xsl:apply-templates>
+
+ <xsl:call-template name="create-image-element">
+ <xsl:with-param name="globalData" select="$globalData"/>
+ </xsl:call-template>
+ </xsl:element>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
</xsl:template>
<xsl:template name="create-image-element">
commit 8dae93c0b8a075dee1319efff4e81d90f3f13b2b
Author: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
Date: Thu Nov 30 14:36:14 2017 +0100
tdf#113696 Add mimetype also to fallback graphic
Change-Id: I6eb7bb66aa688b5668d0eacd2ec7131bec2b6955
Reviewed-on: https://gerrit.libreoffice.org/45585
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
Reviewed-on: https://gerrit.libreoffice.org/45678
Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
diff --git a/xmloff/source/draw/shapeexport.cxx b/xmloff/source/draw/shapeexport.cxx
index 3a60df4f3b68..887f5ecfd372 100644
--- a/xmloff/source/draw/shapeexport.cxx
+++ b/xmloff/source/draw/shapeexport.cxx
@@ -2393,6 +2393,14 @@ void XMLShapeExport::ImpExportGraphicObjectShape(
mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
mrExport.AddAttribute(XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD );
}
+
+ uno::Reference<io::XInputStream> xInputStream(
+ mrExport.GetEmbeddedGraphicObjectStream(aReplacementUrl));
+ OUString aMimeType(
+ comphelper::GraphicMimeTypeHelper::GetMimeTypeForImageStream(xInputStream));
+ if (!aMimeType.isEmpty())
+ GetExport().AddAttribute(XML_NAMESPACE_LO_EXT, "mime-type", aMimeType);
+
SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, XML_IMAGE, true, true);
// optional office:binary-data
More information about the Libreoffice-commits
mailing list