w2l toolbar configuration: Define behavior of TeX-button

git-svn-id: svn://svn.code.sf.net/p/writer2latex/code/trunk@245 f0f2a975-2e09-46c8-9428-3b39399b9f3c
This commit is contained in:
henrikjust 2015-05-15 06:49:11 +00:00
parent 853ff0968d
commit 2953e5845c
10 changed files with 142 additions and 64 deletions

View file

@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
* Version 1.6 (2015-04-05)
* Version 1.6 (2015-05-14)
*
*/
@ -85,6 +85,9 @@ public final class ApplicationsDialog
if (sMethod.equals("external_event") ){
return handleExternalEvent(dlg, event);
}
else if (sMethod.equals("AfterExportChange")) {
return changeBehavior(dlg);
}
else if (sMethod.equals("ApplicationChange")) {
return changeApplication(dlg);
}
@ -111,7 +114,7 @@ public final class ApplicationsDialog
}
public String[] getSupportedMethodNames() {
String[] sNames = { "external_event", "ApplicationChange", "BrowseClick", "ExecutableUnfocus", "OptionsUnfocus", "AutomaticClick" };
String[] sNames = { "external_event", "AfterExportChange", "ApplicationChange", "BrowseClick", "ExecutableUnfocus", "OptionsUnfocus", "AutomaticClick" };
return sNames;
}
@ -140,6 +143,7 @@ public final class ApplicationsDialog
return true;
} else if (sMethod.equals("back") || sMethod.equals("initialize")) {
externalApps.load();
updateBehavior(dlg);
return changeApplication(dlg);
}
}
@ -149,6 +153,16 @@ public final class ApplicationsDialog
}
return false;
}
private boolean changeBehavior(DialogAccess dlg) {
externalApps.setProcessingLevel(dlg.getListBoxSelectedItem("AfterExport"));
return true;
}
private boolean updateBehavior(DialogAccess dlg) {
dlg.setListBoxSelectedItem("AfterExport", externalApps.getProcessingLevel());
return true;
}
private boolean changeApplication(DialogAccess dlg) {
String sAppName = getSelectedAppName(dlg);

View file

@ -16,11 +16,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
* Copyright: 2002-2014 by Henrik Just
* Copyright: 2002-2015 by Henrik Just
*
* All Rights Reserved.
*
* Version 1.6 (2014-10-29)
* Version 1.6 (2015-05-14)
*
*/
@ -36,9 +36,10 @@ import java.util.Vector;
import org.openoffice.da.comp.w2lcommon.helper.RegistryHelper;
import org.openoffice.da.comp.w2lcommon.helper.StreamGobbler;
//import java.util.Map;
import org.openoffice.da.comp.w2lcommon.helper.XPropertySetHelper;
import com.sun.star.beans.XMultiHierarchicalPropertySet;
import com.sun.star.beans.XPropertySet;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;
import com.sun.star.util.XChangesBatch;
@ -49,7 +50,11 @@ import com.sun.star.util.XChangesBatch;
* The registry is used for persistent storage of the settings.
*/
public class ExternalApps {
public final static short EXPORT = (short)0;
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";
@ -65,6 +70,8 @@ public class ExternalApps {
private XComponentContext xContext;
private short nLevel = (short)2;
private HashMap<String,String[]> apps;
/** Construct a new ExternalApps object, with empty definitions */
@ -75,6 +82,22 @@ public class ExternalApps {
setApplication(sApps[i], "?", "?");
}
}
/** Set the desired processing level (0: export only, 1: export and build, 2: export, build and preview)
*
* @param nLevel the desired level
*/
public void setProcessingLevel(short nLevel) {
this.nLevel = nLevel;
}
/** Get the desired processing level (0: export only, 1: export and build, 2: export, build and preview)
*
* @return the level
*/
public short getProcessingLevel() {
return nLevel;
}
/** Define an external application
* @param sAppName the name of the application to define
@ -175,7 +198,10 @@ public class ExternalApps {
return;
}
XMultiHierarchicalPropertySet xProps = (XMultiHierarchicalPropertySet)
XPropertySet xSimpleProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,view);
nLevel = XPropertySetHelper.getPropertyValueAsShort(xSimpleProps,"AfterExport");
XMultiHierarchicalPropertySet xProps = (XMultiHierarchicalPropertySet)
UnoRuntime.queryInterface(XMultiHierarchicalPropertySet.class, view);
for (int i=0; i<sApps.length; i++) {
String[] sNames = new String[2];
@ -205,6 +231,9 @@ public class ExternalApps {
// Give up...
return;
}
XPropertySet xSimpleProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,view);
XPropertySetHelper.setPropertyValue(xSimpleProps, "AfterExport", nLevel);
XMultiHierarchicalPropertySet xProps = (XMultiHierarchicalPropertySet)
UnoRuntime.queryInterface(XMultiHierarchicalPropertySet.class, view);

View file

@ -16,11 +16,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
* Copyright: 2002-2010 by Henrik Just
* Copyright: 2002-2015 by Henrik Just
*
* All Rights Reserved.
*
* Version 1.2 (2011-01-25)
* Version 1.6 (2015-05-14)
*
*/
@ -67,15 +67,15 @@ public final class TeXify {
ExternalApps.XELATEX, ExternalApps.MAKEINDEX, ExternalApps.XELATEX };
// Global objects
//private XComponentContext xContext;
private ExternalApps externalApps;
public TeXify(XComponentContext xContext) {
//this.xContext = xContext;
externalApps = new ExternalApps(xContext);
}
/** Process a document
/** Process a document. This will either (depending on the registry settings) do nothing, build with LaTeX
* or build with LaTeX and preview
*
* @param file the LaTeX file to process
* @param sBibinputs value for the BIBINPUTS environment variable (or null if it should not be extended)
* @param nBackend the desired backend format (generic, dvips, pdftex)
@ -94,45 +94,48 @@ public final class TeXify {
externalApps.load();
// Process LaTeX document
boolean bResult = false;
if (nBackend==GENERIC) {
bResult = doTeXify(genericTexify, file, sBibinputs);
if (!bResult) return false;
if (externalApps.execute(ExternalApps.DVIVIEWER,
new File(file.getParentFile(),file.getName()+".dvi").getPath(),
file.getParentFile(), null, false)>0) {
throw new IOException("Error executing dvi viewer");
}
if (externalApps.getProcessingLevel()>=ExternalApps.BUILD) {
boolean bPreview = externalApps.getProcessingLevel()>=ExternalApps.PREVIEW;
boolean bResult = false;
if (nBackend==GENERIC) {
bResult = doTeXify(genericTexify, file, sBibinputs);
if (!bResult) return false;
if (bPreview && externalApps.execute(ExternalApps.DVIVIEWER,
new File(file.getParentFile(),file.getName()+".dvi").getPath(),
file.getParentFile(), null, false)>0) {
throw new IOException("Error executing dvi viewer");
}
}
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(),
file.getParentFile(), null, false)>0) {
throw new IOException("Error executing pdf viewer");
}
}
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(),
file.getParentFile(), null, false)>0) {
throw new IOException("Error executing postscript viewer");
}
}
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(),
file.getParentFile(), null, false)>0) {
throw new IOException("Error executing pdf viewer");
}
}
return bResult;
}
else if (nBackend==PDFTEX) {
bResult = doTeXify(pdfTexify, file, sBibinputs);
if (!bResult) return false;
if (externalApps.execute(ExternalApps.PDFVIEWER,
new File(file.getParentFile(),file.getName()+".pdf").getPath(),
file.getParentFile(), null, false)>0) {
throw new IOException("Error executing pdf viewer");
}
}
else if (nBackend==DVIPS) {
bResult = doTeXify(dvipsTexify, file, sBibinputs);
if (!bResult) return false;
if (externalApps.execute(ExternalApps.POSTSCRIPTVIEWER,
new File(file.getParentFile(),file.getName()+".ps").getPath(),
file.getParentFile(), null, false)>0) {
throw new IOException("Error executing postscript viewer");
}
}
else if (nBackend==XETEX) {
bResult = doTeXify(xeTexify, file, sBibinputs);
if (!bResult) return false;
if (externalApps.execute(ExternalApps.PDFVIEWER,
new File(file.getParentFile(),file.getName()+".pdf").getPath(),
file.getParentFile(), null, false)>0) {
throw new IOException("Error executing pdf viewer");
}
}
return bResult;
return true;
}
private boolean doTeXify(String[] sAppList, File file, String sBibinputs) throws IOException {