X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;ds=sidebyside;f=src%2Forg%2Fxwt%2FTemplate.java;h=324fea1b37057d8233a5a9207a9add789f58b9fc;hb=66fa691f3f037006be09e5abfe747bcbbe4fe2c1;hp=7ff09ce1033ab932484760c98a4b9804303c8f76;hpb=fea7f27cc252c8feaafb8a5c0d4b9f391f03975d;p=org.ibex.core.git
diff --git a/src/org/xwt/Template.java b/src/org/xwt/Template.java
index 7ff09ce..324fea1 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()]);
@@ -492,9 +535,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
@@ -526,11 +569,8 @@ public class Template {
boolean periodUsed = false;
for(int j=0; j