BibTeX support

git-svn-id: svn://svn.code.sf.net/p/writer2latex/code/trunk@223 f0f2a975-2e09-46c8-9428-3b39399b9f3c
This commit is contained in:
henrikjust 2014-12-11 20:10:51 +00:00
parent ceddd94461
commit 86c96621a7
13 changed files with 461 additions and 146 deletions

View file

@ -2,7 +2,7 @@
############################################################################ ############################################################################
# This is the Ant build file for writer2latex # This is the Ant build file for writer2latex
# Original: Sep 2004 (mgn) # Original: Sep 2004 (mgn)
# version 1.6 (2014-11-10) # version 1.6 (2014-11-24)
############################################################################ ############################################################################
--> -->
<project name="w2l" default="help" basedir="."> <project name="w2l" default="help" basedir=".">
@ -49,6 +49,7 @@
<property name="source.idl" location="source/idl"/> <property name="source.idl" location="source/idl"/>
<property name="source.lib" location="source/lib"/> <property name="source.lib" location="source/lib"/>
<property name="org.json" value="json-20140107.jar"/> <property name="org.json" value="json-20140107.jar"/>
<property name="org.jbibtex" value="jbibtex-1.0.14.jar"/>
<!-- classpath for the application; needs java-uno classes --> <!-- classpath for the application; needs java-uno classes -->
<path id="main.class.path"> <path id="main.class.path">
<!-- java uno classes --> <!-- java uno classes -->
@ -58,7 +59,7 @@
files="unoil.jar"/> files="unoil.jar"/>
<!-- third party jars --> <!-- third party jars -->
<filelist dir="${source.lib}" <filelist dir="${source.lib}"
files="${org.json}"/> files="${org.json},${org.jbibtex}"/>
<!-- additional uno interfaces generated from idl --> <!-- additional uno interfaces generated from idl -->
<pathelement path="${source.idl}/writer2latex"/> <pathelement path="${source.idl}/writer2latex"/>
<pathelement path="${source.idl}/writer2xhtml"/> <pathelement path="${source.idl}/writer2xhtml"/>
@ -78,7 +79,7 @@
encoding="us-ascii" encoding="us-ascii"
source="1.6" source="1.6"
target="1.6" target="1.6"
classpath="${source.lib}/${org.json}" classpath="${source.lib}/${org.json}:${source.lib}/${org.jbibtex}"
bootclasspath="${JAVA6_RT_JAR}" bootclasspath="${JAVA6_RT_JAR}"
includeantruntime="false" includeantruntime="false"
debug="on"> debug="on">
@ -142,7 +143,7 @@
</patternset> </patternset>
</fileset> </fileset>
<!-- include third party libraries --> <!-- include third party libraries -->
<zipgroupfileset dir="${source.lib}" includes="${org.json}" /> <zipgroupfileset dir="${source.lib}" includes="${org.json},${org.jbibtex}" />
<!-- also include uno interface as generated from idl --> <!-- also include uno interface as generated from idl -->
<fileset dir="${source.idl}/writer2latex"> <fileset dir="${source.idl}/writer2latex">
<include name="org/**/*"/> <include name="org/**/*"/>

View file

@ -2,7 +2,8 @@ Changelog for Writer2LaTeX version 1.4 -> 1.6
---------- version 1.5.2 ---------- ---------- version 1.5.2 ----------
[w2x] Bugfix: No longer include xmlns attribute on math nodes in HTML5 [w2l] New BibTeX dialog to insert a bibliographic reference to a BibTeX file. The BibTeX files are located as defined
in the configuration, and the reference is inserted as an ordinary reference mark.
[w2l] Various improvements to the log viewer dialog: Reduced height to better accommodate small screen resolutions. [w2l] Various improvements to the log viewer dialog: Reduced height to better accommodate small screen resolutions.
Added checkbox to filter the LaTeX log to display only errors. Added help page and long tips. Added checkbox to filter the LaTeX log to display only errors. Added help page and long tips.

View file

@ -0,0 +1,86 @@
/************************************************************************
*
* BibTeXDialog.java
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
* Copyright: 2002-2014 by Henrik Just
*
* All Rights Reserved.
*
* Version 1.6 (2014-12-11)
*
*/
package org.openoffice.da.comp.writer2latex;
import com.sun.star.awt.XDialog;
import com.sun.star.uno.XComponentContext;
import org.openoffice.da.comp.w2lcommon.helper.DialogBase;
/** This class provides a UNO dialog to insert a BibTeX bibliographic reference
*/
public class BibTeXDialog extends DialogBase {
//implements com.sun.star.lang.XInitialization {
/** The component will be registered under this name.
*/
public static String __serviceName = "org.openoffice.da.writer2latex.BibTeXDialog";
/** The component should also have an implementation name.
*/
public static String __implementationName = "org.openoffice.da.comp.writer2latex.BibTeXDialog";
/** Return the name of the library containing the dialog
*/
public String getDialogLibraryName() {
return "W4LDialogs";
}
/** Return the name of the dialog within the library
*/
public String getDialogName() {
return "BibTeXEntry";
}
public void initialize() {
}
public void endDialog() {
}
/** Create a new BibTeXDialog */
public BibTeXDialog(XComponentContext xContext) {
super(xContext);
}
// Implement com.sun.star.lang.XInitialization
/*public void initialize( Object[] object )
throws com.sun.star.uno.Exception {
}*/
// Implement XDialogEventHandler
public boolean callHandlerMethod(XDialog xDialog, Object event, String sMethod) {
return true;
}
public String[] getSupportedMethodNames() {
String[] sNames = { };
return sNames;
}
}

View file

@ -0,0 +1,141 @@
/************************************************************************
*
* BibTeXReader.java
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
* Copyright: 2002-2014 by Henrik Just
*
* All Rights Reserved.
*
* Version 1.6 (2014-11-24)
*
*/
package org.openoffice.da.comp.writer2latex;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import org.jbibtex.BibTeXDatabase;
import org.jbibtex.BibTeXEntry;
import org.jbibtex.BibTeXParser;
import org.jbibtex.BibTeXString;
import org.jbibtex.Key;
import org.jbibtex.LaTeXParser;
import org.jbibtex.LaTeXPrinter;
import org.jbibtex.ParseException;
import org.jbibtex.Value;
import writer2latex.bibtex.BibTeXEntryMap;
import writer2latex.office.BibMark;
import writer2latex.office.BibMark.EntryType;
/**
* The class reads the contents of a BibTeX file and makes it available as a map
* of ODF <code>BibMark</code> objects
*/
public class BibTeXReader {
private Map<String, BibMark> entries;
/**
* Construct a new <code>BibTeXReader</code> based on a file
*
* @param file the file to read
* @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 {
BibTeXDatabase database = parseBibTeX(file);
readEntries(database);
}
/** Get the entries of this BibTeX file
*
* @return the entries
*/
public Map<String, BibMark> getEntries() {
return entries;
}
private static BibTeXDatabase parseBibTeX(File file) throws IOException, ParseException {
Reader reader = new FileReader(file);
try {
BibTeXParser parser = new BibTeXParser() {
@Override
public void checkStringResolution(Key key, BibTeXString string) {
if (string == null) {
System.err.println("Unresolved string: \"" + key.getValue() + "\"");
}
}
@Override
public void checkCrossReferenceResolution(Key key,
BibTeXEntry entry) {
if (entry == null) {
System.err.println("Unresolved cross-reference: \"" + key.getValue() + "\"");
}
}
};
return parser.parse(reader);
} finally {
reader.close();
}
}
private void readEntries(BibTeXDatabase database) throws IOException {
entries = new HashMap<String, BibMark>();
Map<Key, BibTeXEntry> entryMap = database.getEntries();
Collection<BibTeXEntry> bibentries = entryMap.values();
for (BibTeXEntry bibentry : bibentries) {
String sKey = bibentry.getKey().toString();
String sType = bibentry.getType().toString();
BibMark entry = new BibMark(sKey,sType);
entries.put(sKey, entry);
Map<Key,Value> fields = bibentry.getFields();
for (Key key : fields.keySet()) {
Value value = fields.get(key);
EntryType entryType = BibTeXEntryMap.getEntryType(key.getValue());
if (entryType!=null) {
entry.setField(entryType, parseLaTeX(value.toUserString()));
}
}
}
}
private static String parseLaTeX(String string) throws IOException {
Reader reader = new StringReader(string);
try {
LaTeXParser parser = new LaTeXParser();
LaTeXPrinter printer = new LaTeXPrinter();
return printer.print(parser.parse(reader));
} catch (ParseException e) {
// If parsing fails, return the original string
return string;
} finally {
reader.close();
}
}
}

View file

@ -20,7 +20,7 @@
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.4 (2014-10-29) * Version 1.6 (2014-12-11)
* *
*/ */
@ -120,6 +120,12 @@ public class W2LRegistration {
multiFactory, multiFactory,
regKey); regKey);
} }
else if (implName.equals(BibTeXDialog.__implementationName) ) {
xSingleServiceFactory = FactoryHelper.getServiceFactory(BibTeXDialog.class,
BibTeXDialog.__serviceName,
multiFactory,
regKey);
}
return xSingleServiceFactory; return xSingleServiceFactory;
} }
@ -153,7 +159,8 @@ public class W2LRegistration {
FactoryHelper.writeRegistryServiceInfo(BibliographyDialog.__implementationName, FactoryHelper.writeRegistryServiceInfo(BibliographyDialog.__implementationName,
BibliographyDialog.__serviceName, regKey) & BibliographyDialog.__serviceName, regKey) &
FactoryHelper.writeRegistryServiceInfo(LogViewerDialog.__implementationName, FactoryHelper.writeRegistryServiceInfo(LogViewerDialog.__implementationName,
LogViewerDialog.__serviceName, regKey); LogViewerDialog.__serviceName, regKey) &
FactoryHelper.writeRegistryServiceInfo(BibTeXDialog.__implementationName,
BibTeXDialog.__serviceName, regKey);
} }
} }

View file

@ -20,7 +20,7 @@
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.6 (2014-11-03) * Version 1.6 (2014-12-11)
* *
*/ */
@ -34,7 +34,6 @@ import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext; import com.sun.star.uno.XComponentContext;
import org.openoffice.da.comp.w2lcommon.filter.UNOPublisher.TargetFormat; import org.openoffice.da.comp.w2lcommon.filter.UNOPublisher.TargetFormat;
import org.openoffice.da.comp.w2lcommon.helper.MessageBox;
/** This class implements the ui (dispatch) commands provided by the Writer2LaTeX toolbar. /** This class implements the ui (dispatch) commands provided by the Writer2LaTeX toolbar.
* The actual processing is done by the core classes <code>UNOPublisher</code>, * The actual processing is done by the core classes <code>UNOPublisher</code>,
@ -176,8 +175,19 @@ public final class Writer2LaTeX extends WeakBase
} }
private void insertBibTeX() { private void insertBibTeX() {
MessageBox msgBox = new MessageBox(m_xContext, m_xFrame); // Execute the BibTeX dialog
msgBox.showMessage("Writer2LaTeX","This feature is not implemented yet"); try {
Object dialog = m_xContext.getServiceManager()
.createInstanceWithContext(
"org.openoffice.da.writer2latex.BibTeXDialog", m_xContext);
XExecutableDialog xDialog = (XExecutableDialog)
UnoRuntime.queryInterface(XExecutableDialog.class, dialog);
if (xDialog.execute()==ExecutableDialogResults.OK) {
// Closed with the close button
}
}
catch (com.sun.star.uno.Exception e) {
}
} }
private void createUNOPublisher() { private void createUNOPublisher() {

View file

@ -20,7 +20,7 @@
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.4 (2014-08-26) * Version 1.6 (2014-11-28)
* *
*/ */
@ -39,8 +39,8 @@ import writer2latex.latex.LaTeXConfig;
import writer2latex.latex.i18n.ClassicI18n; import writer2latex.latex.i18n.ClassicI18n;
import writer2latex.latex.i18n.I18n; import writer2latex.latex.i18n.I18n;
import writer2latex.util.ExportNameCollection; import writer2latex.util.ExportNameCollection;
//import writer2latex.util.Misc;
import writer2latex.office.BibMark; import writer2latex.office.BibMark;
import writer2latex.office.BibMark.EntryType;;
/** /**
* <p>Class representing a BibTeX document.</p> * <p>Class representing a BibTeX document.</p>
@ -126,15 +126,15 @@ public class BibTeXDocument implements OutputFile {
osw.write("{"); osw.write("{");
osw.write(exportNames.getExportName(entry.getIdentifier())); osw.write(exportNames.getExportName(entry.getIdentifier()));
osw.write(",\n"); osw.write(",\n");
for (int i=0; i<BibMark.FIELD_COUNT; i++) { for (EntryType entryType : EntryType.values()) {
String sValue = entry.getField(i); String sValue = entry.getField(entryType);
if (sValue!=null) { if (sValue!=null) {
if (i==BibMark.AUTHOR || i==BibMark.EDITOR) { if (entryType==EntryType.author || entryType==EntryType.editor) {
// OOo uses ; to separate authors and editors - BibTeX uses and // OOo uses ; to separate authors and editors - BibTeX uses and
sValue = sValue.replaceAll(";" , " and "); sValue = sValue.replaceAll(";" , " and ");
} }
osw.write(" "); osw.write(" ");
osw.write(getFieldName(i).toUpperCase()); osw.write(BibTeXEntryMap.getFieldName(entryType).toUpperCase());
osw.write(" = {"); osw.write(" = {");
for (int j=0; j<sValue.length(); j++) { for (int j=0; j<sValue.length(); j++) {
String s = i18n.convert(Character.toString(sValue.charAt(j)),false,"en"); String s = i18n.convert(Character.toString(sValue.charAt(j)),false,"en");
@ -151,47 +151,6 @@ public class BibTeXDocument implements OutputFile {
osw.close(); osw.close();
} }
/**
* <p> Return BibTeX name of field </p>
*/
public static final String getFieldName(int nField) {
switch (nField) {
case BibMark.ADDRESS: return "address";
case BibMark.ANNOTE: return "annote";
case BibMark.AUTHOR: return "author";
case BibMark.BOOKTITLE: return "booktitle";
case BibMark.CHAPTER: return "chapter";
// case BibMark.CROSSREF: return "croosref"; // not in OOo
case BibMark.EDITION: return "edition";
case BibMark.EDITOR: return "editor";
case BibMark.HOWPUBLISHED: return "howpublished";
case BibMark.INSTITUTION: return "institution";
case BibMark.JOURNAL: return "journal";
// case BibMark.KEY: return "key"; // not in OOo
case BibMark.MONTH: return "month";
case BibMark.NOTE: return "note";
case BibMark.NUMBER: return "number";
case BibMark.ORGANIZATIONS: return "organization";
case BibMark.PAGES: return "pages";
case BibMark.PUBLISHER: return "publisher";
case BibMark.SCHOOL: return "school";
case BibMark.SERIES: return "series";
case BibMark.TITLE: return "title";
case BibMark.REPORT_TYPE: return "type";
case BibMark.VOLUME: return "volume";
case BibMark.YEAR: return "year";
case BibMark.URL: return "url";
case BibMark.CUSTOM1: return "custom1";
case BibMark.CUSTOM2: return "custom2";
case BibMark.CUSTOM3: return "custom3";
case BibMark.CUSTOM4: return "custom4";
case BibMark.CUSTOM5: return "custom5";
case BibMark.ISBN: return "isbn";
default: return null;
}
}
/* /*
* <p>Check if this entry exists</p> * <p>Check if this entry exists</p>
*/ */

View file

@ -0,0 +1,109 @@
/************************************************************************
*
* BibTeXEntryMap.java
*
* This library is free software); you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY); without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library); if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
* Copyright: 2002-2014 by Henrik Just
*
* All Rights Reserved.
*
* Version 1.6 (2014-11-28)
*
*/
package writer2latex.bibtex;
import java.util.HashMap;
import java.util.Map;
import writer2latex.office.BibMark.EntryType;
/**
* This class provides static methods to map the the entry types of an ODF
* bibliography mark to and from BibTeX field names
*
*/
public class BibTeXEntryMap {
private static Map<EntryType, String> bibTeXFields = null;
private static Map<String, EntryType> entryTypes = null;
private static void createMaps() {
// Note the BibTeX fileds key and crossref are not supported in ODF
bibTeXFields = new HashMap<EntryType, String>();
bibTeXFields.put(EntryType.address, "address");
bibTeXFields.put(EntryType.annote, "annote");
bibTeXFields.put(EntryType.author, "author");
bibTeXFields.put(EntryType.booktitle, "booktitle");
bibTeXFields.put(EntryType.chapter, "chapter");
bibTeXFields.put(EntryType.edition, "edition");
bibTeXFields.put(EntryType.editor, "editor");
bibTeXFields.put(EntryType.howpublished, "howpublished");
bibTeXFields.put(EntryType.institution, "institution");
bibTeXFields.put(EntryType.journal, "journal");
bibTeXFields.put(EntryType.month, "month");
bibTeXFields.put(EntryType.note, "note");
bibTeXFields.put(EntryType.number, "number");
bibTeXFields.put(EntryType.organizations, "organization");
bibTeXFields.put(EntryType.pages, "pages");
bibTeXFields.put(EntryType.publisher, "publisher");
bibTeXFields.put(EntryType.school, "school");
bibTeXFields.put(EntryType.series, "series");
bibTeXFields.put(EntryType.title, "title");
bibTeXFields.put(EntryType.report_type, "type");
bibTeXFields.put(EntryType.volume, "volume");
bibTeXFields.put(EntryType.year, "year");
bibTeXFields.put(EntryType.url, "url");
bibTeXFields.put(EntryType.custom1, "custom1");
bibTeXFields.put(EntryType.custom2, "custom2");
bibTeXFields.put(EntryType.custom3, "custom3");
bibTeXFields.put(EntryType.custom4, "custom4");
bibTeXFields.put(EntryType.custom5, "custom5");
bibTeXFields.put(EntryType.isbn, "isbn");
entryTypes = new HashMap<String, EntryType>();
for (EntryType entryType : bibTeXFields.keySet()) {
entryTypes.put(bibTeXFields.get(entryType), entryType);
}
}
/**
* Return BibTeX field name corresponding to and entry type
*
* @param entryType
* the entry type
* @return the BibTeX field name, or null if there is no corresponding
* BibTeX field
*/
public static final String getFieldName(EntryType entryType) {
if (bibTeXFields == null) {
createMaps();
}
return bibTeXFields.containsKey(entryType) ? bibTeXFields.get(entryType) : null;
}
/**
* Return entry type corresponding to a BibTeX field
*
* @param sFieldName
* the BibTeX field name
* @return the entry type, or null if there is no corresponding entry type
*/
public static final EntryType getEntryType(String sFieldName) {
if (bibTeXFields == null) {
createMaps();
}
return entryTypes.containsKey(sFieldName) ? entryTypes.get(sFieldName) : null;
}
}

View file

@ -16,76 +16,54 @@
* 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.6 (2014-11-24)
* *
*/ */
package writer2latex.office; package writer2latex.office;
import java.util.HashMap;
import java.util.Map;
import org.w3c.dom.Node; import org.w3c.dom.Node;
import writer2latex.util.Misc;
import writer2latex.util.*; /** This class represents a single bibliography-mark in an ODF document
//import writer2latex.office.*;
/**
* <p>This class represents a single bibliography-mark.</p>
*/ */
public final class BibMark { public final class BibMark {
// Available fields
public static final int ADDRESS = 0;
public static final int ANNOTE = 1;
public static final int AUTHOR = 2;
public static final int BOOKTITLE = 3;
public static final int CHAPTER = 4;
// public static final int CROSSREF = 5; // BibTeX, missing in OOo
public static final int EDITION = 6;
public static final int EDITOR = 7;
public static final int HOWPUBLISHED = 8;
public static final int INSTITUTION = 9;
public static final int JOURNAL = 10;
// public static final int KEY = 11; // BibTeX, missing in OOo
public static final int MONTH = 12;
public static final int NOTE = 13;
public static final int NUMBER = 14;
public static final int ORGANIZATIONS = 15; // BibTeX: organization
public static final int PAGES = 16;
public static final int PUBLISHER = 17;
public static final int SCHOOL = 18;
public static final int SERIES = 19;
public static final int TITLE = 20 ;
public static final int REPORT_TYPE = 21; // BibTeX: report
public static final int VOLUME = 22;
public static final int YEAR = 23;
// remaining fields are not standard in BibTeX
public static final int URL = 24;
public static final int CUSTOM1 = 25;
public static final int CUSTOM2 = 26;
public static final int CUSTOM3 = 27;
public static final int CUSTOM4 = 28;
public static final int CUSTOM5 = 29;
public static final int ISBN = 30;
public static final int FIELD_COUNT = 31;
/** Entry types in an ODF bibliography marks. These are more or less modeled on BibTeX with
* the following exceptions: organizations is organization in BibTeX, report_type is report in BibTeX,
* the BibTeX fields crossref and key are missing in ODF, the ODF fields
* url, custom1, custom2, custom3, custom4, custom5, isbn are not standard in BibTeX
*
*/
public enum EntryType { address, annote, author, booktitle, chapter,
edition, editor, howpublished, institution, journal, month,
note, number, organizations, pages, publisher, school, series,
title, report_type, volume, year,
url, custom1, custom2, custom3, custom4, custom5, isbn
}
// Private data // The data of the bibliography mark
private String sIdentifier; private String sIdentifier;
private String sEntryType; private String sEntryType;
private String[] fields = new String[FIELD_COUNT]; private Map<EntryType,String> fields = new HashMap<EntryType,String>();
/** /** Create a new BibMark from scratch.
* <p>Create a new BibMark from scratch.</p> * @param sIdentifier the unique identifier for this BibMark
* @param sEntryType the type of entry such as book or article
*/ */
public BibMark(String sIdentifier, String sEntryType) { public BibMark(String sIdentifier, String sEntryType) {
this.sIdentifier = sIdentifier; this.sIdentifier = sIdentifier;
this.sEntryType = sEntryType; this.sEntryType = sEntryType;
} }
/** /** Create a new <code>BibMark</code> from a text:bibliography-mark node.
* <p>Create a new BibMark from a text:bibliography-mark node.</p>
*/ */
public BibMark(Node node) { public BibMark(Node node) {
sIdentifier = Misc.getAttribute(node,XMLString.TEXT_IDENTIFIER); sIdentifier = Misc.getAttribute(node,XMLString.TEXT_IDENTIFIER);
@ -93,54 +71,62 @@ public final class BibMark {
if (sEntryType==null) { // bug in OOo 1.0! if (sEntryType==null) { // bug in OOo 1.0!
sEntryType = Misc.getAttribute(node,XMLString.TEXT_BIBILIOGRAPHIC_TYPE); sEntryType = Misc.getAttribute(node,XMLString.TEXT_BIBILIOGRAPHIC_TYPE);
} }
fields[ADDRESS] = Misc.getAttribute(node,XMLString.TEXT_ADDRESS); fields.put(EntryType.address, Misc.getAttribute(node,XMLString.TEXT_ADDRESS));
fields[ANNOTE] = Misc.getAttribute(node,XMLString.TEXT_ANNOTE); fields.put(EntryType.annote, Misc.getAttribute(node,XMLString.TEXT_ANNOTE));
fields[AUTHOR] = Misc.getAttribute(node,XMLString.TEXT_AUTHOR); fields.put(EntryType.author, Misc.getAttribute(node,XMLString.TEXT_AUTHOR));
fields[BOOKTITLE] = Misc.getAttribute(node,XMLString.TEXT_BOOKTITLE); fields.put(EntryType.booktitle, Misc.getAttribute(node,XMLString.TEXT_BOOKTITLE));
fields[CHAPTER] = Misc.getAttribute(node,XMLString.TEXT_CHAPTER); fields.put(EntryType.chapter, Misc.getAttribute(node,XMLString.TEXT_CHAPTER));
fields[EDITION] = Misc.getAttribute(node,XMLString.TEXT_EDITION); fields.put(EntryType.edition, Misc.getAttribute(node,XMLString.TEXT_EDITION));
fields[EDITOR] = Misc.getAttribute(node,XMLString.TEXT_EDITOR); fields.put(EntryType.editor, Misc.getAttribute(node,XMLString.TEXT_EDITOR));
fields[HOWPUBLISHED] = Misc.getAttribute(node,XMLString.TEXT_HOWPUBLISHED); fields.put(EntryType.howpublished, Misc.getAttribute(node,XMLString.TEXT_HOWPUBLISHED));
fields[INSTITUTION] = Misc.getAttribute(node,XMLString.TEXT_INSTITUTION); fields.put(EntryType.institution, Misc.getAttribute(node,XMLString.TEXT_INSTITUTION));
fields[JOURNAL] = Misc.getAttribute(node,XMLString.TEXT_JOURNAL); fields.put(EntryType.journal, Misc.getAttribute(node,XMLString.TEXT_JOURNAL));
fields[MONTH] = Misc.getAttribute(node,XMLString.TEXT_MONTH); fields.put(EntryType.month, Misc.getAttribute(node,XMLString.TEXT_MONTH));
fields[NOTE] = Misc.getAttribute(node,XMLString.TEXT_NOTE); fields.put(EntryType.note, Misc.getAttribute(node,XMLString.TEXT_NOTE));
fields[NUMBER] = Misc.getAttribute(node,XMLString.TEXT_NUMBER); fields.put(EntryType.number, Misc.getAttribute(node,XMLString.TEXT_NUMBER));
fields[ORGANIZATIONS] = Misc.getAttribute(node,XMLString.TEXT_ORGANIZATIONS); fields.put(EntryType.organizations, Misc.getAttribute(node,XMLString.TEXT_ORGANIZATIONS));
fields[PAGES] = Misc.getAttribute(node,XMLString.TEXT_PAGES); fields.put(EntryType.pages, Misc.getAttribute(node,XMLString.TEXT_PAGES));
fields[PUBLISHER] = Misc.getAttribute(node,XMLString.TEXT_PUBLISHER); fields.put(EntryType.publisher, Misc.getAttribute(node,XMLString.TEXT_PUBLISHER));
fields[SCHOOL] = Misc.getAttribute(node,XMLString.TEXT_SCHOOL); fields.put(EntryType.school, Misc.getAttribute(node,XMLString.TEXT_SCHOOL));
fields[SERIES] = Misc.getAttribute(node,XMLString.TEXT_SERIES); fields.put(EntryType.series, Misc.getAttribute(node,XMLString.TEXT_SERIES));
fields[TITLE] = Misc.getAttribute(node,XMLString.TEXT_TITLE); fields.put(EntryType.title, Misc.getAttribute(node,XMLString.TEXT_TITLE));
fields[REPORT_TYPE] = Misc.getAttribute(node,XMLString.TEXT_REPORT_TYPE); fields.put(EntryType.report_type, Misc.getAttribute(node,XMLString.TEXT_REPORT_TYPE));
fields[VOLUME] = Misc.getAttribute(node,XMLString.TEXT_VOLUME); fields.put(EntryType.volume, Misc.getAttribute(node,XMLString.TEXT_VOLUME));
fields[YEAR] = Misc.getAttribute(node,XMLString.TEXT_YEAR); fields.put(EntryType.year, Misc.getAttribute(node,XMLString.TEXT_YEAR));
fields[URL] = Misc.getAttribute(node,XMLString.TEXT_URL); fields.put(EntryType.url, Misc.getAttribute(node,XMLString.TEXT_URL));
fields[CUSTOM1] = Misc.getAttribute(node,XMLString.TEXT_CUSTOM1); fields.put(EntryType.custom1, Misc.getAttribute(node,XMLString.TEXT_CUSTOM1));
fields[CUSTOM2] = Misc.getAttribute(node,XMLString.TEXT_CUSTOM2); fields.put(EntryType.custom2, Misc.getAttribute(node,XMLString.TEXT_CUSTOM2));
fields[CUSTOM3] = Misc.getAttribute(node,XMLString.TEXT_CUSTOM3); fields.put(EntryType.custom3, Misc.getAttribute(node,XMLString.TEXT_CUSTOM3));
fields[CUSTOM4] = Misc.getAttribute(node,XMLString.TEXT_CUSTOM4); fields.put(EntryType.custom4, Misc.getAttribute(node,XMLString.TEXT_CUSTOM4));
fields[CUSTOM5] = Misc.getAttribute(node,XMLString.TEXT_CUSTOM5); fields.put(EntryType.custom5, Misc.getAttribute(node,XMLString.TEXT_CUSTOM5));
fields[ISBN] = Misc.getAttribute(node,XMLString.TEXT_ISBN); fields.put(EntryType.isbn, Misc.getAttribute(node,XMLString.TEXT_ISBN));
} }
/** /** Get the identifier.
* <p>Get the identifier.</p> *
* @return the unique identifier of this <code>BibMark</code>
*/ */
public String getIdentifier() { return sIdentifier; } public String getIdentifier() { return sIdentifier; }
/** /** Get the entry type.
* <p>Get the entry type.</p> *
* @return the entry type of this <code>BibMark</code>
*/ */
public String getEntryType() { return sEntryType; } public String getEntryType() { return sEntryType; }
/** /** Set a specific field.
* <p>Set a specific field.</p> *
* @param entryType the type of field to set
* @param sValue the new value of the field
*/ */
public void setField(int nField,String sValue) { fields[nField] = sValue; } public void setField(EntryType entryType,String sValue) { fields.put(entryType, sValue); }
/** /** Return a specific field.
* <p>Return a specific field.</p> *
* @param entryType the type of the field to get
* @return the value of the field, or null if the field is not set
*/ */
public String getField(int nField) { return fields[nField]; } public String getField(EntryType entryType) {
return fields.containsKey(entryType) ? fields.get(entryType) : null;
}
} }

View file

@ -20,7 +20,7 @@
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.4 (2014-09-16) * Version 1.4 (2014-11-24)
* *
*/ */

Binary file not shown.

View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dlg:window PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "dialog.dtd">
<dlg:window xmlns:dlg="http://openoffice.org/2000/dialog" xmlns:script="http://openoffice.org/2000/script" dlg:id="BibTeXEntry" dlg:left="117" dlg:top="53" dlg:width="210" dlg:height="100" dlg:closeable="true" dlg:moveable="true" dlg:title="Insert BibTeX reference">
<dlg:bulletinboard>
<dlg:menulist dlg:id="File" dlg:tab-index="0" dlg:left="80" dlg:top="10" dlg:width="120" dlg:height="12" dlg:spin="true"/>
<dlg:text dlg:id="FileLabel" dlg:tab-index="3" dlg:left="10" dlg:top="10" dlg:width="60" dlg:height="12" dlg:value="BibTeX file"/>
<dlg:text dlg:id="EntryLabel" dlg:tab-index="4" dlg:left="10" dlg:top="24" dlg:width="60" dlg:height="12" dlg:value="BibTeX entry"/>
<dlg:menulist dlg:id="Entry" dlg:tab-index="1" dlg:left="80" dlg:top="24" dlg:width="120" dlg:height="12" dlg:spin="true"/>
<dlg:text dlg:id="EntryInformation" dlg:tab-index="5" dlg:left="10" dlg:top="40" dlg:width="170" dlg:height="34"/>
<dlg:button dlg:id="Insert" dlg:tab-index="2" dlg:left="10" dlg:top="78" dlg:width="60" dlg:height="12" dlg:value="Insert reference" dlg:button-type="ok"/>
<dlg:button dlg:id="Cancel" dlg:tab-index="6" dlg:left="75" dlg:top="78" dlg:width="60" dlg:height="12" dlg:value="Cancel" dlg:button-type="cancel"/>
<dlg:button dlg:id="Help" dlg:tab-index="7" dlg:left="140" dlg:top="78" dlg:width="60" dlg:height="12" dlg:value="Help" dlg:button-type="help"/>
</dlg:bulletinboard>
</dlg:window>

View file

@ -6,4 +6,5 @@
<library:element library:name="Bibliography"/> <library:element library:name="Bibliography"/>
<library:element library:name="LogViewer"/> <library:element library:name="LogViewer"/>
<library:element library:name="AutoConfigInfo"/> <library:element library:name="AutoConfigInfo"/>
<library:element library:name="BibTeXEntry"/>
</library:library> </library:library>