Skip to content

Commit

Permalink
Merge pull request #323 from FastReports/sync_branch_637655606053172946
Browse files Browse the repository at this point in the history
FastReport.OpenSource 2021.3.28
  • Loading branch information
KirillKornienko authored Aug 26, 2021
2 parents b8c4a0a + 442692e commit ed95b9d
Show file tree
Hide file tree
Showing 27 changed files with 1,935 additions and 605 deletions.
6 changes: 4 additions & 2 deletions Demos/Reports/Barcode.frx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?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), MaxiCode, Swiss QR Code." ReportInfo.Created="02/21/2008 20:44:59" ReportInfo.Modified="11/05/2020 12:34:28" 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="08/13/2021 13:31:23" 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">
Expand Down Expand Up @@ -68,8 +68,10 @@
<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"/>
</DataBand>
<PageFooterBand Name="PageFooter1" Top="1551.02" Width="718.2" Height="28.35" Fill.Color="WhiteSmoke">
<PageFooterBand Name="PageFooter1" Top="1551.02s" 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
2 changes: 1 addition & 1 deletion FastReport.Base/AssemblyInitializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public AssemblyInitializer()
//RegisteredObjects.Add(typeof(Data.JsonConnection.JsonObjectDataSource), "", 0);
//RegisteredObjects.Add(typeof(Data.JsonConnection.JsonArrayDataSource), "", 0);
RegisteredObjects.InternalAddConnection(typeof(Data.JsonConnection.JsonDataSourceConnection));

RegisteredObjects.InternalAddConnection(typeof(Data.ElasticSearch.ESDataSourceConnection));
// formats
RegisteredObjects.InternalAdd(typeof(BooleanFormat), "", 0);
RegisteredObjects.InternalAdd(typeof(CurrencyFormat), "", 0);
Expand Down
9 changes: 8 additions & 1 deletion FastReport.Base/BandBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -448,10 +448,18 @@ public virtual void UpdateLayout(float dx, float dy)
{
if ((c.Anchor & AnchorStyles.Right) != 0)
{
// Save width of right anchor when page has unlimited width and its width is increasing.
if (Page != null && (Page as ReportPage).UnlimitedWidth && dx > 0)
c.RightAnchorWidth = Width - c.Right;

if ((c.Anchor & AnchorStyles.Left) != 0)
c.Width += dx;
else
c.Left += dx;

// Restore width of right anchor when page has unlimited width and its width is decreasing.
if (Page != null && (Page as ReportPage).UnlimitedWidth && dx < 0)
c.Width = PageWidth - c.RightAnchorWidth - c.Left;
}
else if ((c.Anchor & AnchorStyles.Left) == 0)
{
Expand Down Expand Up @@ -1048,6 +1056,5 @@ public BandBase()
FlagUseStartNewPage = true;
FlagCheckFreeSpace = true;
}

}
}
5 changes: 3 additions & 2 deletions FastReport.Base/Barcode/BarcodeObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -661,10 +661,10 @@ public BarcodeItem(Type objType, string barcodeName)
new BarcodeItem(typeof(Barcode2of5Industrial), "2/5 Industrial"),
new BarcodeItem(typeof(Barcode2of5Matrix), "2/5 Matrix"),
new BarcodeItem(typeof(BarcodeDeutscheIdentcode), "Deutsche Identcode"),
new BarcodeItem(typeof(BarcodeDeutscheLeitcode),"Deutshe Leitcode"),
new BarcodeItem(typeof(BarcodeDeutscheLeitcode),"Deutshe Leitcode"),
new BarcodeItem(typeof(BarcodeITF14), "ITF-14"),
new BarcodeItem(typeof(BarcodeCodabar), "Codabar"),
new BarcodeItem(typeof(Barcode128), "Code128"),
new BarcodeItem(typeof(Barcode128), "Code128"),
new BarcodeItem(typeof(Barcode39), "Code39"),
new BarcodeItem(typeof(Barcode39Extended), "Code39 Extended"),
new BarcodeItem(typeof(Barcode93), "Code93"),
Expand All @@ -673,6 +673,7 @@ public BarcodeItem(Type objType, string barcodeName)
new BarcodeItem(typeof(BarcodeEAN13), "EAN13"),
new BarcodeItem(typeof(BarcodeMSI), "MSI"),
new BarcodeItem(typeof(BarcodePostNet), "PostNet"),
new BarcodeItem(typeof(BarcodeJapanPost4StateCode), "Japan Post 4 State Code"),
new BarcodeItem(typeof(BarcodeUPC_A), "UPC-A"),
new BarcodeItem(typeof(BarcodeUPC_E0), "UPC-E0"),
new BarcodeItem(typeof(BarcodeUPC_E1), "UPC-E1"),
Expand Down
119 changes: 119 additions & 0 deletions FastReport.Base/Barcode/BarcodePostNet.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using FastReport.Utils;
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;

namespace FastReport.Barcode
{
Expand Down Expand Up @@ -34,4 +36,121 @@ internal override string GetPattern()
return result;
}
}

/// <summary>
/// Generates the Japan Post 4 State Code barcode.
/// </summary>
public class BarcodeJapanPost4StateCode : LinearBarcodeBase
{
private string CeckDigitSet = "0123456789-abcdefgh";
private string EncodeTable = "1234567890-abcdefgh";
private static string[] JapanTable =
{
"6161E", //1
"61G1F", //2
"G161F", //3
"61F1G", //4
"61E16", //5
"G1F16", //6
"F161G", //7
"F1G16", //8
"E1616", //9
"61E1E", //0
"E161E", //-
"G1F1E", //a
"G1E1F", //b
"F1G1E", //c
"E1G1F", //d
"F1E1G", //e
"E1F1G", //f
"E1E16", //g
"61616" //h
};

internal override string GetPattern()
{
string encoded = "";
int sum = 0;
int weight = 0;
string result = "61G1"; // start bar

if (text.Length < 7)
{
throw new FormatException(Res.Get("Messages,BarcodeFewError"));
}

foreach (var i in text)
{
if (((i >= '0') && (i <= '9')) || (i == '-'))
{
encoded += i;
weight++;
}
else
{
if ((i >= 'A') && (i <= 'J'))
{
encoded += 'a';
encoded += (char)(i - 'A' + '0');
}
if ((i >= 'K') && (i <= 'T'))
{
encoded += 'b';
encoded += (char)(i - 'K' + '0');
}
if ((i >= 'U') && (i <= 'Z'))
{
encoded += 'c';
encoded += (char)(i - 'U' + '0');
}
weight += 2;
}
}

// remove the hyphens that will not be encoded in the barcode
if (encoded.IndexOf('-') == 3)
{
encoded = encoded.Remove(3, 1);
weight--;
}
if (encoded.IndexOf('-', 5) == 7)
{
encoded = encoded.Remove(7, 1);
weight--;
}

if (weight > 20 || Regex.IsMatch(text.Substring(0, 7), "[^0-9\\-]") ||
Regex.IsMatch(text.Substring(7, text.Length - 7), "[^A-Z0-9\\-]") ||
(encoded.IndexOf('-') < 8 && encoded.IndexOf('-') != -1 ))
{
throw new FormatException(Res.Get("Messages,BarcodeLengthMismatch"));
}

// fill pad character CC4, if need
for (int i = encoded.Length; i < 20; i++)
{
encoded += 'd';
}

for (int i = 0; i < 20; i++)
{
result += JapanTable[EncodeTable.IndexOf(encoded[i])];
sum += CeckDigitSet.IndexOf(encoded[i]);
result += '1';
}

//Calculate check digit
char check_char = char.MinValue;
int check = 19 - (sum % 19);
if (check == 19) { check = 0; }
if (check <= 9) { check_char = (char)(check + '0'); }
if (check == 10) { check_char = '-'; }
if (check >= 11) { check_char = (char)((check - 11) + 'a'); }
result += JapanTable[EncodeTable.IndexOf(check_char)];

// data + stop bar
return result + "1G16";
}
}
}

22 changes: 22 additions & 0 deletions FastReport.Base/ComponentBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public abstract partial class ComponentBase : Base
private bool printable;
private string printableExpression;
private float width;
private float rightAnchorWidth;

#endregion Fields

Expand Down Expand Up @@ -411,6 +412,21 @@ public virtual float Width
}
}

/// <summary>
/// Gets or sets the distance between right of the object and the right of a parent band.
/// </summary>
/// <remarks>
/// This property value is measured in the screen pixels.
/// This property is used only when page has unlimited width.
/// </remarks>
[DefaultValue(0.0f)]
[Browsable(false)]
public float RightAnchorWidth
{
get { return rightAnchorWidth; }
set { rightAnchorWidth = value; }
}

#endregion Properties

#region Constructors
Expand All @@ -427,6 +443,7 @@ public ComponentBase()
printableExpression = "";
SetFlags(Flags.CanWriteBounds | Flags.HasGlobalName, true);
tag = "";
rightAnchorWidth = 0.0f;
}

#endregion Constructors
Expand Down Expand Up @@ -488,6 +505,11 @@ public override void Serialize(FRWriter writer)
}
if (Tag != c.Tag)
writer.WriteStr("Tag", Tag);
if (writer.SerializeTo == SerializeTo.Preview)
{
if (RightAnchorWidth != c.RightAnchorWidth)
writer.WriteFloat("RightAnchorWidth", RightAnchorWidth);
}
}

#endregion Public Methods
Expand Down
Loading

0 comments on commit ed95b9d

Please sign in to comment.