Skip to content

Commit

Permalink
Merge pull request #668 from FastReports/sync_branch_2024.1.4
Browse files Browse the repository at this point in the history
FastReport.OpenSource 2024.1.4
  • Loading branch information
0legK authored Jan 24, 2024
2 parents 412093d + 9611ae1 commit 09d0d97
Show file tree
Hide file tree
Showing 249 changed files with 27,001 additions and 26,715 deletions.
40 changes: 28 additions & 12 deletions FastReport.Base/BandBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ public override void RestoreState()
}
SetRunning(false);

ReportComponentCollection collection_clone = new ReportComponentCollection();
ReportComponentCollection collection_clone = new ReportComponentCollection();
Objects.CopyTo(collection_clone);
foreach (ReportComponentBase obj in collection_clone)
{
Expand Down Expand Up @@ -757,8 +757,8 @@ public void AddLastToFooter(BreakableComponent breakTo)
if (AllObjects[i] is ComponentBase)
{
ComponentBase obj = AllObjects[i] as ComponentBase;
if (obj.Top > maxTop && !(obj is DataFooterBand))
maxTop = obj.Top;
if (obj.Top > maxTop && !(obj is DataFooterBand))
maxTop = obj.Top;
}
}
float breakLine = maxTop;
Expand Down Expand Up @@ -806,13 +806,13 @@ public void AddLastToFooter(BreakableComponent breakTo)
minTop = (breakTo.AllObjects[i] as ComponentBase).Top;

for (int i = itemsBefore; i < breakTo.AllObjects.Count; i++)
if (breakTo.AllObjects[i] is ComponentBase)
if ((breakTo.AllObjects[i] as ComponentBase).Bottom > maxBottom && breakTo.AllObjects[i] is ReportComponentBase && !(breakTo.AllObjects[i] is Table.TableCell))
maxBottom = (breakTo.AllObjects[i] as ComponentBase).Bottom;
if (breakTo.AllObjects[i] is ComponentBase)
if ((breakTo.AllObjects[i] as ComponentBase).Bottom > maxBottom && breakTo.AllObjects[i] is ReportComponentBase && !(breakTo.AllObjects[i] is Table.TableCell))
maxBottom = (breakTo.AllObjects[i] as ComponentBase).Bottom;

for (int i = 0; i < itemsBefore; i++)
if (breakTo.AllObjects[i] is ComponentBase)
(breakTo.AllObjects[i] as ComponentBase).Top += maxBottom - minTop;
if (breakTo.AllObjects[i] is ComponentBase)
(breakTo.AllObjects[i] as ComponentBase).Top += maxBottom - minTop;

breakTo.Height += maxBottom - minTop;

Expand All @@ -824,6 +824,9 @@ 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 @@ -843,7 +846,12 @@ public override bool Break(BreakableComponent breakTo)
clone.Height = breakLine - clone.Top;
// to allow access to the Report
clone.Parent = breakTo;
canBreak = clone.Break(null);
canBreak = clone.Break(null, out excessiveHeight);
if (excessiveHeight > 0)
{
excessiveHeights.Add(clone.Bounds, excessiveHeight);
maxExcessiveHeight = Math.Max(maxExcessiveHeight, excessiveHeight);
}
}
}
}
Expand Down Expand Up @@ -878,13 +886,21 @@ public override bool Break(BreakableComponent breakTo)
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;
obj.Top -= (breakLine - currentExcessiveHeight);
obj.Parent = breakTo;
continue;
}
Expand All @@ -893,7 +909,7 @@ public override bool Break(BreakableComponent breakTo)
}

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

Expand Down Expand Up @@ -966,7 +982,7 @@ public void OnAfterLayout(EventArgs e)
InvokeEvent(AfterLayoutEvent, e);
}

#endregion
#endregion

/// <summary>
/// Initializes a new instance of the <see cref="BandBase"/> class with default settings.
Expand Down
52 changes: 26 additions & 26 deletions FastReport.Base/BandCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,35 @@

namespace FastReport
{
/// <summary>
/// Represents a collection of bands.
/// </summary>
public class BandCollection : FRCollectionBase
{
/// <summary>
/// Gets or sets the element at the specified index.
/// Represents a collection of bands.
/// </summary>
/// <param name="index">Index of an element.</param>
/// <returns>The element at the specified index.</returns>
public BandBase this[int index]
public class BandCollection : FRCollectionBase
{
get { return List[index] as BandBase; }
set { List[index] = value; }
}
/// <summary>
/// Gets or sets the element at the specified index.
/// </summary>
/// <param name="index">Index of an element.</param>
/// <returns>The element at the specified index.</returns>
public BandBase this[int index]
{
get { return List[index] as BandBase; }
set { List[index] = value; }
}

/// <summary>
/// Initializes a new instance of the <see cref="BandCollection"/> class with default settings.
/// </summary>
public BandCollection() : this(null)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="BandCollection"/> class with specified owner.
/// </summary>
/// <param name="owner">Owner that owns this collection.</param>
public BandCollection(Base owner) : base(owner)
{
/// <summary>
/// Initializes a new instance of the <see cref="BandCollection"/> class with default settings.
/// </summary>
public BandCollection() : this(null)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="BandCollection"/> class with specified owner.
/// </summary>
/// <param name="owner">Owner that owns this collection.</param>
public BandCollection(Base owner) : base(owner)
{
}
}
}
}
Loading

0 comments on commit 09d0d97

Please sign in to comment.