Skip to content

Commit

Permalink
Merge pull request #409 from FastReports/sync_branch_2022.1.14
Browse files Browse the repository at this point in the history
FastReport.OpenSource 2022.1.14
  • Loading branch information
0legK authored Feb 22, 2022
2 parents 88c66a3 + 689abc7 commit fbd5d3e
Show file tree
Hide file tree
Showing 13 changed files with 104 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

<!--Source Link-->
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
</ItemGroup>

</Project>
2 changes: 2 additions & 0 deletions FastReport.Base/BandBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,8 @@ internal void FixHeight()
if (maxHeight < 0)
maxHeight = 0;
Height = maxHeight;

Validator.ValidateIntersectionAllObjects(this);
}

internal void FixHeightWithComponentsShift(float deltaY)
Expand Down
3 changes: 0 additions & 3 deletions FastReport.Base/ContainerObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ public override void SaveState()
base.SaveState();
SetRunning(true);
SetDesigning(false);
OnBeforePrint(EventArgs.Empty);

foreach (ReportComponentBase obj in Objects)
{
Expand All @@ -207,7 +206,6 @@ public override void SaveState()
/// <inheritdoc/>
public override void RestoreState()
{
OnAfterPrint(EventArgs.Empty);
base.RestoreState();
SetRunning(false);

Expand All @@ -233,7 +231,6 @@ public override void GetData()
(obj as BreakableComponent).BreakTo.GetType() == obj.GetType())
(obj as BreakableComponent).Break((obj as BreakableComponent).BreakTo);
}
OnAfterData();
}

/// <inheritdoc/>
Expand Down
18 changes: 10 additions & 8 deletions FastReport.Base/Export/Html/HTMLExportDraw.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,23 +176,25 @@ private void HTMLRtl(FastString sb, bool rtl)

private string HTMLGetStylesHeader()
{
FastString header = new FastString();
return "<style type=\"text/css\"><!-- ";
}

private void PrintPageStyle(FastString sb)
{
if (singlePage && pageBreaks)
{
header.AppendLine("<style type=\"text/css\" media=\"print\"><!--");
header.Append("div." + pageStyleName +
" { page-break-after: always; page-break-inside: avoid; ");
sb.AppendLine("<style type=\"text/css\" media=\"print\"><!--");
sb.Append("div.").Append(pageStyleName)
.Append(" { page-break-after: always; page-break-inside: avoid; ");
if (d.page.Landscape && !NotRotateLandscapePage)
{
header.Append("width:").Append(Px(maxHeight * Zoom).Replace(";", " !important;"))
sb.Append("width:").Append(Px(maxHeight * Zoom).Replace(";", " !important;"))
.Append("transform: rotate(90deg); -webkit-transform: rotate(90deg)");
}

header.AppendLine("}")
sb.AppendLine("}")
.AppendLine("--></style>");
}
header.AppendLine("<style type=\"text/css\"><!-- ");
return header.ToString();
}

private string HTMLGetStyleHeader(long index, long subindex)
Expand Down
3 changes: 2 additions & 1 deletion FastReport.Base/Export/Html/HTMLExportLayers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,10 @@ private int UpdateCSSTable(string style)

private void ExportPageStylesLayers(FastString styles, int PageNumber)
{
PrintPageStyle(styles);
if (prevStyleListIndex < cssStyles.Count)
{
styles.Append(HTMLGetStylesHeader());
styles.AppendLine(HTMLGetStylesHeader());
for (int i = prevStyleListIndex; i < cssStyles.Count; i++)
styles.Append(HTMLGetStyleHeader(i, PageNumber)).Append(cssStyles[i]).AppendLine("}");
styles.AppendLine(HTMLGetStylesFooter());
Expand Down
6 changes: 6 additions & 0 deletions FastReport.Base/Report.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1950,6 +1950,12 @@ public void Load(Stream stream)
}

reader.Read(this);

foreach (Base c in AllObjects)
{
if (c is BandBase)
Validator.ValidateIntersectionAllObjects(c as BandBase);
}
}
}

Expand Down
18 changes: 18 additions & 0 deletions FastReport.Base/ReportComponentBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ public abstract partial class ReportComponentBase : ComponentBase
private string mouseDownEvent;
private string mouseEnterEvent;
private string mouseLeaveEvent;
private bool isIntersectingWithOtherObject;
#endregion

#region Properties
Expand Down Expand Up @@ -168,6 +169,17 @@ public bool Exportable
set { exportable = value; }
}

/// <summary>
/// Gets or sets a value that determines if the object is intersecting with other object.
/// </summary>
[DefaultValue(false)]
[Browsable(false)]
public bool IsIntersectingWithOtherObject
{
get { return isIntersectingWithOtherObject; }
set { isIntersectingWithOtherObject = value; }
}

/// <summary>
/// Gets or sets a string containing expression that determines should be object exported.
/// </summary>
Expand Down Expand Up @@ -667,6 +679,7 @@ public override void Assign(Base source)
Border = src.Border.Clone();
Fill = src.Fill.Clone();
Bookmark = src.Bookmark;
IsIntersectingWithOtherObject = src.IsIntersectingWithOtherObject;
Hyperlink.Assign(src.Hyperlink);
CanGrow = src.CanGrow;
CanShrink = src.CanShrink;
Expand Down Expand Up @@ -755,6 +768,8 @@ public void DrawBackground(FRPaintEventArgs e)
{
if (Width < 0.01 || Height < 0.01)
return;
if (DrawIntersectBackground(e))
return;
Fill.Draw(e, AbsBounds);
}

Expand Down Expand Up @@ -794,6 +809,8 @@ public override void Serialize(FRWriter writer)
Hyperlink.Serialize(writer, c.Hyperlink);
if (Bookmark != c.Bookmark)
writer.WriteStr("Bookmark", Bookmark);
if (IsIntersectingWithOtherObject != c.IsIntersectingWithOtherObject)
writer.WriteBool("IsIntersectedWithOtherObject", IsIntersectingWithOtherObject);
if (writer.SerializeTo != SerializeTo.Preview)
{
if (CanGrow != c.CanGrow)
Expand Down Expand Up @@ -1049,6 +1066,7 @@ public ReportComponentBase()
flagUseBorder = true;
flagPreviewVisible = true;
flagSerializeStyle = true;
isIntersectingWithOtherObject = false;
shiftMode = ShiftMode.Always;
style = "";
evenStyle = "";
Expand Down
51 changes: 51 additions & 0 deletions FastReport.Base/Utils/Validator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using System;
using System.Drawing;

namespace FastReport.Utils
{
/// <summary>
/// Contains methods used for validation of report.
/// </summary>
public static class Validator
{
/// <summary>
/// Check all objects on band, do they intersect or not.
/// </summary>
/// <param name="band">Band that should be checked.</param>
/// <returns>Returns <b>true</b> if band has intersecting objects. Otherwise <b>false</b>.</returns>
static public bool ValidateIntersectionAllObjects(BandBase band)
{
bool result = false;

foreach(ReportComponentBase component in band.Objects)
{
component.IsIntersectingWithOtherObject = false;
if (!band.Bounds.Contains(GetReducedRect(component.AbsBounds)))
{
component.IsIntersectingWithOtherObject = true;
result = true;
}
}

for(int i = 0; i < band.Objects.Count; i++)
{
for (int j = i + 1; j < band.Objects.Count; j++)
{
if (band.Objects[i].Bounds.IntersectsWith(GetReducedRect(band.Objects[j].Bounds)))
{
result = true;
band.Objects[i].IsIntersectingWithOtherObject = true;
band.Objects[j].IsIntersectingWithOtherObject = true;
}
}
}

return result;
}

private static RectangleF GetReducedRect(RectangleF rect)
{
return new RectangleF(rect.X + 0.01f, rect.Y + 0.01f, rect.Width - 0.02f, rect.Height - 0.02f);
}
}
}
2 changes: 1 addition & 1 deletion FastReport.Core.Web/FastReport.OpenSource.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Various report objects will allow your report to look exactly how you want it to

<!--Source Link-->
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion FastReport.OpenSource/FastReport.OpenSource.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Various report objects will allow your report to look exactly how you want it to

<!--Source Link-->
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
</ItemGroup>

<!--Import version-info of referenced packages-->
Expand Down
10 changes: 10 additions & 0 deletions FastReport.OpenSource/ReportComponentBase.Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,15 @@ public virtual void AssignPreviewEvents(Base source)
{

}

/// <summary>
/// Does nothing
/// </summary>
/// <param name="e"></param>
/// <returns></returns>
protected bool DrawIntersectBackground(FRPaintEventArgs e)
{
return false;
}
}
}
1 change: 1 addition & 0 deletions FastReport/Resources/en.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1777,6 +1777,7 @@
<EditAfterInsert Text="Edit after insert"/>
<EventBandIndicator Text="Show indicator on bands with events" />
<EventObjectIndicator Text="Show indicator on objects with events" />
<EnableBacklightIntersectingObjects Text="Backlight intersecting objects" />
<ObjectsAppearance Text="Objects appearance"/>
<EnableBacklight Text="Backlight active band"/>
<SimplifyDBFields Text="Simplified display of DB fields"/>
Expand Down
1 change: 1 addition & 0 deletions Localization/Russian.frl
Original file line number Diff line number Diff line change
Expand Up @@ -1576,6 +1576,7 @@
<EditAfterInsert Text="Редактировать объект после вставки"/>
<EventBandIndicator Text="Отображать индикатор на бэндах с событиями"/>
<EventObjectIndicator Text="Отображать индикатор на объектах с событиями"/>
<EnableBacklightIntersectingObjects Text="Подсвечивать пересекающиеся объекты" />
<ObjectsAppearance Text="Внешний вид объектов"/>
<EnableBacklight Text="Подсвечивать активный бэнд"/>
<SimplifyDBFields Text="Упрощенное отображение имен полей БД"/>
Expand Down

0 comments on commit fbd5d3e

Please sign in to comment.