Skip to content

Commit

Permalink
Merge pull request #695 from FastReports/sync_branch_2024.2.1
Browse files Browse the repository at this point in the history
FastReport.OpenSource 2024.2.1
  • Loading branch information
0legK authored Apr 17, 2024
2 parents af3b68f + 54ef99f commit c6b1c93
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 76 deletions.
12 changes: 6 additions & 6 deletions Demos/Reports/Barcode.frx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Report ScriptLanguage="CSharp" TextQuality="Regular" ReportInfo.Description="This report demonstrates different barcode types:&#13;&#10;2/5 barcodes (Interleaved, Industrial, Matrix, ITF-14, Deutsche Post Identcode), Codabar, Code39 (Regular, Extended), Code93 (Regular, Extended), Code128 (A, B, C charsets with autoencoding feature), EAN8, EAN13, UPC-A, UPC-E (E0, E1 codes), MSI, PostNet, 2 or 5 digit supplement code for EAN/UPC barcodes, PDF417, Datamatrix, QR Code, Aztec, Plessey, GS1-128 (UCC/EAN-128), Pharmacode, Intelligent Mail (USPS), Japan Post 4 State Code, MaxiCode, Swiss QR Code." ReportInfo.Created="02/21/2008 20:44:59" ReportInfo.Modified="11/26/2021 17:10:08" ReportInfo.CreatorVersion="1.0.0.0">
<Report ScriptLanguage="CSharp" TextQuality="Regular" ReportInfo.Description="This report demonstrates different barcode types:&#13;&#10;2/5 barcodes (Interleaved, Industrial, Matrix, ITF-14, Deutsche Post Identcode), Codabar, Code39 (Regular, Extended), Code93 (Regular, Extended), Code128 (A, B, C charsets with autoencoding feature), EAN8, EAN13, UPC-A, UPC-E (E0, E1 codes), MSI, PostNet, 2 or 5 digit supplement code for EAN/UPC barcodes, PDF417, Datamatrix, QR Code, Aztec, Plessey, GS1-128 (UCC/EAN-128), Pharmacode, Intelligent Mail (USPS), Japan Post 4 State Code, MaxiCode, Swiss QR Code." ReportInfo.Created="02/21/2008 20:44:59" ReportInfo.Modified="04/16/2024 10:57:52" ReportInfo.CreatorVersion="1.0.0.0">
<Dictionary/>
<ReportPage Name="Page1" RawPaperSize="9" Watermark.Font="Arial, 60pt" UnlimitedHeight="true">
<ReportTitleBand Name="ReportTitle1" Width="718.2" Height="85.05" CanGrow="true">
<TextObject Name="Text29" Width="718.2" Height="28.35" Anchor="Top, Left, Right" Fill.Color="WhiteSmoke" CanGrow="true" Text="[Report.ReportInfo.Description]" Padding="4, 4, 4, 4" VertAlign="Center" Font="Tahoma, 8pt"/>
<TextObject Name="Text30" Top="47.25" Width="718.2" Height="37.8" Text="BarcodeObject" HorzAlign="Center" VertAlign="Center" Font="Tahoma, 14pt, style=Bold"/>
</ReportTitleBand>
<DataBand Name="Data1" Top="87.27" Width="718.2" Height="1738.8">
<DataBand Name="Data1" Top="88.25" Width="718.2" Height="1738.8">
<TextObject Name="Text66" Left="179.55" Top="831.6" Width="529.2" Height="132.3" Border.Lines="All" Border.Color="Silver" Text="Japan Post 4 State Code" Padding="2, 10, 2, 0" HorzAlign="Center" Font="Tahoma, 7.8pt"/>
<TextObject Name="Text63" Left="519.75" Top="37.8" Width="189" Height="132.3" Border.Lines="Left, Right, Bottom" Border.Color="Silver" Text="Codabar" Padding="2, 10, 2, 0" HorzAlign="Center" Font="Tahoma, 8pt"/>
<TextObject Name="Text61" Left="245.7" Top="1512" Width="226.8" Height="226.8" Border.Lines="Left, Right, Bottom" Border.Color="Silver" Text="MaxiCode" Padding="2, 10, 2, 0" HorzAlign="Center" Font="Tahoma, 8pt"/>
<TextObject Name="Text32" Left="9.45" Top="37.8" Width="170.1" Height="132.3" Border.Lines="Left, Right, Bottom" Border.Color="Silver" Text="2/5 Interleaved" Padding="2, 10, 2, 0" HorzAlign="Center" Font="Tahoma, 8pt"/>
Expand Down Expand Up @@ -61,15 +62,14 @@
<BarcodeObject Name="Barcode42" Left="283.5" Top="1559.25" Width="154.5" Height="154.4" AutoSize="false" Text="http://fast-report.com" ShowText="false" AllowExpressions="true" Barcode="MaxiCode" Barcode.Mode="4"/>
<BarcodeObject Name="Barcode43" Left="37.8" Top="1578.15" Width="171.05" Height="111.35" AutoSize="false" ShowText="false" Barcode="PDF417" Barcode.AspectRatio="0.5" Barcode.Columns="0" Barcode.Rows="0" Barcode.CodePage="437" Barcode.CompactionMode="Auto" Barcode.ErrorCorrection="Auto" Barcode.PixelSize="1, 5"/>
<BarcodeObject Name="Barcode44" Left="529.2" Top="1332.45" Width="128.7" Height="128.7" AutoSize="false" ShowText="false" AllowExpressions="true" Barcode="Datamatrix" Barcode.SymbolSize="Size24x24" Barcode.Encoding="Auto" Barcode.CodePage="1252" Barcode.PixelSize="3" Barcode.AutoEncode="true"/>
<BarcodeObject Name="Barcode45" Left="56.7" Top="1332.45" Width="132.3" Height="132.3" AutoSize="false" Text="http://fast-report.com" ShowText="false" AllowExpressions="true" Barcode="QR Code" Barcode.ErrorCorrection="L" Barcode.Encoding="UTF8" Barcode.QuietZone="false"/>
<BarcodeObject Name="Barcode45" Left="56.7" Top="1332.45" Width="132.3" Height="132.3" AutoSize="false" Text="http://fast-report.com" ShowText="false" AllowExpressions="true" Barcode="QR Code" Barcode.ErrorCorrection="L" Barcode.Encoding="UTF8" Barcode.QuietZone="false" Barcode.ShowMarker="true"/>
<BarcodeObject Name="Barcode46" Left="292.95" Top="1332.45" Width="135.6" Height="135.6" AutoSize="false" Text="http://fast-report.com" ShowText="false" AllowExpressions="true" Barcode="Aztec" Barcode.ErrorCorrection="33"/>
<BarcodeObject Name="Barcode47" Left="518.1" Top="1559.25" Width="156" Height="156" AutoSize="false" Text="SPC&#13;&#10;0200&#13;&#10;1&#13;&#10;CH4431999123000889012&#13;&#10;S&#13;&#10;FastReports&#13;&#10;North Pitt Str&#13;&#10;901&#13;&#10;123456&#13;&#10;Alexandria&#13;&#10;US&#13;&#10;&#13;&#10;&#13;&#10;&#13;&#10;&#13;&#10;&#13;&#10;&#13;&#10;&#13;&#10;1000&#13;&#10;EUR&#13;&#10;S&#13;&#10;Debitor&#13;&#10;Street&#13;&#10;1&#13;&#10;1234&#13;&#10;City&#13;&#10;AG&#13;&#10;QRR&#13;&#10;210000000003139471430009017&#13;&#10;Unstructured message&#13;&#10;EPD&#13;&#10;Bill information&#13;&#10;Alt 1&#13;&#10;Alt 2" ShowText="false" AllowExpressions="true" Barcode="QR Code" Barcode.ErrorCorrection="M" Barcode.Encoding="UTF8" Barcode.QuietZone="false"/>
<BarcodeObject Name="Barcode47" Left="518.1" Top="1559.25" Width="156" Height="156" AutoSize="false" Text="SPC&#13;&#10;0200&#13;&#10;1&#13;&#10;CH4431999123000889012&#13;&#10;S&#13;&#10;FastReports&#13;&#10;North Pitt Str&#13;&#10;901&#13;&#10;123456&#13;&#10;Alexandria&#13;&#10;US&#13;&#10;&#13;&#10;&#13;&#10;&#13;&#10;&#13;&#10;&#13;&#10;&#13;&#10;&#13;&#10;1000&#13;&#10;EUR&#13;&#10;S&#13;&#10;Debitor&#13;&#10;Street&#13;&#10;1&#13;&#10;1234&#13;&#10;City&#13;&#10;AG&#13;&#10;QRR&#13;&#10;210000000003139471430009017&#13;&#10;Unstructured message&#13;&#10;EPD&#13;&#10;Bill information&#13;&#10;Alt 1&#13;&#10;Alt 2" ShowText="false" AllowExpressions="true" Barcode="QR Code" Barcode.ErrorCorrection="M" Barcode.Encoding="UTF8" Barcode.QuietZone="false" Barcode.ShowMarker="true"/>
<TextObject Name="Text65" Left="519.75" Top="302.4" Width="189" Height="132.3" Border.Lines="All" Border.Color="Silver" Text="Deutsche Post Leitcode" Padding="2, 10, 2, 0" HorzAlign="Center" Font="Tahoma, 8pt"/>
<BarcodeObject Name="Barcode50" Left="529.2" Top="330.75" Width="168.75" Height="94.5" Text="1234512312312" AllowExpressions="true" Barcode="Deutshe Leitcode" Barcode.WideBarRatio="3" Barcode.DrawVerticalBearerBars="False"/>
<TextObject Name="Text39" Left="179.55" Top="302.4" Width="170.1" Height="132.3" Border.Lines="All" Border.Color="Silver" Text="EAN8" Padding="2, 10, 2, 0" HorzAlign="Center" Font="Tahoma, 8pt"/>
<BarcodeObject Name="Barcode26" Left="223.02" Top="339.2" Width="83.75" Height="85.05" Fill.Color="White" Barcode="EAN8"/>
<BarcodeObject Name="Barcode51" Left="292.95" Top="869.4" Width="332.5" Height="85.05" Text="597-8615-5-7-6" AllowExpressions="true" Barcode="Japan Post 4 State Code"/>
<TextObject Name="Text66" Left="179.55" Top="831.6" Width="529.2" Height="132.3" Border.Lines="All" Border.Color="Silver" Text="Japan Post 4 State Code" Padding="2, 10, 2, 0" HorzAlign="Center" Font="Tahoma, 7.8pt"/>
<TextObject Name="Text67" Left="9.45" Top="963.9" Width="340.2" Height="141.75" Border.Lines="All" Border.Color="Silver" Text="GS1 DataBar Omnidirectional" Padding="2, 10, 2, 0" HorzAlign="Center" Font="Tahoma, 7.8pt"/>
<BarcodeObject Name="Barcode52" Left="56.7" Top="1001.7" Width="240" Height="94.5" Text="1234567890123" AllowExpressions="true" Barcode="GS1 DataBar Omnidirectional"/>
<TextObject Name="Text68" Left="349.65" Top="963.9" Width="359.1" Height="141.75" Border.Lines="All" Border.Color="Silver" Text="GS1 DataBar Limited" Padding="2, 10, 2, 0" HorzAlign="Center" Font="Tahoma, 7.8pt"/>
Expand All @@ -79,7 +79,7 @@
<BarcodeObject Name="Barcode54" Left="103.95" Top="1134" Width="140.77" Height="94.5" Text="1234567890123" AllowExpressions="true" Barcode="GS1 DataBar Stacked Omnidirectional"/>
<BarcodeObject Name="Barcode55" Left="463.05" Top="1134" Width="140.77" Height="94.5" Text="1234567890123" AllowExpressions="true" Barcode="GS1 DataBar Stacked"/>
</DataBand>
<PageFooterBand Name="PageFooter1" Top="1828.29" Width="718.2" Height="28.35" Fill.Color="WhiteSmoke">
<PageFooterBand Name="PageFooter1" Top="1830.25" Width="718.2" Height="28.35" Fill.Color="WhiteSmoke">
<TextObject Name="Text31" Left="9.45" Width="217.35" Height="28.35" Cursor="Hand" Hyperlink.Value="https://www.fast-report.com/en/product/fast-report-net/" Text="Generated by FastReport .NET" VertAlign="Center" Font="Tahoma, 8pt, style=Underline" TextFill.Color="Blue"/>
</PageFooterBand>
</ReportPage>
Expand Down
27 changes: 7 additions & 20 deletions FastReport.Base/BandBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -830,9 +830,6 @@ public override bool Break(BreakableComponent breakTo)
{
// first we find the break line. It's a minimum Top coordinate of the object that cannot break.
float breakLine = Height;
float excessiveHeight = 0;
float maxExcessiveHeight = 0;
Dictionary<RectangleF, float> excessiveHeights = new Dictionary<RectangleF, float>();
bool breakLineFound = true;
do
{
Expand All @@ -852,12 +849,7 @@ public override bool Break(BreakableComponent breakTo)
clone.Height = breakLine - clone.Top;
// to allow access to the Report
clone.Parent = breakTo;
canBreak = clone.Break(null, out excessiveHeight);
if (excessiveHeight > 0)
{
excessiveHeights.Add(clone.Bounds, excessiveHeight);
maxExcessiveHeight = Math.Max(maxExcessiveHeight, excessiveHeight);
}
canBreak = clone.Break(null);
}
}
}
Expand Down Expand Up @@ -889,24 +881,19 @@ public override bool Break(BreakableComponent breakTo)
breakComp.CanGrow = true;
breakComp.CanShrink = false;
breakComp.Height -= breakLine - obj.Top;
breakComp.Top = 0;
breakComp.Top = 0;
obj.Height = breakLine - obj.Top;
(obj as BreakableComponent).Break(breakComp);

}
else
{
float currentExcessiveHeight = 0;
foreach(var item in excessiveHeights)
{
if ((Math.Round(obj.Left, 2) <= Math.Round(item.Key.Left, 2) && Math.Round(obj.Right, 2) >= Math.Round(item.Key.Left, 2)) ||
(Math.Round(obj.Left, 2) >= Math.Round(item.Key.Left, 2) && Math.Round(item.Key.Right, 2) >= Math.Round(obj.Left, 2)))
currentExcessiveHeight = Math.Max(currentExcessiveHeight, item.Value);
}
// (case: object with Anchor = bottom on a breakable band)
// in case of bottom anchor, do not move the object. It will be moved automatically when we decrease the band height
if ((obj.Anchor & AnchorStyles.Bottom) == 0)
obj.Top -= (breakLine - currentExcessiveHeight);
obj.Top -= breakLine;

// add 0.01 to make sure we're below the breaked object. This is necessary due to rounding errors (in some rare cases)
obj.Top += 0.01f;
obj.Parent = breakTo;
continue;
}
Expand All @@ -915,7 +902,7 @@ public override bool Break(BreakableComponent breakTo)
}

Height = breakLine;
breakTo.Height -= (breakLine - maxExcessiveHeight);
breakTo.Height -= breakLine;
return Objects.Count > 0;
}

Expand Down
24 changes: 0 additions & 24 deletions FastReport.Base/BreakableComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,30 +105,6 @@ public virtual bool Break(BreakableComponent breakTo)
return false;
}

/// <summary>
/// Breaks the contents of the object.
/// </summary>
/// <param name="breakTo">Object to put the part of content to that does not fit in this object. These two
/// objects must have the same type.</param>
/// <param name="excessiveHeight">Excessive height that should be moved to the second part.</param>
/// <returns><b>true</b> if there is enough space in this object to display at least one text line.</returns>
/// <remarks>
/// <para>
/// Do not call this method directly, it is used by the report engine. You should override it if
/// you are writing a new FastReport object.
/// </para>
/// <para>
/// This method must break the contents of the object. The part of content that fit in current object's
/// bounds should remain in this object, the part that does not fit should be transferred to <b>breakTo</b>
/// object.
/// </para>
/// </remarks>
public virtual bool Break(BreakableComponent breakTo, out float excessiveHeight)
{
excessiveHeight = 0;
return Break(breakTo);
}

#endregion

/// <summary>
Expand Down
4 changes: 4 additions & 0 deletions FastReport.Base/Code/StubClasses.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ internal static class FileInfo {}
internal static class FileStream {}
internal static class FileSystemInfo {}
internal static class Path {}
internal static class StreamReader {}
}
namespace System.Diagnostics
Expand Down Expand Up @@ -191,6 +192,9 @@ End Class
Friend Class Path
End Class
Friend Class StreamReader
End Class
End Namespace
Namespace System.Diagnostics
Expand Down
48 changes: 47 additions & 1 deletion FastReport.Base/Export/ExportBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using FastReport.Utils;
using FastReport.Preview;
using System.Drawing;

using System.Linq;

namespace FastReport.Export
{
Expand All @@ -30,6 +30,7 @@ public partial class ExportBase : Base
private bool hasMultipleFiles;
private bool shiftNonExportable;
private string saveInitialDirectory;
private List<FileStream> tempFiles;
private List<Stream> generatedStreams;
private bool exportTabs;
protected bool webPreview;
Expand All @@ -46,6 +47,15 @@ public List<Stream> GeneratedStreams
protected set { generatedStreams = value; }
}

/// <summary>
/// Gets list of temp files generated by export.
/// </summary>
internal List<FileStream> TempFiles
{
get { return tempFiles; }
set { tempFiles = value; }
}

/// <summary>
/// Zoom factor for output file
/// </summary>
Expand Down Expand Up @@ -423,6 +433,7 @@ public void Export(Report report, Stream stream)
finally
{
Finish();
DeleteTempFiles();

if (ShowProgress)
Config.ReportSettings.OnProgress(Report, String.Empty);
Expand Down Expand Up @@ -472,7 +483,40 @@ public void InstantExportEndPage(ReportPage page)
public void InstantExportFinish()
{
Finish();
DeleteTempFiles();
}

/// <summary>
/// This file will be closed and deleted after the export is finished.
/// </summary>
/// <returns></returns>
internal FileStream CreateTempFile()
{
string dir = Path.Combine(Config.GetTempFolder(), "TempExport");
if (!Directory.Exists(dir))
Directory.CreateDirectory(dir);

TempFiles.Add(new FileStream(Path.Combine(dir, Path.GetRandomFileName()), FileMode.CreateNew));
return TempFiles.Last();
}

private void DeleteTempFiles()
{
AppDomain.CurrentDomain.UnhandledException -= CurrentDomain_UnhandledException;
foreach (var file in TempFiles)
{
if(file.CanWrite)
file.Close();
File.Delete(file.Name);
}
GC.Collect(2);
}

private void CurrentDomain_UnhandledException(object sender, EventArgs e)
{
DeleteTempFiles();
}

internal void ExportPageNew(int pageNo)
{
PreparedPage ppage = Report.PreparedPages.GetPreparedPage(pageNo);
Expand Down Expand Up @@ -575,6 +619,7 @@ internal void ExportAndZip(Report report, Stream stream)
/// </summary>
public ExportBase()
{
TempFiles = new List<FileStream>();
pageNumbers = "";
pages = new List<int>();
curPage = 1;
Expand All @@ -584,6 +629,7 @@ public ExportBase()
generatedFiles = new List<string>();
exportTabs = false;
shiftNonExportable = false;
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
}
}
}
4 changes: 2 additions & 2 deletions FastReport.Base/Hyperlink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,13 @@ public string Value
get { return value; }
set
{
if (!Regex.IsMatch(value, "(javascript)|(<\\s*script\\s*>)", RegexOptions.IgnoreCase))
if (!String.IsNullOrEmpty(value) && !Regex.IsMatch(value, "(javascript)|(<\\s*script\\s*>)", RegexOptions.IgnoreCase))
{
this.value = value;
}
else
{
this.value = "";
this.value = string.Empty;
}
}
}
Expand Down
Loading

0 comments on commit c6b1c93

Please sign in to comment.