[Libreoffice-commits] core.git: 2 commits - external/libepubgen writerperfect/qa writerperfect/source writerperfect/uiconfig

Miklos Vajna vmiklos at collabora.co.uk
Fri Dec 1 15:31:41 UTC 2017


 external/libepubgen/libepubgen-epub3.patch.1     |  304 +++++++++++++++++++++++
 writerperfect/qa/uitest/epubexport/epubexport.py |   16 +
 writerperfect/qa/unit/EPUBExportTest.cxx         |   16 +
 writerperfect/source/writer/EPUBExportDialog.cxx |   24 +
 writerperfect/source/writer/EPUBExportDialog.hxx |    2 
 writerperfect/source/writer/EPUBExportFilter.cxx |   15 +
 writerperfect/source/writer/EPUBExportFilter.hxx |    2 
 writerperfect/uiconfig/ui/exportepub.ui          |   57 ++++
 8 files changed, 433 insertions(+), 3 deletions(-)

New commits:
commit 913fbc822c0f0e285cd0dc3f919a2fb43a94c7ad
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Dec 1 10:55:09 2017 +0100

    EPUB export: add UI to request fixed layout
    
    Sets the EPUBLayoutMethod filter data key at UNO level.
    
    Change-Id: Ia07029bd83fec02e98cb6a3cc2bfea2ab742d769
    Reviewed-on: https://gerrit.libreoffice.org/45644
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/writerperfect/qa/uitest/epubexport/epubexport.py b/writerperfect/qa/uitest/epubexport/epubexport.py
index 301f090e3362..b8e7d3f52fd9 100644
--- a/writerperfect/qa/uitest/epubexport/epubexport.py
+++ b/writerperfect/qa/uitest/epubexport/epubexport.py
@@ -97,6 +97,22 @@ class EPUBExportTest(UITestCase):
         mediaDir = [i.Value for i in filterData if i.Name == "RVNGMediaDir"][0]
         self.assertEqual("file:///foo/bar", mediaDir)
 
+    def testFixedLayout(self):
+        def handleDialog(dialog):
+            # Select the second entry to request fixed, not reflowable layout.
+            dialog.getChild("layoutlb").executeAction("SELECT", mkPropertyValues({"POS": "1"}))
+            dialog.getChild("ok").executeAction("CLICK", tuple())
+
+        uiComponent = self.ui_test._xContext.ServiceManager.createInstanceWithContext("com.sun.star.comp.Writer.EPUBExportUIComponent", self.ui_test._xContext)
+
+        self.ui_test.execute_blocking_action(action=uiComponent.execute, dialog_handler=handleDialog)
+        propertyValues = uiComponent.getPropertyValues()
+        filterData = [i.Value for i in propertyValues if i.Name == "FilterData"][0]
+        # The EPUBLayoutMethod key was missing, EPUBExportDialog::OKClickHdl() did not set it.
+        layout = [i.Value for i in filterData if i.Name == "EPUBLayoutMethod"][0]
+        # 1 stands for libepubgen::EPUB_LAYOUT_METHOD_FIXED.
+        self.assertEqual(1, layout)
+
     def testMeta(self):
         def handleDialog(dialog):
             dialog.getChild("identifier").executeAction("TYPE", mkPropertyValues({"TEXT": "baddcafe-e394-4cd6-9b83-7172794612e5"}))
diff --git a/writerperfect/source/writer/EPUBExportDialog.cxx b/writerperfect/source/writer/EPUBExportDialog.cxx
index acc1f9a9182d..232ca4128fec 100644
--- a/writerperfect/source/writer/EPUBExportDialog.cxx
+++ b/writerperfect/source/writer/EPUBExportDialog.cxx
@@ -90,12 +90,26 @@ EPUBExportDialog::EPUBExportDialog(vcl::Window *pParent, comphelper::SequenceAsH
         if (it->second >>= nSplitMethod)
             // No conversion, 1:1 mapping between libepubgen::EPUBSplitMethod
             // and entry positions.
-            m_pVersion->SelectEntryPos(nSplitMethod);
+            m_pSplit->SelectEntryPos(nSplitMethod);
     }
     else
         m_pSplit->SelectEntryPos(EPUBExportFilter::GetDefaultSplitMethod());
     m_pSplit->SetSelectHdl(LINK(this, EPUBExportDialog, SplitSelectHdl));
 
+    get(m_pLayout, "layoutlb");
+    it = rFilterData.find("EPUBLayoutMethod");
+    if (it != rFilterData.end())
+    {
+        sal_Int32 nLayoutMethod = 0;
+        if (it->second >>= nLayoutMethod)
+            // No conversion, 1:1 mapping between libepubgen::EPUBLayoutMethod
+            // and entry positions.
+            m_pLayout->SelectEntryPos(nLayoutMethod);
+    }
+    else
+        m_pLayout->SelectEntryPos(EPUBExportFilter::GetDefaultLayoutMethod());
+    m_pLayout->SetSelectHdl(LINK(this, EPUBExportDialog, LayoutSelectHdl));
+
     get(m_pCoverPath, "coverpath");
 
     get(m_pCoverButton, "coverbutton");
@@ -128,6 +142,13 @@ IMPL_LINK_NOARG(EPUBExportDialog, SplitSelectHdl, ListBox &, void)
     mrFilterData["EPUBSplitMethod"] <<= m_pSplit->GetSelectedEntryPos();
 }
 
+IMPL_LINK_NOARG(EPUBExportDialog, LayoutSelectHdl, ListBox &, void)
+{
+    // No conversion, 1:1 mapping between entry positions and
+    // libepubgen::EPUBLayoutMethod.
+    mrFilterData["EPUBLayoutMethod"] <<= m_pLayout->GetSelectedEntryPos();
+}
+
 IMPL_LINK_NOARG(EPUBExportDialog, CoverClickHdl, Button *, void)
 {
     SvxOpenGraphicDialog aDlg("Import", this);
@@ -187,6 +208,7 @@ void EPUBExportDialog::dispose()
     m_pDate.clear();
     m_pMediaDir.clear();
     m_pMediaButton.clear();
+    m_pLayout.clear();
     ModalDialog::dispose();
 }
 
diff --git a/writerperfect/source/writer/EPUBExportDialog.hxx b/writerperfect/source/writer/EPUBExportDialog.hxx
index 1181d096bd03..aafdbbb35105 100644
--- a/writerperfect/source/writer/EPUBExportDialog.hxx
+++ b/writerperfect/source/writer/EPUBExportDialog.hxx
@@ -30,6 +30,7 @@ public:
 private:
     DECL_LINK(VersionSelectHdl, ListBox &, void);
     DECL_LINK(SplitSelectHdl, ListBox &, void);
+    DECL_LINK(LayoutSelectHdl, ListBox &, void);
     DECL_LINK(CoverClickHdl, Button *, void);
     DECL_LINK(MediaClickHdl, Button *, void);
     DECL_LINK(OKClickHdl, Button *, void);
@@ -38,6 +39,7 @@ private:
     comphelper::SequenceAsHashMap &mrFilterData;
     VclPtr<ListBox> m_pVersion;
     VclPtr<ListBox> m_pSplit;
+    VclPtr<ListBox> m_pLayout;
     VclPtr<Edit> m_pCoverPath;
     VclPtr<PushButton> m_pCoverButton;
     VclPtr<Edit> m_pMediaDir;
diff --git a/writerperfect/uiconfig/ui/exportepub.ui b/writerperfect/uiconfig/ui/exportepub.ui
index 3d7c28af73be..da0124161652 100644
--- a/writerperfect/uiconfig/ui/exportepub.ui
+++ b/writerperfect/uiconfig/ui/exportepub.ui
@@ -207,6 +207,59 @@
                   </packing>
                 </child>
                 <child>
+                  <object class="GtkAlignment" id="alignment6">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="top_padding">6</property>
+                    <property name="left_padding">12</property>
+                    <child>
+                      <object class="GtkBox" id="box10">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="orientation">vertical</property>
+                        <property name="spacing">6</property>
+                        <child>
+                          <object class="GtkLabel" id="layoutft">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="margin_top">6</property>
+                            <property name="label" translatable="yes" context="exportepub|layoutft">Layout method:</property>
+                            <property name="use_underline">True</property>
+                            <property name="mnemonic_widget">layoutlb</property>
+                            <property name="xalign">0</property>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">3</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkComboBoxText" id="layoutlb">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="active">0</property>
+                            <items>
+                              <item translatable="yes" context="exportepub|layoutreflowable">Reflowable</item>
+                              <item translatable="yes" context="exportepub|layoutfixed">Fixed</item>
+                            </items>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">4</property>
+                          </packing>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">3</property>
+                  </packing>
+                </child>
+                <child>
                   <object class="GtkAlignment" id="alignment3">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
@@ -276,7 +329,7 @@
                   <packing>
                     <property name="expand">False</property>
                     <property name="fill">True</property>
-                    <property name="position">3</property>
+                    <property name="position">4</property>
                   </packing>
                 </child>
                 <child>
@@ -349,7 +402,7 @@
                   <packing>
                     <property name="expand">False</property>
                     <property name="fill">True</property>
-                    <property name="position">4</property>
+                    <property name="position">5</property>
                   </packing>
                 </child>
               </object>
commit ab7bdd1f91a7e6e25854601cca712488554ab960
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Dec 1 10:54:51 2017 +0100

    EPUB export: initial fixed layout support
    
    This is just the bare minimum that is already a fixed layout and is
    valid.
    
    Change-Id: I64e1216d92125377d7836988586da9ea1d878536
    Reviewed-on: https://gerrit.libreoffice.org/45643
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/external/libepubgen/libepubgen-epub3.patch.1 b/external/libepubgen/libepubgen-epub3.patch.1
index e2948c43bd34..da2b935ad816 100644
--- a/external/libepubgen/libepubgen-epub3.patch.1
+++ b/external/libepubgen/libepubgen-epub3.patch.1
@@ -5354,3 +5354,307 @@ index 11f20cb..3699179 100644
 -- 
 2.13.6
 
+From bd49e1672d0e914736824dadc8f89c26ae955088 Mon Sep 17 00:00:00 2001
+From: Miklos Vajna <vmiklos at collabora.co.uk>
+Date: Tue, 28 Nov 2017 14:50:34 +0100
+Subject: [PATCH] [ABI CHANGE] optionally support the EPUB3 fixed layout
+
+Default is still the reflowable method, of course.
+---
+ inc/libepubgen/EPUBTextGenerator.h |  1 +
+ inc/libepubgen/libepubgen-decls.h  |  8 ++++++++
+ src/lib/EPUBGenerator.cpp          | 17 +++++++++++++++-
+ src/lib/EPUBGenerator.h            |  3 +++
+ src/lib/EPUBHTMLGenerator.cpp      | 41 ++++++++++++++++++++++++++++++++++----
+ src/lib/EPUBHTMLGenerator.h        |  2 +-
+ src/lib/EPUBHTMLManager.cpp        |  4 ++--
+ src/lib/EPUBHTMLManager.h          |  2 +-
+ src/lib/EPUBTextGenerator.cpp      |  5 +++++
+ src/test/EPUBTextGeneratorTest.cpp | 27 +++++++++++++++++++++++++
+ 10 files changed, 101 insertions(+), 9 deletions(-)
+
+diff --git a/inc/libepubgen/EPUBTextGenerator.h b/inc/libepubgen/EPUBTextGenerator.h
+index cb2d9a6..beb05aa 100644
+--- a/inc/libepubgen/EPUBTextGenerator.h
++++ b/inc/libepubgen/EPUBTextGenerator.h
+@@ -43,6 +43,7 @@ public:
+   void setSplitHeadingLevel(unsigned level);
+   void setSplitSize(unsigned size);
+   void setStylesMethod(EPUBStylesMethod styles);
++  void setLayoutMethod(EPUBLayoutMethod layout);
+ 
+   /** Register a handler for embedded images.
+     *
+diff --git a/inc/libepubgen/libepubgen-decls.h b/inc/libepubgen/libepubgen-decls.h
+index 2657a2d..3eb206e 100644
+--- a/inc/libepubgen/libepubgen-decls.h
++++ b/inc/libepubgen/libepubgen-decls.h
+@@ -69,6 +69,14 @@ enum EPUBStylesMethod
+   EPUB_STYLES_METHOD_INLINE, //< The styles will be described inline.
+ };
+ 
++/** The possible ways to lay out HTML files.
++  */
++enum EPUBLayoutMethod
++{
++  EPUB_LAYOUT_METHOD_REFLOWABLE, //< Dynamic pagination.
++  EPUB_LAYOUT_METHOD_FIXED, //< Exactly one page per HTML file.
++};
++
+ }
+ 
+ #endif // INCLUDED_LIBEPUBGEN_LIBEPUBGEN_DECLS_H
+diff --git a/src/lib/EPUBGenerator.cpp b/src/lib/EPUBGenerator.cpp
+index 571f0eb..4a62d7f 100644
+--- a/src/lib/EPUBGenerator.cpp
++++ b/src/lib/EPUBGenerator.cpp
+@@ -47,6 +47,7 @@ EPUBGenerator::EPUBGenerator(EPUBPackage *const package, const EPUBSplitMethod s
+   , m_splitGuard(split)
+   , m_version(version)
+   , m_stylesMethod(EPUB_STYLES_METHOD_CSS)
++  , m_layoutMethod(EPUB_LAYOUT_METHOD_REFLOWABLE)
+ {
+ }
+ 
+@@ -117,7 +118,7 @@ void EPUBGenerator::startNewHtmlFile()
+ 
+   m_splitGuard.onSplit();
+ 
+-  m_currentHtml = m_htmlManager.create(m_imageManager, m_fontManager, m_listStyleManager, m_paragraphStyleManager, m_spanStyleManager, m_tableStyleManager, m_stylesheetPath, m_stylesMethod, m_version);
++  m_currentHtml = m_htmlManager.create(m_imageManager, m_fontManager, m_listStyleManager, m_paragraphStyleManager, m_spanStyleManager, m_tableStyleManager, m_stylesheetPath, m_stylesMethod, m_layoutMethod, m_version);
+ 
+   // restore state in the new file
+   m_currentHtml->startDocument(m_documentProps);
+@@ -156,6 +157,11 @@ void EPUBGenerator::setStylesMethod(EPUBStylesMethod styles)
+   m_stylesMethod = styles;
+ }
+ 
++void EPUBGenerator::setLayoutMethod(EPUBLayoutMethod layout)
++{
++  m_layoutMethod = layout;
++}
++
+ void EPUBGenerator::writeContainer()
+ {
+   EPUBXMLSink sink;
+@@ -362,6 +368,15 @@ void EPUBGenerator::writeRoot()
+     metaAttrs.insert("content", generator.c_str());
+     sink.openElement("meta", metaAttrs);
+     sink.closeElement("meta");
++
++    if (m_layoutMethod == EPUB_LAYOUT_METHOD_FIXED)
++    {
++      metaAttrs.clear();
++      metaAttrs.insert("property", "rendition:layout");
++      sink.openElement("meta", metaAttrs);
++      sink.insertCharacters("pre-paginated");
++      sink.closeElement("meta");
++    }
+   }
+ 
+   sink.closeElement("metadata");
+diff --git a/src/lib/EPUBGenerator.h b/src/lib/EPUBGenerator.h
+index abc6a9a..5a0df86 100644
+--- a/src/lib/EPUBGenerator.h
++++ b/src/lib/EPUBGenerator.h
+@@ -53,6 +53,8 @@ public:
+ 
+   void setStylesMethod(EPUBStylesMethod stylesMethod);
+ 
++  void setLayoutMethod(EPUBLayoutMethod layoutMethod);
++
+ private:
+   virtual void startHtmlFile() = 0;
+   virtual void endHtmlFile() = 0;
+@@ -84,6 +86,7 @@ private:
+ 
+   int m_version;
+   EPUBStylesMethod m_stylesMethod;
++  EPUBLayoutMethod m_layoutMethod;
+ };
+ 
+ }
+diff --git a/src/lib/EPUBHTMLGenerator.cpp b/src/lib/EPUBHTMLGenerator.cpp
+index 5c6421c..4260858 100644
+--- a/src/lib/EPUBHTMLGenerator.cpp
++++ b/src/lib/EPUBHTMLGenerator.cpp
+@@ -7,6 +7,7 @@
+  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+  */
+ 
++#include <cmath>
+ #include <memory>
+ #include <sstream>
+ #include <stack>
+@@ -107,6 +108,11 @@ bool ZoneSinkImpl::endsInLineBreak() const
+          ;
+ }
+ 
++/// Convers inches to CSS pixels.
++int inchToCSSPixel(const librevenge::RVNGProperty *property)
++{
++  return round(property->getDouble() * 96);
++}
+ }
+ 
+ namespace
+@@ -371,7 +377,7 @@ std::string EPUBHTMLTextZone::label(int id) const
+ struct EPUBHTMLGeneratorImpl
+ {
+   //! constructor
+-  EPUBHTMLGeneratorImpl(EPUBXMLSink &document, EPUBImageManager &imageManager, EPUBFontManager &fontManager, EPUBListStyleManager &listStyleManager, EPUBParagraphStyleManager &paragraphStyleManager, EPUBSpanStyleManager &spanStyleManager, EPUBTableStyleManager &tableStyleManager, const EPUBPath &path, const EPUBPath &stylesheetPath, EPUBStylesMethod stylesMethod, int version)
++  EPUBHTMLGeneratorImpl(EPUBXMLSink &document, EPUBImageManager &imageManager, EPUBFontManager &fontManager, EPUBListStyleManager &listStyleManager, EPUBParagraphStyleManager &paragraphStyleManager, EPUBSpanStyleManager &spanStyleManager, EPUBTableStyleManager &tableStyleManager, const EPUBPath &path, const EPUBPath &stylesheetPath, EPUBStylesMethod stylesMethod, EPUBLayoutMethod layoutMethod, int version)
+     : m_document(document)
+     , m_imageManager(imageManager)
+     , m_fontManager(fontManager)
+@@ -382,6 +388,7 @@ struct EPUBHTMLGeneratorImpl
+     , m_path(path)
+     , m_stylesheetPath(stylesheetPath)
+     , m_actualPage(0)
++    , m_actualPageProperties()
+     , m_ignore(false)
+     , m_hasText(false)
+     , m_version(version)
+@@ -389,6 +396,7 @@ struct EPUBHTMLGeneratorImpl
+     , m_framePropertiesStack()
+     , m_linkPropertiesStack()
+     , m_stylesMethod(stylesMethod)
++    , m_layoutMethod(layoutMethod)
+     , m_actualSink()
+     , m_sinkStack()
+   {
+@@ -477,6 +485,7 @@ struct EPUBHTMLGeneratorImpl
+   const EPUBPath m_stylesheetPath;
+ 
+   int m_actualPage;
++  RVNGPropertyList m_actualPageProperties;
+   bool m_ignore;
+   /// Does the currently opened paragraph have some text?
+   bool m_hasText;
+@@ -488,6 +497,7 @@ struct EPUBHTMLGeneratorImpl
+   std::stack<RVNGPropertyList> m_linkPropertiesStack;
+ 
+   EPUBStylesMethod m_stylesMethod;
++  EPUBLayoutMethod m_layoutMethod;
+ 
+ protected:
+   std::unique_ptr<TextZoneSink> m_actualSink;
+@@ -499,8 +509,8 @@ private:
+   EPUBHTMLGeneratorImpl operator=(EPUBHTMLGeneratorImpl const &orig);
+ };
+ 
+-EPUBHTMLGenerator::EPUBHTMLGenerator(EPUBXMLSink &document, EPUBImageManager &imageManager, EPUBFontManager &fontManager, EPUBListStyleManager &listStyleManager, EPUBParagraphStyleManager &paragraphStyleManager, EPUBSpanStyleManager &spanStyleManager, EPUBTableStyleManager &tableStyleManager, const EPUBPath &path, const EPUBPath &stylesheetPath, EPUBStylesMethod stylesMethod, int version)
+-  : m_impl(new EPUBHTMLGeneratorImpl(document, imageManager, fontManager, listStyleManager, paragraphStyleManager, spanStyleManager, tableStyleManager, path, stylesheetPath, stylesMethod, version))
++EPUBHTMLGenerator::EPUBHTMLGenerator(EPUBXMLSink &document, EPUBImageManager &imageManager, EPUBFontManager &fontManager, EPUBListStyleManager &listStyleManager, EPUBParagraphStyleManager &paragraphStyleManager, EPUBSpanStyleManager &spanStyleManager, EPUBTableStyleManager &tableStyleManager, const EPUBPath &path, const EPUBPath &stylesheetPath, EPUBStylesMethod stylesMethod, EPUBLayoutMethod layoutMethod, int version)
++  : m_impl(new EPUBHTMLGeneratorImpl(document, imageManager, fontManager, listStyleManager, paragraphStyleManager, spanStyleManager, tableStyleManager, path, stylesheetPath, stylesMethod, layoutMethod, version))
+ {
+ }
+ 
+@@ -560,6 +570,25 @@ void EPUBHTMLGenerator::endDocument()
+   metaAttrs.insert("content", "text/html; charset=UTF-8");
+   m_impl->m_document.openElement("meta", metaAttrs);
+   m_impl->m_document.closeElement("meta");
++  if (m_impl->m_version >= 30 && m_impl->m_layoutMethod == EPUB_LAYOUT_METHOD_FIXED)
++  {
++    metaAttrs.clear();
++    metaAttrs.insert("name", "viewport");
++    std::stringstream content;
++    if (const librevenge::RVNGProperty *pageWidth = m_impl->m_actualPageProperties["fo:page-width"])
++    {
++      content << "width=";
++      content << inchToCSSPixel(pageWidth);
++    }
++    if (const librevenge::RVNGProperty *pageHeight = m_impl->m_actualPageProperties["fo:page-height"])
++    {
++      content << ", height=";
++      content << inchToCSSPixel(pageHeight);
++    }
++    metaAttrs.insert("content", content.str().c_str());
++    m_impl->m_document.openElement("meta", metaAttrs);
++    m_impl->m_document.closeElement("meta");
++  }
+   if (m_impl->m_version < 30)
+     m_impl->sendMetaData(m_impl->m_document);
+   RVNGPropertyList linkAttrs;
+@@ -582,9 +611,13 @@ void EPUBHTMLGenerator::defineEmbeddedFont(const RVNGPropertyList &propList)
+   m_impl->m_fontManager.insert(propList, m_impl->m_path);
+ }
+ 
+-void EPUBHTMLGenerator::openPageSpan(const RVNGPropertyList & /* propList */)
++void EPUBHTMLGenerator::openPageSpan(const RVNGPropertyList &propList)
+ {
+   m_impl->m_actualPage++;
++
++  librevenge::RVNGPropertyList::Iter i(propList);
++  for (i.rewind(); i.next();)
++    m_impl->m_actualPageProperties.insert(i.key(), i()->clone());
+ }
+ 
+ void EPUBHTMLGenerator::closePageSpan()
+diff --git a/src/lib/EPUBHTMLGenerator.h b/src/lib/EPUBHTMLGenerator.h
+index 3699179..3c6577f 100644
+--- a/src/lib/EPUBHTMLGenerator.h
++++ b/src/lib/EPUBHTMLGenerator.h
+@@ -32,7 +32,7 @@ class EPUBXMLSink;
+ class EPUBHTMLGenerator : public librevenge::RVNGTextInterface
+ {
+ public:
+-  EPUBHTMLGenerator(EPUBXMLSink &document, EPUBImageManager &imageManager, EPUBFontManager &fontManager, EPUBListStyleManager &listStyleManager, EPUBParagraphStyleManager &paragraphStyleManager, EPUBSpanStyleManager &spanStyleManager, EPUBTableStyleManager &tableStyleManager, const EPUBPath &path, const EPUBPath &stylesheetPath, EPUBStylesMethod stylesMethod, int version);
++  EPUBHTMLGenerator(EPUBXMLSink &document, EPUBImageManager &imageManager, EPUBFontManager &fontManager, EPUBListStyleManager &listStyleManager, EPUBParagraphStyleManager &paragraphStyleManager, EPUBSpanStyleManager &spanStyleManager, EPUBTableStyleManager &tableStyleManager, const EPUBPath &path, const EPUBPath &stylesheetPath, EPUBStylesMethod stylesMethod, EPUBLayoutMethod layoutMethod, int version);
+   ~EPUBHTMLGenerator() override;
+ 
+   void setDocumentMetaData(const librevenge::RVNGPropertyList &propList) override;
+diff --git a/src/lib/EPUBHTMLManager.cpp b/src/lib/EPUBHTMLManager.cpp
+index d2c21da..363b33e 100644
+--- a/src/lib/EPUBHTMLManager.cpp
++++ b/src/lib/EPUBHTMLManager.cpp
+@@ -41,7 +41,7 @@ EPUBHTMLManager::EPUBHTMLManager(EPUBManifest &manifest)
+ {
+ }
+ 
+-const EPUBHTMLGeneratorPtr_t EPUBHTMLManager::create(EPUBImageManager &imageManager, EPUBFontManager &fontManager, EPUBListStyleManager &listStyleManager, EPUBParagraphStyleManager &paragraphStyleManager, EPUBSpanStyleManager &spanStyleManager, EPUBTableStyleManager &tableStyleManager, const EPUBPath &stylesheetPath, EPUBStylesMethod stylesMethod, int version)
++const EPUBHTMLGeneratorPtr_t EPUBHTMLManager::create(EPUBImageManager &imageManager, EPUBFontManager &fontManager, EPUBListStyleManager &listStyleManager, EPUBParagraphStyleManager &paragraphStyleManager, EPUBSpanStyleManager &spanStyleManager, EPUBTableStyleManager &tableStyleManager, const EPUBPath &stylesheetPath, EPUBStylesMethod stylesMethod, EPUBLayoutMethod layoutMethod, int version)
+ {
+   std::ostringstream nameBuf;
+   nameBuf << "section" << std::setw(4) << std::setfill('0') << m_number.next();
+@@ -55,7 +55,7 @@ const EPUBHTMLGeneratorPtr_t EPUBHTMLManager::create(EPUBImageManager &imageMana
+   m_contents.push_back(EPUBXMLSink());
+ 
+   const EPUBHTMLGeneratorPtr_t gen(
+-    new EPUBHTMLGenerator(m_contents.back(), imageManager, fontManager, listStyleManager, paragraphStyleManager, spanStyleManager, tableStyleManager, m_paths.back(), stylesheetPath, stylesMethod, version));
++    new EPUBHTMLGenerator(m_contents.back(), imageManager, fontManager, listStyleManager, paragraphStyleManager, spanStyleManager, tableStyleManager, m_paths.back(), stylesheetPath, stylesMethod, layoutMethod, version));
+ 
+   return gen;
+ }
+diff --git a/src/lib/EPUBHTMLManager.h b/src/lib/EPUBHTMLManager.h
+index e1205e6..31e6dfe 100644
+--- a/src/lib/EPUBHTMLManager.h
++++ b/src/lib/EPUBHTMLManager.h
+@@ -41,7 +41,7 @@ class EPUBHTMLManager
+ public:
+   explicit EPUBHTMLManager(EPUBManifest &manifest);
+ 
+-  const EPUBHTMLGeneratorPtr_t create(EPUBImageManager &imageManager, EPUBFontManager &fontManager, EPUBListStyleManager &listStyleManager, EPUBParagraphStyleManager &paragraphStyleManager, EPUBSpanStyleManager &spanStyleManager, EPUBTableStyleManager &tableStyleManager, const EPUBPath &stylesheetPath, EPUBStylesMethod stylesMethod, int version);
++  const EPUBHTMLGeneratorPtr_t create(EPUBImageManager &imageManager, EPUBFontManager &fontManager, EPUBListStyleManager &listStyleManager, EPUBParagraphStyleManager &paragraphStyleManager, EPUBSpanStyleManager &spanStyleManager, EPUBTableStyleManager &tableStyleManager, const EPUBPath &stylesheetPath, EPUBStylesMethod stylesMethod, EPUBLayoutMethod layoutMethod, int version);
+ 
+   void writeTo(EPUBPackage &package);
+ 
+diff --git a/src/lib/EPUBTextGenerator.cpp b/src/lib/EPUBTextGenerator.cpp
+index 5d4e8f2..c3bc963 100644
+--- a/src/lib/EPUBTextGenerator.cpp
++++ b/src/lib/EPUBTextGenerator.cpp
+@@ -147,6 +147,11 @@ void EPUBTextGenerator::setStylesMethod(EPUBStylesMethod styles)
+   m_impl->setStylesMethod(styles);
+ }
+ 
++void EPUBTextGenerator::setLayoutMethod(EPUBLayoutMethod layout)
++{
++  m_impl->setLayoutMethod(layout);
++}
++
+ void EPUBTextGenerator::registerEmbeddedImageHandler(const librevenge::RVNGString &mimeType, EPUBEmbeddedImage imageHandler)
+ {
+   if (!mimeType.empty() && imageHandler)
+-- 
+2.13.6
+
diff --git a/writerperfect/qa/unit/EPUBExportTest.cxx b/writerperfect/qa/unit/EPUBExportTest.cxx
index 335347de60ff..a9692bc2c293 100644
--- a/writerperfect/qa/unit/EPUBExportTest.cxx
+++ b/writerperfect/qa/unit/EPUBExportTest.cxx
@@ -57,6 +57,7 @@ public:
     void testOutlineLevel();
     void testMimetype();
     void testEPUB2();
+    void testEPUBFixedLayout();
     void testPageBreakSplit();
     void testSpanAutostyle();
     void testParaAutostyleCharProps();
@@ -96,6 +97,7 @@ public:
     CPPUNIT_TEST(testOutlineLevel);
     CPPUNIT_TEST(testMimetype);
     CPPUNIT_TEST(testEPUB2);
+    CPPUNIT_TEST(testEPUBFixedLayout);
     CPPUNIT_TEST(testPageBreakSplit);
     CPPUNIT_TEST(testSpanAutostyle);
     CPPUNIT_TEST(testParaAutostyleCharProps);
@@ -292,6 +294,20 @@ void EPUBExportTest::testEPUB2()
     assertXPath(mpXmlDoc, "/opf:package", "version", "2.0");
 }
 
+void EPUBExportTest::testEPUBFixedLayout()
+{
+    uno::Sequence<beans::PropertyValue> aFilterData(comphelper::InitPropertySequence(
+    {
+        // Explicitly request fixed layout.
+        {"EPUBLayoutMethod", uno::makeAny(static_cast<sal_Int32>(libepubgen::EPUB_LAYOUT_METHOD_FIXED))}
+    }));
+    createDoc("hello.fodt", aFilterData);
+
+    mpXmlDoc = parseExport("OEBPS/content.opf");
+    // This was missing, EPUBLayoutMethod filter option was ignored and we always emitted reflowable layout.
+    assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/opf:meta[@property='rendition:layout']", "pre-paginated");
+}
+
 void EPUBExportTest::testPageBreakSplit()
 {
     uno::Sequence<beans::PropertyValue> aFilterData(comphelper::InitPropertySequence(
diff --git a/writerperfect/source/writer/EPUBExportFilter.cxx b/writerperfect/source/writer/EPUBExportFilter.cxx
index ba9e30d85df9..8ebf5994aedc 100644
--- a/writerperfect/source/writer/EPUBExportFilter.cxx
+++ b/writerperfect/source/writer/EPUBExportFilter.cxx
@@ -48,10 +48,20 @@ sal_Int32 EPUBExportFilter::GetDefaultSplitMethod()
     return libepubgen::EPUB_SPLIT_METHOD_HEADING;
 }
 
+sal_Int32 EPUBExportFilter::GetDefaultLayoutMethod()
+{
+#if LIBEPUBGEN_VERSION_SUPPORT
+    return libepubgen::EPUB_LAYOUT_METHOD_REFLOWABLE;
+#else
+    return 0;
+#endif
+}
+
 sal_Bool EPUBExportFilter::filter(const uno::Sequence<beans::PropertyValue> &rDescriptor)
 {
     sal_Int32 nVersion = EPUBExportFilter::GetDefaultVersion();
     sal_Int32 nSplitMethod = EPUBExportFilter::GetDefaultSplitMethod();
+    sal_Int32 nLayoutMethod = EPUBExportFilter::GetDefaultLayoutMethod();
     uno::Sequence<beans::PropertyValue> aFilterData;
     for (sal_Int32 i = 0; i < rDescriptor.getLength(); ++i)
     {
@@ -68,6 +78,8 @@ sal_Bool EPUBExportFilter::filter(const uno::Sequence<beans::PropertyValue> &rDe
             aFilterData[i].Value >>= nVersion;
         else if (aFilterData[i].Name == "EPUBSplitMethod")
             aFilterData[i].Value >>= nSplitMethod;
+        else if (aFilterData[i].Name == "EPUBLayoutMethod")
+            aFilterData[i].Value >>= nLayoutMethod;
     }
 
     // Build the export filter chain: the package has direct access to the ZIP
@@ -79,6 +91,9 @@ sal_Bool EPUBExportFilter::filter(const uno::Sequence<beans::PropertyValue> &rDe
                                              , nVersion
 #endif
                                             );
+#if LIBEPUBGEN_VERSION_SUPPORT
+    aGenerator.setLayoutMethod(static_cast<libepubgen::EPUBLayoutMethod>(nLayoutMethod));
+#endif
     OUString aSourceURL;
     uno::Reference<frame::XModel> xSourceModel(mxSourceDocument, uno::UNO_QUERY);
     if (xSourceModel.is())
diff --git a/writerperfect/source/writer/EPUBExportFilter.hxx b/writerperfect/source/writer/EPUBExportFilter.hxx
index b423f96175e7..e96b0a84b695 100644
--- a/writerperfect/source/writer/EPUBExportFilter.hxx
+++ b/writerperfect/source/writer/EPUBExportFilter.hxx
@@ -50,6 +50,8 @@ public:
     static sal_Int32 GetDefaultVersion();
     /// Gives the default split method.
     static sal_Int32 GetDefaultSplitMethod();
+    /// Gives the default layout method.
+    static sal_Int32 GetDefaultLayoutMethod();
 };
 
 } // namespace writerperfect


More information about the Libreoffice-commits mailing list