Skip to content

Commit e861d95

Browse files
authored
Merge pull request #781 from FastReports/sync_branch_2026.1.0
FastReport.OpenSource 2026.1.0
2 parents 2d896c9 + c21d509 commit e861d95

File tree

11 files changed

+222
-26
lines changed

11 files changed

+222
-26
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<TargetFrameworks>$(NetFrameworkMinimum);net6.0</TargetFrameworks>
4+
<Crossplatform>true</Crossplatform>
5+
</PropertyGroup>
6+
7+
<Import Project="Shared.props" />
8+
9+
<ItemGroup>
10+
<ProjectReference Include="..\..\..\..\FastReport.OpenSource\FastReport.OpenSource.csproj" />
11+
</ItemGroup>
12+
</Project>
Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
<Project>
2-
<PropertyGroup>
3-
<Product>FastReport.Data.Ignite</Product>
4-
<AssemblyName>FastReport.Data.Ignite</AssemblyName>
2+
<PropertyGroup>
3+
<Product>FastReport.Data.Ignite</Product>
4+
<AssemblyName>FastReport.Data.Ignite</AssemblyName>
5+
</PropertyGroup>
56

6-
</PropertyGroup>
7-
8-
<Import Project="..\Connections.props" />
7+
<Import Project="..\Connections.props" />
98

109
<ItemGroup>
11-
<PackageReference Include="Apache.Ignite" Version="[2.17.0,)" />
10+
<PackageReference Include="Apache.Ignite" Version="2.17.0" />
1211
</ItemGroup>
1312

1413
<ItemGroup>
15-
<None Include="$(MSBuildThisFileFullPath)">
16-
<Visible>true</Visible>
17-
<Pack>false</Pack>
18-
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
19-
</None>
20-
</ItemGroup>
14+
<None Include="$(MSBuildThisFileFullPath)">
15+
<Visible>true</Visible>
16+
<Pack>false</Pack>
17+
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
18+
</None>
19+
</ItemGroup>
2120
</Project>

FastReport.Base/Barcode/Barcode2of5.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using FastReport.Utils;
1+
using FastReport.Utils;
22
using System;
33
using System.Collections.Generic;
44
using System.Drawing;
@@ -27,6 +27,12 @@ public class Barcode2of5Interleaved : LinearBarcodeBase
2727
internal override string GetPattern()
2828
{
2929
string text = base.text;
30+
31+
if (IsBarcodeRussianPost)
32+
{
33+
text = text.Substring(2);
34+
}
35+
3036
string result = "5050"; //Startcode
3137
string c;
3238

FastReport.Base/Barcode/BarcodeCodabar.cs

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.ComponentModel;
34
using System.Text;
5+
using FastReport.Utils;
46

57
namespace FastReport.Barcode
68
{
@@ -27,6 +29,9 @@ public Codabar(string c, string data)
2729
}
2830
}
2931

32+
/// <inheritdoc/>
33+
public enum CodabarChar { A, B, C, D };
34+
3035
private static Codabar[] tabelle_cb = {
3136
new Codabar("1", "5050615"),
3237
new Codabar("2", "5051506"),
@@ -49,6 +54,22 @@ public Codabar(string c, string data)
4954
new Codabar("C", "5051516"),
5055
new Codabar("D", "5051615") };
5156

57+
/// <summary>
58+
/// Specifies start character (A, B, C or D).
59+
/// </summary>
60+
/// <inheritdoc/>
61+
[Category("Barcode")]
62+
[DefaultValue(CodabarChar.A)]
63+
public CodabarChar StartChar { get; set; } = CodabarChar.A;
64+
65+
/// <summary>
66+
/// Specifies stop character (A, B, C or D)
67+
/// </summary>
68+
/// <inheritdoc/>
69+
[Category("Barcode")]
70+
[DefaultValue(CodabarChar.B)]
71+
public CodabarChar StopChar { get; set; } = CodabarChar.B;
72+
5273
/// <inheritdoc/>
5374
public override bool IsNumeric
5475
{
@@ -68,7 +89,7 @@ private int FindBarItem(string c)
6889
internal override string GetPattern()
6990
{
7091
string result = "";
71-
int index = FindBarItem("A");
92+
int index = FindBarItem(StartChar.ToString());
7293
if (index >= 0)
7394
{
7495
result = tabelle_cb[index].data + "0";
@@ -83,14 +104,35 @@ internal override string GetPattern()
83104
}
84105
}
85106

86-
index = FindBarItem("B");
107+
index = FindBarItem(StopChar.ToString());
87108
if (index >= 0)
88109
{
89110
result += tabelle_cb[index].data;
90111
}
91112
return result;
92113
}
93114

115+
/// <inheritdoc/>
116+
public override void Assign(BarcodeBase source)
117+
{
118+
base.Assign(source);
119+
StartChar = (source as BarcodeCodabar).StartChar;
120+
StopChar = (source as BarcodeCodabar).StopChar;
121+
}
122+
123+
/// <inheritdoc/>
124+
internal override void Serialize(FRWriter writer, string prefix, BarcodeBase diff)
125+
{
126+
base.Serialize(writer, prefix, diff);
127+
BarcodeCodabar c = diff as BarcodeCodabar;
128+
129+
if (c == null || StartChar != c.StartChar)
130+
writer.WriteStr(prefix + "StartChar", StartChar.ToString());
131+
132+
if (c == null || StopChar != c.StopChar)
133+
writer.WriteStr(prefix + "StopChar", StopChar.ToString());
134+
}
135+
94136
/// <summary>
95137
/// Initializes a new instance of the <see cref="BarcodeCodabar"/> class with default settings.
96138
/// </summary>

FastReport.Base/Barcode/LinearBarcodeBase.cs

Lines changed: 109 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using FastReport.Utils;
1+
using FastReport.Utils;
22
using System;
33
using System.ComponentModel;
44
using System.Drawing;
@@ -109,6 +109,14 @@ internal string Code
109109
return pattern;
110110
}
111111
}
112+
113+
internal bool IsBarcodeRussianPost
114+
{
115+
get
116+
{
117+
return text.Length == 15 && text.StartsWith("RP", StringComparison.OrdinalIgnoreCase);
118+
}
119+
}
112120
#endregion
113121

114122
#region Private Methods
@@ -192,7 +200,12 @@ internal virtual void DoLines(string data, IGraphics g, float zoom)
192200
}
193201
}
194202

195-
internal string CheckSumModulo10(string data)
203+
/// <summary>
204+
/// Calculates the modulo 10 checksum and appends it to the data.
205+
/// </summary>
206+
/// <param name="data">A string of numeric data.</param>
207+
/// <returns>The string with the appended checksum.</returns>
208+
public static string CheckSumModulo10(string data)
196209
{
197210
int sum = 0;
198211
int fak = data.Length;
@@ -411,7 +424,12 @@ internal override void Initialize(string text, bool showText, int angle, float z
411424
internal override SizeF CalcBounds()
412425
{
413426
float barWidth = GetWidth(Code);
414-
float extra1 = 0;
427+
if (IsBarcodeRussianPost)
428+
{
429+
barWidth += 21.15f; // Increase the width of the object
430+
}
431+
432+
float extra1 = IsBarcodeRussianPost ? 18 : 0; // Left margin 6 mm
415433
float extra2 = 0;
416434

417435
if (showText)
@@ -439,20 +457,29 @@ internal override SizeF CalcBounds()
439457
extra2 = this.extra2;
440458

441459
drawArea = new RectangleF(0, 0, barWidth + extra1 + extra2, 0);
442-
barArea = new RectangleF(extra1, 0, barWidth, 0);
460+
float barTopOffset = IsBarcodeRussianPost ? 9 : 0; // The indentation at the top of the barcode
461+
barArea = new RectangleF(extra1, barTopOffset, barWidth, 0);
443462

444-
return new SizeF(drawArea.Width * 1.25f, 0);
463+
float width = drawArea.Width * 1.25f;
464+
float height = IsBarcodeRussianPost ? 56.7f : 0; // The height of the object at the AutoSize
465+
return new SizeF(width, height);
445466
}
446467

447468
/// <inheritdoc/>
448469
public override void DrawBarcode(IGraphics g, RectangleF displayRect)
449470
{
450471
float originalWidth = CalcBounds().Width / 1.25f;
472+
473+
if (IsBarcodeRussianPost)
474+
{
475+
originalWidth -= 3f; // Increasing the barcode width to meet the specification
476+
}
477+
451478
float width = angle == 90 || angle == 270 ? displayRect.Height : displayRect.Width;
452479
float height = angle == 90 || angle == 270 ? displayRect.Width : displayRect.Height;
453480
zoom = width / originalWidth;
454481
barArea.Height = height / zoom;
455-
if (showText)
482+
if (showText && !IsBarcodeRussianPost)
456483
{
457484
barArea.Height -= FontHeight;
458485
if (textUp)
@@ -479,18 +506,92 @@ public override void DrawBarcode(IGraphics g, RectangleF displayRect)
479506
break;
480507
}
481508

509+
if (IsBarcodeRussianPost)
510+
{
511+
g.DrawRectangle(new Pen(Color.Black, 1f), drawArea.X, drawArea.Y, displayRect.Width, displayRect.Height);
512+
DrawTopLabel(g, zoom);
513+
barArea.Height -= 18; // Reducing the height of the barcode itself
514+
}
515+
482516
g.TranslateTransform(barArea.Left * zoom, 0);
483517
DoLines(pattern, g, zoom);
484-
if (showText)
485-
DrawText(g, text);
486518

519+
if (IsBarcodeRussianPost)
520+
{
521+
DrawBottomLabel(g, zoom, barArea, drawArea);
522+
}
523+
else if (showText)
524+
{
525+
DrawText(g, text);
526+
}
487527
}
488528
finally
489529
{
490530
g.Restore(state);
491531
}
492532
}
493533

534+
/// <summary>
535+
/// Draws a top label for the barcode, adjusting its size and position based on the zoom level.
536+
/// </summary>
537+
private static void DrawTopLabel(IGraphics g, float zoom)
538+
{
539+
string label = "ПОЧТА РОССИИ";
540+
float labelHeight = 1.3f * Units.Millimeters * zoom;
541+
542+
// Ensure the font size is valid (greater than 0) to avoid exceptions when creating the font
543+
float labelFontSize = labelHeight > 0 ? labelHeight : 0.1f;
544+
Font labelFont = new Font("Arial", labelFontSize, FontStyle.Regular);
545+
546+
g.DrawString(label, labelFont, Brushes.Black, 16.5f * zoom, 2f * zoom);
547+
labelFont.Dispose();
548+
}
549+
550+
/// <summary>
551+
/// Draws the bottom label text below the barcode, splitting it into parts and applying specific formatting. <br/>
552+
/// Adjusts positioning and spacing based on the zoom level and barcode area dimensions.
553+
/// </summary>
554+
private void DrawBottomLabel(IGraphics g, float zoom, RectangleF barArea, RectangleF drawArea)
555+
{
556+
string text = base.text;
557+
558+
text = CheckSumModulo10(text.Substring(2));
559+
560+
float fontSize = 1.8f * Units.Millimeters * zoom;
561+
562+
using (Font regularFont = new Font("Arial", fontSize > 0 ? fontSize : 0.1f, FontStyle.Regular))
563+
using (Font boldFont = new Font("Arial", fontSize > 0 ? fontSize : 0.1f, FontStyle.Bold))
564+
{
565+
// Split the processed text into parts for separate rendering
566+
string[] parts = new string[]
567+
{
568+
text.Substring(0, 6),
569+
text.Substring(6, 2),
570+
text.Substring(8, 5),
571+
text.Substring(13, 1)
572+
};
573+
574+
// Calculate the total width of all text parts, including spacing between them
575+
float totalWidth = 0;
576+
foreach (var part in parts)
577+
{
578+
SizeF partSize = g.MeasureString(part, regularFont);
579+
totalWidth += partSize.Width + 2f; // Add fixed spacing between parts
580+
}
581+
582+
float currentX = (barArea.Left - 17) * zoom; // Offset by 17 to move text closer to the left edge
583+
float textY = (barArea.Bottom - 1) * zoom; // Offset by 1 to move text closer to the barcode
584+
585+
for (int i = 0; i < parts.Length; i++)
586+
{
587+
SizeF partSize = g.MeasureString(parts[i], regularFont);
588+
Font partFont = (i == 2) ? boldFont : regularFont;
589+
g.DrawString(parts[i], partFont, Brushes.Black, currentX, textY);
590+
currentX += partSize.Width + (7f * zoom); // Add spacing (7 units scaled by zoom) between parts
591+
}
592+
}
593+
}
594+
494595
internal void DrawString(IGraphics g, float x1, float x2, string s)
495596
{
496597
DrawString(g, x1, x2, s, false);

FastReport.Base/PictureObject.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,14 @@ public virtual Image Image
8989
}
9090
}
9191

92+
/// <summary>
93+
/// Gets the raw image data as a byte array.
94+
/// </summary>
95+
internal byte[] ImageData
96+
{
97+
get { return imageData; }
98+
}
99+
92100
/// <summary>
93101
/// Gets or sets the extension of image.
94102
/// </summary>

FastReport.Base/Report.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ public string[] ReferencedAssemblies
681681
/// <summary>
682682
/// Gets or sets a script event name that will be fired when the report starts.
683683
/// </summary>
684-
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
684+
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
685685
public string StartReportEvent
686686
{
687687
get { return startReportEvent; }
@@ -691,7 +691,7 @@ public string StartReportEvent
691691
/// <summary>
692692
/// Gets or sets a script event name that will be fired when the report is finished.
693693
/// </summary>
694-
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
694+
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
695695
public string FinishReportEvent
696696
{
697697
get { return finishReportEvent; }

FastReport.OpenSource.sln

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FastReport.OpenSource.Data.
5959
EndProject
6060
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FastReport.Compat", "FastReport.Compat\FastReport.Compat\FastReport.Compat.csproj", "{00AF18F4-89D0-434A-82C2-C8A8A43F008C}"
6161
EndProject
62+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FastReport.OpenSource.Data.Ignite", "Extras\Core\FastReport.Data\FastReport.Data.Ignite\FastReport.OpenSource.Data.Ignite.csproj", "{46BE71B1-66A6-CB31-A340-410047E732AC}"
63+
EndProject
6264
Global
6365
GlobalSection(SolutionConfigurationPlatforms) = preSolution
6466
Academic|Any CPU = Academic|Any CPU
@@ -210,6 +212,12 @@ Global
210212
{00AF18F4-89D0-434A-82C2-C8A8A43F008C}.Debug|Any CPU.Build.0 = Debug|Any CPU
211213
{00AF18F4-89D0-434A-82C2-C8A8A43F008C}.Release|Any CPU.ActiveCfg = Release|Any CPU
212214
{00AF18F4-89D0-434A-82C2-C8A8A43F008C}.Release|Any CPU.Build.0 = Release|Any CPU
215+
{46BE71B1-66A6-CB31-A340-410047E732AC}.Academic|Any CPU.ActiveCfg = Release|Any CPU
216+
{46BE71B1-66A6-CB31-A340-410047E732AC}.Academic|Any CPU.Build.0 = Release|Any CPU
217+
{46BE71B1-66A6-CB31-A340-410047E732AC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
218+
{46BE71B1-66A6-CB31-A340-410047E732AC}.Debug|Any CPU.Build.0 = Debug|Any CPU
219+
{46BE71B1-66A6-CB31-A340-410047E732AC}.Release|Any CPU.ActiveCfg = Release|Any CPU
220+
{46BE71B1-66A6-CB31-A340-410047E732AC}.Release|Any CPU.Build.0 = Release|Any CPU
213221
EndGlobalSection
214222
GlobalSection(SolutionProperties) = preSolution
215223
HideSolutionNode = FALSE
@@ -237,6 +245,7 @@ Global
237245
{A1827297-EAD4-413D-BA8D-811F5FF6125D} = {CCF32DAC-85D9-43D4-A4A7-72626A13D806}
238246
{28005ED3-3E5B-443F-A054-C74A45BE3C4C} = {A1827297-EAD4-413D-BA8D-811F5FF6125D}
239247
{7C97A904-620B-49A5-9000-41452DA11BB3} = {898AF8DC-11C3-4640-B60C-5D8CBF2F29CF}
248+
{46BE71B1-66A6-CB31-A340-410047E732AC} = {898AF8DC-11C3-4640-B60C-5D8CBF2F29CF}
240249
EndGlobalSection
241250
GlobalSection(ExtensibilityGlobals) = postSolution
242251
SolutionGuid = {DFBB1F5B-F03E-4BCB-AFEE-A45A2C4D5BB8}

0 commit comments

Comments
 (0)