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

@ -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-16)
*
*/
@ -969,7 +969,7 @@ public class FieldConverter extends ConverterHelper {
// For the argument to a href, we have to escape or encode certain characters
private String escapeHref(String s, boolean bInFootnote) {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
for (int i=0; i<s.length(); i++) {
if (bInFootnote && s.charAt(i)=='#') { buf.append("\\#"); }
else if (bInFootnote && s.charAt(i)=='%') { buf.append("\\%"); }

View file

@ -20,7 +20,7 @@
*
* 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++) {
Node child = list.item(i);
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;
}
}

View file

@ -20,7 +20,7 @@
*
* 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);
}
else if (elm.getTagName().equals("custom-preamble")) {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
Node child = elm.getFirstChild();
while (child!=null) {
if (child.getNodeType()==Node.TEXT_NODE) {

View file

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

View file

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

View file

@ -16,11 +16,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
* Copyright: 2002-2011 by Henrik Just
* Copyright: 2002-2014 by Henrik Just
*
* 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";
}
else { // individual borders for each column
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
buf.append("\\hhline{");
for (int nCol=0; nCol<nColCount; nCol++) {
if (bHBorder[nRow][nCol]) { buf.append("-"); }

View file

@ -10,7 +10,7 @@
<option name="inputencoding" value="ascii" />
<option name="use_geometry" 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_ifsym" value="true" />
<option name="use_wasysym" value="true" />

View file

@ -10,7 +10,7 @@
<option name="documentclass" value="article" />
<option name="backend" value="pdftex" />
<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_ifsym" value="true" />
<option name="use_wasysym" value="true" />

View file

@ -16,11 +16,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
* Copyright: 2002-2011 by Henrik Just
* Copyright: 2002-2014 by Henrik Just
*
* 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){
if (!bAlwaysUseDefaultLang && sLang!=null) { languages.add(sLang); }
StringBuffer buf=new StringBuffer();
StringBuilder buf=new StringBuilder();
int nFontenc = bAlwaysUseDefaultLang ? nDefaultFontenc : getFontenc(sLang);
int nLen = s.length();
int i = 0;
@ -485,7 +485,7 @@ public class ClassicI18n extends I18n {
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;
ucparser.reset(table,s,nStart,nEnd);
boolean bIsFirst = true; // Protect all dangerous characters at the start

View file

@ -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-02-27)
* Version 1.4 (2014-09-16)
*
*/
@ -134,7 +134,7 @@ public class XeTeXI18n extends I18n {
* @return the LaTeX string
*/
public String convert(String s, boolean bMathMode, String sLang){
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
int nLen = s.length();
char c;
if (bMathMode) {
@ -190,7 +190,7 @@ public class XeTeXI18n extends I18n {
return buf.toString();
}
private void convert(char c, StringBuffer buf) {
private void convert(char c, StringBuilder buf) {
switch (c) {
case '#' : buf.append("\\#"); break; // Parameter
case '$' : buf.append("\\$"); break; // Math shift