Some minor bugfixing, refactoring and rearrangement
git-svn-id: svn://svn.code.sf.net/p/writer2latex/code/trunk@165 f0f2a975-2e09-46c8-9428-3b39399b9f3c
This commit is contained in:
parent
8a6e654344
commit
6249ef406e
31 changed files with 146 additions and 288 deletions
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.4 (2014-08-13)
|
||||
* Version 1.4 (2014-08-26)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -248,22 +248,22 @@ public class Converter extends ConverterBase {
|
|||
l10n = new L10n();
|
||||
|
||||
if (isOPS()) {
|
||||
imageLoader.setBaseFileName("image");
|
||||
imageLoader.setUseSubdir("images");
|
||||
imageConverter.setBaseFileName("image");
|
||||
imageConverter.setUseSubdir("images");
|
||||
}
|
||||
else {
|
||||
imageLoader.setBaseFileName(sTargetFileName+"-img");
|
||||
imageConverter.setBaseFileName(sTargetFileName+"-img");
|
||||
if (config.saveImagesInSubdir()) {
|
||||
imageLoader.setUseSubdir(sTargetFileName+"-img");
|
||||
imageConverter.setUseSubdir(sTargetFileName+"-img");
|
||||
}
|
||||
}
|
||||
|
||||
imageLoader.setDefaultFormat(MIMETypes.PNG);
|
||||
imageLoader.addAcceptedFormat(MIMETypes.JPEG);
|
||||
imageLoader.addAcceptedFormat(MIMETypes.GIF);
|
||||
imageConverter.setDefaultFormat(MIMETypes.PNG);
|
||||
imageConverter.addAcceptedFormat(MIMETypes.JPEG);
|
||||
imageConverter.addAcceptedFormat(MIMETypes.GIF);
|
||||
|
||||
if (nType==XhtmlDocument.HTML5 && config.useSVG()) { // HTML supports (inline) SVG as well
|
||||
imageLoader.setDefaultVectorFormat(MIMETypes.SVG);
|
||||
imageConverter.setDefaultVectorFormat(MIMETypes.SVG);
|
||||
}
|
||||
|
||||
styleCv = new StyleConverter(ofr,config,this,nType);
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.4 (2014-08-20)
|
||||
* Version 1.4 (2014-08-26)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -59,7 +59,7 @@ import org.w3c.dom.Element;
|
|||
import writer2latex.util.Misc;
|
||||
import writer2latex.util.CSVList;
|
||||
import writer2latex.util.SimpleXMLParser;
|
||||
import writer2latex.xmerge.BinaryGraphicsDocument;
|
||||
import writer2latex.base.BinaryGraphicsDocument;
|
||||
import writer2latex.office.EmbeddedObject;
|
||||
import writer2latex.office.EmbeddedXMLObject;
|
||||
import writer2latex.office.XMLString;
|
||||
|
@ -480,7 +480,7 @@ public class DrawConverter extends ConverterHelper {
|
|||
}
|
||||
}
|
||||
else { // embedded or base64 encoded image
|
||||
bgd = converter.getImageLoader().getImage(onode);
|
||||
bgd = converter.getImageCv().getImage(onode);
|
||||
if (bgd!=null) {
|
||||
sFileName = bgd.getFileName();
|
||||
// If this is the cover image, add it to the converter result
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.4 (2014-08-20)
|
||||
* Version 1.4 (2014-08-26)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -33,7 +33,7 @@ import org.w3c.dom.NamedNodeMap;
|
|||
|
||||
import writer2latex.office.*;
|
||||
import writer2latex.util.Misc;
|
||||
import writer2latex.xmerge.BinaryGraphicsDocument;
|
||||
import writer2latex.base.BinaryGraphicsDocument;
|
||||
import writer2latex.latex.StarMathConverter;
|
||||
|
||||
/** This class converts formulas: Either as MathML, as an image or as plain text (StarMath or LaTeX format)
|
||||
|
@ -151,7 +151,7 @@ public class MathConverter extends ConverterHelper {
|
|||
// Get the image from the ImageLoader
|
||||
String sHref = Misc.getAttribute(onode,XMLString.XLINK_HREF);
|
||||
if (sHref==null || sHref.length()==0 || ofr.isInPackage(sHref)) {
|
||||
BinaryGraphicsDocument bgd = converter.getImageLoader().getImage(image);
|
||||
BinaryGraphicsDocument bgd = converter.getImageCv().getImage(image);
|
||||
if (bgd!=null) {
|
||||
String sMIME = bgd.getDocumentMIMEType();
|
||||
if (MIMETypes.PNG.equals(sMIME) || MIMETypes.JPEG.equals(sMIME) || MIMETypes.GIF.equals(sMIME)) {
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.4 (2014-08-13)
|
||||
* Version 1.4 (2014-08-27)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -966,15 +966,15 @@ public class TextConverter extends ConverterHelper {
|
|||
ListCounter counter = getListCounter(ofr.getListStyle(styleName));
|
||||
|
||||
// Restart numbering, if required
|
||||
if (counter!=null) {
|
||||
boolean bContinueNumbering = "true".equals(Misc.getAttribute(onode,XMLString.TEXT_CONTINUE_NUMBERING));
|
||||
if (!bContinueNumbering && counter!=null) {
|
||||
counter.restart(nLevel);
|
||||
}
|
||||
if (config.listFormatting()==XhtmlConfig.CSS1_HACK && counter.getValue(nLevel)>0) {
|
||||
hnode.setAttribute("start",Integer.toString(counter.getValue(nLevel)+1));
|
||||
}
|
||||
//if (counter!=null) {
|
||||
boolean bContinueNumbering = "true".equals(Misc.getAttribute(onode,XMLString.TEXT_CONTINUE_NUMBERING));
|
||||
if (!bContinueNumbering && counter!=null) {
|
||||
counter.restart(nLevel);
|
||||
}
|
||||
if (config.listFormatting()==XhtmlConfig.CSS1_HACK && counter.getValue(nLevel)>0) {
|
||||
hnode.setAttribute("start",Integer.toString(counter.getValue(nLevel)+1));
|
||||
}
|
||||
//}
|
||||
|
||||
if (onode.hasChildNodes()) {
|
||||
NodeList nList = onode.getChildNodes();
|
||||
|
@ -1001,7 +1001,9 @@ public class TextConverter extends ConverterHelper {
|
|||
}
|
||||
else {
|
||||
// add an li element
|
||||
sCurrentListLabel = counter.step(nLevel).getLabel();
|
||||
//if (counter!=null) {
|
||||
sCurrentListLabel = counter.step(nLevel).getLabel();
|
||||
//}
|
||||
currentListStyle = ofr.getListStyle(styleName);
|
||||
nCurrentListLevel = nLevel;
|
||||
Element item = converter.createElement("li");
|
||||
|
@ -1016,9 +1018,9 @@ public class TextConverter extends ConverterHelper {
|
|||
XMLString.TEXT_START_VALUE),1);
|
||||
if (bRestart) {
|
||||
item.setAttribute("value",Integer.toString(nStartValue));
|
||||
if (counter!=null) {
|
||||
sCurrentListLabel = counter.restart(nLevel,nStartValue).getLabel();
|
||||
}
|
||||
//if (counter!=null) {
|
||||
sCurrentListLabel = counter.restart(nLevel,nStartValue).getLabel();
|
||||
//}
|
||||
}
|
||||
}
|
||||
traverseListItem(child,nLevel,styleName,item);
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.4 (2014-08-13)
|
||||
* Version 1.4 (2014-08-26)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -32,20 +32,17 @@ package writer2latex.xhtml;
|
|||
import org.w3c.dom.NodeList;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
//import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.DocumentType;
|
||||
import org.w3c.dom.DOMImplementation;
|
||||
//import org.xml.sax.SAXException;
|
||||
//import org.xml.sax.SAXParseException;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
//import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import writer2latex.api.MIMETypes;
|
||||
import writer2latex.base.DOMDocument;
|
||||
import writer2latex.office.XMLString;
|
||||
import writer2latex.xmerge.DOMDocument;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
@ -262,15 +259,13 @@ public class XhtmlDocument extends DOMDocument {
|
|||
|
||||
/**
|
||||
* Constructor. This constructor also creates the DOM (minimal: root, head,
|
||||
* title and body node only) - unlike the constructors in
|
||||
* writer2latex.xmerge.DOMDocument.
|
||||
* @param name <code>Document</code> name.
|
||||
* title and body node only)
|
||||
* @param name name of this document
|
||||
* @param nType the type of document
|
||||
*/
|
||||
public XhtmlDocument(String name, int nType) {
|
||||
super(name,sExtension[nType]);
|
||||
this.nType = nType;
|
||||
|
||||
|
||||
// create DOM
|
||||
Document contentDOM = null;
|
||||
|
@ -281,21 +276,21 @@ public class XhtmlDocument extends DOMDocument {
|
|||
String[] sDocType = getDoctypeStrings();
|
||||
DocumentType doctype = domImpl.createDocumentType("html", sDocType[0], sDocType[1]);
|
||||
contentDOM = domImpl.createDocument("http://www.w3.org/1999/xhtml","html",doctype);
|
||||
contentDOM.getDocumentElement().setAttribute("xmlns","http://www.w3.org/1999/xhtml");
|
||||
// add head, title and body
|
||||
headNode = contentDOM.createElement("head");
|
||||
titleNode = contentDOM.createElement("title");
|
||||
bodyNode = contentDOM.createElement("body");
|
||||
contentDOM.getDocumentElement().appendChild(headNode);
|
||||
headNode.appendChild(titleNode);
|
||||
contentDOM.getDocumentElement().appendChild(bodyNode);
|
||||
contentNode = bodyNode;
|
||||
setContentDOM(contentDOM);
|
||||
}
|
||||
catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
catch (ParserConfigurationException e) {
|
||||
// The newDocumentBuilder() method may in theory throw this, but this will not happen
|
||||
e.printStackTrace();
|
||||
}
|
||||
contentDOM.getDocumentElement().setAttribute("xmlns","http://www.w3.org/1999/xhtml");
|
||||
// add head, title and body
|
||||
headNode = contentDOM.createElement("head");
|
||||
titleNode = contentDOM.createElement("title");
|
||||
bodyNode = contentDOM.createElement("body");
|
||||
contentDOM.getDocumentElement().appendChild(headNode);
|
||||
headNode.appendChild(titleNode);
|
||||
contentDOM.getDocumentElement().appendChild(bodyNode);
|
||||
contentNode = bodyNode;
|
||||
setContentDOM(contentDOM);
|
||||
|
||||
}
|
||||
|
||||
@Override public String getMIMEType() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue