Permalink
Browse files

Merge branch 'reports' of github.com:icsharpcode/SharpDevelop into re…

…ports
  • Loading branch information...
2 parents 7aeb621 + fa3fe08 commit 0973b205c8d30e5f28c554fe4bc57bab025bb3c5 @PeterForstmeier PeterForstmeier committed Jul 23, 2011
@@ -18,8 +18,6 @@ public class BasePager:IReportCreator
{
private PagesCollection pages;
private readonly object pageLock = new object();
-
-// private Point currentBottom;
public event EventHandler<PageCreatedEventArgs> PageCreated;
public event EventHandler<SectionRenderEventArgs> SectionRendering;
@@ -49,26 +47,35 @@ public BasePager(IReportModel reportModel)
#region Create and Init new page
-
- protected ExporterPage InitNewPage ()
+ protected void InitNewPage ()
{
bool firstPage;
- this.ReportModel.ReportSettings.LeftMargin = this.ReportModel.ReportSettings.LeftMargin;
+
if (this.Pages.Count == 0) {
firstPage = true;
} else {
firstPage = false;
}
- SectionBounds sectionBounds = new SectionBounds (this.ReportModel.ReportSettings,firstPage);
- ExporterPage sp = ExporterPage.CreateInstance(sectionBounds,this.pages.Count + 1);
- return sp;
+ this.ReportModel.ReportSettings.LeftMargin = this.ReportModel.ReportSettings.LeftMargin;
+ var sectionBounds = new SectionBounds (this.ReportModel.ReportSettings,firstPage);
+
+ this.SinglePage = ExporterPage.CreateInstance(sectionBounds,this.pages.Count + 1);
+
+ if (this.EvaluatorFacade == null)
+ {
+ Console.WriteLine ("");
+ Console.WriteLine ("InitNewPage create evaluator");
+ EvaluatorFacade = EvaluationHelper.CreateEvaluator(SinglePage,SinglePage.IDataNavigator);
+ }
+ EvaluatorFacade.SinglePage = this.SinglePage;
}
+
protected virtual void BuildNewPage ()
{
- this.SinglePage = this.InitNewPage();
+ InitNewPage();
PrintHelper.InitPage(this.SinglePage,this.ReportModel.ReportSettings);
this.SinglePage.CalculatePageBounds(this.ReportModel);
}
@@ -77,8 +84,6 @@ protected virtual void BuildNewPage ()
#region Converters
-
-
protected ExporterCollection ConvertSection (BaseSection section,int dataRow)
{
Point currentBottom = Point.Empty;
@@ -93,7 +98,91 @@ protected ExporterCollection ConvertSection (BaseSection section,int dataRow)
if (section.Items.Count > 0)
{
Size sectionSize = section.Size;
+
+ Rectangle desiredRectangle = LayoutHelper.CalculateSectionLayout(this.Graphics,section);
+ LayoutHelper.FixSectionLayout(desiredRectangle,section);
+ section.Items.SortByLocation();
+ GapList gapCalculator = new GapList();
+ gapCalculator.CalculateGapList(section);
+ int i = 0;
+
+ foreach (BaseReportItem item in section.Items)
+ {
+ ISimpleContainer simpleContainer = item as ISimpleContainer;
+
+ if (simpleContainer != null)
+ {
+ Offset = new Point(Offset.X,Offset.Y + gapCalculator.GapBetweenItems[i] );
+ var containerSize = simpleContainer.Size;
+
+ EvaluationHelper.EvaluateReportItems(EvaluatorFacade,simpleContainer.Items);
+
+ var layouter = (ILayouter)ServiceContainer.GetService(typeof(ILayouter));
+ LayoutHelper.SetLayoutForRow(Graphics,layouter, simpleContainer);
+ /*
+ * */
+
+
+ /*
+ section.Items.ForEach(delegate(BaseReportItem aitem)
+ {
+// Console.WriteLine(item.Location);
+ });
+ var h = section.Items.FindHighestElement();
+ */
+ section.MeasureOverride(section.Size);
+ /** */
+ Offset = BaseConverter.ConvertContainer(convertedSection,simpleContainer,Offset.X,Offset);
+ simpleContainer.Size = containerSize;
+ }
+ else
+ {
+ var converteditem = ExportHelper.ConvertLineItem(item,Offset);
+ if (converteditem != null) {
+ if (converteditem.StyleDecorator.DisplayRectangle.Bottom > currentBottom.Y) {
+ currentBottom = new Point(converteditem.StyleDecorator.Location.X,converteditem.StyleDecorator.DisplayRectangle.Bottom);
+ }
+
+ convertedSection.Add((BaseExportColumn)converteditem );
+
+ }
+// if (converteditem.StyleDecorator.DisplayRectangle.Bottom > currentBottom.Y) {
+// currentBottom = new Point(converteditem.StyleDecorator.Location.X,converteditem.StyleDecorator.DisplayRectangle.Bottom);
+// }
+//
+// convertedSection.Add((BaseExportColumn)converteditem );
+
+ }
+ i ++;
+ }
+ Offset = new Point (Offset.X,Offset.Y + gapCalculator.LastGap);
+// Offset = new Point (Offset.X,Offset.Y + 5);
+ if (currentBottom.Y > Offset.Y) {
+ Offset = new Point (Offset.X,currentBottom.Y);
+ }
+// Offset = new Point (Offset.X,Offset.Y + gapCalculator.LastGap);
+ }
+ SectionBounds.Offset = Offset;
+ return convertedSection;
+ }
+
+
+ protected ExporterCollection old_ConvertSection (BaseSection section,int dataRow)
+ {
+ Point currentBottom = Point.Empty;
+ FireSectionRenderEvent (section ,dataRow);
+ PrintHelper.AdjustParent(section,section.Items);
+ PrintHelper.AdjustSectionLocation(section);
+
+ var convertedSection = new ExporterCollection();
+ Offset = SectionBounds.Offset;
+ Point startOffset = Offset;
+
+ if (section.Items.Count > 0)
+ {
+ Size sectionSize = section.Size;
+ Console.WriteLine ("BasePager-createEval for {0}",section.Name);
IExpressionEvaluatorFacade evaluator = EvaluationHelper.CreateEvaluator(this.SinglePage,this.SinglePage.IDataNavigator);
Rectangle desiredRectangle = LayoutHelper.CalculateSectionLayout(this.Graphics,section);
@@ -220,6 +309,28 @@ protected void FinishRendering (IDataNavigator dataNavigator)
if (this.Pages.Count == 0) {
return;
}
+ Console.WriteLine ("FinishRendereing create IExpressionEvaluatorFacade");
+
+ //IExpressionEvaluatorFacade evaluatorFacade = new ExpressionEvaluatorFacade(this.SinglePage);
+ //Evaluator.SinglePage = this.SinglePage;
+ foreach (ExporterPage page in this.pages)
+ {
+ page.TotalPages = this.Pages.Count;
+// dataNavigator.Reset();
+// dataNavigator.MoveNext();
+ page.IDataNavigator = dataNavigator;
+ EvaluatorFacade.SinglePage = page;
+ EvaluateRecursive(EvaluatorFacade,page.Items);
+ }
+ }
+
+ /*
+ protected void FinishRendering (IDataNavigator dataNavigator)
+ {
+ if (this.Pages.Count == 0) {
+ return;
+ }
+ Console.WriteLine ("FinishRendereing create IExpressionEvaluatorFacade");
IExpressionEvaluatorFacade evaluatorFacade = new ExpressionEvaluatorFacade(this.SinglePage);
@@ -231,7 +342,7 @@ protected void FinishRendering (IDataNavigator dataNavigator)
EvaluateRecursive(evaluatorFacade,p.Items);
}
}
-
+ */
private static void EvaluateRecursive (IExpressionEvaluatorFacade evaluatorFassade,ExporterCollection items)
{
@@ -244,7 +355,6 @@ private static void EvaluateRecursive (IExpressionEvaluatorFacade evaluatorFassa
EvaluateRecursive(evaluatorFassade,ec.Items);
}
}
-
IReportExpression expressionItem = exportColumn as IReportExpression;
if (expressionItem != null) {
evaluatorFassade.Evaluate(expressionItem);
@@ -312,14 +422,17 @@ protected void DebugShowSections ()
protected Graphics Graphics {get; private set;}
+ protected IExpressionEvaluatorFacade EvaluatorFacade {get; private set;}
+
+ public IReportModel ReportModel {get;private set;}
+
+ protected ExporterPage SinglePage {get;private set;}
+
protected SectionBounds SectionBounds
{
get { return SinglePage.SectionBounds; }
}
- public IReportModel ReportModel {get;set;}
-
- protected ExporterPage SinglePage {get;set;}
public PagesCollection Pages
{
@@ -332,6 +445,7 @@ public PagesCollection Pages
}
}
}
+
#endregion
}
}
@@ -33,6 +33,7 @@ public static IExpressionEvaluatorFacade CreateEvaluator (ISinglePage singlePag
throw new ArgumentNullException("singlePage");
}
+ Console.WriteLine ("EvaluationHelper.CreateEvaluator");
singlePage.IDataNavigator = dataNavigator;
IExpressionEvaluatorFacade evaluatorFacade = new ExpressionEvaluatorFacade(singlePage);
return evaluatorFacade;
@@ -23,6 +23,7 @@ public class ExpressionEvaluatorFacade:IExpressionEvaluatorFacade
public ExpressionEvaluatorFacade(IPageInfo pageInfo)
{
+ Console.WriteLine("Eval-fassade Constr");
compiler = new ReportingLanguageCompiler();
this.context = new ExpressionContext(null);
context.ResolveUnknownVariable += VariableStore;
@@ -59,15 +60,15 @@ public string Evaluate (string expression, object row)
{
try {
string s = EvaluationHelper.ExtractExpressionPart(expression);
- if (s.Length > 0) {
+ if (s.Length > 0)
+ {
this.context.ContextObject = row;
return EvaluateExpression (s);
}
} catch (Exception e) {
expression = e.Message;
WriteLogMessage(e);
}
-
return expression;
}
@@ -248,66 +248,8 @@ public void DataRowCountEqualListCount ()
#endregion
- #region RangeEnumerator
- /*
- [Test]
- public void RangeEnumeratorFromBeginToEnd()
- {
- IDataManager dm = ICSharpCode.Reports.Core.DataManager.CreateInstance(this.contributorCollection,new ReportSettings());
- IDataNavigator dn = dm.GetNavigator;
- int start = 0;
- int end = 10;
- System.Collections.IEnumerator en = dn.RangeEnumerator(start,end);
-
- while (en.MoveNext()) {
- object o = en.Current;
- Contributor view = en.Current as Contributor;
- start++;
- }
- Assert.AreEqual(start -1,dn.CurrentRow);
- }
-
- [Test]
- public void RangeEnumeratFrom5To10 ()
- {
- IDataManager dm = ICSharpCode.Reports.Core.DataManager.CreateInstance(this.contributorCollection,
- new ReportSettings());
-
- IDataNavigator dn = dm.GetNavigator;
- int start = 5;
- int end = 10;
- System.Collections.IEnumerator en = dn.RangeEnumerator(start,end);
-
- while (en.MoveNext()) {
- object o = en.Current;
- //Contributor view = en.Current as Contributor;
- start++;
- }
- Assert.AreEqual(start -1,dn.CurrentRow);
- }
-
- [Test]
- [ExpectedException(typeof(ArgumentException))]
- public void RangeEnumeratorThrowExceptionIfStartGreateEnd ()
- {
- IDataManager dm = ICSharpCode.Reports.Core.DataManager.CreateInstance(this.contributorCollection,
- new ReportSettings());
- IDataNavigator dn = dm.GetNavigator;
- int start = 10;
- int end = 5;
- System.Collections.IEnumerator en = dn.RangeEnumerator(start,end);
- while (en.MoveNext()) {
- object o = en.Current;
- Contributor view = en.Current as Contributor;
- start++;
- }
- Assert.AreEqual(start -1,dn.CurrentRow);
- }
- */
- #endregion
#region get included class
-
ContributorCollection ModifyCollection ()
{
@@ -74,16 +74,10 @@ public void Count_Only_If_Matches()
Assert.That(this.evaluator.Evaluate(expression), Is.EqualTo("2"));
}
-// [Test]
-// [ExpectedException(typeof(FieldNotFoundException))]
-// public void Throw_On_Unknown_Field ()
-// {
-// const string expression = "=count(unknown)";
-// Assert.That(this.evaluator.Evaluate(expression), Is.EqualTo(expression));
-// }
#endregion
+
#region sum()
[Test]
@@ -99,7 +93,6 @@ public void Can_Sum_Integer ()
public void Can_Sum_Double ()
{
const string expression = "=sum(amount)";
- //var s = this.evaluator.Evaluate(expression);
Assert.That(this.evaluator.Evaluate(expression),
Is.EqualTo(this.doubleResult.ToString()));
}
Oops, something went wrong.

0 comments on commit 0973b20

Please sign in to comment.