w2l log viewer improvements

git-svn-id: svn://svn.code.sf.net/p/writer2latex/code/trunk@221 f0f2a975-2e09-46c8-9428-3b39399b9f3c
This commit is contained in:
henrikjust 2014-11-24 10:56:12 +00:00
parent cdca675509
commit ceddd94461
7 changed files with 106 additions and 13 deletions

View file

@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
* Version 1.6 (2014-10-29)
* Version 1.6 (2014-11-20)
*
*/
@ -36,6 +36,7 @@ import java.net.URISyntaxException;
import com.sun.star.awt.XDialog;
import com.sun.star.uno.XComponentContext;
import org.openoffice.da.comp.w2lcommon.helper.DialogAccess;
import org.openoffice.da.comp.w2lcommon.helper.DialogBase;
/** This class provides a uno component which displays logfiles
@ -59,6 +60,7 @@ public class LogViewerDialog extends DialogBase
private String sBaseUrl = null;
private String sLaTeXLog = null;
private String sLaTeXErrors = null;
private String sBibTeXLog = null;
private String sMakeindexLog = null;
@ -71,6 +73,7 @@ public class LogViewerDialog extends DialogBase
public void initialize() {
if (sBaseUrl!=null) {
sLaTeXLog = readTextFile(sBaseUrl+".log");
sLaTeXErrors = errorFilter(sLaTeXLog);
sBibTeXLog = readTextFile(sBaseUrl+".blg");
sMakeindexLog = readTextFile(sBaseUrl+".ilg");
setComboBoxText("LogContents",sLaTeXLog);
@ -98,19 +101,27 @@ public class LogViewerDialog extends DialogBase
// Implement XDialogEventHandler
public boolean callHandlerMethod(XDialog xDialog, Object event, String sMethod) {
if (sMethod.equals("ViewLaTeXLog")) {
setComboBoxText("LogContents", sLaTeXLog);
setComboBoxText("LogContents",
getCheckBoxState("ErrorFilter")==DialogAccess.CHECKBOX_CHECKED ? sLaTeXErrors : sLaTeXLog);
setControlEnabled("ErrorFilter",true);
}
else if (sMethod.equals("ViewBibTeXLog")) {
setComboBoxText("LogContents", sBibTeXLog);
setControlEnabled("ErrorFilter",false);
}
else if (sMethod.equals("ViewMakeindexLog")) {
setComboBoxText("LogContents", sMakeindexLog);
setControlEnabled("ErrorFilter",false);
}
else if (sMethod.equals("ErrorFilterChange")) {
setComboBoxText("LogContents",
getCheckBoxState("ErrorFilter")==DialogAccess.CHECKBOX_CHECKED ? sLaTeXErrors : sLaTeXLog);
}
return true;
}
public String[] getSupportedMethodNames() {
String[] sNames = { "ViewLaTeXLog", "ViewBibTeXLog", "ViewMakeindexLog" };
String[] sNames = { "ViewLaTeXLog", "ViewBibTeXLog", "ViewMakeindexLog", "ErrorFilterChange" };
return sNames;
}
@ -139,6 +150,32 @@ public class LogViewerDialog extends DialogBase
}
return buf.toString();
}
// Extract errors from LaTeX log file only
private String errorFilter(String log) {
StringBuilder buf = new StringBuilder();
int nLen = log.length();
int nIndex = 0;
boolean bIncludeLines = false;
while (nIndex<nLen) {
int nNewline = log.indexOf('\n', nIndex);
if (nNewline==-1) nNewline = nLen;
if (nNewline-nIndex>1 && log.charAt(nIndex)=='!') {
bIncludeLines = true;
}
else if (nNewline==nIndex) {
if (bIncludeLines) {
buf.append('\n');
}
bIncludeLines = false;
}
if (bIncludeLines) {
buf.append(log.substring(nIndex,nNewline)).append('\n');
}
nIndex = nNewline+1;
}
return buf.toString();
}
}

View file

@ -187,9 +187,10 @@ public class MathConverter extends ConverterHelper {
if (onode.hasAttribute("xmlns:math")) {
math.setAttribute("xmlns", onode.getAttribute("xmlns:math"));
}
else if (onode.hasAttribute("xmlns")) {
else if (onode.hasAttribute("xmlns") && converter.nType!=XhtmlDocument.HTML5) {
// Don't include xmlns attribute in HTML5
math.setAttribute("xmlns", onode.getAttribute("xmlns"));
}
}
if (bAllowDisplay && onode.hasAttribute("display")) {
// Starting with version 4.2, LO exports display="block" for display equations
// This is a good thing, but in XHTML we can unfortunately only allow this for