feat: add external drawing boxes and paged callbacks
CI / build-and-test (push) Canceled after 0s

This commit is contained in:
2026-08-31 22:10:06 +02:00
parent 3e5f197bdb
commit e2e2bfb854
10 changed files with 534 additions and 25 deletions
+10 -4
View File
@@ -92,14 +92,16 @@ public sealed class TemplateLoader(TemplateLimits? limits = null,
issues.Add(new(ValidationSeverity.Error, "Folgeseiten-Layout und Hauptlayout müssen dieselbe Seitengröße und Einheit verwenden."));
}
var allLayouts = continuationLayout is null ? new[] { layout } : new[] { layout, continuationLayout };
var flowBoxes = layout.Elements.OfType<FlowBoxElement>().ToList();
var flowBoxes = FlowElements(layout).ToList();
if (flowBoxes.Count > 1)
issues.Add(new(ValidationSeverity.Error, "Ein Layout darf höchstens eine FLOWBOX enthalten."));
issues.Add(new(ValidationSeverity.Error, "Ein Layout darf höchstens ein fließendes Element (FLOWBOX/FLOWDRAWBOX) enthalten."));
if (continuationLayout is not null)
{
var continuationFlows = continuationLayout.Elements.OfType<FlowBoxElement>().ToList();
var continuationFlows = FlowElements(continuationLayout).ToList();
if (flowBoxes.Count != 1 || continuationFlows.Count != 1)
issues.Add(new(ValidationSeverity.Error, "Bei einem Folgeseiten-Layout müssen Haupt- und Folgeseite jeweils genau eine FLOWBOX enthalten."));
issues.Add(new(ValidationSeverity.Error, "Bei einem Folgeseiten-Layout müssen Haupt- und Folgeseite jeweils genau ein gleichartiges fließendes Element enthalten."));
else if (flowBoxes[0].GetType() != continuationFlows[0].GetType())
issues.Add(new(ValidationSeverity.Error, "Haupt- und Folgeseite müssen denselben fließenden Elementtyp verwenden."));
else if (flowBoxes[0].X != continuationFlows[0].X || flowBoxes[0].Y != continuationFlows[0].Y
|| flowBoxes[0].Width != continuationFlows[0].Width || flowBoxes[0].Height != continuationFlows[0].Height)
issues.Add(new(ValidationSeverity.Error, "Die FLOWBOX muss auf Haupt- und Folgeseiten dieselbe Position und Größe haben."));
@@ -169,10 +171,14 @@ public sealed class TemplateLoader(TemplateLimits? limits = null,
TextElement { Placeholder: { } p } => p,
TextBoxElement { Placeholder: { } p } => p,
FlowBoxElement { Placeholder: { } p } => p,
DrawBoxElement d => d.Placeholder,
FlowDrawBoxElement d => d.Placeholder,
TableElement t => t.Placeholder,
ChartElement c => c.Placeholder,
_ => null,
}).Where(x => x is not null).Cast<string>().Distinct(StringComparer.Ordinal);
private static IEnumerable<TemplateElement> FlowElements(TemplateLayout layout) =>
layout.Elements.Where(x => x is FlowBoxElement or FlowDrawBoxElement);
internal static bool IsSafeRelativePath(string path) => !string.IsNullOrWhiteSpace(path)
&& !Path.IsPathRooted(path) && !path.Split('/', '\\').Any(part => part == ".." || part.Length == 0);