[Libreoffice-commits] core.git: external/libepubgen

2018-10-24 Thread Libreoffice Gerrit user
 external/libepubgen/UnpackedTarball_libepubgen.mk |1 
 external/libepubgen/tdf-120491.patch  |   33 ++
 2 files changed, 34 insertions(+)

New commits:
commit 548e60a8c47e270aba79a5f4e5911cbb35462814
Author: Miklos Vajna 
AuthorDate: Wed Oct 24 09:25:35 2018 +0200
Commit: Miklos Vajna 
CommitDate: Wed Oct 24 12:43:25 2018 +0200

tdf#120491 EPUB export: fix IngramSpark validator error

Change-Id: I7b6d2217525dbf2e8c9c78a14ea7601c4170857a
Reviewed-on: https://gerrit.libreoffice.org/62267
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/external/libepubgen/UnpackedTarball_libepubgen.mk 
b/external/libepubgen/UnpackedTarball_libepubgen.mk
index 14efadb337c0..7553e825284f 100644
--- a/external/libepubgen/UnpackedTarball_libepubgen.mk
+++ b/external/libepubgen/UnpackedTarball_libepubgen.mk
@@ -8,6 +8,7 @@
 #
 
 epubgen_patches :=
+epubgen_patches += tdf-120491.patch
 
 ifeq ($(COM_IS_CLANG),TRUE)
 ifneq ($(filter -fsanitize=%,$(CC)),)
diff --git a/external/libepubgen/tdf-120491.patch 
b/external/libepubgen/tdf-120491.patch
new file mode 100644
index ..2a02a66e4808
--- /dev/null
+++ b/external/libepubgen/tdf-120491.patch
@@ -0,0 +1,33 @@
+From 92760e4b0b8da126029c5ff858ebec27df4acfa8 Mon Sep 17 00:00:00 2001
+Subject: [PATCH] tdf#120491 EPUBHTMLGenerator: remove not needed 
+
+IngramSpark flags this as an error, and not writing it still passes
+epubcheck.
+---
+ src/lib/EPUBHTMLGenerator.cpp | 7 +--
+ 1 file changed, 1 insertion(+), 6 deletions(-)
+
+diff --git a/src/lib/EPUBHTMLGenerator.cpp b/src/lib/EPUBHTMLGenerator.cpp
+index a950ea5..f6c2527 100644
+--- src/lib/EPUBHTMLGenerator.cpp
 src/lib/EPUBHTMLGenerator.cpp
+@@ -579,14 +579,9 @@ void EPUBHTMLGenerator::endDocument()
+ m_impl->m_document.openElement("title", RVNGPropertyList());
+ m_impl->m_document.closeElement("title");
+   }
+-  RVNGPropertyList metaAttrs;
+-  metaAttrs.insert("http-equiv", "content-type");
+-  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();
++RVNGPropertyList metaAttrs;
+ metaAttrs.insert("name", "viewport");
+ std::stringstream content;
+ if (const librevenge::RVNGProperty *pageWidth = 
m_impl->m_actualPageProperties["fo:page-width"])
+-- 
+2.16.4
+
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2018-04-26 Thread Mark Hung
 
external/libepubgen/0001-Enclose-span-with-ruby-if-text-ruby-text-is-set.patch.1
 |  117 ++
 external/libepubgen/UnpackedTarball_libepubgen.mk  
  |2 
 writerperfect/qa/unit/EPUBExportTest.cxx   
  |   10 
 writerperfect/qa/unit/data/writer/epubexport/simple-ruby.odt   
  |binary
 writerperfect/source/writer/exp/txtparai.cxx   
  |   85 +++
 5 files changed, 214 insertions(+)

New commits:
commit 4fb081704811b66194ea11e528ad792957b7ccfd
Author: Mark Hung 
Date:   Tue Apr 24 21:26:49 2018 +0800

tdf#116822 export ruby text and base text to epub.

Backport aa254c9e6f2d1ecfa2512111746a77c05ba9717f from libepubgen,
implement XMLRubyContext, XMLRubyTextContext, XMLRubyBaseContext.

Character formats of ruby text, ruby alignment, and ruby position
are not implemented yet.

Change-Id: I6c3708e6bc8e9e36a68171a037fd393f45d8d34f
Reviewed-on: https://gerrit.libreoffice.org/53408
Tested-by: Jenkins 
Reviewed-by: Miklos Vajna 

diff --git 
a/external/libepubgen/0001-Enclose-span-with-ruby-if-text-ruby-text-is-set.patch.1
 
b/external/libepubgen/0001-Enclose-span-with-ruby-if-text-ruby-text-is-set.patch.1
new file mode 100644
index ..99c8523a9dc9
--- /dev/null
+++ 
b/external/libepubgen/0001-Enclose-span-with-ruby-if-text-ruby-text-is-set.patch.1
@@ -0,0 +1,117 @@
+From 16c4e93af6d5eb9d021a671c54af664edc120df9 Mon Sep 17 00:00:00 2001
+From: Mark Hung 
+Date: Mon, 23 Apr 2018 01:24:48 +0800
+Subject: [PATCH] Enclose  with  if text:ruby-text is set.
+
+---
+ src/lib/EPUBHTMLGenerator.cpp  | 22 ++
+ src/test/EPUBTextGeneratorTest.cpp | 25 +
+ 2 files changed, 47 insertions(+)
+
+diff --git a/src/lib/EPUBHTMLGenerator.cpp b/src/lib/EPUBHTMLGenerator.cpp
+index 0080816..a4467a9 100644
+--- a/src/lib/EPUBHTMLGenerator.cpp
 b/src/lib/EPUBHTMLGenerator.cpp
+@@ -397,6 +397,7 @@ struct EPUBHTMLGeneratorImpl
+ , m_linkPropertiesStack()
+ , m_paragraphAttributesStack()
+ , m_spanAttributesStack()
++, m_rubyText()
+ , m_stylesMethod(stylesMethod)
+ , m_layoutMethod(layoutMethod)
+ , m_actualSink()
+@@ -500,6 +501,9 @@ struct EPUBHTMLGeneratorImpl
+   std::stack m_paragraphAttributesStack;
+   std::stack m_spanAttributesStack;
+ 
++  /// This is set when the span has ruby text and should be wrapped in 
.
++  std::string m_rubyText;
++
+   EPUBStylesMethod m_stylesMethod;
+   EPUBLayoutMethod m_layoutMethod;
+ 
+@@ -743,6 +747,14 @@ void EPUBHTMLGenerator::openSpan(const RVNGPropertyList 
)
+ attrs.insert("style", m_impl->m_spanManager.getStyle(propList, 
false).c_str());
+ break;
+   }
++
++  const librevenge::RVNGProperty *rubyText = propList["text:ruby-text"];
++  if (rubyText)
++  {
++m_impl->m_rubyText = rubyText->getStr().cstr();
++m_impl->output(false).openElement("ruby", attrs);
++  }
++
+   m_impl->output(false).openElement("span", attrs);
+ 
+   librevenge::RVNGPropertyList::Iter i(attrs);
+@@ -761,6 +773,16 @@ void EPUBHTMLGenerator::closeSpan()
+ m_impl->m_spanAttributesStack.pop();
+ 
+   m_impl->output().closeElement("span");
++
++  if (m_impl->m_rubyText.length())
++  {
++m_impl->output().openElement("rt");
++m_impl->output().insertCharacters(m_impl->m_rubyText.c_str());
++m_impl->output().closeElement("rt");
++m_impl->output().closeElement("ruby");
++m_impl->m_hasText = true;
++m_impl->m_rubyText.clear();
++  }
+ }
+ 
+ void EPUBHTMLGenerator::openLink(const RVNGPropertyList )
+diff --git a/src/test/EPUBTextGeneratorTest.cpp 
b/src/test/EPUBTextGeneratorTest.cpp
+index f03824f..61c7cac 100644
+--- a/src/test/EPUBTextGeneratorTest.cpp
 b/src/test/EPUBTextGeneratorTest.cpp
+@@ -240,6 +240,7 @@ private:
+   CPPUNIT_TEST(testSplitOnHeadingInPageSpan);
+   CPPUNIT_TEST(testSplitOnSizeInPageSpan);
+   CPPUNIT_TEST(testManyWritingModes);
++  CPPUNIT_TEST(testRubyElements);
+   CPPUNIT_TEST_SUITE_END();
+ 
+ private:
+@@ -284,6 +285,7 @@ private:
+   void testSplitOnHeadingInPageSpan();
+   void testSplitOnSizeInPageSpan();
+   void testManyWritingModes();
++  void testRubyElements();
+ 
+   /// Asserts that exactly one xpath exists in buffer, and its content equals 
content.
+   void assertXPathContent(xmlBufferPtr buffer, const std::string , 
const std::string );
+@@ -1507,6 +1509,29 @@ void EPUBTextGeneratorTest::testManyWritingModes()
+   assertXPath(package.m_streams["OEBPS/sections/section0002.xhtml"], 
"//xhtml:body", "class", "body1");
+ }
+ 
++void EPUBTextGeneratorTest::testRubyElements()
++{
++  StringEPUBPackage package;
++  libepubgen::EPUBTextGenerator generator();
++  generator.startDocument(librevenge::RVNGPropertyList());
++  generator.openParagraph(librevenge::RVNGPropertyList());
++  {
++

[Libreoffice-commits] core.git: external/libepubgen

2018-04-04 Thread Mark Hung
 
external/libepubgen/0001-Support-writing-mode-for-reflowable-layout-method.patch.1
|  264 ++
 
external/libepubgen/0002-Always-keep-page-properties-when-splitting-the-HTML-.patch.1
 |  181 ++
 external/libepubgen/0003-Ensure-page-properties-in-the-page-span-works.patch.1 
   |  225 
 external/libepubgen/UnpackedTarball_libepubgen.mk  
   |6 
 4 files changed, 676 insertions(+)

New commits:
commit 75c166d058717a7edd26273f50a86fe5f2cc7fb0
Author: Mark Hung 
Date:   Wed Mar 28 07:26:08 2018 +0800

tdf#115623: patch libepubgen to support writing-mode.

Backport three patches from libepubgen master branch to support
exporting style:writing-mode as body CSS styles.

1. Support writing-mode for reflowable layout method.

https://sourceforge.net/p/libepubgen/code/ci/9a284081eea4a95235a6d6a6a50cbe3f7ad323ba/

2. Always keep page properties when splitting.

https://sourceforge.net/p/libepubgen/code/ci/0318031b9094b9180d1d391d0ca31a782b016e99/

3. Ensure page properties in the page span work

https://sourceforge.net/p/libepubgen/code/ci/1f602fcaa74fc9dbc6457019d11c602ff4040a4e/

Change-Id: I9033cb1f5fcbfedb423308fb29b9bd4d6d7d7a43
Reviewed-on: https://gerrit.libreoffice.org/52083
Tested-by: Jenkins 
Reviewed-by: Miklos Vajna 

diff --git 
a/external/libepubgen/0001-Support-writing-mode-for-reflowable-layout-method.patch.1
 
b/external/libepubgen/0001-Support-writing-mode-for-reflowable-layout-method.patch.1
new file mode 100644
index ..d3799d1d6e8b
--- /dev/null
+++ 
b/external/libepubgen/0001-Support-writing-mode-for-reflowable-layout-method.patch.1
@@ -0,0 +1,264 @@
+From 9b1c3fd42fa256b58dfb4dedd070954406c25596 Mon Sep 17 00:00:00 2001
+From: Mark Hung 
+Date: Mon, 19 Mar 2018 20:36:11 +0800
+Subject: [PATCH 1/3] Support writing-mode for reflowable layout method.
+
+Convert style:writing-mode in page properties to css style for
+HTML body element. The class names of body elements will be like
+"body0".
+---
+ src/lib/EPUBGenerator.cpp  |  1 +
+ src/lib/EPUBHTMLGenerator.cpp  | 18 +--
+ src/lib/EPUBSpanStyleManager.cpp   | 45 --
+ src/lib/EPUBSpanStyleManager.h | 14 
+ src/test/EPUBTextGeneratorTest.cpp | 25 +
+ 5 files changed, 90 insertions(+), 13 deletions(-)
+
+diff --git a/src/lib/EPUBGenerator.cpp b/src/lib/EPUBGenerator.cpp
+index 83f3f40..56db4dc 100644
+--- a/src/lib/EPUBGenerator.cpp
 b/src/lib/EPUBGenerator.cpp
+@@ -122,6 +122,7 @@ void EPUBGenerator::startNewHtmlFile()
+   if (m_layoutMethod == EPUB_LAYOUT_METHOD_FIXED && m_currentHtml)
+ m_currentHtml->getPageProperties(pageProperties);
+   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);
++
+   if (m_layoutMethod == EPUB_LAYOUT_METHOD_FIXED)
+ m_currentHtml->setPageProperties(pageProperties);
+ 
+diff --git a/src/lib/EPUBHTMLGenerator.cpp b/src/lib/EPUBHTMLGenerator.cpp
+index 342213e..d5cc0d2 100644
+--- a/src/lib/EPUBHTMLGenerator.cpp
 b/src/lib/EPUBHTMLGenerator.cpp
+@@ -600,6 +600,20 @@ void EPUBHTMLGenerator::endDocument()
+   RVNGPropertyList bodyAttrs;
+   if (m_impl->m_version >= 30)
+ bodyAttrs.insert("xmlns:epub", "http://www.idpf.org/2007/ops;);
++
++  if (m_impl->m_actualPageProperties["style:writing-mode"])
++  {
++switch (m_impl->m_stylesMethod)
++{
++case EPUB_STYLES_METHOD_CSS:
++  bodyAttrs.insert("class", 
m_impl->m_spanManager.getClass(m_impl->m_actualPageProperties, true).c_str());
++  break;
++case EPUB_STYLES_METHOD_INLINE:
++  bodyAttrs.insert("style", 
m_impl->m_spanManager.getStyle(m_impl->m_actualPageProperties, true).c_str());
++  break;
++}
++  }
++
+   m_impl->m_document.openElement("body", bodyAttrs);
+   m_impl->flushUnsent(m_impl->m_document);
+   m_impl->m_document.closeElement("body");
+@@ -710,10 +724,10 @@ void EPUBHTMLGenerator::openSpan(const RVNGPropertyList 
)
+   switch (m_impl->m_stylesMethod)
+   {
+   case EPUB_STYLES_METHOD_CSS:
+-attrs.insert("class", m_impl->m_spanManager.getClass(propList).c_str());
++attrs.insert("class", m_impl->m_spanManager.getClass(propList, 
false).c_str());
+ break;
+   case EPUB_STYLES_METHOD_INLINE:
+-attrs.insert("style", m_impl->m_spanManager.getStyle(propList).c_str());
++attrs.insert("style", m_impl->m_spanManager.getStyle(propList, 
false).c_str());
+ break;
+   }
+   m_impl->output(false).openElement("span", attrs);
+diff --git a/src/lib/EPUBSpanStyleManager.cpp 
b/src/lib/EPUBSpanStyleManager.cpp
+index e25fa26..ded34ba 100644
+--- a/src/lib/EPUBSpanStyleManager.cpp
 

[Libreoffice-commits] core.git: external/libepubgen writerperfect/Module_writerperfect.mk

2018-01-23 Thread Miklos Vajna
 external/libepubgen/libepubgen-epub3.patch.1 |   68 +++
 writerperfect/Module_writerperfect.mk|2 
 2 files changed, 69 insertions(+), 1 deletion(-)

New commits:
commit 90ae1e1bbbce7be9b2ff7add75923b1891e65df6
Author: Miklos Vajna 
Date:   Mon Jan 22 16:00:10 2018 +0100

EPUB export, fxl: silence Page  toc entries when have chapter names

The EPUB ToC is now on par with the PDF ToC.

Change-Id: Iea714fdb68c825aa14345037e909c354bbd7cf00
Reviewed-on: https://gerrit.libreoffice.org/48346
Tested-by: Jenkins 
Reviewed-by: Miklos Vajna 

diff --git a/external/libepubgen/libepubgen-epub3.patch.1 
b/external/libepubgen/libepubgen-epub3.patch.1
index bcec187b5218..f102eaefe7a6 100644
--- a/external/libepubgen/libepubgen-epub3.patch.1
+++ b/external/libepubgen/libepubgen-epub3.patch.1
@@ -355,3 +355,71 @@ index 8e88adb..38ddcdf 100644
 -- 
 2.13.6
 
+From b6081f659e3000d9f3d5851278d8abdd33448353 Mon Sep 17 00:00:00 2001
+From: Miklos Vajna 
+Date: Mon, 22 Jan 2018 15:54:43 +0100
+Subject: [PATCH] fixed layout: avoid Page  entries when chapter names are
+ provided
+
+---
+ src/lib/EPUBHTMLManager.cpp| 31 ++-
+ src/test/EPUBTextGeneratorTest.cpp | 16 
+ 2 files changed, 34 insertions(+), 13 deletions(-)
+
+diff --git a/src/lib/EPUBHTMLManager.cpp b/src/lib/EPUBHTMLManager.cpp
+index d35bc3f..35d82e8 100644
+--- a/src/lib/EPUBHTMLManager.cpp
 b/src/lib/EPUBHTMLManager.cpp
+@@ -7,6 +7,7 @@
+  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+  */
+ 
++#include 
+ #include 
+ #include 
+ #include 
+@@ -91,24 +92,28 @@ void EPUBHTMLManager::writeTocTo(EPUBXMLSink , const 
EPUBPath , int
+ {
+   if (version >= 30)
+   {
++bool hasChapterNames = std::find_if(m_paths.begin(), m_paths.end(), 
[](const EPUBPath )
++{
++  return !path.getChapters().empty();
++}) != m_paths.end();
+ for (std::vector::size_type i = 0; m_paths.size() != i; ++i)
+ {
+   const std::vector  = m_paths[i].getChapters();
+-  if (!chapters.empty())
++  for (const auto  : chapters)
+   {
+-for (const auto  : chapters)
+-{
+-  sink.openElement("li");
+-  librevenge::RVNGPropertyList anchorAttrs;
+-  anchorAttrs.insert("href", 
m_paths[i].relativeTo(tocPath).str().c_str());
+-  sink.openElement("a", anchorAttrs);
+-  std::ostringstream label;
+-  sink.insertCharacters(chapter.c_str());
+-  sink.closeElement("a");
+-  sink.closeElement("li");
+-}
+-continue;
++sink.openElement("li");
++librevenge::RVNGPropertyList anchorAttrs;
++anchorAttrs.insert("href", 
m_paths[i].relativeTo(tocPath).str().c_str());
++sink.openElement("a", anchorAttrs);
++std::ostringstream label;
++sink.insertCharacters(chapter.c_str());
++sink.closeElement("a");
++sink.closeElement("li");
+   }
++  if (hasChapterNames)
++// Chapter names are provided for this document, so never write Page
++//  entries.
++continue;
+ 
+   sink.openElement("li");
+   librevenge::RVNGPropertyList anchorAttrs;
+-- 
+2.13.6
+
diff --git a/writerperfect/Module_writerperfect.mk 
b/writerperfect/Module_writerperfect.mk
index 6fa274bc8ce5..01f8a0dc5e59 100644
--- a/writerperfect/Module_writerperfect.mk
+++ b/writerperfect/Module_writerperfect.mk
@@ -40,7 +40,7 @@ $(eval $(call gb_Module_add_check_targets,writerperfect,\
 $(eval $(call gb_Module_add_slowcheck_targets,writerperfect,\
CppunitTest_writerperfect_calc \
CppunitTest_writerperfect_draw \
-   CppunitTest_writerperfect_epubexport \
+   $(if $(SYSTEM_EPUBGEN),,CppunitTest_writerperfect_epubexport) \
CppunitTest_writerperfect_import \
CppunitTest_writerperfect_impress \
CppunitTest_writerperfect_writer \
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: external/libepubgen filter/source include/svtools include/vcl svtools/source sw/source vcl/source writerperfect/qa writerperfect/source

2018-01-23 Thread Miklos Vajna
 external/libepubgen/libepubgen-epub3.patch.1|  158 
 filter/source/graphic/GraphicExportFilter.cxx   |2 
 include/svtools/DocumentToGraphicRenderer.hxx   |   10 
 include/vcl/pdfextoutdevdata.hxx|2 
 svtools/source/filter/DocumentToGraphicRenderer.cxx |   26 +
 svtools/source/filter/exportdialog.cxx  |2 
 sw/source/uibase/uno/unotxdoc.cxx   |5 
 vcl/source/gdi/pdfextoutdevdata.cxx |4 
 writerperfect/qa/unit/EPUBExportTest.cxx|7 
 writerperfect/qa/unit/data/writer/epubexport/fxl-2page.fodt |7 
 writerperfect/source/writer/EPUBExportFilter.cxx|   12 
 writerperfect/source/writer/EPUBExportFilter.hxx|4 
 writerperfect/source/writer/exp/xmlimp.cxx  |   32 +-
 writerperfect/source/writer/exp/xmlimp.hxx  |   17 -
 14 files changed, 261 insertions(+), 27 deletions(-)

New commits:
commit a54787669b9283efdfdd18b0cbafc3184cdde58f
Author: Miklos Vajna 
Date:   Mon Jan 22 15:18:45 2018 +0100

EPUB export, fixed layout: add chapter names to the navigation document

Extend vcl::PDFExtOutDevData so that it's possible to use it outside the
PDF export; this way the EPUB export can know which chapters start on
which page.

This means fixed and reflowable layout has the same table of contents,
instead of just Page  in the fixed layout case.

Change-Id: I935fb23c66ec747431b91e83b0e677d4e5f704b9
Reviewed-on: https://gerrit.libreoffice.org/48332
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins 

diff --git a/external/libepubgen/libepubgen-epub3.patch.1 
b/external/libepubgen/libepubgen-epub3.patch.1
index 4b7fe5215f05..bcec187b5218 100644
--- a/external/libepubgen/libepubgen-epub3.patch.1
+++ b/external/libepubgen/libepubgen-epub3.patch.1
@@ -197,3 +197,161 @@ index bdf3bf0..cb4efee 100644
 -- 
 2.13.6
 
+From c081609849b18113340c39a73b6af432a103a102 Mon Sep 17 00:00:00 2001
+From: Miklos Vajna 
+Date: Mon, 22 Jan 2018 14:39:19 +0100
+Subject: [PATCH] fixed layout: allow defining chapter names
+
+Fixed layout normally just works with SVG images (one image / page), but
+readable navigation document is still expected, e.g. PDF provides it. So
+add a way to mention what chapters start on a given page.
+---
+ src/lib/EPUBHTMLManager.cpp| 25 +
+ src/lib/EPUBHTMLManager.h  |  3 +++
+ src/lib/EPUBPath.cpp   | 11 +++
+ src/lib/EPUBPath.h |  4 
+ src/lib/EPUBTextGenerator.cpp  | 15 +++
+ src/test/EPUBTextGeneratorTest.cpp | 37 +
+ 6 files changed, 95 insertions(+)
+
+diff --git a/src/lib/EPUBHTMLManager.cpp b/src/lib/EPUBHTMLManager.cpp
+index 5e96d1d..d35bc3f 100644
+--- a/src/lib/EPUBHTMLManager.cpp
 b/src/lib/EPUBHTMLManager.cpp
+@@ -93,6 +93,23 @@ void EPUBHTMLManager::writeTocTo(EPUBXMLSink , const 
EPUBPath , int
+   {
+ for (std::vector::size_type i = 0; m_paths.size() != i; ++i)
+ {
++  const std::vector  = m_paths[i].getChapters();
++  if (!chapters.empty())
++  {
++for (const auto  : chapters)
++{
++  sink.openElement("li");
++  librevenge::RVNGPropertyList anchorAttrs;
++  anchorAttrs.insert("href", 
m_paths[i].relativeTo(tocPath).str().c_str());
++  sink.openElement("a", anchorAttrs);
++  std::ostringstream label;
++  sink.insertCharacters(chapter.c_str());
++  sink.closeElement("a");
++  sink.closeElement("li");
++}
++continue;
++  }
++
+   sink.openElement("li");
+   librevenge::RVNGPropertyList anchorAttrs;
+   anchorAttrs.insert("href", 
m_paths[i].relativeTo(tocPath).str().c_str());
+@@ -140,6 +157,14 @@ void EPUBHTMLManager::insertHeadingText(const std::string 
)
+   m_paths.back().appendTitle(text);
+ }
+ 
++void EPUBHTMLManager::addChapterName(const std::string )
++{
++  if (m_paths.empty())
++return;
++
++  m_paths.back().addChapter(text);
++}
++
+ bool EPUBHTMLManager::hasHeadingText() const
+ {
+   if (m_paths.empty())
+diff --git a/src/lib/EPUBHTMLManager.h b/src/lib/EPUBHTMLManager.h
+index 157896b..d48ddf2 100644
+--- a/src/lib/EPUBHTMLManager.h
 b/src/lib/EPUBHTMLManager.h
+@@ -51,6 +51,9 @@ public:
+   /// Appends text to the title of the current heading.
+   void insertHeadingText(const std::string );
+ 
++  /// Registers a chapter name for the current page (fixed layout case).
++  void addChapterName(const std::string );
++
+   /// If the current heading has a title.
+   bool hasHeadingText() const;
+ 
+diff --git a/src/lib/EPUBPath.cpp b/src/lib/EPUBPath.cpp
+index e1c05ed..be24de5 100644
+--- a/src/lib/EPUBPath.cpp
 

[Libreoffice-commits] core.git: external/libepubgen

2018-01-19 Thread Miklos Vajna
 external/libepubgen/libepubgen-epub3.patch.1 |   30 +++
 1 file changed, 30 insertions(+)

New commits:
commit d5d4166df8ad189761387146966c91d58c28076f
Author: Miklos Vajna 
Date:   Thu Jan 18 15:05:55 2018 +0100

EPUB export: handle text frame and image width

So that an image and its caption in a text frame always go to separate
lines.

Change-Id: I439e370ad3bc8628f80a8db45499f8bffd84ef2b
Reviewed-on: https://gerrit.libreoffice.org/48148
Tested-by: Jenkins 
Reviewed-by: Miklos Vajna 

diff --git a/external/libepubgen/libepubgen-epub3.patch.1 
b/external/libepubgen/libepubgen-epub3.patch.1
index 7ea3a365737f..4b7fe5215f05 100644
--- a/external/libepubgen/libepubgen-epub3.patch.1
+++ b/external/libepubgen/libepubgen-epub3.patch.1
@@ -167,3 +167,33 @@ index bc9c1b7..59ded90 100644
 -- 
 2.13.6
 
+From 51e17dc87d85f1dc71b380906f9260de4cd0371c Mon Sep 17 00:00:00 2001
+From: Miklos Vajna 
+Date: Thu, 18 Jan 2018 14:54:06 +0100
+Subject: [PATCH] EPUBImageManager: handle relative and absolute width
+
+---
+ src/lib/EPUBImageManager.cpp   |  6 +
+ src/test/EPUBTextGeneratorTest.cpp | 54 ++
+ 2 files changed, 60 insertions(+)
+
+diff --git a/src/lib/EPUBImageManager.cpp b/src/lib/EPUBImageManager.cpp
+index bdf3bf0..cb4efee 100644
+--- a/src/lib/EPUBImageManager.cpp
 b/src/lib/EPUBImageManager.cpp
+@@ -171,6 +171,12 @@ void 
EPUBImageManager::extractImageProperties(librevenge::RVNGPropertyList const
+   continue;
+ cssProps[type[i]] =  pList[field.c_str()]->getStr().cstr();
+   }
++
++  // Extract size.
++  if (auto pRelWidth = pList["style:rel-width"])
++cssProps["width"] = pRelWidth->getStr().cstr();
++  else if (auto pWidth = pList["svg:width"])
++cssProps["width"] = pWidth->getStr().cstr();
+ }
+ 
+ std::string EPUBImageManager::getWrapStyle(librevenge::RVNGPropertyList const 
)
+-- 
+2.13.6
+
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: external/libepubgen

2017-12-22 Thread Miklos Vajna
 external/libepubgen/UnpackedTarball_libepubgen.mk |2 
 external/libepubgen/libepubgen-epub3.patch.1  |  169 ++
 2 files changed, 171 insertions(+)

New commits:
commit fe652ec259f7ca9e79810553ce6c884688963102
Author: Miklos Vajna 
Date:   Fri Dec 22 17:49:09 2017 +0100

EPUB export: fix invalid XHTML output for text boxes

 not allowed inside . Also fix two more similar validation
problems.

Change-Id: I7c326743b5e89a5a32609bdf312cb8caa203692e
Reviewed-on: https://gerrit.libreoffice.org/46983
Tested-by: Jenkins 
Reviewed-by: Miklos Vajna 

diff --git a/external/libepubgen/UnpackedTarball_libepubgen.mk 
b/external/libepubgen/UnpackedTarball_libepubgen.mk
index 14efadb337c0..47b21d7ee5d0 100644
--- a/external/libepubgen/UnpackedTarball_libepubgen.mk
+++ b/external/libepubgen/UnpackedTarball_libepubgen.mk
@@ -8,6 +8,8 @@
 #
 
 epubgen_patches :=
+# Backport of 
.
+epubgen_patches += libepubgen-epub3.patch.1
 
 ifeq ($(COM_IS_CLANG),TRUE)
 ifneq ($(filter -fsanitize=%,$(CC)),)
diff --git a/external/libepubgen/libepubgen-epub3.patch.1 
b/external/libepubgen/libepubgen-epub3.patch.1
new file mode 100644
index ..7ea3a365737f
--- /dev/null
+++ b/external/libepubgen/libepubgen-epub3.patch.1
@@ -0,0 +1,169 @@
+From 006848cb62225647c418d5143d4e88a9d73829da Mon Sep 17 00:00:00 2001
+From: Miklos Vajna 
+Date: Fri, 22 Dec 2017 16:33:52 +0100
+Subject: [PATCH] EPUBHTMLGenerator: avoid  inside  and/or 
+
+This is not allowed in XHTML, but we wrote that markup when a text frame
+was inside a span or a paragraph. The closest allowed markup in XHTML
+seems to be closing the span/paragraph before opening the text box and
+doing the opposite after the text box is closed.
+---
+ src/lib/EPUBHTMLGenerator.cpp  | 33 +
+ src/test/EPUBTextGeneratorTest.cpp |  4 +++-
+ 2 files changed, 36 insertions(+), 1 deletion(-)
+
+diff --git a/src/lib/EPUBHTMLGenerator.cpp b/src/lib/EPUBHTMLGenerator.cpp
+index 342213e..bc9c1b7 100644
+--- a/src/lib/EPUBHTMLGenerator.cpp
 b/src/lib/EPUBHTMLGenerator.cpp
+@@ -395,6 +395,8 @@ struct EPUBHTMLGeneratorImpl
+ , m_frameAnchorTypes()
+ , m_framePropertiesStack()
+ , m_linkPropertiesStack()
++, m_paragraphAttributesStack()
++, m_spanAttributesStack()
+ , m_stylesMethod(stylesMethod)
+ , m_layoutMethod(layoutMethod)
+ , m_actualSink()
+@@ -495,6 +497,8 @@ struct EPUBHTMLGeneratorImpl
+   std::stack m_framePropertiesStack;
+   /// This is used for links which don't have a href.
+   std::stack m_linkPropertiesStack;
++  std::stack m_paragraphAttributesStack;
++  std::stack m_spanAttributesStack;
+ 
+   EPUBStylesMethod m_stylesMethod;
+   EPUBLayoutMethod m_layoutMethod;
+@@ -683,6 +687,12 @@ void EPUBHTMLGenerator::openParagraph(const 
RVNGPropertyList )
+   }
+   m_impl->output(false).openElement("p", attrs);
+   m_impl->m_hasText = false;
++
++  librevenge::RVNGPropertyList::Iter i(attrs);
++  RVNGPropertyList paragraphAttributes;
++  for (i.rewind(); i.next();)
++paragraphAttributes.insert(i.key(), i()->clone());
++  m_impl->m_paragraphAttributesStack.push(paragraphAttributes);
+ }
+ 
+ void EPUBHTMLGenerator::closeParagraph()
+@@ -690,6 +700,9 @@ void EPUBHTMLGenerator::closeParagraph()
+   if (m_impl->m_ignore)
+ return;
+ 
++  if (!m_impl->m_paragraphAttributesStack.empty())
++m_impl->m_paragraphAttributesStack.pop();
++
+   if (!m_impl->m_hasText)
+ insertSpace();
+ 
+@@ -717,12 +730,22 @@ void EPUBHTMLGenerator::openSpan(const RVNGPropertyList 
)
+ break;
+   }
+   m_impl->output(false).openElement("span", attrs);
++
++  librevenge::RVNGPropertyList::Iter i(attrs);
++  RVNGPropertyList spanAttributes;
++  for (i.rewind(); i.next();)
++spanAttributes.insert(i.key(), i()->clone());
++  m_impl->m_spanAttributesStack.push(spanAttributes);
+ }
+ 
+ void EPUBHTMLGenerator::closeSpan()
+ {
+   if (m_impl->m_ignore)
+ return;
++
++  if (!m_impl->m_spanAttributesStack.empty())
++m_impl->m_spanAttributesStack.pop();
++
+   m_impl->output().closeElement("span");
+ }
+ 
+@@ -931,6 +954,11 @@ void EPUBHTMLGenerator::openTextBox(const 
RVNGPropertyList & /*propList*/)
+   if (m_impl->m_ignore)
+ return;
+ 
++  if (!m_impl->m_spanAttributesStack.empty())
++m_impl->output().closeElement("span");
++  if (!m_impl->m_paragraphAttributesStack.empty())
++m_impl->output().closeElement("p");
++
+   RVNGPropertyList attrs;
+ 
+   if (!m_impl->m_framePropertiesStack.empty())
+@@ -968,6 +996,11 @@ void EPUBHTMLGenerator::closeTextBox()
+   m_impl->output().insertEmptyElement("br", attrs);
+ }
+   }
++
++  if (!m_impl->m_paragraphAttributesStack.empty())
++m_impl->output(false).openElement("p", 
m_impl->m_paragraphAttributesStack.top());

[Libreoffice-commits] core.git: external/libepubgen writerperfect/Library_wpftwriter.mk writerperfect/qa writerperfect/source

2017-12-04 Thread Miklos Vajna
 external/libepubgen/libepubgen-epub3.patch.1|   25 ++
 writerperfect/Library_wpftwriter.mk |1 
 writerperfect/qa/unit/EPUBExportTest.cxx|   17 +
 writerperfect/qa/unit/data/writer/epubexport/fxl-2page.fodt |   71 
 writerperfect/source/writer/EPUBExportFilter.cxx|   49 +
 writerperfect/source/writer/EPUBExportFilter.hxx|7 
 writerperfect/source/writer/exp/xmlimp.cxx  |  106 ++--
 writerperfect/source/writer/exp/xmlimp.hxx  |7 
 8 files changed, 264 insertions(+), 19 deletions(-)

New commits:
commit 3ed8466b55ace15a28761e06b6bb76ebd8758106
Author: Miklos Vajna 
Date:   Fri Dec 1 10:58:05 2017 +0100

EPUB export, fixed layout: switch to a metafile-based approach

Trying to guess layout from flat ODF output is an approach that doesn't
scale, think of complex documents with split tables, etc.

Do it similar to the PDF export instead: take a metafile of each page
and use the existing SVG writer to embed it into XHTML.

Change-Id: I6e860834beb8025519d3e367f858077ae9e9c006
Reviewed-on: https://gerrit.libreoffice.org/45647
Tested-by: Jenkins 
Reviewed-by: Miklos Vajna 

diff --git a/external/libepubgen/libepubgen-epub3.patch.1 
b/external/libepubgen/libepubgen-epub3.patch.1
index c234ab10ec13..af6c9366fbc1 100644
--- a/external/libepubgen/libepubgen-epub3.patch.1
+++ b/external/libepubgen/libepubgen-epub3.patch.1
@@ -5831,3 +5831,28 @@ index c3bc963..02c299a 100644
 -- 
 2.13.6
 
+From 88b9d9a1efb9b064ea99c57ec273f76712d361ff Mon Sep 17 00:00:00 2001
+From: Miklos Vajna 
+Date: Thu, 30 Nov 2017 11:32:41 +0100
+Subject: [PATCH] EPUBTextGenerator: allow a single image on a page
+
+---
+ src/lib/EPUBTextGenerator.cpp  |  1 +
+ src/test/EPUBTextGeneratorTest.cpp | 24 
+ 2 files changed, 25 insertions(+)
+
+diff --git a/src/lib/EPUBTextGenerator.cpp b/src/lib/EPUBTextGenerator.cpp
+index 02c299a..38573ec 100644
+--- a/src/lib/EPUBTextGenerator.cpp
 b/src/lib/EPUBTextGenerator.cpp
+@@ -684,6 +684,7 @@ void EPUBTextGenerator::insertBinaryObject(const 
librevenge::RVNGPropertyList 
+   if (m_impl->m_inHeader || m_impl->m_inFooter)
+ m_impl->m_currentHeaderOrFooter->addInsertBinaryObject(newPropList);
+ 
++  m_impl->getSplitGuard().incrementSize(1);
+   m_impl->getHtml()->insertBinaryObject(newPropList);
+ }
+ 
+-- 
+2.13.6
+
diff --git a/writerperfect/Library_wpftwriter.mk 
b/writerperfect/Library_wpftwriter.mk
index 5e356304544d..3f0609fc0d9c 100644
--- a/writerperfect/Library_wpftwriter.mk
+++ b/writerperfect/Library_wpftwriter.mk
@@ -36,6 +36,7 @@ $(eval $(call gb_Library_use_libraries,wpftwriter,\
sal \
sfx \
sot \
+   svt \
svx \
tl \
ucbhelper \
diff --git a/writerperfect/qa/unit/EPUBExportTest.cxx 
b/writerperfect/qa/unit/EPUBExportTest.cxx
index ac6e25efc2ae..bd42356e60ce 100644
--- a/writerperfect/qa/unit/EPUBExportTest.cxx
+++ b/writerperfect/qa/unit/EPUBExportTest.cxx
@@ -60,6 +60,7 @@ public:
 void testEPUB2();
 void testEPUBFixedLayout();
 void testEPUBFixedLayoutOption();
+void testEPUBFixedLayoutImplicitBreak();
 void testPageBreakSplit();
 void testSpanAutostyle();
 void testParaAutostyleCharProps();
@@ -102,6 +103,7 @@ public:
 CPPUNIT_TEST(testEPUB2);
 CPPUNIT_TEST(testEPUBFixedLayout);
 CPPUNIT_TEST(testEPUBFixedLayoutOption);
+CPPUNIT_TEST(testEPUBFixedLayoutImplicitBreak);
 CPPUNIT_TEST(testPageBreakSplit);
 CPPUNIT_TEST(testSpanAutostyle);
 CPPUNIT_TEST(testParaAutostyleCharProps);
@@ -327,6 +329,21 @@ void EPUBExportTest::testEPUBFixedLayoutOption()
 assertXPathContent(mpXmlDoc, 
"/opf:package/opf:metadata/opf:meta[@property='rendition:layout']", 
"pre-paginated");
 }
 
+void EPUBExportTest::testEPUBFixedLayoutImplicitBreak()
+{
+uno::Sequence 
aFilterData(comphelper::InitPropertySequence(
+{
+// Explicitly request fixed layout.
+{"EPUBLayoutMethod", 
uno::makeAny(static_cast(libepubgen::EPUB_LAYOUT_METHOD_FIXED))}
+}));
+createDoc("fxl-2page.fodt", aFilterData);
+
+CPPUNIT_ASSERT(mxZipFile->hasByName("OEBPS/sections/section0001.xhtml"));
+// This was missing, implicit page break (as calculated by the layout) was 
lost on export.
+CPPUNIT_ASSERT(mxZipFile->hasByName("OEBPS/sections/section0002.xhtml"));
+CPPUNIT_ASSERT(!mxZipFile->hasByName("OEBPS/sections/section0003.xhtml"));
+}
+
 void EPUBExportTest::testPageBreakSplit()
 {
 uno::Sequence 
aFilterData(comphelper::InitPropertySequence(
diff --git a/writerperfect/qa/unit/data/writer/epubexport/fxl-2page.fodt 
b/writerperfect/qa/unit/data/writer/epubexport/fxl-2page.fodt
new file mode 100644
index ..6a22acd0821f
--- /dev/null
+++ 

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

2017-11-30 Thread Miklos Vajna
 external/libepubgen/libepubgen-epub3.patch.1   |   30 +++
 writerperfect/qa/unit/EPUBExportTest.cxx   |   15 +
 writerperfect/qa/unit/data/writer/epubexport/meta-xmp.fodt |8 +
 writerperfect/qa/unit/data/writer/epubexport/meta-xmp.xmp  |   28 +++
 writerperfect/source/writer/EPUBExportFilter.cxx   |2 
 writerperfect/source/writer/exp/xmlimp.cxx |   98 ++---
 writerperfect/source/writer/exp/xmlimp.hxx |7 
 writerperfect/source/writer/exp/xmlmetai.cxx   |   91 
 writerperfect/source/writer/exp/xmlmetai.hxx   |   45 +
 9 files changed, 304 insertions(+), 20 deletions(-)

New commits:
commit 1a48cdaf91633b354fb1110c566c766a4398fba0
Author: Miklos Vajna 
Date:   Thu Nov 30 08:48:06 2017 +0100

EPUB export: allow overwriting of document metadata

Pick up overrides from /.xmp as a start.

Change-Id: Ib64a6bbdadc53633fb1f0d4a7efdde2e3c96b5ef
Reviewed-on: https://gerrit.libreoffice.org/45551
Tested-by: Jenkins 
Reviewed-by: Miklos Vajna 

diff --git a/external/libepubgen/libepubgen-epub3.patch.1 
b/external/libepubgen/libepubgen-epub3.patch.1
index af87b2644e8d..39bac59c51ff 100644
--- a/external/libepubgen/libepubgen-epub3.patch.1
+++ b/external/libepubgen/libepubgen-epub3.patch.1
@@ -4467,3 +4467,33 @@ index 3f4bf3c..cbb83b7 100644
 -- 
 2.13.6
 
+From 631b21834883aa8f2ee83a20717dd37900331696 Mon Sep 17 00:00:00 2001
+From: Miklos Vajna 
+Date: Tue, 21 Nov 2017 11:52:03 +0100
+Subject: [PATCH] EPUBGenerator: allow overwriting dc:identifier default
+
+All other types had a way to be overwritten.
+---
+ src/lib/EPUBGenerator.cpp  | 5 -
+ src/test/EPUBTextGeneratorTest.cpp | 3 +++
+ 2 files changed, 7 insertions(+), 1 deletion(-)
+
+diff --git a/src/lib/EPUBGenerator.cpp b/src/lib/EPUBGenerator.cpp
+index 62dac6e..1cb1112 100644
+--- a/src/lib/EPUBGenerator.cpp
 b/src/lib/EPUBGenerator.cpp
+@@ -285,7 +285,10 @@ void EPUBGenerator::writeRoot()
+   boost::uuids::uuid uuid = boost::uuids::random_generator()();
+   identifierStream << uuid;
+   std::string identifierCharactrs = identifierStream.str();
+-  sink.insertCharacters(identifierCharactrs.c_str());
++  RVNGString identifier = identifierCharactrs.c_str();
++  if (m_metadata["dc:identifier"] && 
!m_metadata["dc:identifier"]->getStr().empty())
++identifier = m_metadata["dc:identifier"]->getStr();
++  sink.insertCharacters(identifier);
+   sink.closeElement("dc:identifier");
+ 
+   RVNGString title("Unknown Title");
+-- 
+2.13.6
+
diff --git a/writerperfect/qa/unit/EPUBExportTest.cxx 
b/writerperfect/qa/unit/EPUBExportTest.cxx
index 72c9a27dc495..82452d958152 100644
--- a/writerperfect/qa/unit/EPUBExportTest.cxx
+++ b/writerperfect/qa/unit/EPUBExportTest.cxx
@@ -61,6 +61,7 @@ public:
 void testSpanAutostyle();
 void testParaAutostyleCharProps();
 void testMeta();
+void testMetaXMP();
 void testCoverImage();
 void testParaNamedstyle();
 void testCharNamedstyle();
@@ -94,6 +95,7 @@ public:
 CPPUNIT_TEST(testSpanAutostyle);
 CPPUNIT_TEST(testParaAutostyleCharProps);
 CPPUNIT_TEST(testMeta);
+CPPUNIT_TEST(testMetaXMP);
 CPPUNIT_TEST(testCoverImage);
 CPPUNIT_TEST(testParaNamedstyle);
 CPPUNIT_TEST(testCharNamedstyle);
@@ -335,6 +337,19 @@ void EPUBExportTest::testMeta()
 CPPUNIT_ASSERT(mxZipFile->hasByName("OEBPS/images/image0001.png"));
 }
 
+void EPUBExportTest::testMetaXMP()
+{
+createDoc("meta-xmp.fodt", {});
+mpXmlDoc = parseExport("OEBPS/content.opf");
+
+// These were the libepubgen default values, metadata from a matching .xmp 
file was not picked up.
+assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/dc:identifier", 
"deadbeef-e394-4cd6-9b83-7172794612e5");
+assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/dc:title", 
"unknown title from xmp");
+assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/dc:creator", 
"unknown author from xmp");
+assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/dc:language", 
"nl");
+assertXPathContent(mpXmlDoc, 
"/opf:package/opf:metadata/opf:meta[@property='dcterms:modified']", 
"2016-11-20T17:16:07Z");
+}
+
 void EPUBExportTest::testCoverImage()
 {
 OUString aCoverURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + 
"meta.cover-image.png";
diff --git a/writerperfect/qa/unit/data/writer/epubexport/meta-xmp.fodt 
b/writerperfect/qa/unit/data/writer/epubexport/meta-xmp.fodt
new file mode 100644
index ..b245e9d7abce
--- /dev/null
+++ b/writerperfect/qa/unit/data/writer/epubexport/meta-xmp.fodt
@@ -0,0 +1,8 @@
+
+
+  
+
+  Hello world!
+
+  
+
diff --git a/writerperfect/qa/unit/data/writer/epubexport/meta-xmp.xmp 
b/writerperfect/qa/unit/data/writer/epubexport/meta-xmp.xmp
new file mode 100644
index 

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

2017-11-29 Thread Miklos Vajna
 external/libepubgen/libepubgen-epub3.patch.1  |   82 

 writerperfect/qa/unit/EPUBExportTest.cxx  |5 
 writerperfect/qa/unit/data/writer/epubexport/meta.cover-image.png |binary
 writerperfect/source/writer/EPUBExportFilter.cxx  |7 
 writerperfect/source/writer/exp/xmlimp.cxx|   92 
+-
 writerperfect/source/writer/exp/xmlimp.hxx|5 
 writerperfect/source/writer/exp/xmlmetai.cxx  |1 
 7 files changed, 189 insertions(+), 3 deletions(-)

New commits:
commit 389f7b9581ebd6420a8b9f815807d957608ce8a8
Author: Miklos Vajna 
Date:   Wed Nov 29 11:44:55 2017 +0100

EPUB export: add support for cover images

Pick them up from /.cover-image. as a
start.

Change-Id: Ie5ee7c02d6b3271e6e850ca9a2a10ed0bb4a598d
Reviewed-on: https://gerrit.libreoffice.org/45483
Tested-by: Jenkins 
Reviewed-by: Miklos Vajna 

diff --git a/external/libepubgen/libepubgen-epub3.patch.1 
b/external/libepubgen/libepubgen-epub3.patch.1
index f0facbac64f9..af87b2644e8d 100644
--- a/external/libepubgen/libepubgen-epub3.patch.1
+++ b/external/libepubgen/libepubgen-epub3.patch.1
@@ -4385,3 +4385,85 @@ index d5e650c..a1ce33e 100644
  return false;
}
bool fixed = true;
+From 0d06b60d45b3e1465976eb027c3fde31fccdc025 Mon Sep 17 00:00:00 2001
+From: Miklos Vajna 
+Date: Fri, 17 Nov 2017 15:45:12 +0100
+Subject: [PATCH] EPUBGenerator: add support for cover image metadata
+
+The librevenge:cover-images key can't have a property list as a value,
+so go with a list of cover images, though in practice more than one
+won't result in a valid EPUB3 file.
+---
+ src/lib/EPUBGenerator.cpp  | 18 ++
+ src/lib/EPUBImageManager.cpp   |  4 ++--
+ src/lib/EPUBImageManager.h |  2 +-
+ src/test/EPUBTextGeneratorTest.cpp | 31 +++
+ 4 files changed, 52 insertions(+), 3 deletions(-)
+
+diff --git a/src/lib/EPUBGenerator.cpp b/src/lib/EPUBGenerator.cpp
+index 64707c5..62dac6e 100644
+--- a/src/lib/EPUBGenerator.cpp
 b/src/lib/EPUBGenerator.cpp
+@@ -86,6 +86,24 @@ void EPUBGenerator::endDocument()
+ void EPUBGenerator::setDocumentMetaData(const RVNGPropertyList )
+ {
+   m_metadata = props;
++
++  if (m_version == 30)
++  {
++const librevenge::RVNGPropertyListVector *coverImages = 
props.child("librevenge:cover-images");
++if (coverImages)
++{
++  for (size_t i = 0; i < coverImages->count(); ++i)
++  {
++librevenge::RVNGPropertyList const  = (*coverImages)[i];
++if (propertyList["office:binary-data"] && 
propertyList["librevenge:mime-type"])
++{
++  
m_imageManager.insert(librevenge::RVNGBinaryData(propertyList["office:binary-data"]->getStr()),
++
propertyList["librevenge:mime-type"]->getStr(),
++"cover-image");
++}
++  }
++}
++  }
+ }
+ 
+ void EPUBGenerator::startNewHtmlFile()
+diff --git a/src/lib/EPUBImageManager.cpp b/src/lib/EPUBImageManager.cpp
+index c4c9457..bdf3bf0 100644
+--- a/src/lib/EPUBImageManager.cpp
 b/src/lib/EPUBImageManager.cpp
+@@ -84,7 +84,7 @@ EPUBImageManager::EPUBImageManager(EPUBManifest )
+ {
+ }
+ 
+-const EPUBPath ::insert(const librevenge::RVNGBinaryData 
, const librevenge::RVNGString )
++const EPUBPath ::insert(const librevenge::RVNGBinaryData 
, const librevenge::RVNGString , const librevenge::RVNGString 
)
+ {
+   MapType_t::const_iterator it = m_map.find(data);
+   if (m_map.end() == it)
+@@ -99,7 +99,7 @@ const EPUBPath ::insert(const 
librevenge::RVNGBinaryData ,
+ 
+ const EPUBPath path(EPUBPath("OEBPS/images") / nameBuf.str());
+ 
+-m_manifest.insert(path, mime, id, "");
++m_manifest.insert(path, mime, id, properties.cstr());
+ it = m_map.insert(MapType_t::value_type(data, path)).first;
+   }
+ 
+diff --git a/src/lib/EPUBImageManager.h b/src/lib/EPUBImageManager.h
+index 3f4bf3c..cbb83b7 100644
+--- a/src/lib/EPUBImageManager.h
 b/src/lib/EPUBImageManager.h
+@@ -49,7 +49,7 @@ class EPUBImageManager
+ public:
+   explicit EPUBImageManager(EPUBManifest );
+ 
+-  const EPUBPath (const librevenge::RVNGBinaryData , const 
librevenge::RVNGString );
++  const EPUBPath (const librevenge::RVNGBinaryData , const 
librevenge::RVNGString , const librevenge::RVNGString ="");
+ 
+   void writeTo(EPUBPackage );
+ 
+-- 
+2.13.6
+
diff --git a/writerperfect/qa/unit/EPUBExportTest.cxx 
b/writerperfect/qa/unit/EPUBExportTest.cxx
index c8fe9a3491bd..e038a7ef6135 100644
--- a/writerperfect/qa/unit/EPUBExportTest.cxx
+++ b/writerperfect/qa/unit/EPUBExportTest.cxx
@@ -326,6 +326,11 @@ void EPUBExportTest::testMeta()
 assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/dc:title", 
"Title");
 assertXPathContent(mpXmlDoc, 

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

2017-11-29 Thread Miklos Vajna
 external/libepubgen/libepubgen-epub3.patch.1 |  362 +
 writerperfect/qa/unit/EPUBExportTest.cxx |   24 
 writerperfect/qa/unit/data/writer/epubexport/font-embedding.fodt | 2657 
++
 writerperfect/source/writer/exp/XMLBase64ImportContext.cxx   |   25 
 writerperfect/source/writer/exp/XMLBase64ImportContext.hxx   |4 
 writerperfect/source/writer/exp/xmlfmt.cxx   |  169 
 writerperfect/source/writer/exp/xmlfmt.hxx   |9 
 writerperfect/source/writer/exp/xmlimp.cxx   |2 
 8 files changed, 3250 insertions(+), 2 deletions(-)

New commits:
commit 793bbac379c5800dc09ff76f093d45047e662ff0
Author: Miklos Vajna 
Date:   Tue Nov 28 09:06:07 2017 +0100

EPUB export: implement font embedding support

Also avoid librevenge::RVNGBinaryData::appendBase64Data() for
performance reasons. Times with and without the XMLBase64ImportContext
rework for sw/qa/extras/odfexport/data/embedded-font-props.odt:

- before: 1m32.254s
- after: 0m7.045s

(Need to insvestigate macOS font embedding situation in general, later.)

Change-Id: I5aa56bfbfa8dc64f19c021202a1b87618b4b2775
Reviewed-on: https://gerrit.libreoffice.org/45385
Tested-by: Jenkins 
Reviewed-by: Miklos Vajna 

diff --git a/external/libepubgen/libepubgen-epub3.patch.1 
b/external/libepubgen/libepubgen-epub3.patch.1
index 8e845918c22b..f0facbac64f9 100644
--- a/external/libepubgen/libepubgen-epub3.patch.1
+++ b/external/libepubgen/libepubgen-epub3.patch.1
@@ -4023,3 +4023,365 @@ index 939d350..9d1da4e 100644
 -- 
 2.13.6
 
+diff --git a/src/lib/EPUBGenerator.cpp b/src/lib/EPUBGenerator.cpp
+index 38c3188..64707c5 100644
+--- a/src/lib/EPUBGenerator.cpp
 b/src/lib/EPUBGenerator.cpp
+@@ -35,6 +35,7 @@ EPUBGenerator::EPUBGenerator(EPUBPackage *const package, 
const EPUBSplitMethod s
+   , m_manifest()
+   , m_htmlManager(m_manifest)
+   , m_imageManager(m_manifest)
++  , m_fontManager(m_manifest)
+   , m_listStyleManager()
+   , m_paragraphStyleManager()
+   , m_spanStyleManager()
+@@ -79,6 +80,7 @@ void EPUBGenerator::endDocument()
+   writeStylesheet();
+   m_htmlManager.writeTo(*m_package);
+   m_imageManager.writeTo(*m_package);
++  m_fontManager.writeTo(*m_package);
+ }
+ 
+ void EPUBGenerator::setDocumentMetaData(const RVNGPropertyList )
+@@ -97,7 +99,7 @@ void EPUBGenerator::startNewHtmlFile()
+ 
+   m_splitGuard.onSplit();
+ 
+-  m_currentHtml = m_htmlManager.create(m_imageManager, m_listStyleManager, 
m_paragraphStyleManager, m_spanStyleManager, m_tableStyleManager, 
m_stylesheetPath, m_stylesMethod);
++  m_currentHtml = m_htmlManager.create(m_imageManager, m_fontManager, 
m_listStyleManager, m_paragraphStyleManager, m_spanStyleManager, 
m_tableStyleManager, m_stylesheetPath, m_stylesMethod);
+ 
+   // restore state in the new file
+   m_currentHtml->startDocument(m_documentProps);
+@@ -226,6 +228,7 @@ void EPUBGenerator::writeStylesheet()
+ {
+   EPUBCSSSink sink;
+ 
++  m_fontManager.send(sink);
+   m_listStyleManager.send(sink);
+   m_paragraphStyleManager.send(sink);
+   m_spanStyleManager.send(sink);
+diff --git a/src/lib/EPUBGenerator.h b/src/lib/EPUBGenerator.h
+index 099eb4a..abc6a9a 100644
+--- a/src/lib/EPUBGenerator.h
 b/src/lib/EPUBGenerator.h
+@@ -68,6 +68,7 @@ private:
+   EPUBManifest m_manifest;
+   EPUBHTMLManager m_htmlManager;
+   EPUBImageManager m_imageManager;
++  EPUBFontManager m_fontManager;
+   EPUBListStyleManager m_listStyleManager;
+   EPUBParagraphStyleManager m_paragraphStyleManager;
+   EPUBSpanStyleManager m_spanStyleManager;
+diff --git a/src/lib/EPUBHTMLGenerator.cpp b/src/lib/EPUBHTMLGenerator.cpp
+index 9d39333..614dd02 100644
+--- a/src/lib/EPUBHTMLGenerator.cpp
 b/src/lib/EPUBHTMLGenerator.cpp
+@@ -351,9 +351,10 @@ std::string EPUBHTMLTextZone::label(int id) const
+ struct EPUBHTMLGeneratorImpl
+ {
+   //! constructor
+-  EPUBHTMLGeneratorImpl(EPUBXMLSink , EPUBImageManager 
, EPUBListStyleManager , 
EPUBParagraphStyleManager , EPUBSpanStyleManager 
, EPUBTableStyleManager , const EPUBPath 
, const EPUBPath , EPUBStylesMethod stylesMethod)
++  EPUBHTMLGeneratorImpl(EPUBXMLSink , EPUBImageManager 
, EPUBFontManager , EPUBListStyleManager 
, EPUBParagraphStyleManager , 
EPUBSpanStyleManager , EPUBTableStyleManager 
, const EPUBPath , const EPUBPath , 
EPUBStylesMethod stylesMethod)
+ : m_document(document)
+ , m_imageManager(imageManager)
++, m_fontManager(fontManager)
+ , m_listManager(listStyleManager)
+ , m_paragraphManager(paragraphStyleManager)
+ , m_spanManager(spanStyleManager)
+@@ -442,6 +443,7 @@ struct EPUBHTMLGeneratorImpl
+ 
+   EPUBXMLSink _document;
+   EPUBImageManager _imageManager;
++  EPUBFontManager _fontManager;
+   EPUBListStyleManager _listManager;
+   EPUBParagraphStyleManager _paragraphManager;
+   

[Libreoffice-commits] core.git: external/libepubgen

2017-11-27 Thread Miklos Vajna
 external/libepubgen/libepubgen-epub3.patch.1 |  146 +++
 1 file changed, 146 insertions(+)

New commits:
commit b0e226b58a261ccfe24137048c11bdf7af7c5265
Author: Miklos Vajna 
Date:   Mon Nov 27 08:25:17 2017 +0100

EPUB export: handle text box wrap types

Change-Id: I89487bc115ba84cfb7700b1617e531f2d3aed950

diff --git a/external/libepubgen/libepubgen-epub3.patch.1 
b/external/libepubgen/libepubgen-epub3.patch.1
index 97a145c19351..8e845918c22b 100644
--- a/external/libepubgen/libepubgen-epub3.patch.1
+++ b/external/libepubgen/libepubgen-epub3.patch.1
@@ -3877,3 +3877,149 @@ index 5f10902..156f042 100644
 -- 
 2.13.6
 
+From 3da66e7b1fbda75e43b3ab63502d66097f39ef7a Mon Sep 17 00:00:00 2001
+From: Miklos Vajna 
+Date: Fri, 10 Nov 2017 16:36:11 +0100
+Subject: [PATCH] EPUBImageManager: handle text box wrap types
+
+By sharing the image and textbox wrap code.
+---
+ src/lib/EPUBHTMLGenerator.cpp  | 44 --
+ src/lib/EPUBImageManager.cpp   | 29 +
+ src/lib/EPUBImageManager.h |  2 ++
+ src/test/EPUBTextGeneratorTest.cpp |  2 ++
+ 4 files changed, 51 insertions(+), 26 deletions(-)
+
+diff --git a/src/lib/EPUBHTMLGenerator.cpp b/src/lib/EPUBHTMLGenerator.cpp
+index 156f042..9d39333 100644
+--- a/src/lib/EPUBHTMLGenerator.cpp
 b/src/lib/EPUBHTMLGenerator.cpp
+@@ -859,6 +859,18 @@ void EPUBHTMLGenerator::closeTextBox()
+ return;
+ 
+   m_impl->output().closeElement("div");
++
++  if (!m_impl->m_framePropertiesStack.empty())
++  {
++RVNGPropertyList  = m_impl->m_framePropertiesStack.top();
++RVNGString wrapStyle = 
m_impl->m_imageManager.getWrapStyle(frameProperties).c_str();
++if (!wrapStyle.empty())
++{
++  RVNGPropertyList attrs;
++  attrs.insert("style", wrapStyle);
++  m_impl->output().insertEmptyElement("br", attrs);
++}
++  }
+ }
+ 
+ void EPUBHTMLGenerator::openTable(const RVNGPropertyList )
+@@ -999,8 +1011,7 @@ void EPUBHTMLGenerator::insertBinaryObject(const 
RVNGPropertyList )
+propList["librevenge:mime-type"]->getStr());
+ 
+   RVNGPropertyList attrs;
+-  RVNGString wrap;
+-  RVNGString anchorType;
++  RVNGString wrapStyle;
+ 
+   if (!m_impl->m_framePropertiesStack.empty())
+   {
+@@ -1015,10 +1026,7 @@ void EPUBHTMLGenerator::insertBinaryObject(const 
RVNGPropertyList )
+   break;
+ }
+ 
+-if (frameProperties["style:wrap"])
+-  wrap = frameProperties["style:wrap"]->getStr();
+-if (frameProperties["text:anchor-type"])
+-  anchorType = frameProperties["text:anchor-type"]->getStr();
++wrapStyle = m_impl->m_imageManager.getWrapStyle(frameProperties).c_str();
+   }
+ 
+   attrs.insert("src", path.relativeTo(m_impl->m_path).str().c_str());
+@@ -1026,27 +1034,11 @@ void EPUBHTMLGenerator::insertBinaryObject(const 
RVNGPropertyList )
+   attrs.insert("alt", path.str().c_str());
+   m_impl->output().insertEmptyElement("img", attrs);
+ 
+-  if (anchorType != "as-char")
++  if (!wrapStyle.empty())
+   {
+-// Emulate wrap type with a break after the image.
+-RVNGString brStyle;
+-if (wrap == "none")
+-  brStyle = "clear: both;";
+-else if (wrap == "left")
+-  // We want content on the left side, space on the right side, so the 
next
+-  // element should clear on its left.
+-  brStyle = "clear: left;";
+-else if (wrap == "right")
+-  // Same here.
+-  brStyle = "clear: right;";
+-else if (wrap == "parallel")
+-  brStyle = "clear: none;";
+-if (!brStyle.empty())
+-{
+-  attrs.clear();
+-  attrs.insert("style", brStyle);
+-  m_impl->output().insertEmptyElement("br", attrs);
+-}
++attrs.clear();
++attrs.insert("style", wrapStyle);
++m_impl->output().insertEmptyElement("br", attrs);
+   }
+ }
+ 
+diff --git a/src/lib/EPUBImageManager.cpp b/src/lib/EPUBImageManager.cpp
+index dfa0cb7..c31fb82 100644
+--- a/src/lib/EPUBImageManager.cpp
 b/src/lib/EPUBImageManager.cpp
+@@ -162,6 +162,35 @@ void 
EPUBImageManager::extractImageProperties(librevenge::RVNGPropertyList const
+   }
+ }
+ 
++std::string EPUBImageManager::getWrapStyle(librevenge::RVNGPropertyList const 
)
++{
++  librevenge::RVNGString wrap;
++  librevenge::RVNGString anchorType;
++  std::string ret;
++
++  if (pList["style:wrap"])
++wrap = pList["style:wrap"]->getStr();
++  if (pList["text:anchor-type"])
++anchorType = pList["text:anchor-type"]->getStr();
++
++  if (anchorType == "as-char")
++return ret;
++
++  // Emulate wrap type with a break after the image.
++  if (wrap == "none")
++ret = "clear: both;";
++  else if (wrap == "left")
++// We want content on the left side, space on the right side, so the next
++// element should clear on its left.
++ret = "clear: left;";
++  else if (wrap == "right")
++ret = "clear: right;";
++  else if (wrap == "parallel")
++ret = "clear: 

[Libreoffice-commits] core.git: external/libepubgen

2017-11-27 Thread Miklos Vajna
 external/libepubgen/libepubgen-epub3.patch.1 |   80 +++
 1 file changed, 80 insertions(+)

New commits:
commit 587dcbfc23eada9dc2818b5da137f115c28aeb3b
Author: Miklos Vajna 
Date:   Mon Nov 27 08:24:19 2017 +0100

EPUB export: avoid wrap type for as-char anchored images

This fixes the wrapping of the inner frame of
writerperfect/qa/unit/data/writer/epubexport/text-box.fodt.

Change-Id: I8f2a4a2db8e49469c08f3dbf11d5891df3eddff8
Reviewed-on: https://gerrit.libreoffice.org/45311
Tested-by: Jenkins 
Reviewed-by: Miklos Vajna 

diff --git a/external/libepubgen/libepubgen-epub3.patch.1 
b/external/libepubgen/libepubgen-epub3.patch.1
index 1c64aa694ee0..97a145c19351 100644
--- a/external/libepubgen/libepubgen-epub3.patch.1
+++ b/external/libepubgen/libepubgen-epub3.patch.1
@@ -3797,3 +3797,83 @@ index c9f4236..939d350 100644
 -- 
 2.13.6
 
+From da840df8eaacfcfbd93d82751a774371d7e5c9b9 Mon Sep 17 00:00:00 2001
+From: Miklos Vajna 
+Date: Fri, 10 Nov 2017 15:29:47 +0100
+Subject: [PATCH] EPUBHTMLGenerator: avoid wrap type for as-char anchored
+ images
+
+---
+ src/lib/EPUBHTMLGenerator.cpp  | 40 ++
+ src/test/EPUBTextGeneratorTest.cpp | 15 +-
+ 2 files changed, 37 insertions(+), 18 deletions(-)
+
+diff --git a/src/lib/EPUBHTMLGenerator.cpp b/src/lib/EPUBHTMLGenerator.cpp
+index 5f10902..156f042 100644
+--- a/src/lib/EPUBHTMLGenerator.cpp
 b/src/lib/EPUBHTMLGenerator.cpp
+@@ -1000,6 +1000,7 @@ void EPUBHTMLGenerator::insertBinaryObject(const 
RVNGPropertyList )
+ 
+   RVNGPropertyList attrs;
+   RVNGString wrap;
++  RVNGString anchorType;
+ 
+   if (!m_impl->m_framePropertiesStack.empty())
+   {
+@@ -1016,6 +1017,8 @@ void EPUBHTMLGenerator::insertBinaryObject(const 
RVNGPropertyList )
+ 
+ if (frameProperties["style:wrap"])
+   wrap = frameProperties["style:wrap"]->getStr();
++if (frameProperties["text:anchor-type"])
++  anchorType = frameProperties["text:anchor-type"]->getStr();
+   }
+ 
+   attrs.insert("src", path.relativeTo(m_impl->m_path).str().c_str());
+@@ -1023,24 +1026,27 @@ void EPUBHTMLGenerator::insertBinaryObject(const 
RVNGPropertyList )
+   attrs.insert("alt", path.str().c_str());
+   m_impl->output().insertEmptyElement("img", attrs);
+ 
+-  // Emulate wrap type with a break after the image.
+-  RVNGString brStyle;
+-  if (wrap == "none")
+-brStyle = "clear: both;";
+-  else if (wrap == "left")
+-// We want content on the left side, space on the right side, so the next
+-// element should clear on its left.
+-brStyle = "clear: left;";
+-  else if (wrap == "right")
+-// Same here.
+-brStyle = "clear: right;";
+-  else if (wrap == "parallel")
+-brStyle = "clear: none;";
+-  if (!brStyle.empty())
++  if (anchorType != "as-char")
+   {
+-attrs.clear();
+-attrs.insert("style", brStyle);
+-m_impl->output().insertEmptyElement("br", attrs);
++// Emulate wrap type with a break after the image.
++RVNGString brStyle;
++if (wrap == "none")
++  brStyle = "clear: both;";
++else if (wrap == "left")
++  // We want content on the left side, space on the right side, so the 
next
++  // element should clear on its left.
++  brStyle = "clear: left;";
++else if (wrap == "right")
++  // Same here.
++  brStyle = "clear: right;";
++else if (wrap == "parallel")
++  brStyle = "clear: none;";
++if (!brStyle.empty())
++{
++  attrs.clear();
++  attrs.insert("style", brStyle);
++  m_impl->output().insertEmptyElement("br", attrs);
++}
+   }
+ }
+ 
+-- 
+2.13.6
+
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2017-11-27 Thread Miklos Vajna
 external/libepubgen/libepubgen-epub3.patch.1   |  114 +
 writerperfect/qa/unit/EPUBExportTest.cxx   |   12 +
 writerperfect/qa/unit/data/writer/epubexport/text-box.fodt |   45 +
 writerperfect/source/writer/exp/XMLTextFrameContext.cxx|   36 
 4 files changed, 207 insertions(+)

New commits:
commit ae8f28b86fa6247106bbdecfeac8367f942fb398
Author: Miklos Vajna 
Date:   Mon Nov 27 08:23:24 2017 +0100

EPUB export: handle non-image frames

TextFrame on the Writer UI.

Change-Id: I755fde113ef86a656b7f1f39c02642c22a5a6102
Reviewed-on: https://gerrit.libreoffice.org/45310
Tested-by: Jenkins 
Reviewed-by: Miklos Vajna 

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 
+Date: Fri, 10 Nov 2017 14:13:29 +0100
+Subject: [PATCH] EPUBHTMLGenerator: map TextBox to 
+
+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  = 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 )
+@@ -990,10 +1007,10 @@ void EPUBHTMLGenerator::insertBinaryObject(const 
RVNGPropertyList )
+ 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 )
+   }
+ }
+ 
+-std::string EPUBImageManager::getImageClass(librevenge::RVNGPropertyList 
const )
++std::string EPUBImageManager::getFrameClass(librevenge::RVNGPropertyList 
const )
+ {
+   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 )
++std::string EPUBImageManager::getFrameStyle(librevenge::RVNGPropertyList 
const )
+ {
+   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 );
+ 
+   //! returns the class name corresponding to a propertylist
+-  

[Libreoffice-commits] core.git: external/libepubgen

2017-11-27 Thread Miklos Vajna
 external/libepubgen/libepubgen-epub3.patch.1 |   64 +++
 1 file changed, 64 insertions(+)

New commits:
commit 50b1bbf6024f30616a3f2f77e5bb268fe35c5cf2
Author: Miklos Vajna 
Date:   Mon Nov 27 08:22:09 2017 +0100

EPUB export: handle image wrap types

Change-Id: If7ef8f8e72e68fb71285ddb0164f033f44c62a53
Reviewed-on: https://gerrit.libreoffice.org/45309
Tested-by: Jenkins 
Reviewed-by: Miklos Vajna 

diff --git a/external/libepubgen/libepubgen-epub3.patch.1 
b/external/libepubgen/libepubgen-epub3.patch.1
index 70a77b101a5c..d83521aa0b3d 100644
--- a/external/libepubgen/libepubgen-epub3.patch.1
+++ b/external/libepubgen/libepubgen-epub3.patch.1
@@ -3619,3 +3619,67 @@ index 2311e76..8414da5 100644
 -- 
 2.13.6
 
+From 3d47458738729c86992a1ed0002726cba5ec315c Mon Sep 17 00:00:00 2001
+From: Miklos Vajna 
+Date: Fri, 10 Nov 2017 12:27:35 +0100
+Subject: [PATCH] EPUBImageManager: initial wrap type handling
+
+You could assume that the wrap is the opposide of clear, but given it's
+an attribute on the next element, they are the same at the end in case
+of left and right.
+---
+ src/lib/EPUBHTMLGenerator.cpp  | 24 
+ src/test/EPUBTextGeneratorTest.cpp | 38 ++
+ 2 files changed, 62 insertions(+)
+
+diff --git a/src/lib/EPUBHTMLGenerator.cpp b/src/lib/EPUBHTMLGenerator.cpp
+index d81a905..a90ac68 100644
+--- a/src/lib/EPUBHTMLGenerator.cpp
 b/src/lib/EPUBHTMLGenerator.cpp
+@@ -982,6 +982,7 @@ void EPUBHTMLGenerator::insertBinaryObject(const 
RVNGPropertyList )
+propList["librevenge:mime-type"]->getStr());
+ 
+   RVNGPropertyList attrs;
++  RVNGString wrap;
+ 
+   if (!m_impl->m_framePropertiesStack.empty())
+   {
+@@ -995,12 +996,35 @@ void EPUBHTMLGenerator::insertBinaryObject(const 
RVNGPropertyList )
+   attrs.insert("style", 
m_impl->m_imageManager.getImageStyle(frameProperties).c_str());
+   break;
+ }
++
++if (frameProperties["style:wrap"])
++  wrap = frameProperties["style:wrap"]->getStr();
+   }
+ 
+   attrs.insert("src", path.relativeTo(m_impl->m_path).str().c_str());
+   // FIXME: use alternative repr. if available
+   attrs.insert("alt", path.str().c_str());
+   m_impl->output().insertEmptyElement("img", attrs);
++
++  // Emulate wrap type with a break after the image.
++  RVNGString brStyle;
++  if (wrap == "none")
++brStyle = "clear: both;";
++  else if (wrap == "left")
++// We want content on the left side, space on the right side, so the next
++// element should clear on its left.
++brStyle = "clear: left;";
++  else if (wrap == "right")
++// Same here.
++brStyle = "clear: right;";
++  else if (wrap == "parallel")
++brStyle = "clear: none;";
++  if (!brStyle.empty())
++  {
++attrs.clear();
++attrs.insert("style", brStyle);
++m_impl->output().insertEmptyElement("br", attrs);
++  }
+ }
+ 
+ void EPUBHTMLGenerator::insertEquation(const RVNGPropertyList & /* propList 
*/) {}
+-- 
+2.13.6
+
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2017-11-27 Thread Miklos Vajna
 external/libepubgen/libepubgen-epub3.patch.1 |   42 +++
 writerperfect/source/writer/exp/txtstyli.cxx |1 
 2 files changed, 43 insertions(+)

New commits:
commit 034c6ef667e734ee1f525daffc55d89cdc83b261
Author: Miklos Vajna 
Date:   Mon Nov 27 08:21:06 2017 +0100

EPUB export: handle horizontal left/right positioning of non-as-char images

The change in XMLStyleContext::startElement() just makes sure that
properties from the parent graphic styles are read, but currently it's
just a nice-to-have addition, we don't depend on this yet, so no test.

Change-Id: Ieac599dd47049edea57cb0860aa483f1045b47fd
Reviewed-on: https://gerrit.libreoffice.org/45308
Tested-by: Jenkins 
Reviewed-by: Miklos Vajna 

diff --git a/external/libepubgen/libepubgen-epub3.patch.1 
b/external/libepubgen/libepubgen-epub3.patch.1
index c226c51d4388..70a77b101a5c 100644
--- a/external/libepubgen/libepubgen-epub3.patch.1
+++ b/external/libepubgen/libepubgen-epub3.patch.1
@@ -3577,3 +3577,45 @@ index 4ffa55d..d81a905 100644
 -- 
 2.13.6
 
+From 0f5073481b094562f2c78481475a660fb6826cdb Mon Sep 17 00:00:00 2001
+From: Miklos Vajna 
+Date: Thu, 9 Nov 2017 11:32:27 +0100
+Subject: [PATCH] EPUBImageManager: initial horizontal positioning
+
+For now position everything to the left, except for explicit "right".
+---
+ src/lib/EPUBImageManager.cpp   | 17 ++
+ src/test/EPUBTextGeneratorTest.cpp | 66 ++
+ 2 files changed, 83 insertions(+)
+
+diff --git a/src/lib/EPUBImageManager.cpp b/src/lib/EPUBImageManager.cpp
+index 2311e76..8414da5 100644
+--- a/src/lib/EPUBImageManager.cpp
 b/src/lib/EPUBImageManager.cpp
+@@ -133,6 +133,23 @@ std::string 
EPUBImageManager::getImageStyle(librevenge::RVNGPropertyList const &
+ 
+ void EPUBImageManager::extractImageProperties(librevenge::RVNGPropertyList 
const , EPUBCSSProperties ) const
+ {
++  // Positioning.
++  librevenge::RVNGString anchorType;
++  if (pList["text:anchor-type"])
++anchorType = pList["text:anchor-type"]->getStr();
++  if (anchorType != "as-char")
++  {
++// Horizontal position.
++librevenge::RVNGString horizontalPos;
++if (pList["style:horizontal-pos"])
++  horizontalPos = pList["style:horizontal-pos"]->getStr();
++
++if (horizontalPos == "right")
++  cssProps["float"] = "right";
++else
++  cssProps["float"] = "left";
++  }
++
+   // Extract borders.
+   static char const *(type[]) = {"border", "border-left", "border-top", 
"border-right", "border-bottom" };
+   for (int i = 0; i < 5; i++)
+-- 
+2.13.6
+
diff --git a/writerperfect/source/writer/exp/txtstyli.cxx 
b/writerperfect/source/writer/exp/txtstyli.cxx
index 88c63aa9063f..e8fe1a43bea0 100644
--- a/writerperfect/source/writer/exp/txtstyli.cxx
+++ b/writerperfect/source/writer/exp/txtstyli.cxx
@@ -260,6 +260,7 @@ void XMLStyleContext::startElement(const OUString 
&/*rName*/, const css::uno::Re
 OString sValue = OUStringToOString(rAttributeValue, 
RTL_TEXTENCODING_UTF8);
 m_aTextPropertyList.insert(sName.getStr(), sValue.getStr());
 m_aParagraphPropertyList.insert(sName.getStr(), sValue.getStr());
+m_aGraphicPropertyList.insert(sName.getStr(), sValue.getStr());
 }
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2017-11-27 Thread Miklos Vajna
 external/libepubgen/libepubgen-epub3.patch.1 |   29 +++
 writerperfect/qa/unit/EPUBExportTest.cxx |  181 ---
 writerperfect/source/writer/EPUBExportFilter.cxx |   22 --
 writerperfect/source/writer/EPUBExportFilter.hxx |2 
 4 files changed, 99 insertions(+), 135 deletions(-)

New commits:
commit 9fc84943503be2433b7ec6ddb8487be80d155f24
Author: Miklos Vajna 
Date:   Mon Nov 27 08:18:09 2017 +0100

EPUB export: switch back to using an external CSS

And fix the root of the problem in libepubgen. Also clean up related
test code, so asserting CSS markup is as simple as asserting XML markup
now.

Change-Id: Iebe20be07e604b864e65a3376609a44a35bfa491
Reviewed-on: https://gerrit.libreoffice.org/45306
Tested-by: Jenkins 
Reviewed-by: Miklos Vajna 

diff --git a/external/libepubgen/libepubgen-epub3.patch.1 
b/external/libepubgen/libepubgen-epub3.patch.1
index c28f1b49a633..c226c51d4388 100644
--- a/external/libepubgen/libepubgen-epub3.patch.1
+++ b/external/libepubgen/libepubgen-epub3.patch.1
@@ -3548,3 +3548,32 @@ index 21a1b37..c9f4236 100644
 -- 
 2.13.6
 
+From 094db625e36b91b57e152296a1f7db1bdcc682c5 Mon Sep 17 00:00:00 2001
+From: Miklos Vajna 
+Date: Wed, 8 Nov 2017 14:10:26 +0100
+Subject: [PATCH] EPUBHTMLGenerator: add missing rel attribute for CSS
+ reference
+
+Turns out a number of readers (checked Calibre and Aldiko on Android) do
+support taking formatting from an external CSS, but only in case this
+attribute is present.
+---
+ src/lib/EPUBHTMLGenerator.cpp  |  1 +
+ src/test/EPUBTextGeneratorTest.cpp | 24 
+ 2 files changed, 25 insertions(+)
+
+diff --git a/src/lib/EPUBHTMLGenerator.cpp b/src/lib/EPUBHTMLGenerator.cpp
+index 4ffa55d..d81a905 100644
+--- a/src/lib/EPUBHTMLGenerator.cpp
 b/src/lib/EPUBHTMLGenerator.cpp
+@@ -531,6 +531,7 @@ void EPUBHTMLGenerator::endDocument()
+   RVNGPropertyList linkAttrs;
+   linkAttrs.insert("href", 
m_impl->m_stylesheetPath.relativeTo(m_impl->m_path).str().c_str());
+   linkAttrs.insert("type", "text/css");
++  linkAttrs.insert("rel", "stylesheet");
+   m_impl->m_document.insertEmptyElement("link", linkAttrs);
+   m_impl->m_document.closeElement("head");
+   m_impl->m_document.openElement("body", RVNGPropertyList());
+-- 
+2.13.6
+
diff --git a/writerperfect/qa/unit/EPUBExportTest.cxx 
b/writerperfect/qa/unit/EPUBExportTest.cxx
index 18865e4d8c4b..bddfb8fd2d92 100644
--- a/writerperfect/qa/unit/EPUBExportTest.cxx
+++ b/writerperfect/qa/unit/EPUBExportTest.cxx
@@ -47,15 +47,13 @@ public:
 void setUp() override;
 void tearDown() override;
 void registerNamespaces(xmlXPathContextPtr ) override;
-/// Asserts that rCssDoc has a key named rKey and one of its rules is 
rValue.
-void assertCss(const std::map< OString, std::vector > , 
const OString , const OString );
 void createDoc(const OUString , const 
uno::Sequence );
 /// Returns an XML representation of the stream named rName in the 
exported package.
 xmlDocPtr parseExport(const OUString );
-/// Loads a CSS representation of the stream named rName in the exported 
package into rTree.
-void parseCssExport(const OUString , std::map< OString, 
std::vector > );
-/// Loads a CSS style string into a map.
-static std::map parseCssStyle(const OUString );
+/// Parses a CSS representation of the stream named rName and returns it.
+std::map< OUString, std::vector > parseCss(const OUString 
);
+/// Looks up a key of a class in rCss.
+static OUString getCss(std::map< OUString, std::vector > , 
const OUString , const OUString );
 void testOutlineLevel();
 void testMimetype();
 void testEPUB2();
@@ -144,16 +142,6 @@ void EPUBExportTest::registerNamespaces(xmlXPathContextPtr 
)
 xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("xhtml"), 
BAD_CAST("http://www.w3.org/1999/xhtml;));
 }
 
-void EPUBExportTest::assertCss(const std::map< OString, std::vector > 
, const OString , const OString )
-{
-auto it = rCssDoc.find(rKey);
-CPPUNIT_ASSERT(it != rCssDoc.end());
-
-const std::vector  = it->second;
-CPPUNIT_ASSERT_MESSAGE(OString("In '" + rKey + "', rule '" + rValue + "' 
is not found.").getStr(),
-   std::find(rRule.begin(), rRule.end(), rValue) != 
rRule.end());
-}
-
 void EPUBExportTest::createDoc(const OUString , const 
uno::Sequence )
 {
 // Import the bugdoc and export as EPUB.
@@ -177,38 +165,52 @@ xmlDocPtr EPUBExportTest::parseExport(const OUString 
)
 return parseXmlStream(pStream.get());
 }
 
-void EPUBExportTest::parseCssExport(const OUString , std::map< OString, 
std::vector > )
+std::map< OUString, std::vector > EPUBExportTest::parseCss(const 
OUString )
 {
+std::map< OUString, std::vector > aRet;
+
 uno::Reference xInputStream(mxZipFile->getByName(rName), 

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

2017-11-27 Thread Miklos Vajna
 external/libepubgen/libepubgen-epub3.patch.1   |  232 
++
 writerperfect/qa/unit/EPUBExportTest.cxx   |   12 
 writerperfect/qa/unit/data/writer/epubexport/image-border.fodt |   36 +
 writerperfect/source/writer/exp/XMLTextFrameContext.cxx|   20 
 writerperfect/source/writer/exp/txtstyli.cxx   |   45 +
 writerperfect/source/writer/exp/txtstyli.hxx   |2 
 writerperfect/source/writer/exp/xmlfmt.cxx |   25 -
 writerperfect/source/writer/exp/xmlfmt.hxx |9 
 writerperfect/source/writer/exp/xmlimp.cxx |   24 -
 writerperfect/source/writer/exp/xmlimp.hxx |4 
 10 files changed, 373 insertions(+), 36 deletions(-)

New commits:
commit d43aa095b47bfb7e82a3c5a7b3b5149550716640
Author: Miklos Vajna 
Date:   Mon Nov 27 08:17:33 2017 +0100

EPUB export: handle image borders

This requires handling of graphic styles.

Change-Id: I74d4ee882b91192da44d8d7bbd88c1a66e97695f
Reviewed-on: https://gerrit.libreoffice.org/45305
Tested-by: Jenkins 
Reviewed-by: Miklos Vajna 

diff --git a/external/libepubgen/libepubgen-epub3.patch.1 
b/external/libepubgen/libepubgen-epub3.patch.1
index 98ce658e5705..c28f1b49a633 100644
--- a/external/libepubgen/libepubgen-epub3.patch.1
+++ b/external/libepubgen/libepubgen-epub3.patch.1
@@ -3316,3 +3316,235 @@ index 24ae1a5..ab1f9e6 100644
 -- 
 2.13.6
 
+From 801367ee905aa70bb2ba2ad5b8257cd2a25bed9b Mon Sep 17 00:00:00 2001
+From: Miklos Vajna 
+Date: Wed, 8 Nov 2017 10:50:11 +0100
+Subject: [PATCH] EPUBImageManager: add support for borders
+
+The properties are on the frame, but the inner binary object emits the
+"img" element that has the properties in XHTML. Solve this by
+maintaining a stack of currently opened frames, with their properties.
+---
+ src/lib/EPUBGenerator.cpp  |  1 +
+ src/lib/EPUBHTMLGenerator.cpp  | 26 
+ src/lib/EPUBImageManager.cpp   | 50 ++
+ src/lib/EPUBImageManager.h | 16 
+ src/test/EPUBTextGeneratorTest.cpp | 26 
+ 5 files changed, 119 insertions(+)
+
+diff --git a/src/lib/EPUBGenerator.cpp b/src/lib/EPUBGenerator.cpp
+index 75c3076..38c3188 100644
+--- a/src/lib/EPUBGenerator.cpp
 b/src/lib/EPUBGenerator.cpp
+@@ -230,6 +230,7 @@ void EPUBGenerator::writeStylesheet()
+   m_paragraphStyleManager.send(sink);
+   m_spanStyleManager.send(sink);
+   m_tableStyleManager.send(sink);
++  m_imageManager.send(sink);
+ 
+   sink.writeTo(*m_package, m_stylesheetPath.str().c_str());
+ }
+diff --git a/src/lib/EPUBHTMLGenerator.cpp b/src/lib/EPUBHTMLGenerator.cpp
+index e00bea8..4ffa55d 100644
+--- a/src/lib/EPUBHTMLGenerator.cpp
 b/src/lib/EPUBHTMLGenerator.cpp
+@@ -364,6 +364,7 @@ struct EPUBHTMLGeneratorImpl
+ , m_ignore(false)
+ , m_hasText(false)
+ , m_frameAnchorTypes()
++, m_framePropertiesStack()
+ , m_stylesMethod(stylesMethod)
+ , m_actualSink()
+ , m_sinkStack()
+@@ -454,6 +455,7 @@ struct EPUBHTMLGeneratorImpl
+   bool m_hasText;
+ 
+   std::stack m_frameAnchorTypes;
++  std::stack m_framePropertiesStack;
+ 
+   EPUBStylesMethod m_stylesMethod;
+ 
+@@ -929,20 +931,29 @@ void EPUBHTMLGenerator::openFrame(const RVNGPropertyList 
)
+ {
+   librevenge::RVNGPropertyList::Iter i(propList);
+   std::string anchorType;
++  RVNGPropertyList frameProperties;
+   for (i.rewind(); i.next();)
+   {
+ if (std::string("text:anchor-type") == i.key())
+   anchorType = i()->getStr().cstr();
++
++// Remember the property for binary object purposes.
++frameProperties.insert(i.key(), i()->clone());
+   }
+ 
+   if (anchorType == "page")
+ // Other anchor types are already inside a paragraph.
+ m_impl->output().openElement("p", RVNGPropertyList());
+   m_impl->m_frameAnchorTypes.push(anchorType);
++
++  m_impl->m_framePropertiesStack.push(frameProperties);
+ }
+ 
+ void EPUBHTMLGenerator::closeFrame()
+ {
++  if (!m_impl->m_framePropertiesStack.empty())
++m_impl->m_framePropertiesStack.pop();
++
+   if (m_impl->m_frameAnchorTypes.empty())
+ return;
+ 
+@@ -970,6 +981,21 @@ void EPUBHTMLGenerator::insertBinaryObject(const 
RVNGPropertyList )
+propList["librevenge:mime-type"]->getStr());
+ 
+   RVNGPropertyList attrs;
++
++  if (!m_impl->m_framePropertiesStack.empty())
++  {
++RVNGPropertyList  = m_impl->m_framePropertiesStack.top();
++switch (m_impl->m_stylesMethod)
++{
++case EPUB_STYLES_METHOD_CSS:
++  attrs.insert("class", 
m_impl->m_imageManager.getImageClass(frameProperties).c_str());
++  break;
++case EPUB_STYLES_METHOD_INLINE:
++  attrs.insert("style", 
m_impl->m_imageManager.getImageStyle(frameProperties).c_str());
++  break;
++}
++  }
++
+   

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

2017-11-24 Thread Miklos Vajna
 external/libepubgen/libepubgen-epub3.patch.1  |  219 ++
 writerperfect/qa/unit/EPUBExportTest.cxx  |   39 +
 writerperfect/qa/unit/data/writer/epubexport/table-width.fodt |   28 +
 writerperfect/source/writer/exp/txtstyli.cxx  |   41 +
 writerperfect/source/writer/exp/txtstyli.hxx  |2 
 writerperfect/source/writer/exp/xmlfmt.cxx|   11 
 writerperfect/source/writer/exp/xmlfmt.hxx|5 
 writerperfect/source/writer/exp/xmlimp.cxx|   16 
 writerperfect/source/writer/exp/xmlimp.hxx|4 
 writerperfect/source/writer/exp/xmltbli.cxx   |   23 -
 writerperfect/source/writer/exp/xmltbli.hxx   |2 
 11 files changed, 367 insertions(+), 23 deletions(-)

New commits:
commit 8b8aa6bc010fffbcd47679aa101075d702741f69
Author: Miklos Vajna 
Date:   Fri Nov 24 09:14:05 2017 +0100

EPUB export: handle total table width

This is important when e.g. the col width are 50-50%, then without
explicit total table width the table width won't be correct.

Change-Id: I5ccd6dfb5b78c564485d54cda62e12f3d1ca36c1
Reviewed-on: https://gerrit.libreoffice.org/45204
Tested-by: Jenkins 
Reviewed-by: Miklos Vajna 

diff --git a/external/libepubgen/libepubgen-epub3.patch.1 
b/external/libepubgen/libepubgen-epub3.patch.1
index 3ce4fe034f75..98ce658e5705 100644
--- a/external/libepubgen/libepubgen-epub3.patch.1
+++ b/external/libepubgen/libepubgen-epub3.patch.1
@@ -3097,3 +3097,222 @@ index 4de70e3..24ae1a5 100644
 -- 
 2.13.6
 
+From d5bd8c9078eeb63769ff1807be1a9571430eaed1 Mon Sep 17 00:00:00 2001
+From: Miklos Vajna 
+Date: Mon, 6 Nov 2017 10:19:32 +0100
+Subject: [PATCH] EPUBTableStyleManager: handle table props
+
+Other than column properties. Only width and relative width for now.
+---
+ src/lib/EPUBHTMLGenerator.cpp  | 16 +--
+ src/lib/EPUBTableStyleManager.cpp  | 87 --
+ src/lib/EPUBTableStyleManager.h| 12 +-
+ src/test/EPUBTextGeneratorTest.cpp | 27 
+ 4 files changed, 114 insertions(+), 28 deletions(-)
+
+diff --git a/src/lib/EPUBHTMLGenerator.cpp b/src/lib/EPUBHTMLGenerator.cpp
+index 86b3ac2..e00bea8 100644
+--- a/src/lib/EPUBHTMLGenerator.cpp
 b/src/lib/EPUBHTMLGenerator.cpp
+@@ -846,10 +846,18 @@ void EPUBHTMLGenerator::openTable(const RVNGPropertyList 
)
+   if (m_impl->m_ignore)
+ return;
+ 
+-  const librevenge::RVNGPropertyListVector *columns = 
propList.child("librevenge:table-columns");
+-  if (columns)
+-m_impl->m_tableManager.openTable(*columns);
+-  m_impl->output().openElement("table", RVNGPropertyList());
++  m_impl->m_tableManager.openTable(propList);
++  RVNGPropertyList attrs;
++  switch (m_impl->m_stylesMethod)
++  {
++  case EPUB_STYLES_METHOD_CSS:
++attrs.insert("class", 
m_impl->m_tableManager.getTableClass(propList).c_str());
++break;
++  case EPUB_STYLES_METHOD_INLINE:
++attrs.insert("style", 
m_impl->m_tableManager.getTableStyle(propList).c_str());
++break;
++  }
++  m_impl->output().openElement("table", attrs);
+   m_impl->output().openElement("tbody", RVNGPropertyList());
+ }
+ 
+diff --git a/src/lib/EPUBTableStyleManager.cpp 
b/src/lib/EPUBTableStyleManager.cpp
+index 92078a2..d5e650c 100644
+--- a/src/lib/EPUBTableStyleManager.cpp
 b/src/lib/EPUBTableStyleManager.cpp
+@@ -23,34 +23,38 @@ using librevenge::RVNGPropertyList;
+ using librevenge::RVNGPropertyListVector;
+ using librevenge::RVNGString;
+ 
+-void EPUBTableStyleManager::openTable(RVNGPropertyListVector const )
++void EPUBTableStyleManager::openTable(RVNGPropertyList const )
+ {
+-  std::vector colWidths;
+-  std::vector relColWidths;
+-  for (unsigned long i = 0; i < colList.count(); i++)
++  const librevenge::RVNGPropertyListVector *columns = 
propList.child("librevenge:table-columns");
++  if (columns)
+   {
+-RVNGPropertyList const =colList[i];
+-double width=0;
+-if (prop["style:column-width"])
++std::vector colWidths;
++std::vector relColWidths;
++for (unsigned long i = 0; i < columns->count(); i++)
+ {
+-  librevenge::RVNGUnit unit=prop["style:column-width"]->getUnit();
+-  if (unit==librevenge::RVNG_POINT)
+-width=prop["style:column-width"]->getDouble()/72.;
+-  else if (unit==librevenge::RVNG_INCH)
+-width=prop["style:column-width"]->getDouble();
+-  else if (unit==librevenge::RVNG_TWIP)
+-width=prop["style:column-width"]->getDouble()/1440.;
+-}
+-colWidths.push_back(width);
++  RVNGPropertyList const =(*columns)[i];
++  double width=0;
++  if (prop["style:column-width"])
++  {
++librevenge::RVNGUnit unit=prop["style:column-width"]->getUnit();
++if (unit==librevenge::RVNG_POINT)
++  

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

2017-11-24 Thread Miklos Vajna
 external/libepubgen/libepubgen-epub3.patch.1   |  315 
++
 writerperfect/qa/unit/EPUBExportTest.cxx   |   27 
 writerperfect/qa/unit/data/writer/epubexport/table-cell-width.fodt |   45 +
 writerperfect/source/writer/exp/txtstyli.cxx   |   37 +
 writerperfect/source/writer/exp/txtstyli.hxx   |2 
 writerperfect/source/writer/exp/xmlfmt.cxx |   11 
 writerperfect/source/writer/exp/xmlfmt.hxx |5 
 writerperfect/source/writer/exp/xmlimp.cxx |   16 
 writerperfect/source/writer/exp/xmlimp.hxx |4 
 writerperfect/source/writer/exp/xmltbli.cxx|   94 ++
 writerperfect/source/writer/exp/xmltbli.hxx|4 
 11 files changed, 543 insertions(+), 17 deletions(-)

New commits:
commit af72d1b9d1745944cd7842905d2d8ac3f8d1d640
Author: Miklos Vajna 
Date:   Fri Nov 24 09:12:26 2017 +0100

EPUB export: handle cell width

By handling relative column widths in libepubgen (since LO may only know
that one, when layout is not available) and parsing column properties in
writerperfect.

Change-Id: I8fae5f1a3c970b97c2b452f3c20eff0911a56ba8
Reviewed-on: https://gerrit.libreoffice.org/45202
Tested-by: Jenkins 
Reviewed-by: Miklos Vajna 

diff --git a/external/libepubgen/libepubgen-epub3.patch.1 
b/external/libepubgen/libepubgen-epub3.patch.1
index a45b9666568c..3ce4fe034f75 100644
--- a/external/libepubgen/libepubgen-epub3.patch.1
+++ b/external/libepubgen/libepubgen-epub3.patch.1
@@ -2782,3 +2782,318 @@ index 20056ad..135a144 100644
 -- 
 2.12.3
 
+From 6c8e86ccebb11df7ece32d10da2894c6698c5515 Mon Sep 17 00:00:00 2001
+From: Miklos Vajna 
+Date: Thu, 2 Nov 2017 12:07:02 +0100
+Subject: [PATCH 1/4] EPUBTableStyleManager: witdh -> width
+
+---
+ src/lib/EPUBTableStyleManager.cpp | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/lib/EPUBTableStyleManager.cpp 
b/src/lib/EPUBTableStyleManager.cpp
+index 4e24611..5795524 100644
+--- a/src/lib/EPUBTableStyleManager.cpp
 b/src/lib/EPUBTableStyleManager.cpp
+@@ -48,7 +48,7 @@ void EPUBTableStyleManager::closeTable()
+ {
+   if (!m_columWitdhsStack.size())
+   {
+-EPUBGEN_DEBUG_MSG(("EPUBTableStyleManager::closeTable: can not find the 
columns witdh\n"));
++EPUBGEN_DEBUG_MSG(("EPUBTableStyleManager::closeTable: can not find the 
columns width\n"));
+ return;
+   }
+   m_columWitdhsStack.pop_back();
+@@ -61,7 +61,7 @@ bool EPUBTableStyleManager::getColumnsWidth(int col, int 
numSpanned, double )
+   std::vector const =m_columWitdhsStack.back();
+   if (col < 0 || size_t(col+numSpanned-1) >= widths.size())
+   {
+-EPUBGEN_DEBUG_MSG(("EPUBTableStyleManager::getColumnsWidth: can not 
compute the columns witdh\n"));
++EPUBGEN_DEBUG_MSG(("EPUBTableStyleManager::getColumnsWidth: can not 
compute the columns width\n"));
+ return false;
+   }
+   bool fixed = true;
+-- 
+2.13.6
+
+From 45bf16a8b384010814148538d86ee584b9295c7a Mon Sep 17 00:00:00 2001
+From: Miklos Vajna 
+Date: Fri, 3 Nov 2017 12:30:13 +0100
+Subject: [PATCH 2/4] Witdh -> Width
+
+---
+ src/lib/EPUBTableStyleManager.cpp | 10 +-
+ src/lib/EPUBTableStyleManager.h   |  4 ++--
+ 2 files changed, 7 insertions(+), 7 deletions(-)
+
+diff --git a/src/lib/EPUBTableStyleManager.cpp 
b/src/lib/EPUBTableStyleManager.cpp
+index 5795524..6f8b2af 100644
+--- a/src/lib/EPUBTableStyleManager.cpp
 b/src/lib/EPUBTableStyleManager.cpp
+@@ -41,24 +41,24 @@ void 
EPUBTableStyleManager::openTable(RVNGPropertyListVector const )
+ }
+ colWidths.push_back(width);
+   }
+-  m_columWitdhsStack.push_back(colWidths);
++  m_columWidthsStack.push_back(colWidths);
+ }
+ 
+ void EPUBTableStyleManager::closeTable()
+ {
+-  if (!m_columWitdhsStack.size())
++  if (!m_columWidthsStack.size())
+   {
+ EPUBGEN_DEBUG_MSG(("EPUBTableStyleManager::closeTable: can not find the 
columns width\n"));
+ return;
+   }
+-  m_columWitdhsStack.pop_back();
++  m_columWidthsStack.pop_back();
+ }
+ 
+ bool EPUBTableStyleManager::getColumnsWidth(int col, int numSpanned, double 
) const
+ {
+-  if (!m_columWitdhsStack.size())
++  if (!m_columWidthsStack.size())
+ return false;
+-  std::vector const =m_columWitdhsStack.back();
++  std::vector const =m_columWidthsStack.back();
+   if (col < 0 || size_t(col+numSpanned-1) >= widths.size())
+   {
+ EPUBGEN_DEBUG_MSG(("EPUBTableStyleManager::getColumnsWidth: can not 
compute the columns width\n"));
+diff --git a/src/lib/EPUBTableStyleManager.h b/src/lib/EPUBTableStyleManager.h
+index 135a144..5f704a1 100644
+--- a/src/lib/EPUBTableStyleManager.h
 b/src/lib/EPUBTableStyleManager.h
+@@ -32,7 +32,7 @@ class EPUBTableStyleManager
+ 
+ public:
+   //! 

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

2017-11-24 Thread Miklos Vajna
 external/libepubgen/libepubgen-epub3.patch.1 |  177 
++
 writerperfect/qa/unit/EPUBExportTest.cxx |   11 
 writerperfect/qa/unit/data/writer/epubexport/table-row-span.fodt |   42 ++
 writerperfect/source/writer/exp/xmltbli.cxx  |   20 -
 4 files changed, 247 insertions(+), 3 deletions(-)

New commits:
commit 0baecd418e79a703dcf89fec3f66e416beefcf56
Author: Miklos Vajna 
Date:   Fri Nov 24 09:09:25 2017 +0100

EPUB export: implement row span for tables

By turning  attributes into librevenge properties.
Also make sure that row/cell styles are inline at a libepubgen level.

Change-Id: Ic23058748d241209845f76d8edc548bab8212c5f

diff --git a/external/libepubgen/libepubgen-epub3.patch.1 
b/external/libepubgen/libepubgen-epub3.patch.1
index d6f41f13f61e..a45b9666568c 100644
--- a/external/libepubgen/libepubgen-epub3.patch.1
+++ b/external/libepubgen/libepubgen-epub3.patch.1
@@ -2605,3 +2605,180 @@ index 11bf7de..25294c6 100644
 -- 
 2.12.3
 
+From f3a04df200d818b4aaa9d54910b670cd6cf3149f Mon Sep 17 00:00:00 2001
+From: Miklos Vajna 
+Date: Tue, 31 Oct 2017 15:50:50 +0100
+Subject: [PATCH] EPUBHTMLGenerator: librevenge:type -> xlink:type
+
+That's what libetonyek and LO's librevenge producer generates, also
+matches librevenge documentation. This isn't really a behavior change,
+just makes the warning go away in the xlink case.
+---
+ src/lib/EPUBHTMLGenerator.cpp | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/lib/EPUBHTMLGenerator.cpp b/src/lib/EPUBHTMLGenerator.cpp
+index 25294c6..0d39c00 100644
+--- a/src/lib/EPUBHTMLGenerator.cpp
 b/src/lib/EPUBHTMLGenerator.cpp
+@@ -657,9 +657,9 @@ void EPUBHTMLGenerator::openLink(const RVNGPropertyList 
)
+   if (m_impl->m_ignore)
+ return;
+ 
+-  if (!propList["librevenge:type"])
++  if (!propList["xlink:type"])
+   {
+-EPUBGEN_DEBUG_MSG(("EPUBHTMLGenerator::openLink: librevenge:type: not 
filled, suppose link\n"));
++EPUBGEN_DEBUG_MSG(("EPUBHTMLGenerator::openLink: xlink:type: not filled, 
suppose link\n"));
+   }
+   RVNGPropertyList attrs;
+   if (propList["xlink:href"])
+-- 
+2.12.3
+
+From c5e32608ecea8410b11760284d49e1f1958c6f75 Mon Sep 17 00:00:00 2001
+From: Miklos Vajna 
+Date: Tue, 31 Oct 2017 16:50:50 +0100
+Subject: [PATCH] EPUBTableStyleManager: handle EPUB_STYLES_METHOD_INLINE for
+ rows
+
+This was working for paragraphs and spans only previously.
+---
+ src/lib/EPUBHTMLGenerator.cpp  | 10 +-
+ src/lib/EPUBTableStyleManager.cpp  | 11 +++
+ src/lib/EPUBTableStyleManager.h|  2 ++
+ src/test/EPUBTextGeneratorTest.cpp | 28 
+ 4 files changed, 50 insertions(+), 1 deletion(-)
+
+diff --git a/src/lib/EPUBHTMLGenerator.cpp b/src/lib/EPUBHTMLGenerator.cpp
+index 0d39c00..42e8e3e 100644
+--- a/src/lib/EPUBHTMLGenerator.cpp
 b/src/lib/EPUBHTMLGenerator.cpp
+@@ -858,7 +858,15 @@ void EPUBHTMLGenerator::openTableRow(const 
RVNGPropertyList )
+   if (m_impl->m_ignore)
+ return;
+   RVNGPropertyList attrs;
+-  attrs.insert("class", m_impl->m_tableManager.getRowClass(propList).c_str());
++  switch (m_impl->m_stylesMethod)
++  {
++  case EPUB_STYLES_METHOD_CSS:
++attrs.insert("class", 
m_impl->m_tableManager.getRowClass(propList).c_str());
++break;
++  case EPUB_STYLES_METHOD_INLINE:
++attrs.insert("style", 
m_impl->m_tableManager.getRowStyle(propList).c_str());
++break;
++  }
+   m_impl->output().openElement("tr", attrs);
+ }
+ 
+diff --git a/src/lib/EPUBTableStyleManager.cpp 
b/src/lib/EPUBTableStyleManager.cpp
+index 52b6959..ead9170 100644
+--- a/src/lib/EPUBTableStyleManager.cpp
 b/src/lib/EPUBTableStyleManager.cpp
+@@ -111,6 +111,17 @@ std::string 
EPUBTableStyleManager::getRowClass(RVNGPropertyList const )
+   return s.str();
+ }
+ 
++std::string EPUBTableStyleManager::getRowStyle(RVNGPropertyList const )
++{
++  EPUBCSSProperties content;
++  extractRowProperties(pList, content);
++
++  std::stringstream s;
++  for (const auto  : content)
++s << property.first << ": " << property.second << "; ";
++  return s.str();
++}
++
+ void EPUBTableStyleManager::send(EPUBCSSSink )
+ {
+   for (ContentNameMap_t::const_iterator it=m_cellContentNameMap.begin(); 
m_cellContentNameMap.end() != it; ++it)
+diff --git a/src/lib/EPUBTableStyleManager.h b/src/lib/EPUBTableStyleManager.h
+index e6d09bc..20056ad 100644
+--- a/src/lib/EPUBTableStyleManager.h
 b/src/lib/EPUBTableStyleManager.h
+@@ -47,6 +47,8 @@ public:
+   std::string getCellClass(librevenge::RVNGPropertyList const );
+   //! returns the class name corresponding to a propertylist
+   std::string getRowClass(librevenge::RVNGPropertyList const );
++  //! returns the style string corresponding to a propertylist
++  std::string getRowStyle(librevenge::RVNGPropertyList const );
+   //! send the data to the sink
+   void 

[Libreoffice-commits] core.git: external/libepubgen

2017-11-05 Thread David Tardon
 external/libepubgen/UnpackedTarball_libepubgen.mk |2 ++
 1 file changed, 2 insertions(+)

New commits:
commit d6765e376706680156e71e985eeeb58bf469f849
Author: David Tardon 
Date:   Sun Nov 5 15:05:43 2017 +0100

fix build of bundled libepubgen on ppc64le

Change-Id: I559058ffe2192764a27d278eea0e4d4676bbd64d

diff --git a/external/libepubgen/UnpackedTarball_libepubgen.mk 
b/external/libepubgen/UnpackedTarball_libepubgen.mk
index 28582a5cf0f3..312facb2bb11 100644
--- a/external/libepubgen/UnpackedTarball_libepubgen.mk
+++ b/external/libepubgen/UnpackedTarball_libepubgen.mk
@@ -32,6 +32,8 @@ $(eval $(call gb_UnpackedTarball_UnpackedTarball,libepubgen))
 
 $(eval $(call gb_UnpackedTarball_set_tarball,libepubgen,$(EPUBGEN_TARBALL)))
 
+$(eval $(call gb_UnpackedTarball_update_autoconf_configs,libepubgen))
+
 $(eval $(call gb_UnpackedTarball_set_patchlevel,libepubgen,0))
 
 $(eval $(call gb_UnpackedTarball_add_patches,libepubgen,\
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: external/libepubgen

2017-10-28 Thread David Tardon
 external/libepubgen/ExternalProject_libepubgen.mk |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit e6af915fae27a19b6ac79a9f76fb8b04361d6f4b
Author: David Tardon 
Date:   Sat Oct 28 11:00:17 2017 +0200

libepubgen: pass optimization flags to configure

Change-Id: I50e0c7bfe89249c421b8e03f57445ce1bf51ecb4
Reviewed-on: https://gerrit.libreoffice.org/43982
Reviewed-by: David Tardon 
Tested-by: David Tardon 

diff --git a/external/libepubgen/ExternalProject_libepubgen.mk 
b/external/libepubgen/ExternalProject_libepubgen.mk
index d127f63956d1..772a41daa2e4 100644
--- a/external/libepubgen/ExternalProject_libepubgen.mk
+++ b/external/libepubgen/ExternalProject_libepubgen.mk
@@ -31,7 +31,8 @@ $(call gb_ExternalProject_get_state_target,libepubgen,build) :
$(if $(ENABLE_DEBUG),--enable-debug,--disable-debug) \
--disable-werror \
$(if 
$(verbose),--disable-silent-rules,--enable-silent-rules) \
-   CXXFLAGS="$(CXXFLAGS) $(BOOST_CPPFLAGS)" \
+   CXXFLAGS="$(gb_CXXFLAGS) $(if 
$(ENABLE_OPTIMIZED),$(gb_COMPILEROPTFLAGS),$(gb_COMPILERNOOPTFLAGS))" \
+   CPPFLAGS="$(CPPFLAGS) $(BOOST_CPPFLAGS)" \
$(if $(CROSS_COMPILING),--build=$(BUILD_PLATFORM) 
--host=$(HOST_PLATFORM)) \
&& $(MAKE) \
)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2017-10-18 Thread Miklos Vajna
 external/libepubgen/libepubgen-epub3.patch.1 |   48 +++
 writerperfect/qa/unit/EPUBExportTest.cxx |2 -
 2 files changed, 49 insertions(+), 1 deletion(-)

New commits:
commit e3ecb42e32b7daa07b327b2f40f757f0206fb484
Author: Miklos Vajna 
Date:   Wed Oct 18 13:50:51 2017 +0200

EPUB export: better handling of tabs

Mapping ODF/librevenge tab to \t in HTML is not a great idea, as it's
ignorable whitespace. Go with NBSPs and a breakable space instead, that
is much closer visually (15 is just an arbitrary number, it's what MS
Word uses in its HTML export, LO Writer HTML export doesn't handle
this).

Adapt the empty paragraph case to also use NBSP for consistency.

Change-Id: I131802416499eb4f3a83a333b37ca20b59fcd56a

diff --git a/external/libepubgen/libepubgen-epub3.patch.1 
b/external/libepubgen/libepubgen-epub3.patch.1
index 01d88d4da380..d6f41f13f61e 100644
--- a/external/libepubgen/libepubgen-epub3.patch.1
+++ b/external/libepubgen/libepubgen-epub3.patch.1
@@ -2557,3 +2557,51 @@ index 26675af..5d4e8f2 100644
 -- 
 2.12.3
 
+From c5bb9ad8922c9f537f0d613d42c33487717455c3 Mon Sep 17 00:00:00 2001
+From: Miklos Vajna 
+Date: Wed, 18 Oct 2017 10:52:01 +0200
+Subject: [PATCH] EPUBHTMLGenerator: better handling of tabs
+
+Mapping ODF/librevenge tab to \t in HTML is not a great idea, as it's
+ignorable whitespace. Go with NBSPs and a breakable space instead, that
+is much closer visually (15 is just an arbitrary number, it's what MS
+Word uses in its HTML export, LO Writer HTML export doesn't handle
+this).
+
+Adapt the empty paragraph case to also use NBSP for consistency.
+---
+ src/lib/EPUBHTMLGenerator.cpp  | 10 +++---
+ src/test/EPUBTextGeneratorTest.cpp | 18 +-
+ 2 files changed, 24 insertions(+), 4 deletions(-)
+
+diff --git a/src/lib/EPUBHTMLGenerator.cpp b/src/lib/EPUBHTMLGenerator.cpp
+index 11bf7de..25294c6 100644
+--- a/src/lib/EPUBHTMLGenerator.cpp
 b/src/lib/EPUBHTMLGenerator.cpp
+@@ -617,7 +617,7 @@ void EPUBHTMLGenerator::closeParagraph()
+ return;
+ 
+   if (!m_impl->m_hasText)
+-insertLineBreak();
++insertSpace();
+ 
+   m_impl->output().closeElement("p");
+ }
+@@ -687,8 +687,12 @@ void EPUBHTMLGenerator::insertTab()
+   if (m_impl->m_ignore)
+ return;
+ 
+-  // Does not have a lot of effect since tabs in html are ignorable 
white-space
+-  m_impl->output().insertCharacters("\t");
++  // \t would not have a lot of effect since tabs in html are ignorable
++  // white-space. Write NBSPs and a breakable space instead.
++  for (int i = 0; i < 15; ++i)
++m_impl->output().insertCharacters("\xc2\xa0");
++  m_impl->output().insertCharacters(" ");
++  m_impl->m_hasText = true;
+ }
+ 
+ void EPUBHTMLGenerator::insertLineBreak()
+-- 
+2.12.3
+
diff --git a/writerperfect/qa/unit/EPUBExportTest.cxx 
b/writerperfect/qa/unit/EPUBExportTest.cxx
index 850228c0a276..e9f1ee8743df 100644
--- a/writerperfect/qa/unit/EPUBExportTest.cxx
+++ b/writerperfect/qa/unit/EPUBExportTest.cxx
@@ -400,7 +400,7 @@ void EPUBExportTest::testEscape()
 // Make sure escaping happens only once.
 assertXPathContent(mpXmlDoc, "//xhtml:p[1]/xhtml:span[2]", "a");
 // This was also lost.
-assertXPathContent(mpXmlDoc, "//xhtml:p[1]/xhtml:span[3]", "\t");
+assertXPathContent(mpXmlDoc, "//xhtml:p[1]/xhtml:span[3]", 
OUString::fromUtf8("\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0
 "));
 }
 
 void EPUBExportTest::testParaCharProps()
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: external/libepubgen

2017-10-18 Thread Miklos Vajna
 external/libepubgen/libepubgen-epub3.patch.1 |   70 +++
 1 file changed, 70 insertions(+)

New commits:
commit 8aedc0aeeedf4518fe958a109bdd7f264ec5fa46
Author: Miklos Vajna 
Date:   Wed Oct 18 10:14:45 2017 +0200

EPUB export: handle headings inside sections

On one hand, we don't want to split inside a section as there might be
elements we need to close/open at split boundary, OTOH this is currently
not a problem as we don't produce any output for sections.

So remove the level management for sections (this way allowing headings
to split inside sections), let's get back to this when there is a
concept how e.g. multiple columns would be represented in EPUB.

Use case is when sections are used to just group paragraph together and
mark all of them read-only: in this case it's unexpected that headings
are handled differently to not-in-section ones.

Change-Id: If419624f8eec4a6f676ad7f186484c0035f62626
Reviewed-on: https://gerrit.libreoffice.org/43482
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins 

diff --git a/external/libepubgen/libepubgen-epub3.patch.1 
b/external/libepubgen/libepubgen-epub3.patch.1
index 98d4930c5f3f..01d88d4da380 100644
--- a/external/libepubgen/libepubgen-epub3.patch.1
+++ b/external/libepubgen/libepubgen-epub3.patch.1
@@ -2487,3 +2487,73 @@ index f3b30a6..d822571 100644
 -- 
 2.12.3
 
+From 8166fc972e3d4b930ad0baab164f99b3c717252e Mon Sep 17 00:00:00 2001
+From: Miklos Vajna 
+Date: Wed, 18 Oct 2017 10:04:32 +0200
+Subject: [PATCH] EPUBTextGenerator: handle headings inside sections
+
+On one hand, we don't want to split inside a section as there might be
+elements we need to close/open at split boundary, OTOH this is currently
+not a problem as we don't produce any output for sections.
+
+So remove the level management for sections (this way allowing headings
+to split inside sections), let's get back to this when there is a
+concept how e.g. multiple columns would be represented in EPUB.
+
+Use case is when sections are used to just group paragraph together and
+mark all of them read-only: in this case it's unexpected that headings
+are handled differently to not-in-section ones.
+---
+ src/lib/EPUBHTMLGenerator.cpp  | 14 --
+ src/lib/EPUBTextGenerator.cpp  |  3 ---
+ src/test/EPUBTextGeneratorTest.cpp | 38 ++
+ 3 files changed, 50 insertions(+), 5 deletions(-)
+
+diff --git a/src/lib/EPUBHTMLGenerator.cpp b/src/lib/EPUBHTMLGenerator.cpp
+index d822571..11bf7de 100644
+--- a/src/lib/EPUBHTMLGenerator.cpp
 b/src/lib/EPUBHTMLGenerator.cpp
+@@ -574,8 +574,18 @@ void EPUBHTMLGenerator::closeFooter()
+ }
+ 
+ void EPUBHTMLGenerator::defineSectionStyle(const RVNGPropertyList &) {}
+-void EPUBHTMLGenerator::openSection(const RVNGPropertyList & /* propList */) 
{}
+-void EPUBHTMLGenerator::closeSection() {}
++
++void EPUBHTMLGenerator::openSection(const RVNGPropertyList & /* propList */)
++{
++  // Once output is produced here, EPUBTextGenerator::openSection() will need
++  // to call EPUBSplitGuard::openLevel().
++}
++
++void EPUBHTMLGenerator::closeSection()
++{
++  // Once output is produced here, EPUBTextGenerator::closeSection() will need
++  // to call EPUBSplitGuard::closeLevel().
++}
+ 
+ void EPUBHTMLGenerator::defineParagraphStyle(const RVNGPropertyList )
+ {
+diff --git a/src/lib/EPUBTextGenerator.cpp b/src/lib/EPUBTextGenerator.cpp
+index 26675af..5d4e8f2 100644
+--- a/src/lib/EPUBTextGenerator.cpp
 b/src/lib/EPUBTextGenerator.cpp
+@@ -335,15 +335,12 @@ void EPUBTextGenerator::openSection(const 
librevenge::RVNGPropertyList 
+ {
+   if (m_impl->getSplitGuard().splitOnSize())
+ m_impl->startNewHtmlFile();
+-  m_impl->getSplitGuard().openLevel();
+ 
+   m_impl->getHtml()->openSection(propList);
+ }
+ 
+ void EPUBTextGenerator::closeSection()
+ {
+-  m_impl->getSplitGuard().closeLevel();
+-
+   m_impl->getHtml()->closeSection();
+ }
+ 
+-- 
+2.12.3
+
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: external/libepubgen

2017-10-17 Thread Miklos Vajna
 external/libepubgen/libepubgen-epub3.patch.1 |   68 +++
 1 file changed, 68 insertions(+)

New commits:
commit 7a72f593dada6a7b3231a599772aed8be7d5a62f
Author: Miklos Vajna 
Date:   Tue Oct 17 12:31:41 2017 +0200

EPUB export: fix handling of empty paragraphs

sw HTML export does work to avoid vertical collapsing of empty
(ODF) paragraphs, do the same for EPUB export.

Change-Id: I316a310178dd4aadbe3ed8548be23d64aabf5e47
Reviewed-on: https://gerrit.libreoffice.org/43451
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins 

diff --git a/external/libepubgen/libepubgen-epub3.patch.1 
b/external/libepubgen/libepubgen-epub3.patch.1
index 95ad47038ba9..98d4930c5f3f 100644
--- a/external/libepubgen/libepubgen-epub3.patch.1
+++ b/external/libepubgen/libepubgen-epub3.patch.1
@@ -2419,3 +2419,71 @@ index 5e53ee2..e25fa26 100644
 -- 
 2.12.3
 
+From 383f315b067e9fc1aa840913c581e7451949c2db Mon Sep 17 00:00:00 2001
+From: Miklos Vajna 
+Date: Tue, 17 Oct 2017 12:21:26 +0200
+Subject: [PATCH] EPUBHTMLGenerator: better handling of empty paragraphs
+
+The ODF/librevenge concept is that empty paragraphs still take their
+vertical space, i.e. inserting lots of them is a (poor) equivalent of a
+page break.
+
+HTML collapses empty paragraphs by default, so empty paragraphs need
+some content to preserve this effect. Do the same trick what LibreOffice
+Writer does: if the text has no content, add a  element inside the
+paragraph.
+---
+ src/lib/EPUBHTMLGenerator.cpp  |  8 
+ src/test/EPUBTextGeneratorTest.cpp | 15 +++
+ 2 files changed, 23 insertions(+)
+
+diff --git a/src/lib/EPUBHTMLGenerator.cpp b/src/lib/EPUBHTMLGenerator.cpp
+index f3b30a6..d822571 100644
+--- a/src/lib/EPUBHTMLGenerator.cpp
 b/src/lib/EPUBHTMLGenerator.cpp
+@@ -362,6 +362,7 @@ struct EPUBHTMLGeneratorImpl
+ , m_stylesheetPath(stylesheetPath)
+ , m_actualPage(0)
+ , m_ignore(false)
++, m_hasText(false)
+ , m_frameAnchorTypes()
+ , m_stylesMethod(stylesMethod)
+ , m_actualSink()
+@@ -449,6 +450,8 @@ struct EPUBHTMLGeneratorImpl
+ 
+   int m_actualPage;
+   bool m_ignore;
++  /// Does the currently opened paragraph have some text?
++  bool m_hasText;
+ 
+   std::stack m_frameAnchorTypes;
+ 
+@@ -595,6 +598,7 @@ void EPUBHTMLGenerator::openParagraph(const 
RVNGPropertyList )
+ break;
+   }
+   m_impl->output(false).openElement("p", attrs);
++  m_impl->m_hasText = false;
+ }
+ 
+ void EPUBHTMLGenerator::closeParagraph()
+@@ -602,6 +606,9 @@ void EPUBHTMLGenerator::closeParagraph()
+   if (m_impl->m_ignore)
+ return;
+ 
++  if (!m_impl->m_hasText)
++insertLineBreak();
++
+   m_impl->output().closeElement("p");
+ }
+ 
+@@ -694,6 +701,7 @@ void EPUBHTMLGenerator::insertText(const RVNGString )
+   if (m_impl->m_ignore)
+ return;
+   m_impl->output().insertCharacters(text);
++  m_impl->m_hasText = true;
+ }
+ 
+ void EPUBHTMLGenerator::insertSpace()
+-- 
+2.12.3
+
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: external/libepubgen

2017-10-17 Thread Miklos Vajna
 external/libepubgen/libepubgen-epub3.patch.1 |   36 +++
 1 file changed, 36 insertions(+)

New commits:
commit 0f50f4d91809c65b50da087a84fb7b8722fda3f9
Author: Miklos Vajna 
Date:   Tue Oct 17 10:32:41 2017 +0200

EPUB export: ignore underline type/style 'none'

This is similar to commit ebf34ec31fb441d6226075a51f5f83ebf4668082 (EPUB
export: ignore line though type/style 'none', 2017-09-11), but this time
for underline.

Change-Id: I806f64cc59e8cd8ab944500256755c18ed3d1249
Reviewed-on: https://gerrit.libreoffice.org/43449
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins 

diff --git a/external/libepubgen/libepubgen-epub3.patch.1 
b/external/libepubgen/libepubgen-epub3.patch.1
index d1d1af2333f6..95ad47038ba9 100644
--- a/external/libepubgen/libepubgen-epub3.patch.1
+++ b/external/libepubgen/libepubgen-epub3.patch.1
@@ -2383,3 +2383,39 @@ index 07aa50d..26675af 100644
 -- 
 2.12.3
 
+From 4f46bc715a5fc8a0e13bb1596f6f5dbb55ca0632 Mon Sep 17 00:00:00 2001
+From: Miklos Vajna 
+Date: Tue, 17 Oct 2017 10:22:35 +0200
+Subject: [PATCH] EPUBSpanStyleManager: ignore underline type/style 'none'
+
+This is similar to commit 7be89d1881e175182039ca93a1546d79933cab85
+(EPUBSpanStyleManager: ignore line though type/style 'none',
+2017-09-11).
+---
+ src/lib/EPUBSpanStyleManager.cpp   |  9 -
+ src/test/EPUBTextGeneratorTest.cpp | 22 ++
+ 2 files changed, 30 insertions(+), 1 deletion(-)
+
+diff --git a/src/lib/EPUBSpanStyleManager.cpp 
b/src/lib/EPUBSpanStyleManager.cpp
+index 5e53ee2..e25fa26 100644
+--- a/src/lib/EPUBSpanStyleManager.cpp
 b/src/lib/EPUBSpanStyleManager.cpp
+@@ -161,7 +161,14 @@ void 
EPUBSpanStyleManager::extractDecorations(RVNGPropertyList const , EPU
+ 
+   if (pList["style:text-overline-style"] || pList["style:text-overline-type"])
+ s << " overline";
+-  if (pList["style:text-underline-style"] || 
pList["style:text-underline-type"])
++  const librevenge::RVNGProperty *textUnderlineStyle = 
pList["style:text-underline-style"];
++  bool underline = textUnderlineStyle && textUnderlineStyle->getStr() != 
"none";
++  if (!underline)
++  {
++const librevenge::RVNGProperty *textUnderlineType = 
pList["style:text-underline-type"];
++underline = textUnderlineType && textUnderlineType->getStr() != "none";
++  }
++  if (underline)
+ s << " underline";
+   if (s.str().length())
+ cssProps["text-decoration"] = s.str();
+-- 
+2.12.3
+
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2017-09-19 Thread Miklos Vajna
 external/libepubgen/libepubgen-epub3.patch.1 |  328 +++
 writerperfect/qa/unit/EPUBExportTest.cxx |   49 ++-
 writerperfect/source/writer/EPUBExportFilter.cxx |   11 
 writerperfect/source/writer/EPUBExportFilter.hxx |2 
 4 files changed, 383 insertions(+), 7 deletions(-)

New commits:
commit 10b49dfb3996f99dec8dd0d2ffae2aef4022f395
Author: Miklos Vajna 
Date:   Mon Sep 18 18:28:57 2017 +0200

EPUB export: write styles inline to please poor readers

And add a filter option to disable the new behavior, if wanted.

Change-Id: Ib70f60fc38d02c959452882bf593cd498b642fba
Reviewed-on: https://gerrit.libreoffice.org/42433
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins 

diff --git a/external/libepubgen/libepubgen-epub3.patch.1 
b/external/libepubgen/libepubgen-epub3.patch.1
index 0146310f46d0..d1d1af2333f6 100644
--- a/external/libepubgen/libepubgen-epub3.patch.1
+++ b/external/libepubgen/libepubgen-epub3.patch.1
@@ -2055,3 +2055,331 @@ index 1bd1e16..07aa50d 100644
 -- 
 2.12.3
 
+From d8ee84ff50a6113f49105a70f946b23acfa2566f Mon Sep 17 00:00:00 2001
+From: Miklos Vajna 
+Date: Mon, 18 Sep 2017 17:49:13 +0200
+Subject: [PATCH] [ABI CHANGE] optionally support not writing formatting to CSS
+ files
+
+This should help a number of poor readers, which don't support the old
+method. Examples:
+
+- Sigil
+- Readium
+- Moon+ reader
+- Calibre
+- MS Edge
+---
+ inc/libepubgen/EPUBTextGenerator.h|  1 +
+ inc/libepubgen/libepubgen-decls.h |  8 
+ src/lib/EPUBGenerator.cpp |  8 +++-
+ src/lib/EPUBGenerator.h   |  3 +++
+ src/lib/EPUBHTMLGenerator.cpp | 29 -
+ src/lib/EPUBHTMLGenerator.h   |  2 +-
+ src/lib/EPUBHTMLManager.cpp   |  4 ++--
+ src/lib/EPUBHTMLManager.h |  2 +-
+ src/lib/EPUBParagraphStyleManager.cpp | 11 +++
+ src/lib/EPUBParagraphStyleManager.h   |  2 ++
+ src/lib/EPUBSpanStyleManager.cpp  | 11 +++
+ src/lib/EPUBSpanStyleManager.h|  2 ++
+ src/lib/EPUBTextGenerator.cpp |  5 +
+ src/test/EPUBTextGeneratorTest.cpp| 26 ++
+ 14 files changed, 104 insertions(+), 10 deletions(-)
+
+diff --git a/inc/libepubgen/EPUBTextGenerator.h 
b/inc/libepubgen/EPUBTextGenerator.h
+index 664f673..cb2d9a6 100644
+--- a/inc/libepubgen/EPUBTextGenerator.h
 b/inc/libepubgen/EPUBTextGenerator.h
+@@ -42,6 +42,7 @@ public:
+ 
+   void setSplitHeadingLevel(unsigned level);
+   void setSplitSize(unsigned size);
++  void setStylesMethod(EPUBStylesMethod styles);
+ 
+   /** Register a handler for embedded images.
+ *
+diff --git a/inc/libepubgen/libepubgen-decls.h 
b/inc/libepubgen/libepubgen-decls.h
+index 3fb0220..2657a2d 100644
+--- a/inc/libepubgen/libepubgen-decls.h
 b/inc/libepubgen/libepubgen-decls.h
+@@ -61,6 +61,14 @@ typedef bool (*EPUBEmbeddedImage)(const 
librevenge::RVNGBinaryData , libre
+   */
+ typedef bool (*EPUBEmbeddedObject)(const librevenge::RVNGBinaryData , 
const EPUBEmbeddingContact );
+ 
++/** The possible ways to represent styles in CSS/HTML files.
++  */
++enum EPUBStylesMethod
++{
++  EPUB_STYLES_METHOD_CSS, //< The styles will be described in a seprarate CSS 
file.
++  EPUB_STYLES_METHOD_INLINE, //< The styles will be described inline.
++};
++
+ }
+ 
+ #endif // INCLUDED_LIBEPUBGEN_LIBEPUBGEN_DECLS_H
+diff --git a/src/lib/EPUBGenerator.cpp b/src/lib/EPUBGenerator.cpp
+index 3340643..75c3076 100644
+--- a/src/lib/EPUBGenerator.cpp
 b/src/lib/EPUBGenerator.cpp
+@@ -45,6 +45,7 @@ EPUBGenerator::EPUBGenerator(EPUBPackage *const package, 
const EPUBSplitMethod s
+   , m_currentHtml()
+   , m_splitGuard(split)
+   , m_version(version)
++  , m_stylesMethod(EPUB_STYLES_METHOD_CSS)
+ {
+ }
+ 
+@@ -96,7 +97,7 @@ void EPUBGenerator::startNewHtmlFile()
+ 
+   m_splitGuard.onSplit();
+ 
+-  m_currentHtml = m_htmlManager.create(m_imageManager, m_listStyleManager, 
m_paragraphStyleManager, m_spanStyleManager, m_tableStyleManager, 
m_stylesheetPath);
++  m_currentHtml = m_htmlManager.create(m_imageManager, m_listStyleManager, 
m_paragraphStyleManager, m_spanStyleManager, m_tableStyleManager, 
m_stylesheetPath, m_stylesMethod);
+ 
+   // restore state in the new file
+   m_currentHtml->startDocument(m_documentProps);
+@@ -130,6 +131,11 @@ int EPUBGenerator::getVersion() const
+   return m_version;
+ }
+ 
++void EPUBGenerator::setStylesMethod(EPUBStylesMethod styles)
++{
++  m_stylesMethod = styles;
++}
++
+ void EPUBGenerator::writeContainer()
+ {
+   EPUBXMLSink sink;
+diff --git a/src/lib/EPUBGenerator.h b/src/lib/EPUBGenerator.h
+index f98c80f..099eb4a 100644
+--- a/src/lib/EPUBGenerator.h
 b/src/lib/EPUBGenerator.h
+@@ -51,6 +51,8 @@ public:
+   EPUBSplitGuard ();
+   int getVersion() const;
+ 
++  void setStylesMethod(EPUBStylesMethod stylesMethod);
++
+ private:
+   

[Libreoffice-commits] core.git: external/libepubgen

2017-09-11 Thread Miklos Vajna
 external/libepubgen/libepubgen-epub3.patch.1 |   61 +++
 1 file changed, 61 insertions(+)

New commits:
commit ebf34ec31fb441d6226075a51f5f83ebf4668082
Author: Miklos Vajna 
Date:   Mon Sep 11 12:32:22 2017 +0200

EPUB export: ignore line though type/style 'none'

In CSS this is a boolean property, but in ODF it's an enum, so map none
to false and everything else to true.

Change-Id: Id28d0a33121c9c1fd5a1ae6bf68280a9c4cffc03
Reviewed-on: https://gerrit.libreoffice.org/42159
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins 

diff --git a/external/libepubgen/libepubgen-epub3.patch.1 
b/external/libepubgen/libepubgen-epub3.patch.1
index 0fdf0c72f070..0146310f46d0 100644
--- a/external/libepubgen/libepubgen-epub3.patch.1
+++ b/external/libepubgen/libepubgen-epub3.patch.1
@@ -1994,3 +1994,64 @@ index 0f7f1e0..1bd1e16 100644
 -- 
 2.12.3
 
+From 7be89d1881e175182039ca93a1546d79933cab85 Mon Sep 17 00:00:00 2001
+From: Miklos Vajna 
+Date: Mon, 11 Sep 2017 11:03:03 +0200
+Subject: [PATCH] EPUBSpanStyleManager: ignore line though type/style 'none'
+
+In CSS this is a boolean property, but in ODF it's an enum, so map none
+to false and everything else to true.
+---
+ src/lib/EPUBSpanStyleManager.cpp   | 11 +++-
+ src/lib/EPUBTextGenerator.cpp  |  4 +--
+ src/test/EPUBTextGeneratorTest.cpp | 58 --
+ 3 files changed, 68 insertions(+), 5 deletions(-)
+
+diff --git a/src/lib/EPUBSpanStyleManager.cpp 
b/src/lib/EPUBSpanStyleManager.cpp
+index 4887858..211946c 100644
+--- a/src/lib/EPUBSpanStyleManager.cpp
 b/src/lib/EPUBSpanStyleManager.cpp
+@@ -137,8 +137,17 @@ void 
EPUBSpanStyleManager::extractDecorations(RVNGPropertyList const , EPU
+   // replaceme by text-decoration-line when its implementation will appear in 
browser
+   std::stringstream s;
+ 
+-  if (pList["style:text-line-through-style"] || 
pList["style:text-line-through-type"])
++  // line-though style or type 'none' is not line-though, everything else is.
++  const librevenge::RVNGProperty *textLineThoughStyle = 
pList["style:text-line-through-style"];
++  bool lineThough = textLineThoughStyle && textLineThoughStyle->getStr() != 
"none";
++  if (!lineThough)
++  {
++const librevenge::RVNGProperty *textLineThoughType = 
pList["style:text-line-through-type"];
++lineThough = textLineThoughType && textLineThoughType->getStr() != "none";
++  }
++  if (lineThough)
+ s << " line-through";
++
+   if (pList["style:text-overline-style"] || pList["style:text-overline-type"])
+ s << " overline";
+   if (pList["style:text-underline-style"] || 
pList["style:text-underline-type"])
+diff --git a/src/lib/EPUBTextGenerator.cpp b/src/lib/EPUBTextGenerator.cpp
+index 1bd1e16..07aa50d 100644
+--- a/src/lib/EPUBTextGenerator.cpp
 b/src/lib/EPUBTextGenerator.cpp
+@@ -596,7 +596,7 @@ void EPUBTextGenerator::closeFrame()
+ }
+ 
+ /// Checks if the media type is an EPUB 3 Core Media Type or not.
+-static bool isValidMimeType(const RVNGString& mediaType)
++static bool isValidMimeType(const RVNGString )
+ {
+   // Defined at .
+   static char const *(types[])=
+@@ -607,7 +607,7 @@ static bool isValidMimeType(const RVNGString& mediaType)
+ "image/svg+xml"
+   };
+ 
+-  for (const auto& i : types)
++  for (const auto  : types)
+   {
+ if (mediaType == i)
+   return true;
+-- 
+2.12.3
+
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: external/libepubgen

2017-09-08 Thread Miklos Vajna
 external/libepubgen/libepubgen-epub3.patch.1 |   59 +++
 1 file changed, 59 insertions(+)

New commits:
commit 44786fad67cf48f6091e868cf0476e754650d385
Author: Miklos Vajna 
Date:   Fri Sep 8 17:57:23 2017 +0200

EPUB export: avoid writing image/x-vclgraphic to the output file

The spec has a fixed list of allowed MIME types.

Change-Id: I99a3121e41a2f6a3d0c5a040d66302161b16b0fb
Reviewed-on: https://gerrit.libreoffice.org/42116
Tested-by: Jenkins 
Reviewed-by: Miklos Vajna 

diff --git a/external/libepubgen/libepubgen-epub3.patch.1 
b/external/libepubgen/libepubgen-epub3.patch.1
index 8e62660ea566..0fdf0c72f070 100644
--- a/external/libepubgen/libepubgen-epub3.patch.1
+++ b/external/libepubgen/libepubgen-epub3.patch.1
@@ -1935,3 +1935,62 @@ index aa09332..ed968bf 100644
 -- 
 2.12.3
 
+From 7cf3c6541a61f9d74cd51fb2a01344df783cb26d Mon Sep 17 00:00:00 2001
+From: Miklos Vajna 
+Date: Fri, 8 Sep 2017 16:25:36 +0200
+Subject: [PATCH] EPUBTextGenerator: ignore invalid media types
+
+This assumes there is no image type that is valid in EPUB2, but not in
+EPUB3.
+---
+ src/lib/EPUBTextGenerator.cpp  | 26 +-
+ src/test/EPUBTextGeneratorTest.cpp | 23 +++
+ 2 files changed, 48 insertions(+), 1 deletion(-)
+
+diff --git a/src/lib/EPUBTextGenerator.cpp b/src/lib/EPUBTextGenerator.cpp
+index 0f7f1e0..1bd1e16 100644
+--- a/src/lib/EPUBTextGenerator.cpp
 b/src/lib/EPUBTextGenerator.cpp
+@@ -595,6 +595,27 @@ void EPUBTextGenerator::closeFrame()
+   m_impl->getHtml()->closeFrame();
+ }
+ 
++/// Checks if the media type is an EPUB 3 Core Media Type or not.
++static bool isValidMimeType(const RVNGString& mediaType)
++{
++  // Defined at .
++  static char const *(types[])=
++  {
++"image/gif",
++"image/png",
++"image/jpeg",
++"image/svg+xml"
++  };
++
++  for (const auto& i : types)
++  {
++if (mediaType == i)
++  return true;
++  }
++
++  return false;
++}
++
+ void EPUBTextGenerator::insertBinaryObject(const librevenge::RVNGPropertyList 
)
+ {
+   if (m_impl->getSplitGuard().splitOnSize())
+@@ -607,7 +628,10 @@ void EPUBTextGenerator::insertBinaryObject(const 
librevenge::RVNGPropertyList 
+   for (RVNGPropertyList::Iter iter(propList); !iter.last(); iter.next())
+   {
+ if (RVNGString("librevenge:mime-type") == iter.key())
+-  mimetype.reset(iter()->clone());
++{
++  if (isValidMimeType(iter()->getStr()))
++mimetype.reset(iter()->clone());
++}
+ else if (RVNGString("office:binary-data") == iter.key())
+   data.reset(iter()->clone());
+ else
+-- 
+2.12.3
+
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2017-09-08 Thread Miklos Vajna
 external/libepubgen/libepubgen-epub3.patch.1 |   29 +
 writerperfect/qa/unit/EPUBExportTest.cxx |   15 
 writerperfect/qa/unit/data/writer/epubexport/escape.fodt |   16 +
 writerperfect/source/writer/exp/txtparai.cxx |   46 +++
 4 files changed, 106 insertions(+)

New commits:
commit a27eb931c22313d4dd5c73b35358c0532d20b79e
Author: Miklos Vajna 
Date:   Fri Sep 8 12:02:51 2017 +0200

EPUB export: fix double escaped NBSP

The EPUB package interface already XML-escapes characters, avoid a double
escape.

And once that works, handle NBSP/tabs.

Change-Id: I8b7bbdc2592096bdd46fbdb29b48b723ef5cf990
Reviewed-on: https://gerrit.libreoffice.org/42098
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins 

diff --git a/external/libepubgen/libepubgen-epub3.patch.1 
b/external/libepubgen/libepubgen-epub3.patch.1
index 0415bf340e78..8e62660ea566 100644
--- a/external/libepubgen/libepubgen-epub3.patch.1
+++ b/external/libepubgen/libepubgen-epub3.patch.1
@@ -1906,3 +1906,32 @@ index 1661064..3340643 100644
 -- 
 2.12.3
 
+From bce7c05a18a4c5089d5ac77bc61b9f6978e7224b Mon Sep 17 00:00:00 2001
+From: Miklos Vajna 
+Date: Fri, 8 Sep 2017 11:21:32 +0200
+Subject: [PATCH] EPUBHTMLGenerator: write un-escaped NBSP
+
+Package implementations are supposed to take care of escaping, like it
+was already a requirement for normal text.
+---
+ src/lib/EPUBHTMLGenerator.cpp  |  3 ++-
+ src/test/EPUBTextGeneratorTest.cpp | 18 ++
+ 2 files changed, 20 insertions(+), 1 deletion(-)
+
+diff --git a/src/lib/EPUBHTMLGenerator.cpp b/src/lib/EPUBHTMLGenerator.cpp
+index aa09332..ed968bf 100644
+--- a/src/lib/EPUBHTMLGenerator.cpp
 b/src/lib/EPUBHTMLGenerator.cpp
+@@ -681,7 +681,8 @@ void EPUBHTMLGenerator::insertSpace()
+ {
+   if (m_impl->m_ignore)
+ return;
+-  m_impl->output().insertCharacters("");
++  // NBSP.
++  m_impl->output().insertCharacters("\xc2\xa0");
+ }
+ 
+ void EPUBHTMLGenerator::openOrderedListLevel(const RVNGPropertyList )
+-- 
+2.12.3
+
diff --git a/writerperfect/qa/unit/EPUBExportTest.cxx 
b/writerperfect/qa/unit/EPUBExportTest.cxx
index 0d869737fc8e..10fd5eb5a94a 100644
--- a/writerperfect/qa/unit/EPUBExportTest.cxx
+++ b/writerperfect/qa/unit/EPUBExportTest.cxx
@@ -63,6 +63,7 @@ public:
 void testNamedStyleInheritance();
 void testNestedSpan();
 void testLineBreak();
+void testEscape();
 
 CPPUNIT_TEST_SUITE(EPUBExportTest);
 CPPUNIT_TEST(testOutlineLevel);
@@ -77,6 +78,7 @@ public:
 CPPUNIT_TEST(testNamedStyleInheritance);
 CPPUNIT_TEST(testNestedSpan);
 CPPUNIT_TEST(testLineBreak);
+CPPUNIT_TEST(testEscape);
 CPPUNIT_TEST_SUITE_END();
 };
 
@@ -330,6 +332,19 @@ void EPUBExportTest::testLineBreak()
 assertXPath(mpXmlDoc, "//xhtml:p[2]/xhtml:br", 1);
 }
 
+void EPUBExportTest::testEscape()
+{
+createDoc("escape.fodt", {});
+
+mpXmlDoc = parseExport("OEBPS/sections/section0001.xhtml");
+// This was lost.
+assertXPathContent(mpXmlDoc, "//xhtml:p[1]/xhtml:span[1]", 
OUString::fromUtf8("\xc2\xa0"));
+// Make sure escaping happens only once.
+assertXPathContent(mpXmlDoc, "//xhtml:p[1]/xhtml:span[2]", "a");
+// This was also lost.
+assertXPathContent(mpXmlDoc, "//xhtml:p[1]/xhtml:span[3]", "\t");
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(EPUBExportTest);
 
 }
diff --git a/writerperfect/qa/unit/data/writer/epubexport/escape.fodt 
b/writerperfect/qa/unit/data/writer/epubexport/escape.fodt
new file mode 100644
index ..8d23fb36ef1d
--- /dev/null
+++ b/writerperfect/qa/unit/data/writer/epubexport/escape.fodt
@@ -0,0 +1,16 @@
+
+http://openoffice.org/2009/office; office:version="1.2" 
office:mimetype="application/vnd.oasis.opendocument.text">
+  
+
+  
+
+
+  
+
+  
+  
+
+  ab
+
+  
+
diff --git a/writerperfect/source/writer/exp/txtparai.cxx 
b/writerperfect/source/writer/exp/txtparai.cxx
index b085537cf106..e660a34b1e30 100644
--- a/writerperfect/source/writer/exp/txtparai.cxx
+++ b/writerperfect/source/writer/exp/txtparai.cxx
@@ -152,6 +152,48 @@ void XMLLineBreakContext::startElement(const OUString 
&/*rName*/, const css::uno
 mrImport.GetGenerator().insertLineBreak();
 }
 
+/// Handler for .
+class XMLSpaceContext : public XMLImportContext
+{
+public:
+XMLSpaceContext(XMLImport );
+
+void SAL_CALL startElement(const OUString , const 
css::uno::Reference ) override;
+};
+
+XMLSpaceContext::XMLSpaceContext(XMLImport )
+: XMLImportContext(rImport)
+{
+}
+
+void XMLSpaceContext::startElement(const OUString &/*rName*/, const 
css::uno::Reference &/*xAttribs*/)
+{
+mrImport.GetGenerator().openSpan(librevenge::RVNGPropertyList());
+mrImport.GetGenerator().insertSpace();
+mrImport.GetGenerator().closeSpan();
+}
+
+/// Handler for .
+class XMLTabContext : 

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

2017-09-04 Thread Miklos Vajna
 external/libepubgen/libepubgen-epub3.patch.1   |   44 +
 writerperfect/qa/unit/EPUBExportTest.cxx   |   13 +
 writerperfect/qa/unit/data/writer/epubexport/meta.fodt |   12 
 writerperfect/source/writer/exp/xmlmetai.cxx   |   24 +
 4 files changed, 93 insertions(+)

New commits:
commit 41092fe0bb0d2f49948bf2a1f27acb53f21a84aa
Author: Miklos Vajna 
Date:   Mon Sep 4 17:27:39 2017 +0200

EPUB export: write author metadata

 is the author and  is the "last
modified by" in ODF (it seems), so map the first to EPUB's .

Change-Id: Id701c8c38b0901ae14fbbc7b32d01b43d6d03f68
Reviewed-on: https://gerrit.libreoffice.org/41903
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins 

diff --git a/external/libepubgen/libepubgen-epub3.patch.1 
b/external/libepubgen/libepubgen-epub3.patch.1
index d1d35c102022..0415bf340e78 100644
--- a/external/libepubgen/libepubgen-epub3.patch.1
+++ b/external/libepubgen/libepubgen-epub3.patch.1
@@ -1862,3 +1862,47 @@ index 4ce2964..1661064 100644
 -- 
 2.12.3
 
+From 7e3b5186616326534b1ae95c6d2d188c5e522c7f Mon Sep 17 00:00:00 2001
+From: Miklos Vajna 
+Date: Mon, 4 Sep 2017 17:18:49 +0200
+Subject: [PATCH] EPUBGenerator: always write author and title
+
+Some EPUB3 readers categorize books by author and then title, so if
+these are empty, then it's next to impossible to reach the export result
+there.
+---
+ src/lib/EPUBGenerator.cpp  | 11 ---
+ src/test/EPUBTextGeneratorTest.cpp | 11 +++
+ 2 files changed, 19 insertions(+), 3 deletions(-)
+
+diff --git a/src/lib/EPUBGenerator.cpp b/src/lib/EPUBGenerator.cpp
+index 1661064..3340643 100644
+--- a/src/lib/EPUBGenerator.cpp
 b/src/lib/EPUBGenerator.cpp
+@@ -260,15 +260,20 @@ void EPUBGenerator::writeRoot()
+   sink.insertCharacters(identifierCharactrs.c_str());
+   sink.closeElement("dc:identifier");
+ 
+-  // Zero-width space as it must be at least one character in length after
+-  // white space has been trimmed.
+-  RVNGString title("\u200b");
++  RVNGString title("Unknown Title");
+   if (m_metadata["dc:title"] && !m_metadata["dc:title"]->getStr().empty())
+ title = m_metadata["dc:title"]->getStr();
+   sink.openElement("dc:title");
+   sink.insertCharacters(title);
+   sink.closeElement("dc:title");
+ 
++  RVNGString creator("Unknown Author");
++  if (m_metadata["meta:initial-creator"] && 
!m_metadata["meta:initial-creator"]->getStr().empty())
++creator = m_metadata["meta:initial-creator"]->getStr();
++  sink.openElement("dc:creator");
++  sink.insertCharacters(creator);
++  sink.closeElement("dc:creator");
++
+   RVNGString language("en");
+   if (m_metadata["dc:language"] && 
!m_metadata["dc:language"]->getStr().empty())
+ language = m_metadata["dc:language"]->getStr();
+-- 
+2.12.3
+
diff --git a/writerperfect/qa/unit/EPUBExportTest.cxx 
b/writerperfect/qa/unit/EPUBExportTest.cxx
index fef1cf19770c..61a6da2941f0 100644
--- a/writerperfect/qa/unit/EPUBExportTest.cxx
+++ b/writerperfect/qa/unit/EPUBExportTest.cxx
@@ -53,6 +53,7 @@ public:
 void testPageBreakSplit();
 void testSpanAutostyle();
 void testParaAutostyleCharProps();
+void testMeta();
 
 CPPUNIT_TEST_SUITE(EPUBExportTest);
 CPPUNIT_TEST(testOutlineLevel);
@@ -61,6 +62,7 @@ public:
 CPPUNIT_TEST(testPageBreakSplit);
 CPPUNIT_TEST(testSpanAutostyle);
 CPPUNIT_TEST(testParaAutostyleCharProps);
+CPPUNIT_TEST(testMeta);
 CPPUNIT_TEST_SUITE_END();
 };
 
@@ -88,6 +90,7 @@ void EPUBExportTest::tearDown()
 
 void EPUBExportTest::registerNamespaces(xmlXPathContextPtr )
 {
+xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("dc"), 
BAD_CAST("http://purl.org/dc/elements/1.1/;));
 xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("opf"), 
BAD_CAST("http://www.idpf.org/2007/opf;));
 xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("xhtml"), 
BAD_CAST("http://www.w3.org/1999/xhtml;));
 }
@@ -202,6 +205,16 @@ void EPUBExportTest::testParaAutostyleCharProps()
 assertXPath(mpXmlDoc, "//xhtml:p[2]/xhtml:span", "class", "span1");
 }
 
+void EPUBExportTest::testMeta()
+{
+createDoc("meta.fodt", {});
+
+mpXmlDoc = parseExport("OEBPS/content.opf");
+// This was "Unknown Author",  was not handled.
+assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/dc:creator", "A U 
Thor");
+assertXPathContent(mpXmlDoc, "/opf:package/opf:metadata/dc:title", 
"Title");
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(EPUBExportTest);
 
 }
diff --git a/writerperfect/qa/unit/data/writer/epubexport/meta.fodt 
b/writerperfect/qa/unit/data/writer/epubexport/meta.fodt
new file mode 100644
index ..4e46fe79fcda
--- /dev/null
+++ b/writerperfect/qa/unit/data/writer/epubexport/meta.fodt
@@ -0,0 +1,12 @@
+
+http://purl.org/dc/elements/1.1/;>
+  
+A U Thor
+Title
+  
+  
+
+  Hello world!
+
+  
+
diff --git 

[Libreoffice-commits] core.git: external/libepubgen

2017-08-29 Thread Miklos Vajna
 external/libepubgen/ExternalProject_libepubgen.mk |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 79a48682deca145eadcdd37303fa9b7d85b57d4c
Author: Miklos Vajna 
Date:   Tue Aug 29 09:07:55 2017 +0200

Pass --enable-debug also down to external/libepubgen

So one gets debug symbols if wanted.

Change-Id: I71fdf224ff1e445800c9bbf4f2289e53f57232ed
Reviewed-on: https://gerrit.libreoffice.org/41669
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins 

diff --git a/external/libepubgen/ExternalProject_libepubgen.mk 
b/external/libepubgen/ExternalProject_libepubgen.mk
index 70a16af147eb..d127f63956d1 100644
--- a/external/libepubgen/ExternalProject_libepubgen.mk
+++ b/external/libepubgen/ExternalProject_libepubgen.mk
@@ -28,7 +28,7 @@ $(call gb_ExternalProject_get_state_target,libepubgen,build) :
--enable-static \
--disable-shared \
--without-docs \
-   --disable-debug \
+   $(if $(ENABLE_DEBUG),--enable-debug,--disable-debug) \
--disable-werror \
$(if 
$(verbose),--disable-silent-rules,--enable-silent-rules) \
CXXFLAGS="$(CXXFLAGS) $(BOOST_CPPFLAGS)" \
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2017-08-29 Thread Miklos Vajna
 external/libepubgen/libepubgen-epub3.patch.1 |   59 +++
 writerperfect/qa/unit/EPUBExportTest.cxx |5 ++
 writerperfect/source/writer/exp/xmlmetai.cxx |   24 ++
 3 files changed, 88 insertions(+)

New commits:
commit 6dfb01f15ce7a7287dcb705a592ede852ccf9cab
Author: Miklos Vajna 
Date:   Mon Aug 28 18:10:59 2017 +0200

EPUB export: write generator string

Should help with debugging when it's not clear the version creating the
output had a certain fix or not.

Change-Id: Ibd1b5153d3210d30f95eba8927c55e2e812d985c
Reviewed-on: https://gerrit.libreoffice.org/41652
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins 

diff --git a/external/libepubgen/libepubgen-epub3.patch.1 
b/external/libepubgen/libepubgen-epub3.patch.1
index 52070425d7c0..d1d35c102022 100644
--- a/external/libepubgen/libepubgen-epub3.patch.1
+++ b/external/libepubgen/libepubgen-epub3.patch.1
@@ -1803,3 +1803,62 @@ index 019404f..aa09332 100644
 -- 
 2.12.3
 
+From 143a470f190aaf2f420d2f84b5f08e9b01b40473 Mon Sep 17 00:00:00 2001
+From: Miklos Vajna 
+Date: Fri, 25 Aug 2017 17:44:38 +0200
+Subject: [PATCH] Export generator
+
+---
+ src/lib/EPUBGenerator.cpp  | 28 
+ src/test/EPUBTextGeneratorTest.cpp | 17 +
+ 2 files changed, 45 insertions(+)
+
+diff --git a/src/lib/EPUBGenerator.cpp b/src/lib/EPUBGenerator.cpp
+index 4ce2964..1661064 100644
+--- a/src/lib/EPUBGenerator.cpp
 b/src/lib/EPUBGenerator.cpp
+@@ -7,6 +7,10 @@
+  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+  */
+ 
++#ifdef HAVE_CONFIG_H
++#include "config.h"
++#endif
++
+ #include 
+ #include 
+ 
+@@ -298,6 +302,30 @@ void EPUBGenerator::writeRoot()
+ sink.openElement("meta", metaAttrs);
+ sink.insertCharacters(date);
+ sink.closeElement("meta");
++
++#ifdef VERSION
++const std::string version(VERSION);
++#else
++const std::string version("unknown");
++#endif
++std::string generator;
++if (m_metadata["meta:generator"])
++  generator = m_metadata["meta:generator"]->getStr().cstr();
++
++if (generator.empty())
++  generator = "libepubgen/" + version;
++else
++{
++  generator += " (";
++  generator += "libepubgen/" + version;
++  generator += ")";
++}
++
++metaAttrs.clear();
++metaAttrs.insert("name", "generator");
++metaAttrs.insert("content", generator.c_str());
++sink.openElement("meta", metaAttrs);
++sink.closeElement("meta");
+   }
+ 
+   sink.closeElement("metadata");
+-- 
+2.12.3
+
diff --git a/writerperfect/qa/unit/EPUBExportTest.cxx 
b/writerperfect/qa/unit/EPUBExportTest.cxx
index f6e0d756fd25..cf602956c631 100644
--- a/writerperfect/qa/unit/EPUBExportTest.cxx
+++ b/writerperfect/qa/unit/EPUBExportTest.cxx
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -138,6 +139,10 @@ void EPUBExportTest::testMimetype()
 mpXmlDoc = parseExport("OEBPS/content.opf");
 // Default is EPUB3.
 assertXPath(mpXmlDoc, "/opf:package", "version", "3.0");
+
+// This was just "libepubgen/x.y.z", i.e. the LO version was missing.
+OUString aGenerator = getXPath(mpXmlDoc, 
"/opf:package/opf:metadata/opf:meta[@name='generator']", "content");
+
CPPUNIT_ASSERT(aGenerator.startsWith(utl::DocInfoHelper::GetGeneratorString()));
 }
 
 void EPUBExportTest::testEPUB2()
diff --git a/writerperfect/source/writer/exp/xmlmetai.cxx 
b/writerperfect/source/writer/exp/xmlmetai.cxx
index cc8b37f43a0a..6c01adeb8f11 100644
--- a/writerperfect/source/writer/exp/xmlmetai.cxx
+++ b/writerperfect/source/writer/exp/xmlmetai.cxx
@@ -84,6 +84,28 @@ void XMLDcDateContext::characters(const OUString )
 mrMeta.m_aPropertyList.insert("dc:date", 
librevenge::RVNGString(sCharU8.getStr()));
 }
 
+/// Handler for .
+class XMLMetaGeneratorContext : public XMLImportContext
+{
+public:
+XMLMetaGeneratorContext(XMLImport , XMLMetaDocumentContext );
+
+void SAL_CALL characters(const OUString ) override;
+
+XMLMetaDocumentContext 
+};
+
+XMLMetaGeneratorContext::XMLMetaGeneratorContext(XMLImport , 
XMLMetaDocumentContext )
+: XMLImportContext(rImport), mrMeta(rMeta)
+{
+}
+
+void XMLMetaGeneratorContext::characters(const OUString )
+{
+OString sCharU8 = OUStringToOString(rChars, RTL_TEXTENCODING_UTF8);
+mrMeta.m_aPropertyList.insert("meta:generator", 
librevenge::RVNGString(sCharU8.getStr()));
+}
+
 XMLMetaDocumentContext::XMLMetaDocumentContext(XMLImport )
 : XMLImportContext(rImport)
 {
@@ -97,6 +119,8 @@ XMLImportContext 
*XMLMetaDocumentContext::CreateChildContext(const OUString 
 return new XMLDcLanguageContext(mrImport, *this);
 if (rName == "dc:date")
 return new XMLDcDateContext(mrImport, *this);
+if (rName == "meta:generator")
+return new XMLMetaGeneratorContext(mrImport, *this);
 

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

2017-08-25 Thread Miklos Vajna
 external/libepubgen/libepubgen-epub3.patch.1|   77 
 writerperfect/qa/unit/EPUBExportTest.cxx|   36 ++-
 writerperfect/qa/unit/data/writer/epubexport/hello.fodt |8 +
 writerperfect/source/writer/EPUBPackage.cxx |5 +
 4 files changed, 120 insertions(+), 6 deletions(-)

New commits:
commit 8d411f38badc7adc61fdfc5c08fdbda247bce37a
Author: Miklos Vajna 
Date:   Thu Aug 24 18:08:11 2017 +0200

EPUB export: make sure that the mimetype stream is not compressed

Similar to ODF, the spec mandates this, and recent enough epubcheck
validator asserts this.

Also backport 2 libepubgen commits that fix other validator errors
around missing mimetypes / malformed URLs.

Change-Id: I29f0524465a30d26585cea92ec27bd336f6a17d8
Reviewed-on: https://gerrit.libreoffice.org/41526
Tested-by: Jenkins 
Reviewed-by: Miklos Vajna 

diff --git a/external/libepubgen/libepubgen-epub3.patch.1 
b/external/libepubgen/libepubgen-epub3.patch.1
index 14675692846c..52070425d7c0 100644
--- a/external/libepubgen/libepubgen-epub3.patch.1
+++ b/external/libepubgen/libepubgen-epub3.patch.1
@@ -1726,3 +1726,80 @@ index 40c507e..019404f 100644
 -- 
 2.12.3
 
+From 89ae3e392890b9360d271f1c1796cb27e36be26f Mon Sep 17 00:00:00 2001
+From: Miklos Vajna 
+Date: Thu, 24 Aug 2017 17:11:17 +0200
+Subject: [PATCH] EPUBTextGenerator: empty mime type is the same as no mime
+ type
+
+epubcheck says:
+
+   ERROR(RSC-005): image.epub/OEBPS/content.opf(11,69): Error while 
parsing file: value of attribute "media-type" is invalid; must be a string 
matching the regular expression 
"[a-zA-Z0-9!#$&+\-\^_]+/[a-zA-Z0-9!#$&+\-\^_]+.*"
+---
+ src/lib/EPUBTextGenerator.cpp  |  2 +-
+ src/test/EPUBTextGeneratorTest.cpp | 24 
+ 2 files changed, 25 insertions(+), 1 deletion(-)
+
+diff --git a/src/lib/EPUBTextGenerator.cpp b/src/lib/EPUBTextGenerator.cpp
+index a39f266..0f7f1e0 100644
+--- a/src/lib/EPUBTextGenerator.cpp
 b/src/lib/EPUBTextGenerator.cpp
+@@ -614,7 +614,7 @@ void EPUBTextGenerator::insertBinaryObject(const 
librevenge::RVNGPropertyList 
+   newPropList.insert(iter.key(), iter()->clone());
+   }
+ 
+-  if (!mimetype || !data)
++  if (!mimetype || mimetype->getStr().empty() || !data)
+   {
+ EPUBGEN_DEBUG_MSG(("invalid binary object dropped"));
+ return;
+-- 
+2.12.3
+
+From 28e5e30c20aba54dff6505df4c03d6a3da0ee0f3 Mon Sep 17 00:00:00 2001
+From: Miklos Vajna 
+Date: Thu, 24 Aug 2017 17:41:49 +0200
+Subject: [PATCH] EPUBHTMLGenerator: sanitize URLs a bit in openLink()
+
+epubcheck warns on this:
+
+   WARNING(RSC-023): large.epub/OEBPS/sections/section0018.xhtml(2,5171): 
The URL 'https:///www.fsf.org' is missing 1 slash(es) '/' after the protocol 
'https:'
+---
+ configure.ac   |  1 +
+ src/lib/EPUBHTMLGenerator.cpp  | 12 +++-
+ src/test/EPUBTextGeneratorTest.cpp | 40 ++
+ 3 files changed, 52 insertions(+), 1 deletion(-)
+
+diff --git a/src/lib/EPUBHTMLGenerator.cpp b/src/lib/EPUBHTMLGenerator.cpp
+index 019404f..aa09332 100644
+--- a/src/lib/EPUBHTMLGenerator.cpp
 b/src/lib/EPUBHTMLGenerator.cpp
+@@ -12,6 +12,8 @@
+ #include 
+ #include 
+ 
++#include 
++
+ #include "EPUBHTMLGenerator.h"
+ #include "EPUBImageManager.h"
+ #include "EPUBListStyleManager.h"
+@@ -625,7 +627,15 @@ void EPUBHTMLGenerator::openLink(const RVNGPropertyList 
)
+   }
+   RVNGPropertyList attrs;
+   if (propList["xlink:href"])
+-attrs.insert("href", propList["xlink:href"]->getStr().cstr());
++  {
++std::string href(propList["xlink:href"]->getStr().cstr());
++
++// Basic URL sanitization.
++boost::replace_all(href, "http:///;, "http://;);
++boost::replace_all(href, "https:///;, "https://;);
++
++attrs.insert("href", href.c_str());
++  }
+   m_impl->output(false).openElement("a", attrs);
+ }
+ 
+-- 
+2.12.3
+
diff --git a/writerperfect/qa/unit/EPUBExportTest.cxx 
b/writerperfect/qa/unit/EPUBExportTest.cxx
index ef65012daca9..ab1ca51c855b 100644
--- a/writerperfect/qa/unit/EPUBExportTest.cxx
+++ b/writerperfect/qa/unit/EPUBExportTest.cxx
@@ -30,14 +30,18 @@ class EPUBExportTest : public test::BootstrapFixture, 
public unotest::MacrosTest
 {
 uno::Reference mxComponentContext;
 uno::Reference mxComponent;
+utl::TempFile maTempFile;
 
 public:
 virtual void setUp() override;
 virtual void tearDown() override;
+void createDoc(const OUString );
 void testOutlineLevel();
+void testMimetype();
 
 CPPUNIT_TEST_SUITE(EPUBExportTest);
 CPPUNIT_TEST(testOutlineLevel);
+CPPUNIT_TEST(testMimetype);
 CPPUNIT_TEST_SUITE_END();
 };
 
@@ -57,28 +61,48 @@ void EPUBExportTest::tearDown()
 test::BootstrapFixture::tearDown();
 }
 
-void EPUBExportTest::testOutlineLevel()
+void 

[Libreoffice-commits] core.git: external/libepubgen

2017-08-22 Thread Miklos Vajna
 external/libepubgen/libepubgen-epub3.patch.1 |   92 +++
 1 file changed, 92 insertions(+)

New commits:
commit 15253417276d3239a57b37dfa608f5b8eab9912a
Author: Miklos Vajna 
Date:   Tue Aug 22 16:47:45 2017 +0200

EPUB export: fix validation error around as-char images

Matching testcase is in libepubgen.git only.

Change-Id: Iee00264894099ccafb7b2d7d3252e2c7cc48ab11
Reviewed-on: https://gerrit.libreoffice.org/41427
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins 

diff --git a/external/libepubgen/libepubgen-epub3.patch.1 
b/external/libepubgen/libepubgen-epub3.patch.1
index b7e5364f9073..14675692846c 100644
--- a/external/libepubgen/libepubgen-epub3.patch.1
+++ b/external/libepubgen/libepubgen-epub3.patch.1
@@ -1634,3 +1634,95 @@ index 5206b37..a39f266 100644
 -- 
 2.12.3
 
+From 1376b91046ad50f3a443b6fd4887252c1922870c Mon Sep 17 00:00:00 2001
+From: Miklos Vajna 
+Date: Tue, 22 Aug 2017 16:23:55 +0200
+Subject: [PATCH] EPUBHTMLGenerator: fix validation problem with non-page
+ anchored images
+
+In most cases (except for at-page anchored images) there is a paragraph
+already opened, and writing  inside  results in a validation
+error.
+
+So just write  in case we're not in paragraph already.
+---
+ src/lib/EPUBHTMLGenerator.cpp | 35 +--
+ 1 file changed, 29 insertions(+), 6 deletions(-)
+
+diff --git a/src/lib/EPUBHTMLGenerator.cpp b/src/lib/EPUBHTMLGenerator.cpp
+index 40c507e..019404f 100644
+--- a/src/lib/EPUBHTMLGenerator.cpp
 b/src/lib/EPUBHTMLGenerator.cpp
+@@ -360,6 +360,7 @@ struct EPUBHTMLGeneratorImpl
+ , m_stylesheetPath(stylesheetPath)
+ , m_actualPage(0)
+ , m_ignore(false)
++, m_frameAnchorTypes()
+ , m_actualSink()
+ , m_sinkStack()
+   {
+@@ -446,6 +447,8 @@ struct EPUBHTMLGeneratorImpl
+   int m_actualPage;
+   bool m_ignore;
+ 
++  std::stack m_frameAnchorTypes;
++
+ protected:
+   std::unique_ptr m_actualSink;
+   std::stack m_sinkStack;
+@@ -846,8 +849,32 @@ void EPUBHTMLGenerator::closeTable()
+   m_impl->m_tableManager.closeTable();
+ }
+ 
+-void EPUBHTMLGenerator::openFrame(const RVNGPropertyList & /* propList */) {}
+-void EPUBHTMLGenerator::closeFrame() {}
++void EPUBHTMLGenerator::openFrame(const RVNGPropertyList )
++{
++  librevenge::RVNGPropertyList::Iter i(propList);
++  std::string anchorType;
++  for (i.rewind(); i.next();)
++  {
++if (std::string("text:anchor-type") == i.key())
++  anchorType = i()->getStr().cstr();
++  }
++
++  if (anchorType == "page")
++// Other anchor types are already inside a paragraph.
++m_impl->output().openElement("p", RVNGPropertyList());
++  m_impl->m_frameAnchorTypes.push(anchorType);
++}
++
++void EPUBHTMLGenerator::closeFrame()
++{
++  if (m_impl->m_frameAnchorTypes.empty())
++return;
++
++  if (m_impl->m_frameAnchorTypes.top() == "page")
++m_impl->output().closeElement("p");
++
++  m_impl->m_frameAnchorTypes.pop();
++}
+ 
+ void EPUBHTMLGenerator::openGroup(const librevenge::RVNGPropertyList & /* 
propList */) {}
+ void EPUBHTMLGenerator::closeGroup() {}
+@@ -862,8 +889,6 @@ void EPUBHTMLGenerator::drawConnector(const 
librevenge::RVNGPropertyList & /* pr
+ 
+ void EPUBHTMLGenerator::insertBinaryObject(const RVNGPropertyList )
+ {
+-  m_impl->output().openElement("p", RVNGPropertyList());
+-
+   const EPUBPath  = m_impl->m_imageManager.insert(
+
RVNGBinaryData(propList["office:binary-data"]->getStr()),
+propList["librevenge:mime-type"]->getStr());
+@@ -873,8 +898,6 @@ void EPUBHTMLGenerator::insertBinaryObject(const 
RVNGPropertyList )
+   // FIXME: use alternative repr. if available
+   attrs.insert("alt", path.str().c_str());
+   m_impl->output().insertEmptyElement("img", attrs);
+-
+-  m_impl->output().closeElement("p");
+ }
+ 
+ void EPUBHTMLGenerator::insertEquation(const RVNGPropertyList & /* propList 
*/) {}
+-- 
+2.12.3
+
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: external/libepubgen

2017-08-22 Thread Miklos Vajna
 external/libepubgen/libepubgen-epub3.patch.1 |  106 +++
 1 file changed, 106 insertions(+)

New commits:
commit ebd0f06d87d7db3015a29c4f6f895db6ac998c38
Author: Miklos Vajna 
Date:   Tue Aug 22 13:40:56 2017 +0200

EPUB export: fix unexpected first chapter name

Matching testcase is in libepubgen.git only.

Change-Id: I7a6ce6a8f7deaa26a2b31ca024ff98a02a8a85f7
Reviewed-on: https://gerrit.libreoffice.org/41421
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins 

diff --git a/external/libepubgen/libepubgen-epub3.patch.1 
b/external/libepubgen/libepubgen-epub3.patch.1
index 2962ca9b355a..b7e5364f9073 100644
--- a/external/libepubgen/libepubgen-epub3.patch.1
+++ b/external/libepubgen/libepubgen-epub3.patch.1
@@ -1528,3 +1528,109 @@ index b1e33f8..5206b37 100644
 -- 
 2.12.3
 
+From a4e85e191813e7c8f4e6b5bcf2458504f9d06aeb Mon Sep 17 00:00:00 2001
+From: Miklos Vajna 
+Date: Tue, 22 Aug 2017 12:05:28 +0200
+Subject: [PATCH] EPUB_SPLIT_METHOD_HEADING: fix unexpected first chapter name
+
+If the structure of the document is like this:
+
+ Heading 2
+Heading 1
+ Heading 2
+Heading 1
+ Heading 2
+
+Then this resulted in 3 chapters: Section 1, Heading 1 and Heading 1.
+The first one is unexpected; so in case we don't have a heading 1
+paragraph for the first section, then fall back to any other heading.
+---
+ src/lib/EPUBHTMLManager.cpp   | 8 
+ src/lib/EPUBHTMLManager.h | 3 +++
+ src/lib/EPUBSplitGuard.cpp| 5 -
+ src/lib/EPUBSplitGuard.h  | 2 +-
+ src/lib/EPUBTextGenerator.cpp | 2 +-
+ 5 files changed, 17 insertions(+), 3 deletions(-)
+
+diff --git a/src/lib/EPUBHTMLManager.cpp b/src/lib/EPUBHTMLManager.cpp
+index 5141f31..7753160 100644
+--- a/src/lib/EPUBHTMLManager.cpp
 b/src/lib/EPUBHTMLManager.cpp
+@@ -134,6 +134,14 @@ void EPUBHTMLManager::insertHeadingText(const std::string 
)
+   m_paths.back().appendTitle(text);
+ }
+ 
++bool EPUBHTMLManager::hasHeadingText() const
++{
++  if (m_paths.empty())
++return false;
++
++  return !m_paths.back().getTitle().empty();
++}
++
+ }
+ 
+ /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
+diff --git a/src/lib/EPUBHTMLManager.h b/src/lib/EPUBHTMLManager.h
+index 6b480c4..158b466 100644
+--- a/src/lib/EPUBHTMLManager.h
 b/src/lib/EPUBHTMLManager.h
+@@ -51,6 +51,9 @@ public:
+   /// Appends text to the title of the current heading.
+   void insertHeadingText(const std::string );
+ 
++  /// If the current heading has a title.
++  bool hasHeadingText() const;
++
+ private:
+   EPUBManifest _manifest;
+   std::vector m_paths;
+diff --git a/src/lib/EPUBSplitGuard.cpp b/src/lib/EPUBSplitGuard.cpp
+index 25eae87..890500b 100644
+--- a/src/lib/EPUBSplitGuard.cpp
 b/src/lib/EPUBSplitGuard.cpp
+@@ -65,11 +65,14 @@ bool EPUBSplitGuard::splitOnHeading(const unsigned level) 
const
+   return canSplit(EPUB_SPLIT_METHOD_HEADING) && (m_headingLevel >= level);
+ }
+ 
+-bool EPUBSplitGuard::inHeading() const
++bool EPUBSplitGuard::inHeading(bool any) const
+ {
+   if (!m_currentHeadingLevel)
+ return false;
+ 
++  if (any)
++return true;
++
+   return m_headingLevel >= m_currentHeadingLevel;
+ }
+ 
+diff --git a/src/lib/EPUBSplitGuard.h b/src/lib/EPUBSplitGuard.h
+index 7bc53ce..1a74079 100644
+--- a/src/lib/EPUBSplitGuard.h
 b/src/lib/EPUBSplitGuard.h
+@@ -30,7 +30,7 @@ public:
+ 
+   bool splitOnPageBreak() const;
+   bool splitOnHeading(unsigned level) const;
+-  bool inHeading() const;
++  bool inHeading(bool any) const;
+   bool splitOnSize() const;
+ 
+   void onSplit();
+diff --git a/src/lib/EPUBTextGenerator.cpp b/src/lib/EPUBTextGenerator.cpp
+index 5206b37..a39f266 100644
+--- a/src/lib/EPUBTextGenerator.cpp
 b/src/lib/EPUBTextGenerator.cpp
+@@ -367,7 +367,7 @@ void EPUBTextGenerator::insertText(const 
librevenge::RVNGString )
+   if (m_impl->m_inHeader || m_impl->m_inFooter)
+ m_impl->m_currentHeaderOrFooter->addInsertText(text);
+ 
+-  if (m_impl->getSplitGuard().inHeading())
++  if 
(m_impl->getSplitGuard().inHeading(!m_impl->getHtmlManager().hasHeadingText()))
+ m_impl->getHtmlManager().insertHeadingText(text.cstr());
+ 
+   m_impl->getSplitGuard().incrementSize(text.len());
+-- 
+2.12.3
+
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: external/libepubgen

2017-08-17 Thread Miklos Vajna
 external/libepubgen/libepubgen-epub3.patch.1 |  122 +++
 1 file changed, 122 insertions(+)

New commits:
commit 91f4d01af4772fe5156e59ea4f4ef771de657a57
Author: Miklos Vajna 
Date:   Thu Aug 17 12:07:24 2017 +0200

EPUB export: fix unexpected text in chapter names

Chapter name was a collection of all heading 1 (and contained heading 2,
heading 3, ...) texts, but just heading 1 itself is enough.

Change-Id: I893a935c4f4855ef5d19a01e2679ba7101af853f
Reviewed-on: https://gerrit.libreoffice.org/41246
Tested-by: Jenkins 
Reviewed-by: Miklos Vajna 

diff --git a/external/libepubgen/libepubgen-epub3.patch.1 
b/external/libepubgen/libepubgen-epub3.patch.1
index 32aa72d76a32..2962ca9b355a 100644
--- a/external/libepubgen/libepubgen-epub3.patch.1
+++ b/external/libepubgen/libepubgen-epub3.patch.1
@@ -1406,3 +1406,125 @@ index aba8827..b1e33f8 100644
 -- 
 2.12.3
 
+From 8a3cc9733f567864ad0658cf1a25c60d5e7205a6 Mon Sep 17 00:00:00 2001
+From: Miklos Vajna 
+Date: Thu, 17 Aug 2017 12:01:44 +0200
+Subject: [PATCH] EPUB_SPLIT_METHOD_HEADING: fix unexpected text in chapter
+ names
+
+We used to add text for all headings for the chapter name, but if we
+split on heading 1, then text of heading2+ should not be included.
+---
+ src/lib/EPUBSplitGuard.cpp| 14 ++
+ src/lib/EPUBSplitGuard.h  |  3 +++
+ src/lib/EPUBTextGenerator.cpp |  6 ++
+ 3 files changed, 19 insertions(+), 4 deletions(-)
+
+diff --git a/src/lib/EPUBSplitGuard.cpp b/src/lib/EPUBSplitGuard.cpp
+index 15ba20f..25eae87 100644
+--- a/src/lib/EPUBSplitGuard.cpp
 b/src/lib/EPUBSplitGuard.cpp
+@@ -18,6 +18,7 @@ static const unsigned DEFAULT_SPLIT_SIZE = 1 << 16;
+ EPUBSplitGuard::EPUBSplitGuard(const EPUBSplitMethod method)
+   : m_method(method)
+   , m_headingLevel(DEFAULT_SPLIT_HEADING_LEVEL)
++  , m_currentHeadingLevel(0)
+   , m_size(DEFAULT_SPLIT_SIZE)
+   , m_currentSize(0)
+   , m_nestingLevel(0)
+@@ -29,6 +30,11 @@ void EPUBSplitGuard::setSplitHeadingLevel(const unsigned 
level)
+   m_headingLevel = level;
+ }
+ 
++void EPUBSplitGuard::setCurrentHeadingLevel(const unsigned level)
++{
++  m_currentHeadingLevel = level;
++}
++
+ void EPUBSplitGuard::setSplitSize(const unsigned size)
+ {
+   m_size = size;
+@@ -59,6 +65,14 @@ bool EPUBSplitGuard::splitOnHeading(const unsigned level) 
const
+   return canSplit(EPUB_SPLIT_METHOD_HEADING) && (m_headingLevel >= level);
+ }
+ 
++bool EPUBSplitGuard::inHeading() const
++{
++  if (!m_currentHeadingLevel)
++return false;
++
++  return m_headingLevel >= m_currentHeadingLevel;
++}
++
+ bool EPUBSplitGuard::splitOnSize() const
+ {
+   return canSplit(EPUB_SPLIT_METHOD_SIZE) && (m_size <= m_currentSize);
+diff --git a/src/lib/EPUBSplitGuard.h b/src/lib/EPUBSplitGuard.h
+index 17613ac..7bc53ce 100644
+--- a/src/lib/EPUBSplitGuard.h
 b/src/lib/EPUBSplitGuard.h
+@@ -21,6 +21,7 @@ public:
+   explicit EPUBSplitGuard(EPUBSplitMethod method);
+ 
+   void setSplitHeadingLevel(unsigned level);
++  void setCurrentHeadingLevel(unsigned level);
+   void setSplitSize(unsigned size);
+ 
+   void openLevel();
+@@ -29,6 +30,7 @@ public:
+ 
+   bool splitOnPageBreak() const;
+   bool splitOnHeading(unsigned level) const;
++  bool inHeading() const;
+   bool splitOnSize() const;
+ 
+   void onSplit();
+@@ -39,6 +41,7 @@ private:
+ private:
+   const EPUBSplitMethod m_method;
+   unsigned m_headingLevel;
++  unsigned m_currentHeadingLevel;
+   unsigned m_size;
+   unsigned m_currentSize;
+   unsigned m_nestingLevel;
+diff --git a/src/lib/EPUBTextGenerator.cpp b/src/lib/EPUBTextGenerator.cpp
+index b1e33f8..5206b37 100644
+--- a/src/lib/EPUBTextGenerator.cpp
 b/src/lib/EPUBTextGenerator.cpp
+@@ -67,7 +67,6 @@ public:
+   bool m_inPageSpan;
+   bool m_inHeader;
+   bool m_inFooter;
+-  bool m_inHeading;
+ 
+   RVNGPropertyList m_pageSpanProps;
+   shared_ptr m_currentHeader;
+@@ -89,7 +88,6 @@ EPUBTextGenerator::Impl::Impl(EPUBPackage *const package, 
const EPUBSplitMethod
+   , m_inPageSpan(false)
+   , m_inHeader(false)
+   , m_inFooter(false)
+-  , m_inHeading(false)
+   , m_pageSpanProps()
+   , m_currentHeader()
+   , m_currentFooter()
+@@ -262,7 +260,7 @@ void EPUBTextGenerator::openParagraph(const 
librevenge::RVNGPropertyList 
+   const RVNGProperty *const outlineLevel = propList["text:outline-level"];
+   if (outlineLevel && 
m_impl->getSplitGuard().splitOnHeading(outlineLevel->getInt()))
+ m_impl->startNewHtmlFile();
+-  m_impl->m_inHeading = outlineLevel != nullptr;
++  m_impl->getSplitGuard().setCurrentHeadingLevel(outlineLevel ? 
outlineLevel->getInt() : 0);
+ 
+   m_impl->getSplitGuard().openLevel();
+ 
+@@ -369,7 +367,7 @@ void EPUBTextGenerator::insertText(const 
librevenge::RVNGString )
+   if (m_impl->m_inHeader || m_impl->m_inFooter)
+ m_impl->m_currentHeaderOrFooter->addInsertText(text);
+ 
+-  if 

[Libreoffice-commits] core.git: external/libepubgen

2017-08-17 Thread Miklos Vajna
 external/libepubgen/libepubgen-epub3.patch.1 |  214 +++
 1 file changed, 214 insertions(+)

New commits:
commit ec4034c4a4f23574401ba2a74b635d9ed4befbc8
Author: Miklos Vajna 
Date:   Thu Aug 17 10:15:34 2017 +0200

EPUB export: use real chapter names

Instead of "Seciton N" placeholders, by backporting the relevant
libepubgen commit.

Change-Id: I7073658597205927eeefc4e63ec23bd95cf4f30c
Reviewed-on: https://gerrit.libreoffice.org/41241
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins 

diff --git a/external/libepubgen/libepubgen-epub3.patch.1 
b/external/libepubgen/libepubgen-epub3.patch.1
index 0da826609e23..32aa72d76a32 100644
--- a/external/libepubgen/libepubgen-epub3.patch.1
+++ b/external/libepubgen/libepubgen-epub3.patch.1
@@ -1192,3 +1192,217 @@ index cb557b2..aba8827 100644
 -- 
 2.12.3
 
+From 576c2472e384ea1a71739b15f42561cd34de5bba Mon Sep 17 00:00:00 2001
+From: Miklos Vajna 
+Date: Wed, 16 Aug 2017 17:52:37 +0200
+Subject: [PATCH] EPUB_SPLIT_METHOD_HEADING: try to use real chapter names, not
+ Section N
+
+What users call "chapter title" is the text of a paragraph with an
+outline level set.
+
+To keep this simple just handle the text after opening such a paragraph,
+but no other paragraph is opened, i.e. assume that in:
+
+ABC
+
+only A is interesting, but not B, neither C. (Which could happen with an
+at-character anchored frame inside a heading text e.g.)
+---
+ src/lib/EPUBGenerator.cpp |  5 +
+ src/lib/EPUBGenerator.h   |  2 ++
+ src/lib/EPUBHTMLManager.cpp   | 26 --
+ src/lib/EPUBHTMLManager.h |  3 +++
+ src/lib/EPUBPath.cpp  | 11 +++
+ src/lib/EPUBPath.h|  4 
+ src/lib/EPUBTextGenerator.cpp |  6 ++
+ 7 files changed, 55 insertions(+), 2 deletions(-)
+
+diff --git a/src/lib/EPUBGenerator.cpp b/src/lib/EPUBGenerator.cpp
+index 4bffb8b..4ce2964 100644
+--- a/src/lib/EPUBGenerator.cpp
 b/src/lib/EPUBGenerator.cpp
+@@ -106,6 +106,11 @@ const EPUBHTMLGeneratorPtr_t ::getHtml() 
const
+   return m_currentHtml;
+ }
+ 
++EPUBHTMLManager ::getHtmlManager()
++{
++  return m_htmlManager;
++}
++
+ const EPUBSplitGuard ::getSplitGuard() const
+ {
+   return m_splitGuard;
+diff --git a/src/lib/EPUBGenerator.h b/src/lib/EPUBGenerator.h
+index 1a67a88..f98c80f 100644
+--- a/src/lib/EPUBGenerator.h
 b/src/lib/EPUBGenerator.h
+@@ -45,6 +45,8 @@ public:
+ 
+   const EPUBHTMLGeneratorPtr_t () const;
+ 
++  EPUBHTMLManager ();
++
+   const EPUBSplitGuard () const;
+   EPUBSplitGuard ();
+   int getVersion() const;
+diff --git a/src/lib/EPUBHTMLManager.cpp b/src/lib/EPUBHTMLManager.cpp
+index be56cc7..5141f31 100644
+--- a/src/lib/EPUBHTMLManager.cpp
 b/src/lib/EPUBHTMLManager.cpp
+@@ -18,6 +18,20 @@
+ namespace libepubgen
+ {
+ 
++namespace
++{
++
++/// Extracts a title string from a path and provides a fallback if it would 
be empty.
++void getPathTitle(std::ostringstream , const EPUBPath , 
std::vector::size_type index)
++{
++  if (path.getTitle().empty())
++label << "Section " << (index + 1);
++  else
++label << path.getTitle();
++}
++
++}
++
+ EPUBHTMLManager::EPUBHTMLManager(EPUBManifest )
+   : m_manifest(manifest)
+   , m_paths()
+@@ -78,7 +92,7 @@ void EPUBHTMLManager::writeTocTo(EPUBXMLSink , const 
EPUBPath , int
+   anchorAttrs.insert("href", 
m_paths[i].relativeTo(tocPath).str().c_str());
+   sink.openElement("a", anchorAttrs);
+   std::ostringstream label;
+-  label << "Section " << (i + 1);
++  getPathTitle(label, m_paths[i], i);
+   sink.insertCharacters(label.str().c_str());
+   sink.closeElement("a");
+   sink.closeElement("li");
+@@ -101,7 +115,7 @@ void EPUBHTMLManager::writeTocTo(EPUBXMLSink , const 
EPUBPath , int
+ sink.openElement("navLabel");
+ sink.openElement("text");
+ std::ostringstream label;
+-label << "Section " << (i + 1);
++getPathTitle(label, m_paths[i], i);
+ sink.insertCharacters(label.str().c_str());
+ sink.closeElement("text");
+ sink.closeElement("navLabel");
+@@ -112,6 +126,14 @@ void EPUBHTMLManager::writeTocTo(EPUBXMLSink , const 
EPUBPath , int
+   }
+ }
+ 
++void EPUBHTMLManager::insertHeadingText(const std::string )
++{
++  if (m_paths.empty())
++return;
++
++  m_paths.back().appendTitle(text);
++}
++
+ }
+ 
+ /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
+diff --git a/src/lib/EPUBHTMLManager.h b/src/lib/EPUBHTMLManager.h
+index 2ec7bb7..6b480c4 100644
+--- a/src/lib/EPUBHTMLManager.h
 b/src/lib/EPUBHTMLManager.h
+@@ -48,6 +48,9 @@ public:
+   void writeSpineTo(EPUBXMLSink );
+   void writeTocTo(EPUBXMLSink , const EPUBPath , int version);
+ 
++  /// Appends text to the title of the current heading.
++  void insertHeadingText(const std::string );
++
+ private:
+   EPUBManifest _manifest;
+   std::vector m_paths;
+diff --git 

[Libreoffice-commits] core.git: external/libepubgen

2017-08-11 Thread Miklos Vajna
 external/libepubgen/libepubgen-epub3.patch.1 |   78 +++
 1 file changed, 78 insertions(+)

New commits:
commit 01fa5e8e8f0204447e5fa2e7849575ea89cd9b41
Author: Miklos Vajna 
Date:   Fri Aug 11 11:26:20 2017 +0200

EPUB export: write legacy ToC as well

Tolerated in EPUB3, and some readers not yet fully supporting EPUB3
(just EPUB2) actually need it.

Change-Id: I8b52d081a939c74052f3945cc21c834c2af8bb7d

diff --git a/external/libepubgen/libepubgen-epub3.patch.1 
b/external/libepubgen/libepubgen-epub3.patch.1
index 33a5982fcbdd..a41fce29acef 100644
--- a/external/libepubgen/libepubgen-epub3.patch.1
+++ b/external/libepubgen/libepubgen-epub3.patch.1
@@ -864,3 +864,81 @@ index 7b17304..be56cc7 100644
 -- 
 2.12.3
 
+From c30bc184c18837203e9f249386711e9cd616c9f0 Mon Sep 17 00:00:00 2001
+From: Miklos Vajna 
+Date: Fri, 11 Aug 2017 10:50:47 +0200
+Subject: [PATCH] EPUB3: write the deprecated NCX navication as well
+
+
+"3.2 Navigation" says:
+
+   EPUB 3 Publications may include the EPUB 2 NCX for EPUB 2 Reading System
+   forward compatibility purposes.
+---
+ src/lib/EPUBGenerator.cpp | 18 +-
+ 1 file changed, 9 insertions(+), 9 deletions(-)
+
+diff --git a/src/lib/EPUBGenerator.cpp b/src/lib/EPUBGenerator.cpp
+index ca05ea7..8017ffe 100644
+--- a/src/lib/EPUBGenerator.cpp
 b/src/lib/EPUBGenerator.cpp
+@@ -56,8 +56,7 @@ void EPUBGenerator::startDocument(const RVNGPropertyList 
)
+ 
+   if (m_version == 30)
+ m_manifest.insert(EPUBPath("OEBPS/toc.xhtml"), "application/xhtml+xml", 
"toc.xhtml", "nav");
+-  else
+-m_manifest.insert(EPUBPath("OEBPS/toc.ncx"), "application/x-dtbncx+xml", 
"toc.ncx", "");
++  m_manifest.insert(EPUBPath("OEBPS/toc.ncx"), "application/x-dtbncx+xml", 
"toc.ncx", "");
+   m_manifest.insert(m_stylesheetPath, "text/css", "stylesheet.css", "");
+ }
+ 
+@@ -147,10 +146,10 @@ void EPUBGenerator::writeContainer()
+ 
+ void EPUBGenerator::writeNavigation()
+ {
+-  EPUBXMLSink sink;
+-
+   if (m_version == 30)
+   {
++EPUBXMLSink sink;
++
+ const EPUBPath path("OEBPS/toc.xhtml");
+ RVNGPropertyList htmlAttrs;
+ htmlAttrs.insert("xmlns", "http://www.w3.org/1999/xhtml;);
+@@ -174,10 +173,10 @@ void EPUBGenerator::writeNavigation()
+ sink.closeElement("html");
+ 
+ sink.writeTo(*m_package, path.str().c_str());
+-
+-return;
+   }
+ 
++  EPUBXMLSink sink;
++
+   const EPUBPath path("OEBPS/toc.ncx");
+   RVNGPropertyList ncxAttrs;
+   ncxAttrs.insert("xmlns", "http://www.daisy.org/z3986/2005/ncx/;);
+@@ -198,7 +197,9 @@ void EPUBGenerator::writeNavigation()
+   sink.closeElement("docTitle");
+ 
+   sink.openElement("navMap");
+-  m_htmlManager.writeTocTo(sink, path, m_version);
++  // In case of EPUB3 the (deprecated, but valid) EPUB2 markup is wanted, so
++  // the version is unconditional here.
++  m_htmlManager.writeTocTo(sink, path, /*version=*/20);
+   sink.closeElement("navMap");
+ 
+   sink.closeElement("ncx");
+@@ -284,8 +285,7 @@ void EPUBGenerator::writeRoot()
+   sink.closeElement("manifest");
+ 
+   RVNGPropertyList spineAttrs;
+-  if (m_version == 20)
+-spineAttrs.insert("toc", "toc.ncx");
++  spineAttrs.insert("toc", "toc.ncx");
+ 
+   sink.openElement("spine", spineAttrs);
+   m_htmlManager.writeSpineTo(sink);
+-- 
+2.12.3
+
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2017-08-10 Thread Miklos Vajna
 external/libepubgen/UnpackedTarball_libepubgen.mk |2 
 external/libepubgen/libepubgen-epub3.patch.1  |  866 ++
 writerperfect/source/writer/EPUBExportFilter.cxx  |2 
 3 files changed, 869 insertions(+), 1 deletion(-)

New commits:
commit b9630dc9cdad8cd734267db13a401a97078a1d47
Author: Miklos Vajna 
Date:   Thu Aug 10 15:27:35 2017 +0200

EPUB export: write EPUB3 output

EPUB3 was released in 2011, it makes little sense to target the older
EPUB2 in new code.

Change-Id: Ifdd547bfc7e8f097124ed3effe9053ee2e5f2163
Reviewed-on: https://gerrit.libreoffice.org/40975
Tested-by: Jenkins 
Reviewed-by: Miklos Vajna 

diff --git a/external/libepubgen/UnpackedTarball_libepubgen.mk 
b/external/libepubgen/UnpackedTarball_libepubgen.mk
index 8d60eccc65fe..eb8f0bab9fae 100644
--- a/external/libepubgen/UnpackedTarball_libepubgen.mk
+++ b/external/libepubgen/UnpackedTarball_libepubgen.mk
@@ -16,6 +16,8 @@ epubgen_patches += libepubgen-validation2.patch.1
 epubgen_patches += libepubgen-validation3.patch.1
 # Backport of 
.
 epubgen_patches += libepubgen-vc.patch.1
+# Backport of 

 (and its deps).
+epubgen_patches += libepubgen-epub3.patch.1
 
 ifeq ($(COM_IS_CLANG),TRUE)
 ifneq ($(filter -fsanitize=%,$(CC)),)
diff --git a/external/libepubgen/libepubgen-epub3.patch.1 
b/external/libepubgen/libepubgen-epub3.patch.1
new file mode 100644
index ..33a5982fcbdd
--- /dev/null
+++ b/external/libepubgen/libepubgen-epub3.patch.1
@@ -0,0 +1,866 @@
+From 17b4d0a2b595d1504f3d957268e2085ae0f80db7 Mon Sep 17 00:00:00 2001
+From: Miklos Vajna 
+Date: Wed, 9 Aug 2017 15:53:02 +0200
+Subject: [PATCH 1/9] EPUBGenerator: avoid container version roundtrip to
+ double
+
+This will be an error for EPUB3:
+
+ERROR(RSC-005): test.epub/META-INF/container.xml(2,85): Error while parsing 
file: value of attribute "version" is invalid; must be equal to "1.0"
+
+But it does not hurt for EPUB2, either.
+---
+ src/lib/EPUBGenerator.cpp | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/lib/EPUBGenerator.cpp b/src/lib/EPUBGenerator.cpp
+index 3357cf2..1033c0f 100644
+--- a/src/lib/EPUBGenerator.cpp
 b/src/lib/EPUBGenerator.cpp
+@@ -117,7 +117,7 @@ void EPUBGenerator::writeContainer()
+   EPUBXMLSink sink;
+ 
+   RVNGPropertyList containerAttrs;
+-  containerAttrs.insert("version", "1.0");
++  containerAttrs.insert("version", RVNGPropertyFactory::newStringProp("1.0"));
+   containerAttrs.insert("xmlns", 
"urn:oasis:names:tc:opendocument:xmlns:container");
+ 
+   sink.openElement("container", containerAttrs);
+-- 
+2.12.3
+
+From 8ca1fe2b9db9bacd6e868e69a0909a441fb6a7f8 Mon Sep 17 00:00:00 2001
+From: Miklos Vajna 
+Date: Wed, 9 Aug 2017 16:00:05 +0200
+Subject: [PATCH 2/9] EPUBGenerator: avoid opf:scheme attribute when writing
+ the UUID
+
+This will be an error for EPUB3:
+
+ERROR(RSC-005): test.epub/OEBPS/content.opf(2,292): Error while parsing file: 
found attribute "opf:scheme", but no attributes allowed here
+
+But it's optional for EPUB2 already.
+---
+ src/lib/EPUBGenerator.cpp | 1 -
+ 1 file changed, 1 deletion(-)
+
+diff --git a/src/lib/EPUBGenerator.cpp b/src/lib/EPUBGenerator.cpp
+index 1033c0f..14e3c58 100644
+--- a/src/lib/EPUBGenerator.cpp
 b/src/lib/EPUBGenerator.cpp
+@@ -199,7 +199,6 @@ void EPUBGenerator::writeRoot()
+ 
+   RVNGPropertyList identifierAttrs;
+   identifierAttrs.insert("id", uniqueId);
+-  identifierAttrs.insert("opf:scheme", "UUID");
+   sink.openElement("dc:identifier", identifierAttrs);
+   // The identifier element is required to have a unique character content.
+   std::stringstream identifierStream("urn:uuid:");
+-- 
+2.12.3
+
+From aa71784fcee0404c2f136f035887ca4c52d0e756 Mon Sep 17 00:00:00 2001
+From: Miklos Vajna 
+Date: Wed, 9 Aug 2017 16:11:13 +0200
+Subject: [PATCH 3/9] EPUBGenerator: avoid empty dc:title element
+
+This is a warning for EPUB2, but it'll be an error for EPUB3:
+
+ERROR(RSC-005): test.epub/OEBPS/content.opf(2,337): Error while parsing file: 
character content of element "dc:title" invalid; must be a string with length 
at least 1 (actual length was 0)
+
+The problem is that for ODF/librevenge this element is optional, so work
+it around by adding a zero-width space.
+
+A later commit should read the optional title of declared with a
+librevenge API call, though.
+---
+ src/lib/EPUBGenerator.cpp | 4 
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/lib/EPUBGenerator.cpp b/src/lib/EPUBGenerator.cpp
+index 14e3c58..75ccb5a 100644
+--- a/src/lib/EPUBGenerator.cpp
 b/src/lib/EPUBGenerator.cpp
+@@ -208,8 +208,12 @@ void EPUBGenerator::writeRoot()
+   

[Libreoffice-commits] core.git: external/libepubgen

2017-08-09 Thread Stephan Bergmann
 external/libepubgen/UnpackedTarball_libepubgen.mk |8 
 external/libepubgen/ubsan-visibility.patch|   11 +++
 2 files changed, 19 insertions(+)

New commits:
commit fb899f976d2d8f15ca992ecb61511a2c83153c33
Author: Stephan Bergmann 
Date:   Wed Aug 9 16:04:48 2017 +0200

For Clang -fsanitize=vptr use -fvisibility-ms-compat in exernal/libepubgen 
too

...similarly to how it is used for other external libraries since
f0aa1a78fb209310e8baef53c02f365fca518d11 "For Clang -fsanitize=vptr use
-fvisibility-ms-compat, not -fvisibility=hidden".  This caused
CppunitTest_writerperfect_writer to fail now with -fsanitize=vptr after
7915f35d7fca5d0720d96954beaa97c00a2c3821 "EPUB export: implement doc/para
open/close and text in doc handler", where additions to
writerperfect/source/writer/EPUBExportFilter.cxx caused Library_wpftwriter 
to
import more stuff from the libepubgen archive, which happend to make it 
pick up
the (erroneously hidden) definition of _ZTIN10librevenge17RVNGTextInterfaceE
from that archive, instead of from some other object/archive as happened 
before.

Change-Id: I2b56df38d7225505ff993321598ddd51812d9de4

diff --git a/external/libepubgen/UnpackedTarball_libepubgen.mk 
b/external/libepubgen/UnpackedTarball_libepubgen.mk
index 5525ca3b2ce7..8d60eccc65fe 100644
--- a/external/libepubgen/UnpackedTarball_libepubgen.mk
+++ b/external/libepubgen/UnpackedTarball_libepubgen.mk
@@ -17,10 +17,18 @@ epubgen_patches += libepubgen-validation3.patch.1
 # Backport of 
.
 epubgen_patches += libepubgen-vc.patch.1
 
+ifeq ($(COM_IS_CLANG),TRUE)
+ifneq ($(filter -fsanitize=%,$(CC)),)
+epubgen_patches += ubsan-visibility.patch
+endif
+endif
+
 $(eval $(call gb_UnpackedTarball_UnpackedTarball,libepubgen))
 
 $(eval $(call gb_UnpackedTarball_set_tarball,libepubgen,$(EPUBGEN_TARBALL)))
 
+$(eval $(call gb_UnpackedTarball_set_patchlevel,libepubgen,0))
+
 $(eval $(call gb_UnpackedTarball_add_patches,libepubgen,\
$(foreach patch,$(epubgen_patches),external/libepubgen/$(patch)) \
 ))
diff --git a/external/libepubgen/ubsan-visibility.patch 
b/external/libepubgen/ubsan-visibility.patch
new file mode 100644
index ..10234b308ba5
--- /dev/null
+++ b/external/libepubgen/ubsan-visibility.patch
@@ -0,0 +1,11 @@
+--- configure
 configure
+@@ -18425,7 +18425,7 @@
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for 
-fvisibility=hidden compiler flag" >&5
+ $as_echo_n "checking for -fvisibility=hidden compiler flag... " >&6; }
+ saved_CXXFLAGS="$CXXFLAGS"
+-CXXFLAGS="$CXXFLAGS -fvisibility=hidden"
++CXXFLAGS="$CXXFLAGS -fvisibility-ms-compat"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+ 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2017-08-09 Thread Miklos Vajna
 external/libepubgen/UnpackedTarball_libepubgen.mk  |6 ++
 external/libepubgen/libepubgen-validation1.patch.1 |   49 +
 external/libepubgen/libepubgen-validation2.patch.1 |   34 ++
 external/libepubgen/libepubgen-validation3.patch.1 |   35 +++
 external/libepubgen/libepubgen-vc.patch.1  |   13 +
 writerperfect/source/writer/EPUBPackage.cxx|2 
 6 files changed, 138 insertions(+), 1 deletion(-)

New commits:
commit 12b739aa2bf1f664acbbb4c4c815b3348c912977
Author: Miklos Vajna 
Date:   Wed Aug 9 10:53:11 2017 +0200

libepubgen: backport 3 validation fixes

A hello world ODT is now exported without validation errors.

Change-Id: I2b160ee980f8ed9c80fd76945600d1edb1ee29bc
Reviewed-on: https://gerrit.libreoffice.org/40908
Tested-by: Jenkins 
Reviewed-by: Miklos Vajna 

diff --git a/external/libepubgen/UnpackedTarball_libepubgen.mk 
b/external/libepubgen/UnpackedTarball_libepubgen.mk
index cd4ec7d56e83..5525ca3b2ce7 100644
--- a/external/libepubgen/UnpackedTarball_libepubgen.mk
+++ b/external/libepubgen/UnpackedTarball_libepubgen.mk
@@ -8,6 +8,12 @@
 #
 
 epubgen_patches :=
+# Backport of 
.
+epubgen_patches += libepubgen-validation1.patch.1
+# Backport of 
.
+epubgen_patches += libepubgen-validation2.patch.1
+# Backport of 
.
+epubgen_patches += libepubgen-validation3.patch.1
 # Backport of 
.
 epubgen_patches += libepubgen-vc.patch.1
 
diff --git a/external/libepubgen/libepubgen-validation1.patch.1 
b/external/libepubgen/libepubgen-validation1.patch.1
new file mode 100644
index ..18707e76205d
--- /dev/null
+++ b/external/libepubgen/libepubgen-validation1.patch.1
@@ -0,0 +1,49 @@
+From 96e9786f5aba1078251f36e58feefc8d953cdea0 Mon Sep 17 00:00:00 2001
+From: Miklos Vajna 
+Date: Tue, 8 Aug 2017 16:54:24 +0200
+Subject: [PATCH 1/3] EPUBGenerator: fix validation error with empty
+ dc:identifier element
+
+
+"3.4.3.2.1 The identifier Element" says that the character content is
+not optional, so write it.
+---
+ configure.ac  |  3 +++
+ src/lib/EPUBGenerator.cpp | 14 +-
+ 2 files changed, 16 insertions(+), 1 deletion(-)
+
+diff --git a/src/lib/EPUBGenerator.cpp b/src/lib/EPUBGenerator.cpp
+index 0d0f866..507eb14 100644
+--- a/src/lib/EPUBGenerator.cpp
 b/src/lib/EPUBGenerator.cpp
+@@ -7,6 +7,10 @@
+  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+  */
+ 
++#include 
++#include 
++#include 
++
+ #include "EPUBCSSSink.h"
+ #include "EPUBHTMLGenerator.h"
+ #include "EPUBGenerator.h"
+@@ -193,7 +197,15 @@ void EPUBGenerator::writeRoot()
+ 
+   RVNGPropertyList identifierAttrs;
+   identifierAttrs.insert("id", uniqueId);
+-  sink.insertEmptyElement("dc:identifier", identifierAttrs);
++  identifierAttrs.insert("opf:scheme", "UUID");
++  sink.openElement("dc:identifier", identifierAttrs);
++  // The identifier element is required to have a unique character content.
++  std::stringstream identifierStream("urn:uuid:");
++  boost::uuids::uuid uuid = boost::uuids::random_generator()();
++  identifierStream << uuid;
++  std::string identifierCharactrs = identifierStream.str();
++  sink.insertCharacters(identifierCharactrs.c_str());
++  sink.closeElement("dc:identifier");
+ 
+   sink.openElement("dc:title");
+   sink.closeElement("dc:title");
+-- 
+2.12.3
+
diff --git a/external/libepubgen/libepubgen-validation2.patch.1 
b/external/libepubgen/libepubgen-validation2.patch.1
new file mode 100644
index ..a1807f33841b
--- /dev/null
+++ b/external/libepubgen/libepubgen-validation2.patch.1
@@ -0,0 +1,34 @@
+From 2e51fb9163bbc6b9a27fa524382c5aad9700dd0d Mon Sep 17 00:00:00 2001
+From: Miklos Vajna 
+Date: Tue, 8 Aug 2017 17:23:38 +0200
+Subject: [PATCH 2/3] EPUBGenerator: don't write empty guide element
+
+ "2.6:
+Guide" requires:
+
+   Within the package there may be one guide element, containing one or
+   more reference elements.
+
+Given that we never wrote reference child-elements, just don't write the
+guide element at all, especially seeing that it's deprecated in OPF3.
+---
+ src/lib/EPUBGenerator.cpp | 3 ---
+ 1 file changed, 3 deletions(-)
+
+diff --git a/src/lib/EPUBGenerator.cpp b/src/lib/EPUBGenerator.cpp
+index 507eb14..9dbccac 100644
+--- a/src/lib/EPUBGenerator.cpp
 b/src/lib/EPUBGenerator.cpp
+@@ -225,9 +225,6 @@ void