Skip to content

Commit c13d606

Browse files
Snipxitext-teamcity
authored andcommitted
Add support for inline block elements
DEVSIX-1053 Autoported commit. Original commit hash: [ad0c281]
1 parent dd57aa7 commit c13d606

File tree

13 files changed

+213
-14
lines changed

13 files changed

+213
-14
lines changed
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

itext/itext.io/itext/io/LogMessageConstant.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ public sealed class LogMessageConstant {
100100

101101
public const String INCORRECT_PAGEROTATION = "Encounterd a page rotation that was not a multiple of 90°/ (Pi/2) when generating default appearances for form fields";
102102

103+
public const String INLINE_BLOCK_ELEMENT_WILL_BE_CLIPPED = "Inline block element does not fit into parent element and will be clipped";
104+
103105
public const String INPUT_STREAM_CONTENT_IS_LOST_ON_PDFSTREAM_SERIALIZATION = "PdfStream contains not null input stream. It's content will be lost in serialized object.";
104106

105107
public const String INVALID_INDIRECT_REFERENCE = "Invalid indirect reference {0} {1} R";

itext/itext.layout/itext/layout/element/Paragraph.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@ public virtual iText.Layout.Element.Paragraph Add(ILeafElement element) {
110110
return this;
111111
}
112112

113+
public virtual iText.Layout.Element.Paragraph Add(IBlockElement element) {
114+
childElements.Add(element);
115+
return this;
116+
}
117+
113118
/// <summary>
114119
/// Adds a
115120
/// <see cref="System.Collections.IList{E}"/>

itext/itext.layout/itext/layout/margincollapse/MarginsCollapseHandler.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,9 +451,12 @@ private void GetRidOfCollapseArtifactsAtopOccupiedArea() {
451451

452452
private static bool MarginsCouldBeSelfCollapsing(IRenderer renderer) {
453453
return !(renderer is TableRenderer) && !RendererIsFloated(renderer) && !HasBottomBorders(renderer) && !HasTopBorders
454-
(renderer) && !HasBottomPadding(renderer) && !HasTopPadding(renderer) && !HasPositiveHeight(renderer);
454+
(renderer) && !HasBottomPadding(renderer) && !HasTopPadding(renderer) && !HasPositiveHeight(renderer)
455+
&& !(IsBlockElement(renderer) && renderer is AbstractRenderer && ((AbstractRenderer)renderer).GetParent
456+
() is LineRenderer);
455457
}
456458

459+
// inline block
457460
private static bool FirstChildMarginAdjoinedToParent(IRenderer parent) {
458461
return !(parent is RootRenderer) && !(parent is TableRenderer) && !(parent is CellRenderer) && !RendererIsFloated
459462
(parent) && !HasTopBorders(parent) && !HasTopPadding(parent);

itext/itext.layout/itext/layout/renderer/AbstractRenderer.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,22 @@ protected internal virtual void AddAllProperties(IDictionary<int, Object> proper
712712
return ((iText.Layout.Renderer.AbstractRenderer)childRenderers[0]).GetFirstYLineRecursively();
713713
}
714714

715+
protected internal virtual float? GetLastYLineRecursively() {
716+
if (childRenderers.Count == 0) {
717+
return null;
718+
}
719+
for (int i = childRenderers.Count - 1; i >= 0; i--) {
720+
IRenderer child = childRenderers[i];
721+
if (child is iText.Layout.Renderer.AbstractRenderer) {
722+
float? lastYLine = ((iText.Layout.Renderer.AbstractRenderer)child).GetLastYLineRecursively();
723+
if (lastYLine != null) {
724+
return lastYLine;
725+
}
726+
}
727+
}
728+
return null;
729+
}
730+
715731
/// <summary>Applies margins of the renderer on the given rectangle</summary>
716732
/// <param name="rect">a rectangle margins will be applied on.</param>
717733
/// <param name="reverse">

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

Lines changed: 164 additions & 12 deletions
Large diffs are not rendered by default.

itext/itext.layout/itext/layout/renderer/ParagraphRenderer.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,19 @@ public virtual IList<LineRenderer> GetLines() {
490490
return lines[0].GetFirstYLineRecursively();
491491
}
492492

493+
protected internal override float? GetLastYLineRecursively() {
494+
if (lines == null || lines.Count == 0) {
495+
return null;
496+
}
497+
for (int i = lines.Count - 1; i >= 0; i--) {
498+
float? yLine = lines[i].GetLastYLineRecursively();
499+
if (yLine != null) {
500+
return yLine;
501+
}
502+
}
503+
return null;
504+
}
505+
493506
[Obsolete]
494507
protected internal virtual iText.Layout.Renderer.ParagraphRenderer CreateOverflowRenderer() {
495508
return (iText.Layout.Renderer.ParagraphRenderer)GetNextRenderer();

0 commit comments

Comments
 (0)