Skip to content

Commit c9621fb

Browse files
ars18wrwiText-CI
authored andcommitted
Fix an issue with processing tabs inside of a paragraph.
Move not only a renderer itself, but its children as well. DEVSIX-1830 Autoported commit. Original commit hash: [35c39fb79]
1 parent 6643b6f commit c9621fb

File tree

4 files changed

+43
-4
lines changed

4 files changed

+43
-4
lines changed

itext.tests/itext.layout.tests/itext/layout/TabsTest.cs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,45 @@ public virtual void AnchorTabStopsTest02() {
236236
, "diff" + outFileName));
237237
}
238238

239+
/// <exception cref="System.IO.IOException"/>
240+
/// <exception cref="System.Exception"/>
241+
[NUnit.Framework.Test]
242+
public virtual void TablesAndTabInsideOfParagraph() {
243+
String testName = "tablesAndTabInsideOfParagraph.pdf";
244+
String outFileName = destinationFolder + testName;
245+
String cmpFileName = sourceFolder + "cmp_" + testName;
246+
Document doc = InitDocument(outFileName, false);
247+
Table leftTable = new Table(1);
248+
for (int x = 0; x < 3; x++) {
249+
leftTable.AddCell("Table 1, Line " + (x + 1));
250+
}
251+
Table rightTable = new Table(1);
252+
for (int x = 0; x < 3; x++) {
253+
rightTable.AddCell("Table 2, Line " + (x + 1));
254+
}
255+
Paragraph p = new Paragraph().Add(leftTable);
256+
p.Add(new Tab());
257+
p.AddTabStops(new TabStop(300, TabAlignment.LEFT));
258+
p.Add(rightTable);
259+
doc.Add(new Paragraph("TabAlignment: LEFT"));
260+
doc.Add(p);
261+
p = new Paragraph().Add(leftTable);
262+
p.Add(new Tab());
263+
p.AddTabStops(new TabStop(300, TabAlignment.CENTER));
264+
p.Add(rightTable);
265+
doc.Add(new Paragraph("TabAlignment: CENTER"));
266+
doc.Add(p);
267+
p = new Paragraph().Add(leftTable);
268+
p.Add(new Tab());
269+
p.AddTabStops(new TabStop(300, TabAlignment.RIGHT));
270+
p.Add(rightTable);
271+
doc.Add(new Paragraph("TabAlignment: RIGHT"));
272+
doc.Add(p);
273+
doc.Close();
274+
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder
275+
, testName + "_diff"));
276+
}
277+
239278
/// <exception cref="System.IO.IOException"/>
240279
/// <exception cref="System.Exception"/>
241280
[NUnit.Framework.Test]

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -408,12 +408,12 @@ public override LayoutResult Layout(LayoutContext layoutContext) {
408408
));
409409
float sumOfAffectedRendererWidths = 0;
410410
foreach (IRenderer renderer in affectedRenderers) {
411-
renderer.GetOccupiedArea().GetBBox().MoveRight(tabWidth + sumOfAffectedRendererWidths);
411+
renderer.Move(tabWidth + sumOfAffectedRendererWidths, 0);
412412
sumOfAffectedRendererWidths += renderer.GetOccupiedArea().GetBBox().GetWidth();
413413
}
414414
if (childResult.GetSplitRenderer() != null) {
415-
childResult.GetSplitRenderer().GetOccupiedArea().GetBBox().MoveRight(tabWidth + sumOfAffectedRendererWidths
416-
- childResult.GetSplitRenderer().GetOccupiedArea().GetBBox().GetWidth());
415+
childResult.GetSplitRenderer().Move(tabWidth + sumOfAffectedRendererWidths - childResult.GetSplitRenderer(
416+
).GetOccupiedArea().GetBBox().GetWidth(), 0);
417417
}
418418
float tabAndNextElemWidth = tabWidth + childResult.GetOccupiedArea().GetBBox().GetWidth();
419419
if (hangingTabStop.GetTabAlignment() == TabAlignment.RIGHT && curWidth + tabAndNextElemWidth < hangingTabStop

port-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3f0b06e884c136b9d31400c2e0a60335f2b0572b
1+
35c39fb798538638ca164e992a6b614267813179

0 commit comments

Comments
 (0)