فهرست منبع

Improved hierarchy extraction

MarcinZiabek 3 سال پیش
والد
کامیت
a9c06db2e0

+ 2 - 2
QuestPDF/Drawing/DocumentGenerator.cs

@@ -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));
             });
         }
         

+ 0 - 1
QuestPDF/Drawing/Proxy/InspectionProxy.cs

@@ -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
QuestPDF/Elements/Column.cs

@@ -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
QuestPDF/Elements/DebugPointer.cs

@@ -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
QuestPDF/Elements/Inlined.cs

@@ -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 - 0
QuestPDF/Elements/Layers.cs

@@ -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
QuestPDF/Elements/Row.cs

@@ -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 - 0
QuestPDF/Elements/Table/Table.cs

@@ -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
QuestPDF/Elements/Table/TableCell.cs

@@ -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
QuestPDF/Infrastructure/IComponent.cs

@@ -7,7 +7,7 @@ namespace QuestPDF.Infrastructure
         
     }
 
-    class Slot : Container, ISlot
+    class Slot : ContainerElement, ISlot
     {
         
     }

+ 2 - 0
QuestPDF/Previewer/Inspection/DocumentHierarchyProcessor.cs

@@ -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);