Skip to content

Commit a5f4932

Browse files
ars18wrwiText-CI
authored andcommitted
Process corners of collapsed borders according to browsers
DEVSIX-5524 Autoported commit. Original commit hash: [486b539af]
1 parent 3fae0e6 commit a5f4932

File tree

105 files changed

+799
-138
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+799
-138
lines changed

itext.tests/itext.layout.tests/itext/layout/LargeElementTest.cs

Lines changed: 174 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ public virtual void LargeTableWithHeaderFooterTest01B() {
207207

208208
[NUnit.Framework.Test]
209209
public virtual void LargeTableWithHeaderFooterTest01C() {
210+
// TODO DEVSIX-5868 Look at page 2: large table's vertical borders are shorter in length than expected
210211
String testName = "largeTableWithHeaderFooterTest01C.pdf";
211212
String outFileName = destinationFolder + testName;
212213
String cmpFileName = sourceFolder + "cmp_" + testName;
@@ -713,6 +714,7 @@ private void LargeTableSplitTest(String outFileName, float pageHeight, float row
713714

714715
[NUnit.Framework.Test]
715716
public virtual void LargeTableWithTableBorderSplitTest() {
717+
// TODO DEVSIX-5865 Table last horizontal border is drawn twice: at final Table#flush and then at Table#complete
716718
String testName = "largeTableWithTableBorderSplitTest.pdf";
717719
String outFileName = destinationFolder + testName;
718720
String cmpFileName = sourceFolder + "cmp_" + testName;
@@ -735,9 +737,54 @@ public virtual void LargeTableWithTableBorderSplitTest() {
735737
));
736738
}
737739

740+
[NUnit.Framework.Test]
741+
public virtual void LargeTableWithTableBorderSplitTest02() {
742+
// TODO DEVSIX-5865 Table last horizontal border is drawn twice: at final Table#flush and then at Table#complete
743+
String testName = "largeTableWithTableBorderSplitTest02.pdf";
744+
String outFileName = destinationFolder + testName;
745+
String cmpFileName = sourceFolder + "cmp_" + testName;
746+
PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outFileName));
747+
Document doc = new Document(pdfDoc, new PageSize(595, 100));
748+
Table table = new Table(2, true);
749+
doc.Add(table);
750+
table.SetBorder(new SolidBorder(ColorConstants.BLUE, 2));
751+
table.AddCell(new Cell().SetBackgroundColor(ColorConstants.RED).SetHeight(50).SetMargin(0).SetPadding(0));
752+
table.AddCell(new Cell().SetBackgroundColor(ColorConstants.RED).SetHeight(50).SetMargin(0).SetPadding(0));
753+
table.Flush();
754+
table.Complete();
755+
doc.Close();
756+
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder
757+
));
758+
}
759+
760+
[NUnit.Framework.Test]
761+
public virtual void LargeTableWithCellBordersSplitTest1() {
762+
// TODO DEVSIX-5866 at #complete left border is initialized as null
763+
String testName = "largeTableWithCellBordersSplitTest1.pdf";
764+
String outFileName = destinationFolder + testName;
765+
String cmpFileName = sourceFolder + "cmp_" + testName;
766+
PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outFileName));
767+
Document doc = new Document(pdfDoc);
768+
float[] colWidths = new float[] { 30, 30, 30 };
769+
Table table = new Table(colWidths, true).SetWidth(290);
770+
doc.Add(table);
771+
table.AddCell(new Cell().Add(new Paragraph("Cell" + 0)).SetPadding(0).SetMargin(0).SetBorder(new SolidBorder
772+
(ColorConstants.MAGENTA, 50)).SetBorderBottom(new SolidBorder(ColorConstants.BLUE, 50)));
773+
table.AddCell(new Cell().Add(new Paragraph("Cell" + 1)).SetPadding(0).SetMargin(0).SetBorder(new SolidBorder
774+
(ColorConstants.MAGENTA, 50)).SetBorderBottom(new SolidBorder(ColorConstants.RED, 50)));
775+
table.AddCell(new Cell().Add(new Paragraph("Cell" + 3)).SetPadding(0).SetMargin(0).SetBorder(new SolidBorder
776+
(ColorConstants.MAGENTA, 50)).SetBorderBottom(new SolidBorder(ColorConstants.BLUE, 50)));
777+
table.Flush();
778+
table.Complete();
779+
doc.Close();
780+
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder
781+
));
782+
}
783+
738784
[NUnit.Framework.Test]
739785
[LogMessage(iText.IO.LogMessageConstant.ELEMENT_DOES_NOT_FIT_AREA)]
740786
public virtual void LargeTableWithCellBordersSplitTest() {
787+
// TODO DEVSIX-5866 at #complete left border is initialized as null
741788
String testName = "largeTableWithCellBordersSplitTest.pdf";
742789
String outFileName = destinationFolder + testName;
743790
String cmpFileName = sourceFolder + "cmp_" + testName;
@@ -746,17 +793,59 @@ public virtual void LargeTableWithCellBordersSplitTest() {
746793
float[] colWidths = new float[] { 200, -1, 20, 40 };
747794
Table table = new Table(UnitValue.CreatePointArray(colWidths), true);
748795
doc.Add(table);
749-
for (int i = 0; i < 1; i++) {
750-
table.AddCell(new Cell().Add(new Paragraph("Cell" + (i * 4 + 0))).SetBorderBottom(new SolidBorder(ColorConstants
751-
.BLUE, 2)));
752-
table.AddCell(new Cell().Add(new Paragraph("Cell" + (i * 4 + 1))).SetBorderBottom(new SolidBorder(ColorConstants
753-
.RED, 5)));
754-
table.AddCell(new Cell().Add(new Paragraph("Cell" + (i * 4 + 2))).SetBorderBottom(new SolidBorder(ColorConstants
755-
.GREEN, 7)));
756-
table.AddCell(new Cell().Add(new Paragraph("Cell" + (i * 4 + 3))).SetBorderBottom(new SolidBorder(ColorConstants
757-
.BLUE, 10)));
758-
table.Flush();
759-
}
796+
table.AddCell(new Cell().Add(new Paragraph("Cell" + 0)).SetBorderBottom(new SolidBorder(ColorConstants.BLUE
797+
, 2)));
798+
table.AddCell(new Cell().Add(new Paragraph("Cell" + 1)).SetBorderBottom(new SolidBorder(ColorConstants.RED
799+
, 5)));
800+
table.AddCell(new Cell().Add(new Paragraph("Cell" + 2)).SetBorderBottom(new SolidBorder(ColorConstants.GREEN
801+
, 7)));
802+
table.AddCell(new Cell().Add(new Paragraph("Cell" + 3)).SetBorderBottom(new SolidBorder(ColorConstants.BLUE
803+
, 10)));
804+
table.Flush();
805+
table.Complete();
806+
doc.Close();
807+
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder
808+
));
809+
}
810+
811+
[NUnit.Framework.Test]
812+
[LogMessage(iText.IO.LogMessageConstant.ELEMENT_DOES_NOT_FIT_AREA)]
813+
public virtual void LargeTableWithCellBordersSplitTest02() {
814+
// TODO DEVSIX-5866 at #complete left border is initialized as null
815+
String testName = "largeTableWithCellBordersSplitTest02.pdf";
816+
String outFileName = destinationFolder + testName;
817+
String cmpFileName = sourceFolder + "cmp_" + testName;
818+
PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outFileName));
819+
Document doc = new Document(pdfDoc, new PageSize(595, 100));
820+
float[] colWidths = new float[] { 200, 40 };
821+
Table table = new Table(UnitValue.CreatePointArray(colWidths), true);
822+
doc.Add(table);
823+
table.AddCell(new Cell().Add(new Paragraph("Cell" + 0)).SetBackgroundColor(ColorConstants.YELLOW).SetBorderBottom
824+
(new SolidBorder(ColorConstants.BLUE, 2)));
825+
table.AddCell(new Cell().Add(new Paragraph("Cell" + 3)).SetBackgroundColor(ColorConstants.YELLOW).SetBorderBottom
826+
(new SolidBorder(ColorConstants.BLUE, 10)));
827+
table.Flush();
828+
doc.Close();
829+
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder
830+
));
831+
}
832+
833+
[NUnit.Framework.Test]
834+
public virtual void SimpleLargeTableDifferentCellBottomBorderTest() {
835+
// TODO DEVSIX-5866 at #complete left border is initialized as null
836+
String testName = "simpleLargeTableDifferentCellBottomBorderTest.pdf";
837+
String outFileName = destinationFolder + testName;
838+
String cmpFileName = sourceFolder + "cmp_" + testName;
839+
PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outFileName));
840+
Document doc = new Document(pdfDoc);
841+
Table table = new Table(2, true);
842+
doc.Add(table);
843+
table.AddCell(new Cell().Add(new Paragraph("Cell" + 0)).SetHeight(30).SetMargin(0).SetPadding(0).SetBackgroundColor
844+
(ColorConstants.RED).SetBorder(new SolidBorder(ColorConstants.BLUE, 10)));
845+
table.AddCell(new Cell().Add(new Paragraph("Cell" + 1)).SetHeight(30).SetMargin(0).SetPadding(0).SetBackgroundColor
846+
(ColorConstants.RED).SetBorder(new SolidBorder(10)).SetBorderBottom(new SolidBorder(ColorConstants.BLUE
847+
, 100)));
848+
table.Flush();
760849
table.Complete();
761850
doc.Close();
762851
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder
@@ -765,6 +854,9 @@ public virtual void LargeTableWithCellBordersSplitTest() {
765854

766855
[NUnit.Framework.Test]
767856
public virtual void LargeTableSplitFooter2Test() {
857+
// TODO DEVSIX-5867 footer's top / table body's bottom border gets drawn twice at different coordinates
858+
// (Look at yellow border at page 2: it might not be tat obvious, however, there are two yelow borders
859+
// there which overlap each other a bit)
768860
String testName = "largeTableSplitFooter2Test.pdf";
769861
String outFileName = destinationFolder + testName;
770862
String cmpFileName = sourceFolder + "cmp_" + testName;
@@ -786,6 +878,51 @@ public virtual void LargeTableSplitFooter2Test() {
786878
));
787879
}
788880

881+
[NUnit.Framework.Test]
882+
public virtual void LargeTableSplitFooter2ATest() {
883+
// TODO DEVSIX-5867 footer's top / table body's bottom border gets drawn twice at different coordinates
884+
// (Look at yellow border: it might not be tat obvious, however, there are two yelow borders
885+
// there which overlap each other a bit)
886+
String testName = "largeTableSplitFooter2ATest.pdf";
887+
String outFileName = destinationFolder + testName;
888+
String cmpFileName = sourceFolder + "cmp_" + testName;
889+
PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outFileName));
890+
Document doc = new Document(pdfDoc);
891+
Table table = new Table(1, true);
892+
doc.Add(table);
893+
table.AddFooterCell(new Cell().Add(new Paragraph("Footer")).SetBorderTop(new SolidBorder(ColorConstants.YELLOW
894+
, 15)));
895+
table.AddCell(new Cell().Add(new Paragraph("Cell1")).SetHeight(50).SetBorderBottom(new SolidBorder(ColorConstants
896+
.BLUE, 20)));
897+
table.Flush();
898+
table.AddCell(new Cell().Add(new Paragraph("Cell2")).SetHeight(50));
899+
table.Complete();
900+
doc.Close();
901+
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder
902+
));
903+
}
904+
905+
[NUnit.Framework.Test]
906+
public virtual void LargeTableSplitFooter2BTest() {
907+
// TODO DEVSIX-5869 large table's width should not change between flushes
908+
String testName = "largeTableSplitFooter2BTest.pdf";
909+
String outFileName = destinationFolder + testName;
910+
String cmpFileName = sourceFolder + "cmp_" + testName;
911+
PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outFileName));
912+
Document doc = new Document(pdfDoc, new PageSize(595, 900));
913+
AddSpecificTableConsideringFlushes(doc, false, false);
914+
doc.Add(new AreaBreak());
915+
AddSpecificTableConsideringFlushes(doc, true, false);
916+
doc.Add(new AreaBreak());
917+
AddSpecificTableConsideringFlushes(doc, false, true);
918+
doc.Add(new AreaBreak());
919+
AddSpecificTableConsideringFlushes(doc, true, true);
920+
doc.Add(new AreaBreak());
921+
doc.Close();
922+
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder
923+
));
924+
}
925+
789926
[NUnit.Framework.Test]
790927
public virtual void LargeTableCollapsingSplitTest() {
791928
String testName = "largeTableCollapsingSplitTest.pdf";
@@ -1126,30 +1263,44 @@ public virtual void LargeEmptyTableTest02Separated() {
11261263
}
11271264

11281265
[NUnit.Framework.Test]
1129-
// TODO DEVSIX-3953
1130-
[LogMessage(iText.IO.LogMessageConstant.ELEMENT_DOES_NOT_FIT_AREA, Count = 2)]
1266+
// TODO DEVSIX-3953 Footer is not placed on the first page in case of large table, but fits the page for a usual table
1267+
[LogMessage(iText.IO.LogMessageConstant.ELEMENT_DOES_NOT_FIT_AREA)]
11311268
public virtual void LargeTableFooterNotFitTest() {
11321269
String testName = "largeTableFooterNotFitTest.pdf";
11331270
String outFileName = destinationFolder + testName;
11341271
String cmpFileName = sourceFolder + "cmp_" + testName;
11351272
PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outFileName));
11361273
Document doc = new Document(pdfDoc, new PageSize(595, 100));
1137-
float[] colWidths = new float[] { 200, -1, 40, 40 };
1138-
Table table = new Table(UnitValue.CreatePointArray(colWidths), true);
1139-
Cell footerCell = new Cell(1, 4).Add(new Paragraph("Table footer: continue on next page"));
1274+
Table table = new Table(1, true);
1275+
Cell footerCell = new Cell().Add(new Paragraph("Table footer: continue on next page"));
11401276
table.AddFooterCell(footerCell);
11411277
doc.Add(table);
1142-
for (int i = 0; i < 2; i++) {
1143-
table.AddCell(new Cell().Add(new Paragraph("Cell" + (i * 4 + 0))));
1144-
table.AddCell(new Cell().Add(new Paragraph("Cell" + (i * 4 + 1))));
1145-
table.AddCell(new Cell().Add(new Paragraph("Cell" + (i * 4 + 2))));
1146-
table.AddCell(new Cell().Add(new Paragraph("Cell" + (i * 4 + 3))));
1147-
table.Flush();
1148-
}
1278+
table.AddCell(new Cell().Add(new Paragraph("Cell")).SetBackgroundColor(ColorConstants.RED));
1279+
// If one comments flush, then the table fits the page
1280+
table.Flush();
11491281
table.Complete();
11501282
doc.Close();
11511283
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder
11521284
, testName + "_diff"));
11531285
}
1286+
1287+
private static void AddSpecificTableConsideringFlushes(Document doc, bool flushFirst, bool flushSecond) {
1288+
Table table = new Table(UnitValue.CreatePercentArray(1), true);
1289+
doc.Add(table);
1290+
table.AddFooterCell(new Cell().Add(new Paragraph("Footer")).SetBorderTop(new SolidBorder(ColorConstants.YELLOW
1291+
, 15)).SetHeight(100).SetMargin(0).SetPadding(0));
1292+
table.AddCell(new Cell().Add(new Paragraph("Cell1")).SetHeight(100).SetMargin(0).SetPadding(0).SetBackgroundColor
1293+
(ColorConstants.RED));
1294+
if (flushFirst) {
1295+
table.Flush();
1296+
}
1297+
table.AddCell(new Cell().Add(new Paragraph("Cell2")).SetHeight(100).SetMargin(0).SetPadding(0).SetBackgroundColor
1298+
(ColorConstants.RED).SetBorderLeft(new SolidBorder(ColorConstants.GREEN, 50)).SetBorderRight(new SolidBorder
1299+
(ColorConstants.GREEN, 50)).SetBorderTop(new SolidBorder(ColorConstants.MAGENTA, 10)));
1300+
if (flushSecond) {
1301+
table.Flush();
1302+
}
1303+
table.Complete();
1304+
}
11541305
}
11551306
}

0 commit comments

Comments
 (0)