summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--external/libepubgen/libepubgen-epub3.patch.1114
-rw-r--r--writerperfect/qa/unit/EPUBExportTest.cxx12
-rw-r--r--writerperfect/qa/unit/data/writer/epubexport/text-box.fodt45
-rw-r--r--writerperfect/source/writer/exp/XMLTextFrameContext.cxx36
4 files changed, 207 insertions, 0 deletions
diff --git a/external/libepubgen/libepubgen-epub3.patch.1 b/external/libepubgen/libepubgen-epub3.patch.1
index d83521aa0b3d..1c64aa694ee0 100644
--- a/external/libepubgen/libepubgen-epub3.patch.1
+++ b/external/libepubgen/libepubgen-epub3.patch.1
@@ -3683,3 +3683,117 @@ index d81a905..a90ac68 100644
--
2.13.6
+From 40111db25a92537c922a768dd04916cb5edd0239 Mon Sep 17 00:00:00 2001
+From: Miklos Vajna <vmiklos@collabora.co.uk>
+Date: Fri, 10 Nov 2017 14:13:29 +0100
+Subject: [PATCH] EPUBHTMLGenerator: map TextBox to <div>
+
+This way e.g. image with caption is no longer lost from the text
+generator. This generalizes image and textbox styles as "frame" styles.
+---
+ src/lib/EPUBHTMLGenerator.cpp | 27 ++++++++++++++++++----
+ src/lib/EPUBImageManager.cpp | 6 ++---
+ src/lib/EPUBImageManager.h | 4 ++--
+ src/test/EPUBTextGeneratorTest.cpp | 47 +++++++++++++++++++++++++++++++++-----
+ 4 files changed, 68 insertions(+), 16 deletions(-)
+
+diff --git a/src/lib/EPUBHTMLGenerator.cpp b/src/lib/EPUBHTMLGenerator.cpp
+index a90ac68..5f10902 100644
+--- a/src/lib/EPUBHTMLGenerator.cpp
++++ b/src/lib/EPUBHTMLGenerator.cpp
+@@ -833,15 +833,32 @@ void EPUBHTMLGenerator::openTextBox(const RVNGPropertyList & /*propList*/)
+ {
+ if (m_impl->m_ignore)
+ return;
+- m_impl->push(EPUBHTMLTextZone::Z_TextBox);
+- m_impl->getSink().addLabel(m_impl->output());
++
++ RVNGPropertyList attrs;
++
++ if (!m_impl->m_framePropertiesStack.empty())
++ {
++ RVNGPropertyList &frameProperties = m_impl->m_framePropertiesStack.top();
++ switch (m_impl->m_stylesMethod)
++ {
++ case EPUB_STYLES_METHOD_CSS:
++ attrs.insert("class", m_impl->m_imageManager.getFrameClass(frameProperties).c_str());
++ break;
++ case EPUB_STYLES_METHOD_INLINE:
++ attrs.insert("style", m_impl->m_imageManager.getFrameStyle(frameProperties).c_str());
++ break;
++ }
++ }
++
++ m_impl->output().openElement("div", attrs);
+ }
+
+ void EPUBHTMLGenerator::closeTextBox()
+ {
+ if (m_impl->m_ignore)
+ return;
+- m_impl->pop();
++
++ m_impl->output().closeElement("div");
+ }
+
+ void EPUBHTMLGenerator::openTable(const RVNGPropertyList &propList)
+@@ -990,10 +1007,10 @@ void EPUBHTMLGenerator::insertBinaryObject(const RVNGPropertyList &propList)
+ switch (m_impl->m_stylesMethod)
+ {
+ case EPUB_STYLES_METHOD_CSS:
+- attrs.insert("class", m_impl->m_imageManager.getImageClass(frameProperties).c_str());
++ attrs.insert("class", m_impl->m_imageManager.getFrameClass(frameProperties).c_str());
+ break;
+ case EPUB_STYLES_METHOD_INLINE:
+- attrs.insert("style", m_impl->m_imageManager.getImageStyle(frameProperties).c_str());
++ attrs.insert("style", m_impl->m_imageManager.getFrameStyle(frameProperties).c_str());
+ break;
+ }
+
+diff --git a/src/lib/EPUBImageManager.cpp b/src/lib/EPUBImageManager.cpp
+index 8414da5..dfa0cb7 100644
+--- a/src/lib/EPUBImageManager.cpp
++++ b/src/lib/EPUBImageManager.cpp
+@@ -107,7 +107,7 @@ void EPUBImageManager::writeTo(EPUBPackage &package)
+ }
+ }
+
+-std::string EPUBImageManager::getImageClass(librevenge::RVNGPropertyList const &pList)
++std::string EPUBImageManager::getFrameClass(librevenge::RVNGPropertyList const &pList)
+ {
+ EPUBCSSProperties content;
+ extractImageProperties(pList, content);
+@@ -115,12 +115,12 @@ std::string EPUBImageManager::getImageClass(librevenge::RVNGPropertyList const &
+ if (it != m_imageContentNameMap.end())
+ return it->second;
+ std::stringstream s;
+- s << "image" << m_imageContentNameMap.size();
++ s << "frame" << m_imageContentNameMap.size();
+ m_imageContentNameMap[content]=s.str();
+ return s.str();
+ }
+
+-std::string EPUBImageManager::getImageStyle(librevenge::RVNGPropertyList const &pList)
++std::string EPUBImageManager::getFrameStyle(librevenge::RVNGPropertyList const &pList)
+ {
+ EPUBCSSProperties content;
+ extractImageProperties(pList, content);
+diff --git a/src/lib/EPUBImageManager.h b/src/lib/EPUBImageManager.h
+index c9f4236..939d350 100644
+--- a/src/lib/EPUBImageManager.h
++++ b/src/lib/EPUBImageManager.h
+@@ -53,9 +53,9 @@ public:
+ void writeTo(EPUBPackage &package);
+
+ //! returns the class name corresponding to a propertylist
+- std::string getImageClass(librevenge::RVNGPropertyList const &pList);
++ std::string getFrameClass(librevenge::RVNGPropertyList const &pList);
+ //! returns the style string corresponding to a propertylist
+- std::string getImageStyle(librevenge::RVNGPropertyList const &pList);
++ std::string getFrameStyle(librevenge::RVNGPropertyList const &pList);
+ //! send the data to the sink
+ void send(EPUBCSSSink &out);
+
+--
+2.13.6
+
diff --git a/writerperfect/qa/unit/EPUBExportTest.cxx b/writerperfect/qa/unit/EPUBExportTest.cxx
index 7f155c35de8e..fdcafe827147 100644
--- a/writerperfect/qa/unit/EPUBExportTest.cxx
+++ b/writerperfect/qa/unit/EPUBExportTest.cxx
@@ -82,6 +82,7 @@ public:
void testLinkCharFormat();
void testLinkNamedCharFormat();
void testTableWidth();
+ void testTextBox();
CPPUNIT_TEST_SUITE(EPUBExportTest);
CPPUNIT_TEST(testOutlineLevel);
@@ -112,6 +113,7 @@ public:
CPPUNIT_TEST(testLinkCharFormat);
CPPUNIT_TEST(testLinkNamedCharFormat);
CPPUNIT_TEST(testTableWidth);
+ CPPUNIT_TEST(testTextBox);
CPPUNIT_TEST_SUITE_END();
};
@@ -571,6 +573,16 @@ void EPUBExportTest::testTableWidth()
CPPUNIT_ASSERT_EQUAL(OUString("50%"), EPUBExportTest::getCss(aCssDoc, aClass, "width"));
}
+void EPUBExportTest::testTextBox()
+{
+ createDoc("text-box.fodt", {});
+
+ mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml");
+
+ // This failed, image with caption was lost.
+ assertXPath(mpXmlDoc, "//xhtml:img", "class", "frame1");
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(EPUBExportTest);
}
diff --git a/writerperfect/qa/unit/data/writer/epubexport/text-box.fodt b/writerperfect/qa/unit/data/writer/epubexport/text-box.fodt
new file mode 100644
index 000000000000..dad8d20b149b
--- /dev/null
+++ b/writerperfect/qa/unit/data/writer/epubexport/text-box.fodt
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rpt="http://openoffice.org/2005/report" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:officeooo="http://openoffice.org/2009/office" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:drawooo="http://openoffice.org/2010/draw" xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:css3t="http://www.w3.org/TR/css3-text/" office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.text">
+ <office:styles>
+ <style:style style:name="Graphics" style:family="graphic">
+ <style:graphic-properties text:anchor-type="paragraph" svg:x="0cm" svg:y="0cm" style:wrap="dynamic" style:number-wrapped-paragraphs="no-limit" style:wrap-contour="false" style:vertical-pos="top" style:vertical-rel="paragraph" style:horizontal-pos="center" style:horizontal-rel="paragraph"/>
+ </style:style>
+ <style:style style:name="Frame" style:family="graphic">
+ <style:graphic-properties text:anchor-type="paragraph" svg:x="0cm" svg:y="0cm" fo:margin-left="0.201cm" fo:margin-right="0.201cm" fo:margin-top="0.201cm" fo:margin-bottom="0.201cm" style:wrap="parallel" style:number-wrapped-paragraphs="no-limit" style:wrap-contour="false" style:vertical-pos="top" style:vertical-rel="paragraph-content" style:horizontal-pos="center" style:horizontal-rel="paragraph-content" fo:padding="0.15cm" fo:border="0.06pt solid #000000"/>
+ </style:style>
+ </office:styles>
+ <office:automatic-styles>
+ <style:style style:name="fr1" style:family="graphic" style:parent-style-name="Frame">
+ <style:graphic-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:margin-top="0cm" fo:margin-bottom="0cm" style:wrap="none" style:vertical-pos="top" style:vertical-rel="paragraph" style:horizontal-pos="center" style:horizontal-rel="paragraph" fo:padding="0.049cm" fo:border="0.99pt dashed #ed1c24" style:shadow="none" draw:shadow-opacity="100%"/>
+ </style:style>
+ <style:style style:name="fr2" style:family="graphic" style:parent-style-name="Graphics">
+ <style:graphic-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:margin-top="0cm" fo:margin-bottom="0cm" style:run-through="foreground" style:wrap="none" style:vertical-pos="top" style:vertical-rel="baseline" style:horizontal-pos="center" style:horizontal-rel="paragraph-content" fo:padding="0cm" fo:border="none" style:shadow="none" draw:shadow-opacity="100%" style:mirror="none" fo:clip="rect(0cm, 0cm, 0cm, 0cm)" draw:luminance="0%" draw:contrast="0%" draw:red="0%" draw:green="0%" draw:blue="0%" draw:gamma="100%" draw:color-inversion="false" draw:image-opacity="100%" draw:color-mode="standard" loext:rel-width-rel="paragraph"/>
+ </style:style>
+ </office:automatic-styles>
+ <office:body>
+ <office:text>
+ <text:sequence-decls>
+ <text:sequence-decl text:display-outline-level="0" text:name="Illustration"/>
+ <text:sequence-decl text:display-outline-level="0" text:name="Table"/>
+ <text:sequence-decl text:display-outline-level="0" text:name="Text"/>
+ <text:sequence-decl text:display-outline-level="0" text:name="Drawing"/>
+ </text:sequence-decls>
+ <text:p><draw:frame draw:style-name="fr1" draw:name="Frame1" text:anchor-type="char" svg:width="5.674cm" draw:z-index="0"><draw:text-box fo:min-height="3.336cm"><text:p><draw:frame draw:style-name="fr2" draw:name="Object0" text:anchor-type="as-char" svg:width="1.663cm" style:rel-width="100%" svg:height="1.663cm" style:rel-height="scale" draw:z-index="1"><draw:image><office:binary-data>iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAQAAAAAYLlVAAAABGdBTUEAALGPC/xhBQAAAAFz
+ UkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAA
+ AAJiS0dEAACqjSMyAAAACW9GRnMAAAAGAAAAAAAMc1XTAAAACXBIWXMAAA3XAAAN1wFCKJt4
+ AAAACXZwQWcAAABMAAAAQACdMTgbAAABzUlEQVRo3u3ZPU/CQBjA8X+Jxs3ESUDj4iK+LA5+
+ BBfjqBE1cXB2MlFAEqMgxvhNNL4sLsK3UPQL6ObkoAETz+FKW2mxCPRYnucWUu76/OC59C49
+ cGOCKqrD9kHRc6ddPv7oW2WCwMh0nF63Myz7Tm8hPTNu0pgHMER3scepTbgK6enJNND83RLn
+ /878yRaPmgBZFDuMsNLeWB9gmFQHP77MIg9gsYciR50NFKvtjIy10yk84pSZA7DYpwR8scmF
+ QQCMuoQMpzbh0iAARrlnVn90CWHTsZcAiHPPdINQAuqsc2MQAAnKDUKWEhZ10twaBEDSJWQo
+ YlFj7S9CzwEegkXWIbQsRAQASFJhpplwbRAACS+hANRJBxMiAkDcJeQ4sQkBhYgMoJ+Ozlwo
+ 2YQ7AJ6CRxyiUGnVy3hVKb0Af9v7hUG2Wy9TEQCUelFTDULB2S+YKYGOMcpM6UIccOQnRA6A
+ cSp6ibfI+wkGADBGpTEd8xz1AaAfTQ7huA8AvUw5hVjuA0D/C5OaMN8XACRZ8F0zCggKAQhA
+ AAIQgAAEIAABCEAAAhCAAAQgAAH4zg3feY4w3Xs44M5+oW0qvCWoGcvaIlM3x/f/ab+O738A
+ hOCNQr34oD4AAAAldEVYdGNyZWF0ZS1kYXRlADIwMTAtMTItMjBUMTc6MDg6MzYrMDE6MDB6
+ 5RscAAAAJXRFWHRtb2RpZnktZGF0ZQAyMDEwLTEyLTIwVDE3OjA4OjM3KzAxOjAwgyNmnAAA
+ AABJRU5ErkJggg==
+ </office:binary-data></draw:image></draw:frame><text:span><text:line-break/></text:span><text:span>Illustration </text:span><text:span><text:sequence text:ref-name="refIllustration0" text:name="Illustration" text:formula="ooow:Illustration+1" style:num-format="1">1</text:sequence></text:span><text:span>: foo</text:span></text:p></draw:text-box></draw:frame>bar</text:p>
+ </office:text>
+ </office:body>
+</office:document>
diff --git a/writerperfect/source/writer/exp/XMLTextFrameContext.cxx b/writerperfect/source/writer/exp/XMLTextFrameContext.cxx
index 556b6597cb42..78ea1b4d1e4b 100644
--- a/writerperfect/source/writer/exp/XMLTextFrameContext.cxx
+++ b/writerperfect/source/writer/exp/XMLTextFrameContext.cxx
@@ -12,6 +12,7 @@
#include "XMLBase64ImportContext.hxx"
#include "txtparai.hxx"
#include "xmlimp.hxx"
+#include "xmltext.hxx"
using namespace com::sun::star;
@@ -20,6 +21,38 @@ namespace writerperfect
namespace exp
{
+/// Handler for <draw:text-box>.
+class XMLTextBoxContext : public XMLImportContext
+{
+public:
+ XMLTextBoxContext(XMLImport &rImport);
+
+ rtl::Reference<XMLImportContext> CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override;
+
+ void SAL_CALL startElement(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &xAttribs) override;
+ void SAL_CALL endElement(const OUString &rName) override;
+};
+
+XMLTextBoxContext::XMLTextBoxContext(XMLImport &rImport)
+ : XMLImportContext(rImport)
+{
+}
+
+rtl::Reference<XMLImportContext> XMLTextBoxContext::CreateChildContext(const OUString &rName, const css::uno::Reference<css::xml::sax::XAttributeList> &/*xAttribs*/)
+{
+ return CreateTextChildContext(mrImport, rName);
+}
+
+void XMLTextBoxContext::startElement(const OUString &/*rName*/, const css::uno::Reference<css::xml::sax::XAttributeList> &/*xAttribs*/)
+{
+ mrImport.GetGenerator().openTextBox(librevenge::RVNGPropertyList());
+}
+
+void XMLTextBoxContext::endElement(const OUString &/*rName*/)
+{
+ mrImport.GetGenerator().closeTextBox();
+}
+
/// Handler for <draw:image>.
class XMLTextImageContext : public XMLImportContext
{
@@ -81,6 +114,9 @@ rtl::Reference<XMLImportContext> XMLTextFrameContext::CreateChildContext(const O
{
if (rName == "draw:image")
return new XMLTextImageContext(mrImport);
+ if (rName == "draw:text-box")
+ return new XMLTextBoxContext(mrImport);
+ SAL_WARN("writerperfect", "XMLTextFrameContext::CreateChildContext: unhandled " << rName);
return nullptr;
}