Browse Source

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
pull/1/head
Peter Forstmeier 16 years ago
parent
commit
fb6ddc87af
  1. 1
      src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/Xml/MycroWriter.cs
  2. 1
      src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseClasses/Printing/Layouter.cs
  3. 12
      src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseClasses/Printing/MeasurementService.cs
  4. 17
      src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseClasses/Printing/StandardPrinter.cs
  5. 11
      src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseItems/BaseTextItem.cs
  6. 24
      src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/old_Exporter/ExportColumns/ExportText.cs
  7. 12
      src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/old_Exporter/ExportRenderer/PdfRenderer.cs

1
src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/Xml/MycroWriter.cs

@ -31,7 +31,6 @@ namespace ICSharpCode.Reports.Addin @@ -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));

1
src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseClasses/Printing/Layouter.cs

@ -62,7 +62,6 @@ namespace ICSharpCode.Reports.Core.BaseClasses.Printing @@ -62,7 +62,6 @@ namespace ICSharpCode.Reports.Core.BaseClasses.Printing
if (section == null) {
throw new ArgumentNullException("section");
}
//section.Items.SortByLocation();
IEnumerable<BaseReportItem> canGrowShrinkCollection = from bt in section.Items where bt.CanGrow == true select bt;

12
src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseClasses/Printing/MeasurementService.cs

@ -19,18 +19,6 @@ namespace ICSharpCode.Reports.Core.BaseClasses.Printing @@ -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;

17
src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseClasses/Printing/StandardPrinter.cs

@ -84,10 +84,11 @@ namespace ICSharpCode.Reports.Core.BaseClasses.Printing @@ -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 @@ -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 {

11
src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseItems/BaseTextItem.cs

@ -84,21 +84,14 @@ namespace ICSharpCode.Reports.Core @@ -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);
}

24
src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/old_Exporter/ExportColumns/ExportText.cs

@ -61,25 +61,16 @@ namespace ICSharpCode.Reports.Core.old_Exporter { @@ -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 { @@ -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 { @@ -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();
}

12
src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/old_Exporter/ExportRenderer/PdfRenderer.cs

@ -175,21 +175,21 @@ namespace ICSharpCode.Reports.Core.old_Exporter.ExportRenderer @@ -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;

Loading…
Cancel
Save