Skip to content

Commit 749ae02

Browse files
yulian-gaponenkoitext-teamcity
authored andcommitted
Merge branch 'feature/box_sizing_prop' into develop
Autoported commit. Original commit hash: [a965deebc]
2 parents ab2c2a6 + be67f86 commit 749ae02

25 files changed

+414
-178
lines changed

itext.tests/itext.layout.tests/itext/layout/FloatTest.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,5 +506,27 @@ public virtual void ClearanceApplyingPageSplit() {
506506
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFile, cmpFileName, destinationFolder,
507507
"diff13_"));
508508
}
509+
510+
/// <exception cref="System.IO.IOException"/>
511+
/// <exception cref="System.Exception"/>
512+
[NUnit.Framework.Test]
513+
public virtual void FloatInlineBlockTest01() {
514+
String cmpFileName = sourceFolder + "cmp_floatInlineBlockTest01.pdf";
515+
String outFile = destinationFolder + "floatInlineBlockTest01.pdf";
516+
PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outFile));
517+
Document doc = new Document(pdfDoc);
518+
Paragraph p = new Paragraph().SetBorder(new SolidBorder(1));
519+
p.Add("Float with large borders shall fit on first line with this text. ");
520+
Div div = new Div().SetBorder(new SolidBorder(Color.RED, 40));
521+
div.SetProperty(Property.FLOAT, FloatPropertyValue.RIGHT);
522+
div.Add(new Paragraph("Floating div."));
523+
p.Add(div);
524+
p.Add("Inline block with large borders floating. Inline block with large borders floating. " + "Inline block with large borders floating. Inline block with large borders floating."
525+
);
526+
doc.Add(p);
527+
doc.Close();
528+
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFile, cmpFileName, destinationFolder,
529+
"diff14_"));
530+
}
509531
}
510532
}

itext.tests/itext.layout.tests/itext/layout/PositioningTest.cs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ source product.
5252
using iText.Layout.Element;
5353
using iText.Layout.Properties;
5454
using iText.Test;
55+
using iText.Test.Attributes;
5556

5657
namespace iText.Layout {
5758
public class PositioningTest : ExtendedITextTest {
@@ -157,6 +158,54 @@ public virtual void FixedPositioningTest02() {
157158
, "diff"));
158159
}
159160

161+
/// <exception cref="System.IO.IOException"/>
162+
/// <exception cref="System.Exception"/>
163+
[NUnit.Framework.Test]
164+
[LogMessage(iText.IO.LogMessageConstant.CLIP_ELEMENT, Count = 1)]
165+
public virtual void FixedPositioningTest03() {
166+
String outFileName = destinationFolder + "fixedPositioningTest03.pdf";
167+
String cmpFileName = sourceFolder + "cmp_fixedPositioningTest03.pdf";
168+
PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName));
169+
Document document = new Document(pdfDocument);
170+
document.GetPdfDocument().AddNewPage();
171+
Paragraph p = new Paragraph("Hello, this is fairly long text. Lorem ipsum dolor sit amet, " + "consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna "
172+
+ "aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex " +
173+
"ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu "
174+
+ "fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt "
175+
+ "mollit anim id est laborum.").SetMargin(0).SetBackgroundColor(Color.LIGHT_GRAY).SetHeight(100).SetFixedPosition
176+
(1, 300, 300, 100);
177+
document.Add(p);
178+
new PdfCanvas(document.GetPdfDocument().GetPage(1)).SetStrokeColor(Color.BLACK).Rectangle(300, 300, 100, 100
179+
).Stroke().Release();
180+
document.Close();
181+
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder
182+
, "diff"));
183+
}
184+
185+
/// <exception cref="System.IO.IOException"/>
186+
/// <exception cref="System.Exception"/>
187+
[NUnit.Framework.Test]
188+
[LogMessage(iText.IO.LogMessageConstant.CLIP_ELEMENT, Count = 1)]
189+
public virtual void FixedPositioningTest04() {
190+
String outFileName = destinationFolder + "fixedPositioningTest04.pdf";
191+
String cmpFileName = sourceFolder + "cmp_fixedPositioningTest04.pdf";
192+
PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName));
193+
Document document = new Document(pdfDocument);
194+
document.GetPdfDocument().AddNewPage();
195+
Div div = new Div().SetBackgroundColor(Color.LIGHT_GRAY).SetHeight(100).SetFixedPosition(1, 300, 300, 100)
196+
.Add(new Paragraph("Hello, this is fairly long text. Lorem ipsum dolor sit amet, " + "consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna "
197+
+ "aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex " +
198+
"ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu "
199+
+ "fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt "
200+
+ "mollit anim id est laborum.").SetMargin(0));
201+
document.Add(div);
202+
new PdfCanvas(document.GetPdfDocument().GetPage(1)).SetStrokeColor(Color.BLACK).Rectangle(300, 300, 100, 100
203+
).Stroke().Release();
204+
document.Close();
205+
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder
206+
, "diff"));
207+
}
208+
160209
/// <exception cref="System.IO.IOException"/>
161210
/// <exception cref="System.Exception"/>
162211
[NUnit.Framework.Test]

itext.tests/itext.layout.tests/itext/layout/RotationTest.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,28 @@ public virtual void ImageInRotatedBlockTest02() {
659659
, "diff"));
660660
}
661661

662+
/// <exception cref="System.IO.IOException"/>
663+
/// <exception cref="System.Exception"/>
664+
[NUnit.Framework.Test]
665+
public virtual void BlockWithBorderBoxSizingTest01() {
666+
String outFileName = destinationFolder + "blockWithBorderBoxSizingTest01.pdf";
667+
String cmpFileName = sourceFolder + "cmp_blockWithBorderBoxSizingTest01.pdf";
668+
PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName));
669+
Document doc = new Document(pdfDocument);
670+
Div div = new Div();
671+
div.SetRotationAngle(Math.PI / 3);
672+
div.SetBorder(new SolidBorder(Color.BLUE, 50));
673+
div.Add(new Paragraph("Long long long Long long long Long long long Long long long Long long long Long long long text"
674+
));
675+
doc.Add(div);
676+
doc.Add(new AreaBreak());
677+
div.SetProperty(Property.BOX_SIZING, BoxSizingPropertyValue.BORDER_BOX);
678+
doc.Add(div);
679+
doc.Close();
680+
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder
681+
, "diff"));
682+
}
683+
662684
/// <exception cref="System.IO.IOException"/>
663685
/// <exception cref="System.Exception"/>
664686
[NUnit.Framework.Test]

itext.tests/itext.layout.tests/itext/layout/renderer/MinWidthTest.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ source product.
4343
using System;
4444
using iText.IO.Image;
4545
using iText.Kernel.Colors;
46-
using iText.Kernel.Geom;
4746
using iText.Kernel.Pdf;
4847
using iText.Kernel.Pdf.Xobject;
4948
using iText.Kernel.Utils;
@@ -80,7 +79,7 @@ public virtual void ParagraphTest() {
8079
Paragraph p = new Paragraph(new Text(str).SetBorder(new SolidBorder(Color.BLACK, 5))).SetBorder(new SolidBorder
8180
(Color.BLUE, 5));
8281
MinMaxWidth result = ((AbstractRenderer)p.CreateRendererSubTree().SetParent(doc.GetRenderer())).GetMinMaxWidth
83-
(doc.GetPageEffectiveArea(PageSize.A4).GetWidth());
82+
(MinMaxWidthUtils.GetMax());
8483
p.SetWidth(ToEffectiveWidth(p, result.GetMinWidth()));
8584
doc.Add(p);
8685
doc.Close();
@@ -102,7 +101,7 @@ public virtual void DivTest() {
102101
Div d = new Div().SetPadding(4f).SetBorder(new SolidBorder(Color.GREEN, 5)).SetMargin(6);
103102
d.Add(p);
104103
MinMaxWidth result = ((AbstractRenderer)d.CreateRendererSubTree().SetParent(doc.GetRenderer())).GetMinMaxWidth
105-
(doc.GetPageEffectiveArea(PageSize.A4).GetWidth());
104+
(MinMaxWidthUtils.GetMax());
106105
d.SetWidth(ToEffectiveWidth(d, result.GetMinWidth()));
107106
doc.Add(d);
108107
doc.Close();
@@ -125,7 +124,7 @@ public virtual void DivWithSmallRotatedParagraph() {
125124
d.Add(new Paragraph(("iText")).SetRotationAngle(Math.PI / 8).SetBorder(new SolidBorder(Color.BLUE, 2f)));
126125
d.Add(p);
127126
MinMaxWidth result = ((AbstractRenderer)d.CreateRendererSubTree().SetParent(doc.GetRenderer())).GetMinMaxWidth
128-
(doc.GetPageEffectiveArea(PageSize.A4).GetWidth());
127+
(MinMaxWidthUtils.GetMax());
129128
d.SetWidth(ToEffectiveWidth(d, result.GetMinWidth()));
130129
doc.Add(d);
131130
doc.Close();
@@ -136,6 +135,7 @@ public virtual void DivWithSmallRotatedParagraph() {
136135
/// <exception cref="System.IO.IOException"/>
137136
/// <exception cref="System.Exception"/>
138137
[NUnit.Framework.Test]
138+
[LogMessage(iText.IO.LogMessageConstant.ELEMENT_DOES_NOT_FIT_AREA)]
139139
public virtual void DivWithBigRotatedParagraph() {
140140
String outFileName = destinationFolder + "divBigRotatedParagraphTest01.pdf";
141141
String cmpFileName = sourceFolder + "cmp_divBigRotatedParagraphTest01.pdf";
@@ -148,7 +148,7 @@ public virtual void DivWithBigRotatedParagraph() {
148148
d.Add(p);
149149
d.Add(new Paragraph(("iText")));
150150
MinMaxWidth result = ((AbstractRenderer)d.CreateRendererSubTree().SetParent(doc.GetRenderer())).GetMinMaxWidth
151-
(doc.GetPageEffectiveArea(PageSize.A4).GetWidth());
151+
(MinMaxWidthUtils.GetMax());
152152
d.SetWidth(ToEffectiveWidth(d, result.GetMinWidth()));
153153
doc.Add(d);
154154
doc.Close();
@@ -172,7 +172,7 @@ public virtual void DivWithSmallRotatedDiv() {
172172
Div dRotated = new Div().SetRotationAngle(Math.PI / 8).SetBorder(new SolidBorder(Color.BLUE, 2f));
173173
d.Add(dRotated.Add(new Paragraph(("iText"))));
174174
MinMaxWidth result = ((AbstractRenderer)d.CreateRendererSubTree().SetParent(doc.GetRenderer())).GetMinMaxWidth
175-
(doc.GetPageEffectiveArea(PageSize.A4).GetWidth());
175+
(MinMaxWidthUtils.GetMax());
176176
d.SetWidth(ToEffectiveWidth(d, result.GetMinWidth()));
177177
doc.Add(d);
178178
doc.Close();
@@ -195,7 +195,7 @@ public virtual void DivWithBigRotatedDiv() {
195195
dRotated.Add(p).SetRotationAngle(Math.PI * 3 / 8);
196196
Div d = new Div().Add(new Paragraph(("iText"))).Add(dRotated).SetBorder(new SolidBorder(Color.BLUE, 2f));
197197
MinMaxWidth result = ((AbstractRenderer)d.CreateRendererSubTree().SetParent(doc.GetRenderer())).GetMinMaxWidth
198-
(doc.GetPageEffectiveArea(PageSize.A4).GetWidth());
198+
(MinMaxWidthUtils.GetMax());
199199
d.SetWidth(ToEffectiveWidth(d, result.GetMinWidth()));
200200
doc.Add(d);
201201
doc.Close();
@@ -217,10 +217,10 @@ public virtual void DivWithPercentImage() {
217217
iText.Layout.Element.Image imgPercent = new iText.Layout.Element.Image(imageXObject).SetWidthPercent(50);
218218
Div dPercent = new Div().Add(imgPercent).SetBorder(new SolidBorder(Color.BLUE, 2f));
219219
MinMaxWidth result = ((AbstractRenderer)d.CreateRendererSubTree().SetParent(doc.GetRenderer())).GetMinMaxWidth
220-
(doc.GetPageEffectiveArea(PageSize.A4).GetWidth());
220+
(MinMaxWidthUtils.GetMax());
221221
d.SetWidth(ToEffectiveWidth(d, result.GetMinWidth()));
222222
MinMaxWidth resultPercent = ((AbstractRenderer)dPercent.CreateRendererSubTree().SetParent(doc.GetRenderer(
223-
))).GetMinMaxWidth(doc.GetPageEffectiveArea(PageSize.A4).GetWidth());
223+
))).GetMinMaxWidth(MinMaxWidthUtils.GetMax());
224224
dPercent.SetWidth(ToEffectiveWidth(dPercent, resultPercent.GetMaxWidth()));
225225
doc.Add(d);
226226
doc.Add(dPercent);
@@ -245,10 +245,10 @@ public virtual void DivWithRotatedPercentImage() {
245245
(Math.PI * 3 / 8);
246246
Div dPercent = new Div().Add(imgPercent).SetBorder(new SolidBorder(Color.BLUE, 2f));
247247
MinMaxWidth result = ((AbstractRenderer)d.CreateRendererSubTree().SetParent(doc.GetRenderer())).GetMinMaxWidth
248-
(doc.GetPageEffectiveArea(PageSize.A4).GetWidth());
248+
(MinMaxWidthUtils.GetMax());
249249
d.SetWidth(ToEffectiveWidth(d, result.GetMinWidth()));
250250
MinMaxWidth resultPercent = ((AbstractRenderer)dPercent.CreateRendererSubTree().SetParent(doc.GetRenderer(
251-
))).GetMinMaxWidth(doc.GetPageEffectiveArea(PageSize.A4).GetWidth());
251+
))).GetMinMaxWidth(MinMaxWidthUtils.GetMax());
252252
dPercent.SetWidth(ToEffectiveWidth(dPercent, resultPercent.GetMaxWidth()));
253253
doc.Add(d);
254254
doc.Add(dPercent);
@@ -279,7 +279,7 @@ public virtual void MultipleDivTest() {
279279
(3).SetBackgroundColor(Color.LIGHT_GRAY);
280280
curr.Add(p);
281281
MinMaxWidth result = ((AbstractRenderer)externalDiv.CreateRendererSubTree().SetParent(doc.GetRenderer())).
282-
GetMinMaxWidth(doc.GetPageEffectiveArea(PageSize.A4).GetWidth());
282+
GetMinMaxWidth(MinMaxWidthUtils.GetMax());
283283
externalDiv.SetWidth(ToEffectiveWidth(externalDiv, result.GetMinWidth()));
284284
doc.Add(externalDiv);
285285
doc.Close();
@@ -392,7 +392,7 @@ public virtual void HeaderFooterTableTest() {
392392
(cell.Clone(true)).AddFooterCell(bigCell.Clone(true)).AddHeaderCell(bigCell.Clone(true)).AddHeaderCell
393393
(cell.Clone(true)).AddHeaderCell(cell.Clone(true));
394394
TableRenderer renderer = (TableRenderer)table.CreateRendererSubTree().SetParent(doc.GetRenderer());
395-
MinMaxWidth minMaxWidth = renderer.GetMinMaxWidth(doc.GetPageEffectiveArea(PageSize.A4).GetWidth());
395+
MinMaxWidth minMaxWidth = renderer.GetMinMaxWidth(MinMaxWidthUtils.GetMax());
396396
Table minTable = new Table(new float[] { -1, -1, -1 }).SetWidth(UnitValue.CreatePointValue(1)).SetBorder(new
397397
SolidBorder(Color.BLACK, 20)).SetMarginTop(20).AddCell(mediumCell.Clone(true)).AddCell(mediumCell.Clone
398398
(true)).AddCell(mediumCell.Clone(true)).AddFooterCell(cell.Clone(true)).AddFooterCell(cell.Clone(true)
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)