diff --git a/source/distro/changelog.txt b/source/distro/changelog.txt
index 9dc7d0b..13437f2 100644
--- a/source/distro/changelog.txt
+++ b/source/distro/changelog.txt
@@ -2,6 +2,24 @@ Changelog for Writer2LaTeX version 1.2 -> 1.4
---------- version 1.3.2 alpha ----------
+[w2x] Two or more span elements in a row with identical attributes are now merged
+
+[all] Filters: Appended [Writer2LaTeX] or [Writer2xhtml] to all filter UI names to make them more visible
+
+[w2l] Bugfix: Avoid null pointer exception caused by list styles in some cases
+
+[w2x] Bugfix: EPUB export filter works again (was broken in 1.3.1)
+
+[w2x] Bugfix: Text boxes are no longer lost if within a paragraph
+
+[w2x] SVG support in HTML5 is now finished: Vector graphics is converted to SVG (does not work in older versions of LO).
+ The option use_svg has been renamed to inline_svg. If set to true (default) inline SVG is used, if set to false,
+ external SVG-files are used.
+
+[all] If an image image cannot be converted to an acceptable format, the optional alternative image will now be tried
+
+[all] Bugfix: Avoid null pointer exception if a table has no defined table width
+
[w2l] Bugfix (StarMath conversion): Protect the character [ after \\ in gather and matrix environments
[w2l] Bugfix: Protect the character [ after \\ in tables
@@ -29,7 +47,7 @@ Changelog for Writer2LaTeX version 1.2 -> 1.4
the option xslt_path has been removed. Also the vacant spot in the export dialog is now used for the option use_mathjax
(only active for XHTML+MathML and HTML5)
-[w2l] Added support for TexMaths equations in LaTeX, XHTML+MathML and HTML5 (the last two only if use_mathjax=true)
+[all] Added support for TexMaths equations in LaTeX, XHTML+MathML and HTML5 (the last two only if use_mathjax=true)
[all] The command line application now gives an explanation if the source file is not in ODF format
diff --git a/source/distro/doc/user-manual.odt b/source/distro/doc/user-manual.odt
index a4117a6..facaf65 100644
Binary files a/source/distro/doc/user-manual.odt and b/source/distro/doc/user-manual.odt differ
diff --git a/source/java/org/openoffice/da/comp/w2lcommon/filter/GraphicConverterImpl1.java b/source/java/org/openoffice/da/comp/w2lcommon/filter/GraphicConverterImpl1.java
index 204d048..f3db9c3 100644
--- a/source/java/org/openoffice/da/comp/w2lcommon/filter/GraphicConverterImpl1.java
+++ b/source/java/org/openoffice/da/comp/w2lcommon/filter/GraphicConverterImpl1.java
@@ -16,11 +16,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
- * Copyright: 2002-2012 by Henrik Just
+ * Copyright: 2002-2014 by Henrik Just
*
* All Rights Reserved.
*
- * Version 1.4 (2012-04-03)
+ * Version 1.4 (2014-09-05)
*/
@@ -76,9 +76,8 @@ public class GraphicConverterImpl1 implements GraphicConverter {
// We don't support cropping and resizing
if (bCrop || bResize) { return false; }
- // We can convert vector formats to EPS.
- // The IDL reference claims we can convert to SVG too, but for some reason this always returns an empty array?
- if ((MIMETypes.EPS.equals(sTargetMime)) && // || MIMETypes.SVG.equals(sTargetMime)) &&
+ // We can convert vector formats to EPS and SVG
+ if ((MIMETypes.EPS.equals(sTargetMime) || MIMETypes.SVG.equals(sTargetMime)) &&
(MIMETypes.EMF.equals(sSourceMime) || MIMETypes.WMF.equals(sSourceMime) || MIMETypes.SVM.equals(sSourceMime))) {
return true;
}
@@ -133,7 +132,10 @@ public class GraphicConverterImpl1 implements GraphicConverter {
}
else {
byte[] converted = xTarget.getBuffer();
- return converted;
+ if (converted.length>0) { // Older versions of AOO/LO fails to convert to SVG (empty result)
+ return converted;
+ }
+ return null;
}
}
catch (com.sun.star.io.IOException e) {
diff --git a/source/java/writer2latex/api/ConverterFactory.java b/source/java/writer2latex/api/ConverterFactory.java
index 2772c9d..907cf60 100644
--- a/source/java/writer2latex/api/ConverterFactory.java
+++ b/source/java/writer2latex/api/ConverterFactory.java
@@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
- * Version 1.4 (2014-09-03)
+ * Version 1.4 (2014-09-06)
*
*/
@@ -33,7 +33,7 @@ public class ConverterFactory {
// Version information
private static final String VERSION = "1.3.2";
- private static final String DATE = "2014-09-03";
+ private static final String DATE = "2014-09-06";
/** Return the Writer2LaTeX version in the form
* (major version).(minor version).(patch level)
diff --git a/source/java/writer2latex/base/BinaryGraphicsDocument.java b/source/java/writer2latex/base/BinaryGraphicsDocument.java
index 2af92c3..20710ec 100644
--- a/source/java/writer2latex/base/BinaryGraphicsDocument.java
+++ b/source/java/writer2latex/base/BinaryGraphicsDocument.java
@@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
- * Version 1.4 (2014-09-03)
+ * Version 1.4 (2014-09-05)
*
*/
@@ -30,7 +30,6 @@ import java.io.OutputStream;
import java.io.IOException;
import writer2latex.api.OutputFile;
-import writer2latex.util.Misc;
/** This class is used to represent a binary graphics document to be included in the converter result.
@@ -40,37 +39,55 @@ import writer2latex.util.Misc;
public class BinaryGraphicsDocument implements OutputFile {
private String sFileName;
- private String sFileExtension;
private String sMimeType;
- private boolean bIsLinked = false;
- private boolean bIsAcceptedFormat = false;
+ private boolean bAcceptedFormat;
+
+ private boolean bRecycled = false;
// Data for an embedded image
private byte[] blob = null;
- private int nOff;
- private int nLen;
+ private int nOff = 0;
+ private int nLen = 0;
- // Data for a linked image
- private String sURL = null;
-
/**Constructs a new graphics document.
- * This new document does not contain any data. Document data must
- * be added using the appropriate methods.
+ * Until data is added using the read
methods, the document is considered a link to
+ * the image given by the file name.
*
- * @param sName The name of the GraphicsDocument
.
- * @param sFileExtension the file extension
+ * @param sFileName The name or URL of the GraphicsDocument
.
* @param sMimeType the MIME type of the document
*/
- public BinaryGraphicsDocument(String sName, String sFileExtension, String sMimeType) {
- this.sFileExtension = sFileExtension;
+ public BinaryGraphicsDocument(String sFileName, String sMimeType) {
+ this.sFileName = sFileName;
this.sMimeType = sMimeType;
- sFileName = Misc.trimDocumentName(sName, sFileExtension);
+ bAcceptedFormat = false; // or rather "don't know"
}
-
+
+ /** Construct a new graphics document which is a recycled version of the supplied one.
+ * This implies that all information is identical, but the recycled version does not contain any data.
+ * This is for images that are used more than once in the document.
+ *
+ * @param bgd the source document
+ */
+ public BinaryGraphicsDocument(BinaryGraphicsDocument bgd) {
+ this.sFileName = bgd.getFileName();
+ this.sMimeType = bgd.getMIMEType();
+ this.bAcceptedFormat = bgd.isAcceptedFormat();
+ this.bRecycled = true;
+ }
+
+ /** Is this graphics document recycled?
+ *
+ * @return true if this is the case
+ */
+ public boolean isRecycled() {
+ return bRecycled;
+ }
+
/** Set image contents to a byte array
*
* @param data the image data
+ * @param bIsAcceptedFormat flag to indicate that the format of the image is acceptable for the converter
*/
public void setData(byte[] data, boolean bIsAcceptedFormat) {
setData(data,0,data.length,bIsAcceptedFormat);
@@ -87,30 +104,7 @@ public class BinaryGraphicsDocument implements OutputFile {
this.blob = data;
this.nOff = nOff;
this.nLen = nLen;
- this.bIsAcceptedFormat = bIsAcceptedFormat;
- this.bIsLinked = false;
- this.sURL = null;
- }
-
- /** Set the URL of a linked image
- *
- * @param sURL the URL
- */
- public void setURL(String sURL) {
- this.blob = null;
- this.nOff = 0;
- this.nLen = 0;
- this.bIsAcceptedFormat = false; // or rather don't know
- this.bIsLinked = true;
- this.sURL = sURL;
- }
-
- /** Get the URL of a linked image
- *
- * @return the URL or null if this is an embedded image
- */
- public String getURL() {
- return sURL;
+ this.bAcceptedFormat = bIsAcceptedFormat;
}
/** Does this BinaryGraphicsDocument
represent a linked image?
@@ -118,7 +112,7 @@ public class BinaryGraphicsDocument implements OutputFile {
* @return true if so
*/
public boolean isLinked() {
- return bIsLinked;
+ return blob==null && !bRecycled;
}
/** Is this image in an acceptable format for the converter?
@@ -126,9 +120,13 @@ public class BinaryGraphicsDocument implements OutputFile {
* @return true if so (always returns false for linked images)
*/
public boolean isAcceptedFormat() {
- return bIsAcceptedFormat;
+ return bAcceptedFormat;
}
+ /** Get the data of the image
+ *
+ * @return the image data as a byte array - or null if this is a linked image
+ */
public byte[] getData() {
return blob;
}
@@ -148,20 +146,12 @@ public class BinaryGraphicsDocument implements OutputFile {
}
}
- /** Get the file extension
- *
- * @return the file extension
- */
- public String getFileExtension() {
- return sFileExtension;
- }
-
- /** Get the document with file extension.
ImageConverter
referring to a specific document
*
@@ -159,17 +164,48 @@ public final class ImageConverter {
* or convert it to an accepted format
*/
public BinaryGraphicsDocument getImage(Element node) {
+ String sName = sSubDirName+sBaseFileName+formatter.format(++nImageCount);
+ BinaryGraphicsDocument bgd = getImage(node,sName);
+ if (bgd!=null) {
+ if (!bgd.isAcceptedFormat()) { // We may have better luck with an alternative image
+ Element sibling = getAlternativeImage(node);
+ if (sibling!=null) {
+ BinaryGraphicsDocument altBgd = getImage(sibling,sName);
+ if (altBgd!=null && altBgd.isAcceptedFormat()) {
+ bgd = altBgd;
+ }
+ }
+ }
+ }
+ if (bgd==null || bgd.isLinked() || bgd.isRecycled()) {
+ // The file name was not used
+ nImageCount--;
+ }
+ else if (node.hasAttribute(XMLString.XLINK_HREF)) {
+ // This is an embedded image we meet for the first time.
+ // Recycle it on behalf of the original image node.
+ String sHref = node.getAttribute(XMLString.XLINK_HREF);
+ recycledImages.put(sHref, new BinaryGraphicsDocument(bgd));
+ }
+ return bgd;
+ }
+
+ private BinaryGraphicsDocument getImage(Element node, String sName) {
assert(XMLString.DRAW_IMAGE.equals(node.getTagName()));
// Image data
+ String sExt = null;
String sMIME = null;
- String sExt = null;
byte[] blob = null;
// First try to extract the image using the xlink:href attribute
if (node.hasAttribute(XMLString.XLINK_HREF)) {
String sHref = node.getAttribute(XMLString.XLINK_HREF);
if (sHref.length()>0) {
+ // We may have seen this image before, return the recycled version
+ if (recycledImages.containsKey(sHref)) {
+ return recycledImages.get(sHref);
+ }
// Image may be embedded in package:
String sPath = sHref;
if (sPath.startsWith("#")) { sPath = sPath.substring(1); }
@@ -192,9 +228,9 @@ public final class ImageConverter {
else {
// This is a linked image
// TODO: Add option to download image from the URL?
+ String sFileName = ofr.fixRelativeLink(sHref);
BinaryGraphicsDocument bgd
- = new BinaryGraphicsDocument(Misc.getFileName(sHref),Misc.getFileExtension(sHref),null);
- bgd.setURL(ofr.fixRelativeLink(sHref));
+ = new BinaryGraphicsDocument(sFileName,null);
return bgd;
}
}
@@ -225,21 +261,22 @@ public final class ImageConverter {
}
}
- // We have an embedded image. Assign a name (without extension)
- String sName = sSubDirName+sBaseFileName+formatter.format(++nImageCount);
-
// Is this an EPS file embedded in an SVM file?
+ // (This case is obsolete, but kept for the sake of old documents)
if (bExtractEPS && MIMETypes.SVM.equals(sMIME)) {
// Look for postscript:
int[] offlen = new int[2];
if (SVMReader.readSVM(blob,offlen)) {
+ String sFileName = sName+MIMETypes.EPS_EXT;
BinaryGraphicsDocument bgd
- = new BinaryGraphicsDocument(sName,MIMETypes.EPS_EXT,MIMETypes.EPS);
+ = new BinaryGraphicsDocument(sFileName, MIMETypes.EPS);
bgd.setData(blob,offlen[0],offlen[1],true);
return bgd;
}
}
+ // We have an embedded image.
+
// If we have a converter AND a default format AND this image
// is not in an accepted format AND the converter knows how to
// convert it - try to convert...
@@ -264,10 +301,12 @@ public final class ImageConverter {
sExt = MIMETypes.getFileExtension(sMIME);
}
}
-
+
// Create the result
+
if (isAcceptedFormat(sMIME) || bAcceptOtherFormats) {
- BinaryGraphicsDocument bgd = new BinaryGraphicsDocument(sName,sExt,sMIME);
+ String sFileName = sName+sExt;
+ BinaryGraphicsDocument bgd = new BinaryGraphicsDocument(sFileName,sMIME);
bgd.setData(blob,isAcceptedFormat(sMIME));
return bgd;
}
@@ -276,4 +315,12 @@ public final class ImageConverter {
}
}
+ private Element getAlternativeImage(Element node) {
+ Node sibling = node.getNextSibling();
+ if (sibling!=null && Misc.isElement(sibling, XMLString.DRAW_IMAGE)) {
+ return (Element) sibling;
+ }
+ return null;
+ }
+
}
diff --git a/source/java/writer2latex/epub/EPUBConverter.java b/source/java/writer2latex/epub/EPUBConverter.java
index 5d1952c..a3f4950 100644
--- a/source/java/writer2latex/epub/EPUBConverter.java
+++ b/source/java/writer2latex/epub/EPUBConverter.java
@@ -16,11 +16,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
- * Copyright: 2001-2010 by Henrik Just
+ * Copyright: 2001-2014 by Henrik Just
*
* All Rights Reserved.
*
- * version 1.2 (2010-12-15)
+ * version 1.4 (2014-09-06)
*
*/
@@ -41,12 +41,22 @@ public final class EPUBConverter extends Xhtml11Converter {
// Constructor
public EPUBConverter() {
super();
+ System.out.println("Creating epub converter");
}
@Override public ConverterResult convert(InputStream is, String sTargetFileName) throws IOException {
setOPS(true);
ConverterResult xhtmlResult = super.convert(is, "chapter");
-
+ return createPackage(xhtmlResult,sTargetFileName);
+ }
+
+ @Override public ConverterResult convert(org.w3c.dom.Document dom, String sTargetFileName, boolean bDestructive) throws IOException {
+ setOPS(true);
+ ConverterResult xhtmlResult = super.convert(dom, "chapter", bDestructive);
+ return createPackage(xhtmlResult,sTargetFileName);
+ }
+
+ private ConverterResult createPackage(ConverterResult xhtmlResult, String sTargetFileName) {
ConverterResultImpl epubResult = new ConverterResultImpl();
epubResult.addDocument(new EPUBWriter(xhtmlResult,sTargetFileName,getXhtmlConfig()));
epubResult.setMetaData(xhtmlResult.getMetaData());
diff --git a/source/java/writer2latex/latex/DrawConverter.java b/source/java/writer2latex/latex/DrawConverter.java
index 5c34eb8..ec7c153 100644
--- a/source/java/writer2latex/latex/DrawConverter.java
+++ b/source/java/writer2latex/latex/DrawConverter.java
@@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
- * Version 1.4 (2014-09-03)
+ * Version 1.4 (2014-09-05)
*
*/
@@ -297,7 +297,7 @@ public class DrawConverter extends ConverterHelper {
BinaryGraphicsDocument bgd = palette.getImageCv().getImage(node);
if (bgd!=null) {
if (!bgd.isLinked()) { // embedded image
- palette.addDocument(bgd);
+ if (!bgd.isRecycled()) { palette.addDocument(bgd); }
sFileName = bgd.getFileName();
String sMIME = bgd.getMIMEType();
bCommentOut = !(
@@ -311,8 +311,8 @@ public class DrawConverter extends ConverterHelper {
(config.getBackend()==LaTeXConfig.DVIPS && MIMETypes.EPS.equals(sMIME)));
}
else { // linked image
- sFileName = bgd.getURL();
- String sExt = bgd.getFileExtension().toLowerCase();
+ sFileName = bgd.getFileName();
+ String sExt = Misc.getFileExtension(sFileName).toLowerCase();
// Accept only relative filenames and supported filetypes:
bCommentOut = sFileName.indexOf(":")>-1 || !(
config.getBackend()==LaTeXConfig.UNSPECIFIED ||
diff --git a/source/java/writer2latex/latex/ListStyleConverter.java b/source/java/writer2latex/latex/ListStyleConverter.java
index b99271a..d651af9 100644
--- a/source/java/writer2latex/latex/ListStyleConverter.java
+++ b/source/java/writer2latex/latex/ListStyleConverter.java
@@ -16,11 +16,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
- * Copyright: 2002-2012 by Henrik Just
+ * Copyright: 2002-2014 by Henrik Just
*
* All Rights Reserved.
*
- * Version 1.2 (2012-03-05)
+ * Version 1.4 (2014-09-06)
*
*/
@@ -94,7 +94,7 @@ public class ListStyleConverter extends StyleConverter {
if (config.formatting()==LaTeXConfig.CONVERT_BASIC ||
(config.formatting()>=LaTeXConfig.CONVERT_MOST && oc.isInTable())) {
if (oc.getListLevel()==1) {
- if (!styleNames.containsName(getDisplayName(oc.getListStyleName()))) {
+ if (!listStyleLevelNames.containsKey(oc.getListStyleName())) {
createListStyleLabels(oc.getListStyleName());
}
ba.add("\\liststyle"+styleNames.getExportName(getDisplayName(oc.getListStyleName()))+"\n","");
diff --git a/source/java/writer2latex/office/MIMETypes.java b/source/java/writer2latex/office/MIMETypes.java
index fd04572..f612517 100644
--- a/source/java/writer2latex/office/MIMETypes.java
+++ b/source/java/writer2latex/office/MIMETypes.java
@@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
- * Version 1.4 (2014-08-13)
+ * Version 1.4 (2014-09-05)
*
*/
@@ -69,6 +69,7 @@ public final class MIMETypes extends writer2latex.api.MIMETypes {
public static final String BIBTEX_EXT = ".bib";
public static final String XHTML_EXT = ".html";
public static final String XHTML_MATHML_EXT = ".xhtml";
+ public static final String HTML5_EXT = ".html";
public static final String PNG_EXT = ".png";
public static final String JPEG_EXT = ".jpg"; // this is the default in graphicx.sty
public static final String GIF_EXT = ".gif";
@@ -90,8 +91,8 @@ public final class MIMETypes extends writer2latex.api.MIMETypes {
}
private static final boolean isSVG(byte[] blob) {
- // Look for