// Methods to apply templates ////////////////////////////////////////////////////////
- private Template() { }
- private Template(InputStream is, String nodeName) throws XML.SAXException, IOException {
+ private Template(String nodeName) {
this.nodeName = nodeName;
cache.put(nodeName, this);
+ }
+ private Template(InputStream is, String nodeName) throws XML.SAXException, IOException {
+ this(nodeName);
new TemplateHelper().parseit(is, this);
}
}
/** adds a theme mapping, retemplatizing as needed */
- public static void retheme(String from, String to) {
- if (Log.on) Log.log(Template.class, "retheming from " + from + " to " + to);
+ public static void retheme(Function callback) {
XWF.flushXWFs();
- Resources.mapFrom.addElement(from);
- Resources.mapTo.addElement(to);
// clear changed marker and relink
Template[] t = new Template[cache.size()];
Box b = ((Surface)Surface.allSurfaces.elementAt(i)).root;
if (b != null) reapply(b);
}
+
+ if (callback != null)
+ try {
+ callback.call(Context.enter(), null, null, new Object[] { new Double(1.0), new Double(1.0) });
+ } catch (EcmaError ex) {
+ if (Log.on) Log.log(Template.class, "WARNING: uncaught interpreter exception: " + ex.getMessage());
+ if (Log.on) Log.log(Template.class, " thrown from within progress callback at " + ex.getSourceName() + ":" + ex.getLineNumber());
+ } catch (JavaScriptException ex) {
+ if (Log.on) Log.log(Template.class, "WARNING: uncaught ecmascript exception: " + ex.getMessage());
+ if (Log.on) Log.log(Template.class, " thrown from within progress callback at " + ex.sourceFile + ":" + ex.line);
+ }
}
/** template reapplication procedure */
if (t != b.template) retemplatize = true;
b.template = t;
}
- if (b.template != null && b.template.changed)
- retemplatize = true;
+ if (b.template != null && b.template.changed) retemplatize = true;
if (retemplatize) {
nodeStack.addElement(t);
// instantiate a new node, and set its nodeName/importlist/preapply
- Template t2 = new Template();
- t2.nodeName = t.nodeName + "." + t.childvect.size();
+ Template t2 = new Template(t.nodeName + "." + t.childvect.size());
t2.importlist = t.importlist;
t2.startLine = line;
if (!name.equals("box")) t2.preapply = new String[] { name };