From d1416190533e8a940deafde9189740de6b057916 Mon Sep 17 00:00:00 2001
From: henrikjust <henrikjust@f0f2a975-2e09-46c8-9428-3b39399b9f3c>
Date: Tue, 28 Apr 2015 11:48:39 +0000
Subject: [PATCH] EPUB 3 support

git-svn-id: svn://svn.code.sf.net/p/writer2latex/code/trunk@239 f0f2a975-2e09-46c8-9428-3b39399b9f3c
---
 source/distro/changelog.txt                   |   4 +-
 .../comp/w2lcommon/filter/UNOPublisher.java   |   4 +-
 .../comp/writer2xhtml/Epub3OptionsDialog.java |  48 +++++++
 .../comp/writer2xhtml/EpubOptionsDialog.java  |   7 +-
 .../da/comp/writer2xhtml/W2XRegistration.java |  10 +-
 .../writer2xhtml/XhtmlOptionsDialogMath.java  |   4 +-
 source/java/writer2latex/epub/EPUBWriter.java |  25 +++-
 .../writer2latex/epub/NavigationWriter.java   | 131 +++++++++++++++++
 source/java/writer2latex/epub/OPFWriter.java  | 133 ++++++++++++++----
 .../java/writer2latex/xhtml/XhtmlConfig.java  |  47 ++++---
 .../writer2latex/xhtml/XhtmlDocument.java     |  15 +-
 source/oxt/writer2xhtml/Options.xcs           |   1 +
 source/oxt/writer2xhtml/Options.xcu           |   3 +
 .../writer2xhtml/W2XDialogs2/EpubMetadata.xdl |   1 -
 .../writer2xhtml/W2XDialogs2/EpubOptions.xdl  | 102 +++++++-------
 15 files changed, 413 insertions(+), 122 deletions(-)
 create mode 100644 source/java/org/openoffice/da/comp/writer2xhtml/Epub3OptionsDialog.java
 create mode 100644 source/java/writer2latex/epub/NavigationWriter.java

diff --git a/source/distro/changelog.txt b/source/distro/changelog.txt
index 7e0fab3..f9200c4 100644
--- a/source/distro/changelog.txt
+++ b/source/distro/changelog.txt
@@ -8,8 +8,10 @@ Items marked with * are work in progress
 
 [w2x] Added toolbar configuration dialog: Select XHTML and EPUB export format and behavior after export (do nothing,
   display in default viewer or display with custom application) 
+  
+[w2x] New option include_ncx to include a NCX file even if the export format is EPUB 3 
 
-[w2x] *Added EPUB 3 as export format and changed default export format for toolbar to EPUB 3
+[w2x] *Added EPUB 3 as export format and changed default export format for the toolbar to EPUB 3
 
 [all] Implementation detail: Moved descriptions to a separate folder within the extensions
 
diff --git a/source/java/org/openoffice/da/comp/w2lcommon/filter/UNOPublisher.java b/source/java/org/openoffice/da/comp/w2lcommon/filter/UNOPublisher.java
index 636d8ed..b4fb1dc 100644
--- a/source/java/org/openoffice/da/comp/w2lcommon/filter/UNOPublisher.java
+++ b/source/java/org/openoffice/da/comp/w2lcommon/filter/UNOPublisher.java
@@ -20,7 +20,7 @@
  *
  *  All Rights Reserved.
  *  
- *  Version 1.6 (2015-04-05)
+ *  Version 1.6 (2015-04-24)
  *  
  */
 package org.openoffice.da.comp.w2lcommon.filter;
@@ -334,7 +334,7 @@ public class UNOPublisher {
     	case xhtml_mathml: return "org.openoffice.da.writer2xhtml.mathml";
     	case html5: return "org.openoffice.da.writer2xhtml5";
     	case epub: return "org.openoffice.da.writer2xhtml.epub";
-    	case epub3: return "org.openoffice.da.writer2xhtml.epub";
+    	case epub3: return "org.openoffice.da.writer2xhtml.epub3";
     	case latex: return "org.openoffice.da.writer2latex";
     	default: return "";
     	}
diff --git a/source/java/org/openoffice/da/comp/writer2xhtml/Epub3OptionsDialog.java b/source/java/org/openoffice/da/comp/writer2xhtml/Epub3OptionsDialog.java
new file mode 100644
index 0000000..a27b19f
--- /dev/null
+++ b/source/java/org/openoffice/da/comp/writer2xhtml/Epub3OptionsDialog.java
@@ -0,0 +1,48 @@
+/************************************************************************
+ *
+ *  EpubOptionsDialog.java
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License version 2.1, as published by the Free Software Foundation.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ *  MA  02111-1307  USA
+ *
+ *  Copyright: 2002-2016 by Henrik Just
+ *
+ *  All Rights Reserved.
+ * 
+ *  Version 1.6 (2015-04-28)
+ *
+ */
+package org.openoffice.da.comp.writer2xhtml;
+
+import com.sun.star.uno.XComponentContext;
+
+/** This class provides a UNO component which implements a filter UI for the
+ *  EPUB 3 export. In this version the option to include NCX is enabled.
+ */
+public class Epub3OptionsDialog extends EpubOptionsDialog {
+
+    /** The component will be registered under this name.
+     */
+    public static String __serviceName = "org.openoffice.da.writer2xhtml.Epub3OptionsDialog";
+
+    /** The component should also have an implementation name.
+     */
+    public static String __implementationName = "org.openoffice.da.comp.writer2xhtml.EpubOptionsDialog3";
+	
+    /** Create a new Epub3OptionsDialog */
+    public Epub3OptionsDialog(XComponentContext xContext) {
+        super(xContext);
+    }
+
+}
diff --git a/source/java/org/openoffice/da/comp/writer2xhtml/EpubOptionsDialog.java b/source/java/org/openoffice/da/comp/writer2xhtml/EpubOptionsDialog.java
index 43c443d..11b36ae 100644
--- a/source/java/org/openoffice/da/comp/writer2xhtml/EpubOptionsDialog.java
+++ b/source/java/org/openoffice/da/comp/writer2xhtml/EpubOptionsDialog.java
@@ -16,11 +16,11 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  *  MA  02111-1307  USA
  *
- *  Copyright: 2002-2014 by Henrik Just
+ *  Copyright: 2002-2015 by Henrik Just
  *
  *  All Rights Reserved.
  * 
- *  Version 1.4 (2014-09-25)
+ *  Version 1.6 (2015-04-28)
  *
  */
 
@@ -119,6 +119,7 @@ public class EpubOptionsDialog extends OptionsDialogBase {
         // Navigation table
         loadListBoxOption(xProps, "ExternalTocDepth");
         loadCheckBoxOption(xProps, "IncludeToc");
+        loadCheckBoxOption(xProps, "IncludeNCX");
 
         updateLockedOptions();
         enableControls();
@@ -204,6 +205,7 @@ public class EpubOptionsDialog extends OptionsDialogBase {
         short nExternalTocDepth = saveListBoxOption(xProps, "ExternalTocDepth");
         helper.put("external_toc_depth", Integer.toString(nExternalTocDepth+1));
         saveCheckBoxOption(xProps, helper, "IncludeToc", "include_toc");
+        saveCheckBoxOption(xProps, helper, "IncludeNCX", "include_ncx");
     }
 	
 	
@@ -291,6 +293,7 @@ public class EpubOptionsDialog extends OptionsDialogBase {
         setControlEnabled("ExternalTocDepthLabel", !isLocked("external_toc_depth"));
         setControlEnabled("ExternalTocDepth", !isLocked("external_toc_depth"));
         setControlEnabled("IncludeToc", !isLocked("include_toc"));
+        setControlEnabled("IncludeNCX", (this instanceof Epub3OptionsDialog) && !isLocked("include_ncx"));
     }
 	
     private void relativeFontSizeChange() {
diff --git a/source/java/org/openoffice/da/comp/writer2xhtml/W2XRegistration.java b/source/java/org/openoffice/da/comp/writer2xhtml/W2XRegistration.java
index 34e66d2..1c42f71 100644
--- a/source/java/org/openoffice/da/comp/writer2xhtml/W2XRegistration.java
+++ b/source/java/org/openoffice/da/comp/writer2xhtml/W2XRegistration.java
@@ -20,7 +20,7 @@
  *
  *  All Rights Reserved.
  * 
- *  Version 1.6 (2015-04-03) 
+ *  Version 1.6 (2015-04-28) 
  *
  */ 
  
@@ -102,6 +102,12 @@ public class W2XRegistration {
             multiFactory,						    
             regKey);
         }
+        else if (implName.equals(Epub3OptionsDialog.__implementationName)) {
+            xSingleServiceFactory = FactoryHelper.getServiceFactory(Epub3OptionsDialog.class,
+            Epub3OptionsDialog.__serviceName,
+            multiFactory,						    
+            regKey);
+        }
         else if (implName.equals(EpubMetadataDialog.__implementationName)) {
             xSingleServiceFactory = FactoryHelper.getServiceFactory(EpubMetadataDialog.class,
             EpubMetadataDialog.__serviceName,
@@ -148,6 +154,8 @@ public class W2XRegistration {
                 XhtmlOptionsDialogCalc.__serviceName, regKey) & 
             FactoryHelper.writeRegistryServiceInfo(EpubOptionsDialog.__implementationName,
                         EpubOptionsDialog.__serviceName, regKey) &
+            FactoryHelper.writeRegistryServiceInfo(Epub3OptionsDialog.__implementationName,
+                        Epub3OptionsDialog.__serviceName, regKey) &
             FactoryHelper.writeRegistryServiceInfo(EpubMetadataDialog.__implementationName,
                         EpubMetadataDialog.__serviceName, regKey) &
             FactoryHelper.writeRegistryServiceInfo(ConfigurationDialog.__implementationName,
diff --git a/source/java/org/openoffice/da/comp/writer2xhtml/XhtmlOptionsDialogMath.java b/source/java/org/openoffice/da/comp/writer2xhtml/XhtmlOptionsDialogMath.java
index 7e4d515..f4eeae5 100644
--- a/source/java/org/openoffice/da/comp/writer2xhtml/XhtmlOptionsDialogMath.java
+++ b/source/java/org/openoffice/da/comp/writer2xhtml/XhtmlOptionsDialogMath.java
@@ -1,6 +1,6 @@
 /************************************************************************
  *
- *  XhtmlOptionsDialogXsl.java
+ *  XhtmlOptionsDialogMath.java
  *
  *  This library is free software; you can redistribute it and/or
  *  modify it under the terms of the GNU Lesser General Public
@@ -30,7 +30,7 @@ import com.sun.star.uno.XComponentContext;
 
 /** This class provides a uno component which implements a filter ui for the
  *  Xhtml export for the XHTML+MathML and HTML export.
- *  This variant of the dialog has the MahtJax setting enabled
+ *  This variant of the dialog has the MathJax setting enabled
  */
 public class XhtmlOptionsDialogMath extends XhtmlOptionsDialog {
     /** The component will be registered under this name.
diff --git a/source/java/writer2latex/epub/EPUBWriter.java b/source/java/writer2latex/epub/EPUBWriter.java
index 58cfe2b..4b479f5 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-01-15)
+ *  version 1.6 (2015-04-21)
  *
  */
 
@@ -49,6 +49,7 @@ public class EPUBWriter implements OutputFile {
 	
 	private ConverterResult xhtmlResult;
 	private String sFileName;
+	private int nVersion;
 	//private XhtmlConfig config;
 	
 	/** Create a new <code>EPUBWriter</code> based on a <code>ConverterResult</code>.
@@ -61,6 +62,7 @@ public class EPUBWriter implements OutputFile {
 	public EPUBWriter(ConverterResult xhtmlResult, String sFileName, int nVersion, XhtmlConfig config) {
 		this.xhtmlResult = xhtmlResult;
 		this.sFileName = Misc.removeExtension(sFileName);
+		this.nVersion = nVersion;
 		//this.config = config;
 	}
 	
@@ -98,18 +100,27 @@ public class EPUBWriter implements OutputFile {
 		zos.closeEntry();
 		
 		// Then manifest
-		OPFWriter manifest = new OPFWriter(xhtmlResult);
+		OPFWriter manifest = new OPFWriter(xhtmlResult,nVersion);
 		ZipEntry manifestEntry = new ZipEntry("OEBPS/book.opf");
 		zos.putNextEntry(manifestEntry);
 		writeZipEntry(manifest,zos);
 		zos.closeEntry();
 		
 		// And content table
-		OutputFile ncx = new NCXWriter(xhtmlResult, manifest.getUid());
-		ZipEntry ncxEntry = new ZipEntry("OEBPS/book.ncx");
-		zos.putNextEntry(ncxEntry);
-		writeZipEntry(ncx,zos);
-		zos.closeEntry();
+		if (nVersion==3) {
+			OutputFile navigation = new NavigationWriter(xhtmlResult);
+			ZipEntry navigationEntry = new ZipEntry("OEBPS/nav.xhtml");
+			zos.putNextEntry(navigationEntry);
+			writeZipEntry(navigation,zos);
+			zos.closeEntry();
+		}
+		else {
+			OutputFile ncx = new NCXWriter(xhtmlResult, manifest.getUid());
+			ZipEntry ncxEntry = new ZipEntry("OEBPS/book.ncx");
+			zos.putNextEntry(ncxEntry);
+			writeZipEntry(ncx,zos);
+			zos.closeEntry();
+		}
 		
 		// Finally XHTML content
 		Iterator<OutputFile> iter = xhtmlResult.iterator();
diff --git a/source/java/writer2latex/epub/NavigationWriter.java b/source/java/writer2latex/epub/NavigationWriter.java
new file mode 100644
index 0000000..fa14673
--- /dev/null
+++ b/source/java/writer2latex/epub/NavigationWriter.java
@@ -0,0 +1,131 @@
+/************************************************************************
+ *
+ *  NavigationWriter.java
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License version 2.1, as published by the Free Software Foundation.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ *  MA  02111-1307  USA
+ *
+ *  Copyright: 2001-2015 by Henrik Just
+ *
+ *  All Rights Reserved.
+ * 
+ *  version 1.6 (2015-04-21)
+ *
+ */
+package writer2latex.epub;
+
+import java.util.Iterator;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.w3c.dom.DOMImplementation;
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentType;
+import org.w3c.dom.Element;
+
+import writer2latex.api.ContentEntry;
+import writer2latex.api.ConverterResult;
+import writer2latex.base.DOMDocument;
+import writer2latex.util.Misc;
+
+/** This class writes the EPUB Navigation Document as defined in EPUB 3
+ */
+public class NavigationWriter extends DOMDocument {
+
+	public NavigationWriter(ConverterResult cr) {
+		super("nav", "xhtml");
+		
+        // create DOM
+        Document contentDOM = null;
+        try {
+            DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
+            DocumentBuilder builder = builderFactory.newDocumentBuilder();
+            DOMImplementation domImpl = builder.getDOMImplementation();
+            DocumentType doctype = domImpl.createDocumentType("xhtml","",""); 
+            contentDOM = domImpl.createDocument("http://www.w3.org/1999/xhtml","html",doctype);
+        }
+        catch (ParserConfigurationException t) { // this should never happen
+            throw new RuntimeException(t);
+        }
+        
+        // Populate the DOM tree
+        Element doc = contentDOM.getDocumentElement();
+        doc.setAttribute("xmlns","http://www.w3.org/1999/xhtml");
+        doc.setAttribute("xmlns:epub","http://www.idpf.org/2007/ops");
+        doc.setAttribute("xml:lang", cr.getMetaData().getLanguage());
+        doc.setAttribute("lang", cr.getMetaData().getLanguage());
+        
+        // Create and populate the head
+        Element head = contentDOM.createElement("head");
+        doc.appendChild(head);
+        
+        Element title = contentDOM.createElement("title");
+        head.appendChild(title);
+        title.appendChild(contentDOM.createTextNode("EPUB 3 Navigation Document"));
+        // Or use the document title cr.getMetaData().getTitle()?
+        
+        // Create the body
+        Element body = contentDOM.createElement("body");
+        doc.appendChild(body);
+        
+        // Create nav element
+        Element nav = contentDOM.createElement("nav");
+        nav.setAttribute("epub:type", "toc");
+        body.appendChild(nav);
+        
+        // Populate the nav element from the content table in the converter result
+        Element currentContainer = body;
+        int nCurrentLevel = 0;
+        int nCurrentEntryLevel = 0; // This may differ from nCurrentLevel if the heading levels "jump" in then document
+        Iterator<ContentEntry> content = cr.getContent().iterator();
+        while (content.hasNext()) {
+        	ContentEntry entry = content.next();
+        	int nEntryLevel = Math.max(entry.getLevel(), 1);
+        	
+        	if (nEntryLevel<nCurrentLevel) {
+        		// Return to higher level
+        		for (int i=nEntryLevel; i<nCurrentLevel; i++) {
+        			currentContainer = (Element) currentContainer.getParentNode().getParentNode();
+        		}
+        		nCurrentLevel = nEntryLevel;
+        	}
+        	else if (nEntryLevel>nCurrentEntryLevel) {
+        		// To lower level (always one step; a jump from e.g. heading 1 to heading 3 in the document
+        		// is considered an error)
+        		currentContainer = (Element) currentContainer.getLastChild();
+        		Element ol = contentDOM.createElement("ol");
+        		currentContainer.appendChild(ol);
+        		currentContainer = ol;
+        		nCurrentLevel++;
+        	}
+        	
+        	nCurrentEntryLevel = nEntryLevel;
+        	
+        	// Create the actual toc entry
+        	Element li = contentDOM.createElement("li");
+        	currentContainer.appendChild(li);
+        	Element a = contentDOM.createElement("a");
+        	li.appendChild(a);
+        	String sHref = Misc.makeHref(entry.getFile().getFileName());
+        	if (entry.getTarget()!=null) { sHref+="#"+entry.getTarget(); }
+        	a.setAttribute("href", sHref);
+        	a.appendChild(contentDOM.createTextNode(entry.getTitle()));
+        }
+        
+        setContentDOM(contentDOM);
+	}
+
+}
diff --git a/source/java/writer2latex/epub/OPFWriter.java b/source/java/writer2latex/epub/OPFWriter.java
index 3b3a270..942e188 100644
--- a/source/java/writer2latex/epub/OPFWriter.java
+++ b/source/java/writer2latex/epub/OPFWriter.java
@@ -16,11 +16,11 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  *  MA  02111-1307  USA
  *
- *  Copyright: 2001-2014 by Henrik Just
+ *  Copyright: 2001-2015 by Henrik Just
  *
  *  All Rights Reserved.
  * 
- *  version 1.4 (2014-08-26)
+ *  version 1.6 (2015-04-21)
  *
  */
 
@@ -51,7 +51,7 @@ import writer2latex.util.Misc;
 public class OPFWriter extends DOMDocument {
 	private String sUID=null;
 
-	public OPFWriter(ConverterResult cr) {
+	public OPFWriter(ConverterResult cr, int nVersion) {
 		super("book", "opf");
 		
         // create DOM
@@ -69,20 +69,35 @@ public class OPFWriter extends DOMDocument {
         
         // Populate the DOM tree
         Element pack = contentDOM.getDocumentElement();
-        pack.setAttribute("version", "2.0");
+        if (nVersion==3) {
+        	pack.setAttribute("version", "3.0");
+        }
+        else {
+        	pack.setAttribute("version", "2.0");
+        }
         pack.setAttribute("xmlns","http://www.idpf.org/2007/opf");
         pack.setAttribute("unique-identifier", "BookId");
         
+        // TODO: http://sketchytech.blogspot.dk/2014/03/epub2-to-epub3-lessons-learnt-in.html
+        
         // Meta data, at least dc:title, dc:language and dc:identifier are required by the specification
+        // For EPUB 3, also dcterms:modified is required
         Element metadata = contentDOM.createElement("metadata");
         metadata.setAttribute("xmlns:dc", "http://purl.org/dc/elements/1.1/");
-        metadata.setAttribute("xmlns:opf", "http://www.idpf.org/2007/opf");
+        if (nVersion!=3) {
+        	metadata.setAttribute("xmlns:opf", "http://www.idpf.org/2007/opf");
+        }
         pack.appendChild(metadata);
         
         // Title and language (required)
         appendElement(contentDOM, metadata, "dc:title", cr.getMetaData().getTitle());
         appendElement(contentDOM, metadata, "dc:language", cr.getMetaData().getLanguage());
         
+        // Modification (required in EPUB 3)
+        
+        appendElement(contentDOM, metadata, "meta", cr.getMetaData().getDate())
+        	.setAttribute("property", "dcterms:modified");
+        
         // Subject and keywords in ODF both map to Dublin core subjects
         if (cr.getMetaData().getSubject().length()>0) {
         	appendElement(contentDOM, metadata, "dc:subject", cr.getMetaData().getSubject());
@@ -99,7 +114,7 @@ public class OPFWriter extends DOMDocument {
         
         // User defined meta data
         // The identifier, creator, contributor and date has an optional attribute and there may be multiple instances of
-        // the first three. The key must be in the form name[id][.attribute]
+        // the latter three. The key must be in the form name[id][.attribute]
         // where the id is some unique id amongst the instances with the same name
         // Furthermore the instances will be sorted on the id
         // Thus you can have e.g. creator1.aut="John Doe" and creator2.aut="Jane Doe", and "John Doe" will be the first author
@@ -138,29 +153,72 @@ public class OPFWriter extends DOMDocument {
         			sUID = sValue;
         		}
         		if (sAttributeValue!=null) {
-        			identifier.setAttribute("opf:scheme", sAttributeValue);
+        			if (nVersion==3) {
+        				Element meta = appendElement(contentDOM, metadata, "meta", sAttributeValue);
+        				meta.setAttribute("refines", "#BookId");
+        				meta.setAttribute("property", "identifier-type");
+        			}
+        			else {
+        				identifier.setAttribute("opf:scheme", sAttributeValue);
+        			}
         		}
         		bHasIdentifier = true;
         	}
         	else if (sKey.startsWith("creator")) {
         		Element creator = appendElement(contentDOM, metadata, "dc:creator", sValue);
-        		creator.setAttribute("opf:file-as", fileAs(sValue));
-        		if (sAttributeValue!=null) {
-        			creator.setAttribute("opf:role", sAttributeValue);
+        		creator.setAttribute("id", sKey);
+        		if (nVersion==3) {
+        			Element fileas = appendElement(contentDOM, metadata, "meta", fileAs(sValue));
+        			fileas.setAttribute("refines", "#"+sKey);
+        			fileas.setAttribute("property", "file-as");
+        			if (sAttributeValue!=null) {
+        				Element role = appendElement(contentDOM, metadata, "meta", sAttributeValue);
+        				role.setAttribute("refines", "#"+sKey);
+        				role.setAttribute("property", "role");
+        			}
+        		}
+        		else {
+	        		creator.setAttribute("opf:file-as", fileAs(sValue));
+	        		if (sAttributeValue!=null) {
+	        			creator.setAttribute("opf:role", sAttributeValue);
+	        		}
         		}
         		bHasCreator = true;
         	}
         	else if (sKey.startsWith("contributor")) {
         		Element contributor = appendElement(contentDOM, metadata, "dc:contributor", sValue);
-        		contributor.setAttribute("opf:file-as", fileAs(sValue));
-        		if (sAttributeValue!=null) {
-        			contributor.setAttribute("opf:role", sAttributeValue);
+        		contributor.setAttribute("id", sKey);
+        		if (nVersion==3) {
+        			Element fileas = appendElement(contentDOM, metadata, "meta", fileAs(sValue));
+        			fileas.setAttribute("refines", "#"+sKey);
+        			fileas.setAttribute("property", "file-as");
+        			if (sAttributeValue!=null) {
+        				Element role = appendElement(contentDOM, metadata, "meta", sAttributeValue);
+        				role.setAttribute("refines", "#"+sKey);
+        				role.setAttribute("property", "role");
+        			}
+        		}
+        		else {
+            		contributor.setAttribute("opf:file-as", fileAs(sValue));
+	        		if (sAttributeValue!=null) {
+	        			contributor.setAttribute("opf:role", sAttributeValue);
+	        		}
         		}
         	}
         	else if (sKey.startsWith("date")) {
         		Element date = appendElement(contentDOM, metadata, "dc:date", sValue);
-        		if (sAttributeValue!=null) {
-        			date.setAttribute("opf:event", sAttributeValue);
+        		date.setAttribute("id", sKey);
+        		if (nVersion==3) {
+        			if (sAttributeValue!=null) {
+        				Element event = appendElement(contentDOM, metadata, "meta", sAttributeValue);
+        				event.setAttribute("refines", "#"+sKey);
+        				event.setAttribute("property", "event");
+        			}
+        		}
+        		else {
+	        		if (sAttributeValue!=null) {
+	        			date.setAttribute("opf:event", sAttributeValue);
+	        		}
         		}
         		bHasDate = true;
         	}
@@ -196,11 +254,26 @@ public class OPFWriter extends DOMDocument {
     		sUID = UUID.randomUUID().toString(); 
     		Element identifier = appendElement(contentDOM, metadata, "dc:identifier", sUID);
     		identifier.setAttribute("id", "BookId");
-    		identifier.setAttribute("opf:scheme", "UUID");
+			if (nVersion==3) {
+				Element meta = appendElement(contentDOM, metadata, "meta", "UUID");
+				meta.setAttribute("refines", "#BookId");
+				meta.setAttribute("property", "identifier-type");
+			}
+			else {
+	    		identifier.setAttribute("opf:scheme", "UUID");
+			}
     	}
     	if (!bHasCreator && cr.getMetaData().getCreator().length()>0) {
-    		appendElement(contentDOM, metadata, "dc:creator", cr.getMetaData().getCreator())
-    			.setAttribute("opf:file-as", fileAs(cr.getMetaData().getCreator()));
+    		Element creator = appendElement(contentDOM, metadata, "dc:creator", cr.getMetaData().getCreator());
+    		creator.setAttribute("id", "creator");
+    		if (nVersion==3) {
+    			Element fileas = appendElement(contentDOM, metadata, "meta", fileAs(cr.getMetaData().getCreator()));
+    			fileas.setAttribute("refines", "#creator");
+    			fileas.setAttribute("property", "file-as");    			
+    		}
+    		else {
+    			creator.setAttribute("opf:file-as", fileAs(cr.getMetaData().getCreator()));
+    		}
     	}
     	if (!bHasDate && cr.getMetaData().getDate().length()>0) {
     		// TODO: Support meta:creation-date?
@@ -213,7 +286,9 @@ public class OPFWriter extends DOMDocument {
         pack.appendChild(manifest);
         
         Element spine = contentDOM.createElement("spine");
-        spine.setAttribute("toc", "ncx");
+        if (nVersion!=3) { // Use old NCX file for navigation
+        	spine.setAttribute("toc", "ncx");
+        }
         pack.appendChild(spine);
         
         int nMasterCount = 0;
@@ -255,11 +330,21 @@ public class OPFWriter extends DOMDocument {
         	}
         }
         
-        Element item = contentDOM.createElement("item");
-        item.setAttribute("href", "book.ncx");
-        item.setAttribute("media-type", "application/x-dtbncx+xml");
-        item.setAttribute("id", "ncx");
-        manifest.appendChild(item);
+        if (nVersion==3) { // Include the new Navigation Document
+	        Element item = contentDOM.createElement("item");
+	        item.setAttribute("href", "nav.xhtml");
+	        item.setAttribute("media-type", "application/xhtml+xml");
+	        item.setAttribute("id", "nav");
+	        item.setAttribute("properties", "nav");
+	        manifest.appendChild(item);
+        }
+        else { // Include old NCX file
+	        Element item = contentDOM.createElement("item");
+	        item.setAttribute("href", "book.ncx");
+	        item.setAttribute("media-type", "application/x-dtbncx+xml");
+	        item.setAttribute("id", "ncx");
+	        manifest.appendChild(item);
+        }
         
         // The guide may contain references to some fundamental structural components
         Element guide = contentDOM.createElement("guide");
diff --git a/source/java/writer2latex/xhtml/XhtmlConfig.java b/source/java/writer2latex/xhtml/XhtmlConfig.java
index 9c80a30..44de914 100644
--- a/source/java/writer2latex/xhtml/XhtmlConfig.java
+++ b/source/java/writer2latex/xhtml/XhtmlConfig.java
@@ -20,7 +20,7 @@
  *
  *  All Rights Reserved.
  * 
- *  Version 1.6 (2015-01-14)
+ *  Version 1.6 (2015-04-28)
  *
  */
 
@@ -41,7 +41,7 @@ import writer2latex.util.Misc;
 
 public class XhtmlConfig extends writer2latex.base.ConfigBase {
     // Implement configuration methods
-    protected int getOptionCount() { return 57; }
+    protected int getOptionCount() { return 58; }
     protected String getDefaultConfigPath() { return "/writer2latex/xhtml/config/"; }
 	
     // Override setOption: To be backwards compatible, we must accept options
@@ -137,26 +137,27 @@ public class XhtmlConfig extends writer2latex.base.ConfigBase {
     private static final int FOOTNOTES_HEADING = 34;
     private static final int EXTERNAL_TOC_DEPTH = 35;
     private static final int INCLUDE_TOC = 36;
-    private static final int SPLIT_LEVEL = 37;
-    private static final int REPEAT_LEVELS = 38;
-    private static final int PAGE_BREAK_SPLIT = 39;
-    private static final int SPLIT_AFTER = 40;
-    private static final int IMAGE_SPLIT = 41;
-    private static final int COVER_IMAGE = 42;
-    private static final int EMBED_SVG = 43;
-    private static final int EMBED_IMG = 44;
-    private static final int USE_MATHJAX = 45;
-    private static final int CALC_SPLIT = 46;
-    private static final int DISPLAY_HIDDEN_SHEETS = 47;
-    private static final int DISPLAY_HIDDEN_ROWS_COLS = 48;
-    private static final int DISPLAY_FILTERED_ROWS_COLS = 49;
-    private static final int APPLY_PRINT_RANGES = 50;
-    private static final int USE_TITLE_AS_HEADING = 51;
-    private static final int USE_SHEET_NAMES_AS_HEADINGS = 52;
-    private static final int SAVE_IMAGES_IN_SUBDIR = 53;
-    private static final int UPLINK = 54;
-    private static final int DIRECTORY_ICON = 55;
-    private static final int DOCUMENT_ICON = 56;
+    private static final int INCLUDE_NCX = 37;
+    private static final int SPLIT_LEVEL = 38;
+    private static final int REPEAT_LEVELS = 39;
+    private static final int PAGE_BREAK_SPLIT = 40;
+    private static final int SPLIT_AFTER = 41;
+    private static final int IMAGE_SPLIT = 42;
+    private static final int COVER_IMAGE = 43;
+    private static final int EMBED_SVG = 44;
+    private static final int EMBED_IMG = 45;
+    private static final int USE_MATHJAX = 46;
+    private static final int CALC_SPLIT = 47;
+    private static final int DISPLAY_HIDDEN_SHEETS = 48;
+    private static final int DISPLAY_HIDDEN_ROWS_COLS = 49;
+    private static final int DISPLAY_FILTERED_ROWS_COLS = 50;
+    private static final int APPLY_PRINT_RANGES = 51;
+    private static final int USE_TITLE_AS_HEADING = 52;
+    private static final int USE_SHEET_NAMES_AS_HEADINGS = 53;
+    private static final int SAVE_IMAGES_IN_SUBDIR = 54;
+    private static final int UPLINK = 55;
+    private static final int DIRECTORY_ICON = 56;
+    private static final int DOCUMENT_ICON = 57;
 
     protected ComplexOption xheading = addComplexOption("heading-map");
     protected ComplexOption xpar = addComplexOption("paragraph-map");
@@ -245,6 +246,7 @@ public class XhtmlConfig extends writer2latex.base.ConfigBase {
             }
         };
         options[INCLUDE_TOC] = new BooleanOption("include_toc","true");
+        options[INCLUDE_NCX] = new BooleanOption("include_ncx","true");
         options[SPLIT_LEVEL] = new IntegerOption("split_level","0") {
         	@Override public void setString(String sValue) {
                 super.setString(sValue);
@@ -408,6 +410,7 @@ public class XhtmlConfig extends writer2latex.base.ConfigBase {
     public int formulas() { return ((IntegerOption) options[FORMULAS]).getValue(); }
     public int externalTocDepth() { return ((IntegerOption) options[EXTERNAL_TOC_DEPTH]).getValue(); }
     public boolean includeToc() { return ((BooleanOption) options[INCLUDE_TOC]).getValue(); }
+    public boolean includeNCX() { return ((BooleanOption) options[INCLUDE_NCX]).getValue(); }
     public int getXhtmlSplitLevel() { return ((IntegerOption) options[SPLIT_LEVEL]).getValue(); }
     public int getXhtmlRepeatLevels() { return ((IntegerOption) options[REPEAT_LEVELS]).getValue(); }
     public int pageBreakSplit() { return ((IntegerOption) options[PAGE_BREAK_SPLIT]).getValue(); }
diff --git a/source/java/writer2latex/xhtml/XhtmlDocument.java b/source/java/writer2latex/xhtml/XhtmlDocument.java
index e9b2d27..76be3cf 100644
--- a/source/java/writer2latex/xhtml/XhtmlDocument.java
+++ b/source/java/writer2latex/xhtml/XhtmlDocument.java
@@ -16,11 +16,11 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  *  MA  02111-1307  USA
  *
- *  Copyright: 2002-2014 by Henrik Just
+ *  Copyright: 2002-2015 by Henrik Just
  *
  *  All Rights Reserved.
  * 
- *  Version 1.4 (2014-09-23)
+ *  Version 1.6 (2015-04-21)
  *
  */
 
@@ -40,7 +40,6 @@ import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.ParserConfigurationException;
 
-import writer2latex.api.MIMETypes;
 import writer2latex.base.DOMDocument;
 import writer2latex.office.XMLString;
 
@@ -294,13 +293,9 @@ public class XhtmlDocument extends DOMDocument {
     }
     
     @Override public String getMIMEType() {
-    	switch (nType) {
-    	case XHTML10: return MIMETypes.XHTML;
-    	case XHTML11: return MIMETypes.XHTML_MATHML; // TODO: Change the constant names in MIMETypes, this is a bit confusing...
-    	case XHTML_MATHML: return MIMETypes.XHTML_MATHML;
-    	case HTML5: return MIMETypes.HTML5;
-    	}
-    	return "";
+    	// Get the real MIME type, not the pseudo ones used by the converter API
+    	// We always produce XHTML, thus
+    	return "application/xhtml+xml";
     }
     
     @Override public boolean isMasterDocument() {
diff --git a/source/oxt/writer2xhtml/Options.xcs b/source/oxt/writer2xhtml/Options.xcs
index 185b402..e03342f 100644
--- a/source/oxt/writer2xhtml/Options.xcs
+++ b/source/oxt/writer2xhtml/Options.xcs
@@ -81,6 +81,7 @@
             <!-- Table of contents -->
             <prop oor:name="ExternalTocDepth" oor:type="xs:short" />
             <prop oor:name="IncludeToc" oor:type="xs:boolean" />
+            <prop oor:name="IncludeNCX" oor:type="xs:boolean" />
             <!-- Configurations -->
             <set oor:name="Configurations" oor:node-type="Configuration" />
             <set oor:name="Templates" oor:node-type="Template" />			
diff --git a/source/oxt/writer2xhtml/Options.xcu b/source/oxt/writer2xhtml/Options.xcu
index 7bcadd7..ea387bc 100644
--- a/source/oxt/writer2xhtml/Options.xcu
+++ b/source/oxt/writer2xhtml/Options.xcu
@@ -130,6 +130,9 @@
         <prop oor:name="IncludeToc" oor:type="xs:boolean">
             <value>true</value>
         </prop>
+        <prop oor:name="IncludeNCX" oor:type="xs:boolean">
+            <value>true</value>
+        </prop>
     </node>
     <node oor:name="XhtmlOptionsCalc">
         <prop oor:name="Config" oor:type="xs:short">
diff --git a/source/oxt/writer2xhtml/W2XDialogs2/EpubMetadata.xdl b/source/oxt/writer2xhtml/W2XDialogs2/EpubMetadata.xdl
index d4f13ec..c62f1b1 100644
--- a/source/oxt/writer2xhtml/W2XDialogs2/EpubMetadata.xdl
+++ b/source/oxt/writer2xhtml/W2XDialogs2/EpubMetadata.xdl
@@ -34,7 +34,6 @@
   <dlg:button dlg:id="DeleteAuthorButton" dlg:tab-index="9" dlg:left="100" dlg:top="100" dlg:width="40" dlg:height="12" dlg:value="Delete...">
    <script:event script:event-name="on-mouseup" script:macro-name="vnd.sun.star.UNO:AuthorDeleteClick" script:language="UNO"/>
   </dlg:button>
-  <dlg:button dlg:id="CommandButton1" dlg:tab-index="32" dlg:left="149" dlg:top="-11" dlg:width="8" dlg:height="0" dlg:value="CommandButton1"/>
   <dlg:text dlg:id="DatesLabel" dlg:tab-index="33" dlg:left="5" dlg:top="116" dlg:width="165" dlg:height="12" dlg:value="Dates"/>
   <dlg:menulist dlg:id="Dates" dlg:tab-index="12" dlg:left="10" dlg:top="128" dlg:width="130" dlg:height="36"/>
   <dlg:button dlg:id="AddDateButton" dlg:tab-index="13" dlg:left="10" dlg:top="166" dlg:width="40" dlg:height="12" dlg:value="Add...">
diff --git a/source/oxt/writer2xhtml/W2XDialogs2/EpubOptions.xdl b/source/oxt/writer2xhtml/W2XDialogs2/EpubOptions.xdl
index ac0dfc8..e6e119a 100755
--- a/source/oxt/writer2xhtml/W2XDialogs2/EpubOptions.xdl
+++ b/source/oxt/writer2xhtml/W2XDialogs2/EpubOptions.xdl
@@ -16,30 +16,7 @@
   <dlg:text dlg:id="ScalingPercentLabel" dlg:tab-index="5" dlg:left="155" dlg:top="36" dlg:width="10" dlg:height="12" dlg:value="%"/>
   <dlg:text dlg:id="ColumnScalingLabel" dlg:tab-index="6" dlg:left="10" dlg:top="50" dlg:width="100" dlg:height="12" dlg:value="Column scaling"/>
   <dlg:numericfield dlg:id="ColumnScaling" dlg:tab-index="7" dlg:left="120" dlg:top="48" dlg:width="30" dlg:height="12" dlg:help-url="org.openoffice.da.writer2xhtml.oxt:EpubOptionsColumnScaling" dlg:strict-format="true" dlg:decimal-accuracy="0" dlg:value="100" dlg:value-min="1" dlg:value-max="1000" dlg:value-step="10" dlg:spin="true"/>
-  <dlg:text dlg:id="ColumnScalingPercentLabel" dlg:tab-index="29" dlg:left="155" dlg:top="50" dlg:width="10" dlg:height="12" dlg:value="%"/>
-  <dlg:checkbox dlg:id="ConvertToPx" dlg:tab-index="12" dlg:left="10" dlg:top="120" dlg:width="155" dlg:height="12" dlg:help-url="org.openoffice.da.writer2xhtml.oxt:EpubOptionsConvertToPx" dlg:value="Convert units to px (pixels)" dlg:checked="true"/>
-  <dlg:text dlg:id="SpecialContentLabel" dlg:tab-index="30" dlg:left="185" dlg:top="8" dlg:width="160" dlg:height="12" dlg:value="Special content"/>
-  <dlg:checkbox dlg:id="Notes" dlg:tab-index="18" dlg:left="190" dlg:top="36" dlg:width="155" dlg:height="12" dlg:help-url="org.openoffice.da.writer2xhtml.oxt:EpubOptionsNotes" dlg:value="Export notes" dlg:checked="true"/>
-  <dlg:text dlg:id="AutoCorrectLabel" dlg:tab-index="31" dlg:left="5" dlg:top="148" dlg:width="160" dlg:height="12" dlg:value="AutoCorrect"/>
-  <dlg:checkbox dlg:id="IgnoreHardLineBreaks" dlg:tab-index="14" dlg:left="10" dlg:top="162" dlg:width="155" dlg:height="12" dlg:help-url="org.openoffice.da.writer2xhtml.oxt:EpubOptionsIgnoreHardLineBreaks" dlg:value="Ignore hard line breaks" dlg:checked="false"/>
-  <dlg:checkbox dlg:id="IgnoreEmptyParagraphs" dlg:tab-index="15" dlg:left="10" dlg:top="176" dlg:width="155" dlg:height="12" dlg:help-url="org.openoffice.da.writer2xhtml.oxt:EpubOptionsIgnoreEmptyParagraphs" dlg:value="Ignore empty paragraphs" dlg:checked="false"/>
-  <dlg:checkbox dlg:id="IgnoreDoubleSpaces" dlg:tab-index="16" dlg:left="10" dlg:top="190" dlg:width="155" dlg:height="15" dlg:help-url="org.openoffice.da.writer2xhtml.oxt:EpubOptionsIgnoreDoubleSpaces" dlg:value="Ignore double spaces" dlg:checked="false"/>
-  <dlg:text dlg:id="SplitLevelLabel" dlg:tab-index="33" dlg:left="190" dlg:top="78" dlg:width="90" dlg:height="12" dlg:value="At heading level"/>
-  <dlg:menulist dlg:id="SplitLevel" dlg:tab-index="20" dlg:left="285" dlg:top="76" dlg:width="60" dlg:height="12" dlg:help-url="org.openoffice.da.writer2xhtml.oxt:EpubOptionsSplitLevel" dlg:spin="true" dlg:linecount="7">
-   <dlg:menupopup>
-    <dlg:menuitem dlg:value="None"/>
-    <dlg:menuitem dlg:value="1"/>
-    <dlg:menuitem dlg:value="2"/>
-    <dlg:menuitem dlg:value="3"/>
-    <dlg:menuitem dlg:value="4"/>
-    <dlg:menuitem dlg:value="5"/>
-    <dlg:menuitem dlg:value="6"/>
-   </dlg:menupopup>
-  </dlg:menulist>
-  <dlg:button dlg:id="ExportButton" dlg:tab-index="34" dlg:left="5" dlg:top="230" dlg:width="55" dlg:height="12" dlg:value="Export" dlg:button-type="ok"/>
-  <dlg:button dlg:id="CancelButton" dlg:tab-index="35" dlg:left="70" dlg:top="230" dlg:width="55" dlg:height="12" dlg:value="Cancel" dlg:button-type="cancel"/>
-  <dlg:button dlg:id="HelpButton" dlg:tab-index="36" dlg:left="290" dlg:top="230" dlg:width="55" dlg:height="12" dlg:value="Help" dlg:help-url="org.openoffice.da.writer2xhtml.oxt:EpubOptions" dlg:button-type="help"/>
-  <dlg:fixedline dlg:id="FixedLine1" dlg:tab-index="37" dlg:left="175" dlg:top="9" dlg:width="2" dlg:height="190" dlg:value="" dlg:align="vertical"/>
+  <dlg:text dlg:id="ColumnScalingPercentLabel" dlg:tab-index="38" dlg:left="155" dlg:top="50" dlg:width="10" dlg:height="12" dlg:value="%"/>
   <dlg:checkbox dlg:id="RelativeFontSize" dlg:tab-index="8" dlg:left="10" dlg:top="64" dlg:width="155" dlg:height="12" dlg:help-url="org.openoffice.da.writer2xhtml.oxt:EpubOptionsRelativeFontSize" dlg:value="Use relative font size" dlg:checked="true">
    <script:event script:event-name="on-itemstatechange" script:macro-name="vnd.sun.star.UNO:RelativeFontSizeChange" script:language="UNO"/>
   </dlg:checkbox>
@@ -51,9 +28,37 @@
   </dlg:checkbox>
   <dlg:text dlg:id="DefaultFontNameLabel" dlg:tab-index="40" dlg:left="19" dlg:top="106" dlg:width="50" dlg:height="12" dlg:value="Font name"/>
   <dlg:combobox dlg:id="DefaultFontName" dlg:tab-index="11" dlg:left="75" dlg:top="104" dlg:width="90" dlg:height="12" dlg:help-url="org.openoffice.da.writer2xhtml.oxt:EpubOptionsDefaultFontName" dlg:spin="true"/>
+  <dlg:checkbox dlg:id="ConvertToPx" dlg:tab-index="12" dlg:left="10" dlg:top="120" dlg:width="155" dlg:height="12" dlg:help-url="org.openoffice.da.writer2xhtml.oxt:EpubOptionsConvertToPx" dlg:value="Convert units to px (pixels)" dlg:checked="true"/>
+  <dlg:text dlg:id="ImageSizeLabel" dlg:tab-index="45" dlg:left="10" dlg:top="134" dlg:width="60" dlg:height="12" dlg:value="Image size"/>
+  <dlg:menulist dlg:id="ImageSize" dlg:tab-index="13" dlg:left="75" dlg:top="132" dlg:width="90" dlg:height="12" dlg:help-url="org.openoffice.da.writer2xhtml.oxt:EpubOptionsImageSize" dlg:spin="true" dlg:linecount="3">
+   <dlg:menupopup>
+    <dlg:menuitem dlg:value="Use absolute size"/>
+    <dlg:menuitem dlg:value="Use relative size (%)"/>
+    <dlg:menuitem dlg:value="Use original image size"/>
+   </dlg:menupopup>
+  </dlg:menulist>
+  <dlg:text dlg:id="AutoCorrectLabel" dlg:tab-index="30" dlg:left="5" dlg:top="148" dlg:width="160" dlg:height="12" dlg:value="AutoCorrect"/>
+  <dlg:checkbox dlg:id="IgnoreHardLineBreaks" dlg:tab-index="14" dlg:left="10" dlg:top="162" dlg:width="155" dlg:height="12" dlg:help-url="org.openoffice.da.writer2xhtml.oxt:EpubOptionsIgnoreHardLineBreaks" dlg:value="Ignore hard line breaks" dlg:checked="false"/>
+  <dlg:checkbox dlg:id="IgnoreEmptyParagraphs" dlg:tab-index="15" dlg:left="10" dlg:top="176" dlg:width="155" dlg:height="12" dlg:help-url="org.openoffice.da.writer2xhtml.oxt:EpubOptionsIgnoreEmptyParagraphs" dlg:value="Ignore empty paragraphs" dlg:checked="false"/>
+  <dlg:checkbox dlg:id="IgnoreDoubleSpaces" dlg:tab-index="16" dlg:left="10" dlg:top="190" dlg:width="155" dlg:height="15" dlg:help-url="org.openoffice.da.writer2xhtml.oxt:EpubOptionsIgnoreDoubleSpaces" dlg:value="Ignore double spaces" dlg:checked="false"/>
+  <dlg:text dlg:id="SpecialContentLabel" dlg:tab-index="29" dlg:left="185" dlg:top="8" dlg:width="160" dlg:height="12" dlg:value="Special content"/>
   <dlg:checkbox dlg:id="DisplayHiddenText" dlg:tab-index="17" dlg:left="190" dlg:top="22" dlg:width="155" dlg:height="12" dlg:help-url="org.openoffice.da.writer2xhtml.oxt:EpubOptionsDisplayHiddenText" dlg:value="Display hidden text" dlg:checked="false"/>
-  <dlg:text dlg:id="PageBreakSplitLabel" dlg:tab-index="41" dlg:left="190" dlg:top="92" dlg:width="90" dlg:height="12" dlg:value="At page breaks"/>
-  <dlg:menulist dlg:id="PageBreakSplit" dlg:tab-index="21" dlg:left="285" dlg:top="90" dlg:width="60" dlg:height="12" dlg:help-url="org.openoffice.da.writer2xhtml.oxt:EpubOptionsPageBreakSplit" dlg:spin="true" dlg:linecount="4">
+  <dlg:checkbox dlg:id="Notes" dlg:tab-index="18" dlg:left="190" dlg:top="36" dlg:width="155" dlg:height="12" dlg:help-url="org.openoffice.da.writer2xhtml.oxt:EpubOptionsNotes" dlg:value="Export notes" dlg:checked="true"/>
+  <dlg:text dlg:id="DocumentDivisionLabel" dlg:tab-index="31" dlg:left="185" dlg:top="50" dlg:width="160" dlg:height="12" dlg:value="Document division (page breaks)"/>
+  <dlg:text dlg:id="SplitLevelLabel" dlg:tab-index="32" dlg:left="190" dlg:top="64" dlg:width="90" dlg:height="12" dlg:value="At heading level"/>
+  <dlg:menulist dlg:id="SplitLevel" dlg:tab-index="19" dlg:left="285" dlg:top="62" dlg:width="60" dlg:height="12" dlg:help-url="org.openoffice.da.writer2xhtml.oxt:EpubOptionsSplitLevel" dlg:spin="true" dlg:linecount="7">
+   <dlg:menupopup>
+    <dlg:menuitem dlg:value="None"/>
+    <dlg:menuitem dlg:value="1"/>
+    <dlg:menuitem dlg:value="2"/>
+    <dlg:menuitem dlg:value="3"/>
+    <dlg:menuitem dlg:value="4"/>
+    <dlg:menuitem dlg:value="5"/>
+    <dlg:menuitem dlg:value="6"/>
+   </dlg:menupopup>
+  </dlg:menulist>
+  <dlg:text dlg:id="PageBreakSplitLabel" dlg:tab-index="41" dlg:left="190" dlg:top="78" dlg:width="90" dlg:height="12" dlg:value="At page breaks"/>
+  <dlg:menulist dlg:id="PageBreakSplit" dlg:tab-index="20" dlg:left="285" dlg:top="76" dlg:width="60" dlg:height="12" dlg:help-url="org.openoffice.da.writer2xhtml.oxt:EpubOptionsPageBreakSplit" dlg:spin="true" dlg:linecount="4">
    <dlg:menupopup>
     <dlg:menuitem dlg:value="None"/>
     <dlg:menuitem dlg:value="Defined by styles"/>
@@ -61,14 +66,21 @@
     <dlg:menuitem dlg:value="All"/>
    </dlg:menupopup>
   </dlg:menulist>
-  <dlg:checkbox dlg:id="IncludeToc" dlg:tab-index="28" dlg:left="190" dlg:top="204" dlg:width="155" dlg:height="12" dlg:help-url="org.openoffice.da.writer2xhtml.oxt:EpubOptionsIncludeToc" dlg:value="Also include original table of contents" dlg:checked="false"/>
-  <dlg:checkbox dlg:id="UseSplitAfter" dlg:tab-index="25" dlg:left="190" dlg:top="148" dlg:width="155" dlg:height="12" dlg:help-url="org.openoffice.da.writer2xhtml.oxt:EpubOptionsUseEpubAutoSplit" dlg:value="Automatic split of long documents" dlg:checked="false">
+  <dlg:text dlg:id="ImageSplitLabel" dlg:tab-index="46" dlg:left="199" dlg:top="106" dlg:width="90" dlg:height="12" dlg:value="Minimum width"/>
+  <dlg:checkbox dlg:id="UseImageSplit" dlg:tab-index="21" dlg:left="190" dlg:top="92" dlg:width="155" dlg:height="12" dlg:help-url="org.openoffice.da.writer2xhtml.oxt:EpubOptionsUseImageSplit" dlg:value="Use full screen for large images" dlg:checked="false">
+   <script:event script:event-name="on-itemstatechange" script:macro-name="vnd.sun.star.UNO:UseImageSplitChange" script:language="UNO"/>
+  </dlg:checkbox>
+  <dlg:numericfield dlg:id="ImageSplit" dlg:tab-index="22" dlg:left="300" dlg:top="104" dlg:width="30" dlg:height="12" dlg:help-url="org.openoffice.da.writer2xhtml.oxt:EpubOptionsImageSplit" dlg:strict-format="true" dlg:decimal-accuracy="0" dlg:value="100" dlg:value-min="0" dlg:value-max="100" dlg:spin="true"/>
+  <dlg:text dlg:id="ImageSplitPercentLabel" dlg:tab-index="47" dlg:left="335" dlg:top="104" dlg:width="10" dlg:height="12" dlg:value="%"/>
+  <dlg:checkbox dlg:id="CoverImage" dlg:tab-index="23" dlg:left="190" dlg:top="120" dlg:width="155" dlg:height="12" dlg:help-url="org.openoffice.da.writer2xhtml.oxt:EpubOptionsCoverImage" dlg:value="Use first image as cover image" dlg:checked="false"/>
+  <dlg:checkbox dlg:id="UseSplitAfter" dlg:tab-index="24" dlg:left="190" dlg:top="134" dlg:width="155" dlg:height="12" dlg:help-url="org.openoffice.da.writer2xhtml.oxt:EpubOptionsUseEpubAutoSplit" dlg:value="Automatic split of long documents" dlg:checked="false">
    <script:event script:event-name="on-itemstatechange" script:macro-name="vnd.sun.star.UNO:UseSplitAfterChange" script:language="UNO"/>
   </dlg:checkbox>
-  <dlg:text dlg:id="SplitAfterLabel" dlg:tab-index="42" dlg:left="199" dlg:top="162" dlg:width="90" dlg:height="12" dlg:value="After (in 1000 characters)"/>
-  <dlg:numericfield dlg:id="SplitAfter" dlg:tab-index="26" dlg:left="300" dlg:top="160" dlg:width="45" dlg:height="12" dlg:help-url="org.openoffice.da.writer2xhtml.oxt:EpubOptionsEpubAutoSplit" dlg:strict-format="true" dlg:decimal-accuracy="0" dlg:value-min="10" dlg:value-max="1000" dlg:value-step="10" dlg:spin="true"/>
-  <dlg:text dlg:id="ExternalTocDepthLabel" dlg:tab-index="43" dlg:left="190" dlg:top="190" dlg:width="100" dlg:height="12" dlg:value="Number of heading levels to include"/>
-  <dlg:menulist dlg:id="ExternalTocDepth" dlg:tab-index="27" dlg:left="300" dlg:top="188" dlg:width="45" dlg:height="12" dlg:help-url="org.openoffice.da.writer2xhtml.oxt:EpubOptionsExternalTocDepth" dlg:spin="true" dlg:linecount="10">
+  <dlg:text dlg:id="SplitAfterLabel" dlg:tab-index="42" dlg:left="199" dlg:top="148" dlg:width="90" dlg:height="12" dlg:value="After (in 1000 characters)"/>
+  <dlg:numericfield dlg:id="SplitAfter" dlg:tab-index="25" dlg:left="300" dlg:top="156" dlg:width="45" dlg:height="12" dlg:help-url="org.openoffice.da.writer2xhtml.oxt:EpubOptionsEpubAutoSplit" dlg:strict-format="true" dlg:decimal-accuracy="0" dlg:value-min="10" dlg:value-max="1000" dlg:value-step="10" dlg:spin="true"/>
+  <dlg:text dlg:id="TocLabel" dlg:tab-index="44" dlg:left="185" dlg:top="162" dlg:width="160" dlg:height="12" dlg:value="Navigation table"/>
+  <dlg:text dlg:id="ExternalTocDepthLabel" dlg:tab-index="43" dlg:left="190" dlg:top="174" dlg:width="100" dlg:height="12" dlg:value="Number of heading levels to include"/>
+  <dlg:menulist dlg:id="ExternalTocDepth" dlg:tab-index="26" dlg:left="300" dlg:top="174" dlg:width="45" dlg:height="12" dlg:help-url="org.openoffice.da.writer2xhtml.oxt:EpubOptionsExternalTocDepth" dlg:spin="true" dlg:linecount="10">
    <dlg:menupopup>
     <dlg:menuitem dlg:value="1"/>
     <dlg:menuitem dlg:value="2"/>
@@ -82,25 +94,15 @@
     <dlg:menuitem dlg:value="10"/>
    </dlg:menupopup>
   </dlg:menulist>
-  <dlg:text dlg:id="TocLabel" dlg:tab-index="44" dlg:left="185" dlg:top="176" dlg:width="160" dlg:height="12" dlg:value="Navigation table"/>
-  <dlg:text dlg:id="DocumentDivisionLabel" dlg:tab-index="32" dlg:left="185" dlg:top="64" dlg:width="160" dlg:height="12" dlg:value="Document division (page breaks)"/>
-  <dlg:button dlg:id="EditMetadata" dlg:tab-index="19" dlg:left="190" dlg:top="48" dlg:width="100" dlg:height="12" dlg:help-url="org.openoffice.da.writer2xhtml.oxt:EpubOptionsEditMetadata" dlg:value="Edit document properties">
+  <dlg:checkbox dlg:id="IncludeToc" dlg:tab-index="27" dlg:left="190" dlg:top="190" dlg:width="155" dlg:height="12" dlg:help-url="org.openoffice.da.writer2xhtml.oxt:EpubOptionsIncludeToc" dlg:value="Also include original table of contents" dlg:checked="false"/>
+  <dlg:checkbox dlg:id="IncludeNCX" dlg:tab-index="28" dlg:left="190" dlg:top="204" dlg:width="155" dlg:height="12" dlg:help-url="org.openoffice.da.writer2xhtml.oxt:EpubOptionsIncludeToc" dlg:value="Include EPUB 2 navigation" dlg:checked="false"/>
+  <dlg:button dlg:id="ExportButton" dlg:tab-index="33" dlg:left="5" dlg:top="230" dlg:width="55" dlg:height="12" dlg:value="Export" dlg:button-type="ok"/>
+  <dlg:button dlg:id="CancelButton" dlg:tab-index="34" dlg:left="70" dlg:top="230" dlg:width="55" dlg:height="12" dlg:value="Cancel" dlg:button-type="cancel"/>
+  <dlg:button dlg:id="EditMetadata" dlg:tab-index="35" dlg:left="135" dlg:top="230" dlg:width="100" dlg:height="12" dlg:help-url="org.openoffice.da.writer2xhtml.oxt:EpubOptionsEditMetadata" dlg:value="Edit document properties">
    <script:event script:event-name="on-mouseup" script:macro-name="vnd.sun.star.UNO:EditMetadataClick" script:language="UNO"/>
   </dlg:button>
-  <dlg:text dlg:id="ImageSizeLabel" dlg:tab-index="45" dlg:left="10" dlg:top="134" dlg:width="60" dlg:height="12" dlg:value="Image size"/>
-  <dlg:menulist dlg:id="ImageSize" dlg:tab-index="13" dlg:left="75" dlg:top="132" dlg:width="90" dlg:height="12" dlg:help-url="org.openoffice.da.writer2xhtml.oxt:EpubOptionsImageSize" dlg:spin="true" dlg:linecount="3">
-   <dlg:menupopup>
-    <dlg:menuitem dlg:value="Use absolute size"/>
-    <dlg:menuitem dlg:value="Use relative size (%)"/>
-    <dlg:menuitem dlg:value="Use original image size"/>
-   </dlg:menupopup>
-  </dlg:menulist>
-  <dlg:checkbox dlg:id="UseImageSplit" dlg:tab-index="22" dlg:left="190" dlg:top="106" dlg:width="155" dlg:height="12" dlg:help-url="org.openoffice.da.writer2xhtml.oxt:EpubOptionsUseImageSplit" dlg:value="Use full screen for large images" dlg:checked="false">
-   <script:event script:event-name="on-itemstatechange" script:macro-name="vnd.sun.star.UNO:UseImageSplitChange" script:language="UNO"/>
-  </dlg:checkbox>
-  <dlg:text dlg:id="ImageSplitLabel" dlg:tab-index="46" dlg:left="199" dlg:top="120" dlg:width="90" dlg:height="12" dlg:value="Minimum width"/>
-  <dlg:text dlg:id="ImageSplitPercentLabel" dlg:tab-index="47" dlg:left="335" dlg:top="120" dlg:width="10" dlg:height="12" dlg:value="%"/>
-  <dlg:numericfield dlg:id="ImageSplit" dlg:tab-index="23" dlg:left="300" dlg:top="118" dlg:width="30" dlg:height="12" dlg:help-url="org.openoffice.da.writer2xhtml.oxt:EpubOptionsImageSplit" dlg:strict-format="true" dlg:decimal-accuracy="0" dlg:value="100" dlg:value-min="0" dlg:value-max="100" dlg:spin="true"/>
-  <dlg:checkbox dlg:id="CoverImage" dlg:tab-index="24" dlg:left="190" dlg:top="134" dlg:width="155" dlg:height="12" dlg:help-url="org.openoffice.da.writer2xhtml.oxt:EpubOptionsCoverImage" dlg:value="Use first image as cover image" dlg:checked="false"/>
+  <dlg:button dlg:id="HelpButton" dlg:tab-index="36" dlg:left="290" dlg:top="230" dlg:width="55" dlg:height="12" dlg:value="Help" dlg:help-url="org.openoffice.da.writer2xhtml.oxt:EpubOptions" dlg:button-type="help"/>
+
+  <dlg:fixedline dlg:id="FixedLine1" dlg:tab-index="37" dlg:left="175" dlg:top="9" dlg:width="2" dlg:height="204" dlg:value="" dlg:align="vertical"/>
  </dlg:bulletinboard>
 </dlg:window>
\ No newline at end of file