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:
henrikjust 2014-09-17 07:32:31 +00:00
parent 5d82772d91
commit 2fd6ccd490
35 changed files with 129 additions and 111 deletions

View file

@ -2,6 +2,12 @@ Changelog for Writer2LaTeX version 1.2 -> 1.4
---------- version 1.3.2 alpha ---------- ---------- version 1.3.2 alpha ----------
[w2l] Replace usage of StringBuffer with StringBuilder everywhere (marginal optimization)
[w2l] The standard configurations pdfprint.xml and pdfscreen.xml no longer requires ooomath.sty
[w2l] A bookmark in a heading no longer results in an optional argument to \section commands
[w2l] New option display_hidden_text (default false) to toggle whether or not hidden text should be included in [w2l] New option display_hidden_text (default false) to toggle whether or not hidden text should be included in
the export (there is currently no user interface for this option) the export (there is currently no user interface for this option)

View file

@ -20,7 +20,7 @@
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.4 (2014-08-05) * Version 1.4 (2014-09-16)
* *
*/ */
@ -437,7 +437,7 @@ public abstract class ConfigurationDialogBase extends WeakBase implements XConta
if (xIs!=null) { if (xIs!=null) {
InputStream is = new XInputStreamToInputStreamAdapter(xIs); InputStream is = new XInputStreamToInputStreamAdapter(xIs);
BufferedReader reader = new BufferedReader(new InputStreamReader(is)); BufferedReader reader = new BufferedReader(new InputStreamReader(is));
StringBuffer buf = new StringBuffer(); StringBuilder buf = new StringBuilder();
String sLine; String sLine;
try { try {
while ((sLine = reader.readLine())!=null) { while ((sLine = reader.readLine())!=null) {

View file

@ -20,7 +20,7 @@
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.3.1 (2014-08-04) * Version 1.4 (2014-09-16)
* *
*/ */
@ -403,7 +403,7 @@ public abstract class OptionsDialogBase extends DialogBase implements
Object resources = XPropertySetHelper.getPropertyValue(xCfgProps,"Resources"); Object resources = XPropertySetHelper.getPropertyValue(xCfgProps,"Resources");
XNameAccess xResourceNameAccess = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class,resources); XNameAccess xResourceNameAccess = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class,resources);
if (xResourceNameAccess!=null) { if (xResourceNameAccess!=null) {
StringBuffer buf = new StringBuffer(); StringBuilder buf = new StringBuilder();
String[] sResourceNames = xResourceNameAccess.getElementNames(); String[] sResourceNames = xResourceNameAccess.getElementNames();
for (String sName : sResourceNames) { for (String sName : sResourceNames) {
Object resource = xResourceNameAccess.getByName(sName); Object resource = xResourceNameAccess.getByName(sName);

View file

@ -16,11 +16,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA * MA 02111-1307 USA
* *
* Copyright: 2002-2012 by Henrik Just * Copyright: 2002-2014 by Henrik Just
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.2 (2012-03-12) * Version 1.4 (2014-09-16)
* *
*/ */
@ -434,7 +434,7 @@ public final class ConfigurationDialog extends ConfigurationDialogBase implement
sNextItems[i]=internalNames.get(sNextItems[i]); sNextItems[i]=internalNames.get(sNextItems[i]);
} }
} }
StringBuffer list = new StringBuffer(); StringBuilder list = new StringBuilder();
for (int i=0; i<nLen; i++) { for (int i=0; i<nLen; i++) {
if (i>0) list.append(';'); if (i>0) list.append(';');
list.append(sNextItems[i]); list.append(sNextItems[i]);

View file

@ -16,11 +16,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA * MA 02111-1307 USA
* *
* Copyright: 2002-2010 by Henrik Just * Copyright: 2002-2014 by Henrik Just
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.2 (2010-10-10) * Version 1.4 (2014-09-16)
* *
*/ */
@ -229,7 +229,7 @@ public final class ApplicationsDialog
} }
// Unix: Configure a certain application, reporting the availability // Unix: Configure a certain application, reporting the availability
private boolean configureApp(String sName, String sAppName, String sArguments, StringBuffer info) { private boolean configureApp(String sName, String sAppName, String sArguments, StringBuilder info) {
if (hasApp(sAppName)) { if (hasApp(sAppName)) {
externalApps.setApplication(sName, sAppName, sArguments); externalApps.setApplication(sName, sAppName, sArguments);
info.append("Found "+sAppName+" - OK\n"); info.append("Found "+sAppName+" - OK\n");
@ -244,7 +244,7 @@ public final class ApplicationsDialog
// Unix: Configure a certain application testing the availability // Unix: Configure a certain application testing the availability
// This variant uses an array of potential apps // This variant uses an array of potential apps
private boolean configureApp(String sName, String[] sAppNames, String sArguments, StringBuffer info) { private boolean configureApp(String sName, String[] sAppNames, String sArguments, StringBuilder info) {
for (String sAppName : sAppNames) { for (String sAppName : sAppNames) {
if (configureApp(sName, sAppName, sArguments)) { if (configureApp(sName, sAppName, sArguments)) {
info.append("Found "+sName+": "+sAppName+" - OK\n"); info.append("Found "+sName+": "+sAppName+" - OK\n");
@ -266,7 +266,7 @@ public final class ApplicationsDialog
} }
// Windows: Configure a certain MikTeX application // Windows: Configure a certain MikTeX application
private boolean configureMikTeX(String sPath, String sName, String sAppName, String sArguments, StringBuffer info, boolean bRequired) { private boolean configureMikTeX(String sPath, String sName, String sAppName, String sArguments, StringBuilder info, boolean bRequired) {
File app = new File(new File(sPath),sAppName+".exe"); File app = new File(new File(sPath),sAppName+".exe");
if (app.exists()) { if (app.exists()) {
externalApps.setApplication(sName, sAppName, sArguments); externalApps.setApplication(sName, sAppName, sArguments);
@ -285,7 +285,7 @@ public final class ApplicationsDialog
String sOsName = System.getProperty("os.name"); String sOsName = System.getProperty("os.name");
String sOsVersion = System.getProperty("os.version"); String sOsVersion = System.getProperty("os.version");
String sOsArch = System.getProperty("os.arch"); String sOsArch = System.getProperty("os.arch");
StringBuffer info = new StringBuffer(); StringBuilder info = new StringBuilder();
info.append("Results of configuration:\n\n"); info.append("Results of configuration:\n\n");
info.append("Your system identifies itself as "+sOsName+" version "+sOsVersion+ " (" + sOsArch +")\n\n"); info.append("Your system identifies itself as "+sOsName+" version "+sOsVersion+ " (" + sOsArch +")\n\n");
if (sOsName.startsWith("Windows")) { if (sOsName.startsWith("Windows")) {

View file

@ -16,11 +16,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA * MA 02111-1307 USA
* *
* Copyright: 2002-2011 by Henrik Just * Copyright: 2002-2014 by Henrik Just
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.2 (2011-02-23) * Version 1.4 (2014-09-16)
* *
*/ */
@ -117,7 +117,7 @@ public class LogViewerDialog extends DialogBase
// Utility methods // Utility methods
private String readTextFile(String sUrl) { private String readTextFile(String sUrl) {
StringBuffer buf = new StringBuffer(); StringBuilder buf = new StringBuilder();
try { try {
File file = new File(new URI(sUrl)); File file = new File(new URI(sUrl));
if (file.exists() && file.isFile()) { if (file.exists() && file.isFile()) {

View file

@ -20,7 +20,7 @@
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.4 (2014-09-08) * Version 1.4 (2014-09-16)
* *
*/ */
@ -33,7 +33,7 @@ public class ConverterFactory {
// Version information // Version information
private static final String VERSION = "1.3.2"; private static final String VERSION = "1.3.2";
private static final String DATE = "2014-09-08"; private static final String DATE = "2014-09-16";
/** Return the Writer2LaTeX version in the form /** Return the Writer2LaTeX version in the form
* (major version).(minor version).(patch level)<br/> * (major version).(minor version).(patch level)<br/>

View file

@ -20,7 +20,7 @@
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.4 (2014-09-05) * Version 1.4 (2014-09-16)
* *
*/ */
@ -240,7 +240,7 @@ public final class ImageConverter {
if (blob==null) { if (blob==null) {
Node obd = Misc.getChildByTagName(node,XMLString.OFFICE_BINARY_DATA); Node obd = Misc.getChildByTagName(node,XMLString.OFFICE_BINARY_DATA);
if (obd!=null) { if (obd!=null) {
StringBuffer buf = new StringBuffer(); StringBuilder buf = new StringBuilder();
NodeList nl = obd.getChildNodes(); NodeList nl = obd.getChildNodes();
int nLen = nl.getLength(); int nLen = nl.getLength();
for (int i=0; i<nLen; i++) { for (int i=0; i<nLen; i++) {

View file

@ -16,11 +16,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA * MA 02111-1307 USA
* *
* Copyright: 2002-2012 by Henrik Just * Copyright: 2002-2014 by Henrik Just
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.2 (2012-03-05) * Version 1.4 (2014-09-16)
* *
*/ */
@ -969,7 +969,7 @@ public class FieldConverter extends ConverterHelper {
// For the argument to a href, we have to escape or encode certain characters // For the argument to a href, we have to escape or encode certain characters
private String escapeHref(String s, boolean bInFootnote) { private String escapeHref(String s, boolean bInFootnote) {
StringBuffer buf = new StringBuffer(); StringBuilder buf = new StringBuilder();
for (int i=0; i<s.length(); i++) { for (int i=0; i<s.length(); i++) {
if (bInFootnote && s.charAt(i)=='#') { buf.append("\\#"); } if (bInFootnote && s.charAt(i)=='#') { buf.append("\\#"); }
else if (bInFootnote && s.charAt(i)=='%') { buf.append("\\%"); } else if (bInFootnote && s.charAt(i)=='%') { buf.append("\\%"); }

View file

@ -20,7 +20,7 @@
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.4 (2014-09-08) * Version 1.4 (2014-09-15)
* *
*/ */
@ -409,7 +409,8 @@ public class HeadingConverter extends ConverterHelper {
for (int i = 0; i < nLen; i++) { for (int i = 0; i < nLen; i++) {
Node child = list.item(i); Node child = list.item(i);
if (child.getNodeType()==Node.ELEMENT_NODE && if (child.getNodeType()==Node.ELEMENT_NODE &&
!child.getNodeName().startsWith(XMLString.TEXT_REFERENCE_MARK)) { !(child.getNodeName().startsWith(XMLString.TEXT_REFERENCE_MARK) ||
child.getNodeName().startsWith(XMLString.TEXT_BOOKMARK))) {
return true; return true;
} }
} }

View file

@ -20,7 +20,7 @@
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.4 (2014-09-08) * Version 1.4 (2014-09-16)
* *
*/ */
@ -483,7 +483,7 @@ public class LaTeXConfig extends writer2latex.base.ConfigBase {
mathSymbols.put(sName, attr); mathSymbols.put(sName, attr);
} }
else if (elm.getTagName().equals("custom-preamble")) { else if (elm.getTagName().equals("custom-preamble")) {
StringBuffer buf = new StringBuffer(); StringBuilder buf = new StringBuilder();
Node child = elm.getFirstChild(); Node child = elm.getFirstChild();
while (child!=null) { while (child!=null) {
if (child.getNodeType()==Node.TEXT_NODE) { if (child.getNodeType()==Node.TEXT_NODE) {

View file

@ -20,7 +20,7 @@
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.4 (2014-09-03) * Version 1.4 (2014-09-16)
* *
*/ */
@ -38,7 +38,7 @@ public class LaTeXDocumentPortion {
private Vector<Object> nodes; // The collection of all nodes in this portion private Vector<Object> nodes; // The collection of all nodes in this portion
private StringBuffer curText; // The currently active node (always the last node) private StringBuilder curText; // The currently active node (always the last node)
private boolean bEmpty; // Is the active node empty? private boolean bEmpty; // Is the active node empty?
private boolean bWrap; // Do we allow line wrap in this portion? private boolean bWrap; // Do we allow line wrap in this portion?
@ -50,7 +50,7 @@ public class LaTeXDocumentPortion {
public LaTeXDocumentPortion(boolean bWrap){ public LaTeXDocumentPortion(boolean bWrap){
this.bWrap = bWrap; this.bWrap = bWrap;
nodes = new Vector<Object>(); nodes = new Vector<Object>();
curText = new StringBuffer(); curText = new StringBuilder();
bEmpty = true; bEmpty = true;
} }
@ -63,7 +63,7 @@ public class LaTeXDocumentPortion {
if (!bEmpty) { if (!bEmpty) {
// add the current node to the node list and create new current node // add the current node to the node list and create new current node
nodes.add(curText); nodes.add(curText);
curText = new StringBuffer(); curText = new StringBuilder();
bEmpty = true; bEmpty = true;
} }
nodes.add(ldp); nodes.add(ldp);
@ -96,8 +96,8 @@ public class LaTeXDocumentPortion {
for (int i=nStart; i<nEnd; i++) { osw.write(s.charAt(i)); } for (int i=nStart; i<nEnd; i++) { osw.write(s.charAt(i)); }
} }
/** write the contents of a StringBuffer to the output */ /** write the contents of a StringBuilder to the output */
private void writeBuffer(StringBuffer text, OutputStreamWriter osw, int nLineLen, String sNewline) throws IOException { private void writeBuffer(StringBuilder text, OutputStreamWriter osw, int nLineLen, String sNewline) throws IOException {
String s = text.toString(); String s = text.toString();
int nLen = s.length(); int nLen = s.length();
@ -157,8 +157,8 @@ public class LaTeXDocumentPortion {
} }
} }
/** write the contents of a StringBuffer to the output without wrap */ /** write the contents of a StringBuilder to the output without wrap */
private void writeBuffer(StringBuffer text, OutputStreamWriter osw, String sNewline) throws IOException { private void writeBuffer(StringBuilder text, OutputStreamWriter osw, String sNewline) throws IOException {
String s = text.toString(); String s = text.toString();
int nLen = s.length(); int nLen = s.length();
@ -193,10 +193,10 @@ public class LaTeXDocumentPortion {
((LaTeXDocumentPortion) nodes.get(i)).write(osw,nLineLen,sNewline); ((LaTeXDocumentPortion) nodes.get(i)).write(osw,nLineLen,sNewline);
} }
else if (bWrap && nLineLen>0) { else if (bWrap && nLineLen>0) {
writeBuffer((StringBuffer) nodes.get(i),osw,nLineLen,sNewline); writeBuffer((StringBuilder) nodes.get(i),osw,nLineLen,sNewline);
} }
else { else {
writeBuffer((StringBuffer) nodes.get(i),osw,sNewline); writeBuffer((StringBuilder) nodes.get(i),osw,sNewline);
} }
} }
if (!bEmpty) { // write current node as well if (!bEmpty) { // write current node as well
@ -214,14 +214,14 @@ public class LaTeXDocumentPortion {
* @return a string representation of the <code>LaTeXDocumentPortion</code> * @return a string representation of the <code>LaTeXDocumentPortion</code>
*/ */
public String toString() { public String toString() {
StringBuffer buf = new StringBuffer(); StringBuilder buf = new StringBuilder();
int n = nodes.size(); int n = nodes.size();
for (int i=0; i<n; i++) { for (int i=0; i<n; i++) {
if (nodes.get(i) instanceof LaTeXDocumentPortion) { if (nodes.get(i) instanceof LaTeXDocumentPortion) {
buf.append(((LaTeXDocumentPortion) nodes.get(i)).toString()); buf.append(((LaTeXDocumentPortion) nodes.get(i)).toString());
} }
else { else {
buf.append((StringBuffer) nodes.get(i)); buf.append((StringBuilder) nodes.get(i));
} }
} }
if (!bEmpty) { // write current node as well if (!bEmpty) { // write current node as well

View file

@ -18,7 +18,7 @@
* *
* Copyright: 2002-2014 by Henrik Just * Copyright: 2002-2014 by Henrik Just
* *
* Version 1.4 (2014-09-08) * Version 1.4 (2014-09-16)
* *
* All Rights Reserved. * All Rights Reserved.
*/ */
@ -1051,7 +1051,7 @@ public final class StarMathConverter implements writer2latex.api.StarMathConvert
// Grammar // Grammar
private String table(float fSize, Token eAlign){ private String table(float fSize, Token eAlign){
StringBuffer bufTable=new StringBuffer(); StringBuilder bufTable=new StringBuilder();
String sLine=line(fSize,eAlign,true); String sLine=line(fSize,eAlign,true);
if (curToken.eType==Token.NEWLINE){ // more than one line if (curToken.eType==Token.NEWLINE){ // more than one line
bufTable.append("\\begin{gathered}").append(sLine); bufTable.append("\\begin{gathered}").append(sLine);
@ -1126,7 +1126,7 @@ public final class StarMathConverter implements writer2latex.api.StarMathConvert
} }
private String expression(float fSize, Token eAlign){ private String expression(float fSize, Token eAlign){
StringBuffer bufExpression=new StringBuffer().append(relation(fSize,eAlign)); StringBuilder bufExpression=new StringBuilder().append(relation(fSize,eAlign));
while (curToken.nLevel>=5){ while (curToken.nLevel>=5){
bufExpression.append(relation(fSize,eAlign)); bufExpression.append(relation(fSize,eAlign));
} }
@ -1134,7 +1134,7 @@ public final class StarMathConverter implements writer2latex.api.StarMathConvert
} }
private String relation(float fSize, Token eAlign){ private String relation(float fSize, Token eAlign){
StringBuffer bufRelation=new StringBuffer().append(sum(fSize,eAlign)); StringBuilder bufRelation=new StringBuilder().append(sum(fSize,eAlign));
while (tokenInGroup(TGroup.RELATION)){ while (tokenInGroup(TGroup.RELATION)){
if (curToken.eType==Token.TRANSL) { bMultimapdotbothA=true; } if (curToken.eType==Token.TRANSL) { bMultimapdotbothA=true; }
else if (curToken.eType==Token.TRANSR) { bMultimapdotbothB=true; } else if (curToken.eType==Token.TRANSR) { bMultimapdotbothB=true; }
@ -1145,7 +1145,7 @@ public final class StarMathConverter implements writer2latex.api.StarMathConvert
} }
private String sum(float fSize, Token eAlign){ private String sum(float fSize, Token eAlign){
StringBuffer bufSum=new StringBuffer().append(product(fSize,eAlign)); StringBuilder bufSum=new StringBuilder().append(product(fSize,eAlign));
while (tokenInGroup(TGroup.SUM)){ while (tokenInGroup(TGroup.SUM)){
bufSum.append(opsubsup(fSize,eAlign)).append(product(fSize,eAlign)); bufSum.append(opsubsup(fSize,eAlign)).append(product(fSize,eAlign));
} }
@ -1262,7 +1262,7 @@ public final class StarMathConverter implements writer2latex.api.StarMathConvert
} }
private String blank(){ private String blank(){
StringBuffer bufBlank=new StringBuffer(); StringBuilder bufBlank=new StringBuilder();
while (tokenInGroup(TGroup.BLANK)){ while (tokenInGroup(TGroup.BLANK)){
bufBlank.append(curToken.sLaTeX); bufBlank.append(curToken.sLaTeX);
nextToken(); nextToken();
@ -1608,7 +1608,7 @@ public final class StarMathConverter implements writer2latex.api.StarMathConvert
private String stack(float fSize, Token eAlign){ private String stack(float fSize, Token eAlign){
nextToken(); nextToken();
if (curToken.eType==Token.LGROUP){ if (curToken.eType==Token.LGROUP){
StringBuffer bufStack=new StringBuffer().append("\\begin{matrix}"); StringBuilder bufStack=new StringBuilder().append("\\begin{matrix}");
nextToken(); nextToken();
bufStack.append(align(fSize,eAlign,true,true)); bufStack.append(align(fSize,eAlign,true,true));
while (curToken.eType==Token.POUND) { while (curToken.eType==Token.POUND) {
@ -1631,7 +1631,7 @@ public final class StarMathConverter implements writer2latex.api.StarMathConvert
private String matrix(float fSize, Token eAlign){ private String matrix(float fSize, Token eAlign){
nextToken(); nextToken();
if (curToken.eType==Token.LGROUP){ if (curToken.eType==Token.LGROUP){
StringBuffer bufMatrix = new StringBuffer().append("\\begin{matrix}"); StringBuilder bufMatrix = new StringBuilder().append("\\begin{matrix}");
int nCols = 1; int nCols = 1;
boolean bProtect = false; boolean bProtect = false;
do { do {

View file

@ -16,11 +16,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA * MA 02111-1307 USA
* *
* Copyright: 2002-2011 by Henrik Just * Copyright: 2002-2014 by Henrik Just
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.2 (2011-04-20) * Version 1.4 (2014-09-16)
* *
*/ */
@ -402,7 +402,7 @@ public class TableFormatter extends ConverterHelper {
return "\\hline"; return "\\hline";
} }
else { // individual borders for each column else { // individual borders for each column
StringBuffer buf = new StringBuffer(); StringBuilder buf = new StringBuilder();
buf.append("\\hhline{"); buf.append("\\hhline{");
for (int nCol=0; nCol<nColCount; nCol++) { for (int nCol=0; nCol<nColCount; nCol++) {
if (bHBorder[nRow][nCol]) { buf.append("-"); } if (bHBorder[nRow][nCol]) { buf.append("-"); }

View file

@ -10,7 +10,7 @@
<option name="inputencoding" value="ascii" /> <option name="inputencoding" value="ascii" />
<option name="use_geometry" value="true" /> <option name="use_geometry" value="true" />
<option name="use_fancyhdr" value="true" /> <option name="use_fancyhdr" value="true" />
<option name="use_ooomath" value="true" /> <option name="use_ooomath" value="false" />
<option name="use_pifont" value="true" /> <option name="use_pifont" value="true" />
<option name="use_ifsym" value="true" /> <option name="use_ifsym" value="true" />
<option name="use_wasysym" value="true" /> <option name="use_wasysym" value="true" />

View file

@ -10,7 +10,7 @@
<option name="documentclass" value="article" /> <option name="documentclass" value="article" />
<option name="backend" value="pdftex" /> <option name="backend" value="pdftex" />
<option name="inputencoding" value="ascii" /> <option name="inputencoding" value="ascii" />
<option name="use_ooomath" value="true" /> <option name="use_ooomath" value="false" />
<option name="use_pifont" value="true" /> <option name="use_pifont" value="true" />
<option name="use_ifsym" value="true" /> <option name="use_ifsym" value="true" />
<option name="use_wasysym" value="true" /> <option name="use_wasysym" value="true" />

View file

@ -16,11 +16,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA * MA 02111-1307 USA
* *
* Copyright: 2002-2011 by Henrik Just * Copyright: 2002-2014 by Henrik Just
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.2 (2011-05-07) * Version 1.4 (2014-09-16)
* *
*/ */
@ -453,7 +453,7 @@ public class ClassicI18n extends I18n {
*/ */
public String convert(String s, boolean bMathMode, String sLang){ public String convert(String s, boolean bMathMode, String sLang){
if (!bAlwaysUseDefaultLang && sLang!=null) { languages.add(sLang); } if (!bAlwaysUseDefaultLang && sLang!=null) { languages.add(sLang); }
StringBuffer buf=new StringBuffer(); StringBuilder buf=new StringBuilder();
int nFontenc = bAlwaysUseDefaultLang ? nDefaultFontenc : getFontenc(sLang); int nFontenc = bAlwaysUseDefaultLang ? nDefaultFontenc : getFontenc(sLang);
int nLen = s.length(); int nLen = s.length();
int i = 0; int i = 0;
@ -485,7 +485,7 @@ public class ClassicI18n extends I18n {
return buf.toString(); return buf.toString();
} }
private void convert(String s, int nStart, int nEnd, boolean bMathMode, String sLang, StringBuffer buf, int nFontenc) { private void convert(String s, int nStart, int nEnd, boolean bMathMode, String sLang, StringBuilder buf, int nFontenc) {
int nCurFontenc = nFontenc; int nCurFontenc = nFontenc;
ucparser.reset(table,s,nStart,nEnd); ucparser.reset(table,s,nStart,nEnd);
boolean bIsFirst = true; // Protect all dangerous characters at the start boolean bIsFirst = true; // Protect all dangerous characters at the start

View file

@ -16,11 +16,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA * MA 02111-1307 USA
* *
* Copyright: 2002-2012 by Henrik Just * Copyright: 2002-2014 by Henrik Just
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.2 (2012-02-27) * Version 1.4 (2014-09-16)
* *
*/ */
@ -134,7 +134,7 @@ public class XeTeXI18n extends I18n {
* @return the LaTeX string * @return the LaTeX string
*/ */
public String convert(String s, boolean bMathMode, String sLang){ public String convert(String s, boolean bMathMode, String sLang){
StringBuffer buf = new StringBuffer(); StringBuilder buf = new StringBuilder();
int nLen = s.length(); int nLen = s.length();
char c; char c;
if (bMathMode) { if (bMathMode) {
@ -190,7 +190,7 @@ public class XeTeXI18n extends I18n {
return buf.toString(); return buf.toString();
} }
private void convert(char c, StringBuffer buf) { private void convert(char c, StringBuilder buf) {
switch (c) { switch (c) {
case '#' : buf.append("\\#"); break; // Parameter case '#' : buf.append("\\#"); break; // Parameter
case '$' : buf.append("\\$"); break; // Math shift case '$' : buf.append("\\$"); break; // Math shift

View file

@ -16,11 +16,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA * MA 02111-1307 USA
* *
* Copyright: 2002-2008 by Henrik Just * Copyright: 2002-2014 by Henrik Just
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.0 (2008-11-22) * Version 1.4 (2014-09-16)
* *
*/ */
@ -66,7 +66,7 @@ public final class IndexMark {
} }
private final static String collectMark(Node node) { private final static String collectMark(Node node) {
StringBuffer buf = new StringBuffer(); StringBuilder buf = new StringBuilder();
String sId = Misc.getAttribute(node,XMLString.TEXT_ID); String sId = Misc.getAttribute(node,XMLString.TEXT_ID);
node = getRightNode(node); node = getRightNode(node);
while (node!=null) { while (node!=null) {

View file

@ -16,11 +16,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA * MA 02111-1307 USA
* *
* Copyright: 2002-2010 by Henrik Just * Copyright: 2002-2014 by Henrik Just
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.2 (2010-03-29) * Version 1.4 (2014-09-16)
* *
*/ */
@ -174,7 +174,7 @@ public class MetaData implements writer2latex.api.MetaData {
public Map<String,String> getUserDefinedMetaData() { return userdefined; } public Map<String,String> getUserDefinedMetaData() { return userdefined; }
private String getContent(Node node) { private String getContent(Node node) {
StringBuffer buf = new StringBuffer(); StringBuilder buf = new StringBuilder();
Node child = node.getFirstChild(); Node child = node.getFirstChild();
while (child!=null) { while (child!=null) {
if (child.getNodeType()==Node.TEXT_NODE) { if (child.getNodeType()==Node.TEXT_NODE) {

View file

@ -16,11 +16,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA * MA 02111-1307 USA
* *
* Copyright: 2002 by Henrik Just * Copyright: 2002-2014 by Henrik Just
* *
* All Rights Reserved. * 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 sSep;
private String sNameValueSep; private String sNameValueSep;
private boolean bEmpty = true; private boolean bEmpty = true;
private StringBuffer buf = new StringBuffer(); private StringBuilder buf = new StringBuilder();
public CSVList(String sSep, String sNameValueSep) { public CSVList(String sSep, String sNameValueSep) {
this.sSep=sSep; this.sSep=sSep;

View file

@ -16,11 +16,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA * MA 02111-1307 USA
* *
* Copyright: 2002-2010 by Henrik Just * Copyright: 2002-2014 by Henrik Just
* *
* All Rights Reserved. * 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){ public void addName(String sName){
if (containsName(sName)) { return; } if (containsName(sName)) { return; }
StringBuffer outbuf=new StringBuffer(); StringBuilder outbuf=new StringBuilder();
SimpleInputBuffer inbuf=new SimpleInputBuffer(sName); SimpleInputBuffer inbuf=new SimpleInputBuffer(sName);
// Don't start with a digit // Don't start with a digit

View file

@ -20,7 +20,7 @@
* *
* All Rights Reserved. * 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) { public static final String int2roman(int number) {
assert number>0; // Only works for positive numbers! assert number>0; // Only works for positive numbers!
StringBuffer roman=new StringBuffer(); StringBuilder roman=new StringBuilder();
while (number>=1000) { roman.append('m'); number-=1000; } while (number>=1000) { roman.append('m'); number-=1000; }
if (number>=900) { roman.append("cm"); number-=900; } if (number>=900) { roman.append("cm"); number-=900; }
if (number>=500) { roman.append('d'); number-=500; } if (number>=500) { roman.append('d'); number-=500; }
@ -404,7 +404,7 @@ public class Misc{
/* utility method that collects PCDATA content of an element */ /* utility method that collects PCDATA content of an element */
public static String getPCDATA(Node node) { public static String getPCDATA(Node node) {
StringBuffer buf = new StringBuffer(); StringBuilder buf = new StringBuilder();
if (node.hasChildNodes()) { if (node.hasChildNodes()) {
NodeList nl = node.getChildNodes(); NodeList nl = node.getChildNodes();
int nLen = nl.getLength(); int nLen = nl.getLength();

View file

@ -16,11 +16,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA * MA 02111-1307 USA
* *
* Copyright: 2002-2012 by Henrik Just * Copyright: 2002-2014 by Henrik Just
* *
* All Rights Reserved. * 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 { public class SimpleDOMBuilder {
private Document dom=null; private Document dom=null;
private Element currentElement=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. * 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) { public boolean startElement(String sTagName) {
if (currentElement!=null) { if (currentElement!=null) {
flushCharacters();
currentElement = (Element) currentElement.appendChild(dom.createElement(sTagName)); currentElement = (Element) currentElement.appendChild(dom.createElement(sTagName));
} }
else { else {
@ -74,6 +76,7 @@ public class SimpleDOMBuilder {
*/ */
public boolean endElement() { public boolean endElement() {
if (currentElement!=null) { if (currentElement!=null) {
flushCharacters();
if (currentElement!=dom.getDocumentElement()) { if (currentElement!=dom.getDocumentElement()) {
currentElement=(Element) currentElement.getParentNode(); 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 * @param sText
* @return true on success, false if there is no current element * @return true on success, false if there is no current element
*/ */
public boolean characters(String sText) { public boolean characters(String sText) {
if (currentElement!=null) { if (currentElement!=null) {
currentElement.appendChild(dom.createTextNode(sText)); charBuffer.append(sText);
return true; return true;
} }
return false; return false;
} }
private void flushCharacters() {
if (charBuffer.length()>0) {
currentElement.appendChild(dom.createTextNode(charBuffer.toString()));
charBuffer.setLength(0);
}
}
/** /**
* Get the DOM tree * Get the DOM tree
* *

View file

@ -20,7 +20,7 @@
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.4 (2014-09-05) * Version 1.4 (2014-09-16)
* *
*/ */
@ -538,7 +538,7 @@ public class Converter extends ConverterBase {
/* get inline text, ignoring any draw objects, footnotes, formatting and hyperlinks */ /* get inline text, ignoring any draw objects, footnotes, formatting and hyperlinks */
protected String getPlainInlineText(Node node) { protected String getPlainInlineText(Node node) {
StringBuffer buf = new StringBuffer(); StringBuilder buf = new StringBuilder();
Node child = node.getFirstChild(); Node child = node.getFirstChild();
while (child!=null) { while (child!=null) {
short nodeType = child.getNodeType(); short nodeType = child.getNodeType();
@ -575,7 +575,7 @@ public class Converter extends ConverterBase {
public void handleOfficeAnnotation(Node onode, Node hnode) { public void handleOfficeAnnotation(Node onode, Node hnode) {
if (config.xhtmlNotes()) { if (config.xhtmlNotes()) {
// Extract the text from the paragraphs, separate paragraphs with newline // Extract the text from the paragraphs, separate paragraphs with newline
StringBuffer buf = new StringBuffer(); StringBuilder buf = new StringBuilder();
Element creator = null; Element creator = null;
Element date = null; Element date = null;
Node child = onode.getFirstChild(); Node child = onode.getFirstChild();

View file

@ -16,11 +16,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA * MA 02111-1307 USA
* *
* Copyright: 2002-2011 by Henrik Just * Copyright: 2002-2014 by Henrik Just
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.2 (2011-02-17) * Version 1.4 (2014-09-16)
* *
*/ */
@ -75,7 +75,7 @@ public class CssDocument implements OutputFile {
public void read(InputStream is) throws IOException { public void read(InputStream is) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(is,"UTF-8")); BufferedReader reader = new BufferedReader(new InputStreamReader(is,"UTF-8"));
StringBuffer buf = new StringBuffer(); StringBuilder buf = new StringBuilder();
String sLine; String sLine;
while ((sLine=reader.readLine())!=null) { while ((sLine=reader.readLine())!=null) {
buf.append(sLine).append('\n'); buf.append(sLine).append('\n');

View file

@ -20,7 +20,7 @@
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.4 (2014-09-07) * Version 1.4 (2014-09-16)
* *
*/ */
@ -62,7 +62,7 @@ public class FrameStyleConverter extends StyleWithPropertiesConverterHelper {
*/ */
public String getStyleDeclarations(String sIndent) { public String getStyleDeclarations(String sIndent) {
if (bConvertStyles) { if (bConvertStyles) {
StringBuffer buf = new StringBuffer(); StringBuilder buf = new StringBuilder();
buf.append(super.getStyleDeclarations(sIndent)); buf.append(super.getStyleDeclarations(sIndent));
Enumeration<String> names = styleNames.keys(); Enumeration<String> names = styleNames.keys();
while (names.hasMoreElements()) { while (names.hasMoreElements()) {
@ -267,7 +267,7 @@ public class FrameStyleConverter extends StyleWithPropertiesConverterHelper {
// Scale the border with while preserving the rest of the attribute // Scale the border with while preserving the rest of the attribute
public String borderScale(String sBorder) { public String borderScale(String sBorder) {
SimpleInputBuffer in = new SimpleInputBuffer(sBorder); SimpleInputBuffer in = new SimpleInputBuffer(sBorder);
StringBuffer out = new StringBuffer(); StringBuilder out = new StringBuilder();
while (in.peekChar()!='\0') { while (in.peekChar()!='\0') {
// Skip spaces // Skip spaces
while(in.peekChar()==' ') { out.append(" "); in.getChar(); } while(in.peekChar()==' ') { out.append(" "); in.getChar(); }
@ -287,7 +287,7 @@ public class FrameStyleConverter extends StyleWithPropertiesConverterHelper {
// Must escape certain characters in the url property // Must escape certain characters in the url property
private String escapeUrl(String sUrl) { private String escapeUrl(String sUrl) {
StringBuffer buf = new StringBuffer(); StringBuilder buf = new StringBuilder();
int nLen = sUrl.length(); int nLen = sUrl.length();
for (int i=0; i<nLen; i++) { for (int i=0; i<nLen; i++) {
char c = sUrl.charAt(i); char c = sUrl.charAt(i);

View file

@ -16,11 +16,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA * MA 02111-1307 USA
* *
* Copyright: 2002-2010 by Henrik Just * Copyright: 2002-2014 by Henrik Just
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.2 (2010-05-09) * Version 1.4 (2014-09-16)
* *
*/package writer2latex.xhtml; */package writer2latex.xhtml;
@ -42,7 +42,7 @@ public class HeadingStyleConverter extends StyleConverterHelper {
@Override @Override
public String getStyleDeclarations(String sIndent) { public String getStyleDeclarations(String sIndent) {
if (bConvertStyles) { if (bConvertStyles) {
StringBuffer buf = new StringBuffer(); StringBuilder buf = new StringBuilder();
for (int i=1; i<=6; i++) { for (int i=1; i<=6; i++) {
if (ofr.getHeadingStyle(i)!=null) { if (ofr.getHeadingStyle(i)!=null) {
CSVList props = new CSVList(";"); CSVList props = new CSVList(";");

View file

@ -16,11 +16,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA * MA 02111-1307 USA
* *
* Copyright: 2002-2012 by Henrik Just * Copyright: 2002-2014 by Henrik Just
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.2 (2012-03-07) * Version 1.4 (2014-09-16)
* *
*/ */
@ -86,7 +86,7 @@ public class ListStyleConverter extends StyleConverterHelper {
*/ */
public String getStyleDeclarations(String sIndent) { public String getStyleDeclarations(String sIndent) {
if (bConvertStyles) { if (bConvertStyles) {
StringBuffer buf = new StringBuffer(); StringBuilder buf = new StringBuilder();
Enumeration<String> names = styleNames.keys(); Enumeration<String> names = styleNames.keys();
while (names.hasMoreElements()) { while (names.hasMoreElements()) {
String sDisplayName = names.nextElement(); String sDisplayName = names.nextElement();

View file

@ -20,7 +20,7 @@
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.4 (2014-09-01) * Version 1.4 (2014-09-16)
* *
*/ */
@ -259,7 +259,7 @@ public class MathConverter extends ConverterHelper {
// with real unicode positions. // with real unicode positions.
private String replacePrivateChars(String s) { private String replacePrivateChars(String s) {
int nLen = s.length(); int nLen = s.length();
StringBuffer buf = new StringBuffer(nLen); StringBuilder buf = new StringBuilder(nLen);
for (int i=0; i<nLen; i++) { for (int i=0; i<nLen; i++) {
buf.append(replacePrivateChar(s.charAt(i))); buf.append(replacePrivateChar(s.charAt(i)));
} }

View file

@ -16,11 +16,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA * MA 02111-1307 USA
* *
* Copyright: 2002-2011 by Henrik Just * Copyright: 2002-2014 by Henrik Just
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.2 (2011-03-21) * Version 1.4 (2014-09-16)
* *
*/ */
@ -130,7 +130,7 @@ public class PageStyleConverter extends StyleConverterHelper {
* @param sIndent a String of spaces to add before each line * @param sIndent a String of spaces to add before each line
*/ */
public String getStyleDeclarations(String sIndent) { public String getStyleDeclarations(String sIndent) {
StringBuffer buf = new StringBuffer(); StringBuilder buf = new StringBuilder();
// This will be master pages for presentations only // This will be master pages for presentations only
Enumeration<String> names = styleNames.keys(); Enumeration<String> names = styleNames.keys();

View file

@ -16,11 +16,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA * MA 02111-1307 USA
* *
* Copyright: 2002-2010 by Henrik Just * Copyright: 2002-2014 by Henrik Just
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.2 (2010-03-01) * Version 1.4 (2014-09-16)
* *
*/ */
@ -85,7 +85,7 @@ public class PresentationStyleConverter extends FrameStyleConverter {
*/ */
public String getStyleDeclarations(String sIndent) { public String getStyleDeclarations(String sIndent) {
if (bConvertStyles) { if (bConvertStyles) {
StringBuffer buf = new StringBuffer(); StringBuilder buf = new StringBuilder();
buf.append(super.getStyleDeclarations(sIndent)); buf.append(super.getStyleDeclarations(sIndent));
Enumeration<String> names = outlineStyleNames.keys(); Enumeration<String> names = outlineStyleNames.keys();
while (names.hasMoreElements()) { while (names.hasMoreElements()) {

View file

@ -20,7 +20,7 @@
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.4 (2014-08-13) * Version 1.4 (2014-09-16)
* *
*/ */
@ -123,7 +123,7 @@ class StyleConverter extends ConverterHelper {
public String exportStyles(boolean bIndent) { public String exportStyles(boolean bIndent) {
String sIndent = bIndent ? " " : ""; String sIndent = bIndent ? " " : "";
StringBuffer buf = new StringBuffer(); StringBuilder buf = new StringBuilder();
// Export default style // Export default style
if (config.xhtmlCustomStylesheet().length()==0 && if (config.xhtmlCustomStylesheet().length()==0 &&

View file

@ -16,11 +16,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA * MA 02111-1307 USA
* *
* Copyright: 2002-2012 by Henrik Just * Copyright: 2002-2014 by Henrik Just
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.2 (2012-03-07) * Version 1.4 (2014-09-16)
* *
*/ */
@ -94,7 +94,7 @@ public abstract class StyleWithPropertiesConverterHelper
*/ */
public String getStyleDeclarations(String sIndent) { public String getStyleDeclarations(String sIndent) {
if (bConvertStyles) { if (bConvertStyles) {
StringBuffer buf = new StringBuffer(); StringBuilder buf = new StringBuilder();
Enumeration<String> names = styleNames.keys(); Enumeration<String> names = styleNames.keys();
while (names.hasMoreElements()) { while (names.hasMoreElements()) {
String sDisplayName = names.nextElement(); String sDisplayName = names.nextElement();

View file

@ -16,11 +16,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA * MA 02111-1307 USA
* *
* Copyright: 2002-2010 by Henrik Just * Copyright: 2002-2014 by Henrik Just
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.2 (2010-12-29) * Version 1.4 (2014-09-16)
* *
*/ */
@ -136,7 +136,7 @@ public class TextStyleConverter extends StyleWithPropertiesConverterHelper {
* @param sIndent a String of spaces to add before each line * @param sIndent a String of spaces to add before each line
*/ */
public String getStyleDeclarations(String sIndent) { public String getStyleDeclarations(String sIndent) {
StringBuffer buf = new StringBuffer(); StringBuilder buf = new StringBuilder();
buf.append(super.getStyleDeclarations(sIndent)); buf.append(super.getStyleDeclarations(sIndent));
if (bConvertStyles) { if (bConvertStyles) {
// Export anchor styles // Export anchor styles