From fb6ddc87af897eebc14cd1377f533d684d6dc0ad Mon Sep 17 00:00:00 2001 From: Peter Forstmeier Date: Thu, 15 Jul 2010 18:36:00 +0000 Subject: [PATCH] More exact display of long text in small Textfield git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/reports@6124 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../Project/Xml/MycroWriter.cs | 1 - .../Project/BaseClasses/Printing/Layouter.cs | 1 - .../Printing/MeasurementService.cs | 12 ---------- .../BaseClasses/Printing/StandardPrinter.cs | 17 ++++++++++++- .../Project/BaseItems/BaseTextItem.cs | 11 ++------- .../old_Exporter/ExportColumns/ExportText.cs | 24 ++++--------------- .../ExportRenderer/PdfRenderer.cs | 12 +++++----- 7 files changed, 29 insertions(+), 49 deletions(-) diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/Xml/MycroWriter.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/Xml/MycroWriter.cs index 1fb4aac688..aaa290ac1d 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/Xml/MycroWriter.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/Xml/MycroWriter.cs @@ -31,7 +31,6 @@ namespace ICSharpCode.Reports.Addin public void Save(object obj, XmlWriter writer) { - System.Console.WriteLine("Save <{0}>",obj.GetType().Name); Type t = obj.GetType(); // writer.WriteStartElement(GetTypeName(t)); diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseClasses/Printing/Layouter.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseClasses/Printing/Layouter.cs index 8dbda36d13..faf581fdf5 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseClasses/Printing/Layouter.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseClasses/Printing/Layouter.cs @@ -62,7 +62,6 @@ namespace ICSharpCode.Reports.Core.BaseClasses.Printing if (section == null) { throw new ArgumentNullException("section"); } - //section.Items.SortByLocation(); IEnumerable canGrowShrinkCollection = from bt in section.Items where bt.CanGrow == true select bt; diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseClasses/Printing/MeasurementService.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseClasses/Printing/MeasurementService.cs index 734650dd4b..5cf0291a07 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseClasses/Printing/MeasurementService.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseClasses/Printing/MeasurementService.cs @@ -19,18 +19,6 @@ namespace ICSharpCode.Reports.Core.BaseClasses.Printing public static class MeasurementService { -// private Graphics graphics; - -// public MeasurementService (Graphics graphics) -// { -// if ( graphics == null) { -// throw new ArgumentNullException("graphics"); -// } -// this.graphics = graphics; -// } - - - public static Size MeasureReportItem(Graphics graphics,IReportItem item) { BaseTextItem textItem = item as BaseTextItem; 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 2072603225..10b0123eb2 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 @@ -84,10 +84,11 @@ namespace ICSharpCode.Reports.Core.BaseClasses.Printing IExportColumnBuilder columnBuilder = item as IExportColumnBuilder; BaseExportColumn lineItem = null; + if (columnBuilder != null) { lineItem = columnBuilder.CreateExportColumn(); - + lineItem.StyleDecorator.Location = new Point(offset.X + lineItem.StyleDecorator.Location.X, lineItem.StyleDecorator.Location.Y + offset.Y); @@ -108,12 +109,26 @@ namespace ICSharpCode.Reports.Core.BaseClasses.Printing item.Location = new Point(offset.X + item.Location.X, 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; if (textItem != null) { + string str = textItem.Text; textItem.Text = evaluator.Evaluate(textItem.Text); + + 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); textItem.Text = str; } else { diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseItems/BaseTextItem.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseItems/BaseTextItem.cs index ef71cce092..8f43301ea4 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseItems/BaseTextItem.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseItems/BaseTextItem.cs @@ -84,21 +84,14 @@ namespace ICSharpCode.Reports.Core base.Render(rpea); - Console.WriteLine ("text {0} - {1}",base.BaseStyleDecorator.Location,base.DrawingRectangle.Location); - base.BaseStyleDecorator.Location = base.DrawingRectangle.Location; - StandardPrinter.FillBackground(rpea.PrintPageEventArgs.Graphics,this.BaseStyleDecorator); - Console.WriteLine ("text {0} - {1}",base.BaseStyleDecorator.Location,base.DrawingRectangle.Location); StandardPrinter.DrawBorder(rpea.PrintPageEventArgs.Graphics,this.BaseStyleDecorator); string formated = StandardFormatter.FormatOutput(this.text,this.FormatString,this.DataType,String.Empty); - - Console.WriteLine ("text {0} - {1}",base.BaseStyleDecorator.Location,base.DrawingRectangle.Location); - + Print (rpea,formated,base.DrawingRectangle); - Console.WriteLine ("-----------------------"); - + base.NotifyAfterPrint (rpea.LocationAfterDraw); } diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/old_Exporter/ExportColumns/ExportText.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/old_Exporter/ExportColumns/ExportText.cs index 536faa2a6d..316b37af1f 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/old_Exporter/ExportColumns/ExportText.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/old_Exporter/ExportColumns/ExportText.cs @@ -61,25 +61,16 @@ namespace ICSharpCode.Reports.Core.old_Exporter { (int)this.StyleDecorator.Font.Style, this.StyleDecorator.PdfForeColor); } -// -// http://www.google.de/search?hl=de&q=itextsharp+%2B+measure+text&start=10&sa=N -// http://www.mikesdotnetting.com/Article/82/iTextSharp-Adding-Text-with-Chunks-Phrases-and-Paragraphs -// http://www.mikesdotnetting.com/Category/20 - -// itextsharp + columntext + textheight -//itextsharp + columntext + rectangle -//itextsharp + simulate -//http://www.mail-archive.com/itext-questions@lists.sourceforge.net/msg04747.html base.Decorate(); PdfContentByte contentByte = base.PdfWriter.DirectContent; iTextSharp.text.Rectangle r = base.ConvertToPdfRectangle(); + ColumnText columnText = new ColumnText(contentByte); PdfFormat pdfFormat = new PdfFormat(this.StyleDecorator,font); - columnText.SetSimpleColumn(r.Left, r.Top , r.Left + r.Width,r.Height,pdfFormat.Leading,pdfFormat.Alignment); -// int a = Convert.ToInt16((r.Height/font.Size) + 1); -// columnText.SetSimpleColumn(r.Left, r.Top , r.Left + r.Width,r.Height,a,pdfFormat.Alignment); + columnText.SetSimpleColumn(r.Left, r.Top , r.Left + r.Width,r.Top - r.Height,pdfFormat.Leading,pdfFormat.Alignment); + string formated = StandardFormatter.FormatOutput(this.text,this.StyleDecorator.FormatString, this.StyleDecorator.DataType,String.Empty); @@ -88,12 +79,7 @@ namespace ICSharpCode.Reports.Core.old_Exporter { columnText.AddText(chunk); columnText.Go(); - int i = columnText.LinesWritten; - - if (i > 1) { - Console.WriteLine("{0} - {1}",i,this.text); - Console.WriteLine("dif {0}",r.Height/font.Size); - } + } @@ -155,7 +141,7 @@ namespace ICSharpCode.Reports.Core.old_Exporter { } this.font = font; this.textDecorator = textDecorator; - this.height = UnitConverter.FromPixel(this.textDecorator.DisplayRectangle.Height).Point; + this.height = Convert.ToInt16(UnitConverter.FromPixel(this.textDecorator.DisplayRectangle.Height).Point) + 1; this.CalculateFormat(); } diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/old_Exporter/ExportRenderer/PdfRenderer.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/old_Exporter/ExportRenderer/PdfRenderer.cs index dbbd4a0cd5..f2db4f13be 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/old_Exporter/ExportRenderer/PdfRenderer.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/old_Exporter/ExportRenderer/PdfRenderer.cs @@ -175,21 +175,21 @@ namespace ICSharpCode.Reports.Core.old_Exporter.ExportRenderer float lowerleftY; float upperRightX; float upperRightY; - ReportSettings reportsettings; + ReportSettings reportSettings; - public PdfUnitConverter (Rectangle pageSize,ReportSettings reportsettings) + public PdfUnitConverter (Rectangle pageSize,ReportSettings reportSettings) { if (pageSize == null) { throw new ArgumentNullException("pageSize"); } - if (reportsettings == null) { + if (reportSettings == null) { throw new ArgumentNullException("reportsettings"); } this.pageSize = pageSize; - this.reportsettings = reportsettings; - this.lowerLeftX = UnitConverter.FromPixel(this.reportsettings.LeftMargin); + this.reportSettings = reportSettings; + this.lowerLeftX = UnitConverter.FromPixel(this.reportSettings.LeftMargin); - this.lowerleftY = UnitConverter.FromPixel(this.reportsettings.BottomMargin); + this.lowerleftY = UnitConverter.FromPixel(this.reportSettings.BottomMargin); this.upperRightX = PageSize.A4.Width; this.upperRightY = PageSize.A4.Height;