A few w2x fixes
git-svn-id: svn://svn.code.sf.net/p/writer2latex/code/trunk@70 f0f2a975-2e09-46c8-9428-3b39399b9f3c
This commit is contained in:
parent
fcd3702d7d
commit
a799097caa
11 changed files with 309 additions and 204 deletions
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.2 (2010-05-17)
|
||||
* Version 1.2 (2010-06-20)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -501,11 +501,11 @@ public class TextConverter extends ConverterHelper {
|
|||
|
||||
private void handleHeading(Element onode, Node hnode, boolean bAfterSplit) {
|
||||
int nListLevel = getOutlineLevel((Element)onode);
|
||||
boolean bUnNumbered = "true".equals(Misc.getAttribute(onode,XMLString.TEXT_IS_LIST_HEADER));
|
||||
//boolean bUnNumbered = "true".equals(Misc.getAttribute(onode,XMLString.TEXT_IS_LIST_HEADER));
|
||||
boolean bRestart = "true".equals(Misc.getAttribute(onode,XMLString.TEXT_RESTART_NUMBERING));
|
||||
int nStartValue = Misc.getPosInteger(Misc.getAttribute(onode,XMLString.TEXT_START_VALUE),1)-1;
|
||||
handleHeading(onode, hnode, bAfterSplit, ofr.getOutlineStyle(),
|
||||
nListLevel, bUnNumbered, bRestart, nStartValue);
|
||||
nListLevel, false, bRestart, nStartValue);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -515,11 +515,21 @@ public class TextConverter extends ConverterHelper {
|
|||
ListStyle listStyle, int nListLevel, boolean bUnNumbered,
|
||||
boolean bRestart, int nStartValue) {
|
||||
String sStyleName = onode.getAttribute(XMLString.TEXT_STYLE_NAME);
|
||||
if (!bUnNumbered) {
|
||||
// If the heading uses a paragraph style which sets an explicit empty list style name, it's unnumbered
|
||||
StyleWithProperties style = ofr.getParStyle(sStyleName);
|
||||
if (style!=null) {
|
||||
String sListStyleName = style.getListStyleName();
|
||||
if (sListStyleName!=null && sListStyleName.length()==0) {
|
||||
bUnNumbered = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Note: nListLevel may in theory be different from the outline level,
|
||||
// though the ui in OOo does not allow this
|
||||
|
||||
// Numbering: It is possible to define outline numbering in CSS2
|
||||
// using counters; but this is not supported by Mozilla 1.0.
|
||||
// using counters; but this is not supported in all browsers
|
||||
// TODO: Offer CSS2 solution as an alternative later.
|
||||
|
||||
// Note: Conditional styles are not supported
|
||||
|
@ -560,16 +570,19 @@ public class TextConverter extends ConverterHelper {
|
|||
prependAsapNode(heading);
|
||||
|
||||
// Prepend numbering
|
||||
ListCounter counter = getListCounter(listStyle);
|
||||
if (bRestart) { counter.restart(nListLevel,nStartValue); }
|
||||
String sLabel = counter.step(nListLevel).getLabel();
|
||||
if (config.zenHack() && nLevel==2) {
|
||||
// Hack for ePub Zen Garden: Special style for the prefix at level 2
|
||||
// TODO: Replace by some proper style map construct...
|
||||
insertListLabel(listStyle,nListLevel,"SectionNumber",counter.getPrefix(),counter.getLabelAndSuffix(),heading);
|
||||
}
|
||||
else {
|
||||
insertListLabel(listStyle,nListLevel,"SectionNumber",null,sLabel,heading);
|
||||
String sLabel="";
|
||||
if (!bUnNumbered) {
|
||||
ListCounter counter = getListCounter(listStyle);
|
||||
if (bRestart) { counter.restart(nListLevel,nStartValue); }
|
||||
sLabel = counter.step(nListLevel).getLabel();
|
||||
if (config.zenHack() && nLevel==2) {
|
||||
// Hack for ePub Zen Garden: Special style for the prefix at level 2
|
||||
// TODO: Replace by some proper style map construct...
|
||||
insertListLabel(listStyle,nListLevel,"SectionNumber",counter.getPrefix(),counter.getLabelAndSuffix(),heading);
|
||||
}
|
||||
else {
|
||||
insertListLabel(listStyle,nListLevel,"SectionNumber",null,sLabel,heading);
|
||||
}
|
||||
}
|
||||
|
||||
// Add to toc
|
||||
|
@ -1606,19 +1619,27 @@ public class TextConverter extends ConverterHelper {
|
|||
|
||||
public void insertEndnotes(Node hnode) {
|
||||
int n = endnotes.size();
|
||||
if (nSplit>0 && n>0) { hnode = converter.nextOutFile(); }
|
||||
for (int i=0; i<n; i++) {
|
||||
Node endnote = endnotes.get(i);
|
||||
String sId = Misc.getAttribute(endnote,XMLString.TEXT_ID);
|
||||
Node citation = Misc.getChildByTagName(endnote,XMLString.TEXT_ENDNOTE_CITATION);
|
||||
if (citation==null) { // try oasis
|
||||
citation = Misc.getChildByTagName(endnote,XMLString.TEXT_NOTE_CITATION);
|
||||
}
|
||||
Node body = Misc.getChildByTagName(endnote,XMLString.TEXT_ENDNOTE_BODY);
|
||||
if (body==null) { // try oasis
|
||||
body = Misc.getChildByTagName(endnote,XMLString.TEXT_NOTE_BODY);
|
||||
}
|
||||
traverseNoteBody(sId,sEntCitStyle,citation,body,hnode);
|
||||
if (n>0) {
|
||||
if (nSplit>0) { hnode = converter.nextOutFile(); }
|
||||
String sHeading = config.getEndnotesHeading();
|
||||
if (sHeading.length()>0) {
|
||||
Element heading = converter.createElement("h1");
|
||||
hnode.appendChild(heading);
|
||||
heading.appendChild(converter.createTextNode(sHeading));
|
||||
}
|
||||
for (int i=0; i<n; i++) {
|
||||
Node endnote = endnotes.get(i);
|
||||
String sId = Misc.getAttribute(endnote,XMLString.TEXT_ID);
|
||||
Node citation = Misc.getChildByTagName(endnote,XMLString.TEXT_ENDNOTE_CITATION);
|
||||
if (citation==null) { // try oasis
|
||||
citation = Misc.getChildByTagName(endnote,XMLString.TEXT_NOTE_CITATION);
|
||||
}
|
||||
Node body = Misc.getChildByTagName(endnote,XMLString.TEXT_ENDNOTE_BODY);
|
||||
if (body==null) { // try oasis
|
||||
body = Misc.getChildByTagName(endnote,XMLString.TEXT_NOTE_BODY);
|
||||
}
|
||||
traverseNoteBody(sId,sEntCitStyle,citation,body,hnode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.2 (2010-05-13)
|
||||
* Version 1.2 (2010-06-20)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -41,7 +41,7 @@ import writer2latex.util.Misc;
|
|||
|
||||
public class XhtmlConfig extends writer2latex.base.ConfigBase {
|
||||
// Implement configuration methods
|
||||
protected int getOptionCount() { return 43; }
|
||||
protected int getOptionCount() { return 44; }
|
||||
protected String getDefaultConfigPath() { return "/writer2latex/xhtml/config/"; }
|
||||
|
||||
// Override setOption: To be backwards compatible, we must accept options
|
||||
|
@ -105,21 +105,22 @@ public class XhtmlConfig extends writer2latex.base.ConfigBase {
|
|||
private static final int FLOAT_OBJECTS = 25;
|
||||
private static final int TABSTOP_STYLE = 26;
|
||||
private static final int FORMULAS = 27;
|
||||
private static final int SPLIT_LEVEL = 28;
|
||||
private static final int REPEAT_LEVELS = 29;
|
||||
private static final int CALC_SPLIT = 30;
|
||||
private static final int DISPLAY_HIDDEN_SHEETS = 31;
|
||||
private static final int DISPLAY_HIDDEN_ROWS_COLS = 32;
|
||||
private static final int DISPLAY_FILTERED_ROWS_COLS = 33;
|
||||
private static final int APPLY_PRINT_RANGES = 34;
|
||||
private static final int USE_TITLE_AS_HEADING = 35;
|
||||
private static final int USE_SHEET_NAMES_AS_HEADINGS = 36;
|
||||
private static final int XSLT_PATH = 37;
|
||||
private static final int SAVE_IMAGES_IN_SUBDIR = 38;
|
||||
private static final int UPLINK = 39;
|
||||
private static final int DIRECTORY_ICON = 40;
|
||||
private static final int DOCUMENT_ICON = 41;
|
||||
private static final int ZEN_HACK = 42; // temporary hack for ePub Zen Garden styles
|
||||
private static final int ENDNOTES_HEADING = 28;
|
||||
private static final int SPLIT_LEVEL = 29;
|
||||
private static final int REPEAT_LEVELS = 30;
|
||||
private static final int CALC_SPLIT = 31;
|
||||
private static final int DISPLAY_HIDDEN_SHEETS = 32;
|
||||
private static final int DISPLAY_HIDDEN_ROWS_COLS = 33;
|
||||
private static final int DISPLAY_FILTERED_ROWS_COLS = 34;
|
||||
private static final int APPLY_PRINT_RANGES = 35;
|
||||
private static final int USE_TITLE_AS_HEADING = 36;
|
||||
private static final int USE_SHEET_NAMES_AS_HEADINGS = 37;
|
||||
private static final int XSLT_PATH = 38;
|
||||
private static final int SAVE_IMAGES_IN_SUBDIR = 39;
|
||||
private static final int UPLINK = 40;
|
||||
private static final int DIRECTORY_ICON = 41;
|
||||
private static final int DOCUMENT_ICON = 42;
|
||||
private static final int ZEN_HACK = 43; // temporary hack for ePub Zen Garden styles
|
||||
|
||||
protected ComplexOption xheading = addComplexOption("heading-map");
|
||||
protected ComplexOption xpar = addComplexOption("paragraph-map");
|
||||
|
@ -165,6 +166,7 @@ public class XhtmlConfig extends writer2latex.base.ConfigBase {
|
|||
options[COLUMN_SCALING] = new Option("column_scaling","100%");
|
||||
options[FLOAT_OBJECTS] = new BooleanOption("float_objects","true");
|
||||
options[TABSTOP_STYLE] = new Option("tabstop_style","");
|
||||
options[ENDNOTES_HEADING] = new Option("endnotes_heading","");
|
||||
options[FORMULAS] = new IntegerOption("formulas","starmath") {
|
||||
@Override public void setString(String sValue) {
|
||||
super.setString(sValue);
|
||||
|
@ -296,6 +298,7 @@ public class XhtmlConfig extends writer2latex.base.ConfigBase {
|
|||
public String getXhtmlColumnScaling() { return options[COLUMN_SCALING].getString(); }
|
||||
public boolean xhtmlFloatObjects() { return ((BooleanOption) options[FLOAT_OBJECTS]).getValue(); }
|
||||
public String getXhtmlTabstopStyle() { return options[TABSTOP_STYLE].getString(); }
|
||||
public String getEndnotesHeading() { return options[ENDNOTES_HEADING].getString(); }
|
||||
public int formulas() { return ((IntegerOption) options[FORMULAS]).getValue(); }
|
||||
public int getXhtmlSplitLevel() { return ((IntegerOption) options[SPLIT_LEVEL]).getValue(); }
|
||||
public int getXhtmlRepeatLevels() { return ((IntegerOption) options[REPEAT_LEVELS]).getValue(); }
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.2 (2010-04-23)
|
||||
* Version 1.2 (2010-06-19)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -49,6 +49,8 @@ import java.io.InputStream;
|
|||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* An implementation of <code>Document</code> for
|
||||
|
@ -65,15 +67,17 @@ public class XhtmlDocument extends DOMDocument {
|
|||
/** Constant to identify XHTML + MathML documents */
|
||||
public static final int XHTML_MATHML = 2;
|
||||
|
||||
/** Constant to identify XHTML + MathML documents using the xsl transformations
|
||||
/** Constant to identify XHTML + MathML documents using the XSL transformations
|
||||
* from w3c's math working group (http://www.w3.org/Math/XSL/)
|
||||
*/
|
||||
public static final int XHTML_MATHML_XSL = 3;
|
||||
|
||||
|
||||
// Some static data
|
||||
private static final String[] sExtension = { ".html", ".xhtml", ".xhtml", ".xml" };
|
||||
|
||||
private static final String[] sEmpty = { "base", "meta", "link", "hr", "br", "param", "img", "area", "input", "col" };
|
||||
|
||||
private static Set<String> blockPrettyPrint;
|
||||
private static Set<String> conditionalBlockPrettyPrint;
|
||||
private static Set<String> emptyElements;
|
||||
private static String[] entities; // Not convenient to define directly due to a lot of null values
|
||||
|
||||
// Type of document
|
||||
|
@ -102,6 +106,139 @@ public class XhtmlDocument extends DOMDocument {
|
|||
private Element headerNode = null;
|
||||
private Element footerNode = null;
|
||||
|
||||
// Initialize static data
|
||||
static {
|
||||
// Paragraphs and headings always block pretty printing
|
||||
blockPrettyPrint = new HashSet<String>();
|
||||
blockPrettyPrint.add("p");
|
||||
blockPrettyPrint.add("h1");
|
||||
blockPrettyPrint.add("h2");
|
||||
blockPrettyPrint.add("h3");
|
||||
blockPrettyPrint.add("h4");
|
||||
blockPrettyPrint.add("h5");
|
||||
blockPrettyPrint.add("h6");
|
||||
|
||||
// List items and table cells may block pretty printing, depending on the context
|
||||
conditionalBlockPrettyPrint = new HashSet<String>();
|
||||
conditionalBlockPrettyPrint.add("li");
|
||||
conditionalBlockPrettyPrint.add("th");
|
||||
conditionalBlockPrettyPrint.add("td");
|
||||
|
||||
// These elements are empty
|
||||
emptyElements = new HashSet<String>();
|
||||
emptyElements.add("base");
|
||||
emptyElements.add("meta");
|
||||
emptyElements.add("link");
|
||||
emptyElements.add("hr");
|
||||
emptyElements.add("br");
|
||||
emptyElements.add("param");
|
||||
emptyElements.add("img");
|
||||
emptyElements.add("area");
|
||||
emptyElements.add("input");
|
||||
emptyElements.add("col");
|
||||
|
||||
// Named character entities (currently only those within the ISO latin 1 range)
|
||||
entities = new String[256];
|
||||
// Latin 1 symbols
|
||||
entities[160]=" ";
|
||||
entities[161]="¡";
|
||||
entities[162]="¢";
|
||||
entities[163]="£";
|
||||
entities[164]="¤";
|
||||
entities[165]="¥";
|
||||
entities[166]="¦";
|
||||
entities[167]="§";
|
||||
entities[168]="¨";
|
||||
entities[169]="©";
|
||||
entities[170]="ª";
|
||||
entities[171]="«";
|
||||
entities[172]="¬";
|
||||
entities[173]="­";
|
||||
entities[174]="®";
|
||||
entities[175]="¯";
|
||||
entities[176]="°";
|
||||
entities[177]="±";
|
||||
entities[178]="²";
|
||||
entities[179]="³";
|
||||
entities[180]="´";
|
||||
entities[181]="µ";
|
||||
entities[182]="¶";
|
||||
entities[183]="·";
|
||||
entities[184]="¸";
|
||||
entities[185]="¹";
|
||||
entities[186]="º";
|
||||
entities[187]="»";
|
||||
entities[188]="¼";
|
||||
entities[189]="½";
|
||||
entities[190]="¾";
|
||||
entities[191]="¿";
|
||||
entities[215]="×";
|
||||
entities[247]="÷";
|
||||
// Latin 1 characters
|
||||
entities[192]="À";
|
||||
entities[193]="Á";
|
||||
entities[194]="Â";
|
||||
entities[195]="Ã";
|
||||
entities[196]="Ä";
|
||||
entities[197]="Å";
|
||||
entities[198]="Æ";
|
||||
entities[199]="Ç";
|
||||
entities[200]="È";
|
||||
entities[201]="É";
|
||||
entities[202]="Ê";
|
||||
entities[203]="Ë";
|
||||
entities[204]="Ì";
|
||||
entities[205]="Í";
|
||||
entities[206]="Î";
|
||||
entities[207]="Ï";
|
||||
entities[208]="Ð";
|
||||
entities[209]="Ñ";
|
||||
entities[210]="Ò";
|
||||
entities[211]="Ó";
|
||||
entities[212]="Ô";
|
||||
entities[213]="Õ";
|
||||
entities[214]="Ö";
|
||||
entities[216]="Ø";
|
||||
entities[217]="Ù";
|
||||
entities[218]="Ú";
|
||||
entities[219]="Û";
|
||||
entities[220]="Ü";
|
||||
entities[221]="Ý";
|
||||
entities[222]="Þ";
|
||||
entities[223]="ß";
|
||||
entities[224]="à";
|
||||
entities[225]="á";
|
||||
entities[226]="â";
|
||||
entities[227]="ã";
|
||||
entities[228]="ä";
|
||||
entities[229]="å";
|
||||
entities[230]="æ";
|
||||
entities[231]="ç";
|
||||
entities[232]="è";
|
||||
entities[233]="é";
|
||||
entities[234]="ê";
|
||||
entities[235]="ë";
|
||||
entities[236]="ì";
|
||||
entities[237]="í";
|
||||
entities[238]="î";
|
||||
entities[239]="ï";
|
||||
entities[240]="ð";
|
||||
entities[241]="ñ";
|
||||
entities[242]="ò";
|
||||
entities[243]="ó";
|
||||
entities[244]="ô";
|
||||
entities[245]="õ";
|
||||
entities[246]="ö";
|
||||
entities[248]="ø";
|
||||
entities[249]="ù";
|
||||
entities[250]="ú";
|
||||
entities[251]="û";
|
||||
entities[252]="ü";
|
||||
entities[253]="ý";
|
||||
entities[254]="þ";
|
||||
entities[255]="ÿ";
|
||||
}
|
||||
|
||||
public static final String getExtension(int nType) {
|
||||
return sExtension[nType];
|
||||
}
|
||||
|
@ -322,7 +459,7 @@ public class XhtmlDocument extends DOMDocument {
|
|||
cLimit = 65535;
|
||||
}
|
||||
|
||||
bAddBOM = config.xhtmlAddBOM();
|
||||
bAddBOM = config.xhtmlAddBOM() && sEncoding.equals("UTF-8");
|
||||
bNoDoctype = config.xhtmlNoDoctype();
|
||||
bPrettyPrint = config.prettyPrint();
|
||||
bUseNamedEntities = config.useNamedEntities();
|
||||
|
@ -341,6 +478,7 @@ public class XhtmlDocument extends DOMDocument {
|
|||
|
||||
public String getFileExtension() { return super.getFileExtension(); }
|
||||
|
||||
// Optimize the usage of xml:dir and xml:lang attributes
|
||||
private void optimize(Element node, String sLang, String sDir) {
|
||||
if (node.hasAttribute("xml:lang")) {
|
||||
if (node.getAttribute("xml:lang").equals(sLang)) {
|
||||
|
@ -378,9 +516,6 @@ public class XhtmlDocument extends DOMDocument {
|
|||
* @throws IOException If any I/O error occurs.
|
||||
*/
|
||||
public void write(OutputStream os) throws IOException {
|
||||
// Prepare named entities
|
||||
prepareEntities();
|
||||
|
||||
OutputStreamWriter osw = new OutputStreamWriter(os,sEncoding);
|
||||
// Add a BOM if the user desires so
|
||||
if (bAddBOM) { osw.write("\uFEFF"); }
|
||||
|
@ -409,16 +544,42 @@ public class XhtmlDocument extends DOMDocument {
|
|||
}
|
||||
Element doc = getContentDOM().getDocumentElement();
|
||||
optimize(doc,null,null);
|
||||
write(doc,0,osw);
|
||||
write(doc,bPrettyPrint ? 0 : -1,osw);
|
||||
osw.flush();
|
||||
osw.close();
|
||||
}
|
||||
|
||||
private static boolean blockThis(Element node) {
|
||||
String sTagName = node.getTagName();
|
||||
if (blockPrettyPrint.contains(sTagName)) {
|
||||
return true;
|
||||
}
|
||||
else if (conditionalBlockPrettyPrint.contains(sTagName)) {
|
||||
// Block pretty printing if the content is anything but elements that block pretty print
|
||||
Node child = node.getFirstChild();
|
||||
while (child!=null) {
|
||||
if (child.getNodeType()==Node.ELEMENT_NODE && !blockPrettyPrint.contains(child.getNodeName())) {
|
||||
return true;
|
||||
}
|
||||
child = child.getNextSibling();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
// Other elements block pretty printing if they contain text nodes
|
||||
Node child = node.getFirstChild();
|
||||
while (child!=null) {
|
||||
if (child.getNodeType()==Node.TEXT_NODE) {
|
||||
return true;
|
||||
}
|
||||
child = child.getNextSibling();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isEmpty(String sTagName) {
|
||||
for (int i=0; i<sEmpty.length; i++) {
|
||||
if (sEmpty[i].equals(sTagName)) { return true; }
|
||||
}
|
||||
return false;
|
||||
private static boolean isEmpty(String sTagName) {
|
||||
return emptyElements.contains(sTagName);
|
||||
}
|
||||
|
||||
// Write nodes; we only need element, text and comment nodes
|
||||
|
@ -427,40 +588,31 @@ public class XhtmlDocument extends DOMDocument {
|
|||
switch (nType) {
|
||||
case Node.ELEMENT_NODE:
|
||||
if (isEmpty(node.getNodeName())) {
|
||||
// This node must be empty, we ignore childnodes
|
||||
// This node must be empty, we ignore child nodes
|
||||
if (nLevel>=0) { writeSpaces(nLevel,osw); }
|
||||
osw.write("<"+node.getNodeName());
|
||||
writeAttributes(node,osw);
|
||||
osw.write(" />");
|
||||
if (bPrettyPrint && nLevel>=0) { osw.write("\n"); }
|
||||
if (nLevel>=0) { osw.write("\n"); }
|
||||
}
|
||||
else if (node.hasChildNodes()) {
|
||||
// Block pretty print from this node?
|
||||
NodeList list = node.getChildNodes();
|
||||
int nLen = list.getLength();
|
||||
boolean bBlockPrettyPrint = false;
|
||||
if (nLevel>=0) {
|
||||
for (int i = 0; i < nLen; i++) {
|
||||
bBlockPrettyPrint |= list.item(i).getNodeType()==Node.TEXT_NODE;
|
||||
}
|
||||
}
|
||||
int nNextLevel = (nLevel<0 || blockThis((Element)node)) ? -1 : nLevel+1;
|
||||
// Print start tag
|
||||
if (nLevel>=0) { writeSpaces(nLevel,osw); }
|
||||
osw.write("<"+node.getNodeName());
|
||||
writeAttributes(node,osw);
|
||||
osw.write(">");
|
||||
if (bPrettyPrint && nLevel>=0 && !bBlockPrettyPrint) { osw.write("\n"); }
|
||||
if (nNextLevel>=0) { osw.write("\n"); }
|
||||
// Print children
|
||||
for (int i = 0; i < nLen; i++) {
|
||||
int nNextLevel;
|
||||
if (bBlockPrettyPrint || nLevel<0) { nNextLevel=-1; }
|
||||
else { nNextLevel=nLevel+1; }
|
||||
write(list.item(i),nNextLevel,osw);
|
||||
Node child = node.getFirstChild();
|
||||
while (child!=null) {
|
||||
write(child,nNextLevel,osw);
|
||||
child = child.getNextSibling();
|
||||
}
|
||||
// Print end tag
|
||||
if (nLevel>=0 && !bBlockPrettyPrint) { writeSpaces(nLevel,osw); }
|
||||
if (nNextLevel>=0) { writeSpaces(nLevel,osw); }
|
||||
osw.write("</"+node.getNodeName()+">");
|
||||
if (bPrettyPrint && nLevel>=0) { osw.write("\n"); }
|
||||
if (nLevel>=0) { osw.write("\n"); }
|
||||
}
|
||||
else { // empty element
|
||||
if (nLevel>=0) { writeSpaces(nLevel,osw); }
|
||||
|
@ -473,7 +625,7 @@ public class XhtmlDocument extends DOMDocument {
|
|||
else {
|
||||
osw.write(" />");
|
||||
}
|
||||
if (bPrettyPrint && nLevel>=0) { osw.write("\n"); }
|
||||
if (nLevel>=0) { osw.write("\n"); }
|
||||
}
|
||||
break;
|
||||
case Node.TEXT_NODE:
|
||||
|
@ -484,7 +636,7 @@ public class XhtmlDocument extends DOMDocument {
|
|||
osw.write("<!-- ");
|
||||
write(node.getNodeValue(),osw);
|
||||
osw.write(" -->");
|
||||
if (bPrettyPrint && nLevel>=0) { osw.write("\n"); }
|
||||
if (nLevel>=0) { osw.write("\n"); }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -502,9 +654,7 @@ public class XhtmlDocument extends DOMDocument {
|
|||
}
|
||||
|
||||
private void writeSpaces(int nCount, OutputStreamWriter osw) throws IOException {
|
||||
if (bPrettyPrint) {
|
||||
for (int i=0; i<nCount; i++) { osw.write(" "); }
|
||||
}
|
||||
for (int i=0; i<nCount; i++) { osw.write(" "); }
|
||||
}
|
||||
|
||||
private void write(String s, OutputStreamWriter osw) throws IOException {
|
||||
|
@ -568,109 +718,6 @@ public class XhtmlDocument extends DOMDocument {
|
|||
}
|
||||
}
|
||||
|
||||
private static void prepareEntities() {
|
||||
if (entities==null) {
|
||||
entities = new String[256];
|
||||
// Latin 1 symbols
|
||||
entities[160]=" ";
|
||||
entities[161]="¡";
|
||||
entities[162]="¢";
|
||||
entities[163]="£";
|
||||
entities[164]="¤";
|
||||
entities[165]="¥";
|
||||
entities[166]="¦";
|
||||
entities[167]="§";
|
||||
entities[168]="¨";
|
||||
entities[169]="©";
|
||||
entities[170]="ª";
|
||||
entities[171]="«";
|
||||
entities[172]="¬";
|
||||
entities[173]="­";
|
||||
entities[174]="®";
|
||||
entities[175]="¯";
|
||||
entities[176]="°";
|
||||
entities[177]="±";
|
||||
entities[178]="²";
|
||||
entities[179]="³";
|
||||
entities[180]="´";
|
||||
entities[181]="µ";
|
||||
entities[182]="¶";
|
||||
entities[183]="·";
|
||||
entities[184]="¸";
|
||||
entities[185]="¹";
|
||||
entities[186]="º";
|
||||
entities[187]="»";
|
||||
entities[188]="¼";
|
||||
entities[189]="½";
|
||||
entities[190]="¾";
|
||||
entities[191]="¿";
|
||||
entities[215]="×";
|
||||
entities[247]="÷";
|
||||
// Latin 1 characters
|
||||
entities[192]="À";
|
||||
entities[193]="Á";
|
||||
entities[194]="Â";
|
||||
entities[195]="Ã";
|
||||
entities[196]="Ä";
|
||||
entities[197]="Å";
|
||||
entities[198]="Æ";
|
||||
entities[199]="Ç";
|
||||
entities[200]="È";
|
||||
entities[201]="É";
|
||||
entities[202]="Ê";
|
||||
entities[203]="Ë";
|
||||
entities[204]="Ì";
|
||||
entities[205]="Í";
|
||||
entities[206]="Î";
|
||||
entities[207]="Ï";
|
||||
entities[208]="Ð";
|
||||
entities[209]="Ñ";
|
||||
entities[210]="Ò";
|
||||
entities[211]="Ó";
|
||||
entities[212]="Ô";
|
||||
entities[213]="Õ";
|
||||
entities[214]="Ö";
|
||||
entities[216]="Ø";
|
||||
entities[217]="Ù";
|
||||
entities[218]="Ú";
|
||||
entities[219]="Û";
|
||||
entities[220]="Ü";
|
||||
entities[221]="Ý";
|
||||
entities[222]="Þ";
|
||||
entities[223]="ß";
|
||||
entities[224]="à";
|
||||
entities[225]="á";
|
||||
entities[226]="â";
|
||||
entities[227]="ã";
|
||||
entities[228]="ä";
|
||||
entities[229]="å";
|
||||
entities[230]="æ";
|
||||
entities[231]="ç";
|
||||
entities[232]="è";
|
||||
entities[233]="é";
|
||||
entities[234]="ê";
|
||||
entities[235]="ë";
|
||||
entities[236]="ì";
|
||||
entities[237]="í";
|
||||
entities[238]="î";
|
||||
entities[239]="ï";
|
||||
entities[240]="ð";
|
||||
entities[241]="ñ";
|
||||
entities[242]="ò";
|
||||
entities[243]="ó";
|
||||
entities[244]="ô";
|
||||
entities[245]="õ";
|
||||
entities[246]="ö";
|
||||
entities[248]="ø";
|
||||
entities[249]="ù";
|
||||
entities[250]="ú";
|
||||
entities[251]="û";
|
||||
entities[252]="ü";
|
||||
entities[253]="ý";
|
||||
entities[254]="þ";
|
||||
entities[255]="ÿ";
|
||||
}
|
||||
}
|
||||
|
||||
// Translate character to MathML entity (contributed by Bruno Mascret)
|
||||
private String getMathMLEntity(char c) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue