A few minor bugfixes and improvements
git-svn-id: svn://svn.code.sf.net/p/writer2latex/code/trunk@174 f0f2a975-2e09-46c8-9428-3b39399b9f3c
This commit is contained in:
parent
5d82772d91
commit
2fd6ccd490
35 changed files with 129 additions and 111 deletions
|
@ -16,11 +16,11 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Copyright: 2002 by Henrik Just
|
||||
* Copyright: 2002-2014 by Henrik Just
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 0.4 (2004-08-10)
|
||||
* Version 1.4 (2014-09-16)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -31,7 +31,7 @@ public class CSVList{
|
|||
private String sSep;
|
||||
private String sNameValueSep;
|
||||
private boolean bEmpty = true;
|
||||
private StringBuffer buf = new StringBuffer();
|
||||
private StringBuilder buf = new StringBuilder();
|
||||
|
||||
public CSVList(String sSep, String sNameValueSep) {
|
||||
this.sSep=sSep;
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Copyright: 2002-2010 by Henrik Just
|
||||
* Copyright: 2002-2014 by Henrik Just
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.2 (2010-10-27)
|
||||
* Version 1.4 (2014-09-16)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -58,7 +58,7 @@ public class ExportNameCollection{
|
|||
|
||||
public void addName(String sName){
|
||||
if (containsName(sName)) { return; }
|
||||
StringBuffer outbuf=new StringBuffer();
|
||||
StringBuilder outbuf=new StringBuilder();
|
||||
SimpleInputBuffer inbuf=new SimpleInputBuffer(sName);
|
||||
|
||||
// Don't start with a digit
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.4 (2014-08-27)
|
||||
* Version 1.4 (2014-09-16)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -91,7 +91,7 @@ public class Misc{
|
|||
|
||||
public static final String int2roman(int number) {
|
||||
assert number>0; // Only works for positive numbers!
|
||||
StringBuffer roman=new StringBuffer();
|
||||
StringBuilder roman=new StringBuilder();
|
||||
while (number>=1000) { roman.append('m'); number-=1000; }
|
||||
if (number>=900) { roman.append("cm"); number-=900; }
|
||||
if (number>=500) { roman.append('d'); number-=500; }
|
||||
|
@ -404,7 +404,7 @@ public class Misc{
|
|||
|
||||
/* utility method that collects PCDATA content of an element */
|
||||
public static String getPCDATA(Node node) {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
StringBuilder buf = new StringBuilder();
|
||||
if (node.hasChildNodes()) {
|
||||
NodeList nl = node.getChildNodes();
|
||||
int nLen = nl.getLength();
|
||||
|
|
|
@ -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-03-22)
|
||||
* Version 1.4 (2014-09-16)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -40,6 +40,7 @@ import org.w3c.dom.Element;
|
|||
public class SimpleDOMBuilder {
|
||||
private Document dom=null;
|
||||
private Element currentElement=null;
|
||||
private StringBuilder charBuffer=new StringBuilder();
|
||||
|
||||
/**
|
||||
* Append an element to the current element and set this new element to be the current element.
|
||||
|
@ -51,6 +52,7 @@ public class SimpleDOMBuilder {
|
|||
*/
|
||||
public boolean startElement(String sTagName) {
|
||||
if (currentElement!=null) {
|
||||
flushCharacters();
|
||||
currentElement = (Element) currentElement.appendChild(dom.createElement(sTagName));
|
||||
}
|
||||
else {
|
||||
|
@ -74,6 +76,7 @@ public class SimpleDOMBuilder {
|
|||
*/
|
||||
public boolean endElement() {
|
||||
if (currentElement!=null) {
|
||||
flushCharacters();
|
||||
if (currentElement!=dom.getDocumentElement()) {
|
||||
currentElement=(Element) currentElement.getParentNode();
|
||||
}
|
||||
|
@ -100,18 +103,26 @@ public class SimpleDOMBuilder {
|
|||
}
|
||||
|
||||
/**
|
||||
* Add characters to the currentElement
|
||||
* Add characters to the currentElement. The actual writing of characters to the DOM is delayed until the
|
||||
* <code>startElement</code> or <code>endElement</code> methods are invoked
|
||||
* @param sText
|
||||
* @return true on success, false if there is no current element
|
||||
*/
|
||||
public boolean characters(String sText) {
|
||||
if (currentElement!=null) {
|
||||
currentElement.appendChild(dom.createTextNode(sText));
|
||||
charBuffer.append(sText);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void flushCharacters() {
|
||||
if (charBuffer.length()>0) {
|
||||
currentElement.appendChild(dom.createTextNode(charBuffer.toString()));
|
||||
charBuffer.setLength(0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the DOM tree
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue