X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2FTemplate.java;h=f345718c1cafea86cfc0037c4594fc0242ae8f6c;hb=a0ab2df6a0936518dfb69945d50d6238cc40da91;hp=e2eb037c716dc250c0ae57642c0355dcd37f1801;hpb=0fa842b9ea3e4010fa8c6d1d9417ea32509dbe5f;p=org.ibex.core.git diff --git a/src/org/xwt/Template.java b/src/org/xwt/Template.java index e2eb037..f345718 100644 --- a/src/org/xwt/Template.java +++ b/src/org/xwt/Template.java @@ -90,6 +90,8 @@ public class Template { /** number of lines in content */ private int content_lines = 0; + /** the line number that this element starts on */ + private int startLine = -1; // Static data/methods /////////////////////////////////////////////////////////////////// @@ -137,10 +139,12 @@ public class Template { // 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); } @@ -161,7 +165,9 @@ public class Template { * @param pboxes a vector of all box parents on which to put $-references * @param ptemplates a vector of the nodeNames to recieve private references on the pboxes */ - void apply(Box b, Vec pboxes, Vec ptemplates) { + void apply(Box b, Vec pboxes, Vec ptemplates, Function callback, int numerator, int denominator) { + + int original_numerator = numerator; if (pboxes == null) { pboxes = new Vec(); @@ -185,10 +191,15 @@ public class Template { link(); for(int i=0; _preapply != null && i<_preapply.length; i++) - if (_preapply[i] != null) _preapply[i].apply(b, null, null); + if (_preapply[i] != null) { + _preapply[i].apply(b, null, null, callback, numerator, denominator); + numerator += _preapply[i].numUnits(); + } - for (int i=0; children != null && i 0) preapply.copyInto(t.preapply = new String[preapply.size()]); if (postapply.size() > 0) postapply.copyInto(t.postapply = new String[postapply.size()]); @@ -496,9 +527,9 @@ public class Template { 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 }; // make the new node the current node