forked from pipeline-foundation/itext7-dotnet
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into devsecops
- Loading branch information
Showing
29 changed files
with
2,145 additions
and
2 deletions.
There are no files selected for viewing
533 changes: 533 additions & 0 deletions
533
itext.tests/itext.layout.tests/itext/layout/element/GridContainerTest.cs
Large diffs are not rendered by default.
Oops, something went wrong.
106 changes: 106 additions & 0 deletions
106
itext.tests/itext.layout.tests/itext/layout/renderer/GridCellUnitTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
/* | ||
This file is part of the iText (R) project. | ||
Copyright (c) 1998-2024 Apryse Group NV | ||
Authors: Apryse Software. | ||
This program is offered under a commercial and under the AGPL license. | ||
For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. | ||
AGPL licensing: | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Affero General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Affero General Public License for more details. | ||
You should have received a copy of the GNU Affero General Public License | ||
along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
using iText.Layout.Element; | ||
using iText.Layout.Properties; | ||
using iText.Test; | ||
|
||
namespace iText.Layout.Renderer { | ||
[NUnit.Framework.Category("UnitTest")] | ||
public class GridCellUnitTest : ExtendedITextTest { | ||
[NUnit.Framework.Test] | ||
public virtual void CellWithOnlyGridRowStartTest() { | ||
IRenderer renderer = new TextRenderer(new Text("test")); | ||
renderer.SetProperty(Property.GRID_ROW_START, 3); | ||
GridCell cell = new GridCell(renderer); | ||
NUnit.Framework.Assert.AreEqual(2, cell.GetRowStart()); | ||
NUnit.Framework.Assert.AreEqual(3, cell.GetRowEnd()); | ||
} | ||
|
||
[NUnit.Framework.Test] | ||
public virtual void CellWithOnlyGridRowEndTest() { | ||
IRenderer renderer = new TextRenderer(new Text("test")); | ||
renderer.SetProperty(Property.GRID_ROW_END, 5); | ||
GridCell cell = new GridCell(renderer); | ||
NUnit.Framework.Assert.AreEqual(3, cell.GetRowStart()); | ||
NUnit.Framework.Assert.AreEqual(4, cell.GetRowEnd()); | ||
} | ||
|
||
[NUnit.Framework.Test] | ||
public virtual void CellWithGridRowStartAndEndTest() { | ||
IRenderer renderer = new TextRenderer(new Text("test")); | ||
renderer.SetProperty(Property.GRID_ROW_START, 2); | ||
renderer.SetProperty(Property.GRID_ROW_END, 4); | ||
GridCell cell = new GridCell(renderer); | ||
NUnit.Framework.Assert.AreEqual(1, cell.GetRowStart()); | ||
NUnit.Framework.Assert.AreEqual(3, cell.GetRowEnd()); | ||
} | ||
|
||
[NUnit.Framework.Test] | ||
public virtual void CellWithOnlyGridColumnStartTest() { | ||
IRenderer renderer = new TextRenderer(new Text("test")); | ||
renderer.SetProperty(Property.GRID_COLUMN_START, 3); | ||
GridCell cell = new GridCell(renderer); | ||
NUnit.Framework.Assert.AreEqual(2, cell.GetColumnStart()); | ||
NUnit.Framework.Assert.AreEqual(3, cell.GetColumnEnd()); | ||
} | ||
|
||
[NUnit.Framework.Test] | ||
public virtual void CellWithOnlyGridColumnEndTest() { | ||
IRenderer renderer = new TextRenderer(new Text("test")); | ||
renderer.SetProperty(Property.GRID_COLUMN_END, 8); | ||
GridCell cell = new GridCell(renderer); | ||
NUnit.Framework.Assert.AreEqual(6, cell.GetColumnStart()); | ||
NUnit.Framework.Assert.AreEqual(7, cell.GetColumnEnd()); | ||
} | ||
|
||
[NUnit.Framework.Test] | ||
public virtual void CellWithGridColumnStartAndEndTest() { | ||
IRenderer renderer = new TextRenderer(new Text("test")); | ||
renderer.SetProperty(Property.GRID_COLUMN_START, 4); | ||
renderer.SetProperty(Property.GRID_COLUMN_END, 7); | ||
GridCell cell = new GridCell(renderer); | ||
NUnit.Framework.Assert.AreEqual(3, cell.GetColumnStart()); | ||
NUnit.Framework.Assert.AreEqual(6, cell.GetColumnEnd()); | ||
} | ||
|
||
[NUnit.Framework.Test] | ||
public virtual void CellWithReversedColumnStartAndEndTest() { | ||
IRenderer renderer = new TextRenderer(new Text("test")); | ||
renderer.SetProperty(Property.GRID_COLUMN_START, 7); | ||
renderer.SetProperty(Property.GRID_COLUMN_END, 4); | ||
GridCell cell = new GridCell(renderer); | ||
NUnit.Framework.Assert.AreEqual(3, cell.GetColumnStart()); | ||
NUnit.Framework.Assert.AreEqual(6, cell.GetColumnEnd()); | ||
} | ||
|
||
[NUnit.Framework.Test] | ||
public virtual void CellWithReversedRowStartAndEndTest() { | ||
IRenderer renderer = new TextRenderer(new Text("test")); | ||
renderer.SetProperty(Property.GRID_ROW_START, 4); | ||
renderer.SetProperty(Property.GRID_ROW_END, 2); | ||
GridCell cell = new GridCell(renderer); | ||
NUnit.Framework.Assert.AreEqual(1, cell.GetRowStart()); | ||
NUnit.Framework.Assert.AreEqual(3, cell.GetRowEnd()); | ||
} | ||
} | ||
} |
165 changes: 165 additions & 0 deletions
165
itext.tests/itext.layout.tests/itext/layout/renderer/GridUnitTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
/* | ||
This file is part of the iText (R) project. | ||
Copyright (c) 1998-2024 Apryse Group NV | ||
Authors: Apryse Software. | ||
This program is offered under a commercial and under the AGPL license. | ||
For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. | ||
AGPL licensing: | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Affero General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Affero General Public License for more details. | ||
You should have received a copy of the GNU Affero General Public License | ||
along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
using iText.Kernel.Geom; | ||
using iText.Layout.Element; | ||
using iText.Layout.Properties; | ||
using iText.Test; | ||
|
||
namespace iText.Layout.Renderer { | ||
[NUnit.Framework.Category("UnitTest")] | ||
public class GridUnitTest : ExtendedITextTest { | ||
[NUnit.Framework.Test] | ||
public virtual void GetClosestTopNeighborTest() { | ||
Grid grid = new Grid(3, 3, false); | ||
grid.AddCell(new GridCell(new TextRenderer(new Text("One")))); | ||
grid.AddCell(new GridCell(new TextRenderer(new Text("Three")))); | ||
IRenderer value = new TextRenderer(new Text("Two")); | ||
value.SetProperty(Property.GRID_COLUMN_START, 2); | ||
value.SetProperty(Property.GRID_ROW_START, 2); | ||
GridCell cell = new GridCell(value); | ||
grid.AddCell(cell); | ||
NUnit.Framework.Assert.AreEqual(grid.GetRows()[0][0], grid.GetClosestTopNeighbor(cell)); | ||
} | ||
|
||
[NUnit.Framework.Test] | ||
public virtual void GetClosestLeftNeighborTest() { | ||
Grid grid = new Grid(3, 3, false); | ||
grid.AddCell(new GridCell(new TextRenderer(new Text("One")))); | ||
IRenderer value = new TextRenderer(new Text("Two")); | ||
value.SetProperty(Property.GRID_COLUMN_START, 2); | ||
value.SetProperty(Property.GRID_ROW_START, 2); | ||
GridCell cell = new GridCell(value); | ||
grid.AddCell(cell); | ||
NUnit.Framework.Assert.AreEqual(grid.GetRows()[0][0], grid.GetClosestLeftNeighbor(cell)); | ||
} | ||
|
||
[NUnit.Framework.Test] | ||
public virtual void GetUniqueCellsTest() { | ||
Grid grid = new Grid(3, 3, false); | ||
grid.AddCell(new GridCell(new TextRenderer(new Text("One")))); | ||
IRenderer twoRenderer = new TextRenderer(new Text("Two")); | ||
twoRenderer.SetProperty(Property.GRID_COLUMN_START, 2); | ||
twoRenderer.SetProperty(Property.GRID_COLUMN_END, 4); | ||
GridCell cell = new GridCell(twoRenderer); | ||
grid.AddCell(cell); | ||
grid.AddCell(new GridCell(new TextRenderer(new Text("Three")))); | ||
grid.AddCell(new GridCell(new TextRenderer(new Text("Four")))); | ||
NUnit.Framework.Assert.AreEqual(4, grid.GetUniqueGridCells(Grid.ROW_ORDER).Count); | ||
} | ||
|
||
[NUnit.Framework.Test] | ||
public virtual void IncreaseRowHeightTest() { | ||
Grid grid = new Grid(3, 3, false); | ||
GridCell cell1 = new GridCell(new TextRenderer(new Text("One"))); | ||
cell1.SetLayoutArea(new Rectangle(50.0f, 50.0f)); | ||
GridCell cell2 = new GridCell(new TextRenderer(new Text("Two"))); | ||
cell2.SetLayoutArea(new Rectangle(50.0f, 50.0f)); | ||
GridCell cell3 = new GridCell(new TextRenderer(new Text("Three"))); | ||
cell3.SetLayoutArea(new Rectangle(50.0f, 50.0f)); | ||
grid.AddCell(cell1); | ||
grid.AddCell(cell2); | ||
grid.AddCell(cell3); | ||
grid.AlignRow(0, 100.0f); | ||
NUnit.Framework.Assert.AreEqual(100.0f, grid.GetRows()[0][0].GetLayoutArea().GetHeight(), 0.00001f); | ||
NUnit.Framework.Assert.AreEqual(100.0f, grid.GetRows()[0][1].GetLayoutArea().GetHeight(), 0.00001f); | ||
NUnit.Framework.Assert.AreEqual(100.0f, grid.GetRows()[0][2].GetLayoutArea().GetHeight(), 0.00001f); | ||
} | ||
|
||
[NUnit.Framework.Test] | ||
public virtual void IncreaseColumnWidthTest() { | ||
Grid grid = new Grid(3, 3, false); | ||
GridCell cell1 = new GridCell(new TextRenderer(new Text("One"))); | ||
cell1.SetLayoutArea(new Rectangle(100.0f, 50.0f)); | ||
GridCell cell2 = new GridCell(new TextRenderer(new Text("Two"))); | ||
cell2.SetLayoutArea(new Rectangle(30.0f, 50.0f)); | ||
GridCell cell3 = new GridCell(new TextRenderer(new Text("Three"))); | ||
cell3.SetLayoutArea(new Rectangle(50.0f, 50.0f)); | ||
GridCell cell4 = new GridCell(new TextRenderer(new Text("Three"))); | ||
cell4.SetLayoutArea(new Rectangle(100.0f, 50.0f)); | ||
GridCell cell5 = new GridCell(new TextRenderer(new Text("Three"))); | ||
cell5.SetLayoutArea(new Rectangle(50.0f, 50.0f)); | ||
grid.AddCell(cell1); | ||
grid.AddCell(cell2); | ||
grid.AddCell(cell3); | ||
grid.AddCell(cell4); | ||
grid.AddCell(cell5); | ||
grid.AlignColumn(1, 150.0f); | ||
NUnit.Framework.Assert.AreEqual(100.0f, grid.GetRows()[0][0].GetLayoutArea().GetWidth(), 0.00001f); | ||
NUnit.Framework.Assert.AreEqual(150.0f, grid.GetRows()[0][1].GetLayoutArea().GetWidth(), 0.00001f); | ||
NUnit.Framework.Assert.AreEqual(150.0f, grid.GetRows()[1][1].GetLayoutArea().GetWidth(), 0.00001f); | ||
NUnit.Framework.Assert.AreEqual(50.0f, grid.GetRows()[0][2].GetLayoutArea().GetWidth(), 0.00001f); | ||
} | ||
|
||
[NUnit.Framework.Test] | ||
public virtual void SparsePackingTest() { | ||
Grid grid = new Grid(3, 3, false); | ||
GridCell cell1 = new GridCell(new TextRenderer(new Text("One"))); | ||
grid.AddCell(cell1); | ||
IRenderer renderer = new TextRenderer(new Text("Two")); | ||
renderer.SetProperty(Property.GRID_COLUMN_START, 1); | ||
renderer.SetProperty(Property.GRID_COLUMN_END, 6); | ||
GridCell wideCell = new GridCell(renderer); | ||
grid.AddCell(wideCell); | ||
GridCell cell3 = new GridCell(new TextRenderer(new Text("Three"))); | ||
GridCell cell4 = new GridCell(new TextRenderer(new Text("Four"))); | ||
GridCell cell5 = new GridCell(new TextRenderer(new Text("Five"))); | ||
GridCell cell6 = new GridCell(new TextRenderer(new Text("Six"))); | ||
grid.AddCell(cell3); | ||
grid.AddCell(cell4); | ||
grid.AddCell(cell5); | ||
grid.AddCell(cell6); | ||
NUnit.Framework.Assert.AreEqual(cell1, grid.GetRows()[0][0]); | ||
NUnit.Framework.Assert.AreEqual(wideCell, grid.GetRows()[1][0]); | ||
NUnit.Framework.Assert.AreEqual(cell3, grid.GetRows()[2][0]); | ||
NUnit.Framework.Assert.AreEqual(cell4, grid.GetRows()[2][1]); | ||
NUnit.Framework.Assert.AreEqual(cell5, grid.GetRows()[2][2]); | ||
NUnit.Framework.Assert.AreEqual(cell6, grid.GetRows()[2][3]); | ||
} | ||
|
||
[NUnit.Framework.Test] | ||
public virtual void DensePackingTest() { | ||
Grid grid = new Grid(3, 3, true); | ||
GridCell cell1 = new GridCell(new TextRenderer(new Text("One"))); | ||
grid.AddCell(cell1); | ||
IRenderer renderer = new TextRenderer(new Text("Two")); | ||
renderer.SetProperty(Property.GRID_COLUMN_START, 1); | ||
renderer.SetProperty(Property.GRID_COLUMN_END, 6); | ||
GridCell wideCell = new GridCell(renderer); | ||
grid.AddCell(wideCell); | ||
GridCell cell3 = new GridCell(new TextRenderer(new Text("Three"))); | ||
GridCell cell4 = new GridCell(new TextRenderer(new Text("Four"))); | ||
GridCell cell5 = new GridCell(new TextRenderer(new Text("Five"))); | ||
GridCell cell6 = new GridCell(new TextRenderer(new Text("Six"))); | ||
grid.AddCell(cell3); | ||
grid.AddCell(cell4); | ||
grid.AddCell(cell5); | ||
grid.AddCell(cell6); | ||
NUnit.Framework.Assert.AreEqual(cell1, grid.GetRows()[0][0]); | ||
NUnit.Framework.Assert.AreEqual(cell3, grid.GetRows()[0][1]); | ||
NUnit.Framework.Assert.AreEqual(cell4, grid.GetRows()[0][2]); | ||
NUnit.Framework.Assert.AreEqual(cell5, grid.GetRows()[0][3]); | ||
NUnit.Framework.Assert.AreEqual(cell6, grid.GetRows()[0][4]); | ||
NUnit.Framework.Assert.AreEqual(wideCell, grid.GetRows()[1][0]); | ||
} | ||
} | ||
} |
Binary file added
BIN
+1.43 KB
.../itext.layout.tests/resources/itext/layout/GridContainerTest/cmp_basicAutoColumnsTest.pdf
Binary file not shown.
Binary file added
BIN
+5.26 KB
...sts/itext.layout.tests/resources/itext/layout/GridContainerTest/cmp_basicAutoRowsTest.pdf
Binary file not shown.
Binary file added
BIN
+1.41 KB
...itext.layout.tests/resources/itext/layout/GridContainerTest/cmp_basicThreeColumnsTest.pdf
Binary file not shown.
Binary file added
BIN
+1.43 KB
...itext/layout/GridContainerTest/cmp_basicThreeColumnsWithCustomColumnAndRowIndexesTest.pdf
Binary file not shown.
Binary file added
BIN
+1.38 KB
...urces/itext/layout/GridContainerTest/cmp_basicThreeColumnsWithCustomColumnIndexesTest.pdf
Binary file not shown.
Binary file added
BIN
+1.36 KB
...esources/itext/layout/GridContainerTest/cmp_basicThreeColumnsWithCustomRowIndexesTest.pdf
Binary file not shown.
Binary file added
BIN
+1.71 KB
...t.tests/resources/itext/layout/GridContainerTest/cmp_basicThreeColumnsWithFrAndPtTest.pdf
Binary file not shown.
Binary file added
BIN
+955 Bytes
...layout.tests/resources/itext/layout/GridContainerTest/cmp_basicThreeColumnsWithFrTest.pdf
Binary file not shown.
Binary file added
BIN
+1.46 KB
...ts/resources/itext/layout/GridContainerTest/cmp_basicThreeColumnsWithPtAndPercentTest.pdf
Binary file not shown.
Binary file added
BIN
+1.42 KB
...resources/itext/layout/GridContainerTest/cmp_basicThreeColumnsWithReversedIndexesTest.pdf
Binary file not shown.
Binary file added
BIN
+1.41 KB
...ts/resources/itext/layout/GridContainerTest/cmp_basicThreeColumnsWithoutColumnEndTest.pdf
Binary file not shown.
Binary file added
BIN
+1.41 KB
...itext.layout.tests/resources/itext/layout/GridContainerTest/cmp_bigCellMinContentTest.pdf
Binary file not shown.
Binary file added
BIN
+1.64 KB
...layout.tests/resources/itext/layout/GridContainerTest/cmp_fixedColumnRowGoesFirstTest.pdf
Binary file not shown.
Binary file added
BIN
+1.4 KB
....layout.tests/resources/itext/layout/GridContainerTest/cmp_thirdColumnNotLayoutedTest.pdf
Binary file not shown.
Binary file added
BIN
+1.43 KB
...ts/resources/itext/layout/GridContainerTest/cmp_threeColumnsWithAdjacentWideCellsTest.pdf
Binary file not shown.
Binary file added
BIN
+1.46 KB
...sources/itext/layout/GridContainerTest/cmp_threeColumnsWithSquareAndVerticalCellsTest.pdf
Binary file not shown.
Binary file added
BIN
+1.47 KB
.../layout/GridContainerTest/cmp_threeColumnsWithSquareCellAndCellWithExplicitHeightTest.pdf
Binary file not shown.
Binary file added
BIN
+1.44 KB
.../GridContainerTest/cmp_threeColumnsWithVerticalCellWithSeveralNeighboursToTheLeftTest.pdf
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
This file is part of the iText (R) project. | ||
Copyright (c) 1998-2024 Apryse Group NV | ||
Authors: Apryse Software. | ||
This program is offered under a commercial and under the AGPL license. | ||
For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. | ||
AGPL licensing: | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Affero General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Affero General Public License for more details. | ||
You should have received a copy of the GNU Affero General Public License | ||
along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
using iText.Layout.Renderer; | ||
|
||
namespace iText.Layout.Element { | ||
/// <summary> | ||
/// A | ||
/// <see cref="GridContainer"/> | ||
/// represents a container of the css grid object. | ||
/// </summary> | ||
public class GridContainer : Div { | ||
/// <summary> | ||
/// Creates a new | ||
/// <see cref="GridContainer"/> | ||
/// instance. | ||
/// </summary> | ||
public GridContainer() | ||
: base() { | ||
} | ||
|
||
protected internal override IRenderer MakeNewRenderer() { | ||
return new GridContainerRenderer(this); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.