Skip to content

Commit 37f5875

Browse files
ars18wrwitext-teamcity
authored andcommitted
Do not overflow while applying leading on children. Minor changes. Add a test.
DEVSIX-1662 Autoported commit. Original commit hash: [775b45765]
1 parent 583c5a1 commit 37f5875

File tree

6 files changed

+78
-3
lines changed

6 files changed

+78
-3
lines changed

itext.tests/itext.layout.tests/itext/layout/TableTest.cs

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2092,6 +2092,80 @@ public virtual void TableMinMaxWidthTest05() {
20922092
, testName + "_diff"));
20932093
}
20942094

2095+
/// <exception cref="System.IO.IOException"/>
2096+
/// <exception cref="System.Exception"/>
2097+
[NUnit.Framework.Test]
2098+
public virtual void CellsWithEdgeCaseLeadingTest01() {
2099+
String testName = "cellsWithEdgeCaseLeadingTest01.pdf";
2100+
String outFileName = destinationFolder + testName;
2101+
String cmpFileName = sourceFolder + "cmp_" + testName;
2102+
PdfWriter writer = new PdfWriter(outFileName);
2103+
PdfDocument pdf = new PdfDocument(writer);
2104+
Document document = new Document(pdf);
2105+
SolidBorder border = new SolidBorder(1f);
2106+
Table table = new Table(UnitValue.CreatePointArray(new float[] { 20, 20, 20, 20 }));
2107+
Paragraph paragraph5 = new Paragraph(new Text("Cell5"));
2108+
Paragraph paragraph6 = new Paragraph(new Text("Cell6"));
2109+
Paragraph paragraph7 = new Paragraph(new Text("Cell7"));
2110+
Paragraph paragraph8 = new Paragraph(new Text("Cell8"));
2111+
Paragraph paragraph13 = new Paragraph("Cell13");
2112+
Paragraph paragraph14 = new Paragraph(new Text(""));
2113+
Paragraph paragraph15 = new Paragraph(new Text("Cell15VVVVVVVVV"));
2114+
Paragraph paragraph16 = new Paragraph(new Text(""));
2115+
Cell cell1 = new Cell().Add(new Paragraph().Add("Cell1")).SetBorder(border);
2116+
Cell cell2 = new Cell().Add(new Paragraph().Add("Cell2")).SetBorder(border);
2117+
Cell cell3 = new Cell().Add(new Paragraph().Add("Cell3")).SetBorder(border);
2118+
Cell cell4 = new Cell().Add(new Paragraph().Add("Cell4")).SetBorder(border);
2119+
Cell cell5 = new Cell().Add(paragraph5.SetFixedLeading(8)).SetBorder(border).SetBackgroundColor(ColorConstants
2120+
.LIGHT_GRAY);
2121+
Cell cell6 = new Cell().Add(paragraph6.SetFixedLeading(0)).SetBorder(border).SetBackgroundColor(ColorConstants
2122+
.LIGHT_GRAY);
2123+
Cell cell7 = new Cell().Add(paragraph7.SetFixedLeading(8)).SetBorder(border).SetBackgroundColor(ColorConstants
2124+
.LIGHT_GRAY);
2125+
Cell cell8 = new Cell().Add(paragraph8.SetFixedLeading(-4)).SetBorder(border).SetBackgroundColor(ColorConstants
2126+
.LIGHT_GRAY);
2127+
Cell cell9 = new Cell().Add(new Paragraph().Add("Cell9")).SetBorder(border);
2128+
Cell cell10 = new Cell().Add(new Paragraph().Add("Cell10")).SetBorder(border);
2129+
Cell cell11 = new Cell().Add(new Paragraph().Add("Cell11")).SetBorder(border);
2130+
Cell cell12 = new Cell().Add(new Paragraph().Add("Cell12")).SetBorder(border);
2131+
Cell cell13 = new Cell().Add(paragraph13.SetMultipliedLeading(-1)).SetBorder(border).SetBackgroundColor(ColorConstants
2132+
.LIGHT_GRAY);
2133+
Cell cell14 = new Cell().Add(paragraph14.SetMultipliedLeading(4)).SetBorder(border).SetBackgroundColor(ColorConstants
2134+
.LIGHT_GRAY);
2135+
Cell cell15 = new Cell().Add(paragraph15.SetMultipliedLeading(8)).SetBorder(border).SetBackgroundColor(ColorConstants
2136+
.LIGHT_GRAY);
2137+
Cell cell16 = new Cell().Add(paragraph16.SetMultipliedLeading(-4)).SetBorder(border).SetBackgroundColor(ColorConstants
2138+
.LIGHT_GRAY);
2139+
Cell cell17 = new Cell().Add(new Paragraph().Add("Cell17")).SetBorder(border);
2140+
Cell cell18 = new Cell().Add(new Paragraph().Add("Cell18")).SetBorder(border);
2141+
Cell cell19 = new Cell().Add(new Paragraph().Add("Cell19")).SetBorder(border);
2142+
Cell cell20 = new Cell().Add(new Paragraph().Add("Cell20")).SetBorder(border);
2143+
table.AddCell(cell1);
2144+
table.AddCell(cell2);
2145+
table.AddCell(cell3);
2146+
table.AddCell(cell4);
2147+
table.AddCell(cell5);
2148+
table.AddCell(cell6);
2149+
table.AddCell(cell7);
2150+
table.AddCell(cell8);
2151+
table.AddCell(cell9);
2152+
table.AddCell(cell10);
2153+
table.AddCell(cell11);
2154+
table.AddCell(cell12);
2155+
table.AddCell(cell13);
2156+
table.AddCell(cell14);
2157+
table.AddCell(cell15);
2158+
table.AddCell(cell16);
2159+
table.AddCell(cell17);
2160+
table.AddCell(cell18);
2161+
table.AddCell(cell19);
2162+
table.AddCell(cell20);
2163+
document.Add(table);
2164+
document.Close();
2165+
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder
2166+
, testName + "_diff"));
2167+
}
2168+
20952169
internal class CustomRenderer : TableRenderer {
20962170
public CustomRenderer(Table modelElement, Table.RowRange rowRange)
20972171
: base(modelElement, rowRange) {

itext/itext.layout/itext/layout/renderer/BlockRenderer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,12 +490,12 @@ public override void Draw(DrawContext drawContext) {
490490
}
491491
BeginElementOpacityApplying(drawContext);
492492
BeginRotationIfApplied(drawContext.GetCanvas());
493-
DrawBackground(drawContext);
494-
DrawBorder(drawContext);
495493
OverflowPropertyValue? overflowX = this.GetProperty<OverflowPropertyValue?>(Property.OVERFLOW_X);
496494
OverflowPropertyValue? overflowY = this.GetProperty<OverflowPropertyValue?>(Property.OVERFLOW_Y);
497495
bool processOverflow = OverflowPropertyValue.HIDDEN.Equals(overflowX) || OverflowPropertyValue.HIDDEN.Equals
498496
(overflowY);
497+
DrawBackground(drawContext);
498+
DrawBorder(drawContext);
499499
if (processOverflow) {
500500
drawContext.GetCanvas().SaveState();
501501
Rectangle clippedArea = drawContext.GetDocument().GetPage(occupiedArea.GetPageNumber()).GetPageSize();

itext/itext.layout/itext/layout/renderer/LineRenderer.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,7 @@ protected internal virtual LineRenderer AdjustChildrenYLine() {
816816

817817
protected internal virtual void ApplyLeading(float deltaY) {
818818
occupiedArea.GetBBox().MoveUp(deltaY);
819+
occupiedArea.GetBBox().DecreaseHeight(deltaY);
819820
foreach (IRenderer child in childRenderers) {
820821
if (!FloatingHelper.IsRendererFloating(child)) {
821822
child.Move(0, deltaY);

port-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
115f777cd21287c68cfc1f22d286ac6e232c3dd2
1+
775b457652bc5816abd2a833093bb93871b73dc4

0 commit comments

Comments
 (0)