Führe Dokumente mit Kapiteln, Fassung, Seite und PDF mit Inhaltsverzeichnis ein (ADR-51)

Ein Dokument ist eine Komposition der Art document, ein Kapitel ein Text mit der
automatischen Materialart Dokumentkapitel; die Ebene steht in der Rolle. Der
Aufbaueditor bekommt den Kapitelarbeitsplatz (Übersicht, Ordnen als Block,
offene Eingaben bleiben beim Wechsel erhalten, Speichern als Entwurf,
Bereitstellen als Dokumentfassung). Module und Programme binden eine Fassung
über den gemeinsamen Picker ein. Mitglieder lesen sie mit anklickbarem
Inhaltsverzeichnis und laden ein PDF mit Inhaltsverzeichnis, Seitenzahlen,
Tabellen und Bildern. Ein älterer Stand liefert die gebundene Fassung weiter.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
LarsandClaude Sonnet 5.5 committed 2026-11-24 12:23:18 +01:00
1 parent c57a506f85
commit 3e2fd872c2
43 files changed
+2827 -64

No files matched your search

+47 -12
View File
@@ -279,9 +279,9 @@ private function image(array $block, float $x): void
$width = max(1.0, $found['width'] * $scale);
$height = max(1.0, $found['height'] * $scale);
$this->room($height + 8);
$this->pdf->image($x, $this->y - $height, $width, $height, $found['jpeg'], $found['width'], $found['height']);
$this->y -= $height + 8;
$this->room($height + 16);
$this->pdf->image($x, $this->y + 4 - $height, $width, $height, $found['jpeg'], $found['width'], $found['height']);
$this->y -= $height + 16;
}
/**
@@ -330,7 +330,7 @@ private function table(array $rows, float $x): void
$this->depth++;
$cell['lines'] = $this->cellLines($cell['blocks'], max(10.0, $inner), $size, $cell['header']);
$this->depth--;
$cell['height'] = max(1, count($cell['lines'])) * $lineHeight + 2 * $pad;
$cell['height'] = max($lineHeight, array_sum(array_column($cell['lines'], 'height'))) + 2 * $pad;
$prepared[] = $cell;
}
@@ -363,7 +363,7 @@ private function table(array $rows, float $x): void
return;
}
$drawRows = function (int $from, int $to) use ($prepared, $widths, $heights, $x, $size, $pad, $lineHeight): void {
$drawRows = function (int $from, int $to) use ($prepared, $widths, $heights, $x, $size, $pad): void {
$y = $this->y;
for ($r = $from; $r <= $to; $r++) {
@@ -379,6 +379,13 @@ private function table(array $rows, float $x): void
$textY = $y - $pad - $size;
foreach ($cell['lines'] as $line) {
if (isset($line['image'])) {
$this->pdf->image($cellLeft + $pad, $textY + $size - $line['image']['height'], $line['image']['width'], $line['image']['height'], $line['image']['jpeg'], $line['image']['pixelWidth'], $line['image']['pixelHeight']);
$textY -= $line['height'];
continue;
}
if ($line['marker'] !== null) {
$this->pdf->text($cellLeft + $pad + $line['indent'] - 12, $textY, $line['marker'], $size, $cell['header']);
}
@@ -390,7 +397,7 @@ private function table(array $rows, float $x): void
$cursor += PdfDocument::exactWidth($text, $size, $isBold || $cell['header']);
}
$textY -= $lineHeight;
$textY -= $line['height'];
}
}
@@ -528,10 +535,21 @@ private function columnWidths(array $cells, int $columns, float $available, floa
return array_map(fn (float $w): float => $w + $extra, $want);
}
// Der Platz über dem Mindestmaß wird gleichmäßig verteilt, aber keine Spalte bekommt mehr, als sie sich wünscht:
// Schmale Spalten behalten ihren Text in einer Zeile, die breite nimmt den Rest.
$widths = $min;
$room = $available - array_sum($min);
$wishes = array_sum($want) - array_sum($min);
$open = array_keys($min);
usort($open, fn (int $a, int $b): int => ($want[$a] - $min[$a]) <=> ($want[$b] - $min[$b]));
return array_map(fn (float $m, float $w): float => $m + $room * (($w - $m) / max(1.0, $wishes)), $min, $want);
foreach ($open as $position => $c) {
$share = $room / (count($open) - $position);
$give = min($want[$c] - $min[$c], $share);
$widths[$c] += $give;
$room -= $give;
}
return $widths;
}
/**
@@ -553,32 +571,49 @@ private function cellText(array $blocks): string
}
/**
* Zeilen einer Tabellenzelle: Absätze, Aufzählungen und Zwischenüberschriften; ein Bild in der Zelle entfällt.
* Zeilen einer Tabellenzelle: Absätze, Aufzählungen, Zwischenüberschriften und Bilder (höchstens 110 Punkt hoch, in
* Breite der Zelle). Jeder Eintrag trägt seine Höhe.
*
* @param list<array<string, mixed>> $blocks
* @return list<array{segments: list<array{0: string, 1: bool, 2: bool}>, indent: float, marker: ?string}>
* @return list<array<string, mixed>>
*/
private function cellLines(array $blocks, float $width, float $size, bool $header): array
{
$out = [];
$lineHeight = $size + 3;
foreach ($blocks as $block) {
if (in_array($block['type'], ['bullets', 'numbered'], true)) {
foreach ($block['items'] as $index => $item) {
foreach ($this->lines($item, $width - 12, $size, $header) as $i => $segments) {
$out[] = ['segments' => $segments, 'indent' => 12.0, 'marker' => $i === 0 ? ($block['type'] === 'bullets' ? '•' : ($index + 1).'.') : null];
$out[] = ['segments' => $segments, 'indent' => 12.0, 'marker' => $i === 0 ? ($block['type'] === 'bullets' ? '•' : ($index + 1).'.') : null, 'height' => $lineHeight];
}
}
continue;
}
if ($block['type'] === 'image') {
$found = $this->images === null ? null : ($this->images)((int) $block['id']);
if ($found !== null && isset($found['jpeg'])) {
$scale = min(1.0, $width / max(1, $found['width']), 110.0 / max(1, $found['height']));
$w = max(1.0, $found['width'] * $scale);
$h = max(1.0, $found['height'] * $scale);
$out[] = ['image' => ['jpeg' => $found['jpeg'], 'width' => $w, 'height' => $h, 'pixelWidth' => $found['width'], 'pixelHeight' => $found['height']], 'height' => $h + 4];
} elseif ($found !== null) {
$out[] = ['segments' => [['['.($found['note'] ?? 'Bild nicht verfügbar').']', false, true]], 'indent' => 0.0, 'marker' => null, 'height' => $lineHeight];
}
continue;
}
if (! isset($block['runs'])) {
continue;
}
foreach ($this->lines($block['runs'], $width, $size, $header || $block['type'] === 'heading', $block['type'] === 'quote') as $segments) {
$out[] = ['segments' => $segments, 'indent' => 0.0, 'marker' => null];
$out[] = ['segments' => $segments, 'indent' => 0.0, 'marker' => null, 'height' => $lineHeight];
}
}