summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWang@YueqianWang2011-09-14 04:33:05 (EDT)
committer xgu2011-10-25 02:10:04 (EDT)
commit1a68ace7a851b3f61e8161682422df016e25e8e0 (patch)
treea02214d2d2061adad0c14e5621656022e6801e65
parent5ebab97f34384b4fa68e24e9a33e939f9dd7f597 (diff)
downloadorg.eclipse.birt-1a68ace7a851b3f61e8161682422df016e25e8e0.zip
org.eclipse.birt-1a68ace7a851b3f61e8161682422df016e25e8e0.tar.gz
org.eclipse.birt-1a68ace7a851b3f61e8161682422df016e25e8e0.tar.bz2
Fix Ted 43587 Fix the line number for variable elements. Add a new test case for the fix.
-rw-r--r--model/org.eclipse.birt.report.model.tests/test/org/eclipse/birt/report/model/parser/ReportDesignParseTest.java10
-rw-r--r--model/org.eclipse.birt.report.model.tests/test/org/eclipse/birt/report/model/parser/input/LineNumberParseTest.xml10
-rw-r--r--model/org.eclipse.birt.report.model/src/org/eclipse/birt/report/model/util/LineNumberInfo.java17
3 files changed, 33 insertions, 4 deletions
diff --git a/model/org.eclipse.birt.report.model.tests/test/org/eclipse/birt/report/model/parser/ReportDesignParseTest.java b/model/org.eclipse.birt.report.model.tests/test/org/eclipse/birt/report/model/parser/ReportDesignParseTest.java
index 901c7e6..a8215b0 100644
--- a/model/org.eclipse.birt.report.model.tests/test/org/eclipse/birt/report/model/parser/ReportDesignParseTest.java
+++ b/model/org.eclipse.birt.report.model.tests/test/org/eclipse/birt/report/model/parser/ReportDesignParseTest.java
@@ -1034,7 +1034,15 @@ public class ReportDesignParseTest extends BaseTestCase
assertEquals( 451, designHandle.getLineNo( attr ) );
propHandle = cubeHandle.getPropertyHandle( ICubeModel.MEASURE_GROUPS_PROP );
- assertEquals( 463, designHandle.getLineNo( propHandle ) );
+ assertEquals( 463, designHandle.getLineNo( propHandle ) );
+
+ List<VariableElementHandle> variables = designHandle.getPageVariables( );
+ assertEquals( "report", variables.get( 0 ).getName( ) );
+ assertEquals( 477, designHandle.getLineNo( variables.get( 0 ) ) );
+
+ assertEquals( "page", variables.get( 1 ).getName( ) );
+ assertEquals( 480, designHandle.getLineNo( variables.get( 1 ) ) );
+
}
/**
diff --git a/model/org.eclipse.birt.report.model.tests/test/org/eclipse/birt/report/model/parser/input/LineNumberParseTest.xml b/model/org.eclipse.birt.report.model.tests/test/org/eclipse/birt/report/model/parser/input/LineNumberParseTest.xml
index 2baa97f..7f7d521 100644
--- a/model/org.eclipse.birt.report.model.tests/test/org/eclipse/birt/report/model/parser/input/LineNumberParseTest.xml
+++ b/model/org.eclipse.birt.report.model.tests/test/org/eclipse/birt/report/model/parser/input/LineNumberParseTest.xml
@@ -472,5 +472,13 @@ from CLASSICMODELS.OFFICES</property>
</property>
<property name="dataSet">Data Set</property>
</tabular-cube>
- </cubes>
+ </cubes>
+ <property name="pageVariables">
+ <variable-element name="report">
+ <property name="type">report</property>
+ </variable-element>
+ <variable-element name="page">
+ <property name="type">page</property>
+ </variable-element>
+ </property>
</report>
diff --git a/model/org.eclipse.birt.report.model/src/org/eclipse/birt/report/model/util/LineNumberInfo.java b/model/org.eclipse.birt.report.model/src/org/eclipse/birt/report/model/util/LineNumberInfo.java
index 21be946..5033bb5 100644
--- a/model/org.eclipse.birt.report.model/src/org/eclipse/birt/report/model/util/LineNumberInfo.java
+++ b/model/org.eclipse.birt.report.model/src/org/eclipse/birt/report/model/util/LineNumberInfo.java
@@ -32,6 +32,7 @@ import org.eclipse.birt.report.model.core.Module;
import org.eclipse.birt.report.model.core.Structure;
import org.eclipse.birt.report.model.elements.Library;
import org.eclipse.birt.report.model.elements.Theme;
+import org.eclipse.birt.report.model.elements.VariableElement;
import org.eclipse.birt.report.model.metadata.PropertyDefn;
/**
@@ -99,6 +100,12 @@ public class LineNumberInfo
private Map<String, Integer> includedCssStyleSheetStructMap = null;
/**
+ * Hash map for the <code>Variable</code> elements namespace. Key is
+ * the file name of the variable element.
+ */
+ private Map<String, Integer> variablesMap = null;
+
+ /**
* The line number for theme property in report design.
*/
@@ -118,6 +125,7 @@ public class LineNumberInfo
embeddedImageStructMap = Collections.synchronizedMap( new HashMap<String, Integer>( ) );
includedCssStyleSheetStructMap = Collections.synchronizedMap( new HashMap<String, Integer>( ) );
xpathMap = Collections.synchronizedMap( new HashMap<String, Integer>( ) );
+ variablesMap = Collections.synchronizedMap( new HashMap<String, Integer>( ) );
}
/**
@@ -140,8 +148,11 @@ public class LineNumberInfo
}
else if ( obj instanceof DesignElement )
{
- elementMap.put( Long.valueOf( ( (DesignElement) obj ).getID( ) ),
- lineNo );
+ if ( obj instanceof VariableElement )
+ variablesMap.put( ( (VariableElement) obj ).getName( ), lineNo );
+ else
+ elementMap.put( Long.valueOf( ( (DesignElement) obj ).getID( ) ),
+ lineNo );
}
else if ( obj instanceof IStructure )
{
@@ -234,6 +245,8 @@ public class LineNumberInfo
}
else if ( obj instanceof DesignElement )
{
+ if ( obj instanceof VariableElement )
+ return variablesMap.get( ( (VariableElement) obj ).getName( ) );
return getElementLineNo( ( (DesignElement) obj ).getID( ) );
}
else if ( obj instanceof StructureHandle )