EPUB 3 support

git-svn-id: svn://svn.code.sf.net/p/writer2latex/code/trunk@240 f0f2a975-2e09-46c8-9428-3b39399b9f3c
This commit is contained in:
henrikjust 2015-05-05 08:55:48 +00:00
parent d141619053
commit 9c99999ad1
16 changed files with 154 additions and 64 deletions

View file

@ -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-16)
* Version 1.6 (2015-05-05)
*
*/
@ -54,15 +54,19 @@ public class CssDocument implements OutputFile {
sContent = "";
}
public String getFileName() {
@Override public String getFileName() {
return sName;
}
public String getMIMEType() {
@Override public String getMIMEType() {
return "text/css";
}
public boolean isMasterDocument() {
@Override public boolean isMasterDocument() {
return false;
}
@Override public boolean containsMath() {
return false;
}

View file

@ -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-11-24)
* Version 1.6 (2015-05-05)
*
*/
@ -187,8 +187,8 @@ public class MathConverter extends ConverterHelper {
if (onode.hasAttribute("xmlns:math")) {
math.setAttribute("xmlns", onode.getAttribute("xmlns:math"));
}
else if (onode.hasAttribute("xmlns") && converter.nType!=XhtmlDocument.HTML5) {
// Don't include xmlns attribute in HTML5
else if (onode.hasAttribute("xmlns") && (converter.nType!=XhtmlDocument.HTML5 || converter.isOPS())) {
// Don't include xmlns attribute in HTML5, unless we are creating EPUB 3
math.setAttribute("xmlns", onode.getAttribute("xmlns"));
}
if (bAllowDisplay && onode.hasAttribute("display")) {

View file

@ -16,11 +16,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
* Copyright: 2002-2010 by Henrik Just
* Copyright: 2002-2015 by Henrik Just
*
* All Rights Reserved.
*
* Version 1.2 (2010-12-21)
* Version 1.5 (2015-05-05)
*
*/
@ -33,8 +33,7 @@ import java.io.OutputStream;
import writer2latex.api.OutputFile;
import writer2latex.util.Misc;
/**
* An implementation of <code>OutputFile</code> for resource documents.
/** An implementation of <code>OutputFile</code> for resource documents.
* (A resource document is an arbitrary binary file to include in the converter result)
*/
public class ResourceDocument implements OutputFile {
@ -55,22 +54,33 @@ public class ResourceDocument implements OutputFile {
content = new byte[0];
}
public String getFileName() {
// Implement OutputFile
@Override public String getFileName() {
return sFileName;
}
public String getMIMEType() {
@Override public String getMIMEType() {
return sMediaType;
}
public boolean isMasterDocument() {
@Override public boolean isMasterDocument() {
return false;
}
@Override public boolean containsMath() {
return false;
}
public void write(OutputStream os) throws IOException {
@Override public void write(OutputStream os) throws IOException {
os.write(content);
}
/** Load the resource document bytes from an arbitrary input stream
*
* @param is the input stream
* @throws IOException if any error occurs reading the input stream
*/
public void read(InputStream is) throws IOException {
content = Misc.inputStreamToByteArray(is);
}

View file

@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
* Version 1.6 (2015-04-21)
* Version 1.6 (2015-05-05)
*
*/
@ -302,6 +302,10 @@ public class XhtmlDocument extends DOMDocument {
return true;
}
@Override public boolean containsMath() {
return bodyNode!=null ? containsMath(bodyNode) : false;
}
public Element getHeadNode() { return headNode; }
public Element getBodyNode() { return bodyNode; }
@ -959,6 +963,25 @@ public class XhtmlDocument extends DOMDocument {
default: return null;
}
}
private boolean containsMath(Element node) {
// First check the node itself
if (node.getTagName().equals("math")) {
return true;
}
// The check the children
Node child = node.getFirstChild();
while (child!=null) {
if (child.getNodeType()==Node.ELEMENT_NODE) {
if (containsMath((Element)child)) {
return true;
}
}
child = child.getNextSibling();
}
// And then look no further
return false;
}
}