JabRef support

git-svn-id: svn://svn.code.sf.net/p/writer2latex/code/trunk@84 f0f2a975-2e09-46c8-9428-3b39399b9f3c
This commit is contained in:
henrikjust 2011-01-25 15:56:13 +00:00
parent 8b7154ca6b
commit 905918aaf2
26 changed files with 315 additions and 188 deletions

View file

@ -35,7 +35,7 @@
<!-- configure the directories --> <!-- configure the directories -->
<property name="jarfile" value="writer2latex"/> <property name="jarfile" value="writer2latex"/>
<property name="basename" value="writer2latex11"/> <property name="basename" value="writer2latex11"/>
<property name="distrofile" value="${basename}9beta.zip" /> <property name="distrofile" value="${basename}6alpha.zip" />
<!--<property name="sourcedistrofile" value="${basename}source.zip" />--> <!--<property name="sourcedistrofile" value="${basename}source.zip" />-->
<property name="src" location="source/java"/> <property name="src" location="source/java"/>
<property name="source.distro" location="source/distro" /> <property name="source.distro" location="source/distro" />

View file

@ -1,7 +1,7 @@
Writer2LaTeX version 1.1.9 (beta test release) Writer2LaTeX version 1.1.6 (alpha test release)
============================================== ===============================================
This is the distribution of Writer2LaTeX version 1.1.9 This is the distribution of Writer2LaTeX version 1.1.6
Latest version can be found at the web site Latest version can be found at the web site
http://writer2latex.sourceforge.net http://writer2latex.sourceforge.net

View file

@ -1,6 +1,12 @@
Changelog for Writer2LaTeX version 1.0 -> 1.2 Changelog for Writer2LaTeX version 1.0 -> 1.2
---------- version 1.1.9 ---------- ---------- version 1.1.6 ----------
[w4l] Bibliography options page has been reworked to include JabRef support and unify BibTeX directory (which is now allowed
to contain special characters like spaces)
[w2l] Added support for JabRef reference marks: A new option jabref_bibtex_files has been added to give the names of
the BibTeX files from JabRef
[w2x] New option include_toc (default true) for EPUB export: If set to false, the table of content will not be exported [w2x] New option include_toc (default true) for EPUB export: If set to false, the table of content will not be exported

Binary file not shown.

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-2011 by Henrik Just
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.2 (2010-04-12) * Version 1.2 (2011-01-15)
* *
*/ */
@ -54,6 +54,7 @@ import writer2latex.api.Converter;
* All errors are silently ignored * All errors are silently ignored
*/ */
public class FilterDataParser { public class FilterDataParser {
// TODO: Use JSON format
//private static XComponentContext xComponentContext = null; //private static XComponentContext xComponentContext = null;
@ -108,7 +109,7 @@ public class FilterDataParser {
PropertyHelper props = new PropertyHelper(filterData); PropertyHelper props = new PropertyHelper(filterData);
// Get the special properties TemplateURL, StyleSheetURL, ConfigURL and AutoCreate // Get the special properties TemplateURL, StyleSheetURL, Resources, ConfigURL and AutoCreate
Object tpl = props.get("TemplateURL"); Object tpl = props.get("TemplateURL");
String sTemplate = null; String sTemplate = null;
if (tpl!=null && AnyConverter.isString(tpl)) { if (tpl!=null && AnyConverter.isString(tpl)) {
@ -131,6 +132,18 @@ public class FilterDataParser {
} }
} }
// This property accepts a semicolon separated list of <mime type>!<file name>!<URL> (not very elegant)
Object resources = props.get("Resources");
String[] sResources = null;
if (resources!=null && AnyConverter.isString(resources)) {
try {
sResources = substituteVariables(AnyConverter.toString(resources)).split(";");
}
catch (com.sun.star.lang.IllegalArgumentException e) {
// Failed to convert to String; should not happen - ignore
}
}
Object auto = props.get("AutoCreate"); Object auto = props.get("AutoCreate");
boolean bAutoCreate = false; boolean bAutoCreate = false;
if (auto!=null && AnyConverter.isString(auto)) { if (auto!=null && AnyConverter.isString(auto)) {
@ -204,7 +217,38 @@ public class FilterDataParser {
// ignore // ignore
} }
} }
// Load the resources from the specified URLs, if any
if (sfa2!=null && sResources!=null) {
for (String sResource : sResources) {
try {
String[] sParts = sResource.split("!");
if (sParts.length==3) {
// Format is <mime type>!<file name>!<URL>
XInputStream xIs = sfa2.openFileRead(sParts[2]);
if (xIs!=null) {
InputStream is = new XInputStreamToInputStreamAdapter(xIs);
converter.readResource(is, sParts[1], sParts[0]);
is.close();
xIs.closeInput();
}
} // otherwise wrong format, ignore
}
catch (IOException e) {
// ignore
}
catch (NotConnectedException e) {
// ignore
}
catch (CommandAbortedException e) {
// ignore
}
catch (com.sun.star.uno.Exception e) {
// ignore
}
}
}
// Create config if required // Create config if required
try { try {
if (bAutoCreate && sfa2!=null && sConfig!=null && !sConfig.startsWith("*") && !sfa2.exists(sConfig)) { if (bAutoCreate && sfa2!=null && sConfig!=null && !sConfig.startsWith("*") && !sfa2.exists(sConfig)) {
@ -271,7 +315,8 @@ public class FilterDataParser {
Enumeration<String> keys = props.keys(); Enumeration<String> keys = props.keys();
while (keys.hasMoreElements()) { while (keys.hasMoreElements()) {
String sKey = keys.nextElement(); String sKey = keys.nextElement();
if (!"ConfigURL".equals(sKey) && !"TemplateURL".equals(sKey) && !"StyleSheetURL".equals(sKey) && !"AutoCreate".equals(sKey)) { if (!"ConfigURL".equals(sKey) && !"TemplateURL".equals(sKey) && !"StyleSheetURL".equals(sKey)
&& !"Resources".equals(sKey) && !"AutoCreate".equals(sKey)) {
Object value = props.get(sKey); Object value = props.get(sKey);
if (AnyConverter.isString(value)) { if (AnyConverter.isString(value)) {
try { try {

View file

@ -402,6 +402,7 @@ public abstract class OptionsDialogBase extends DialogBase implements
filterData.put("ConfigURL",expander.expandMacros(XPropertySetHelper.getPropertyValueAsString(xCfgProps,"ConfigURL"))); filterData.put("ConfigURL",expander.expandMacros(XPropertySetHelper.getPropertyValueAsString(xCfgProps,"ConfigURL")));
filterData.put("TemplateURL",expander.expandMacros(XPropertySetHelper.getPropertyValueAsString(xCfgProps,"TargetTemplateURL"))); filterData.put("TemplateURL",expander.expandMacros(XPropertySetHelper.getPropertyValueAsString(xCfgProps,"TargetTemplateURL")));
filterData.put("StyleSheetURL",expander.expandMacros(XPropertySetHelper.getPropertyValueAsString(xCfgProps,"StyleSheetURL"))); filterData.put("StyleSheetURL",expander.expandMacros(XPropertySetHelper.getPropertyValueAsString(xCfgProps,"StyleSheetURL")));
// TODO: Resources...
XPropertySetHelper.setPropertyValue(xProps,"ConfigName",sConfigNames[i]); XPropertySetHelper.setPropertyValue(xProps,"ConfigName",sConfigNames[i]);
bFound = true; bFound = 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-2010 by Henrik Just * Copyright: 2002-2011 by Henrik Just
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.2 (2010-10-10) * Version 1.2 (2011-01-24)
* *
*/ */
@ -85,18 +85,18 @@ public final class BibliographyDialog
if (sMethod.equals("external_event") ){ if (sMethod.equals("external_event") ){
return handleExternalEvent(dlg, event); return handleExternalEvent(dlg, event);
} }
else if (sMethod.equals("BibTeXDirClick")) {
return bibTeXDirClick(dlg);
}
else if (sMethod.equals("ConvertZoteroCitationsChange")) { else if (sMethod.equals("ConvertZoteroCitationsChange")) {
return convertZoteroCitationsChange(dlg); return convertZoteroCitationsChange(dlg);
} }
else if (sMethod.equals("ZoteroBibTeXDirClick")) { else if (sMethod.equals("ConvertJabRefCitationsChange")) {
return zoteroBibTeXDirClick(dlg); return convertJabRefCitationsChange(dlg);
} }
else if (sMethod.equals("UseExternalBibTeXFilesChange")) { else if (sMethod.equals("UseExternalBibTeXFilesChange")) {
return useExternalBibTeXFilesChange(dlg); return useExternalBibTeXFilesChange(dlg);
} }
else if (sMethod.equals("ExternalBibTeXDirClick")) {
return externalBibTeXDirClick(dlg);
}
} }
catch (com.sun.star.uno.RuntimeException e) { catch (com.sun.star.uno.RuntimeException e) {
throw e; throw e;
@ -108,7 +108,8 @@ public final class BibliographyDialog
} }
public String[] getSupportedMethodNames() { public String[] getSupportedMethodNames() {
String[] sNames = { "external_event", "ConvertZoteroCitationsChange", "ZoteroBibTeXDirClick", "UseExternalBibTeXFilesChange", "ExternalBibTeXDirClick" }; String[] sNames = { "external_event", "UseExternalBibTeXFilesChange", "ConvertZoteroCitationsChange",
"ConvertJabRefCitationsChange", "ExternalBibTeXDirClick" };
return sNames; return sNames;
} }
@ -153,16 +154,16 @@ public final class BibliographyDialog
try { try {
Object view = registry.getRegistryView(REGISTRY_PATH, false); Object view = registry.getRegistryView(REGISTRY_PATH, false);
XPropertySet xProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,view); XPropertySet xProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,view);
dlg.setCheckBoxStateAsBoolean("ConvertZoteroCitations",
XPropertySetHelper.getPropertyValueAsBoolean(xProps, "ConvertZoteroCitations"));
dlg.setTextFieldText("ZoteroBibTeXDir",
XPropertySetHelper.getPropertyValueAsString(xProps, "ZoteroBibTeXDir"));
dlg.setTextFieldText("NatbibOptions",
XPropertySetHelper.getPropertyValueAsString(xProps, "NatbibOptions"));
dlg.setCheckBoxStateAsBoolean("UseExternalBibTeXFiles", dlg.setCheckBoxStateAsBoolean("UseExternalBibTeXFiles",
XPropertySetHelper.getPropertyValueAsBoolean(xProps, "UseExternalBibTeXFiles")); XPropertySetHelper.getPropertyValueAsBoolean(xProps, "UseExternalBibTeXFiles"));
dlg.setTextFieldText("ExternalBibTeXDir", dlg.setCheckBoxStateAsBoolean("ConvertZoteroCitations",
XPropertySetHelper.getPropertyValueAsString(xProps, "ExternalBibTeXDir")); XPropertySetHelper.getPropertyValueAsBoolean(xProps, "ConvertZoteroCitations"));
dlg.setCheckBoxStateAsBoolean("ConvertJabRefCitations",
XPropertySetHelper.getPropertyValueAsBoolean(xProps, "ConvertJabRefCitations"));
dlg.setTextFieldText("NatbibOptions",
XPropertySetHelper.getPropertyValueAsString(xProps, "NatbibOptions"));
dlg.setTextFieldText("BibTeXDir",
XPropertySetHelper.getPropertyValueAsString(xProps, "BibTeXDir"));
registry.disposeRegistryView(view); registry.disposeRegistryView(view);
} }
catch (Exception e) { catch (Exception e) {
@ -180,11 +181,11 @@ public final class BibliographyDialog
try { try {
Object view = registry.getRegistryView(REGISTRY_PATH, true); Object view = registry.getRegistryView(REGISTRY_PATH, true);
XPropertySet xProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,view); XPropertySet xProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,view);
XPropertySetHelper.setPropertyValue(xProps, "ConvertZoteroCitations", dlg.getCheckBoxStateAsBoolean("ConvertZoteroCitations"));
XPropertySetHelper.setPropertyValue(xProps, "ZoteroBibTeXDir", dlg.getTextFieldText("ZoteroBibTeXDir"));
XPropertySetHelper.setPropertyValue(xProps, "NatbibOptions", dlg.getTextFieldText("NatbibOptions"));
XPropertySetHelper.setPropertyValue(xProps, "UseExternalBibTeXFiles", dlg.getCheckBoxStateAsBoolean("UseExternalBibTeXFiles")); XPropertySetHelper.setPropertyValue(xProps, "UseExternalBibTeXFiles", dlg.getCheckBoxStateAsBoolean("UseExternalBibTeXFiles"));
XPropertySetHelper.setPropertyValue(xProps, "ExternalBibTeXDir", dlg.getTextFieldText("ExternalBibTeXDir")); XPropertySetHelper.setPropertyValue(xProps, "ConvertZoteroCitations", dlg.getCheckBoxStateAsBoolean("ConvertZoteroCitations"));
XPropertySetHelper.setPropertyValue(xProps, "ConvertJabRefCitations", dlg.getCheckBoxStateAsBoolean("ConvertJabRefCitations"));
XPropertySetHelper.setPropertyValue(xProps, "NatbibOptions", dlg.getTextFieldText("NatbibOptions"));
XPropertySetHelper.setPropertyValue(xProps, "BibTeXDir", dlg.getTextFieldText("BibTeXDir"));
// Commit registry changes // Commit registry changes
XChangesBatch xUpdateContext = (XChangesBatch) XChangesBatch xUpdateContext = (XChangesBatch)
@ -203,45 +204,44 @@ public final class BibliographyDialog
} }
} }
private boolean convertZoteroCitationsChange(DialogAccess dlg) {
// Update dialog according to the current setting of the checkbox
boolean bConvert = dlg.getCheckBoxStateAsBoolean("ConvertZoteroCitations");
dlg.setControlEnabled("ZoteroBibTeXDirLabel", bConvert);
dlg.setControlEnabled("ZoteroBibTeXDir", bConvert);
dlg.setControlEnabled("ZoteroBibTeXDirButton", bConvert);
dlg.setControlEnabled("NatbibOptionsLabel", bConvert);
dlg.setControlEnabled("NatbibOptions", bConvert);
return true;
}
private boolean zoteroBibTeXDirClick(DialogAccess dlg) {
String sPath = folderPicker.getPath();
if (sPath!=null) {
try {
dlg.setTextFieldText("ZoteroBibTeXDir", new File(new URI(sPath)).getCanonicalPath());
}
catch (IOException e) {
}
catch (URISyntaxException e) {
}
}
return true;
}
private boolean useExternalBibTeXFilesChange(DialogAccess dlg) { private boolean useExternalBibTeXFilesChange(DialogAccess dlg) {
// Update dialog according to the current setting of the checkbox enableBibTeXDir(dlg);
boolean bExternal = dlg.getCheckBoxStateAsBoolean("UseExternalBibTeXFiles");
dlg.setControlEnabled("ExternalBibTeXDirLabel", bExternal);
dlg.setControlEnabled("ExternalBibTeXDir", bExternal);
dlg.setControlEnabled("ExternalBibTeXDirButton", bExternal);
return true; return true;
} }
private boolean externalBibTeXDirClick(DialogAccess dlg) { private boolean convertZoteroCitationsChange(DialogAccess dlg) {
enableNatbibOptions(dlg);
enableBibTeXDir(dlg);
return true;
}
private boolean convertJabRefCitationsChange(DialogAccess dlg) {
enableNatbibOptions(dlg);
enableBibTeXDir(dlg);
return true;
}
private void enableNatbibOptions(DialogAccess dlg) {
boolean bConvertZotero = dlg.getCheckBoxStateAsBoolean("ConvertZoteroCitations");
boolean bConvertJabRef = dlg.getCheckBoxStateAsBoolean("ConvertJabRefCitations");
dlg.setControlEnabled("NatbibOptionsLabel", bConvertZotero || bConvertJabRef);
dlg.setControlEnabled("NatbibOptions", bConvertZotero || bConvertJabRef);
}
private void enableBibTeXDir(DialogAccess dlg) {
boolean bExternal = dlg.getCheckBoxStateAsBoolean("UseExternalBibTeXFiles");
boolean bConvertZotero = dlg.getCheckBoxStateAsBoolean("ConvertZoteroCitations");
boolean bConvertJabRef = dlg.getCheckBoxStateAsBoolean("ConvertJabRefCitations");
dlg.setControlEnabled("BibTeXDirLabel", bExternal || bConvertZotero || bConvertJabRef);
dlg.setControlEnabled("BibTeXDir", bExternal || bConvertZotero || bConvertJabRef);
dlg.setControlEnabled("BibTeXDirButton", bExternal|| bConvertZotero || bConvertJabRef);
}
private boolean bibTeXDirClick(DialogAccess dlg) {
String sPath = folderPicker.getPath(); String sPath = folderPicker.getPath();
if (sPath!=null) { if (sPath!=null) {
try { try {
dlg.setTextFieldText("ExternalBibTeXDir", new File(new URI(sPath)).getCanonicalPath()); dlg.setTextFieldText("BibTeXDir", new File(new URI(sPath)).getCanonicalPath());
} }
catch (IOException e) { catch (IOException e) {
} }

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-2011 by Henrik Just
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.2 (2010-10-11) * Version 1.2 (2011-01-25)
* *
*/ */
@ -31,6 +31,7 @@ import java.io.IOException;
import java.lang.Process; import java.lang.Process;
import java.lang.ProcessBuilder; import java.lang.ProcessBuilder;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map;
import java.util.Vector; import java.util.Vector;
import org.openoffice.da.comp.w2lcommon.helper.RegistryHelper; import org.openoffice.da.comp.w2lcommon.helper.RegistryHelper;
@ -99,11 +100,12 @@ public class ExternalApps {
* @param sAppName the name of the application to execute * @param sAppName the name of the application to execute
* @param sFileName the file name to use * @param sFileName the file name to use
* @param workDir the working directory to use * @param workDir the working directory to use
* @param env map of environment variables to set (or null if no variables needs to be set)
* @param bWaitFor true if the method should wait for the execution to finish * @param bWaitFor true if the method should wait for the execution to finish
* @return error code * @return error code
*/ */
public int execute(String sAppName, String sFileName, File workDir, boolean bWaitFor) { public int execute(String sAppName, String sFileName, File workDir, Map<String,String> env, boolean bWaitFor) {
return execute(sAppName, "", sFileName, workDir, bWaitFor); return execute(sAppName, "", sFileName, workDir, env, bWaitFor);
} }
/** Execute an external application /** Execute an external application
@ -111,10 +113,11 @@ public class ExternalApps {
* @param sCommand subcommand/option to pass to the command * @param sCommand subcommand/option to pass to the command
* @param sFileName the file name to use * @param sFileName the file name to use
* @param workDir the working directory to use * @param workDir the working directory to use
* @param env map of environment variables to set (or null if no variables needs to be set)
* @param bWaitFor true if the method should wait for the execution to finish * @param bWaitFor true if the method should wait for the execution to finish
* @return error code * @return error code
*/ */
public int execute(String sAppName, String sCommand, String sFileName, File workDir, boolean bWaitFor) { public int execute(String sAppName, String sCommand, String sFileName, File workDir, Map<String,String> env, boolean bWaitFor) {
// Assemble the command // Assemble the command
String[] sApp = getApplication(sAppName); String[] sApp = getApplication(sAppName);
if (sApp==null) { return 1; } if (sApp==null) { return 1; }
@ -129,6 +132,12 @@ public class ExternalApps {
ProcessBuilder pb = new ProcessBuilder(command); ProcessBuilder pb = new ProcessBuilder(command);
pb.directory(workDir); pb.directory(workDir);
if (env!=null) {
pb.environment().putAll(env);
if (env.containsKey("BIBINPUTS")) {
System.out.println("Running "+sApp[0]+" with BIBINPUTS="+env.get("BIBINPUTS"));
}
}
Process proc = pb.start(); Process proc = pb.start();
// Gobble the error stream of the application // Gobble the error stream of the application

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-2009 by Henrik Just * Copyright: 2002-2010 by Henrik Just
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.2 (2009-06-19) * Version 1.2 (2011-01-25)
* *
*/ */
@ -291,7 +291,7 @@ public class TeXImportFilter extends WeakBase implements XInitialization, XNamed
System.out.println("Executing tex4ht with command "+sCommand+" on file "+file.getName()); System.out.println("Executing tex4ht with command "+sCommand+" on file "+file.getName());
externalApps.execute(ExternalApps.MK4HT, sCommand, file.getName(), file.getParentFile(), true); externalApps.execute(ExternalApps.MK4HT, sCommand, file.getName(), file.getParentFile(), null, true);
if (xStatus!=null) { nStep+=5; xStatus.setValue(nStep); } if (xStatus!=null) { nStep+=5; xStatus.setValue(nStep); }

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-2009 by Henrik Just * Copyright: 2002-2010 by Henrik Just
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.2 (2009-11-29) * Version 1.2 (2011-01-25)
* *
*/ */
@ -28,10 +28,12 @@ package org.openoffice.da.comp.writer4latex;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import com.sun.star.uno.XComponentContext; import com.sun.star.uno.XComponentContext;
/** This class builds LaTeX documents into dvi, postscript or pdf and displays /** This class builds LaTeX documents into DVI, Postscript or PDF and displays
* the result. * the result.
*/ */
public final class TeXify { public final class TeXify {
@ -74,12 +76,13 @@ public final class TeXify {
/** Process a document /** Process a document
* @param file the LaTeX file to process * @param file the LaTeX file to process
* @param sBibinputs value for the BIBINPUTS environment variable (or null if it should not be extended)
* @param nBackend the desired backend format (generic, dvips, pdftex) * @param nBackend the desired backend format (generic, dvips, pdftex)
* @param bView set the true if the result should be displayed in the viewer * @param bView set the true if the result should be displayed in the viewer
* @throws IOException if the document cannot be read * @throws IOException if the document cannot be read
* @return true if the first LaTeX run was succesful * @return true if the first LaTeX run was successful
*/ */
public boolean process(File file, short nBackend, boolean bView) throws IOException { public boolean process(File file, String sBibinputs, short nBackend, boolean bView) throws IOException {
// Remove extension from file // Remove extension from file
if (file.getName().endsWith(".tex")) { if (file.getName().endsWith(".tex")) {
file = new File(file.getParentFile(), file = new File(file.getParentFile(),
@ -92,38 +95,38 @@ public final class TeXify {
// Process LaTeX document // Process LaTeX document
boolean bResult = false; boolean bResult = false;
if (nBackend==GENERIC) { if (nBackend==GENERIC) {
bResult = doTeXify(genericTexify, file); bResult = doTeXify(genericTexify, file, sBibinputs);
if (!bResult) return false; if (!bResult) return false;
if (externalApps.execute(ExternalApps.DVIVIEWER, if (externalApps.execute(ExternalApps.DVIVIEWER,
new File(file.getParentFile(),file.getName()+".dvi").getPath(), new File(file.getParentFile(),file.getName()+".dvi").getPath(),
file.getParentFile(), false)>0) { file.getParentFile(), null, false)>0) {
throw new IOException("Error executing dvi viewer"); throw new IOException("Error executing dvi viewer");
} }
} }
else if (nBackend==PDFTEX) { else if (nBackend==PDFTEX) {
bResult = doTeXify(pdfTexify, file); bResult = doTeXify(pdfTexify, file, sBibinputs);
if (!bResult) return false; if (!bResult) return false;
if (externalApps.execute(ExternalApps.PDFVIEWER, if (externalApps.execute(ExternalApps.PDFVIEWER,
new File(file.getParentFile(),file.getName()+".pdf").getPath(), new File(file.getParentFile(),file.getName()+".pdf").getPath(),
file.getParentFile(), false)>0) { file.getParentFile(), null, false)>0) {
throw new IOException("Error executing pdf viewer"); throw new IOException("Error executing pdf viewer");
} }
} }
else if (nBackend==DVIPS) { else if (nBackend==DVIPS) {
bResult = doTeXify(dvipsTexify, file); bResult = doTeXify(dvipsTexify, file, sBibinputs);
if (!bResult) return false; if (!bResult) return false;
if (externalApps.execute(ExternalApps.POSTSCRIPTVIEWER, if (externalApps.execute(ExternalApps.POSTSCRIPTVIEWER,
new File(file.getParentFile(),file.getName()+".ps").getPath(), new File(file.getParentFile(),file.getName()+".ps").getPath(),
file.getParentFile(), false)>0) { file.getParentFile(), null, false)>0) {
throw new IOException("Error executing postscript viewer"); throw new IOException("Error executing postscript viewer");
} }
} }
else if (nBackend==XETEX) { else if (nBackend==XETEX) {
bResult = doTeXify(xeTexify, file); bResult = doTeXify(xeTexify, file, sBibinputs);
if (!bResult) return false; if (!bResult) return false;
if (externalApps.execute(ExternalApps.PDFVIEWER, if (externalApps.execute(ExternalApps.PDFVIEWER,
new File(file.getParentFile(),file.getName()+".pdf").getPath(), new File(file.getParentFile(),file.getName()+".pdf").getPath(),
file.getParentFile(), false)>0) { file.getParentFile(), null, false)>0) {
throw new IOException("Error executing pdf viewer"); throw new IOException("Error executing pdf viewer");
} }
} }
@ -131,11 +134,16 @@ public final class TeXify {
} }
private boolean doTeXify(String[] sAppList, File file) throws IOException { private boolean doTeXify(String[] sAppList, File file, String sBibinputs) throws IOException {
for (int i=0; i<sAppList.length; i++) { for (int i=0; i<sAppList.length; i++) {
// Execute external application // Execute external application
Map<String,String> env =null;
if (ExternalApps.BIBTEX.equals(sAppList[i])) {
env = new HashMap<String,String>();
env.put("BIBINPUTS", sBibinputs);
}
int nReturnCode = externalApps.execute( int nReturnCode = externalApps.execute(
sAppList[i], file.getName(), file.getParentFile(), true); sAppList[i], file.getName(), file.getParentFile(), env, true);
System.out.println("Return code from "+sAppList[i]+": "+nReturnCode); System.out.println("Return code from "+sAppList[i]+": "+nReturnCode);
if (i==0 && nReturnCode>0) { if (i==0 && nReturnCode>0) {
return false; return false;

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-2011 by Henrik Just
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.2 (2010-10-13) * Version 1.2 (2011-01-25)
* *
*/ */
@ -44,6 +44,7 @@ import com.sun.star.task.XStatusIndicator;
import com.sun.star.task.XStatusIndicatorFactory; import com.sun.star.task.XStatusIndicatorFactory;
import com.sun.star.ui.dialogs.ExecutableDialogResults; import com.sun.star.ui.dialogs.ExecutableDialogResults;
import com.sun.star.ui.dialogs.XExecutableDialog; import com.sun.star.ui.dialogs.XExecutableDialog;
import com.sun.star.uno.AnyConverter;
import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext; import com.sun.star.uno.XComponentContext;
@ -54,6 +55,7 @@ import org.openoffice.da.comp.w2lcommon.helper.RegistryHelper;
import org.openoffice.da.comp.w2lcommon.helper.XPropertySetHelper; import org.openoffice.da.comp.w2lcommon.helper.XPropertySetHelper;
import writer2latex.util.CSVList; import writer2latex.util.CSVList;
import writer2latex.util.Misc;
/** This class implements the ui (dispatch) commands provided by Writer4LaTeX. /** This class implements the ui (dispatch) commands provided by Writer4LaTeX.
* The actual processing is done by the three core classes <code>TeXify</code>, * The actual processing is done by the three core classes <code>TeXify</code>,
@ -202,6 +204,8 @@ public final class Writer4LaTeX extends WeakBase
// First work a bit on the FilterData (get the backend and set bibliography options) // First work a bit on the FilterData (get the backend and set bibliography options)
String sBackend = "generic"; String sBackend = "generic";
String sBibinputs = null;
PropertyHelper mediaHelper = new PropertyHelper(mediaProps); PropertyHelper mediaHelper = new PropertyHelper(mediaProps);
Object filterData = mediaHelper.get("FilterData"); Object filterData = mediaHelper.get("FilterData");
if (filterData instanceof PropertyValue[]) { if (filterData instanceof PropertyValue[]) {
@ -217,14 +221,24 @@ public final class Writer4LaTeX extends WeakBase
try { try {
Object view = registry.getRegistryView(BibliographyDialog.REGISTRY_PATH, false); Object view = registry.getRegistryView(BibliographyDialog.REGISTRY_PATH, false);
XPropertySet xProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,view); XPropertySet xProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,view);
String sBibTeXFiles = getFileList(XPropertySetHelper.getPropertyValueAsString(xProps, "BibTeXDir"));
if (XPropertySetHelper.getPropertyValueAsBoolean(xProps, "ConvertZoteroCitations")) { if (XPropertySetHelper.getPropertyValueAsBoolean(xProps, "ConvertZoteroCitations")) {
filterHelper.put("zotero_bibtex_files", getFileList(XPropertySetHelper.getPropertyValueAsString(xProps, "ZoteroBibTeXDir"))); filterHelper.put("zotero_bibtex_files", sBibTeXFiles);
filterHelper.put("natbib_options", XPropertySetHelper.getPropertyValueAsString(xProps, "NatbibOptions"));
}
if (XPropertySetHelper.getPropertyValueAsBoolean(xProps, "ConvertJabRefCitations")) {
filterHelper.put("jabref_bibtex_files", sBibTeXFiles);
filterHelper.put("natbib_options", XPropertySetHelper.getPropertyValueAsString(xProps, "NatbibOptions")); filterHelper.put("natbib_options", XPropertySetHelper.getPropertyValueAsString(xProps, "NatbibOptions"));
} }
if (XPropertySetHelper.getPropertyValueAsBoolean(xProps, "UseExternalBibTeXFiles")) { if (XPropertySetHelper.getPropertyValueAsBoolean(xProps, "UseExternalBibTeXFiles")) {
filterHelper.put("external_bibtex_files", getFileList(XPropertySetHelper.getPropertyValueAsString(xProps, "ExternalBibTeXDir"))); filterHelper.put("external_bibtex_files", sBibTeXFiles);
} }
mediaHelper.put("FilterData",filterHelper.toArray()); String sBibTeXDir = XPropertySetHelper.getPropertyValueAsString(xProps, "BibTeXDir");
if (sBibTeXDir.length()>0) {
sBibinputs = sBibTeXDir+":";
}
mediaHelper.put("FilterData",filterHelper.toArray());
mediaProps = mediaHelper.toArray(); mediaProps = mediaHelper.toArray();
registry.disposeRegistryView(view); registry.disposeRegistryView(view);
} }
@ -255,16 +269,16 @@ public final class Writer4LaTeX extends WeakBase
try { try {
if (sBackend=="pdftex") { if (sBackend=="pdftex") {
bResult = texify.process(file, TeXify.PDFTEX, true); bResult = texify.process(file, sBibinputs, TeXify.PDFTEX, true);
} }
else if (sBackend=="dvips") { else if (sBackend=="dvips") {
bResult = texify.process(file, TeXify.DVIPS, true); bResult = texify.process(file, sBibinputs, TeXify.DVIPS, true);
} }
else if (sBackend=="xetex") { else if (sBackend=="xetex") {
bResult = texify.process(file, TeXify.XETEX, true); bResult = texify.process(file, sBibinputs, TeXify.XETEX, true);
} }
else if (sBackend=="generic") { else if (sBackend=="generic") {
bResult = texify.process(file, TeXify.GENERIC, true); bResult = texify.process(file, sBibinputs, TeXify.GENERIC, true);
} }
} }
catch (IOException e) { catch (IOException e) {
@ -289,11 +303,13 @@ public final class Writer4LaTeX extends WeakBase
File[] files = dir.listFiles(); File[] files = dir.listFiles();
for (File file : files) { for (File file : files) {
if (file.isFile() && file.getName().endsWith(".bib")) { if (file.isFile() && file.getName().endsWith(".bib")) {
filelist.addValue(file.getAbsolutePath()); //filelist.addValue(file.getAbsolutePath());
filelist.addValue(Misc.removeExtension(file.getName()));
} }
} }
} }
return filelist.toString(); String sFileList = filelist.toString();
return sFileList.length()>0 ? sFileList : "dummy";
} }
private void viewLog() { private void viewLog() {

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-2011 by Henrik Just
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.2 (2011-01-12) * Version 1.2 (2011-01-25)
* *
*/ */
@ -32,8 +32,8 @@ package writer2latex.api;
public class ConverterFactory { public class ConverterFactory {
// Version information // Version information
private static final String VERSION = "1.1.9"; private static final String VERSION = "1.1.6";
private static final String DATE = "2011-01-12"; private static final String DATE = "2011-01-25";
/** 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

@ -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-2011 by Henrik Just
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.2 (2010-10-13) * Version 1.2 (2011-01-24)
* *
*/ */
@ -58,6 +58,9 @@ public class FieldConverter extends ConverterHelper {
// Identify Zotero items // Identify Zotero items
private static final String ZOTERO_ITEM = "ZOTERO_ITEM"; private static final String ZOTERO_ITEM = "ZOTERO_ITEM";
// Identify JabRef items
private static final String JABREF_ITEM_1 = "JR_cite_1";
private static final String JABREF_ITEM_2 = "JR_cite_2";
// Links & references // Links & references
private ExportNameCollection targets = new ExportNameCollection(true); private ExportNameCollection targets = new ExportNameCollection(true);
@ -79,6 +82,7 @@ public class FieldConverter extends ConverterHelper {
private boolean bUsesTitleref = false; private boolean bUsesTitleref = false;
private boolean bUsesOooref = false; private boolean bUsesOooref = false;
private boolean bConvertZotero = false; private boolean bConvertZotero = false;
private boolean bConvertJabRef = false;
private boolean bNeedNatbib = false; private boolean bNeedNatbib = false;
public FieldConverter(OfficeReader ofr, LaTeXConfig config, ConverterPalette palette) { public FieldConverter(OfficeReader ofr, LaTeXConfig config, ConverterPalette palette) {
@ -86,6 +90,7 @@ public class FieldConverter extends ConverterHelper {
// hyperref.sty is not compatible with titleref.sty and oooref.sty: // hyperref.sty is not compatible with titleref.sty and oooref.sty:
bUseHyperref = config.useHyperref() && !config.useTitleref() && !config.useOooref(); bUseHyperref = config.useHyperref() && !config.useTitleref() && !config.useOooref();
bConvertZotero = config.useBibtex() && config.zoteroBibtexFiles().length()>0; bConvertZotero = config.useBibtex() && config.zoteroBibtexFiles().length()>0;
bConvertJabRef = config.useBibtex() && config.jabrefBibtexFiles().length()>0;
} }
/** <p>Append declarations needed by the <code>FieldConverter</code> to /** <p>Append declarations needed by the <code>FieldConverter</code> to
@ -598,7 +603,7 @@ public class FieldConverter extends ConverterHelper {
ldp.append("}"); ldp.append("}");
} }
oc.setInZoteroText(true); oc.setInZoteroJabRefText(true);
bNeedNatbib = true; bNeedNatbib = true;
@ -609,6 +614,27 @@ public class FieldConverter extends ConverterHelper {
return false; return false;
} }
// Try to handle this reference name as a JabRef reference, return true on success
private boolean handleJabRefReferenceName(String sName, LaTeXDocumentPortion ldp, Context oc) {
// First parse the reference name:
// A JabRef reference name has the form JR_cite_n_identifiers where
// n=1 for (Author date) and n=2 for Author (date) citations
// identifiers is a comma separated list of BibTeX keys
if (sName.startsWith(JABREF_ITEM_1)) {
ldp.append("\\citep{").append(sName.substring(JABREF_ITEM_1.length()+1)).append("}");
oc.setInZoteroJabRefText(true);
bNeedNatbib = true;
return true;
}
else if (sName.startsWith(JABREF_ITEM_2)) {
ldp.append("\\citet{").append(sName.substring(JABREF_ITEM_2.length()+1)).append("}");
oc.setInZoteroJabRefText(true);
bNeedNatbib = true;
return true;
}
return false;
}
private String shortenRefname(String s) { private String shortenRefname(String s) {
// For Zotero items, use the trailing unique identifier // For Zotero items, use the trailing unique identifier
if (s.startsWith(ZOTERO_ITEM)) { if (s.startsWith(ZOTERO_ITEM)) {
@ -627,8 +653,8 @@ public class FieldConverter extends ConverterHelper {
* @param oc the current context * @param oc the current context
*/ */
public void handleReferenceMarkEnd(Element node, LaTeXDocumentPortion ldp, Context oc) { public void handleReferenceMarkEnd(Element node, LaTeXDocumentPortion ldp, Context oc) {
// Nothing to do, except to mark that this ends any Zotero citation // Nothing to do, except to mark that this ends any Zotero/JabRef citation
oc.setInZoteroText(false); oc.setInZoteroJabRefText(false);
} }
/** <p>Process a reference mark (text:reference-mark or text:reference-mark-start tag)</p> /** <p>Process a reference mark (text:reference-mark or text:reference-mark-start tag)</p>
@ -640,8 +666,9 @@ public class FieldConverter extends ConverterHelper {
public void handleReferenceMark(Element node, LaTeXDocumentPortion ldp, Context oc) { public void handleReferenceMark(Element node, LaTeXDocumentPortion ldp, Context oc) {
if (!oc.isInSection() && !oc.isInCaption() && !oc.isVerbatim()) { if (!oc.isInSection() && !oc.isInCaption() && !oc.isVerbatim()) {
String sName = node.getAttribute(XMLString.TEXT_NAME); String sName = node.getAttribute(XMLString.TEXT_NAME);
// Zotero (mis)uses reference marks to store citations, so check this first // Zotero and JabRef (mis)uses reference marks to store citations, so check this first
if (sName!=null && (!bConvertZotero || !handleZoteroReferenceName(sName, ldp, oc))) { if (sName!=null && (!bConvertZotero || !handleZoteroReferenceName(sName, ldp, oc))
&& (!bConvertJabRef || !handleJabRefReferenceName(sName, ldp, oc))) {
// Plain reference mark // Plain reference mark
// Note: Always include \label here, even when it's not used // Note: Always include \label here, even when it's not used
ldp.append("\\label{ref:"+refnames.getExportName(shortenRefname(sName))+"}"); ldp.append("\\label{ref:"+refnames.getExportName(shortenRefname(sName))+"}");

View file

@ -195,11 +195,11 @@ public class InlineConverter extends ConverterHelper {
case Node.TEXT_NODE: case Node.TEXT_NODE:
String s = childNode.getNodeValue(); String s = childNode.getNodeValue();
if (s.length() > 0) { if (s.length() > 0) {
if (oc.isInZoteroText()) { // Comment out Zotero citations if (oc.isInZoteroJabRefText()) { // Comment out Zotero citations
ldp.append("%"); ldp.append("%");
} }
ldp.append(palette.getI18n().convert(s, false, oc.getLang())); ldp.append(palette.getI18n().convert(s, false, oc.getLang()));
if (oc.isInZoteroText()) { // End comment out if (oc.isInZoteroJabRefText()) { // End comment out
ldp.nl(); ldp.nl();
} }
} }

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-2011 by Henrik Just
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.2 (2010-12-15) * Version 1.2 (2011-01-23)
* *
*/ */
@ -48,7 +48,7 @@ public class LaTeXConfig extends writer2latex.base.ConfigBase {
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// I. Define items needed by ConfigBase // I. Define items needed by ConfigBase
protected int getOptionCount() { return 67; } protected int getOptionCount() { return 68; }
protected String getDefaultConfigPath() { return "/writer2latex/latex/config/"; } protected String getDefaultConfigPath() { return "/writer2latex/latex/config/"; }
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
@ -145,38 +145,39 @@ public class LaTeXConfig extends writer2latex.base.ConfigBase {
private static final int BIBTEX_STYLE = 32; private static final int BIBTEX_STYLE = 32;
private static final int EXTERNAL_BIBTEX_FILES = 33; private static final int EXTERNAL_BIBTEX_FILES = 33;
private static final int ZOTERO_BIBTEX_FILES = 34; private static final int ZOTERO_BIBTEX_FILES = 34;
private static final int NATBIB_OPTIONS = 35; private static final int JABREF_BIBTEX_FILES = 35;
private static final int FORMATTING = 36; private static final int NATBIB_OPTIONS = 36;
private static final int PAGE_FORMATTING = 37; private static final int FORMATTING = 37;
private static final int OTHER_STYLES = 38; private static final int PAGE_FORMATTING = 38;
private static final int IMAGE_CONTENT = 39; private static final int OTHER_STYLES = 39;
private static final int TABLE_CONTENT = 40; private static final int IMAGE_CONTENT = 40;
private static final int TABLE_FIRST_HEAD_STYLE = 41; private static final int TABLE_CONTENT = 41;
private static final int TABLE_HEAD_STYLE = 42; private static final int TABLE_FIRST_HEAD_STYLE = 42;
private static final int TABLE_FOOT_STYLE = 43; private static final int TABLE_HEAD_STYLE = 43;
private static final int TABLE_LAST_FOOT_STYLE = 44; private static final int TABLE_FOOT_STYLE = 44;
private static final int IGNORE_HARD_PAGE_BREAKS = 45; private static final int TABLE_LAST_FOOT_STYLE = 45;
private static final int IGNORE_HARD_LINE_BREAKS = 46; private static final int IGNORE_HARD_PAGE_BREAKS = 46;
private static final int IGNORE_EMPTY_PARAGRAPHS = 47; private static final int IGNORE_HARD_LINE_BREAKS = 47;
private static final int IGNORE_DOUBLE_SPACES = 48; private static final int IGNORE_EMPTY_PARAGRAPHS = 48;
private static final int ALIGN_FRAMES = 49; private static final int IGNORE_DOUBLE_SPACES = 49;
private static final int FLOAT_FIGURES = 50; private static final int ALIGN_FRAMES = 50;
private static final int FLOAT_TABLES = 51; private static final int FLOAT_FIGURES = 51;
private static final int FLOAT_OPTIONS = 52; private static final int FLOAT_TABLES = 52;
private static final int FIGURE_SEQUENCE_NAME = 53; private static final int FLOAT_OPTIONS = 53;
private static final int TABLE_SEQUENCE_NAME = 54; private static final int FIGURE_SEQUENCE_NAME = 54;
private static final int IMAGE_OPTIONS = 55; private static final int TABLE_SEQUENCE_NAME = 55;
private static final int REMOVE_GRAPHICS_EXTENSION = 56; private static final int IMAGE_OPTIONS = 56;
private static final int ORIGINAL_IMAGE_SIZE = 57; private static final int REMOVE_GRAPHICS_EXTENSION = 57;
private static final int SIMPLE_TABLE_LIMIT = 58; private static final int ORIGINAL_IMAGE_SIZE = 58;
private static final int NOTES = 59; private static final int SIMPLE_TABLE_LIMIT = 59;
private static final int METADATA = 60; private static final int NOTES = 60;
private static final int TABSTOP = 61; private static final int METADATA = 61;
private static final int WRAP_LINES_AFTER = 62; private static final int TABSTOP = 62;
private static final int SPLIT_LINKED_SECTIONS = 63; private static final int WRAP_LINES_AFTER = 63;
private static final int SPLIT_TOPLEVEL_SECTIONS = 64; private static final int SPLIT_LINKED_SECTIONS = 64;
private static final int SAVE_IMAGES_IN_SUBDIR = 65; private static final int SPLIT_TOPLEVEL_SECTIONS = 65;
private static final int DEBUG = 66; private static final int SAVE_IMAGES_IN_SUBDIR = 66;
private static final int DEBUG = 67;
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// IV. Our options data // IV. Our options data
@ -250,6 +251,7 @@ public class LaTeXConfig extends writer2latex.base.ConfigBase {
options[BIBTEX_STYLE] = new Option("bibtex_style","plain"); options[BIBTEX_STYLE] = new Option("bibtex_style","plain");
options[EXTERNAL_BIBTEX_FILES] = new Option("external_bibtex_files",""); options[EXTERNAL_BIBTEX_FILES] = new Option("external_bibtex_files","");
options[ZOTERO_BIBTEX_FILES] = new Option("zotero_bibtex_files",""); options[ZOTERO_BIBTEX_FILES] = new Option("zotero_bibtex_files","");
options[JABREF_BIBTEX_FILES] = new Option("jabref_bibtex_files","");
options[NATBIB_OPTIONS] = new Option("natbib_options",""); options[NATBIB_OPTIONS] = new Option("natbib_options","");
options[FORMATTING] = new IntegerOption("formatting","convert_basic") { options[FORMATTING] = new IntegerOption("formatting","convert_basic") {
public void setString(String sValue) { public void setString(String sValue) {
@ -661,6 +663,7 @@ public class LaTeXConfig extends writer2latex.base.ConfigBase {
public String bibtexStyle() { return options[BIBTEX_STYLE].getString(); } public String bibtexStyle() { return options[BIBTEX_STYLE].getString(); }
public String externalBibtexFiles() { return options[EXTERNAL_BIBTEX_FILES].getString(); } public String externalBibtexFiles() { return options[EXTERNAL_BIBTEX_FILES].getString(); }
public String zoteroBibtexFiles() { return options[ZOTERO_BIBTEX_FILES].getString(); } public String zoteroBibtexFiles() { return options[ZOTERO_BIBTEX_FILES].getString(); }
public String jabrefBibtexFiles() { return options[JABREF_BIBTEX_FILES].getString(); }
public String getNatbibOptions() { return options[NATBIB_OPTIONS].getString(); } public String getNatbibOptions() { return options[NATBIB_OPTIONS].getString(); }
// Formatting options // Formatting options

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-2011 by Henrik Just
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.2 (2010-10-06) * Version 1.2 (2011-01-24)
* *
*/ */
@ -121,6 +121,20 @@ public class SectionConverter extends ConverterHelper {
return false; return false;
} }
} }
// Handle a section as a JabRef bibliography
private boolean handleJabRefBibliography(Element node, LaTeXDocumentPortion ldp, Context oc) {
String sName = node.getAttribute(XMLString.TEXT_NAME);
if (config.useBibtex() && config.jabrefBibtexFiles().length()>0 && sName.equals("JR_bib")) {
// This section is a JabRef bibliography, and the user wishes to handle it as such
// A JabRef bibliography is identified by the name JR_bib
// Use the BibTeX style and files given in the configuration
ldp.append("\\bibliographystyle{").append(config.bibtexStyle()).append("}").nl()
.append("\\bibliography{").append(config.jabrefBibtexFiles()).append("}").nl();
return true;
}
return false;
}
/** <p> Process a section (text:section tag)</p> /** <p> Process a section (text:section tag)</p>
* @param node The element containing the section * @param node The element containing the section
@ -167,8 +181,8 @@ public class SectionConverter extends ConverterHelper {
if (sFileName!=null) { if (sFileName!=null) {
ldp.append("\\input{").append(sFileName).append("}").nl(); ldp.append("\\input{").append(sFileName).append("}").nl();
} }
// Zotero might have generated this section as a bibliograhy: // Zotero or JabRef might have generated this section as a bibliograhy:
if (!handleZoteroBibliography(node,sectionLdp,ic)) { if (!handleZoteroBibliography(node,sectionLdp,ic) && !handleJabRefBibliography(node,sectionLdp,ic)) {
palette.getBlockCv().traverseBlockText(node,sectionLdp,ic); palette.getBlockCv().traverseBlockText(node,sectionLdp,ic);
} }
if (sectionLdp!=ldp) { sectionLdp.append("\\endinput").nl(); } if (sectionLdp!=ldp) { sectionLdp.append("\\endinput").nl(); }

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-2011 by Henrik Just
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.2 (2010-10-04) * Version 1.2 (2011-01-24)
* *
*/ */
@ -78,8 +78,8 @@ public class Context {
// within a caption // within a caption
private boolean bInCaption = false; private boolean bInCaption = false;
// within a Zotero citation // within a Zotero/JabRef citation
private boolean bInZoteroText = false; private boolean bInZoteroJabRefText = false;
// within a floating figure (figure environment) // within a floating figure (figure environment)
private boolean bInFigureFloat = false; private boolean bInFigureFloat = false;
@ -194,9 +194,9 @@ public class Context {
public boolean isInCaption() { return bInCaption; } public boolean isInCaption() { return bInCaption; }
public void setInZoteroText(boolean bInZoteroText) { this.bInZoteroText = bInZoteroText; } public void setInZoteroJabRefText(boolean bInZoteroJabRefText) { this.bInZoteroJabRefText = bInZoteroJabRefText; }
public boolean isInZoteroText() { return bInZoteroText; } public boolean isInZoteroJabRefText() { return bInZoteroJabRefText; }
public void setInFigureFloat(boolean bInFigureFloat) { this.bInFigureFloat = bInFigureFloat; } public void setInFigureFloat(boolean bInFigureFloat) { this.bInFigureFloat = bInFigureFloat; }
@ -309,6 +309,7 @@ public class Context {
newContext.setInContinuedList(bInContinuedList); newContext.setInContinuedList(bInContinuedList);
newContext.setInSection(bInSection); newContext.setInSection(bInSection);
newContext.setInCaption(bInCaption); newContext.setInCaption(bInCaption);
newContext.setInZoteroJabRefText(bInZoteroJabRefText);
newContext.setInFigureFloat(bInFigureFloat); newContext.setInFigureFloat(bInFigureFloat);
newContext.setInTableFloat(bInTableFloat); newContext.setInTableFloat(bInTableFloat);
newContext.setInFrame(bInFrame); newContext.setInFrame(bInFrame);

View file

@ -5,7 +5,7 @@
<identifier value="org.openoffice.da.writer2latex.oxt"/> <identifier value="org.openoffice.da.writer2latex.oxt"/>
<version value="1.1.9" /> <version value="1.1.6" />
<dependencies> <dependencies>
<OpenOffice.org-minimal-version value="3.0" d:name="OpenOffice.org 3.0"/> <OpenOffice.org-minimal-version value="3.0" d:name="OpenOffice.org 3.0"/>

View file

@ -15,8 +15,9 @@
<set oor:name="Resources" oor:node-type="Resource" /> <set oor:name="Resources" oor:node-type="Resource" />
</group> </group>
<group oor:name="Resource"> <group oor:name="Resource">
<prop oor:name="FileName" oor:type="xs:string" />
<prop oor:name="MediaType" oor:type="xs:string" /> <prop oor:name="MediaType" oor:type="xs:string" />
<prop oor:name="FileName" oor:type="xs:string" />
<prop oor:name="URL" oor:type="xs:string" />
</group> </group>
<group oor:name="Template"> <group oor:name="Template">
<prop oor:name="TemplateName" oor:type="xs:string" /> <prop oor:name="TemplateName" oor:type="xs:string" />

View file

@ -5,7 +5,7 @@
<identifier value="org.openoffice.da.writer2xhtml.oxt" /> <identifier value="org.openoffice.da.writer2xhtml.oxt" />
<version value="1.1.9" /> <version value="1.1.6" />
<dependencies> <dependencies>
<OpenOffice.org-minimal-version value="3.0" d:name="OpenOffice.org 3.0"/> <OpenOffice.org-minimal-version value="3.0" d:name="OpenOffice.org 3.0"/>

View file

@ -25,11 +25,11 @@
<node-ref oor:name="PdfViewer" oor:node-type="Application" /> <node-ref oor:name="PdfViewer" oor:node-type="Application" />
</group> </group>
<group oor:name="BibliographyOptions"> <group oor:name="BibliographyOptions">
<prop oor:name="ConvertZoteroCitations" oor:type="xs:boolean" />
<prop oor:name="ZoteroBibTeXDir" oor:type="xs:string" />
<prop oor:name="NatbibOptions" oor:type="xs:string" />
<prop oor:name="UseExternalBibTeXFiles" oor:type="xs:boolean" /> <prop oor:name="UseExternalBibTeXFiles" oor:type="xs:boolean" />
<prop oor:name="ExternalBibTeXDir" oor:type="xs:string" /> <prop oor:name="ConvertZoteroCitations" oor:type="xs:boolean" />
<prop oor:name="ConvertJabRefCitations" oor:type="xs:boolean" />
<prop oor:name="NatbibOptions" oor:type="xs:string" />
<prop oor:name="BibTeXDir" oor:type="xs:string" />
</group> </group>
</component> </component>
</oor:component-schema> </oor:component-schema>

View file

@ -87,19 +87,19 @@
</node> </node>
</node> </node>
<node oor:name="BibliographyOptions"> <node oor:name="BibliographyOptions">
<prop oor:name="UseExternalBibTeXFiles" oor:type="xs:boolean">
<value>false</value>
</prop>
<prop oor:name="ConvertZoteroCitations" oor:type="xs:boolean"> <prop oor:name="ConvertZoteroCitations" oor:type="xs:boolean">
<value>false</value> <value>false</value>
</prop> </prop>
<prop oor:name="ZoteroBibTeXDir" oor:type="xs:string"> <prop oor:name="ConvertJabRefCitations" oor:type="xs:boolean">
<value></value> <value>false</value>
</prop> </prop>
<prop oor:name="NatbibOptions" oor:type="xs:string"> <prop oor:name="NatbibOptions" oor:type="xs:string">
<value></value> <value></value>
</prop> </prop>
<prop oor:name="UseExternalBibTeXFiles" oor:type="xs:boolean"> <prop oor:name="BibTeXDir" oor:type="xs:string">
<value>false</value>
</prop>
<prop oor:name="ExternalBibTeXDir" oor:type="xs:string">
<value></value> <value></value>
</prop> </prop>
</node> </node>

View file

@ -1,27 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dlg:window PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "dialog.dtd"> <!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="Bibliography" dlg:left="139" dlg:top="84" dlg:width="260" dlg:height="185" dlg:closeable="true" dlg:moveable="true" dlg:title="Writer4LaTeX Bibliography Configuration" dlg:withtitlebar="false" dlg:help-url="org.openoffice.da.writer4latex.oxt:BibliographyDialog"> <dlg:window xmlns:dlg="http://openoffice.org/2000/dialog" xmlns:script="http://openoffice.org/2000/script" dlg:id="Bibliography" dlg:left="139" dlg:top="84" dlg:width="260" dlg:height="185" dlg:help-url="org.openoffice.da.writer4latex.oxt:BibliographyDialog" dlg:closeable="true" dlg:moveable="true" dlg:title="Writer4LaTeX Bibliography Configuration" dlg:withtitlebar="false">
<dlg:bulletinboard> <dlg:bulletinboard>
<dlg:text dlg:id="ZoteroLabel" dlg:tab-index="0" dlg:left="6" dlg:top="4" dlg:width="244" dlg:height="12" dlg:value="Zotero Support"/> <dlg:checkbox dlg:id="ConvertZoteroCitations" dlg:tab-index="2" dlg:left="10" dlg:top="32" dlg:width="240" dlg:height="12" dlg:help-url="org.openoffice.da.writer4latex.oxt:BibliographyConvertZoteroCitations" dlg:value="Convert Zotero citations (requires natbib.sty)" dlg:checked="false">
<dlg:checkbox dlg:id="ConvertZoteroCitations" dlg:tab-index="1" dlg:left="10" dlg:top="18" dlg:width="240" dlg:height="12" dlg:value="Convert Zotero ciations (requires natbib.sty)" dlg:checked="false" dlg:help-url="org.openoffice.da.writer4latex.oxt:BibliographyConvertZoteroCitations">
<script:event script:event-name="on-itemstatechange" script:macro-name="vnd.sun.star.UNO:ConvertZoteroCitationsChange" script:language="UNO"/> <script:event script:event-name="on-itemstatechange" script:macro-name="vnd.sun.star.UNO:ConvertZoteroCitationsChange" script:language="UNO"/>
</dlg:checkbox> </dlg:checkbox>
<dlg:text dlg:id="ZoteroBibTeXDirLabel" dlg:tab-index="2" dlg:left="10" dlg:top="32" dlg:width="60" dlg:height="12" dlg:value="BibTeX folder"/> <dlg:text dlg:id="NatbibOptionsLabel" dlg:tab-index="7" dlg:left="10" dlg:top="60" dlg:width="55" dlg:height="12" dlg:value="Natbib options"/>
<dlg:textfield dlg:id="ZoteroBibTeXDir" dlg:tab-index="3" dlg:left="70" dlg:top="30" dlg:width="130" dlg:height="12" dlg:help-url="org.openoffice.da.writer4latex.oxt:BibliographyZoteroBibTeXDir"/> <dlg:textfield dlg:id="NatbibOptions" dlg:tab-index="4" dlg:left="70" dlg:top="58" dlg:width="180" dlg:height="12" dlg:help-url="org.openoffice.da.writer4latex.oxt:BibliographyNatbibOptions"/>
<dlg:button dlg:id="ZoteroBibTeXDirButton" dlg:tab-index="4" dlg:left="210" dlg:top="30" dlg:width="40" dlg:height="12" dlg:value="Browse..." dlg:help-url="org.openoffice.da.writer4latex.oxt:BibliographyZoteroBibTeXDirButton"> <dlg:checkbox dlg:id="UseExternalBibTeXFiles" dlg:tab-index="1" dlg:left="10" dlg:top="18" dlg:width="240" dlg:height="12" dlg:help-url="org.openoffice.da.writer4latex.oxt:BibliographyUseExternalBibTeXFiles" dlg:value="Use external BibTeX files for normal citations" dlg:checked="false">
<script:event script:event-name="on-mouseup" script:macro-name="vnd.sun.star.UNO:ZoteroBibTeXDirClick" script:language="UNO"/>
</dlg:button>
<dlg:text dlg:id="NatbibOptionsLabel" dlg:tab-index="5" dlg:left="10" dlg:top="46" dlg:width="50" dlg:height="12" dlg:value="Natbib options"/>
<dlg:textfield dlg:id="NatbibOptions" dlg:tab-index="6" dlg:left="70" dlg:top="44" dlg:width="180" dlg:height="12" dlg:help-url="org.openoffice.da.writer4latex.oxt:BibliographyNatbibOptions"/>
<dlg:text dlg:id="ExternalBibTeXLabel" dlg:tab-index="7" dlg:left="6" dlg:top="60" dlg:width="244" dlg:height="12" dlg:value="External BibTeX files"/>
<dlg:checkbox dlg:id="UseExternalBibTeXFiles" dlg:tab-index="8" dlg:left="10" dlg:top="74" dlg:width="240" dlg:height="12" dlg:value="Use external BibTeX files" dlg:checked="false" dlg:help-url="org.openoffice.da.writer4latex.oxt:BibliographyUseExternalBibTeXFiles" >
<script:event script:event-name="on-itemstatechange" script:macro-name="vnd.sun.star.UNO:UseExternalBibTeXFilesChange" script:language="UNO"/> <script:event script:event-name="on-itemstatechange" script:macro-name="vnd.sun.star.UNO:UseExternalBibTeXFilesChange" script:language="UNO"/>
</dlg:checkbox> </dlg:checkbox>
<dlg:text dlg:id="ExternalBibTeXDirLabel" dlg:tab-index="9" dlg:left="10" dlg:top="88" dlg:width="60" dlg:height="12" dlg:value="BibTeX folder"/> <dlg:text dlg:id="BibTeXDirLabel" dlg:tab-index="8" dlg:left="10" dlg:top="74" dlg:width="55" dlg:height="12" dlg:value="BibTeX folder"/>
<dlg:textfield dlg:id="ExternalBibTeXDir" dlg:tab-index="10" dlg:left="70" dlg:top="86" dlg:width="130" dlg:height="12" dlg:help-url="org.openoffice.da.writer4latex.oxt:BibliographyExternalBibTeXDir"/> <dlg:textfield dlg:id="BibTeXDir" dlg:tab-index="5" dlg:left="70" dlg:top="72" dlg:width="130" dlg:height="12" dlg:help-url="org.openoffice.da.writer4latex.oxt:BibliographyBibTeXDir"/>
<dlg:button dlg:id="ExternalBibTeXDirButton" dlg:tab-index="11" dlg:left="210" dlg:top="86" dlg:width="40" dlg:height="12" dlg:value="Browse..." dlg:help-url="org.openoffice.da.writer4latex.oxt:BibliographyExternalBibTeXDirButton"> <dlg:button dlg:id="BibTeXDirButton" dlg:tab-index="6" dlg:left="210" dlg:top="72" dlg:width="40" dlg:height="12" dlg:help-url="org.openoffice.da.writer4latex.oxt:BibliographyBibTeXDirButton" dlg:value="Browse...">
<script:event script:event-name="on-mouseup" script:macro-name="vnd.sun.star.UNO:ExternalBibTeXDirClick" script:language="UNO"/> <script:event script:event-name="on-mouseup" script:macro-name="vnd.sun.star.UNO:BibTeXDirClick" script:language="UNO"/>
</dlg:button> </dlg:button>
</dlg:bulletinboard> <dlg:text dlg:id="BibliographyLabel" dlg:tab-index="0" dlg:left="6" dlg:top="4" dlg:width="244" dlg:height="12" dlg:value="Bibliography and BibTeX"/>
<dlg:checkbox dlg:id="ConvertJabRefCitations" dlg:tab-index="3" dlg:left="10" dlg:top="46" dlg:width="240" dlg:height="12" dlg:value="Convert JabRef citations (requires natbib.sty)" dlg:help-url="org.openoffice.da.writer4latex.oxt:BibliographyConvertJabRefCitations" dlg:checked="false">
<script:event script:event-name="on-itemstatechange" script:macro-name="vnd.sun.star.UNO:ConvertJabRefCitationsChange" script:language="UNO"/>
</dlg:checkbox>
</dlg:bulletinboard>
</dlg:window> </dlg:window>

View file

@ -4,7 +4,7 @@
xmlns:xlink="http://www.w3.org/1999/xlink"> xmlns:xlink="http://www.w3.org/1999/xlink">
<identifier value="org.openoffice.da.writer4latex.oxt" /> <identifier value="org.openoffice.da.writer4latex.oxt" />
<version value="1.1.9" /> <version value="1.1.6" />
<dependencies> <dependencies>
<OpenOffice.org-minimal-version value="3.0" d:name="OpenOffice.org 3.0"/> <OpenOffice.org-minimal-version value="3.0" d:name="OpenOffice.org 3.0"/>
</dependencies> </dependencies>

View file

@ -2,5 +2,5 @@
<description xmlns="http://openoffice.org/extensions/description/2006" <description xmlns="http://openoffice.org/extensions/description/2006"
xmlns:d="http://openoffice.org/extensions/description/2006"> xmlns:d="http://openoffice.org/extensions/description/2006">
<identifier value="org.openoffice.da.writer2latex.xhtml-config-sample.oxt" /> <identifier value="org.openoffice.da.writer2latex.xhtml-config-sample.oxt" />
<version value="1.1.9" /> <version value="1.1.6" />
</description> </description>

View file

@ -1,4 +1,4 @@
Writer2LaTeX source version 1.1.9 Writer2LaTeX source version 1.1.6
================================= =================================
Writer2LaTeX is (c) 2002-2011 by Henrik Just. Writer2LaTeX is (c) 2002-2011 by Henrik Just.