Handle BibTeX files with non-ascii encodings
git-svn-id: svn://svn.code.sf.net/p/writer2latex/code/trunk@263 f0f2a975-2e09-46c8-9428-3b39399b9f3c
This commit is contained in:
parent
5e9dfc8678
commit
658952d328
22 changed files with 207 additions and 113 deletions
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.6 (2015-05-29)
|
||||
* Version 1.6 (2015-07-24)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -61,6 +61,7 @@ import com.sun.star.text.XTextViewCursor;
|
|||
import com.sun.star.text.XTextViewCursorSupplier;
|
||||
import com.sun.star.ui.dialogs.ExecutableDialogResults;
|
||||
import com.sun.star.uno.AnyConverter;
|
||||
import com.sun.star.uno.Exception;
|
||||
import com.sun.star.uno.UnoRuntime;
|
||||
import com.sun.star.uno.XComponentContext;
|
||||
|
||||
|
@ -68,7 +69,10 @@ import org.jbibtex.ParseException;
|
|||
import org.openoffice.da.comp.w2lcommon.helper.DialogAccess;
|
||||
import org.openoffice.da.comp.w2lcommon.helper.DialogBase;
|
||||
import org.openoffice.da.comp.w2lcommon.helper.MessageBox;
|
||||
import org.openoffice.da.comp.w2lcommon.helper.RegistryHelper;
|
||||
import org.openoffice.da.comp.w2lcommon.helper.XPropertySetHelper;
|
||||
|
||||
import writer2latex.latex.i18n.ClassicI18n;
|
||||
import writer2latex.office.BibMark;
|
||||
import writer2latex.office.BibMark.EntryType;
|
||||
import writer2latex.util.Misc;
|
||||
|
@ -95,6 +99,9 @@ public class BibTeXDialog extends DialogBase implements com.sun.star.lang.XIniti
|
|||
// The BibTeX directory (passed at initialization)
|
||||
File bibTeXDirectory = null;
|
||||
|
||||
// The encoding for BibTeX files (set in constructor from the registry)
|
||||
String sBibTeXJavaEncoding = null;
|
||||
|
||||
// Cache of BibTeX files in the BibTeX directory
|
||||
File[] files = null;
|
||||
|
||||
|
@ -121,6 +128,22 @@ public class BibTeXDialog extends DialogBase implements com.sun.star.lang.XIniti
|
|||
/** Create a new BibTeXDialog */
|
||||
public BibTeXDialog(XComponentContext xContext) {
|
||||
super(xContext);
|
||||
sBibTeXJavaEncoding = getBibTeXJavaEncoding();
|
||||
}
|
||||
|
||||
private String getBibTeXJavaEncoding() {
|
||||
RegistryHelper registry = new RegistryHelper(xContext);
|
||||
try {
|
||||
Object view = registry.getRegistryView(BibliographyDialog.REGISTRY_PATH, false);
|
||||
XPropertySet xProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,view);
|
||||
int nBibTeXEncoding = XPropertySetHelper.getPropertyValueAsShort(xProps, "BibTeXEncoding"); //$NON-NLS-1$
|
||||
registry.disposeRegistryView(view);
|
||||
return ClassicI18n.writeJavaEncoding(nBibTeXEncoding);
|
||||
}
|
||||
catch (Exception e) {
|
||||
// Failed to get registry view
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Return the name of the library containing the dialog
|
||||
|
@ -257,11 +280,12 @@ public class BibTeXDialog extends DialogBase implements com.sun.star.lang.XIniti
|
|||
int nFile = getListBoxSelectedItem("File"); //$NON-NLS-1$
|
||||
if (nFile>=0) {
|
||||
try {
|
||||
currentFile = new BibTeXReader(files[nFile]);
|
||||
currentFile = new BibTeXReader(files[nFile],sBibTeXJavaEncoding);
|
||||
} catch (IOException e) {
|
||||
System.err.println(e.getMessage());
|
||||
currentFile = null;
|
||||
} catch (ParseException e) {
|
||||
System.out.println(e.getMessage());
|
||||
System.err.println(e.getMessage());
|
||||
currentFile = null;
|
||||
}
|
||||
|
||||
|
@ -502,10 +526,12 @@ public class BibTeXDialog extends DialogBase implements com.sun.star.lang.XIniti
|
|||
BibTeXReader[] readers = new BibTeXReader[nFiles];
|
||||
for (int i=0; i<nFiles; i++) {
|
||||
try {
|
||||
readers[i] = new BibTeXReader(files[i]);
|
||||
readers[i] = new BibTeXReader(files[i],sBibTeXJavaEncoding);
|
||||
} catch (IOException e) {
|
||||
System.err.println(e.getMessage());
|
||||
readers[i] = null;
|
||||
} catch (ParseException e) {
|
||||
System.err.println(e.getMessage());
|
||||
readers[i] = null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,19 +16,20 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Copyright: 2002-2014 by Henrik Just
|
||||
* Copyright: 2002-2015 by Henrik Just
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.6 (2014-12-27)
|
||||
* Version 1.6 (2015-07-24)
|
||||
*
|
||||
*/
|
||||
|
||||
package org.openoffice.da.comp.writer2latex;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.io.StringReader;
|
||||
import java.util.Collection;
|
||||
|
@ -43,6 +44,7 @@ import org.jbibtex.Key;
|
|||
import org.jbibtex.LaTeXParser;
|
||||
import org.jbibtex.LaTeXPrinter;
|
||||
import org.jbibtex.ParseException;
|
||||
import org.jbibtex.TokenMgrException;
|
||||
import org.jbibtex.Value;
|
||||
|
||||
import writer2latex.bibtex.BibTeXEntryMap;
|
||||
|
@ -56,16 +58,19 @@ import writer2latex.office.BibMark.EntryType;
|
|||
public class BibTeXReader {
|
||||
|
||||
private File file;
|
||||
private String sEncoding;
|
||||
private Map<String, BibMark> entries;
|
||||
|
||||
/** Construct a new <code>BibTeXReader</code> based on a file
|
||||
*
|
||||
* @param file the file to read
|
||||
* @param sEncoding the character encoding of the file
|
||||
* @throws IOException if any error occurs reading the file
|
||||
* @throws ParseException if any error occurs interpreting the contents of the file
|
||||
*/
|
||||
public BibTeXReader(File file) throws IOException, ParseException {
|
||||
public BibTeXReader(File file, String sEncoding) throws IOException, ParseException {
|
||||
this.file = file;
|
||||
this.sEncoding = sEncoding;
|
||||
reload();
|
||||
}
|
||||
|
||||
|
@ -73,8 +78,8 @@ public class BibTeXReader {
|
|||
*/
|
||||
public void reload() throws IOException, ParseException {
|
||||
entries = new HashMap<String, BibMark>();
|
||||
BibTeXDatabase database = parseBibTeX(file);
|
||||
readEntries(database);
|
||||
BibTeXDatabase database = parseBibTeX(file,sEncoding);
|
||||
readEntries(database);
|
||||
}
|
||||
|
||||
/** Get the file associated with this <code>BibTeXReader</code>
|
||||
|
@ -93,8 +98,9 @@ public class BibTeXReader {
|
|||
return entries;
|
||||
}
|
||||
|
||||
private static BibTeXDatabase parseBibTeX(File file) throws ParseException, IOException {
|
||||
Reader reader = new FileReader(file);
|
||||
private static BibTeXDatabase parseBibTeX(File file, String sEncoding) throws ParseException, IOException {
|
||||
FileInputStream is = new FileInputStream(file);
|
||||
Reader reader = new InputStreamReader(is,sEncoding);
|
||||
try {
|
||||
BibTeXParser parser = new BibTeXParser() {
|
||||
@Override
|
||||
|
@ -114,7 +120,8 @@ public class BibTeXReader {
|
|||
};
|
||||
return parser.parse(reader);
|
||||
} finally {
|
||||
reader.close();
|
||||
if (reader!=null) { reader.close(); }
|
||||
if (is!=null) { is.close(); }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -148,6 +155,9 @@ public class BibTeXReader {
|
|||
} catch (ParseException e) {
|
||||
// If parsing fails, return the original string
|
||||
return string;
|
||||
} catch (TokenMgrException e) {
|
||||
// If the string contains invalid characters, return the original string
|
||||
return string;
|
||||
} finally {
|
||||
try {
|
||||
reader.close();
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.6 (2015-05-29)
|
||||
* Version 1.6 (2015-07-23)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -179,6 +179,8 @@ public final class BibliographyDialog
|
|||
XPropertySetHelper.getPropertyValueAsShort(xProps, "BibTeXLocation")); //$NON-NLS-1$
|
||||
dlg.setTextFieldText("BibTeXDir", //$NON-NLS-1$
|
||||
XPropertySetHelper.getPropertyValueAsString(xProps, "BibTeXDir")); //$NON-NLS-1$
|
||||
dlg.setListBoxSelectedItem("BibTeXEncoding", //$NON-NLS-1$
|
||||
XPropertySetHelper.getPropertyValueAsShort(xProps, "BibTeXEncoding")); //$NON-NLS-1$
|
||||
dlg.setCheckBoxStateAsBoolean("UseNatbib", //$NON-NLS-1$
|
||||
XPropertySetHelper.getPropertyValueAsBoolean(xProps, "UseNatbib")); //$NON-NLS-1$
|
||||
dlg.setTextFieldText("NatbibOptions", //$NON-NLS-1$
|
||||
|
@ -206,6 +208,7 @@ public final class BibliographyDialog
|
|||
XPropertySetHelper.setPropertyValue(xProps, "IncludeOriginalCitations", dlg.getCheckBoxStateAsBoolean("IncludeOriginalCitations")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
XPropertySetHelper.setPropertyValue(xProps, "BibTeXLocation", dlg.getListBoxSelectedItem("BibTeXLocation")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
XPropertySetHelper.setPropertyValue(xProps, "BibTeXDir", dlg.getTextFieldText("BibTeXDir")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
XPropertySetHelper.setPropertyValue(xProps, "BibTeXEncoding", dlg.getListBoxSelectedItem("BibTeXEncoding")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
XPropertySetHelper.setPropertyValue(xProps, "UseNatbib", dlg.getCheckBoxStateAsBoolean("UseNatbib")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
XPropertySetHelper.setPropertyValue(xProps, "NatbibOptions", dlg.getTextFieldText("NatbibOptions")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
|
@ -263,6 +266,8 @@ public final class BibliographyDialog
|
|||
dlg.setControlEnabled("BibTeXDirLabel", bEnableSettings && bEnableDir); //$NON-NLS-1$
|
||||
dlg.setControlEnabled("BibTeXDir", bEnableSettings && bEnableDir); //$NON-NLS-1$
|
||||
dlg.setControlEnabled("BibTeXDirButton", bEnableSettings && bEnableDir); //$NON-NLS-1$
|
||||
dlg.setControlEnabled("BibTeXEncodingLabel", bEnableSettings); //$NON-NLS-1$
|
||||
dlg.setControlEnabled("BibTeXEncoding", bEnableSettings); //$NON-NLS-1$
|
||||
dlg.setControlEnabled("ConvertZoteroCitations", bEnableSettings); //$NON-NLS-1$
|
||||
dlg.setControlEnabled("ConvertJabRefCitations", bEnableSettings); //$NON-NLS-1$
|
||||
dlg.setControlEnabled("IncludeOriginalCitations", bEnableSettings && bEnableOriginalCitations); //$NON-NLS-1$
|
||||
|
@ -348,6 +353,3 @@ public final class BibliographyDialog
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.6 (2015-05-29)
|
||||
* Version 1.6 (2015-07-23)
|
||||
*
|
||||
*/
|
||||
package org.openoffice.da.comp.writer2latex;
|
||||
|
@ -34,6 +34,7 @@ import org.openoffice.da.comp.w2lcommon.helper.PropertyHelper;
|
|||
import org.openoffice.da.comp.w2lcommon.helper.RegistryHelper;
|
||||
import org.openoffice.da.comp.w2lcommon.helper.XPropertySetHelper;
|
||||
|
||||
import writer2latex.latex.i18n.ClassicI18n;
|
||||
import writer2latex.util.CSVList;
|
||||
import writer2latex.util.Misc;
|
||||
|
||||
|
@ -107,6 +108,8 @@ public class LaTeXUNOPublisher extends UNOPublisher {
|
|||
XPropertySetHelper.getPropertyValueAsString(xProps, "BibTeXDir")); //$NON-NLS-1$
|
||||
if (XPropertySetHelper.getPropertyValueAsBoolean(xProps, "UseExternalBibTeXFiles")) { //$NON-NLS-1$
|
||||
filterHelper.put("external_bibtex_files", sBibTeXFiles); //$NON-NLS-1$
|
||||
filterHelper.put("bibtex_encoding", ClassicI18n.writeInputenc( //$NON-NLS-1$
|
||||
XPropertySetHelper.getPropertyValueAsShort(xProps, "BibTeXEncoding"))); //$NON-NLS-1$
|
||||
if (XPropertySetHelper.getPropertyValueAsBoolean(xProps, "ConvertZoteroCitations")) { //$NON-NLS-1$
|
||||
filterHelper.put("zotero_bibtex_files", sBibTeXFiles); //$NON-NLS-1$
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.6 (2015-07-01)
|
||||
* Version 1.6 (2015-07-27)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -32,8 +32,8 @@ package writer2latex.api;
|
|||
public class ConverterFactory {
|
||||
|
||||
// Version information
|
||||
private static final String VERSION = "1.5.3";
|
||||
private static final String DATE = "2015-07-01";
|
||||
private static final String VERSION = "1.6";
|
||||
private static final String DATE = "2015-07-27";
|
||||
|
||||
/** Return the Writer2LaTeX version in the form
|
||||
* (major version).(minor version).(patch level)<br/>
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.6 (2015-07-01)
|
||||
* Version 1.6 (2015-07-27)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -33,6 +33,7 @@ import org.w3c.dom.Element;
|
|||
import writer2latex.base.BibliographyGenerator;
|
||||
import writer2latex.bibtex.BibTeXDocument;
|
||||
|
||||
import writer2latex.latex.i18n.ClassicI18n;
|
||||
import writer2latex.latex.util.BeforeAfter;
|
||||
import writer2latex.latex.util.Context;
|
||||
|
||||
|
@ -60,6 +61,8 @@ class BibConverter extends ConverterHelper {
|
|||
|
||||
private BibTeXDocument bibDoc = null;
|
||||
private boolean bUseBibTeX;
|
||||
private String sBibTeXEncoding = null;
|
||||
private String sDocumentEncoding = null;
|
||||
|
||||
/** Construct a new BibConverter.
|
||||
*
|
||||
|
@ -74,6 +77,16 @@ class BibConverter extends ConverterHelper {
|
|||
bibDoc = new BibTeXDocument(palette.getOutFileName(),false,ofr);
|
||||
}
|
||||
|
||||
// We need to use a different encoding for the BibTeX files
|
||||
if (config.externalBibtexFiles().length()>0) {
|
||||
int nBibTeXEncoding = config.getBibtexEncoding();
|
||||
int nDocumentEncoding = config.getInputencoding();
|
||||
if (config.getBackend()!=LaTeXConfig.XETEX && nBibTeXEncoding>-1 && nBibTeXEncoding!=nDocumentEncoding) {
|
||||
sBibTeXEncoding = ClassicI18n.writeInputenc(nBibTeXEncoding);
|
||||
sDocumentEncoding = ClassicI18n.writeInputenc(nDocumentEncoding);
|
||||
}
|
||||
}
|
||||
|
||||
// We need to export it
|
||||
bUseBibTeX = config.useBibtex();
|
||||
}
|
||||
|
@ -199,10 +212,17 @@ class BibConverter extends ConverterHelper {
|
|||
.append("}").nl();
|
||||
|
||||
// Use BibTeX file from configuration, or exported BibTeX file
|
||||
// TODO: For XeTeX, probably use \XeTeXdefaultencoding?
|
||||
if (config.externalBibtexFiles().length()>0) {
|
||||
ldp.append("\\bibliography{")
|
||||
if (sBibTeXEncoding!=null) {
|
||||
ldp.append("\\inputencoding{").append(sBibTeXEncoding).append("}").nl();
|
||||
}
|
||||
ldp.append("\\bibliography{")
|
||||
.append(config.externalBibtexFiles())
|
||||
.append("}").nl();
|
||||
if (sBibTeXEncoding!=null) {
|
||||
ldp.append("\\inputencoding{").append(sDocumentEncoding).append("}").nl();
|
||||
}
|
||||
}
|
||||
else {
|
||||
ldp.append("\\bibliography{")
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.6 (2015-06-23)
|
||||
* Version 1.6 (2015-07-23)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -49,7 +49,7 @@ public class LaTeXConfig extends writer2latex.base.ConfigBase {
|
|||
/////////////////////////////////////////////////////////////////////////
|
||||
// I. Define items needed by ConfigBase
|
||||
|
||||
protected int getOptionCount() { return 72; }
|
||||
protected int getOptionCount() { return 73; }
|
||||
protected String getDefaultConfigPath() { return "/writer2latex/latex/config/"; }
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
@ -144,45 +144,46 @@ public class LaTeXConfig extends writer2latex.base.ConfigBase {
|
|||
private static final int USE_BIBTEX = 30;
|
||||
private static final int BIBTEX_STYLE = 31;
|
||||
private static final int EXTERNAL_BIBTEX_FILES = 32;
|
||||
private static final int ZOTERO_BIBTEX_FILES = 33;
|
||||
private static final int JABREF_BIBTEX_FILES = 34;
|
||||
private static final int INCLUDE_ORIGINAL_CITATIONS = 35;
|
||||
private static final int USE_NATBIB = 36;
|
||||
private static final int NATBIB_OPTIONS = 37;
|
||||
private static final int FONT = 38;
|
||||
private static final int FORMATTING = 39;
|
||||
private static final int PAGE_FORMATTING = 40;
|
||||
private static final int OTHER_STYLES = 41;
|
||||
private static final int IMAGE_CONTENT = 42;
|
||||
private static final int TABLE_CONTENT = 43;
|
||||
private static final int TABLE_FIRST_HEAD_STYLE = 44;
|
||||
private static final int TABLE_HEAD_STYLE = 45;
|
||||
private static final int TABLE_FOOT_STYLE = 46;
|
||||
private static final int TABLE_LAST_FOOT_STYLE = 47;
|
||||
private static final int IGNORE_HARD_PAGE_BREAKS = 48;
|
||||
private static final int IGNORE_HARD_LINE_BREAKS = 49;
|
||||
private static final int IGNORE_EMPTY_PARAGRAPHS =50;
|
||||
private static final int IGNORE_DOUBLE_SPACES = 51;
|
||||
private static final int DISPLAY_HIDDEN_TEXT = 52;
|
||||
private static final int ALIGN_FRAMES = 53;
|
||||
private static final int FLOAT_FIGURES = 54;
|
||||
private static final int FLOAT_TABLES = 55;
|
||||
private static final int FLOAT_OPTIONS = 56;
|
||||
private static final int FIGURE_SEQUENCE_NAME = 57;
|
||||
private static final int TABLE_SEQUENCE_NAME = 58;
|
||||
private static final int IMAGE_OPTIONS = 59;
|
||||
private static final int REMOVE_GRAPHICS_EXTENSION = 60;
|
||||
private static final int ORIGINAL_IMAGE_SIZE = 61;
|
||||
private static final int SIMPLE_TABLE_LIMIT = 62;
|
||||
private static final int NOTES = 63;
|
||||
private static final int METADATA = 64;
|
||||
private static final int TABSTOP = 65;
|
||||
private static final int WRAP_LINES_AFTER = 66;
|
||||
private static final int SPLIT_LINKED_SECTIONS = 67;
|
||||
private static final int SPLIT_TOPLEVEL_SECTIONS = 68;
|
||||
private static final int SAVE_IMAGES_IN_SUBDIR = 69;
|
||||
private static final int OLD_MATH_COLORS = 70;
|
||||
private static final int DEBUG = 71;
|
||||
private static final int BIBTEX_ENCODING = 33;
|
||||
private static final int ZOTERO_BIBTEX_FILES = 34;
|
||||
private static final int JABREF_BIBTEX_FILES = 35;
|
||||
private static final int INCLUDE_ORIGINAL_CITATIONS = 36;
|
||||
private static final int USE_NATBIB = 37;
|
||||
private static final int NATBIB_OPTIONS = 38;
|
||||
private static final int FONT = 39;
|
||||
private static final int FORMATTING = 40;
|
||||
private static final int PAGE_FORMATTING = 41;
|
||||
private static final int OTHER_STYLES = 42;
|
||||
private static final int IMAGE_CONTENT = 43;
|
||||
private static final int TABLE_CONTENT = 44;
|
||||
private static final int TABLE_FIRST_HEAD_STYLE = 45;
|
||||
private static final int TABLE_HEAD_STYLE = 46;
|
||||
private static final int TABLE_FOOT_STYLE = 47;
|
||||
private static final int TABLE_LAST_FOOT_STYLE = 48;
|
||||
private static final int IGNORE_HARD_PAGE_BREAKS = 49;
|
||||
private static final int IGNORE_HARD_LINE_BREAKS = 50;
|
||||
private static final int IGNORE_EMPTY_PARAGRAPHS =51;
|
||||
private static final int IGNORE_DOUBLE_SPACES = 52;
|
||||
private static final int DISPLAY_HIDDEN_TEXT = 53;
|
||||
private static final int ALIGN_FRAMES = 54;
|
||||
private static final int FLOAT_FIGURES = 55;
|
||||
private static final int FLOAT_TABLES = 56;
|
||||
private static final int FLOAT_OPTIONS = 57;
|
||||
private static final int FIGURE_SEQUENCE_NAME = 58;
|
||||
private static final int TABLE_SEQUENCE_NAME = 59;
|
||||
private static final int IMAGE_OPTIONS = 60;
|
||||
private static final int REMOVE_GRAPHICS_EXTENSION = 61;
|
||||
private static final int ORIGINAL_IMAGE_SIZE = 62;
|
||||
private static final int SIMPLE_TABLE_LIMIT = 63;
|
||||
private static final int NOTES = 64;
|
||||
private static final int METADATA = 65;
|
||||
private static final int TABSTOP = 66;
|
||||
private static final int WRAP_LINES_AFTER = 67;
|
||||
private static final int SPLIT_LINKED_SECTIONS = 68;
|
||||
private static final int SPLIT_TOPLEVEL_SECTIONS = 69;
|
||||
private static final int SAVE_IMAGES_IN_SUBDIR = 70;
|
||||
private static final int OLD_MATH_COLORS = 71;
|
||||
private static final int DEBUG = 72;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// IV. Our options data
|
||||
|
@ -254,6 +255,13 @@ public class LaTeXConfig extends writer2latex.base.ConfigBase {
|
|||
options[USE_BIBTEX] = new BooleanOption("use_bibtex","false");
|
||||
options[BIBTEX_STYLE] = new Option("bibtex_style","plain");
|
||||
options[EXTERNAL_BIBTEX_FILES] = new Option("external_bibtex_files","");
|
||||
options[BIBTEX_ENCODING] = new IntegerOption("bibtex_encoding","document") {
|
||||
public void setString(String sValue) {
|
||||
super.setString(sValue);
|
||||
if ("document".equals(sValue)) { nValue = -1; }
|
||||
else { nValue = ClassicI18n.readInputenc(sValue); }
|
||||
}
|
||||
};
|
||||
options[ZOTERO_BIBTEX_FILES] = new Option("zotero_bibtex_files","");
|
||||
options[JABREF_BIBTEX_FILES] = new Option("jabref_bibtex_files","");
|
||||
options[INCLUDE_ORIGINAL_CITATIONS] = new BooleanOption("include_original_citations","false");
|
||||
|
@ -683,6 +691,7 @@ public class LaTeXConfig extends writer2latex.base.ConfigBase {
|
|||
public boolean useBibtex() { return ((BooleanOption) options[USE_BIBTEX]).getValue(); }
|
||||
public String bibtexStyle() { return options[BIBTEX_STYLE].getString(); }
|
||||
public String externalBibtexFiles() { return options[EXTERNAL_BIBTEX_FILES].getString(); }
|
||||
public int getBibtexEncoding() { return ((IntegerOption) options[BIBTEX_ENCODING]).getValue(); }
|
||||
public String zoteroBibtexFiles() { return options[ZOTERO_BIBTEX_FILES].getString(); }
|
||||
public String jabrefBibtexFiles() { return options[JABREF_BIBTEX_FILES].getString(); }
|
||||
public boolean includeOriginalCitations() { return ((BooleanOption) options[INCLUDE_ORIGINAL_CITATIONS]).getValue(); }
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.6 (2015-06-16)
|
||||
* Version 1.6 (2015-07-23)
|
||||
*
|
||||
*/
|
||||
package writer2latex.xhtml;
|
||||
|
@ -61,6 +61,8 @@ final class IndexData {
|
|||
*/
|
||||
class TOCConverter extends IndexConverterHelper {
|
||||
|
||||
private static final String TOC_LINK_PREFIX = "toc";
|
||||
|
||||
private List<IndexData> indexes = new ArrayList<IndexData>(); // All tables of content
|
||||
private List<TocEntry> tocEntries = new ArrayList<TocEntry>(); // All potential(!) toc items
|
||||
private int nTocFileIndex = -1; // file index for main toc
|
||||
|
@ -94,7 +96,7 @@ class TOCConverter extends IndexConverterHelper {
|
|||
*/
|
||||
void handleHeading(Element onode, Element heading, String sLabel) {
|
||||
int nLevel = getTextCv().getOutlineLevel(onode);
|
||||
String sTarget = "toc"+(++nTocIndex);
|
||||
String sTarget = TOC_LINK_PREFIX+(++nTocIndex);
|
||||
converter.addTarget(heading,sTarget);
|
||||
|
||||
this.currentChapter = onode;
|
||||
|
@ -126,7 +128,7 @@ class TOCConverter extends IndexConverterHelper {
|
|||
if (nLevel>config.getXhtmlSplitLevel()) {
|
||||
Element div = converter.createElement("div");
|
||||
hnode.appendChild(div);
|
||||
sTarget = "toc"+(++nTocIndex);
|
||||
sTarget = TOC_LINK_PREFIX+(++nTocIndex);
|
||||
converter.addTarget(div,sTarget);
|
||||
}
|
||||
converter.addContentEntry(sLabel+converter.getPlainInlineText(onode), nLevel, sTarget);
|
||||
|
@ -136,7 +138,7 @@ class TOCConverter extends IndexConverterHelper {
|
|||
void handleParagraph(Element onode, Element par, String sCurrentListLabel) {
|
||||
String sStyleName = Misc.getAttribute(onode,XMLString.TEXT_STYLE_NAME);
|
||||
if (ofr.isIndexSourceStyle(getParSc().getRealParStyleName(sStyleName))) {
|
||||
converter.addTarget(par,"toc"+(++nTocIndex));
|
||||
converter.addTarget(par,TOC_LINK_PREFIX+(++nTocIndex));
|
||||
TocEntry entry = new TocEntry();
|
||||
entry.onode = (Element) onode;
|
||||
entry.sLabel = sCurrentListLabel;
|
||||
|
@ -151,7 +153,7 @@ class TOCConverter extends IndexConverterHelper {
|
|||
* @param hnode the link target will be added to this inline HTML node
|
||||
*/
|
||||
void handleTocMark(Node onode, Node hnode) {
|
||||
hnode.appendChild(converter.createTarget("toc"+(++nTocIndex)));
|
||||
hnode.appendChild(converter.createTarget(TOC_LINK_PREFIX+(++nTocIndex)));
|
||||
TocEntry entry = new TocEntry();
|
||||
entry.onode = (Element) onode;
|
||||
entry.nFileIndex = converter.getOutFileIndex();
|
||||
|
@ -243,7 +245,7 @@ class TOCConverter extends IndexConverterHelper {
|
|||
span.setAttribute("class","SectionNumber");
|
||||
span.appendChild(converter.createTextNode(entry.sLabel));
|
||||
}
|
||||
Element a = converter.createLink("toc"+i);
|
||||
Element a = converter.createLink(TOC_LINK_PREFIX+i);
|
||||
p.appendChild(a);
|
||||
getTextCv().traverseInlineText(entry.onode,a);
|
||||
}
|
||||
|
@ -255,7 +257,7 @@ class TOCConverter extends IndexConverterHelper {
|
|||
if (entry.sLabel!=null) {
|
||||
p.appendChild(converter.createTextNode(entry.sLabel));
|
||||
}
|
||||
Element a = converter.createLink("toc"+i);
|
||||
Element a = converter.createLink(TOC_LINK_PREFIX+i);
|
||||
p.appendChild(a);
|
||||
getTextCv().traverseInlineText(entry.onode,a);
|
||||
}
|
||||
|
@ -269,7 +271,7 @@ class TOCConverter extends IndexConverterHelper {
|
|||
if (entry.sLabel!=null) {
|
||||
p.appendChild(converter.createTextNode(entry.sLabel));
|
||||
}
|
||||
Element a = converter.createLink("toc"+i);
|
||||
Element a = converter.createLink(TOC_LINK_PREFIX+i);
|
||||
p.appendChild(a);
|
||||
getTextCv().traverseInlineText(entry.onode,a);
|
||||
}
|
||||
|
@ -278,7 +280,7 @@ class TOCConverter extends IndexConverterHelper {
|
|||
int nLevel = Misc.getPosInteger(entry.onode.getAttribute(XMLString.TEXT_OUTLINE_LEVEL),1);
|
||||
if (tocReader.useIndexMarks() && nLevel<=tocReader.getOutlineLevel()) {
|
||||
Element p = getTextCv().createParagraph(li,sEntryStyleName[nLevel]);
|
||||
Element a = converter.createLink("toc"+i);
|
||||
Element a = converter.createLink(TOC_LINK_PREFIX+i);
|
||||
p.appendChild(a);
|
||||
a.appendChild(converter.createTextNode(IndexMark.getIndexValue(entry.onode)));
|
||||
}
|
||||
|
@ -287,7 +289,7 @@ class TOCConverter extends IndexConverterHelper {
|
|||
int nLevel = Misc.getPosInteger(entry.onode.getAttribute(XMLString.TEXT_OUTLINE_LEVEL),1);
|
||||
if (tocReader.useIndexMarks() && nLevel<=tocReader.getOutlineLevel()) {
|
||||
Element p = getTextCv().createParagraph(li,sEntryStyleName[nLevel]);
|
||||
Element a = converter.createLink("toc"+i);
|
||||
Element a = converter.createLink(TOC_LINK_PREFIX+i);
|
||||
p.appendChild(a);
|
||||
a.appendChild(converter.createTextNode(IndexMark.getIndexValue(entry.onode)));
|
||||
}
|
||||
|
@ -353,7 +355,7 @@ class TOCConverter extends IndexConverterHelper {
|
|||
String sNodeName = entry.onode.getTagName();
|
||||
if (XMLString.TEXT_H.equals(sNodeName)) {
|
||||
|
||||
// Determine wether or not to include this heading
|
||||
// Determine whether or not to include this heading
|
||||
// Note that this condition misses the case where
|
||||
// a heading of level n is followed by a heading of
|
||||
// level n+2. This is considered a bug in the document!
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.6 (2015-06-16)
|
||||
* Version 1.6 (2015-07-23)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -50,7 +50,7 @@ public class TextConverter extends ConverterHelper {
|
|||
// TODO: Accessor methods for sections
|
||||
// Some (Sony?) EPUB readers have a limit on the file size of individual files
|
||||
// In any case very large files could be a performance problem, hence we do automatic splitting
|
||||
// after this number of characters. TODO: Make configurable.
|
||||
// after this number of characters.
|
||||
private int nSplitAfter = 150000;
|
||||
private int nPageBreakSplit = XhtmlConfig.NONE; // Should we split at page breaks?
|
||||
// TODO: Collect soft page breaks between table rows
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue