w2l: Externalize UI strings

git-svn-id: svn://svn.code.sf.net/p/writer2latex/code/trunk@248 f0f2a975-2e09-46c8-9428-3b39399b9f3c
This commit is contained in:
henrikjust 2015-05-29 09:14:04 +00:00
parent 51a7c85b69
commit 0906487d39
18 changed files with 616 additions and 422 deletions

View file

@ -2,7 +2,7 @@
############################################################################
# This is the Ant build file for writer2latex
# Original: Sep 2004 (mgn)
# version 1.6 (2015-05-12)
# version 1.6 (2015-05-28)
############################################################################
-->
<project name="w2l" default="help" basedir=".">
@ -137,6 +137,7 @@
<exclude name="**/AllTests.class"/>
<include name="**/*.xml"/>
<include name="**/*.class"/>
<include name="**/*.properties"/>
<exclude name="writer2latex/Application.class"/>
<exclude name="writer2latex/xhtml/**/*"/>
<exclude name="org/openoffice/da/comp/writer2xhtml/**/*"/>
@ -176,6 +177,7 @@
<exclude name="**/*Test.class"/>
<exclude name="**/AllTests.class"/>
<include name="org/openoffice/da/comp/w2lcommon/**/*.class"/>
<include name="org/openoffice/da/comp/w2lcommon/**/*.properties"/>
<include name="org/openoffice/da/comp/writer2xhtml/**/*.class"/>
<include name="writer2latex/api/**/*.class"/>
<include name="writer2latex/base/**/*.class"/>

View file

@ -2,6 +2,8 @@ Changelog for Writer2LaTeX version 1.4 -> 1.6
---------- version 1.5.3 ----------
[w2l] UI strings in the code are now externalized for localization
[w2l] Color support in StarMath have changed with LO 4.4 and will with (probably) AOO 4.2
(https://bz.apache.org/ooo/show_bug.cgi?id=118191). Now the 16 basic HTML colors are used. This is an incompatible
change because StarMath used to apply dark versions of red, blue, cyan and magenta.

Binary file not shown.

View file

@ -0,0 +1,47 @@
/************************************************************************
*
* Messages.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-2015 by Henrik Just
*
* All Rights Reserved.
*
* Version 1.6 (2015-05-28)
*
*/
package org.openoffice.da.comp.w2lcommon.filter;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
public class Messages {
private static final String BUNDLE_NAME = "org.openoffice.da.comp.w2lcommon.filter.messages"; //$NON-NLS-1$
private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
.getBundle(BUNDLE_NAME);
private Messages() {
}
public static String getString(String key) {
try {
return RESOURCE_BUNDLE.getString(key);
} catch (MissingResourceException e) {
return '!' + key + '!';
}
}
}

View file

@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
* Version 1.6 (2015-05-05)
* Version 1.6 (2015-05-28)
*
*/
package org.openoffice.da.comp.w2lcommon.filter;
@ -107,7 +107,7 @@ public class UNOPublisher {
XSimpleFileAccess2 sfa2 = null;
try {
Object sfaObject = xContext.getServiceManager().createInstanceWithContext(
"com.sun.star.ucb.SimpleFileAccess", xContext);
"com.sun.star.ucb.SimpleFileAccess", xContext); //$NON-NLS-1$
sfa2 = (XSimpleFileAccess2) UnoRuntime.queryInterface(XSimpleFileAccess2.class, sfaObject);
}
catch (com.sun.star.uno.Exception e) {
@ -120,13 +120,13 @@ public class UNOPublisher {
catch (IOException e) {
xStatus.end();
MessageBox msgBox = new MessageBox(xContext, xFrame);
msgBox.showMessage(sAppName,"Error: Failed to export document");
msgBox.showMessage(sAppName,Messages.getString("UNOPublisher.failexport")); //$NON-NLS-1$
return false;
}
catch (com.sun.star.uno.Exception e) {
xStatus.end();
MessageBox msgBox = new MessageBox(xContext, xFrame);
msgBox.showMessage(sAppName,"Error: Failed to export document");
msgBox.showMessage(sAppName,Messages.getString("UNOPublisher.failexport")); //$NON-NLS-1$
return false;
}
xStatus.setValue(7); // Document is converted, that's 70%
@ -174,26 +174,26 @@ public class UNOPublisher {
String sDocumentUrl = xModel.getURL();
if (sDocumentUrl.length()==0) { // The document has no location
MessageBox msgBox = new MessageBox(xContext, xFrame);
msgBox.showMessage(sAppName,"Please save the document first");
msgBox.showMessage(sAppName,Messages.getString("UNOPublisher.savedocument")); //$NON-NLS-1$
return false;
}
else if (!".odt".equals(Misc.getFileExtension(sDocumentUrl)) && !".fodt".equals(Misc.getFileExtension(sDocumentUrl)) && !".ods".equals(Misc.getFileExtension(sDocumentUrl)) && !".fods".equals(Misc.getFileExtension(sDocumentUrl))) {
else if (!".odt".equals(Misc.getFileExtension(sDocumentUrl)) && !".fodt".equals(Misc.getFileExtension(sDocumentUrl)) && !".ods".equals(Misc.getFileExtension(sDocumentUrl)) && !".fods".equals(Misc.getFileExtension(sDocumentUrl))) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
MessageBox msgBox = new MessageBox(xContext, xFrame);
msgBox.showMessage(sAppName,"Please save the document in OpenDocument format (.odt)");
msgBox.showMessage(sAppName,Messages.getString("UNOPublisher.saveodt")); //$NON-NLS-1$
return false;
}
else if (!sDocumentUrl.startsWith("file:")) {
else if (!sDocumentUrl.startsWith("file:")) { //$NON-NLS-1$
MessageBox msgBox = new MessageBox(xContext, xFrame);
msgBox.showMessage(sAppName,"Please save the document in the local file system");
msgBox.showMessage(sAppName,Messages.getString("UNOPublisher.savefilesystem")); //$NON-NLS-1$
return false;
}
else if (System.getProperty("os.name").startsWith("Windows")) {
else if (System.getProperty("os.name").startsWith("Windows")) { //$NON-NLS-1$ //$NON-NLS-2$
// Avoid UNC paths (LaTeX does not like them)
Pattern windowsPattern = Pattern.compile("^file:///[A-Za-z][|:].*");
Pattern windowsPattern = Pattern.compile("^file:///[A-Za-z][|:].*"); //$NON-NLS-1$
if (!windowsPattern.matcher(sDocumentUrl).matches()) {
MessageBox msgBox = new MessageBox(xContext, xFrame);
msgBox.showMessage(sAppName,
"Please save the document on a location with a drive name");
Messages.getString("UNOPublisher.savedrivename")); //$NON-NLS-1$
return false;
}
}
@ -247,17 +247,17 @@ public class UNOPublisher {
// Create inital media properties
mediaProps = new PropertyValue[2];
mediaProps[0] = new PropertyValue();
mediaProps[0].Name = "FilterName";
mediaProps[0].Name = "FilterName"; //$NON-NLS-1$
mediaProps[0].Value = getFilterName(format);
mediaProps[1] = new PropertyValue();
mediaProps[1].Name = "URL";
mediaProps[1].Name = "URL"; //$NON-NLS-1$
mediaProps[1].Value = getTargetURL(format);
}
private boolean updateMediaProperties(TargetFormat format) {
prepareMediaProperties(format);
String sDialogName = xModel.getURL().endsWith(".odt") || xModel.getURL().endsWith(".fodt") ?
String sDialogName = xModel.getURL().endsWith(".odt") || xModel.getURL().endsWith(".fodt") ? //$NON-NLS-1$ //$NON-NLS-2$
getDialogName(format) : getDialogNameCalc(format);
if (sDialogName!=null) {
try {
@ -290,26 +290,26 @@ public class UNOPublisher {
private static String getTargetExtension(TargetFormat format) {
switch (format) {
case xhtml: return ".html";
case xhtml11: return ".xhtml";
case xhtml_mathml: return ".xhtml";
case html5: return ".html";
case epub: return ".epub";
case epub3: return ".epub";
case latex: return ".tex";
default: return "";
case xhtml: return ".html"; //$NON-NLS-1$
case xhtml11: return ".xhtml"; //$NON-NLS-1$
case xhtml_mathml: return ".xhtml"; //$NON-NLS-1$
case html5: return ".html"; //$NON-NLS-1$
case epub: return ".epub"; //$NON-NLS-1$
case epub3: return ".epub"; //$NON-NLS-1$
case latex: return ".tex"; //$NON-NLS-1$
default: return ""; //$NON-NLS-1$
}
}
private static String getDialogName(TargetFormat format) {
switch (format) {
case xhtml:
case xhtml11: return "org.openoffice.da.comp.writer2xhtml.XhtmlOptionsDialog";
case xhtml11: return "org.openoffice.da.comp.writer2xhtml.XhtmlOptionsDialog"; //$NON-NLS-1$
case xhtml_mathml:
case html5: return "org.openoffice.da.comp.writer2xhtml.XhtmlOptionsDialogMath";
case epub: return "org.openoffice.da.comp.writer2xhtml.EpubOptionsDialog";
case epub3: return "org.openoffice.da.comp.writer2xhtml.Epub3OptionsDialog";
case latex: return "org.openoffice.da.comp.writer2latex.LaTeXOptionsDialog";
case html5: return "org.openoffice.da.comp.writer2xhtml.XhtmlOptionsDialogMath"; //$NON-NLS-1$
case epub: return "org.openoffice.da.comp.writer2xhtml.EpubOptionsDialog"; //$NON-NLS-1$
case epub3: return "org.openoffice.da.comp.writer2xhtml.Epub3OptionsDialog"; //$NON-NLS-1$
case latex: return "org.openoffice.da.comp.writer2latex.LaTeXOptionsDialog"; //$NON-NLS-1$
default: return null;
}
}
@ -319,7 +319,7 @@ public class UNOPublisher {
case xhtml:
case xhtml11:
case xhtml_mathml:
case html5: return "org.openoffice.da.comp.writer2xhtml.XhtmlOptionsDialogCalc";
case html5: return "org.openoffice.da.comp.writer2xhtml.XhtmlOptionsDialogCalc"; //$NON-NLS-1$
case epub:
case epub3:
case latex:
@ -329,14 +329,14 @@ public class UNOPublisher {
private static String getFilterName(TargetFormat format) {
switch (format) {
case xhtml: return "org.openoffice.da.writer2xhtml";
case xhtml11: return "org.openoffice.da.writer2xhtml11";
case xhtml_mathml: return "org.openoffice.da.writer2xhtml.mathml";
case html5: return "org.openoffice.da.writer2xhtml5";
case epub: return "org.openoffice.da.writer2xhtml.epub";
case epub3: return "org.openoffice.da.writer2xhtml.epub3";
case latex: return "org.openoffice.da.writer2latex";
default: return "";
case xhtml: return "org.openoffice.da.writer2xhtml"; //$NON-NLS-1$
case xhtml11: return "org.openoffice.da.writer2xhtml11"; //$NON-NLS-1$
case xhtml_mathml: return "org.openoffice.da.writer2xhtml.mathml"; //$NON-NLS-1$
case html5: return "org.openoffice.da.writer2xhtml5"; //$NON-NLS-1$
case epub: return "org.openoffice.da.writer2xhtml.epub"; //$NON-NLS-1$
case epub3: return "org.openoffice.da.writer2xhtml.epub3"; //$NON-NLS-1$
case latex: return "org.openoffice.da.writer2latex"; //$NON-NLS-1$
default: return ""; //$NON-NLS-1$
}
}

View file

@ -0,0 +1,5 @@
UNOPublisher.failexport=Error: Failed to export document
UNOPublisher.savedocument=Please save the document first
UNOPublisher.saveodt=Please save the document in OpenDocument format (.odt)
UNOPublisher.savefilesystem=Please save the document in the local file system
UNOPublisher.savedrivename=Please save the document on a location with a drive name

View file

@ -0,0 +1,5 @@
UNOPublisher.failexport=Fejl: Kunne ikke eksportere dokumentet
UNOPublisher.savedocument=Gem dokumentet først
UNOPublisher.saveodt=Gem dokumentet i OpenDocument-format (.odt)
UNOPublisher.savefilesystem=Gem dokumentet i det lokale filsystem
UNOPublisher.savedrivename=Gem dokumentet et sted med et drevbogstav

View file

@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
* Version 1.6 (2015-05-19)
* Version 1.6 (2015-05-29)
*
*/
@ -62,11 +62,11 @@ public final class ApplicationsDialog
/** The component will be registered under this name.
*/
public static String __serviceName = "org.openoffice.da.writer2latex.ApplicationsDialog";
public static String __serviceName = "org.openoffice.da.writer2latex.ApplicationsDialog"; //$NON-NLS-1$
/** The component should also have an implementation name.
*/
public static String __implementationName = "org.openoffice.da.comp.writer2latex.ApplicationsDialog";
public static String __implementationName = "org.openoffice.da.comp.writer2latex.ApplicationsDialog"; //$NON-NLS-1$
/** Create a new ApplicationsDialog */
public ApplicationsDialog(XComponentContext xContext) {
@ -83,28 +83,28 @@ public final class ApplicationsDialog
DialogAccess dlg = new DialogAccess(xDialog);
try {
if (sMethod.equals("external_event") ){
if (sMethod.equals("external_event") ){ //$NON-NLS-1$
return handleExternalEvent(dlg, event);
}
else if (sMethod.equals("AfterExportChange")) {
else if (sMethod.equals("AfterExportChange")) { //$NON-NLS-1$
return changeProcessingLevel(dlg);
}
else if (sMethod.equals("ApplicationChange")) {
else if (sMethod.equals("ApplicationChange")) { //$NON-NLS-1$
return changeApplication(dlg);
}
else if (sMethod.equals("UseDefaultChange")) {
else if (sMethod.equals("UseDefaultChange")) { //$NON-NLS-1$
return useDefaultChange(dlg) && updateApplication(dlg);
}
else if (sMethod.equals("BrowseClick")) {
else if (sMethod.equals("BrowseClick")) { //$NON-NLS-1$
return browseForExecutable(dlg);
}
else if (sMethod.equals("ExecutableUnfocus")) {
else if (sMethod.equals("ExecutableUnfocus")) { //$NON-NLS-1$
return updateApplication(dlg);
}
else if (sMethod.equals("OptionsUnfocus")) {
else if (sMethod.equals("OptionsUnfocus")) { //$NON-NLS-1$
return updateApplication(dlg);
}
else if (sMethod.equals("AutomaticClick")) {
else if (sMethod.equals("AutomaticClick")) { //$NON-NLS-1$
return autoConfigure(dlg);
}
}
@ -118,7 +118,7 @@ public final class ApplicationsDialog
}
@Override public String[] getSupportedMethodNames() {
String[] sNames = { "external_event", "AfterExportChange", "ApplicationChange", "BrowseClick", "ExecutableUnfocus", "OptionsUnfocus", "AutomaticClick" };
String[] sNames = { "external_event", "AfterExportChange", "ApplicationChange", "BrowseClick", "ExecutableUnfocus", "OptionsUnfocus", "AutomaticClick" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
return sNames;
}
@ -143,10 +143,10 @@ public final class ApplicationsDialog
throws com.sun.star.uno.Exception {
try {
String sMethod = AnyConverter.toString(aEventObject);
if (sMethod.equals("ok")) {
if (sMethod.equals("ok")) { //$NON-NLS-1$
externalApps.save();
return true;
} else if (sMethod.equals("back") || sMethod.equals("initialize")) {
} else if (sMethod.equals("back") || sMethod.equals("initialize")) { //$NON-NLS-1$ //$NON-NLS-2$
externalApps.load();
updateProcessingLevel(dlg);
return changeApplication(dlg);
@ -154,18 +154,18 @@ public final class ApplicationsDialog
}
catch (com.sun.star.lang.IllegalArgumentException e) {
throw new com.sun.star.lang.IllegalArgumentException(
"Method external_event requires a string in the event object argument.", this,(short) -1);
"Method external_event requires a string in the event object argument.", this,(short) -1); //$NON-NLS-1$
}
return false;
}
private boolean changeProcessingLevel(DialogAccess dlg) {
externalApps.setProcessingLevel(dlg.getListBoxSelectedItem("AfterExport"));
externalApps.setProcessingLevel(dlg.getListBoxSelectedItem("AfterExport")); //$NON-NLS-1$
return true;
}
private boolean updateProcessingLevel(DialogAccess dlg) {
dlg.setListBoxSelectedItem("AfterExport", externalApps.getProcessingLevel());
dlg.setListBoxSelectedItem("AfterExport", externalApps.getProcessingLevel()); //$NON-NLS-1$
return true;
}
@ -173,22 +173,22 @@ public final class ApplicationsDialog
String sAppName = getSelectedAppName(dlg);
if (sAppName!=null) {
String[] s = externalApps.getApplication(sAppName);
dlg.setComboBoxText("Executable", s[0]);
dlg.setComboBoxText("Options", s[1]);
dlg.setCheckBoxStateAsBoolean("UseDefault", externalApps.getUseDefaultApplication(sAppName));
dlg.setControlEnabled("UseDefault", externalApps.isViewer(sAppName));
dlg.setComboBoxText("Executable", s[0]); //$NON-NLS-1$
dlg.setComboBoxText("Options", s[1]); //$NON-NLS-1$
dlg.setCheckBoxStateAsBoolean("UseDefault", externalApps.getUseDefaultApplication(sAppName)); //$NON-NLS-1$
dlg.setControlEnabled("UseDefault", externalApps.isViewer(sAppName)); //$NON-NLS-1$
useDefaultChange(dlg);
}
return true;
}
private boolean useDefaultChange(DialogAccess dlg) {
boolean bCustomApp = !dlg.getCheckBoxStateAsBoolean("UseDefault");
dlg.setControlEnabled("ExecutableLabel", bCustomApp);
dlg.setControlEnabled("Executable", bCustomApp);
dlg.setControlEnabled("OptionsLabel", bCustomApp);
dlg.setControlEnabled("Options", bCustomApp);
dlg.setControlEnabled("BrowseButton", bCustomApp);
boolean bCustomApp = !dlg.getCheckBoxStateAsBoolean("UseDefault"); //$NON-NLS-1$
dlg.setControlEnabled("ExecutableLabel", bCustomApp); //$NON-NLS-1$
dlg.setControlEnabled("Executable", bCustomApp); //$NON-NLS-1$
dlg.setControlEnabled("OptionsLabel", bCustomApp); //$NON-NLS-1$
dlg.setControlEnabled("Options", bCustomApp); //$NON-NLS-1$
dlg.setControlEnabled("BrowseButton", bCustomApp); //$NON-NLS-1$
return true;
}
@ -196,7 +196,7 @@ public final class ApplicationsDialog
String sPath = filePicker.getPath();
if (sPath!=null) {
try {
dlg.setComboBoxText("Executable", new File(new URI(sPath)).getCanonicalPath());
dlg.setComboBoxText("Executable", new File(new URI(sPath)).getCanonicalPath()); //$NON-NLS-1$
}
catch (IOException e) {
}
@ -210,20 +210,20 @@ public final class ApplicationsDialog
private boolean updateApplication(DialogAccess dlg) {
String sAppName = getSelectedAppName(dlg);
if (sAppName!=null) {
externalApps.setApplication(sAppName, dlg.getComboBoxText("Executable"), dlg.getComboBoxText("Options"));
externalApps.setUseDefaultApplication(sAppName, dlg.getCheckBoxStateAsBoolean("UseDefault"));
externalApps.setApplication(sAppName, dlg.getComboBoxText("Executable"), dlg.getComboBoxText("Options")); //$NON-NLS-1$ //$NON-NLS-2$
externalApps.setUseDefaultApplication(sAppName, dlg.getCheckBoxStateAsBoolean("UseDefault")); //$NON-NLS-1$
}
return true;
}
private boolean autoConfigure(DialogAccess dlg) {
String sOsName = System.getProperty("os.name");
String sOsVersion = System.getProperty("os.version");
String sOsArch = System.getProperty("os.arch");
String sOsName = System.getProperty("os.name"); //$NON-NLS-1$
String sOsVersion = System.getProperty("os.version"); //$NON-NLS-1$
String sOsArch = System.getProperty("os.arch"); //$NON-NLS-1$
StringBuilder info = new StringBuilder();
info.append("Results of configuration:\n\n");
info.append("Your system identifies itself as "+sOsName+" version "+sOsVersion+ " (" + sOsArch +")\n\n");
if (sOsName.startsWith("Windows")) {
info.append(Messages.getString("ApplicationsDialog.configresults")+":\n\n"); //$NON-NLS-1$ //$NON-NLS-2$
info.append(Messages.getString("ApplicationsDialog.systemident")+" "+sOsName+" "+Messages.getString("ApplicationsDialog.version")+" "+sOsVersion+ " (" + sOsArch +")\n\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
if (sOsName.startsWith("Windows")) { //$NON-NLS-1$
autoConfigureWindows(dlg, info);
}
else {
@ -235,10 +235,10 @@ public final class ApplicationsDialog
}
private void displayAutoConfigInfo(String sText) {
XDialog xDialog = getDialog("W2LDialogs2.AutoConfigInfo");
XDialog xDialog = getDialog("W2LDialogs2.AutoConfigInfo"); //$NON-NLS-1$
if (xDialog!=null) {
DialogAccess info = new DialogAccess(xDialog);
info.setTextFieldText("Info", sText);
info.setTextFieldText("Info", sText); //$NON-NLS-1$
xDialog.execute();
xDialog.endExecute();
}
@ -248,10 +248,10 @@ public final class ApplicationsDialog
XMultiComponentFactory xMCF = xContext.getServiceManager();
try {
Object provider = xMCF.createInstanceWithContext(
"com.sun.star.awt.DialogProvider2", xContext);
"com.sun.star.awt.DialogProvider2", xContext); //$NON-NLS-1$
XDialogProvider2 xDialogProvider = (XDialogProvider2)
UnoRuntime.queryInterface(XDialogProvider2.class, provider);
String sDialogUrl = "vnd.sun.star.script:"+sDialogName+"?location=application";
String sDialogUrl = "vnd.sun.star.script:"+sDialogName+"?location=application"; //$NON-NLS-1$ //$NON-NLS-2$
return xDialogProvider.createDialogWithHandler(sDialogUrl, this);
}
catch (Exception e) {
@ -260,7 +260,7 @@ public final class ApplicationsDialog
}
private String getSelectedAppName(DialogAccess dlg) {
short nItem = dlg.getListBoxSelectedItem("Application");
short nItem = dlg.getListBoxSelectedItem("Application"); //$NON-NLS-1$
//String sAppName = null;
switch (nItem) {
case 0: return ExternalApps.LATEX;
@ -274,7 +274,7 @@ public final class ApplicationsDialog
case 7: return ExternalApps.PDFVIEWER;
case 8: return ExternalApps.POSTSCRIPTVIEWER;
}
return "???";
return "???"; //$NON-NLS-1$
}
// **** Automatic configuration of applications for Windows systems (assuming MikTeX)
@ -285,63 +285,63 @@ public final class ApplicationsDialog
// Configure TeX and friends + yap (DVi viewer) + TeXworks (PDF viewer)
boolean bFoundTexworks = false;
if (sMikTeXPath!=null) {
info.append("Found MikTeX\n");
configureMikTeX(sMikTeXPath, ExternalApps.LATEX, "latex", "--interaction=batchmode %s", info, true);
configureMikTeX(sMikTeXPath, ExternalApps.PDFLATEX, "pdflatex", "--interaction=batchmode %s", info, true);
configureMikTeX(sMikTeXPath, ExternalApps.XELATEX, "xelatex", "--interaction=batchmode %s", info, true);
configureMikTeX(sMikTeXPath, ExternalApps.DVIPS, "dvips", "%s", info, true);
configureMikTeX(sMikTeXPath, ExternalApps.BIBTEX, "bibtex", "%s", info, true);
configureMikTeX(sMikTeXPath, ExternalApps.MAKEINDEX, "makeindex", "%s", info, true);
info.append(Messages.getString("ApplicationsDialog.foundmiktex")+"\n"); //$NON-NLS-1$ //$NON-NLS-2$
configureMikTeX(sMikTeXPath, ExternalApps.LATEX, "latex", "--interaction=batchmode %s", info, true); //$NON-NLS-1$ //$NON-NLS-2$
configureMikTeX(sMikTeXPath, ExternalApps.PDFLATEX, "pdflatex", "--interaction=batchmode %s", info, true); //$NON-NLS-1$ //$NON-NLS-2$
configureMikTeX(sMikTeXPath, ExternalApps.XELATEX, "xelatex", "--interaction=batchmode %s", info, true); //$NON-NLS-1$ //$NON-NLS-2$
configureMikTeX(sMikTeXPath, ExternalApps.DVIPS, "dvips", "%s", info, true); //$NON-NLS-1$ //$NON-NLS-2$
configureMikTeX(sMikTeXPath, ExternalApps.BIBTEX, "bibtex", "%s", info, true); //$NON-NLS-1$ //$NON-NLS-2$
configureMikTeX(sMikTeXPath, ExternalApps.MAKEINDEX, "makeindex", "%s", info, true); //$NON-NLS-1$ //$NON-NLS-2$
//configureMikTeX(sMikTeXPath, ExternalApps.MK4HT, "mk4ht", "%c %s", info, true);
configureMikTeX(sMikTeXPath, ExternalApps.DVIVIEWER, "yap", "--single-instance %s", info, true);
configureMikTeX(sMikTeXPath, ExternalApps.DVIVIEWER, "yap", "--single-instance %s", info, true); //$NON-NLS-1$ //$NON-NLS-2$
externalApps.setUseDefaultApplication(ExternalApps.DVIVIEWER, false);
// MikTeX 2.8 provides texworks for pdf viewing
bFoundTexworks = configureMikTeX(sMikTeXPath, ExternalApps.PDFVIEWER, "texworks", "%s", info, true);
bFoundTexworks = configureMikTeX(sMikTeXPath, ExternalApps.PDFVIEWER, "texworks", "%s", info, true); //$NON-NLS-1$ //$NON-NLS-2$
}
else {
info.append("Failed to find MikTeX\n");
info.append("Writer2LaTeX has been configured to work if MikTeX is added to your path\n");
externalApps.setApplication(ExternalApps.LATEX, "latex", "--interaction=batchmode %s");
externalApps.setApplication(ExternalApps.PDFLATEX, "pdflatex", "--interaction=batchmode %s");
externalApps.setApplication(ExternalApps.XELATEX, "xelatex", "--interaction=batchmode %s");
externalApps.setApplication(ExternalApps.DVIPS, "dvips", "%s");
externalApps.setApplication(ExternalApps.BIBTEX, "bibtex", "%s");
externalApps.setApplication(ExternalApps.MAKEINDEX, "makeindex", "%s");
info.append(Messages.getString("ApplicationsDialog.failedtofindmiktex")+"\n"); //$NON-NLS-1$ //$NON-NLS-2$
info.append(Messages.getString("ApplicationsDialog.miktexdefaultconfig")+"\n"); //$NON-NLS-1$ //$NON-NLS-2$
externalApps.setApplication(ExternalApps.LATEX, "latex", "--interaction=batchmode %s"); //$NON-NLS-1$ //$NON-NLS-2$
externalApps.setApplication(ExternalApps.PDFLATEX, "pdflatex", "--interaction=batchmode %s"); //$NON-NLS-1$ //$NON-NLS-2$
externalApps.setApplication(ExternalApps.XELATEX, "xelatex", "--interaction=batchmode %s"); //$NON-NLS-1$ //$NON-NLS-2$
externalApps.setApplication(ExternalApps.DVIPS, "dvips", "%s"); //$NON-NLS-1$ //$NON-NLS-2$
externalApps.setApplication(ExternalApps.BIBTEX, "bibtex", "%s"); //$NON-NLS-1$ //$NON-NLS-2$
externalApps.setApplication(ExternalApps.MAKEINDEX, "makeindex", "%s"); //$NON-NLS-1$ //$NON-NLS-2$
//externalApps.setApplication(ExternalApps.MK4HT, "mk4ht", "%c %s");
externalApps.setUseDefaultApplication(ExternalApps.DVIVIEWER, true);
}
externalApps.setUseDefaultApplication(ExternalApps.PDFVIEWER, !bFoundTexworks);
info.append("\n");
info.append("\n"); //$NON-NLS-1$
// Configure gsview (PostScript viewer and fall back viewer for PDF)
String sGsview = getGsviewPath();
if (sGsview!=null) {
info.append("Found gsview - OK\n");
externalApps.setApplication(ExternalApps.POSTSCRIPTVIEWER, sGsview, "-e \"%s\"");
info.append(Messages.getString("ApplicationsDialog.foundgsview")+" - "+Messages.getString("ApplicationsDialog.ok")+"\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
externalApps.setApplication(ExternalApps.POSTSCRIPTVIEWER, sGsview, "-e \"%s\""); //$NON-NLS-1$
if (!bFoundTexworks) {
externalApps.setApplication(ExternalApps.PDFVIEWER, sGsview, "-e \"%s\"");
externalApps.setApplication(ExternalApps.PDFVIEWER, sGsview, "-e \"%s\""); //$NON-NLS-1$
externalApps.setUseDefaultApplication(ExternalApps.PDFVIEWER, false);
}
}
else {
if (!bFoundTexworks) {
info.append("Using default application for PDF\n");
info.append(Messages.getString("ApplicationsDialog.pdfdefaultviewer")+"\n"); //$NON-NLS-1$ //$NON-NLS-2$
}
info.append("Using default application for PostScript\n");
info.append(Messages.getString("ApplicationsDialog.psdefaultviewer")+"\n"); //$NON-NLS-1$ //$NON-NLS-2$
}
externalApps.setUseDefaultApplication(ExternalApps.POSTSCRIPTVIEWER, sGsview!=null);
}
// Windows: Get the path to the MikTeX bin directory
private String getMikTeXPath() {
String[] sPaths = System.getenv("PATH").split(";");
String[] sPaths = System.getenv("PATH").split(";"); //$NON-NLS-1$ //$NON-NLS-2$
for (String s : sPaths) {
if (s.toLowerCase().indexOf("miktex")>-1 && containsExecutable(s,"latex.exe")) {
if (s.toLowerCase().indexOf("miktex")>-1 && containsExecutable(s,"latex.exe")) { //$NON-NLS-1$ //$NON-NLS-2$
return s;
}
}
for (String s : sPaths) {
if (containsExecutable(s,"latex.exe")) {
if (containsExecutable(s,"latex.exe")) { //$NON-NLS-1$
return s;
}
}
@ -350,10 +350,10 @@ public final class ApplicationsDialog
// Windows: Get the path to the gsview executable
private String getGsviewPath() {
String sProgramFiles = System.getenv("ProgramFiles");
String sProgramFiles = System.getenv("ProgramFiles"); //$NON-NLS-1$
if (sProgramFiles!=null) {
if (containsExecutable(sProgramFiles+"\\ghostgum\\gsview","gsview32.exe")) {
return sProgramFiles+"\\ghostgum\\gsview\\gsview32.exe";
if (containsExecutable(sProgramFiles+"\\ghostgum\\gsview","gsview32.exe")) { //$NON-NLS-1$ //$NON-NLS-2$
return sProgramFiles+"\\ghostgum\\gsview\\gsview32.exe"; //$NON-NLS-1$
}
}
return null;
@ -371,15 +371,15 @@ public final class ApplicationsDialog
// Windows: Configure a certain MikTeX application
private boolean configureMikTeX(String sPath, String sName, String sAppName, String sArguments, StringBuilder info, boolean bRequired) {
File app = new File(new File(sPath),sAppName+".exe");
File app = new File(new File(sPath),sAppName+".exe"); //$NON-NLS-1$
if (app.exists()) {
externalApps.setApplication(sName, sAppName, sArguments);
info.append(" Found "+sName+": "+sAppName+" - OK\n");
info.append(" "+Messages.getString("ApplicationsDialog.found")+" "+sName+": "+sAppName+" - "+Messages.getString("ApplicationsDialog.ok")+"\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
return true;
}
else if (bRequired) {
externalApps.setApplication(sName, "???", "???");
info.append(" Failed to find "+sName+"\n");
externalApps.setApplication(sName, "???", "???"); //$NON-NLS-1$ //$NON-NLS-2$
info.append(" "+Messages.getString("ApplicationsDialog.failedtofind")+" "+sName+"\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
return false;
}
@ -388,20 +388,20 @@ public final class ApplicationsDialog
private void autoConfigureUnix(DialogAccess dlg, StringBuilder info) {
// Assume that the "which" command is supported
configureApp(ExternalApps.LATEX, "latex", "--interaction=batchmode %s",info);
configureApp(ExternalApps.PDFLATEX, "pdflatex", "--interaction=batchmode %s",info);
configureApp(ExternalApps.XELATEX, "xelatex", "--interaction=batchmode %s",info);
configureApp(ExternalApps.DVIPS, "dvips", "%s",info);
configureApp(ExternalApps.BIBTEX, "bibtex", "%s",info);
configureApp(ExternalApps.MAKEINDEX, "makeindex", "%s",info);
configureApp(ExternalApps.LATEX, "latex", "--interaction=batchmode %s",info); //$NON-NLS-1$ //$NON-NLS-2$
configureApp(ExternalApps.PDFLATEX, "pdflatex", "--interaction=batchmode %s",info); //$NON-NLS-1$ //$NON-NLS-2$
configureApp(ExternalApps.XELATEX, "xelatex", "--interaction=batchmode %s",info); //$NON-NLS-1$ //$NON-NLS-2$
configureApp(ExternalApps.DVIPS, "dvips", "%s",info); //$NON-NLS-1$ //$NON-NLS-2$
configureApp(ExternalApps.BIBTEX, "bibtex", "%s",info); //$NON-NLS-1$ //$NON-NLS-2$
configureApp(ExternalApps.MAKEINDEX, "makeindex", "%s",info); //$NON-NLS-1$ //$NON-NLS-2$
//configureApp(ExternalApps.MK4HT, "mk4ht", "%c %s",info);
// We have several possible viewers
String[] sDviViewers = {"evince", "okular", "xdvi"};
configureViewer(ExternalApps.DVIVIEWER, sDviViewers, "%s",info);
String[] sPdfViewers = {"evince", "okular", "xpdf"};
configureViewer(ExternalApps.PDFVIEWER, sPdfViewers, "%s",info);
String[] sPsViewers = {"evince", "okular", "ghostview"};
configureViewer(ExternalApps.POSTSCRIPTVIEWER, sPsViewers, "%s",info);
String[] sDviViewers = {"evince", "okular", "xdvi"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
configureViewer(ExternalApps.DVIVIEWER, sDviViewers, "%s",info); //$NON-NLS-1$
String[] sPdfViewers = {"evince", "okular", "xpdf"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
configureViewer(ExternalApps.PDFVIEWER, sPdfViewers, "%s",info); //$NON-NLS-1$
String[] sPsViewers = {"evince", "okular", "ghostview"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
configureViewer(ExternalApps.POSTSCRIPTVIEWER, sPsViewers, "%s",info); //$NON-NLS-1$
// Maybe add some info for Debian/Ubuntu users, e.g.
// sudo apt-get install texlive
@ -415,7 +415,7 @@ public final class ApplicationsDialog
private boolean hasApp(String sAppName) {
try {
Vector<String> command = new Vector<String>();
command.add("which");
command.add("which"); //$NON-NLS-1$
command.add(sAppName);
ProcessBuilder pb = new ProcessBuilder(command);
@ -423,11 +423,11 @@ public final class ApplicationsDialog
// Gobble the error stream of the application
StreamGobbler errorGobbler = new
StreamGobbler(proc.getErrorStream(), "ERROR");
StreamGobbler(proc.getErrorStream(), "ERROR"); //$NON-NLS-1$
// Gobble the output stream of the application
StreamGobbler outputGobbler = new
StreamGobbler(proc.getInputStream(), "OUTPUT");
StreamGobbler(proc.getInputStream(), "OUTPUT"); //$NON-NLS-1$
errorGobbler.start();
outputGobbler.start();
@ -449,15 +449,15 @@ public final class ApplicationsDialog
externalApps.setApplication(sName, sAppName, sArguments);
externalApps.setUseDefaultApplication(sName, false);
if (info!=null) {
info.append("Found "+sAppName+" - OK\n");
info.append(Messages.getString("ApplicationsDialog.found")+" "+sAppName+" - "+Messages.getString("ApplicationsDialog.ok")+"\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
}
return true;
}
else {
externalApps.setApplication(sName, "???", "???");
externalApps.setApplication(sName, "???", "???"); //$NON-NLS-1$ //$NON-NLS-2$
externalApps.setUseDefaultApplication(sName, false);
if (info!=null) {
info.append("Failed to find "+sAppName+"\n");
info.append(Messages.getString("ApplicationsDialog.failedtofind")+" "+sAppName+"\n"); //$NON-NLS-1$ //$NON-NLS-2$
}
return false;
}
@ -468,12 +468,12 @@ public final class ApplicationsDialog
private boolean configureViewer(String sName, String[] sAppNames, String sArguments, StringBuilder info) {
for (String sAppName : sAppNames) {
if (configureApp(sName, sAppName, sArguments, null)) {
info.append("Found "+sName+": "+sAppName+" - OK\n");
info.append(Messages.getString("ApplicationsDialog.found")+" "+ExternalApps.getUIAppName(sName)+": "+sAppName+" - "+Messages.getString("ApplicationsDialog.ok")+"\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
return true;
}
}
externalApps.setUseDefaultApplication(sName, true);
info.append("Using default application as "+sName+"\n");
info.append(Messages.getString("ApplicationsDialog.usingdefaultapp")+" "+ExternalApps.getUIAppName(sName)+"\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
return true;
}

View file

@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
* Version 1.6 (2015-04-01)
* Version 1.6 (2015-05-29)
*
*/
@ -81,11 +81,11 @@ public class BibTeXDialog extends DialogBase implements com.sun.star.lang.XIniti
/** The component will be registered under this service name
*/
public static String __serviceName = "org.openoffice.da.writer2latex.BibTeXDialog";
public static String __serviceName = "org.openoffice.da.writer2latex.BibTeXDialog"; //$NON-NLS-1$
/** The implementation name of the component
*/
public static String __implementationName = "org.openoffice.da.comp.writer2latex.BibTeXDialog";
public static String __implementationName = "org.openoffice.da.comp.writer2latex.BibTeXDialog"; //$NON-NLS-1$
// **** Member variables
@ -126,13 +126,13 @@ public class BibTeXDialog extends DialogBase implements com.sun.star.lang.XIniti
/** Return the name of the library containing the dialog
*/
@Override public String getDialogLibraryName() {
return "W2LDialogs2";
return "W2LDialogs2"; //$NON-NLS-1$
}
/** Return the name of the dialog within the library
*/
@Override public String getDialogName() {
return "BibTeXEntry";
return "BibTeXEntry"; //$NON-NLS-1$
}
@Override public void initialize() {
@ -145,31 +145,31 @@ public class BibTeXDialog extends DialogBase implements com.sun.star.lang.XIniti
// **** Implement XDialogEventHandler
@Override public boolean callHandlerMethod(XDialog xDialog, Object event, String sMethod) {
if (sMethod.equals("FileChange")) {
if (sMethod.equals("FileChange")) { //$NON-NLS-1$
// The user has selected another BibTeX file
fileChange();
}
else if (sMethod.equals("EntryChange")) {
else if (sMethod.equals("EntryChange")) { //$NON-NLS-1$
// The user has selected another BibTeX entry
entryChange();
}
else if (sMethod.equals("New")) {
else if (sMethod.equals("New")) { //$NON-NLS-1$
// Create a new BibTeX file
newFile();
}
else if (sMethod.equals("Edit")) {
else if (sMethod.equals("Edit")) { //$NON-NLS-1$
// Edit the current BibTeX file
edit();
}
else if (sMethod.equals("Reload")) {
else if (sMethod.equals("Reload")) { //$NON-NLS-1$
// Reload the BibTeX files in the dialog
reload(null);
}
else if (sMethod.equals("InsertReference")) {
else if (sMethod.equals("InsertReference")) { //$NON-NLS-1$
// Insert a reference to the current BibTeX entry
insertReference();
}
else if (sMethod.equals("Update")) {
else if (sMethod.equals("Update")) { //$NON-NLS-1$
// Update all reference in the document
update();
}
@ -177,7 +177,7 @@ public class BibTeXDialog extends DialogBase implements com.sun.star.lang.XIniti
}
@Override public String[] getSupportedMethodNames() {
String[] sNames = { "FileChange", "EntryChange", "New", "Edit", "Reload", "InsertReference", "Update" };
String[] sNames = { "FileChange", "EntryChange", "New", "Edit", "Reload", "InsertReference", "Update" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
return sNames;
}
@ -192,9 +192,9 @@ public class BibTeXDialog extends DialogBase implements com.sun.star.lang.XIniti
}
else {
// Remember the previous selection, if any
short nSelectedFile = getListBoxSelectedItem("File");
short nSelectedFile = getListBoxSelectedItem("File"); //$NON-NLS-1$
if (nSelectedFile>=0 && files[nSelectedFile]!=null) {
sFile = getListBoxStringItemList("File")[nSelectedFile];
sFile = getListBoxStringItemList("File")[nSelectedFile]; //$NON-NLS-1$
}
}
@ -202,7 +202,7 @@ public class BibTeXDialog extends DialogBase implements com.sun.star.lang.XIniti
// Populate the file list based on the BibTeX directory
files = bibTeXDirectory.listFiles(
new FilenameFilter() {
public boolean accept(File file, String sName) { return sName!=null && sName.endsWith(".bib"); }
public boolean accept(File file, String sName) { return sName!=null && sName.endsWith(".bib"); } //$NON-NLS-1$
}
);
int nFileCount = files.length;
@ -215,17 +215,17 @@ public class BibTeXDialog extends DialogBase implements com.sun.star.lang.XIniti
if (sFileNames[i].equals(sFile)) { nFile = i; }
}
setListBoxStringItemList("File", sFileNames);
setListBoxSelectedItem("File",(short)nFile);
setListBoxStringItemList("File", sFileNames); //$NON-NLS-1$
setListBoxSelectedItem("File",(short)nFile); //$NON-NLS-1$
if (nFileCount>0) {
setControlEnabled("FileLabel",true);
setControlEnabled("File",true);
setControlEnabled("EntryLabel",true);
setControlEnabled("Entry",true);
setControlEnabled("Edit",true);
setControlEnabled("Insert",true);
setControlEnabled("Update",true);
setControlEnabled("FileLabel",true); //$NON-NLS-1$
setControlEnabled("File",true); //$NON-NLS-1$
setControlEnabled("EntryLabel",true); //$NON-NLS-1$
setControlEnabled("Entry",true); //$NON-NLS-1$
setControlEnabled("Edit",true); //$NON-NLS-1$
setControlEnabled("Insert",true); //$NON-NLS-1$
setControlEnabled("Update",true); //$NON-NLS-1$
fileChange();
@ -234,27 +234,27 @@ public class BibTeXDialog extends DialogBase implements com.sun.star.lang.XIniti
}
// The directory did not contain any BibTeX files
setControlEnabled("FileLabel",false);
setControlEnabled("File",false);
setControlEnabled("EntryLabel",false);
setControlEnabled("Entry",false);
setControlEnabled("Edit",false);
setControlEnabled("Insert",false);
setControlEnabled("Update",false);
setLabelText("EntryInformation","No BibTeX files were found");
setControlEnabled("FileLabel",false); //$NON-NLS-1$
setControlEnabled("File",false); //$NON-NLS-1$
setControlEnabled("EntryLabel",false); //$NON-NLS-1$
setControlEnabled("Entry",false); //$NON-NLS-1$
setControlEnabled("Edit",false); //$NON-NLS-1$
setControlEnabled("Insert",false); //$NON-NLS-1$
setControlEnabled("Update",false); //$NON-NLS-1$
setLabelText("EntryInformation",Messages.getString("BibTeXDialog.nobibtexfiles")); //$NON-NLS-1$ //$NON-NLS-2$
}
// Update the list of entries based on the current selection in the file list
private void fileChange() {
// Remember current entry selection, if any
String sEntry = null;
short nEntry = getListBoxSelectedItem("Entry");
short nEntry = getListBoxSelectedItem("Entry"); //$NON-NLS-1$
if (nEntry>=0) {
sEntry = getListBoxStringItemList("Entry")[nEntry];
sEntry = getListBoxStringItemList("Entry")[nEntry]; //$NON-NLS-1$
}
// Parse the selected file
int nFile = getListBoxSelectedItem("File");
int nFile = getListBoxSelectedItem("File"); //$NON-NLS-1$
if (nFile>=0) {
try {
currentFile = new BibTeXReader(files[nFile]);
@ -268,7 +268,7 @@ public class BibTeXDialog extends DialogBase implements com.sun.star.lang.XIniti
if (currentFile!=null) {
// Populate the entry list with the keys from the current file, if any
String[] sCurrentKeys = currentFile.getEntries().keySet().toArray(new String[0]);
setListBoxStringItemList("Entry", sCurrentKeys);
setListBoxStringItemList("Entry", sCurrentKeys); //$NON-NLS-1$
if (sCurrentKeys.length>0) {
// Select either the first or the previous entry
nEntry = 0;
@ -280,27 +280,27 @@ public class BibTeXDialog extends DialogBase implements com.sun.star.lang.XIniti
}
}
}
setListBoxSelectedItem("Entry",nEntry);
setControlEnabled("EntryLabel",true);
setControlEnabled("Entry",true);
setControlEnabled("Insert",true);
setListBoxSelectedItem("Entry",nEntry); //$NON-NLS-1$
setControlEnabled("EntryLabel",true); //$NON-NLS-1$
setControlEnabled("Entry",true); //$NON-NLS-1$
setControlEnabled("Insert",true); //$NON-NLS-1$
entryChange();
}
else { // No entries, disable controls
setControlEnabled("EntryLabel",false);
setControlEnabled("Entry",false);
setControlEnabled("Insert",false);
setLabelText("EntryInformation","This file does not contain any entries");
setControlEnabled("EntryLabel",false); //$NON-NLS-1$
setControlEnabled("Entry",false); //$NON-NLS-1$
setControlEnabled("Insert",false); //$NON-NLS-1$
setLabelText("EntryInformation",Messages.getString("BibTeXDialog.noentries")); //$NON-NLS-1$ //$NON-NLS-2$
}
setControlEnabled("Edit",true);
setControlEnabled("Edit",true); //$NON-NLS-1$
}
else { // Failed to parse, disable controls
setListBoxStringItemList("Entry", new String[0]);
setControlEnabled("EntryLabel",false);
setControlEnabled("Entry",false);
setControlEnabled("Edit",false);
setControlEnabled("Insert",false);
setLabelText("EntryInformation","There was an error reading this file");
setListBoxStringItemList("Entry", new String[0]); //$NON-NLS-1$
setControlEnabled("EntryLabel",false); //$NON-NLS-1$
setControlEnabled("Entry",false); //$NON-NLS-1$
setControlEnabled("Edit",false); //$NON-NLS-1$
setControlEnabled("Insert",false); //$NON-NLS-1$
setLabelText("EntryInformation",Messages.getString("BibTeXDialog.errorreadingfile")); //$NON-NLS-1$ //$NON-NLS-2$
}
}
}
@ -310,17 +310,17 @@ public class BibTeXDialog extends DialogBase implements com.sun.star.lang.XIniti
BibMark bibMark = getCurrentEntry();
if (bibMark!=null) {
String sAuthor = bibMark.getField(EntryType.author);
if (sAuthor==null) { sAuthor = ""; }
if (sAuthor==null) { sAuthor = ""; } //$NON-NLS-1$
String sTitle = bibMark.getField(EntryType.title);
if (sTitle==null) { sTitle = ""; }
if (sTitle==null) { sTitle = ""; } //$NON-NLS-1$
String sPublisher = bibMark.getField(EntryType.publisher);
if (sPublisher==null) { sPublisher = ""; }
if (sPublisher==null) { sPublisher = ""; } //$NON-NLS-1$
String sYear = bibMark.getField(EntryType.year);
if (sYear==null) { sYear = ""; }
setLabelText("EntryInformation", sAuthor+"\n"+sTitle+"\n"+sPublisher+"\n"+sYear);
if (sYear==null) { sYear = ""; } //$NON-NLS-1$
setLabelText("EntryInformation", sAuthor+"\n"+sTitle+"\n"+sPublisher+"\n"+sYear); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
else {
setLabelText("EntryInformation", "No information");
setLabelText("EntryInformation", Messages.getString("BibTeXDialog.noinformation")); //$NON-NLS-1$ //$NON-NLS-2$
}
}
@ -333,12 +333,12 @@ public class BibTeXDialog extends DialogBase implements com.sun.star.lang.XIniti
private void newFile() {
String sFileName = getFileName();
if (sFileName!=null) {
if (!sFileName.equals(".bib")) {
if (!sFileName.equals(".bib")) { //$NON-NLS-1$
File file = new File(bibTeXDirectory,sFileName);
try {
if (!file.createNewFile() && xFrame!=null) {
MessageBox msgBox = new MessageBox(xContext, xFrame);
msgBox.showMessage("Writer2LaTeX","The file "+sFileName+" already exists");
msgBox.showMessage("Writer2LaTeX",Messages.getString("BibTeXDialog.thefile")+" "+sFileName+" "+Messages.getString("BibTeXDialog.alreadyexists")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
reload(sFileName);
} catch (IOException e) {
@ -346,7 +346,7 @@ public class BibTeXDialog extends DialogBase implements com.sun.star.lang.XIniti
}
else if (xFrame!=null) {
MessageBox msgBox = new MessageBox(xContext, xFrame);
msgBox.showMessage("Writer2LaTeX","The file name is empty");
msgBox.showMessage("Writer2LaTeX",Messages.getString("BibTeXDialog.filenameempty")); //$NON-NLS-1$ //$NON-NLS-2$
}
}
}
@ -356,17 +356,17 @@ public class BibTeXDialog extends DialogBase implements com.sun.star.lang.XIniti
XDialog xDialog=getNewDialog();
if (xDialog!=null) {
DialogAccess ndlg = new DialogAccess(xDialog);
ndlg.setListBoxStringItemList("Name", new String[0]);
ndlg.setListBoxStringItemList("Name", new String[0]); //$NON-NLS-1$
String sResult = null;
if (xDialog.execute()==ExecutableDialogResults.OK) {
DialogAccess dlg = new DialogAccess(xDialog);
sResult = dlg.getTextFieldText("Name");
sResult = dlg.getTextFieldText("Name"); //$NON-NLS-1$
}
xDialog.endExecute();
if (sResult!=null && !sResult.toLowerCase().endsWith(".bib")) {
sResult = sResult+".bib";
if (sResult!=null && !sResult.toLowerCase().endsWith(".bib")) { //$NON-NLS-1$
sResult = sResult+".bib"; //$NON-NLS-1$
}
return Misc.makeTeXFriendly(sResult,"bibliography");
return Misc.makeTeXFriendly(sResult,"bibliography"); //$NON-NLS-1$
}
return null;
}
@ -375,10 +375,10 @@ public class BibTeXDialog extends DialogBase implements com.sun.star.lang.XIniti
protected XDialog getNewDialog() {
XMultiComponentFactory xMCF = xContext.getServiceManager();
try {
Object provider = xMCF.createInstanceWithContext("com.sun.star.awt.DialogProvider2", xContext);
Object provider = xMCF.createInstanceWithContext("com.sun.star.awt.DialogProvider2", xContext); //$NON-NLS-1$
XDialogProvider2 xDialogProvider = (XDialogProvider2)
UnoRuntime.queryInterface(XDialogProvider2.class, provider);
String sDialogUrl = "vnd.sun.star.script:"+getDialogLibraryName()+".NewDialog?location=application";
String sDialogUrl = "vnd.sun.star.script:"+getDialogLibraryName()+".NewDialog?location=application"; //$NON-NLS-1$ //$NON-NLS-2$
return xDialogProvider.createDialog(sDialogUrl);
}
catch (Exception e) {
@ -388,7 +388,7 @@ public class BibTeXDialog extends DialogBase implements com.sun.star.lang.XIniti
// Edit the currently selected BibTeX file, if any
private void edit() {
int nFile = getListBoxSelectedItem("File");
int nFile = getListBoxSelectedItem("File"); //$NON-NLS-1$
if (nFile>=0) {
if (files[nFile].exists()) {
edit(files[nFile]);
@ -399,9 +399,9 @@ public class BibTeXDialog extends DialogBase implements com.sun.star.lang.XIniti
// Helper function: Get the currently selected entry, or null if none is selected
private BibMark getCurrentEntry() {
BibMark bibMark = null;
int nEntry = getListBoxSelectedItem("Entry");
int nEntry = getListBoxSelectedItem("Entry"); //$NON-NLS-1$
if (nEntry>=0) {
String[] sCurrentKeys = getListBoxStringItemList("Entry");
String[] sCurrentKeys = getListBoxStringItemList("Entry"); //$NON-NLS-1$
String sKey = sCurrentKeys[nEntry];
bibMark = currentFile.getEntries().get(sKey);
}
@ -419,13 +419,13 @@ public class BibTeXDialog extends DialogBase implements com.sun.star.lang.XIniti
} catch (IOException e) {
if (xFrame!=null) {
MessageBox msgBox = new MessageBox(xContext, xFrame);
msgBox.showMessage("Writer2LaTeX","Error: Failed to open file with BibTeX editor");
msgBox.showMessage("Writer2LaTeX",Messages.getString("BibTeXDialog.failedbibtexeditor")); //$NON-NLS-1$ //$NON-NLS-2$
}
}
}
else if (xFrame!=null) {
MessageBox msgBox = new MessageBox(xContext, xFrame);
msgBox.showMessage("Writer2LaTeX","Error: No BibTeX editor was found");
msgBox.showMessage("Writer2LaTeX",Messages.getString("BibTeXDialog.nobibtexeditor")); //$NON-NLS-1$ //$NON-NLS-2$
}
}
@ -449,7 +449,7 @@ public class BibTeXDialog extends DialogBase implements com.sun.star.lang.XIniti
XTextField xTextField = (XTextField) AnyConverter.toObject(XTextField.class, elm);
if (xTextField!=null) {
XServiceInfo xInfo = UnoRuntime.queryInterface(XServiceInfo.class, xTextField);
if (xInfo.supportsService("com.sun.star.text.TextField.Bibliography")) {
if (xInfo.supportsService("com.sun.star.text.TextField.Bibliography")) { //$NON-NLS-1$
String sId = updateBibField(xTextField, readers);
if (sId!=null) {
notUpdated.add(sId);
@ -474,7 +474,7 @@ public class BibTeXDialog extends DialogBase implements com.sun.star.lang.XIniti
if (AnyConverter.isObject(indexElm)) {
XDocumentIndex xDocumentIndex = (XDocumentIndex) AnyConverter.toObject(XDocumentIndex.class, indexElm);
if (xDocumentIndex!=null) {
if ("com.sun.star.text.Bibliography".equals(xDocumentIndex.getServiceName())) {
if ("com.sun.star.text.Bibliography".equals(xDocumentIndex.getServiceName())) { //$NON-NLS-1$
xDocumentIndex.update();
}
}
@ -488,10 +488,10 @@ public class BibTeXDialog extends DialogBase implements com.sun.star.lang.XIniti
if (xFrame!=null) {
MessageBox msgBox = new MessageBox(xContext, xFrame);
if (notUpdated.isEmpty()) {
msgBox.showMessage("Writer2LaTeX","All bibliography fields were updated");
msgBox.showMessage("Writer2LaTeX",Messages.getString("BibTeXDialog.allbibfieldsupdated")); //$NON-NLS-1$ //$NON-NLS-2$
}
else {
msgBox.showMessage("Writer2LaTeX","The following bibliography fields were not updated:\n"+notUpdated.toString());
msgBox.showMessage("Writer2LaTeX",Messages.getString("BibTeXDialog.bibfieldsnotupdated")+":\n"+notUpdated.toString()); //$NON-NLS-1$ //$NON-NLS-2$
}
}
}
@ -517,18 +517,18 @@ public class BibTeXDialog extends DialogBase implements com.sun.star.lang.XIniti
XPropertySet xPropSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextField);
if (xPropSet!=null) {
try {
Object fieldsObj = xPropSet.getPropertyValue("Fields");
Object fieldsObj = xPropSet.getPropertyValue("Fields");
if (fieldsObj!=null && fieldsObj instanceof PropertyValue[]) {
PropertyValue[] props = (PropertyValue[]) fieldsObj;
for (PropertyValue prop : props) {
if ("Identifier".equals(prop.Name)) {
if ("Identifier".equals(prop.Name)) {
if (prop.Value instanceof String) {
String sIdentifier = (String)prop.Value;
for (BibTeXReader reader : readers) {
if (reader.getEntries().keySet().contains(sIdentifier)) {
BibMark bibMark = reader.getEntries().get(sIdentifier);
try {
xPropSet.setPropertyValue("Fields", createBibliographyFields(bibMark));
xPropSet.setPropertyValue("Fields", createBibliographyFields(bibMark));
return null;
} catch (IllegalArgumentException e) {
} catch (PropertyVetoException e) {
@ -569,17 +569,17 @@ public class BibTeXDialog extends DialogBase implements com.sun.star.lang.XIniti
// Use the service factory to create a bibliography field
XDependentTextField xBibField = UnoRuntime.queryInterface (
XDependentTextField.class, xDocFactory.createInstance("com.sun.star.text.textfield.Bibliography"));
XDependentTextField.class, xDocFactory.createInstance("com.sun.star.text.textfield.Bibliography"));
// Create a field master for the field
XPropertySet xMasterPropSet = UnoRuntime.queryInterface(
XPropertySet.class, xDocFactory.createInstance("com.sun.star.text.fieldmaster.Bibliography"));
XPropertySet.class, xDocFactory.createInstance("com.sun.star.text.fieldmaster.Bibliography"));
// Populate the bibliography field
XPropertySet xPropSet = UnoRuntime.queryInterface(
XPropertySet.class, xBibField);
PropertyValue[] fields = createBibliographyFields(bibMark);
xPropSet.setPropertyValue("Fields", fields);
xPropSet.setPropertyValue("Fields", fields);
// Attach the field master to the bibliography field
xBibField.attachTextFieldMaster(xMasterPropSet);
@ -597,10 +597,10 @@ public class BibTeXDialog extends DialogBase implements com.sun.star.lang.XIniti
PropertyValue[] fields = new PropertyValue[entryTypes.length+2];
fields[0] = new PropertyValue();
fields[0].Name="Identifier";
fields[0].Name="Identifier";
fields[0].Value=bibMark.getIdentifier();
fields[1] = new PropertyValue();
fields[1].Name="BibiliographicType"; // sic! (API typo)
fields[1].Name="BibiliographicType"; // sic! (API typo)
fields[1].Value=new Short(getBibliographicType(bibMark.getEntryType()));
int i=1;
@ -608,7 +608,7 @@ public class BibTeXDialog extends DialogBase implements com.sun.star.lang.XIniti
fields[++i] = new PropertyValue();
fields[i].Name = getFieldName(entryType);
String sValue = bibMark.getField(entryType);
fields[i].Value = sValue!=null ? bibMark.getField(entryType) : "";
fields[i].Value = sValue!=null ? bibMark.getField(entryType) : "";
}
return fields;
@ -617,35 +617,35 @@ public class BibTeXDialog extends DialogBase implements com.sun.star.lang.XIniti
// Translate entry type to field name
private String getFieldName(EntryType entryType) {
switch(entryType) {
case address: return "Address";
case annote: return "Annote";
case author: return "Author";
case booktitle: return "Booktitle";
case chapter : return "Chapter";
case edition: return "Edition";
case editor: return "Editor";
case howpublished: return "Howpublished";
case institution: return "Institution";
case journal: return "Journal";
case month: return "Month";
case note: return "Note";
case number: return "Number";
case organizations: return "Organizations";
case pages: return "Pages";
case publisher: return "Publisher";
case school: return "School";
case series: return "Series";
case title: return "Title";
case report_type: return "Report_Type";
case volume: return "Volume";
case year: return "Year";
case url: return "URL";
case custom1: return "Custom1";
case custom2: return "Custom2";
case custom3: return "Custom3";
case custom4: return "Custom4";
case custom5: return "Custom5";
case isbn: return "ISBN";
case address: return "Address";
case annote: return "Annote";
case author: return "Author";
case booktitle: return "Booktitle";
case chapter : return "Chapter";
case edition: return "Edition";
case editor: return "Editor";
case howpublished: return "Howpublished";
case institution: return "Institution";
case journal: return "Journal";
case month: return "Month";
case note: return "Note";
case number: return "Number";
case organizations: return "Organizations";
case pages: return "Pages";
case publisher: return "Publisher";
case school: return "School";
case series: return "Series";
case title: return "Title";
case report_type: return "Report_Type";
case volume: return "Volume";
case year: return "Year";
case url: return "URL";
case custom1: return "Custom1";
case custom2: return "Custom2";
case custom3: return "Custom3";
case custom4: return "Custom4";
case custom5: return "Custom5";
case isbn: return "ISBN";
default: return null;
}
}
@ -653,70 +653,70 @@ public class BibTeXDialog extends DialogBase implements com.sun.star.lang.XIniti
// Translate bibliographic type to internal code
private short getBibliographicType(String sBibType) {
String s = sBibType.toUpperCase();
if ("ARTICLE".equals(s)) {
if ("ARTICLE".equals(s)) {
return (short)0;
}
else if ("BOOK".equals(s)) {
else if ("BOOK".equals(s)) {
return (short)1;
}
else if ("BOOKLET".equals(s)) {
else if ("BOOKLET".equals(s)) {
return (short)2;
}
else if ("CONFERENCE".equals(s)) {
else if ("CONFERENCE".equals(s)) {
return (short)3;
}
else if ("INBOOK".equals(s)) {
else if ("INBOOK".equals(s)) {
return (short)4;
}
else if ("INCOLLECTION".equals(s)) {
else if ("INCOLLECTION".equals(s)) {
return (short)5;
}
else if ("INPROCEEDINGS".equals(s)) {
else if ("INPROCEEDINGS".equals(s)) {
return (short)6;
}
else if ("JOURNAL".equals(s)) {
else if ("JOURNAL".equals(s)) {
return (short)7;
}
else if ("MANUAL".equals(s)) {
else if ("MANUAL".equals(s)) {
return (short)8;
}
else if ("MASTERSTHESIS".equals(s)) {
else if ("MASTERSTHESIS".equals(s)) {
return (short)9;
}
else if ("MISC".equals(s)) {
else if ("MISC".equals(s)) {
return (short)10;
}
else if ("PHDTHESIS".equals(s)) {
else if ("PHDTHESIS".equals(s)) {
return (short)11;
}
else if ("PROCEEDINGS".equals(s)) {
else if ("PROCEEDINGS".equals(s)) {
return (short)12;
}
else if ("TECHREPORT".equals(s)) {
else if ("TECHREPORT".equals(s)) {
return (short)13;
}
else if ("UNPUBLISHED".equals(s)) {
else if ("UNPUBLISHED".equals(s)) {
return (short)14;
}
else if ("EMAIL".equals(s)) {
else if ("EMAIL".equals(s)) {
return (short)15;
}
else if ("WWW".equals(s)) {
else if ("WWW".equals(s)) {
return (short)16;
}
else if ("CUSTOM1".equals(s)) {
else if ("CUSTOM1".equals(s)) {
return (short)17;
}
else if ("CUSTOM2".equals(s)) {
else if ("CUSTOM2".equals(s)) {
return (short)18;
}
else if ("CUSTOM3".equals(s)) {
else if ("CUSTOM3".equals(s)) {
return (short)19;
}
else if ("CUSTOM4".equals(s)) {
else if ("CUSTOM4".equals(s)) {
return (short)20;
}
else if ("CUSTOM5".equals(s)) {
else if ("CUSTOM5".equals(s)) {
return (short)21;
}
else {

View file

@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
* Version 1.6 (2015-02-18)
* Version 1.6 (2015-05-29)
*
*/
@ -60,18 +60,18 @@ public final class BibliographyDialog
extends WeakBase
implements XServiceInfo, XContainerWindowEventHandler {
public static final String REGISTRY_PATH = "/org.openoffice.da.Writer2LaTeX.toolbar.ToolbarOptions/BibliographyOptions";
public static final String REGISTRY_PATH = "/org.openoffice.da.Writer2LaTeX.toolbar.ToolbarOptions/BibliographyOptions"; //$NON-NLS-1$
private XComponentContext xContext;
private FolderPicker folderPicker;
/** The component will be registered under this name.
*/
public static String __serviceName = "org.openoffice.da.writer2latex.BibliographyDialog";
public static String __serviceName = "org.openoffice.da.writer2latex.BibliographyDialog"; //$NON-NLS-1$
/** The component should also have an implementation name.
*/
public static String __implementationName = "org.openoffice.da.comp.writer2latex.BibliographyDialog";
public static String __implementationName = "org.openoffice.da.comp.writer2latex.BibliographyDialog"; //$NON-NLS-1$
/** Create a new ConfigurationDialog */
public BibliographyDialog(XComponentContext xContext) {
@ -87,25 +87,25 @@ public final class BibliographyDialog
DialogAccess dlg = new DialogAccess(xDialog);
try {
if (sMethod.equals("external_event") ){
if (sMethod.equals("external_event") ){ //$NON-NLS-1$
return handleExternalEvent(dlg, event);
}
else if (sMethod.equals("ConvertZoteroCitationsChange")) {
else if (sMethod.equals("ConvertZoteroCitationsChange")) { //$NON-NLS-1$
return convertZoteroCitationsChange(dlg);
}
else if (sMethod.equals("ConvertJabRefCitationsChange")) {
else if (sMethod.equals("ConvertJabRefCitationsChange")) { //$NON-NLS-1$
return convertJabRefCitationsChange(dlg);
}
else if (sMethod.equals("UseExternalBibTeXFilesChange")) {
else if (sMethod.equals("UseExternalBibTeXFilesChange")) { //$NON-NLS-1$
return useExternalBibTeXFilesChange(dlg);
}
else if (sMethod.equals("UseNatbibChange")) {
else if (sMethod.equals("UseNatbibChange")) { //$NON-NLS-1$
return useNatbibChange(dlg);
}
else if (sMethod.equals("BibTeXLocationChange")) {
else if (sMethod.equals("BibTeXLocationChange")) { //$NON-NLS-1$
return bibTeXLocationChange(dlg);
}
else if (sMethod.equals("BibTeXDirClick")) {
else if (sMethod.equals("BibTeXDirClick")) { //$NON-NLS-1$
return bibTeXDirClick(dlg);
}
}
@ -119,8 +119,8 @@ public final class BibliographyDialog
}
public String[] getSupportedMethodNames() {
String[] sNames = { "external_event", "UseExternalBibTeXFilesChange", "ConvertZoteroCitationsChange",
"ConvertJabRefCitationsChange", "UseNatbibChange", "BibTeXLocationChange", "ExternalBibTeXDirClick" };
String[] sNames = { "external_event", "UseExternalBibTeXFilesChange", "ConvertZoteroCitationsChange", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"ConvertJabRefCitationsChange", "UseNatbibChange", "BibTeXLocationChange", "ExternalBibTeXDirClick" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
return sNames;
}
@ -144,10 +144,10 @@ public final class BibliographyDialog
throws com.sun.star.uno.Exception {
try {
String sMethod = AnyConverter.toString(aEventObject);
if (sMethod.equals("ok")) {
if (sMethod.equals("ok")) { //$NON-NLS-1$
saveConfiguration(dlg);
return true;
} else if (sMethod.equals("back") || sMethod.equals("initialize")) {
} else if (sMethod.equals("back") || sMethod.equals("initialize")) { //$NON-NLS-1$ //$NON-NLS-2$
loadConfiguration(dlg);
enableBibTeXSettings(dlg);
useNatbibChange(dlg);
@ -156,7 +156,7 @@ public final class BibliographyDialog
}
catch (com.sun.star.lang.IllegalArgumentException e) {
throw new com.sun.star.lang.IllegalArgumentException(
"Method external_event requires a string in the event object argument.", this,(short) -1);
"Method external_event requires a string in the event object argument.", this,(short) -1); //$NON-NLS-1$
}
return false;
}
@ -167,22 +167,22 @@ public final class BibliographyDialog
try {
Object view = registry.getRegistryView(REGISTRY_PATH, false);
XPropertySet xProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,view);
dlg.setCheckBoxStateAsBoolean("UseExternalBibTeXFiles",
XPropertySetHelper.getPropertyValueAsBoolean(xProps, "UseExternalBibTeXFiles"));
dlg.setCheckBoxStateAsBoolean("ConvertZoteroCitations",
XPropertySetHelper.getPropertyValueAsBoolean(xProps, "ConvertZoteroCitations"));
dlg.setCheckBoxStateAsBoolean("ConvertJabRefCitations",
XPropertySetHelper.getPropertyValueAsBoolean(xProps, "ConvertJabRefCitations"));
dlg.setCheckBoxStateAsBoolean("IncludeOriginalCitations",
XPropertySetHelper.getPropertyValueAsBoolean(xProps, "IncludeOriginalCitations"));
dlg.setListBoxSelectedItem("BibTeXLocation",
XPropertySetHelper.getPropertyValueAsShort(xProps, "BibTeXLocation"));
dlg.setTextFieldText("BibTeXDir",
XPropertySetHelper.getPropertyValueAsString(xProps, "BibTeXDir"));
dlg.setCheckBoxStateAsBoolean("UseNatbib",
XPropertySetHelper.getPropertyValueAsBoolean(xProps, "UseNatbib"));
dlg.setTextFieldText("NatbibOptions",
XPropertySetHelper.getPropertyValueAsString(xProps, "NatbibOptions"));
dlg.setCheckBoxStateAsBoolean("UseExternalBibTeXFiles", //$NON-NLS-1$
XPropertySetHelper.getPropertyValueAsBoolean(xProps, "UseExternalBibTeXFiles")); //$NON-NLS-1$
dlg.setCheckBoxStateAsBoolean("ConvertZoteroCitations", //$NON-NLS-1$
XPropertySetHelper.getPropertyValueAsBoolean(xProps, "ConvertZoteroCitations")); //$NON-NLS-1$
dlg.setCheckBoxStateAsBoolean("ConvertJabRefCitations", //$NON-NLS-1$
XPropertySetHelper.getPropertyValueAsBoolean(xProps, "ConvertJabRefCitations")); //$NON-NLS-1$
dlg.setCheckBoxStateAsBoolean("IncludeOriginalCitations", //$NON-NLS-1$
XPropertySetHelper.getPropertyValueAsBoolean(xProps, "IncludeOriginalCitations")); //$NON-NLS-1$
dlg.setListBoxSelectedItem("BibTeXLocation", //$NON-NLS-1$
XPropertySetHelper.getPropertyValueAsShort(xProps, "BibTeXLocation")); //$NON-NLS-1$
dlg.setTextFieldText("BibTeXDir", //$NON-NLS-1$
XPropertySetHelper.getPropertyValueAsString(xProps, "BibTeXDir")); //$NON-NLS-1$
dlg.setCheckBoxStateAsBoolean("UseNatbib", //$NON-NLS-1$
XPropertySetHelper.getPropertyValueAsBoolean(xProps, "UseNatbib")); //$NON-NLS-1$
dlg.setTextFieldText("NatbibOptions", //$NON-NLS-1$
XPropertySetHelper.getPropertyValueAsString(xProps, "NatbibOptions")); //$NON-NLS-1$
registry.disposeRegistryView(view);
}
catch (Exception e) {
@ -200,14 +200,14 @@ public final class BibliographyDialog
try {
Object view = registry.getRegistryView(REGISTRY_PATH, true);
XPropertySet xProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,view);
XPropertySetHelper.setPropertyValue(xProps, "UseExternalBibTeXFiles", dlg.getCheckBoxStateAsBoolean("UseExternalBibTeXFiles"));
XPropertySetHelper.setPropertyValue(xProps, "ConvertZoteroCitations", dlg.getCheckBoxStateAsBoolean("ConvertZoteroCitations"));
XPropertySetHelper.setPropertyValue(xProps, "ConvertJabRefCitations", dlg.getCheckBoxStateAsBoolean("ConvertJabRefCitations"));
XPropertySetHelper.setPropertyValue(xProps, "IncludeOriginalCitations", dlg.getCheckBoxStateAsBoolean("IncludeOriginalCitations"));
XPropertySetHelper.setPropertyValue(xProps, "BibTeXLocation", dlg.getListBoxSelectedItem("BibTeXLocation"));
XPropertySetHelper.setPropertyValue(xProps, "BibTeXDir", dlg.getTextFieldText("BibTeXDir"));
XPropertySetHelper.setPropertyValue(xProps, "UseNatbib", dlg.getCheckBoxStateAsBoolean("UseNatbib"));
XPropertySetHelper.setPropertyValue(xProps, "NatbibOptions", dlg.getTextFieldText("NatbibOptions"));
XPropertySetHelper.setPropertyValue(xProps, "UseExternalBibTeXFiles", dlg.getCheckBoxStateAsBoolean("UseExternalBibTeXFiles")); //$NON-NLS-1$ //$NON-NLS-2$
XPropertySetHelper.setPropertyValue(xProps, "ConvertZoteroCitations", dlg.getCheckBoxStateAsBoolean("ConvertZoteroCitations")); //$NON-NLS-1$ //$NON-NLS-2$
XPropertySetHelper.setPropertyValue(xProps, "ConvertJabRefCitations", dlg.getCheckBoxStateAsBoolean("ConvertJabRefCitations")); //$NON-NLS-1$ //$NON-NLS-2$
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, "UseNatbib", dlg.getCheckBoxStateAsBoolean("UseNatbib")); //$NON-NLS-1$ //$NON-NLS-2$
XPropertySetHelper.setPropertyValue(xProps, "NatbibOptions", dlg.getTextFieldText("NatbibOptions")); //$NON-NLS-1$ //$NON-NLS-2$
// Commit registry changes
XChangesBatch xUpdateContext = (XChangesBatch)
@ -242,9 +242,9 @@ public final class BibliographyDialog
}
private boolean useNatbibChange(DialogAccess dlg) {
boolean bUseNatbib = dlg.getCheckBoxStateAsBoolean("UseNatbib");
dlg.setControlEnabled("NatbibOptionsLabel", bUseNatbib);
dlg.setControlEnabled("NatbibOptions", bUseNatbib);
boolean bUseNatbib = dlg.getCheckBoxStateAsBoolean("UseNatbib"); //$NON-NLS-1$
dlg.setControlEnabled("NatbibOptionsLabel", bUseNatbib); //$NON-NLS-1$
dlg.setControlEnabled("NatbibOptions", bUseNatbib); //$NON-NLS-1$
return true;
}
@ -254,28 +254,28 @@ public final class BibliographyDialog
}
private void enableBibTeXSettings(DialogAccess dlg) {
boolean bEnableSettings = dlg.getCheckBoxStateAsBoolean("UseExternalBibTeXFiles");
boolean bEnableOriginalCitations = dlg.getCheckBoxStateAsBoolean("ConvertZoteroCitations")
|| dlg.getCheckBoxStateAsBoolean("ConvertJabRefCitations");
boolean bEnableDir = dlg.getListBoxSelectedItem("BibTeXLocation")<2;
dlg.setControlEnabled("BibTeXLocationLabel", bEnableSettings);
dlg.setControlEnabled("BibTeXLocation", bEnableSettings);
dlg.setControlEnabled("BibTeXDirLabel", bEnableSettings && bEnableDir);
dlg.setControlEnabled("BibTeXDir", bEnableSettings && bEnableDir);
dlg.setControlEnabled("BibTeXDirButton", bEnableSettings && bEnableDir);
dlg.setControlEnabled("ConvertZoteroCitations", bEnableSettings);
dlg.setControlEnabled("ConvertJabRefCitations", bEnableSettings);
dlg.setControlEnabled("IncludeOriginalCitations", bEnableSettings && bEnableOriginalCitations);
boolean bEnableSettings = dlg.getCheckBoxStateAsBoolean("UseExternalBibTeXFiles"); //$NON-NLS-1$
boolean bEnableOriginalCitations = dlg.getCheckBoxStateAsBoolean("ConvertZoteroCitations") //$NON-NLS-1$
|| dlg.getCheckBoxStateAsBoolean("ConvertJabRefCitations"); //$NON-NLS-1$
boolean bEnableDir = dlg.getListBoxSelectedItem("BibTeXLocation")<2; //$NON-NLS-1$
dlg.setControlEnabled("BibTeXLocationLabel", bEnableSettings); //$NON-NLS-1$
dlg.setControlEnabled("BibTeXLocation", bEnableSettings); //$NON-NLS-1$
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("ConvertZoteroCitations", bEnableSettings); //$NON-NLS-1$
dlg.setControlEnabled("ConvertJabRefCitations", bEnableSettings); //$NON-NLS-1$
dlg.setControlEnabled("IncludeOriginalCitations", bEnableSettings && bEnableOriginalCitations); //$NON-NLS-1$
}
private String getDocumentDirURL() {
// Get the desktop from the service manager
Object desktop=null;
try {
desktop = xContext.getServiceManager().createInstanceWithContext("com.sun.star.frame.Desktop", xContext);
desktop = xContext.getServiceManager().createInstanceWithContext("com.sun.star.frame.Desktop", xContext); //$NON-NLS-1$
} catch (Exception e) {
// Failed to get the desktop service
return "";
return ""; //$NON-NLS-1$
}
XDesktop xDesktop = (XDesktop) UnoRuntime.queryInterface(XDesktop.class, desktop);
@ -283,25 +283,25 @@ public final class BibliographyDialog
if (xDesktop!=null) {
XComponent xComponent = xDesktop.getCurrentComponent();
XServiceInfo xInfo = (XServiceInfo)UnoRuntime.queryInterface(XServiceInfo.class, xComponent);
if (xInfo!=null && xInfo.supportsService("com.sun.star.text.TextDocument")) {
if (xInfo!=null && xInfo.supportsService("com.sun.star.text.TextDocument")) { //$NON-NLS-1$
// Get the model, which provides the URL
XModel xModel = (XModel) UnoRuntime.queryInterface(XModel.class, xComponent);
if (xModel!=null) {
String sURL = xModel.getURL();
int nSlash = sURL.lastIndexOf('/');
return nSlash>-1 ? sURL.substring(0, nSlash) : "";
return nSlash>-1 ? sURL.substring(0, nSlash) : ""; //$NON-NLS-1$
}
}
}
return "";
return ""; //$NON-NLS-1$
}
private boolean hasBibTeXFiles(File dir) {
if (dir.isDirectory()) {
File[] files = dir.listFiles();
for (File file : files) {
if (file.isFile() && file.getName().endsWith(".bib")) {
if (file.isFile() && file.getName().endsWith(".bib")) { //$NON-NLS-1$
return true;
}
}
@ -315,7 +315,7 @@ public final class BibliographyDialog
try {
File bibDir = new File(new URI(sPath));
String sBibPath = bibDir.getCanonicalPath();
if (dlg.getListBoxSelectedItem("BibTeXLocation")==1) {
if (dlg.getListBoxSelectedItem("BibTeXLocation")==1) { //$NON-NLS-1$
// Path relative to document directory, remove the document directory part
String sDocumentDirURL = getDocumentDirURL();
if (sDocumentDirURL.length()>0) {
@ -325,18 +325,18 @@ public final class BibliographyDialog
sBibPath = sBibPath.substring(sDocumentDirPath.length()+1);
}
else { // Same as document directory
sBibPath = "";
sBibPath = ""; //$NON-NLS-1$
}
}
else { // not a subdirectory
sBibPath = "";
sBibPath = ""; //$NON-NLS-1$
}
}
}
dlg.setTextFieldText("BibTeXDir", sBibPath);
dlg.setTextFieldText("BibTeXDir", sBibPath); //$NON-NLS-1$
if (!hasBibTeXFiles(bibDir)) {
MessageBox msgBox = new MessageBox(xContext);
msgBox.showMessage("Writer2LaTeX", "Warning: The selected directory does not contain any BibTeX files");
msgBox.showMessage("Writer2LaTeX", Messages.getString("BibliographyDialog.nobibtexfiles")); //$NON-NLS-1$ //$NON-NLS-2$
}
}
catch (IOException e) {

View file

@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
* Version 1.6 (2015-05-19)
* Version 1.6 (2015-05-29)
*
*/
@ -58,16 +58,16 @@ public class ExternalApps {
public final static short BUILD = (short)1;
public final static short PREVIEW = (short)2;
public final static String LATEX = "LaTeX";
public final static String PDFLATEX = "PdfLaTeX";
public final static String XELATEX = "XeLaTeX";
public final static String BIBTEX = "BibTeX";
public final static String MAKEINDEX = "Makeindex";
public final static String MK4HT = "Mk4ht";
public final static String DVIPS = "Dvips";
public final static String DVIVIEWER = "DVIViewer";
public final static String POSTSCRIPTVIEWER = "PostscriptViewer";
public final static String PDFVIEWER = "PdfViewer";
public final static String LATEX = "LaTeX"; //$NON-NLS-1$
public final static String PDFLATEX = "PdfLaTeX"; //$NON-NLS-1$
public final static String XELATEX = "XeLaTeX"; //$NON-NLS-1$
public final static String BIBTEX = "BibTeX"; //$NON-NLS-1$
public final static String MAKEINDEX = "Makeindex"; //$NON-NLS-1$
public final static String MK4HT = "Mk4ht"; //$NON-NLS-1$
public final static String DVIPS = "Dvips"; //$NON-NLS-1$
public final static String DVIVIEWER = "DVIViewer"; //$NON-NLS-1$
public final static String POSTSCRIPTVIEWER = "PostscriptViewer"; //$NON-NLS-1$
public final static String PDFVIEWER = "PdfViewer"; //$NON-NLS-1$
private final static String[] sApps = { LATEX, PDFLATEX, XELATEX, BIBTEX, MAKEINDEX, MK4HT, DVIPS, DVIVIEWER, POSTSCRIPTVIEWER, PDFVIEWER };
@ -84,11 +84,29 @@ public class ExternalApps {
apps = new HashMap<String,String[]>();
defaultApps = new HashSet<String>();
for (int i=0; i<sApps.length; i++) {
setApplication(sApps[i], "", "");
setApplication(sApps[i], "", ""); //$NON-NLS-1$ //$NON-NLS-2$
setUseDefaultApplication(sApps[i],true);
}
}
/** Return the localized name for an external app to use in the UI (only the viewers has a separate UI name)
*
* @param sName the app name
* @return the UI name
*/
public static String getUIAppName(String sName) {
if (DVIVIEWER.equals(sName)) {
return Messages.getString("ExternalApps.dviviewer"); //$NON-NLS-1$
}
else if (PDFVIEWER.equals(sName)) {
return Messages.getString("ExternalApps.pdfviewer"); //$NON-NLS-1$
}
else if (POSTSCRIPTVIEWER.equals(sName)) {
return Messages.getString("ExternalApps.psviewer"); //$NON-NLS-1$
}
return sName;
}
/** Set the desired processing level (0: export only, 1: export and build, 2: export, build and preview)
*
* @param nLevel the desired level
@ -106,7 +124,7 @@ public class ExternalApps {
}
public boolean isViewer(String sAppName) {
return sAppName!=null && sAppName.endsWith("Viewer");
return sAppName!=null && sAppName.endsWith("Viewer"); //$NON-NLS-1$
}
/** Define an external application
@ -166,7 +184,7 @@ public class ExternalApps {
return openWithDefaultApplication(new File(sFileName)) ? 0 : 1;
}
else {
return execute(sAppName, "", sFileName, workDir, env, bWaitFor);
return execute(sAppName, "", sFileName, workDir, env, bWaitFor); //$NON-NLS-1$
}
}
@ -202,9 +220,9 @@ public class ExternalApps {
try {
Vector<String> command = new Vector<String>();
command.add(sApp[0]);
String[] sArguments = sApp[1].split(" ");
String[] sArguments = sApp[1].split(" "); //$NON-NLS-1$
for (String s : sArguments) {
command.add(s.replace("%c",sCommand).replace("%s",sFileName));
command.add(s.replace("%c",sCommand).replace("%s",sFileName)); //$NON-NLS-1$ //$NON-NLS-2$
}
ProcessBuilder pb = new ProcessBuilder(command);
@ -216,11 +234,11 @@ public class ExternalApps {
// Gobble the error stream of the application
StreamGobbler errorGobbler = new
StreamGobbler(proc.getErrorStream(), "ERROR");
StreamGobbler(proc.getErrorStream(), "ERROR"); //$NON-NLS-1$
// Gobble the output stream of the application
StreamGobbler outputGobbler = new
StreamGobbler(proc.getInputStream(), "OUTPUT");
StreamGobbler(proc.getInputStream(), "OUTPUT"); //$NON-NLS-1$
// Kick them off
errorGobbler.start();
@ -244,7 +262,7 @@ public class ExternalApps {
Object view;
try {
// Prepare registry view
view = registry.getRegistryView("/org.openoffice.da.Writer2LaTeX.toolbar.ToolbarOptions/Applications",false);
view = registry.getRegistryView("/org.openoffice.da.Writer2LaTeX.toolbar.ToolbarOptions/Applications",false); //$NON-NLS-1$
}
catch (com.sun.star.uno.Exception e) {
// Give up...
@ -252,15 +270,15 @@ public class ExternalApps {
}
XPropertySet xSimpleProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,view);
nLevel = XPropertySetHelper.getPropertyValueAsShort(xSimpleProps,"AfterExport");
nLevel = XPropertySetHelper.getPropertyValueAsShort(xSimpleProps,"AfterExport"); //$NON-NLS-1$
XMultiHierarchicalPropertySet xProps = (XMultiHierarchicalPropertySet)
UnoRuntime.queryInterface(XMultiHierarchicalPropertySet.class, view);
for (int i=0; i<sApps.length; i++) {
String[] sNames = new String[3];
sNames[0] = sApps[i]+"/Executable";
sNames[1] = sApps[i]+"/Options";
sNames[2] = sApps[i]+"/UseDefault";
sNames[0] = sApps[i]+"/Executable"; //$NON-NLS-1$
sNames[1] = sApps[i]+"/Options"; //$NON-NLS-1$
sNames[2] = sApps[i]+"/UseDefault"; //$NON-NLS-1$
try {
Object[] values = xProps.getHierarchicalPropertyValues(sNames);
setApplication(sApps[i], (String) values[0], (String) values[1]);
@ -280,7 +298,7 @@ public class ExternalApps {
RegistryHelper registry = new RegistryHelper(xContext);
Object view;
try {
view = registry.getRegistryView("/org.openoffice.da.Writer2LaTeX.toolbar.ToolbarOptions/Applications",true);
view = registry.getRegistryView("/org.openoffice.da.Writer2LaTeX.toolbar.ToolbarOptions/Applications",true); //$NON-NLS-1$
}
catch (com.sun.star.uno.Exception e) {
// Give up...
@ -288,15 +306,15 @@ public class ExternalApps {
}
XPropertySet xSimpleProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,view);
XPropertySetHelper.setPropertyValue(xSimpleProps, "AfterExport", nLevel);
XPropertySetHelper.setPropertyValue(xSimpleProps, "AfterExport", nLevel); //$NON-NLS-1$
XMultiHierarchicalPropertySet xProps = (XMultiHierarchicalPropertySet)
UnoRuntime.queryInterface(XMultiHierarchicalPropertySet.class, view);
for (int i=0; i<sApps.length; i++) {
String[] sNames = new String[3];
sNames[0] = sApps[i]+"/Executable";
sNames[1] = sApps[i]+"/Options";
sNames[2] = sApps[i]+"/UseDefault";
sNames[0] = sApps[i]+"/Executable"; //$NON-NLS-1$
sNames[1] = sApps[i]+"/Options"; //$NON-NLS-1$
sNames[2] = sApps[i]+"/UseDefault"; //$NON-NLS-1$
String[] sApp = getApplication(sApps[i]);
boolean bUseDefault = getUseDefaultApplication(sApps[i]);
Object[] values = { sApp[0], sApp[1], new Boolean(bUseDefault) };

View file

@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
* Version 1.6 (2015-04-05)
* Version 1.6 (2015-05-29)
*
*/
package org.openoffice.da.comp.writer2latex;
@ -49,7 +49,7 @@ public class LaTeXUNOPublisher extends UNOPublisher {
// The TeXifier and associated data
private TeXify texify = null;
private String sBibinputs=null;
private String sBackend = "generic";
private String sBackend = "generic"; //$NON-NLS-1$
public LaTeXUNOPublisher(XComponentContext xContext, XFrame xFrame, String sAppName) {
super(xContext, xFrame, sAppName);
@ -70,30 +70,30 @@ public class LaTeXUNOPublisher extends UNOPublisher {
return null;
}
XPropertySet xProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,view);
return getDirectory(XPropertySetHelper.getPropertyValueAsShort(xProps, "BibTeXLocation"),
XPropertySetHelper.getPropertyValueAsString(xProps, "BibTeXDir"));
return getDirectory(XPropertySetHelper.getPropertyValueAsShort(xProps, "BibTeXLocation"), //$NON-NLS-1$
XPropertySetHelper.getPropertyValueAsString(xProps, "BibTeXDir")); //$NON-NLS-1$
}
/** Make a file name LaTeX friendly
*/
@Override protected String filterFileName(String sFileName) {
return Misc.makeTeXFriendly(sFileName,"writer2latex");
return Misc.makeTeXFriendly(sFileName,"writer2latex"); //$NON-NLS-1$
}
/** Post process the filter data: Set bibliography options and
* determine the backend and the BIBINPUTS directory
*/
@Override protected PropertyValue[] postProcessMediaProps(PropertyValue[] mediaProps) {
sBackend = "generic";
sBackend = "generic"; //$NON-NLS-1$
sBibinputs = null;
PropertyHelper mediaHelper = new PropertyHelper(mediaProps);
Object filterData = mediaHelper.get("FilterData");
Object filterData = mediaHelper.get("FilterData"); //$NON-NLS-1$
if (filterData instanceof PropertyValue[]) {
PropertyHelper filterHelper = new PropertyHelper((PropertyValue[])filterData);
// Get the backend
Object backend = filterHelper.get("backend");
Object backend = filterHelper.get("backend"); //$NON-NLS-1$
if (backend instanceof String) {
sBackend = (String) backend;
}
@ -103,28 +103,28 @@ public class LaTeXUNOPublisher extends UNOPublisher {
try {
Object view = registry.getRegistryView(BibliographyDialog.REGISTRY_PATH, false);
XPropertySet xProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,view);
String sBibTeXFiles = getFileList(XPropertySetHelper.getPropertyValueAsShort(xProps, "BibTeXLocation"),
XPropertySetHelper.getPropertyValueAsString(xProps, "BibTeXDir"));
if (XPropertySetHelper.getPropertyValueAsBoolean(xProps, "UseExternalBibTeXFiles")) {
filterHelper.put("external_bibtex_files", sBibTeXFiles);
if (XPropertySetHelper.getPropertyValueAsBoolean(xProps, "ConvertZoteroCitations")) {
filterHelper.put("zotero_bibtex_files", sBibTeXFiles);
String sBibTeXFiles = getFileList(XPropertySetHelper.getPropertyValueAsShort(xProps, "BibTeXLocation"), //$NON-NLS-1$
XPropertySetHelper.getPropertyValueAsString(xProps, "BibTeXDir")); //$NON-NLS-1$
if (XPropertySetHelper.getPropertyValueAsBoolean(xProps, "UseExternalBibTeXFiles")) { //$NON-NLS-1$
filterHelper.put("external_bibtex_files", sBibTeXFiles); //$NON-NLS-1$
if (XPropertySetHelper.getPropertyValueAsBoolean(xProps, "ConvertZoteroCitations")) { //$NON-NLS-1$
filterHelper.put("zotero_bibtex_files", sBibTeXFiles); //$NON-NLS-1$
}
if (XPropertySetHelper.getPropertyValueAsBoolean(xProps, "ConvertJabRefCitations")) {
filterHelper.put("jabref_bibtex_files", sBibTeXFiles);
if (XPropertySetHelper.getPropertyValueAsBoolean(xProps, "ConvertJabRefCitations")) { //$NON-NLS-1$
filterHelper.put("jabref_bibtex_files", sBibTeXFiles); //$NON-NLS-1$
}
}
filterHelper.put("include_original_citations",
Boolean.toString(XPropertySetHelper.getPropertyValueAsBoolean(xProps, "IncludeOriginalCitations")));
String sBibTeXDir = XPropertySetHelper.getPropertyValueAsString(xProps, "BibTeXDir");
filterHelper.put("include_original_citations", //$NON-NLS-1$
Boolean.toString(XPropertySetHelper.getPropertyValueAsBoolean(xProps, "IncludeOriginalCitations"))); //$NON-NLS-1$
String sBibTeXDir = XPropertySetHelper.getPropertyValueAsString(xProps, "BibTeXDir"); //$NON-NLS-1$
if (sBibTeXDir.length()>0) {
// The separator character in BIBINPUTS is OS specific
sBibinputs = sBibTeXDir+File.pathSeparatorChar;
}
filterHelper.put("use_natbib", Boolean.toString(XPropertySetHelper.getPropertyValueAsBoolean(xProps, "UseNatbib")));
filterHelper.put("natbib_options", XPropertySetHelper.getPropertyValueAsString(xProps, "NatbibOptions"));
filterHelper.put("use_natbib", Boolean.toString(XPropertySetHelper.getPropertyValueAsBoolean(xProps, "UseNatbib"))); //$NON-NLS-1$ //$NON-NLS-2$
filterHelper.put("natbib_options", XPropertySetHelper.getPropertyValueAsString(xProps, "NatbibOptions")); //$NON-NLS-1$ //$NON-NLS-2$
mediaHelper.put("FilterData",filterHelper.toArray());
mediaHelper.put("FilterData",filterHelper.toArray()); //$NON-NLS-1$
PropertyValue[] newMediaProps = mediaHelper.toArray();
registry.disposeRegistryView(view);
return newMediaProps;
@ -147,27 +147,27 @@ public class LaTeXUNOPublisher extends UNOPublisher {
boolean bResult = true;
try {
if (sBackend=="pdftex") {
if (sBackend=="pdftex") { //$NON-NLS-1$
bResult = texify.process(file, sBibinputs, TeXify.PDFTEX, true);
}
else if (sBackend=="dvips") {
else if (sBackend=="dvips") { //$NON-NLS-1$
bResult = texify.process(file, sBibinputs, TeXify.DVIPS, true);
}
else if (sBackend=="xetex") {
else if (sBackend=="xetex") { //$NON-NLS-1$
bResult = texify.process(file, sBibinputs, TeXify.XETEX, true);
}
else if (sBackend=="generic") {
else if (sBackend=="generic") { //$NON-NLS-1$
bResult = texify.process(file, sBibinputs, TeXify.GENERIC, true);
}
}
catch (IOException e) {
MessageBox msgBox = new MessageBox(xContext, xFrame);
msgBox.showMessage("Writer2LaTeX","Error: "+e.getMessage());
msgBox.showMessage("Writer2LaTeX",Messages.getString("LaTeXUNOPublisher.error")+": "+e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
}
if (!bResult) {
MessageBox msgBox = new MessageBox(xContext, xFrame);
msgBox.showMessage("Writer2LaTeX","Error: Failed to execute LaTeX - see log for details");
msgBox.showMessage("Writer2LaTeX",Messages.getString("LaTeXUNOPublisher.error")+": "+Messages.getString("LaTeXUNOPublisher.failedlatex")); //$NON-NLS-1$ //$NON-NLS-2$
}
}
@ -191,10 +191,10 @@ public class LaTeXUNOPublisher extends UNOPublisher {
else {
return null;
}
CSVList filelist = new CSVList(",");
CSVList filelist = new CSVList(","); //$NON-NLS-1$
if (files!=null) {
for (File file : files) {
if (file.isFile() && file.getName().endsWith(".bib")) {
if (file.isFile() && file.getName().endsWith(".bib")) { //$NON-NLS-1$
filelist.addValue(Misc.removeExtension(file.getName()));
}
}

View file

@ -0,0 +1,47 @@
/************************************************************************
*
* Messages.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-2015 by Henrik Just
*
* All Rights Reserved.
*
* Version 1.6 (2015-05-29)
*
*/
package org.openoffice.da.comp.writer2latex;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
public class Messages {
private static final String BUNDLE_NAME = "org.openoffice.da.comp.writer2latex.messages"; //$NON-NLS-1$
private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
.getBundle(BUNDLE_NAME);
private Messages() {
}
public static String getString(String key) {
try {
return RESOURCE_BUNDLE.getString(key);
} catch (MissingResourceException e) {
return '!' + key + '!';
}
}
}

View file

@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
* Version 1.6 (2015-05-14)
* Version 1.6 (2015-05-29)
*
*/
@ -85,7 +85,7 @@ public final class TeXify {
*/
public boolean process(File file, String sBibinputs, short nBackend, boolean bView) throws IOException {
// Remove extension from file
if (file.getName().endsWith(".tex")) {
if (file.getName().endsWith(".tex")) { //$NON-NLS-1$
file = new File(file.getParentFile(),
file.getName().substring(0,file.getName().length()-4));
}
@ -101,36 +101,36 @@ public final class TeXify {
bResult = doTeXify(genericTexify, file, sBibinputs);
if (!bResult) return false;
if (bPreview && externalApps.execute(ExternalApps.DVIVIEWER,
new File(file.getParentFile(),file.getName()+".dvi").getPath(),
new File(file.getParentFile(),file.getName()+".dvi").getPath(), //$NON-NLS-1$
file.getParentFile(), null, false)>0) {
throw new IOException("Error executing dvi viewer");
throw new IOException(Messages.getString("TeXify.dviviewerror")); //$NON-NLS-1$
}
}
else if (nBackend==PDFTEX) {
bResult = doTeXify(pdfTexify, file, sBibinputs);
if (!bResult) return false;
if (bPreview && externalApps.execute(ExternalApps.PDFVIEWER,
new File(file.getParentFile(),file.getName()+".pdf").getPath(),
new File(file.getParentFile(),file.getName()+".pdf").getPath(), //$NON-NLS-1$
file.getParentFile(), null, false)>0) {
throw new IOException("Error executing pdf viewer");
throw new IOException(Messages.getString("TeXify.pdfviewerror")); //$NON-NLS-1$
}
}
else if (nBackend==DVIPS) {
bResult = doTeXify(dvipsTexify, file, sBibinputs);
if (!bResult) return false;
if (bPreview && externalApps.execute(ExternalApps.POSTSCRIPTVIEWER,
new File(file.getParentFile(),file.getName()+".ps").getPath(),
new File(file.getParentFile(),file.getName()+".ps").getPath(), //$NON-NLS-1$
file.getParentFile(), null, false)>0) {
throw new IOException("Error executing postscript viewer");
throw new IOException(Messages.getString("TeXify.psviewerror")); //$NON-NLS-1$
}
}
else if (nBackend==XETEX) {
bResult = doTeXify(xeTexify, file, sBibinputs);
if (!bResult) return false;
if (bPreview && externalApps.execute(ExternalApps.PDFVIEWER,
new File(file.getParentFile(),file.getName()+".pdf").getPath(),
new File(file.getParentFile(),file.getName()+".pdf").getPath(), //$NON-NLS-1$
file.getParentFile(), null, false)>0) {
throw new IOException("Error executing pdf viewer");
throw new IOException(Messages.getString("TeXify.pdfviewerror")); //$NON-NLS-1$
}
}
return bResult;
@ -140,14 +140,14 @@ public final class TeXify {
private boolean doTeXify(String[] sAppList, File file, String sBibinputs) throws IOException {
// Remove the .aux file first (to avoid potential error messages)
File aux = new File(file.getParentFile(), file.getName()+".aux");
File aux = new File(file.getParentFile(), file.getName()+".aux"); //$NON-NLS-1$
aux.delete();
for (int i=0; i<sAppList.length; i++) {
// Execute external application
Map<String,String> env =null;
if (ExternalApps.BIBTEX.equals(sAppList[i]) && sBibinputs!=null) {
env = new HashMap<String,String>();
env.put("BIBINPUTS", sBibinputs);
env.put("BIBINPUTS", sBibinputs); //$NON-NLS-1$
}
int nReturnCode = externalApps.execute(
sAppList[i], file.getName(), file.getParentFile(), env, true);

View file

@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
* Version 1.6 (2015-02-18)
* Version 1.6 (2015-05-29)
*
*/
@ -50,7 +50,7 @@ public final class Writer2LaTeX extends WeakBase
com.sun.star.lang.XInitialization,
com.sun.star.frame.XDispatch {
private static final String PROTOCOL = "org.openoffice.da.writer2latex:";
private static final String PROTOCOL = "org.openoffice.da.writer2latex:"; //$NON-NLS-1$
// From constructor+initialization
private final XComponentContext m_xContext;
@ -58,7 +58,7 @@ public final class Writer2LaTeX extends WeakBase
private LaTeXUNOPublisher unoPublisher = null;
public static final String __implementationName = Writer2LaTeX.class.getName();
public static final String __serviceName = "com.sun.star.frame.ProtocolHandler";
public static final String __serviceName = "com.sun.star.frame.ProtocolHandler"; //$NON-NLS-1$
private static final String[] m_serviceNames = { __serviceName };
public Writer2LaTeX( XComponentContext xContext ) {
@ -99,11 +99,11 @@ public final class Writer2LaTeX extends WeakBase
public com.sun.star.frame.XDispatch queryDispatch( com.sun.star.util.URL aURL,
String sTargetFrameName, int iSearchFlags ) {
if ( aURL.Protocol.compareTo(PROTOCOL) == 0 ) {
if ( aURL.Path.compareTo("ProcessDocument") == 0 )
if ( aURL.Path.compareTo("ProcessDocument") == 0 ) //$NON-NLS-1$
return this;
else if ( aURL.Path.compareTo("ViewLog") == 0 )
else if ( aURL.Path.compareTo("ViewLog") == 0 ) //$NON-NLS-1$
return this;
else if ( aURL.Path.compareTo("InsertBibTeX") == 0 )
else if ( aURL.Path.compareTo("InsertBibTeX") == 0 ) //$NON-NLS-1$
return this;
}
return null;
@ -128,15 +128,15 @@ public final class Writer2LaTeX extends WeakBase
public void dispatch( com.sun.star.util.URL aURL,
com.sun.star.beans.PropertyValue[] aArguments ) {
if ( aURL.Protocol.compareTo(PROTOCOL) == 0 ) {
if ( aURL.Path.compareTo("ProcessDocument") == 0 ) {
if ( aURL.Path.compareTo("ProcessDocument") == 0 ) { //$NON-NLS-1$
process();
return;
}
else if ( aURL.Path.compareTo("ViewLog") == 0 ) {
else if ( aURL.Path.compareTo("ViewLog") == 0 ) { //$NON-NLS-1$
viewLog();
return;
}
else if ( aURL.Path.compareTo("InsertBibTeX") == 0 ) {
else if ( aURL.Path.compareTo("InsertBibTeX") == 0 ) { //$NON-NLS-1$
insertBibTeX();
return;
}
@ -167,7 +167,7 @@ public final class Writer2LaTeX extends WeakBase
args[0] = unoPublisher.getTargetPath()+unoPublisher.getTargetFileName();
Object dialog = m_xContext.getServiceManager()
.createInstanceWithArgumentsAndContext(
"org.openoffice.da.writer2latex.LogViewerDialog", args, m_xContext);
"org.openoffice.da.writer2latex.LogViewerDialog", args, m_xContext); //$NON-NLS-1$
XExecutableDialog xDialog = (XExecutableDialog)
UnoRuntime.queryInterface(XExecutableDialog.class, dialog);
if (xDialog.execute()==ExecutableDialogResults.OK) {
@ -191,7 +191,7 @@ public final class Writer2LaTeX extends WeakBase
args[1] = unoPublisher.getBibTeXDirectory().getPath();
Object dialog = m_xContext.getServiceManager()
.createInstanceWithArgumentsAndContext(
"org.openoffice.da.writer2latex.BibTeXDialog", args, m_xContext);
"org.openoffice.da.writer2latex.BibTeXDialog", args, m_xContext); //$NON-NLS-1$
XExecutableDialog xDialog = (XExecutableDialog)
UnoRuntime.queryInterface(XExecutableDialog.class, dialog);
if (xDialog.execute()==ExecutableDialogResults.OK) {
@ -204,7 +204,7 @@ public final class Writer2LaTeX extends WeakBase
}
else {
MessageBox msgBox = new MessageBox(m_xContext, m_xFrame);
msgBox.showMessage("Writer2LaTeX","Writer2LaTeX is not configured to use external BibTeX files for citations");
msgBox.showMessage("Writer2LaTeX",Messages.getString("Writer2LaTeX.bibtexnotenabled")); //$NON-NLS-1$
}
}
@ -219,12 +219,12 @@ public final class Writer2LaTeX extends WeakBase
return false;
}
XPropertySet xProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,view);
return XPropertySetHelper.getPropertyValueAsBoolean(xProps, "UseExternalBibTeXFiles");
return XPropertySetHelper.getPropertyValueAsBoolean(xProps, "UseExternalBibTeXFiles"); //$NON-NLS-1$
}
private void createUNOPublisher() {
if (unoPublisher==null) {
unoPublisher = new LaTeXUNOPublisher(m_xContext,m_xFrame,"Writer2LaTeX");
unoPublisher = new LaTeXUNOPublisher(m_xContext,m_xFrame,"Writer2LaTeX"); //$NON-NLS-1$
}
}

View file

@ -0,0 +1,34 @@
ApplicationsDialog.configresults=Results of configuration
ApplicationsDialog.failedtofind=Failed to find
ApplicationsDialog.failedtofindmiktex=Failed to find MikTeX
ApplicationsDialog.found=Found
ApplicationsDialog.foundgsview=Found gsview
ApplicationsDialog.foundmiktex=Found MikTeX
ApplicationsDialog.miktexdefaultconfig=Writer2LaTeX has been configured to work if MikTeX is added to your path
ApplicationsDialog.ok=OK
ApplicationsDialog.pdfdefaultviewer=Using default application for PDF
ApplicationsDialog.psdefaultviewer=Using default application for PostScript
ApplicationsDialog.systemident=Your system identifies itself as
ApplicationsDialog.usingdefaultapp=Using default application as
ApplicationsDialog.version=version
BibliographyDialog.nobibtexfiles=Warning: The selected directory does not contain any BibTeX files
BibTeXDialog.allbibfieldsupdated=All bibliography fields were updated
BibTeXDialog.alreadyexists=already exists
BibTeXDialog.bibfieldsnotupdated=The following bibliography fields were not updated
BibTeXDialog.errorreadingfile=There was an error reading this file
BibTeXDialog.failedbibtexeditor=Error: Failed to open file with BibTeX editor
BibTeXDialog.filenameempty=The file name is empty
BibTeXDialog.nobibtexeditor=Error: No BibTeX editor was found
BibTeXDialog.nobibtexfiles=No BibTeX files were found
BibTeXDialog.noentries=This file does not contain any entries
BibTeXDialog.noinformation=No information
BibTeXDialog.thefile=The file
ExternalApps.dviviewer=DVI Viewer
ExternalApps.pdfviewer=PDF Viewer
ExternalApps.psviewer=PostScript Viewer
LaTeXUNOPublisher.error=Error
LaTeXUNOPublisher.failedlatex=Failed to execute LaTeX - see log for details
TeXify.dviviewerror=Error executing DVI viewer
TeXify.pdfviewerror=Error executing PDF viewer
TeXify.psviewerror=Error executing PostScript viewer
Writer2LaTeX.bibtexnotenabled=Writer2LaTeX is not configured to use external BibTeX files for citations

View file

@ -0,0 +1,34 @@
ApplicationsDialog.configresults=Resultat af konfigurationen
ApplicationsDialog.failedtofind=Fandt ikke
ApplicationsDialog.failedtofindmiktex=Fandt ikke MikTeX
ApplicationsDialog.found=Fandt
ApplicationsDialog.foundgsview=Fandt gsview
ApplicationsDialog.foundmiktex=Fandt MikTeX
ApplicationsDialog.miktexdefaultconfig=Writer2LaTeX er blevet konfigureret så det virker hvis MikTeX tilføjes til din PATH
ApplicationsDialog.ok=o.k.
ApplicationsDialog.pdfdefaultviewer=Bruger standardprogram til PDF
ApplicationsDialog.psdefaultviewer=Bruger standardprogram til PostScript
ApplicationsDialog.systemident=Dit system identificerer sig som
ApplicationsDialog.usingdefaultapp=Bruger standardprogram som
ApplicationsDialog.version=version
BibliographyDialog.nobibtexfiles=Advarsel: Den valgte mappe indeholder ingen BibTeX filer
BibTeXDialog.allbibfieldsupdated=Alle litteraturlisteelementer blev opdateret
BibTeXDialog.alreadyexists=findes allerede
BibTeXDialog.bibfieldsnotupdated=Følgende litteraturlisteelementer blev ikke opdateret
BibTeXDialog.errorreadingfile=Der skete en fejl ved læsning af denne fil
BibTeXDialog.failedbibtexeditor=Fejl: Kunne ikke åbne filen med BibTeX-redigeringsprogrammet
BibTeXDialog.filenameempty=Filnavnet er tomt
BibTeXDialog.nobibtexeditor=Fejl: Kunne ikke finde et BibTeX-redigeringsprogram
BibTeXDialog.nobibtexfiles=Fandt ingen BibTeX filer
BibTeXDialog.noentries=Filen indeholder ingen elementer
BibTeXDialog.noinformation=Ingen information
BibTeXDialog.thefile=Filen
ExternalApps.dviviewer=DVI-fremviser
ExternalApps.pdfviewer=PDF-fremviser
ExternalApps.psviewer=PostScript-fremviser
LaTeXUNOPublisher.error=Fejl
LaTeXUNOPublisher.failedlatex=Kunne ikke køre LaTeX - se loggen for detaljer
TeXify.dviviewerror=Fejl ved åbning af DVI-fremviser
TeXify.pdfviewerror=Fejl ved åbning af PDF-fremviser
TeXify.psviewerror=Fejl ved åbning af PostScript-fremviser
Writer2LaTeX.bibtexnotenabled=Writer2LaTeX er ikke sat op til at bruge eksterne BibTeX-filer til litteraturhenvisninger

View file

@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
* Version 1.6 (2015-05-19)
* Version 1.6 (2015-05-29)
*
*/
@ -33,7 +33,7 @@ public class ConverterFactory {
// Version information
private static final String VERSION = "1.5.3";
private static final String DATE = "2015-05-19";
private static final String DATE = "2015-05-29";
/** Return the Writer2LaTeX version in the form
* (major version).(minor version).(patch level)<br/>