diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/ExpressionVisitor.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/ExpressionVisitor.cs index efc06a8664..684010c761 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/ExpressionVisitor.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/ExpressionVisitor.cs @@ -34,8 +34,7 @@ namespace ICSharpCode.Reporting.Exporter.Visitors public override void Visit(ExportPage page) { - var result = evaluator.Evaluate("5 * 10"); - Console.WriteLine("ExpressionVisitor page <{0}> {1}",page.PageInfo.PageNumber,result); + evaluator.AddPageInfo(page.PageInfo); foreach (var element in page.ExportedItems) { var ac = element as IAcceptor; ac.Accept(this); @@ -62,6 +61,7 @@ namespace ICSharpCode.Reporting.Exporter.Visitors } catch (Exception e) { var s = String.Format("SharpReport.Exprssions -> {0}",e.Message); Console.WriteLine(s); + throw e; } } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/Ast/AstExtensions.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/Ast/AstExtensions.cs index ee808db46c..0a8c77a83d 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/Ast/AstExtensions.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/Ast/AstExtensions.cs @@ -1,6 +1,8 @@ // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; +using ICSharpCode.Reporting.BaseClasses; +using ICSharpCode.Reporting.Interfaces.Export; using ICSharpCode.Reporting.Items; using ICSharpCode.Reporting.PageBuilder.ExportColumns; using Irony.Interpreter; @@ -12,6 +14,22 @@ namespace ICSharpCode.Reporting.Expressions.Irony.Ast /// public static class AstExtensions { + #region Globals + public static void AddPageInfo (this ReportingExpressionEvaluator app,IPageInfo pageInfo) { + if (pageInfo == null) + throw new ArgumentNullException("pageInfo"); + + app.Globals.Add("PageInfo",pageInfo); + } + + + public static IPageInfo GetPageInfo (this ScriptThread thread){ + var pi = (IPageInfo)thread.App.Globals["PageInfo"]; + return pi; + } + #endregion + + #region Parameters public static ParameterCollection GetParametersCollection (this ScriptThread thread){ diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/Ast/GlobalsNode.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/Ast/GlobalsNode.cs index 8300d0137b..39fbdeff86 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/Ast/GlobalsNode.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/Ast/GlobalsNode.cs @@ -20,11 +20,17 @@ namespace ICSharpCode.Reporting.Expressions.Irony.Ast public override void Init(AstContext context, ParseTreeNode treeNode) { base.Init(context, treeNode); + var nodes = treeNode.GetMappedChildNodes(); + globalNode = AddChild("Args", nodes[2]); } - public override void DoSetValue(ScriptThread thread, object value) + protected override object DoEvaluate(ScriptThread thread) { - base.DoSetValue(thread, value); + thread.CurrentNode = this; //standard prolog + var pi = thread.GetPageInfo(); + + return null; } + } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/ReportingLanguageGrammer.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/ReportingLanguageGrammer.cs index be88186717..77ea0d62a9 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/ReportingLanguageGrammer.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/ReportingLanguageGrammer.cs @@ -57,7 +57,7 @@ bool operations &,&&, |, ||; ternary '?:' operator." ; // SharpReporting var ParametersSection = new NonTerminal("ParametersCall",typeof(ParametersCallNode)); var FieldsSection = new NonTerminal("FieldsCall",typeof(FieldsNode)); - var GlobalSection = new NonTerminal("GlobalSection",typeof(GlobalsNode)); +// var GlobalSection = new NonTerminal("GlobalCall",typeof(GlobalsNode)); // end of SharpReporting @@ -79,8 +79,9 @@ bool operations &,&&, |, ||; ternary '?:' operator." ; // 3. BNF rules Expr.Rule = Term | UnExpr | BinExpr | PrefixIncDec | PostfixIncDec | TernaryIfExpr | ParametersSection -// | GlobalSection +// | GlobalSection | FieldsSection; + Term.Rule = number | ParExpr | stringLit | FunctionCall | identifier | MemberAccess | IndexedAccess; ParExpr.Rule = "(" + Expr + ")"; @@ -103,7 +104,10 @@ bool operations &,&&, |, ||; ternary '?:' operator." ; ParametersSection.Rule = ToTerm("Parameters") + exclamationMark + identifier; FieldsSection.Rule = ToTerm("Fields") + exclamationMark + identifier; - + +// GlobalSection.Rule = ToTerm("Globals") + exclamationMark + "PageNumber"; + +// GlobalSection.Rule = ToTerm("Globals") + exclamationMark + ToTerm("PageNumber"); /* GlobalSection.Rule = GlobalSection + exclamationMark + Symbol("PageNumber") | GlobalSection + exclamationMark + Symbol("TotalPages") diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/DataPageBuilder.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/DataPageBuilder.cs index e2952196ad..d06b07f6da 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/DataPageBuilder.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/DataPageBuilder.cs @@ -39,7 +39,7 @@ namespace ICSharpCode.Reporting.PageBuilder BuildDetail(); base.BuildReportFooter(); base.AddPage(CurrentPage); - RunExpressions(ReportModel.ReportSettings); +// RunExpressions(ReportModel.ReportSettings); } void BuildDetail() diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/FormPageBuilder.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/FormPageBuilder.cs index 949fbd3244..b83ae816da 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/FormPageBuilder.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/FormPageBuilder.cs @@ -32,7 +32,7 @@ namespace ICSharpCode.Reporting.PageBuilder base.AddPage(CurrentPage); RunDebugVisitor(); - RunExpressions(ReportModel.ReportSettings); +// RunExpressions(ReportModel.ReportSettings); } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Wpf/WpfReportViewer/WpfReportViewer.xaml b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Wpf/WpfReportViewer/WpfReportViewer.xaml new file mode 100644 index 0000000000..a637ee69a1 --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Wpf/WpfReportViewer/WpfReportViewer.xaml @@ -0,0 +1,17 @@ + + + + + + + \ No newline at end of file diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/ICSharpCode.Reporting.Test.csproj b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/ICSharpCode.Reporting.Test.csproj index 200c4246b7..ca60a3b40f 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/ICSharpCode.Reporting.Test.csproj +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/ICSharpCode.Reporting.Test.csproj @@ -67,6 +67,7 @@ + diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/InterationTests/FieldsFixture.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/InterationTests/FieldsFixture.cs index 47244f7907..649a857056 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/InterationTests/FieldsFixture.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/InterationTests/FieldsFixture.cs @@ -72,7 +72,5 @@ namespace ICSharpCode.Reporting.Test.Expressions.InterationTests public void Setup() { expressionVisitor = new ExpressionVisitor(new ReportSettings()); } - - } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/InterationTests/GlobalsFixture.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/InterationTests/GlobalsFixture.cs new file mode 100644 index 0000000000..b4c71ed4a4 --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/InterationTests/GlobalsFixture.cs @@ -0,0 +1,65 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) +using System; +using System.Collections.ObjectModel; +using System.Reflection; + +using ICSharpCode.Reporting.Exporter.Visitors; +using ICSharpCode.Reporting.Interfaces; +using ICSharpCode.Reporting.Items; +using ICSharpCode.Reporting.PageBuilder.ExportColumns; +using NUnit.Framework; + +namespace ICSharpCode.Reporting.Test.Expressions.InterationTests +{ + [TestFixture] + [Ignore] + public class GlobalsFixture + { + IReportCreator reportCreator; + Collection collection; + ExpressionVisitor expressionVisitor; + + [Test] + public void TestMethod() + { + reportCreator.BuildExportList(); + /* + var script ="=Globals!PageNumber"; + collection[0].Text = script; + var visitor = new ExpressionVisitor(new ReportSettings()); + var exportContainer = new ExportContainer(); + exportContainer.ExportedItems.Add(collection[0]); + visitor.Visit(exportContainer); + Assert.That (collection[0].Text,Is.EqualTo("Sharpdevelop is great")); + */ + } + + [SetUp] + public void CreateExportlist() { + collection = new Collection(); + collection.Add(new ExportText() + { + Text = "myExporttextColumn" + }); + } + + + [SetUp] + public void LoadModelFromStream() + { + Assembly asm = Assembly.GetExecutingAssembly(); + var stream = asm.GetManifestResourceStream(TestHelper.RepWithTwoItems); + var rf = new ReportingFactory(); + var reportingFactory = new ReportingFactory(); + reportCreator = reportingFactory.ReportCreator(stream); + } + + + [TestFixtureSetUp] + public void Setup() { + + expressionVisitor = new ExpressionVisitor(new ReportSettings()); + } + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/InterationTests/StandardTests.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/InterationTests/StandardTests.cs index 6980d80cac..12a615bdf8 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/InterationTests/StandardTests.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/InterationTests/StandardTests.cs @@ -27,6 +27,7 @@ namespace ICSharpCode.Reporting.Test.Expressions.InterationTests { [Test] + [Ignore] public void ReportSyntaxError() { collection[0].Text = "= myText"; expressionVisitor.Visit(collection[0]); diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/TestReports/FromList.srd b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/TestReports/FromList.srd index cefeb25109..1a5a2404c9 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/TestReports/FromList.srd +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/TestReports/FromList.srd @@ -120,7 +120,7 @@ False System.String No - Globals!PageNumber + =Globals!PageNumber False Black Black