diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-12-01 10:59:36 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-12-04 09:07:27 +0100 |
commit | e83d7993d46b096ecc18c01d92d39e170cce18c1 (patch) | |
tree | daa5c81c6dbd076027876128fa8ca958f9e1f0b4 /writerperfect | |
parent | 3ed8466b55ace15a28761e06b6bb76ebd8758106 (diff) |
EPUB export, fixed layout: disable DTD string in SVG header
epubcheck complains:
ERROR(HTM-003): test.epub/OEBPS/images/image0001.svg(5675,37): External entities are not allowed in EPUB v3 documents. External entity declaration found: %svg-extensibility.mod.
and similar ones. Just not writing the DTD header is enough to address
the error.
Change-Id: I5307e932a0f07585297cce734aceae77e43cc7a6
Reviewed-on: https://gerrit.libreoffice.org/45648
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'writerperfect')
-rw-r--r-- | writerperfect/qa/unit/EPUBExportTest.cxx | 25 | ||||
-rw-r--r-- | writerperfect/source/writer/exp/xmlimp.cxx | 6 |
2 files changed, 30 insertions, 1 deletions
diff --git a/writerperfect/qa/unit/EPUBExportTest.cxx b/writerperfect/qa/unit/EPUBExportTest.cxx index bd42356e60ce..178041d9c0da 100644 --- a/writerperfect/qa/unit/EPUBExportTest.cxx +++ b/writerperfect/qa/unit/EPUBExportTest.cxx @@ -96,6 +96,7 @@ public: void testPopup(); void testPopupAPI(); void testPageSize(); + void testSVG(); CPPUNIT_TEST_SUITE(EPUBExportTest); CPPUNIT_TEST(testOutlineLevel); @@ -139,6 +140,7 @@ public: CPPUNIT_TEST(testPopup); CPPUNIT_TEST(testPopupAPI); CPPUNIT_TEST(testPageSize); + CPPUNIT_TEST(testSVG); CPPUNIT_TEST_SUITE_END(); }; @@ -813,6 +815,29 @@ void EPUBExportTest::testPageSize() assertXPath(mpXmlDoc, "/xhtml:html/xhtml:head/xhtml:meta[@name='viewport']", "content", "width=816, height=1056"); } +void EPUBExportTest::testSVG() +{ + uno::Sequence<beans::PropertyValue> aFilterData(comphelper::InitPropertySequence( + { + {"EPUBLayoutMethod", uno::makeAny(static_cast<sal_Int32>(libepubgen::EPUB_LAYOUT_METHOD_FIXED))} + })); + createDoc("hello.fodt", aFilterData); + + CPPUNIT_ASSERT(mxZipFile->hasByName("OEBPS/images/image0001.svg")); + uno::Reference<io::XInputStream> xInputStream(mxZipFile->getByName("OEBPS/images/image0001.svg"), uno::UNO_QUERY); + std::shared_ptr<SvStream> pStream(utl::UcbStreamHelper::CreateStream(xInputStream, true)); + + SvMemoryStream aMemoryStream; + aMemoryStream.WriteStream(*pStream); + OString aExpected("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n<svg"); + CPPUNIT_ASSERT(aMemoryStream.GetSize() > static_cast<sal_uInt64>(aExpected.getLength())); + + // This failed, there was a '<!DOCTYPE' line between the xml and the svg + // one, causing a validation error. + OString aActual(static_cast<const char *>(aMemoryStream.GetBuffer()), aExpected.getLength()); + CPPUNIT_ASSERT_EQUAL(aExpected, aActual); +} + CPPUNIT_TEST_SUITE_REGISTRATION(EPUBExportTest); } diff --git a/writerperfect/source/writer/exp/xmlimp.cxx b/writerperfect/source/writer/exp/xmlimp.cxx index 4686cd95ad64..6750019216e3 100644 --- a/writerperfect/source/writer/exp/xmlimp.cxx +++ b/writerperfect/source/writer/exp/xmlimp.cxx @@ -17,6 +17,7 @@ #include <com/sun/star/xml/sax/InputSource.hpp> #include <com/sun/star/xml/sax/Parser.hpp> #include <com/sun/star/xml/sax/Writer.hpp> +#include <comphelper/propertyvalue.hxx> #include <rtl/uri.hxx> #include <tools/stream.hxx> #include <tools/urlobj.hxx> @@ -283,7 +284,10 @@ void XMLOfficeDocContext::HandleFixedLayoutPage(const uno::Sequence<sal_Int8> &r if (!xSaxWriter.is()) return; - uno::Sequence<uno::Any> aArguments; + uno::Sequence<uno::Any> aArguments = + { + uno::makeAny(uno::Sequence<beans::PropertyValue>({comphelper::makePropertyValue("DTDString", false)})) + }; uno::Reference<svg::XSVGWriter> xSVGWriter(xCtx->getServiceManager()->createInstanceWithArgumentsAndContext("com.sun.star.svg.SVGWriter", aArguments, xCtx), uno::UNO_QUERY); if (!xSVGWriter.is()) return; |