Improved hierarchy extraction

This commit is contained in:
MarcinZiabek
2022-12-12 00:42:24 +01:00
parent 2f55b8d386
commit a9c06db2e0
11 changed files with 28 additions and 9 deletions
+2 -2
View File
@@ -87,7 +87,7 @@ namespace QuestPDF.Drawing
RenderPass(pageContext, canvas, content);
if (applyInspection)
inspectionResultHandler(DocumentHierarchyProcessor.ExtractDocumentHierarchy(content));
inspectionResultHandler(content.ExtractDocumentHierarchy());
}
internal static void RenderPass<TCanvas>(PageContext pageContext, TCanvas canvas, Container content)
@@ -183,7 +183,7 @@ namespace QuestPDF.Drawing
{
content.VisitChildren(x =>
{
x.CreateProxy(y => y is ElementProxy ? y : new InspectionProxy(y));
x.CreateProxy(y => y is ElementProxy or Container ? y : new InspectionProxy(y));
});
}
@@ -7,7 +7,6 @@ namespace QuestPDF.Drawing.Proxy
{
internal class InspectionProxy : ElementProxy
{
public Dictionary<int, InspectionStateItem> Statistics { get; set; } = new();
public InspectionProxy(Element child)
+1 -1
View File
@@ -6,7 +6,7 @@ using QuestPDF.Infrastructure;
namespace QuestPDF.Elements
{
internal class ColumnItem : Container
internal class ColumnItem : ContainerElement
{
public bool IsRendered { get; set; }
}
+2 -1
View File
@@ -1,8 +1,9 @@
using System.ComponentModel;
using QuestPDF.Infrastructure;
namespace QuestPDF.Elements
{
internal class DebugPointer : Container
internal class DebugPointer : ContainerElement
{
public string Target { get; set; }
public bool Highlight { get; set; }
+6 -1
View File
@@ -6,7 +6,7 @@ using QuestPDF.Infrastructure;
namespace QuestPDF.Elements
{
internal class InlinedElement : Container
internal class InlinedElement : ContainerElement
{
}
@@ -49,6 +49,11 @@ namespace QuestPDF.Elements
return Elements;
}
internal override void CreateProxy(Func<Element?, Element?> create)
{
Elements.ForEach(x => x.Child = create(x.Child));
}
internal override SpacePlan Measure(Size availableSpace)
{
SetDefaultAlignment();
+5
View File
@@ -20,6 +20,11 @@ namespace QuestPDF.Elements
return Children;
}
internal override void CreateProxy(Func<Element?, Element?> create)
{
Children.ForEach(x => x.Child = create(x.Child));
}
internal override SpacePlan Measure(Size availableSpace)
{
return Children
+1 -1
View File
@@ -14,7 +14,7 @@ namespace QuestPDF.Elements
Relative
}
internal class RowItem : Container
internal class RowItem : ContainerElement
{
public bool IsRendered { get; set; }
public float Width { get; set; }
+5
View File
@@ -34,6 +34,11 @@ namespace QuestPDF.Elements.Table
return Cells;
}
internal override void CreateProxy(Func<Element?, Element?> create)
{
Cells.ForEach(x => x.Child = create(x.Child));
}
public void ResetState()
{
Initialize();
+3 -1
View File
@@ -1,6 +1,8 @@
using QuestPDF.Infrastructure;
namespace QuestPDF.Elements.Table
{
internal class TableCell : Container, ITableCellContainer
internal class TableCell : ContainerElement, ITableCellContainer
{
public int Row { get; set; } = 0;
public int RowSpan { get; set; } = 1;
+1 -1
View File
@@ -7,7 +7,7 @@ namespace QuestPDF.Infrastructure
}
class Slot : Container, ISlot
class Slot : ContainerElement, ISlot
{
}
@@ -13,6 +13,8 @@ public static class DocumentHierarchyProcessor
{
internal static InspectionElement ExtractDocumentHierarchy(this Container content)
{
content.RemoveExistingContainers();
var proxies = content.ExtractProxyOfType<InspectionProxy>();
return Map(proxies);