Writer2xhtml custom config ui

git-svn-id: svn://svn.code.sf.net/p/writer2latex/code/trunk@58 f0f2a975-2e09-46c8-9428-3b39399b9f3c
This commit is contained in:
henrikjust 2010-04-12 19:39:01 +00:00
parent 977a2f7d6b
commit 93d1e472c6
9 changed files with 229 additions and 20 deletions

View file

@ -16,11 +16,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
* Copyright: 2002-2008 by Henrik Just
* Copyright: 2002-2010 by Henrik Just
*
* All Rights Reserved.
*
* Version 1.0 (2008-11-22)
* Version 1.2 (2010-04-12)
*
*/
@ -108,7 +108,7 @@ public class FilterDataParser {
PropertyHelper props = new PropertyHelper(filterData);
// Get the special properties TemplateURL, ConfigURL and AutoCreate
// Get the special properties TemplateURL, StyleSheetURL, ConfigURL and AutoCreate
Object tpl = props.get("TemplateURL");
String sTemplate = null;
if (tpl!=null && AnyConverter.isString(tpl)) {
@ -120,6 +120,17 @@ public class FilterDataParser {
}
}
Object styles = props.get("StyleSheetURL");
String sStyleSheet = null;
if (styles!=null && AnyConverter.isString(styles)) {
try {
sStyleSheet = substituteVariables(AnyConverter.toString(styles));
}
catch (com.sun.star.lang.IllegalArgumentException e) {
// Failed to convert to String; should not happen - ignore
}
}
Object auto = props.get("AutoCreate");
boolean bAutoCreate = false;
if (auto!=null && AnyConverter.isString(auto)) {
@ -169,6 +180,31 @@ public class FilterDataParser {
}
}
// Load the style sheet from the specified URL, if any
if (sfa2!=null && sStyleSheet!=null && sStyleSheet.length()>0) {
try {
XInputStream xIs = sfa2.openFileRead(sStyleSheet);
if (xIs!=null) {
InputStream is = new XInputStreamToInputStreamAdapter(xIs);
converter.readStyleSheet(is);
is.close();
xIs.closeInput();
}
}
catch (IOException e) {
// ignore
}
catch (NotConnectedException e) {
// ignore
}
catch (CommandAbortedException e) {
// ignore
}
catch (com.sun.star.uno.Exception e) {
// ignore
}
}
// Create config if required
try {
if (bAutoCreate && sfa2!=null && sConfig!=null && !sConfig.startsWith("*") && !sfa2.exists(sConfig)) {
@ -235,7 +271,7 @@ public class FilterDataParser {
Enumeration<String> keys = props.keys();
while (keys.hasMoreElements()) {
String sKey = keys.nextElement();
if (!"ConfigURL".equals(sKey) && !"TemplateURL".equals(sKey) && !"AutoCreate".equals(sKey)) {
if (!"ConfigURL".equals(sKey) && !"TemplateURL".equals(sKey) && !"StyleSheetURL".equals(sKey) && !"AutoCreate".equals(sKey)) {
Object value = props.get(sKey);
if (AnyConverter.isString(value)) {
try {

View file

@ -16,11 +16,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
* Copyright: 2002-2019 by Henrik Just
* Copyright: 2002-2010 by Henrik Just
*
* All Rights Reserved.
*
* Version 1.2 (2010-03-12)
* Version 1.2 (2010-04-12)
*
*/
@ -401,6 +401,7 @@ public abstract class OptionsDialogBase extends DialogBase implements
MacroExpander expander = new MacroExpander(xContext);
filterData.put("ConfigURL",expander.expandMacros(XPropertySetHelper.getPropertyValueAsString(xCfgProps,"ConfigURL")));
filterData.put("TemplateURL",expander.expandMacros(XPropertySetHelper.getPropertyValueAsString(xCfgProps,"TargetTemplateURL")));
filterData.put("StyleSheetURL",expander.expandMacros(XPropertySetHelper.getPropertyValueAsString(xCfgProps,"StyleSheetURL")));
XPropertySetHelper.setPropertyValue(xProps,"ConfigName",sConfigNames[i]);
bFound = true;
}

View file

@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
* Version 1.2 (2010-04-11)
* Version 1.2 (2010-04-12)
*
*/
@ -109,13 +109,12 @@ public class XhtmlOptionsDialog extends OptionsDialogBase {
case 6:
case 7:
case 8: helper.put("ConfigURL","*cleanxhtml.xml");
helper.put("custom_stylesheet",
"http://www.w3.org/StyleSheets/Core/"+sCoreStyles[nConfig-1]);
helper.put("custom_stylesheet", "http://www.w3.org/StyleSheets/Core/"+sCoreStyles[nConfig-1]);
break;
case 9: helper.put("ConfigURL","$(user)/writer2xhtml.xml");
helper.put("AutoCreate","true");
helper.put("TemplateURL", "$(user)/writer2xhtml-template.xhtml");
//helper.put("StyleSheetURL", "$(user)/writer2xhtml-style.css");
helper.put("AutoCreate","true");
helper.put("StyleSheetURL", "$(user)/writer2xhtml-styles.css");
}
saveCheckBoxOption(xProps, helper, "ConvertToPx", "convert_to_px");