From 43e3dd2a38818a7268d1718fc69457411ab4d102 Mon Sep 17 00:00:00 2001 From: henrikjust Date: Wed, 24 Jun 2015 06:31:29 +0000 Subject: [PATCH] w2x: Avoid empty title in EPUB export git-svn-id: svn://svn.code.sf.net/p/writer2latex/code/trunk@260 f0f2a975-2e09-46c8-9428-3b39399b9f3c --- source/distro/changelog.txt | 3 +++ source/java/writer2latex/epub/EPUBWriter.java | 4 ++-- source/java/writer2latex/epub/OPFWriter.java | 9 +++++---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/source/distro/changelog.txt b/source/distro/changelog.txt index 5c47fce..5bedea1 100644 --- a/source/distro/changelog.txt +++ b/source/distro/changelog.txt @@ -2,6 +2,9 @@ Changelog for Writer2LaTeX version 1.4 -> 1.6 ---------- version 1.5.3 ---------- +[w2x] In EPUB the title must be non-empty. To avoid creating an invalid EPUB, the file name is now used as title + if the title is empty. + [w2l] Removed old experimental option use_oooref [w2x] Bugfix: writer2latex.xhtml.TableConverter.borderWidth ran into an infinite loop if border shorthand properties diff --git a/source/java/writer2latex/epub/EPUBWriter.java b/source/java/writer2latex/epub/EPUBWriter.java index ab6c1a7..5a9ddd9 100644 --- a/source/java/writer2latex/epub/EPUBWriter.java +++ b/source/java/writer2latex/epub/EPUBWriter.java @@ -20,7 +20,7 @@ * * All Rights Reserved. * - * version 1.6 (2015-05-05) + * version 1.6 (2015-06-24) * */ @@ -106,7 +106,7 @@ public class EPUBWriter implements OutputFile { zos.closeEntry(); // Then manifest - OPFWriter manifest = new OPFWriter(xhtmlResult,nVersion,config); + OPFWriter manifest = new OPFWriter(xhtmlResult,sFileName,nVersion,config); ZipEntry manifestEntry = new ZipEntry("OEBPS/book.opf"); zos.putNextEntry(manifestEntry); writeZipEntry(manifest,zos); diff --git a/source/java/writer2latex/epub/OPFWriter.java b/source/java/writer2latex/epub/OPFWriter.java index d91be52..dd1a4e0 100644 --- a/source/java/writer2latex/epub/OPFWriter.java +++ b/source/java/writer2latex/epub/OPFWriter.java @@ -20,7 +20,7 @@ * * All Rights Reserved. * - * version 1.6 (2015-05-05) + * version 1.6 (2015-06-24) * */ @@ -57,7 +57,7 @@ import writer2latex.xhtml.XhtmlConfig; public class OPFWriter extends DOMDocument { private String sUID=null; - public OPFWriter(ConverterResult cr, int nVersion, XhtmlConfig config) { + public OPFWriter(ConverterResult cr, String sFileName, int nVersion, XhtmlConfig config) { super("book", "opf"); // create DOM @@ -93,8 +93,9 @@ public class OPFWriter extends DOMDocument { } pack.appendChild(metadata); - // Title and language (required) - appendElement(contentDOM, metadata, "dc:title", cr.getMetaData().getTitle()); + // Title and language (required; use file name if title is empty) + String sTitle = cr.getMetaData().getTitle(); + appendElement(contentDOM, metadata, "dc:title", sTitle.length()>0 ? sTitle : sFileName); appendElement(contentDOM, metadata, "dc:language", cr.getMetaData().getLanguage()); // Modification (required in EPUB 3)