From 1e70b9b93e9e90ae766e93083491b0515d2d83a8 Mon Sep 17 00:00:00 2001 From: Peter Forstmeier Date: Sun, 18 Jul 2010 18:13:53 +0000 Subject: [PATCH] Work on Layouter git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/reports@6143 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../BaseClasses/Printing/PrintHelper.cs | 5 ++- .../BaseClasses/Printing/StandardFormatter.cs | 1 + .../BaseClasses/Printing/StandardPrinter.cs | 22 ++++++++--- .../Exporter/Converters/BaseConverter.cs | 19 +++------ .../Exporter/Converters/RowConverter.cs | 4 +- .../Exporter/Converters/TableConverter.cs | 15 +++++-- .../Project/Printing/AbstractDataRenderer.cs | 39 +++++++++++-------- 7 files changed, 62 insertions(+), 43 deletions(-) diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseClasses/Printing/PrintHelper.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseClasses/Printing/PrintHelper.cs index 01800c09f8..3a81a7b628 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseClasses/Printing/PrintHelper.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseClasses/Printing/PrintHelper.cs @@ -29,10 +29,10 @@ namespace ICSharpCode.Reports.Core.BaseClasses.Printing public static void SetLayoutForRow (Graphics graphics, ILayouter layouter,ISimpleContainer row) { BaseReportItem item = row as BaseReportItem; - int extend = item.Size.Height - row.Items[0].Size.Height; + Rectangle textRect = layouter.Layout(graphics,row); if (textRect.Height > item.Size.Height) { - item.Size = new Size(item.Size.Width,textRect.Height + extend ); + item.Size = new Size(item.Size.Width,textRect.Height); } } @@ -171,6 +171,7 @@ namespace ICSharpCode.Reports.Core.BaseClasses.Printing } + #region Debug Code /// diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseClasses/Printing/StandardFormatter.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseClasses/Printing/StandardFormatter.cs index 795285e181..a0258dad76 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseClasses/Printing/StandardFormatter.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseClasses/Printing/StandardFormatter.cs @@ -14,6 +14,7 @@ using System.Globalization; /// namespace ICSharpCode.Reports.Core.BaseClasses.Printing { + internal static class StandardFormatter { diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseClasses/Printing/StandardPrinter.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseClasses/Printing/StandardPrinter.cs index 6e3ecaf0e4..070b70cbb2 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseClasses/Printing/StandardPrinter.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseClasses/Printing/StandardPrinter.cs @@ -110,7 +110,6 @@ namespace ICSharpCode.Reports.Core.BaseClasses.Printing offset.Y + item.Location.Y); var ss = MeasurementService.MeasureReportItem(rpea.PrintPageEventArgs.Graphics,item); - Console.WriteLine ("RenderLineItem {0} - {1}",ss,item.Size); BaseTextItem textItem = item as BaseTextItem; @@ -122,11 +121,6 @@ namespace ICSharpCode.Reports.Core.BaseClasses.Printing if (str != textItem.Text) { var ss1 = MeasurementService.MeasureReportItem(rpea.PrintPageEventArgs.Graphics,item); - - int i = Convert.ToInt16(UnitConverter.FromPixel(ss1.Height).Point); - Console.WriteLine ("RenderLineItemxx {0} - {1} - {2} ",ss1, - item.Size, - i); } textItem.Render(rpea); @@ -227,6 +221,22 @@ namespace ICSharpCode.Reports.Core.BaseClasses.Printing } return null; } + + #endregion + + #region Evaluate + + public static void EvaluateRow(IExpressionEvaluatorFacade evaluator,ExporterCollection row) + { + foreach (BaseExportColumn element in row) { + ExportText textItem = element as ExportText; + + if (textItem != null) { + textItem.Text = evaluator.Evaluate(textItem.Text); + } + } + } + #endregion } } diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/BaseConverter.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/BaseConverter.cs index 434e040b89..e8f1e2de99 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/BaseConverter.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/BaseConverter.cs @@ -144,6 +144,10 @@ namespace ICSharpCode.Reports.Core.Exporter get {return this.saveSize;} } + protected IExpressionEvaluatorFacade Evaluator + { + get {return this.evaluator;} + } protected void FillRow (ISimpleContainer row) { @@ -154,24 +158,11 @@ namespace ICSharpCode.Reports.Core.Exporter protected void LayoutRow (ISimpleContainer row) { - PrintHelper.SetLayoutForRow(Graphics,Layouter,row); } - protected void EvaluateRow(ExporterCollection row) - { - foreach (BaseExportColumn element in row) { - ExportText textItem = element as ExportText; - - if (textItem != null) { - Console.WriteLine (textItem.Text); - textItem.Text = evaluator.Evaluate(textItem.Text); - } - } - } - - + protected Point BaseConvert(ExporterCollection myList,ISimpleContainer container,int leftPos,Point curPos) { ExporterCollection ml = BaseConverter.ConvertItems (container, curPos); diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/RowConverter.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/RowConverter.cs index f323dcc80c..a6b4434088 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/RowConverter.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/RowConverter.cs @@ -74,13 +74,15 @@ namespace ICSharpCode.Reports.Core.Exporter base.FillRow(simpleContainer); + + base.LayoutRow(simpleContainer); base.FireSectionRendering(section); currentPosition = base.BaseConvert(mylist,simpleContainer,defaultLeftPos,currentPosition); - EvaluateRow(mylist); + StandardPrinter.EvaluateRow(base.Evaluator,mylist); section.Items[0].Size = base.RestoreSize; section.SectionOffset += section.Size.Height + 2 * base.SinglePage.SectionBounds.Gap; diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/TableConverter.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/TableConverter.cs index 7015a79d8d..cf337d2b01 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/TableConverter.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/TableConverter.cs @@ -48,11 +48,17 @@ namespace ICSharpCode.Reports.Core.Exporter private ExporterCollection ConvertInternal(ExporterCollection mylist) { - Point currentPosition = new Point(base.SectionBounds.DetailStart.X,base.SectionBounds.DetailStart.Y); + + Point currentPosition = new Point(PrintHelper.DrawingAreaRelativeToParent(this.baseTable.Parent,this.baseTable).Location.X, + base.SectionBounds.DetailStart.Y); + + int defaultLeftPos = currentPosition.X; + Point dataAreaStart = new Point(baseTable.Items[0].Location.X,baseTable.Items[0].Location.Y + currentPosition.Y); + ISimpleContainer headerContainer = null; - int defaultLeftPos = PrintHelper.DrawingAreaRelativeToParent(this.baseTable.Parent,this.baseTable).Left; + this.baseTable.Items.SortByLocation(); @@ -79,6 +85,9 @@ namespace ICSharpCode.Reports.Core.Exporter section.Location = new Point(section.Location.X,section.SectionOffset ); base.FillRow(simpleContainer); + + StandardPrinter.EvaluateRow(base.Evaluator,mylist); + base.LayoutRow(simpleContainer); @@ -93,7 +102,7 @@ namespace ICSharpCode.Reports.Core.Exporter currentPosition = base.BaseConvert(mylist,simpleContainer,defaultLeftPos,currentPosition); - EvaluateRow(mylist); +// EvaluateRow(mylist); simpleContainer.Size = base.RestoreSize; } diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Printing/AbstractDataRenderer.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Printing/AbstractDataRenderer.cs index 6527f0b404..178ca7c118 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Printing/AbstractDataRenderer.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Printing/AbstractDataRenderer.cs @@ -67,32 +67,41 @@ namespace ICSharpCode.Reports.Core } Point saveLocation = tableContainer.Location; - Point currentPosition = new Point(this.CurrentSection.Location.X,this.CurrentSection.Location.Y); - + + Point currentPosition = new Point(PrintHelper.DrawingAreaRelativeToParent(this.CurrentSection,tableContainer).Location.X, + this.CurrentSection.Location.Y); tableContainer.Items.SortByLocation(); rpea.SinglePage.StartRow = this.dataNavigator.CurrentRow; + Size rs = Size.Empty; foreach (BaseRowItem row in tableContainer.Items) { + if (row != null) { + rs = row.Size; PrintHelper.AdjustParent(tableContainer as BaseReportItem,tableContainer.Items); if (PrintHelper.IsTextOnlyRow(row) ) { + PrintHelper.SetLayoutForRow(rpea.PrintPageEventArgs.Graphics,base.Layout,row); Rectangle r = StandardPrinter.RenderContainer(row,Evaluator,currentPosition,rpea); - currentPosition =PrintHelper. ConvertRectangleToCurentPosition (r); - currentPosition = new Point(parent.Location.X + row.Location.X,currentPosition.Y); + + currentPosition =PrintHelper.ConvertRectangleToCurentPosition (r); + +// currentPosition = new Point(parent.Location.X + row.Location.X,currentPosition.Y); + tableContainer.Location = saveLocation; + Console.WriteLine("----"); } else { int adjust = row.Location.Y - saveLocation.Y; row.Location = new Point(row.Location.X,row.Location.Y - adjust - 3 * GlobalValues.GapBetweenContainer); - + rs = row.Size; do { if (PrintHelper.IsPageFull(new Rectangle(currentPosition,row.Size),this.SectionBounds)) { tableContainer.Location = saveLocation; @@ -101,30 +110,26 @@ namespace ICSharpCode.Reports.Core AbstractRenderer.PageBreak(rpea); return; } + this.dataNavigator.Fill(row.Items); + Console.WriteLine("org row size {0}",row.Size); PrintHelper.SetLayoutForRow(rpea.PrintPageEventArgs.Graphics,base.Layout,row); + + Console.WriteLine("new row size {0}",row.Size); + Console.WriteLine(""); Rectangle r = StandardPrinter.RenderContainer(row,Evaluator,currentPosition,rpea); currentPosition = PrintHelper.ConvertRectangleToCurentPosition (r); - - currentPosition = new Point(parent.Location.X + row.Location.X,currentPosition.Y); - + + row.Size = rs; } while (this.dataNavigator.MoveNext()); } } + row.Size = rs; } -// -// if (this.DrawBorder) { -// Border border = new Border(new BaseLine (this.ForeColor,System.Drawing.Drawing2D.DashStyle.Solid,1)); -// border.DrawBorder(rpea.PrintPageEventArgs.Graphics, -// new Rectangle(parent.Location.X,tableStart.Y, -// parent.Size.Width,currentPosition.Y + 5)); -// } - - rpea.LocationAfterDraw = new Point(rpea.LocationAfterDraw.X,rpea.LocationAfterDraw.Y + 20); // base.NotifyAfterPrint (rpea.LocationAfterDraw); }