diff --git a/source/distro/changelog.txt b/source/distro/changelog.txt
index f39408b..7e0fab3 100644
--- a/source/distro/changelog.txt
+++ b/source/distro/changelog.txt
@@ -4,6 +4,8 @@ Changelog for Writer2LaTeX version 1.4 -> 1.6
Items marked with * are work in progress
+[w2x] The template page in the configuration now displays an error message if the template is not well-formed XML.
+
[w2x] Added toolbar configuration dialog: Select XHTML and EPUB export format and behavior after export (do nothing,
display in default viewer or display with custom application)
diff --git a/source/java/org/openoffice/da/comp/w2lcommon/filter/ConfigurationDialogBase.java b/source/java/org/openoffice/da/comp/w2lcommon/filter/ConfigurationDialogBase.java
index ce2ed2f..fb43264 100644
--- a/source/java/org/openoffice/da/comp/w2lcommon/filter/ConfigurationDialogBase.java
+++ b/source/java/org/openoffice/da/comp/w2lcommon/filter/ConfigurationDialogBase.java
@@ -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.4 (2014-09-16)
+* Version 1.5 (2015-04-09)
*
*/
@@ -329,7 +329,7 @@ public abstract class ConfigurationDialogBase extends WeakBase implements XConta
public CustomFileHandler() {
super();
try {
- sCustomFileName = xPathSub.substituteVariables("$(user)/"+getFileName(), false);
+ sCustomFileName = xPathSub.substituteVariables("$(user)/"+getFileName(), false);
}
catch (NoSuchElementException e) {
sCustomFileName = getFileName();
@@ -392,7 +392,7 @@ public abstract class ConfigurationDialogBase extends WeakBase implements XConta
useCustomInner(dlg,bUseCustom);
}
- private void loadCustomClick(DialogAccess dlg) {
+ protected void loadCustomClick(DialogAccess dlg) {
String sFileName=filePicker.getPath();
if (sFileName!=null) {
String sText = loadFile(sFileName);
diff --git a/source/java/org/openoffice/da/comp/writer2xhtml/ConfigurationDialog.java b/source/java/org/openoffice/da/comp/writer2xhtml/ConfigurationDialog.java
index 438331c..a429e2a 100644
--- a/source/java/org/openoffice/da/comp/writer2xhtml/ConfigurationDialog.java
+++ b/source/java/org/openoffice/da/comp/writer2xhtml/ConfigurationDialog.java
@@ -20,16 +20,20 @@
*
* All Rights Reserved.
*
-* Version 1.6 (2015-01-14)
+* Version 1.6 (2015-04-09)
*
*/
package org.openoffice.da.comp.writer2xhtml;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
import java.util.Map;
import org.openoffice.da.comp.w2lcommon.filter.ConfigurationDialogBase;
import org.openoffice.da.comp.w2lcommon.helper.DialogAccess;
+import writer2latex.api.Converter;
+import writer2latex.api.ConverterFactory;
import com.sun.star.container.NoSuchElementException;
import com.sun.star.lang.XServiceInfo;
@@ -95,7 +99,7 @@ public class ConfigurationDialog extends ConfigurationDialogBase implements XSer
// Implement remaining method from XContainerWindowEventHandler
public String[] getSupportedMethodNames() {
String[] sNames = { "EncodingChange", // General
- "CustomTemplateChange", "LoadTemplateClick", // Template
+ "CustomTemplateChange", "LoadTemplateClick", "TemplateKeyup", // Template
"UseCustomStylesheetChange", "IncludeCustomStylesheetClick", "LoadStylesheetClick",
"NewResourceClick", "DeleteResourceClick", // Stylesheet
"StyleFamilyChange", "StyleNameChange", "NewStyleClick", "DeleteStyleClick", "LoadDefaultsClick" // Styles1
@@ -170,6 +174,7 @@ public class ConfigurationDialog extends ConfigurationDialogBase implements XSer
}
protected void useCustomInner(DialogAccess dlg, boolean bEnable) {
+ dlg.setControlEnabled("TestTemplateLabel", bEnable);
dlg.setControlEnabled("ContentIdLabel", bEnable);
dlg.setControlEnabled("ContentId", bEnable);
dlg.setControlEnabled("HeaderIdLabel", bEnable);
@@ -181,12 +186,15 @@ public class ConfigurationDialog extends ConfigurationDialogBase implements XSer
}
@Override protected void setControls(DialogAccess dlg) {
+ System.out.println("set controls");
super.setControls(dlg);
+ System.out.println("done setting controls");
String[] sCustomIds = config.getOption("template_ids").split(",");
if (sCustomIds.length>0) { dlg.setComboBoxText("ContentId", sCustomIds[0]); }
if (sCustomIds.length>1) { dlg.setComboBoxText("HeaderId", sCustomIds[1]); }
if (sCustomIds.length>2) { dlg.setComboBoxText("FooterId", sCustomIds[2]); }
if (sCustomIds.length>3) { dlg.setComboBoxText("PanelId", sCustomIds[3]); }
+ testTemplate(dlg);
}
@Override protected void getControls(DialogAccess dlg) {
@@ -198,6 +206,38 @@ public class ConfigurationDialog extends ConfigurationDialogBase implements XSer
dlg.getComboBoxText("PanelId").trim());
}
+ @Override protected boolean handleEvent(DialogAccess dlg, String sMethod) {
+ if (super.handleEvent(dlg, sMethod)) {
+ return true;
+ }
+ if (sMethod.equals("TemplateKeyup")) {
+ testTemplate(dlg);
+ return true;
+ }
+ return false;
+ }
+
+ @Override protected void loadCustomClick(DialogAccess dlg) {
+ super.loadCustomClick(dlg);
+ testTemplate(dlg);
+ }
+
+ private void testTemplate(DialogAccess dlg) {
+ Converter converter = ConverterFactory.createConverter("text/html");
+ String sTemplate = dlg.getTextFieldText("CustomTemplate").trim();
+ if (sTemplate.length()>0) { // Only display error message if there is content
+ try {
+ converter.readTemplate(new ByteArrayInputStream(sTemplate.getBytes()));
+ dlg.setLabelText("TestTemplateLabel", "");
+ } catch (IOException e) {
+ dlg.setLabelText("TestTemplateLabel", "ERROR: "+e.getMessage());
+ }
+ }
+ else {
+ dlg.setLabelText("TestTemplateLabel", "");
+ }
+ }
+
}
private class StylesheetsHandler extends CustomFileHandler {
diff --git a/source/java/writer2latex/api/ConverterFactory.java b/source/java/writer2latex/api/ConverterFactory.java
index b7fa4dc..4653682 100644
--- a/source/java/writer2latex/api/ConverterFactory.java
+++ b/source/java/writer2latex/api/ConverterFactory.java
@@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
- * Version 1.6 (2015-04-01)
+ * Version 1.6 (2015-04-09)
*
*/
@@ -33,7 +33,7 @@ public class ConverterFactory {
// Version information
private static final String VERSION = "1.5.2";
- private static final String DATE = "2015-04-01";
+ private static final String DATE = "2015-04-09";
/** Return the Writer2LaTeX version in the form
* (major version).(minor version).(patch level)
diff --git a/source/oxt/writer2xhtml/W2XDialogs2/Template.xdl b/source/oxt/writer2xhtml/W2XDialogs2/Template.xdl
index b56027e..78ff5ff 100644
--- a/source/oxt/writer2xhtml/W2XDialogs2/Template.xdl
+++ b/source/oxt/writer2xhtml/W2XDialogs2/Template.xdl
@@ -1,34 +1,40 @@
+
+
+
-
+
+
+
-
-
+
+
+
-
-
+
+
-
-
+
+
-
-
+
+
diff --git a/source/oxt/writer2xhtml/help/en/org.openoffice.da.writer2xhtml.oxt/Configuration/Template.xhp b/source/oxt/writer2xhtml/help/en/org.openoffice.da.writer2xhtml.oxt/Configuration/Template.xhp
index 7deb74a..4533423 100644
--- a/source/oxt/writer2xhtml/help/en/org.openoffice.da.writer2xhtml.oxt/Configuration/Template.xhp
+++ b/source/oxt/writer2xhtml/help/en/org.openoffice.da.writer2xhtml.oxt/Configuration/Template.xhp
@@ -39,6 +39,8 @@
You can change the names of the id attributes at the bottom of this page.
+ The template must be well-formed XML. If this is not the case, an error message
+ is displayed below the template. A template with errors will be ignored in the export.
A simple template including a header might look like this:
<html>