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
This commit is contained in:
henrikjust 2015-06-24 06:31:29 +00:00
parent 58a4ceef23
commit 43e3dd2a38
3 changed files with 10 additions and 6 deletions

View file

@ -2,6 +2,9 @@ Changelog for Writer2LaTeX version 1.4 -> 1.6
---------- version 1.5.3 ---------- ---------- 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 [w2l] Removed old experimental option use_oooref
[w2x] Bugfix: writer2latex.xhtml.TableConverter.borderWidth ran into an infinite loop if border shorthand properties [w2x] Bugfix: writer2latex.xhtml.TableConverter.borderWidth ran into an infinite loop if border shorthand properties

View file

@ -20,7 +20,7 @@
* *
* All Rights Reserved. * 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(); zos.closeEntry();
// Then manifest // Then manifest
OPFWriter manifest = new OPFWriter(xhtmlResult,nVersion,config); OPFWriter manifest = new OPFWriter(xhtmlResult,sFileName,nVersion,config);
ZipEntry manifestEntry = new ZipEntry("OEBPS/book.opf"); ZipEntry manifestEntry = new ZipEntry("OEBPS/book.opf");
zos.putNextEntry(manifestEntry); zos.putNextEntry(manifestEntry);
writeZipEntry(manifest,zos); writeZipEntry(manifest,zos);

View file

@ -20,7 +20,7 @@
* *
* All Rights Reserved. * 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 { public class OPFWriter extends DOMDocument {
private String sUID=null; 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"); super("book", "opf");
// create DOM // create DOM
@ -93,8 +93,9 @@ public class OPFWriter extends DOMDocument {
} }
pack.appendChild(metadata); pack.appendChild(metadata);
// Title and language (required) // Title and language (required; use file name if title is empty)
appendElement(contentDOM, metadata, "dc:title", cr.getMetaData().getTitle()); String sTitle = cr.getMetaData().getTitle();
appendElement(contentDOM, metadata, "dc:title", sTitle.length()>0 ? sTitle : sFileName);
appendElement(contentDOM, metadata, "dc:language", cr.getMetaData().getLanguage()); appendElement(contentDOM, metadata, "dc:language", cr.getMetaData().getLanguage());
// Modification (required in EPUB 3) // Modification (required in EPUB 3)