TemplateDesigner: Redesign des TemplateSkripts
This commit is contained in:
@@ -56,6 +56,71 @@ public sealed class TemplatingTests : IDisposable
|
||||
Assert.Equal(3, exception.Result.Issues.Count(issue => issue.Line is not null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void LayoutParser_LiestSeitentypenSlotsUndContentFlows()
|
||||
{
|
||||
var layout = new LayoutParser().Parse("""
|
||||
PAGE 210 297 mm
|
||||
#pragma format-version 3
|
||||
#pragma page-template first
|
||||
TEXT 20 20 "Briefkopf"
|
||||
#pragma flow-slot body x=20 y=80 w=170 h=190
|
||||
#pragma end-page-template
|
||||
#pragma page-template continuation
|
||||
#pragma flow-slot body x=20 y=25 w=170 h=245
|
||||
#pragma end-page-template
|
||||
#pragma content-flow body
|
||||
TEXTBOX $Text size=11 overflow=continue
|
||||
TEXT "Gruß" gap=8 keep-with-next=true
|
||||
TEXT $Name
|
||||
#pragma end-content-flow
|
||||
""");
|
||||
|
||||
Assert.Equal(3, layout.FormatVersion);
|
||||
Assert.Equal(2, layout.PageTemplates.Count);
|
||||
Assert.Equal(80, layout.PageTemplates[0].FlowSlots.Single().Y);
|
||||
Assert.Equal(3, layout.ContentFlows.Single().Elements.Count);
|
||||
Assert.IsType<TextBoxElement>(layout.ContentFlows.Single().Elements[0]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Renderer_FliesstLangenTextAufFolgeseitenWeiter()
|
||||
{
|
||||
var manifest = new TemplateManifest
|
||||
{
|
||||
Id = "flow", Name = "Flow",
|
||||
Placeholders = [new("Text", PlaceholderType.Multiline, true), new("Name", PlaceholderType.Text, true)],
|
||||
};
|
||||
var layout = new LayoutParser().Parse("""
|
||||
PAGE 210 297 mm
|
||||
#pragma format-version 3
|
||||
#pragma page-template first
|
||||
TEXT 20 15 "Erste Seite" size=16
|
||||
#pragma flow-slot body x=20 y=55 w=170 h=215
|
||||
#pragma end-page-template
|
||||
#pragma page-template continuation
|
||||
TEXT 20 12 "Folgeseite" size=9
|
||||
#pragma flow-slot body x=20 y=25 w=170 h=245
|
||||
#pragma end-page-template
|
||||
#pragma content-flow body
|
||||
TEXTBOX $Text size=11 overflow=continue
|
||||
TEXT "Mit freundlichen Grüßen" gap=8 keep-with-next=true
|
||||
TEXT $Name gap=3
|
||||
#pragma end-content-flow
|
||||
""");
|
||||
var loaded = new LoadedTemplate(manifest, layout, new Dictionary<string, byte[]>());
|
||||
var longText = string.Join('\n', Enumerable.Repeat("Dies ist eine ausreichend lange Textzeile für den Seitenumbruch.", 180));
|
||||
|
||||
var pages = new QuestTemplateRenderer().RenderPagesToPng(loaded,
|
||||
new DictionaryProvider(new Dictionary<string, PlaceholderValue>
|
||||
{
|
||||
["Text"] = new MultilineValue(longText), ["Name"] = new TextValue("M. Mustermann"),
|
||||
}), 40);
|
||||
|
||||
Assert.True(pages.Count >= 3);
|
||||
Assert.All(pages, page => Assert.True(page.Length > 500));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Loader_BlockiertPathTraversal()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user