A few minor W2X and W4L changes

git-svn-id: svn://svn.code.sf.net/p/writer2latex/code/trunk@99 f0f2a975-2e09-46c8-9428-3b39399b9f3c
This commit is contained in:
henrikjust 2011-03-16 08:58:30 +00:00
parent 028e30afb6
commit 4ecd5ede1e
5 changed files with 57 additions and 44 deletions

View file

@ -135,6 +135,9 @@ 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");
aux.delete();
for (int i=0; i<sAppList.length; i++) {
// Execute external application
Map<String,String> env =null;

View file

@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
* Version 1.2 (2011-02-01)
* Version 1.2 (2011-03-10)
*
*/
@ -30,6 +30,7 @@ import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.regex.Pattern;
import com.sun.star.beans.PropertyValue;
import com.sun.star.beans.XPropertyAccess;
@ -157,13 +158,8 @@ public final class Writer4LaTeX extends WeakBase
com.sun.star.beans.PropertyValue[] aArguments ) {
if ( aURL.Protocol.compareTo(PROTOCOL) == 0 ) {
if ( aURL.Path.compareTo("ProcessDocument") == 0 ) {
if (updateLocation()) {
if (updateMediaProperties()) {
process();
}
}
else {
warnNotSaved();
if (updateLocation() && updateMediaProperties()) {
process();
}
return;
}
@ -172,9 +168,6 @@ public final class Writer4LaTeX extends WeakBase
updateMediaPropertiesSilent();
process();
}
else {
warnNotSaved();
}
return;
}
else if ( aURL.Path.compareTo("ViewLog") == 0 ) {
@ -345,10 +338,6 @@ public final class Writer4LaTeX extends WeakBase
catch (com.sun.star.uno.Exception e) {
}
}
else {
warnNotSaved();
}
}
// Some utility methods
@ -560,36 +549,49 @@ public final class Writer4LaTeX extends WeakBase
private boolean updateLocation() {
String sDocumentUrl = xModel.getURL();
if (sDocumentUrl.length()!=0) {
// Get the file name (without extension)
File f = urlToFile(sDocumentUrl);
sBaseFileName = f.getName();
int iDot = sBaseFileName.lastIndexOf(".");
if (iDot>-1) { // remove extension
sBaseFileName = sBaseFileName.substring(0,iDot);
}
sBaseFileName=makeTeXSafe(sBaseFileName);
if (sDocumentUrl.startsWith("file:")) {
if (System.getProperty("os.name").startsWith("Windows")) {
Pattern windowsPattern = Pattern.compile("^file:///[A-Za-z][|:]");
if (!windowsPattern.matcher(sDocumentUrl).matches()) {
MessageBox msgBox = new MessageBox(m_xContext, m_xFrame);
msgBox.showMessage("Please save the document on a location with a drive name!",
"LaTeX does not support UNC paths");
return false;
}
}
// Get the file name (without extension)
File f = urlToFile(sDocumentUrl);
sBaseFileName = f.getName();
int iDot = sBaseFileName.lastIndexOf(".");
if (iDot>-1) { // remove extension
sBaseFileName = sBaseFileName.substring(0,iDot);
}
sBaseFileName=makeTeXSafe(sBaseFileName);
// Get the path
int iSlash = sDocumentUrl.lastIndexOf("/");
if (iSlash>-1) {
sBasePath = sDocumentUrl.substring(0,iSlash+1);
}
else {
sBasePath = "";
}
return true;
// Get the path
int iSlash = sDocumentUrl.lastIndexOf("/");
if (iSlash>-1) {
sBasePath = sDocumentUrl.substring(0,iSlash+1);
}
else {
sBasePath = "";
}
return true;
}
else {
MessageBox msgBox = new MessageBox(m_xContext, m_xFrame);
msgBox.showMessage("Please save the document locally!","LaTeX does not support documents in remote storages");
return false;
}
}
else {
MessageBox msgBox = new MessageBox(m_xContext, m_xFrame);
msgBox.showMessage("Document not saved!","Please save the document before processing the file");
return false;
}
}
private void warnNotSaved() {
MessageBox msgBox = new MessageBox(m_xContext, m_xFrame);
msgBox.showMessage("Document not saved!","Please save the document before processing the file");
}
private String makeTeXSafe(String sArgument) {
String sResult = "";
for (int i=0; i<sArgument.length(); i++) {