From 9035ee7c90ed5ff78864145fd92241491033c074 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 18 Jan 2018 15:53:54 +0100 Subject: EPUB export: accept relative links for image popup from default media dir Previously: - the user had to copy the linked image to the same dir as the doc - set a relative link on the image (in ODF, it resulted in "../foo.png") - copy the image to the media dir ("test" by default for "test.odt") - export to EPUB to have the image popup Now, additionally: - relative link may point to the default media dir (in ODF, it results in "../test/foo.png") - no need to copy the image - export to EPUB creates the popup So one less step is necessary. The downside is that this way the relative URL contain the base name of the document, so renaming the document breaks these relative links. Change-Id: I93894a28393d36a33dcec7bfe7c4a54fd83768da --- writerperfect/qa/unit/EPUBExportTest.cxx | 14 ++++++++++++++ .../qa/unit/data/writer/epubexport/popup-media.odt | Bin 0 -> 10111 bytes .../data/writer/epubexport/popup-media/libreoffice.png | Bin 0 -> 714 bytes 3 files changed, 14 insertions(+) create mode 100644 writerperfect/qa/unit/data/writer/epubexport/popup-media.odt create mode 100644 writerperfect/qa/unit/data/writer/epubexport/popup-media/libreoffice.png (limited to 'writerperfect/qa/unit') diff --git a/writerperfect/qa/unit/EPUBExportTest.cxx b/writerperfect/qa/unit/EPUBExportTest.cxx index 5a1c21c0e48f..176324b0dff7 100644 --- a/writerperfect/qa/unit/EPUBExportTest.cxx +++ b/writerperfect/qa/unit/EPUBExportTest.cxx @@ -94,6 +94,7 @@ public: void testImageLink(); void testFootnote(); void testPopup(); + void testPopupMedia(); void testPopupAPI(); void testPageSize(); void testSVG(); @@ -139,6 +140,7 @@ public: CPPUNIT_TEST(testImageLink); CPPUNIT_TEST(testFootnote); CPPUNIT_TEST(testPopup); + CPPUNIT_TEST(testPopupMedia); CPPUNIT_TEST(testPopupAPI); CPPUNIT_TEST(testPageSize); CPPUNIT_TEST(testSVG); @@ -791,6 +793,18 @@ void EPUBExportTest::testPopup() assertXPath(mpXmlDoc, "//xhtml:body/xhtml:aside[2]/xhtml:img", 1); } +void EPUBExportTest::testPopupMedia() +{ + // This is the same as testPopup(), but the links point to images in the + // default media directory, not in the document directory. + createDoc("popup-media.odt", {}); + + mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml"); + // Test image popup anchor. This failed, number of XPath nodes was 0. + assertXPath(mpXmlDoc, "//xhtml:body/xhtml:p[1]/xhtml:a", "type", "noteref"); + assertXPath(mpXmlDoc, "//xhtml:body/xhtml:p[1]/xhtml:a/xhtml:img", 1); +} + void EPUBExportTest::testPopupAPI() { // Make sure that the popup works with data from a media directory. diff --git a/writerperfect/qa/unit/data/writer/epubexport/popup-media.odt b/writerperfect/qa/unit/data/writer/epubexport/popup-media.odt new file mode 100644 index 000000000000..5f45e7ce8aef Binary files /dev/null and b/writerperfect/qa/unit/data/writer/epubexport/popup-media.odt differ diff --git a/writerperfect/qa/unit/data/writer/epubexport/popup-media/libreoffice.png b/writerperfect/qa/unit/data/writer/epubexport/popup-media/libreoffice.png new file mode 100644 index 000000000000..cc74f136fbdf Binary files /dev/null and b/writerperfect/qa/unit/data/writer/epubexport/popup-media/libreoffice.png differ -- cgit