[208] Anonyme Abgabe vollständig: Berichte, IFC, DXF-Blattnamen, STEP, Blender-Paket, Dateinamen über zentrale competitionIdentity; Test über alle Formate
This commit is contained in:
29 files changed
+488
-72
No files matched your search
@@ -17,6 +17,7 @@ Abschnitt 3.4).
|
||||
| `layoutPdf.ts` | alle Layouts eines Ordners als Mehrseiten-PDF |
|
||||
| `pdfLayers.ts` | PDF-Ebenen (Optional Content Groups, `[80]`) |
|
||||
| `pdfInfo.ts` | PDF-Info-Wörterbuch; bei anonymer Wettbewerbs-Abgabe nur das Kennwort, Producer/Datum längengleich neutralisiert (`[208]`) |
|
||||
| `competitionIdentity.ts` | Anonyme Abgabe ([208]): `competitionIdentity`, `exportProjectName`, `reportHead`, Gegenprüfer `identityLeaks`; alle Exporter holen Name/Autor/Zeitstempel hier. Test `competitionAnonymous.test.ts` |
|
||||
| `exportDxf.ts` | DXF/DWG des Grundrisses in Modellmetern; Schreiben in `src-tauri/fileio/src/export.rs` |
|
||||
| `legendSvg.ts` | Legende als Plan-/Druck-SVG (`[82]`) |
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
//
|
||||
// Die Flächenarten folgen SIA 416, die Kennziffern der IVHB; Herleitung im Kern (`flaechen.rs`).
|
||||
|
||||
import { reportHead } from "./competitionIdentity";
|
||||
import { anonymizeJsPdf } from "./pdfInfo";
|
||||
import { jsPDF } from "jspdf";
|
||||
import type { Project } from "../model/types";
|
||||
import { t } from "../i18n/translate";
|
||||
@@ -36,6 +38,8 @@ export interface ReportSection {
|
||||
export interface AreaReport {
|
||||
title: string;
|
||||
projectName: string;
|
||||
/** Anonyme Wettbewerbs-Abgabe ([208]): `projectName` ist das Kennwort; das PDF trägt keine Erzeuger- und Datumsangaben. */
|
||||
anonymous?: boolean;
|
||||
sections: ReportSection[];
|
||||
/** Fussnoten (Quellen, Annahmen). */
|
||||
notes: string[];
|
||||
@@ -111,7 +115,7 @@ export function buildAreaReport(project: Project, opts: AreaReportOptions = {}):
|
||||
notes.push(t("areas.foot.ivhb"));
|
||||
addNotes(v.notes);
|
||||
}
|
||||
return { title: t("areas.title"), projectName: project.name ?? "", sections, notes };
|
||||
return { title: t("areas.title"), ...reportHead(project), sections, notes };
|
||||
}
|
||||
|
||||
// ── CSV, Seitenaufteilung, SVG: rechnet der Kern (`core/src/area_report.rs`, Bericht als JSON) ─────────────
|
||||
@@ -185,5 +189,6 @@ export function buildAreaReportPdf(report: AreaReport, o: ReportLayoutOptions =
|
||||
}
|
||||
}
|
||||
});
|
||||
if (report.anonymous) anonymizeJsPdf(doc, report.projectName);
|
||||
return doc;
|
||||
}
|
||||
@@ -19,6 +19,7 @@
|
||||
// Achsen in `scene.json`: Modell-Koordinaten (x Ost, y Nord, z oben, Meter) — Blenders glTF-Import dreht das
|
||||
// Y-oben-GLB genau dorthin zurück, Kamera und Sonne brauchen im Skript keine Umrechnung.
|
||||
|
||||
import { exportProjectName } from "./competitionIdentity";
|
||||
import type { Camera, ComponentMaterial, LayoutOrientation, LayoutPaperFormat, Project } from "../model/types";
|
||||
import { projectLatLon, sunPosition } from "../analysis/sun";
|
||||
import { sheetSizeMm } from "../model/layoutModel";
|
||||
@@ -392,7 +393,7 @@ export async function buildRenderPackage(project: Project, opts: RenderOptions,
|
||||
|
||||
const scene: RenderScene = {
|
||||
version: 1,
|
||||
project: project.name || "projekt",
|
||||
project: exportProjectName(project) || "projekt",
|
||||
model: "model.glb",
|
||||
output: "render.png",
|
||||
resolution: { width: Math.round(opts.width), height: Math.round(opts.height) },
|
||||
|
||||
@@ -0,0 +1,186 @@
|
||||
// [208] Anonyme Wettbewerbs-Abgabe: kein Export verrät Büro, Bearbeiter:in, Projektname oder Projektnummer — nur das
|
||||
// Kennwort. Ein Beispielprojekt mit gesetzten Namen geht durch alle Formate (PDF-Info und -Text, Berichte als CSV/PDF,
|
||||
// IFC4/IFC2x3, DXF ASCII/Binär/DWG, SVG, OBJ/MTL/STL/glTF, STEP, CSV, Blender-Paket); danach darf keiner der Namen
|
||||
// vorkommen (Gross-/Kleinschreibung egal). Gegenprobe: ohne Anonymität stehen die Namen in den Ausgaben, der Test
|
||||
// prüft also wirklich etwas. Muster: e2e `competition`, `layoutPdf.images.test.ts`.
|
||||
|
||||
import "../engine/fileioWasm.setup";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { inflateSync } from "node:zlib";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { sampleProject } from "../model/sampleProject";
|
||||
import { createPosterMaster, posterTemplate } from "../model/posterTemplates";
|
||||
import { flattenCategories } from "../model/types";
|
||||
import type { Layout, Project } from "../model/types";
|
||||
import { generatePlan } from "../plan/generatePlan";
|
||||
import { buildPlanDwg, buildPlanDxf, buildPlanDxfBinary } from "./exportDxf";
|
||||
import { exportIfcSpf } from "./exportIfc";
|
||||
import { exportGlb, exportGltf, exportMtl, exportObj, exportStl } from "./exportMesh";
|
||||
import { exportScheduleCsv } from "./exportSchedule";
|
||||
import { exportProjectStep } from "./exportStep";
|
||||
import { buildPagesPdf, layoutPages, pdfBytes } from "./layoutPdf";
|
||||
import { planToSvgString } from "./planToSvgString";
|
||||
import { areaReportToCsv, buildAreaReport, buildAreaReportPdf } from "./areaReport";
|
||||
import { buildProgramReport } from "./programReport";
|
||||
import { buildRoomBookReport } from "./roomBook";
|
||||
import { buildOpeningReport } from "./openingSchedule";
|
||||
import { buildElementReport } from "./elementSchedule";
|
||||
import { buildCostReport } from "./costReport";
|
||||
import { buildRenderPackage } from "./blenderRender";
|
||||
import { identityLeaks, identifyingTexts, NEUTRAL_ISO } from "./competitionIdentity";
|
||||
import { pdfInfoText } from "./pdfInfo";
|
||||
|
||||
const OFFICE = "BUEROXYZ Architekten AG";
|
||||
const AUTHOR = "BEARBEITERQ Muster";
|
||||
const NAME = "PROJEKTNAMEZ Haus";
|
||||
const NUMBER = "NUMMER4711";
|
||||
const KEYWORD = "FALKE 7";
|
||||
const SECRETS = [OFFICE, AUTHOR, NAME, NUMBER];
|
||||
|
||||
/** Ganzes Beispielprojekt mit Büro-, Bearbeiter- und Projektangaben; Blatt mit Plakat-Kopf (zeigt Projekt/Autor). */
|
||||
function project(anonymous: boolean | null): Project {
|
||||
const master = createPosterMaster("m1", posterTemplate("poster-a1-landscape")!);
|
||||
master.titleBlock = { projectName: `${OFFICE} ${NAME}`, author: AUTHOR };
|
||||
const layout: Layout = { id: "l1", name: "Grundriss", paper: "a1", orientation: "landscape", masterId: "m1", viewports: [] };
|
||||
return {
|
||||
...sampleProject,
|
||||
name: NAME,
|
||||
projectNumber: NUMBER,
|
||||
masterLayouts: [master],
|
||||
layouts: [layout],
|
||||
...(anonymous === null ? {} : { competition: { anonymous, keyword: KEYWORD } }),
|
||||
} as Project;
|
||||
}
|
||||
|
||||
const latin1 = (b: Uint8Array): string => Buffer.from(b).toString("latin1");
|
||||
|
||||
/** Seiteninhalt (Flate-Streams) des PDF entpackt, hintereinander. */
|
||||
function streamsText(bytes: Uint8Array): string {
|
||||
const all = Buffer.from(bytes);
|
||||
const text = all.toString("latin1");
|
||||
let out = "";
|
||||
for (const m of text.matchAll(/stream\r?\n/g)) {
|
||||
const from = m.index! + m[0].length;
|
||||
const to = text.indexOf("endstream", from);
|
||||
try {
|
||||
out += inflateSync(all.subarray(from, to)).toString("latin1") + "\n";
|
||||
} catch {
|
||||
// kein Flate-Stream
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/** Alle Ausgaben, die ohne Browser/GPU entstehen: Name → Text (Binärformate als latin1). */
|
||||
async function allOutputs(p: Project): Promise<Record<string, string>> {
|
||||
const plan = generatePlan(p, "eg", new Set(flattenCategories(p.layers).map((l) => l.code)));
|
||||
const out: Record<string, string> = {};
|
||||
// PDF: Blatt (Info + Seiteninhalt) und Berichte (Info + Inhalt)
|
||||
const doc = await buildPagesPdf(p, layoutPages(p, ["l1"]));
|
||||
const sheet = pdfBytes(p, doc!);
|
||||
out["PDF-Blatt"] = latin1(sheet);
|
||||
out["PDF-Blatt-Text"] = streamsText(sheet);
|
||||
out["PDF-Blatt-Info"] = pdfInfoText(sheet);
|
||||
const reports = { Flaechen: buildAreaReport(p, { ivhb: true }), Programm: buildProgramReport(p), Raumbuch: buildRoomBookReport(p), Oeffnungen: buildOpeningReport(p), Bauteile: buildElementReport(p), Kosten: buildCostReport(p) };
|
||||
for (const [name, report] of Object.entries(reports)) {
|
||||
out[`CSV-${name}`] = areaReportToCsv(report);
|
||||
const bytes = new Uint8Array(buildAreaReportPdf(report).output("arraybuffer"));
|
||||
out[`PDF-${name}`] = latin1(bytes);
|
||||
out[`PDF-${name}-Text`] = streamsText(bytes);
|
||||
out[`PDF-${name}-Info`] = pdfInfoText(bytes);
|
||||
}
|
||||
// IFC
|
||||
out["IFC4"] = exportIfcSpf(p);
|
||||
out["IFC2x3"] = exportIfcSpf(p, { schema: "IFC2X3" });
|
||||
// DXF/DWG (mit Papierbereich der Projekt-Layouts)
|
||||
out["DXF"] = buildPlanDxf(plan, p, { paperLayout: true, levelId: "eg" });
|
||||
out["DXF-binaer"] = latin1(buildPlanDxfBinary(plan, p, { paperLayout: true, levelId: "eg" }));
|
||||
out["DWG"] = latin1(buildPlanDwg(plan, p, { paperLayout: true, levelId: "eg" }));
|
||||
// SVG, Mesh, CSV
|
||||
out["SVG"] = planToSvgString(plan, { hatch: true });
|
||||
out["OBJ"] = exportObj(p, {}, "m.mtl");
|
||||
out["OBJ-ohne-MTL"] = exportObj(p);
|
||||
out["MTL"] = exportMtl(p);
|
||||
out["STL"] = exportStl(p);
|
||||
out["glTF"] = exportGltf(p);
|
||||
out["GLB"] = latin1(exportGlb(p));
|
||||
out["CSV-Bauteilliste"] = exportScheduleCsv(p);
|
||||
// STEP (truck-WASM)
|
||||
const mod: any = await import("../engine/pkgTruck/trucksolid.js");
|
||||
await mod.default({ module_or_path: readFileSync("src/engine/pkgTruck/trucksolid_bg.wasm") });
|
||||
out["STEP"] = (await exportProjectStep(p)).text;
|
||||
// Blender-Paket (scene.json)
|
||||
const pkg = await buildRenderPackage(p, { width: 640, height: 360, samples: 16, when: new Date(Date.UTC(2026, 5, 21, 10, 0, 0)), camera: { preset: "iso" } });
|
||||
out["Blender-scene.json"] = new TextDecoder().decode(pkg.files.find((f) => f.path === "scene.json")!.bytes);
|
||||
return out;
|
||||
}
|
||||
|
||||
describe("anonyme Wettbewerbs-Abgabe in allen Ausgaben", () => {
|
||||
it("Gegenprobe: ohne Anonymität stehen die Angaben in den Ausgaben (der Test prüft etwas)", async () => {
|
||||
const p = project(false);
|
||||
expect(identifyingTexts(p)).toEqual(expect.arrayContaining([NAME, NUMBER, AUTHOR]));
|
||||
const o = await allOutputs(p);
|
||||
for (const [where, what] of [
|
||||
["IFC4", NAME],
|
||||
["CSV-Flaechen", NAME],
|
||||
["PDF-Flaechen-Text", NAME],
|
||||
["PDF-Blatt-Text", AUTHOR],
|
||||
["Blender-scene.json", NAME],
|
||||
] as const) {
|
||||
expect(o[where], where).toContain(what);
|
||||
}
|
||||
}, 120000);
|
||||
|
||||
it("anonym: keine Ausgabe nennt Büro, Bearbeiter:in, Projektname oder Projektnummer", async () => {
|
||||
const p = project(true);
|
||||
const o = await allOutputs(p);
|
||||
const leaks: string[] = [];
|
||||
for (const [where, text] of Object.entries(o)) {
|
||||
for (const secret of SECRETS) if (text.toLowerCase().includes(secret.toLowerCase())) leaks.push(`${where}: ${secret}`);
|
||||
for (const l of identityLeaks(p, text)) leaks.push(`${where}: ${l}`);
|
||||
}
|
||||
expect(leaks).toEqual([]);
|
||||
}, 120000);
|
||||
|
||||
it("anonym: das Kennwort steht, wo es stehen soll", async () => {
|
||||
const o = await allOutputs(project(true));
|
||||
expect(o["PDF-Blatt-Text"]).toContain(`(${KEYWORD})`);
|
||||
expect(o["PDF-Blatt-Info"]).toContain(`/Title (${KEYWORD})`);
|
||||
expect(o["PDF-Flaechen-Info"]).toContain(`/Title (${KEYWORD})`);
|
||||
expect(o["PDF-Flaechen-Text"]).toContain(KEYWORD);
|
||||
expect(o["CSV-Flaechen"].split("\n")[1]).toBe(KEYWORD);
|
||||
expect(o["IFC4"]).toContain(`IFCPROJECT('`);
|
||||
expect(o["IFC4"]).toContain(`'${KEYWORD}'`);
|
||||
expect(o["IFC4"]).toContain(`FILE_NAME('${KEYWORD}.ifc','${NEUTRAL_ISO}'`);
|
||||
expect(JSON.parse(o["Blender-scene.json"]).project).toBe(KEYWORD);
|
||||
}, 120000);
|
||||
|
||||
it("anonym: keine Zeit- und Erzeugerspuren in PDF-Info, IFC und STEP", async () => {
|
||||
const o = await allOutputs(project(true));
|
||||
const year = String(new Date().getFullYear());
|
||||
for (const key of ["PDF-Blatt-Info", "PDF-Flaechen-Info", "PDF-Raumbuch-Info"]) {
|
||||
expect(o[key], key).not.toMatch(/jsPDF|Dossier/i);
|
||||
expect(o[key], key).not.toContain(`D:${year}`);
|
||||
expect(o[key], key).toContain("D:20000101000000");
|
||||
}
|
||||
for (const key of ["IFC4", "IFC2x3"]) {
|
||||
// „Dossier_Qto_…" ist der Name eines Eigenschaftssatzes (Programm-Konvention), keine Angabe zur Herkunft.
|
||||
expect(o[key].replace(/Dossier_Qto_/g, ""), key).not.toMatch(/dossier/i);
|
||||
expect(o[key], key).not.toContain(`${year}-`);
|
||||
expect(o[key], key).toContain(`'${NEUTRAL_ISO}'`);
|
||||
}
|
||||
expect(o["STEP"]).not.toContain(`${year}-`);
|
||||
expect(o["STEP"]).toContain("2000-01-01 00:00:00.000");
|
||||
}, 120000);
|
||||
|
||||
it("anonym: Blattnamen der Projekt-Layouts erscheinen im DXF nur als „Blatt n“", async () => {
|
||||
const p = project(true);
|
||||
p.layouts = [{ ...p.layouts![0], name: `${OFFICE} Plan 1` }];
|
||||
const plan = generatePlan(p, "eg", new Set(flattenCategories(p.layers).map((l) => l.code)));
|
||||
const dxf = buildPlanDxf(plan, p, { paperLayout: true, levelId: "eg" });
|
||||
expect(dxf).not.toContain("BUEROXYZ");
|
||||
expect(dxf).toContain("Blatt_1");
|
||||
const plain = { ...p, competition: undefined } as Project;
|
||||
expect(buildPlanDxf(plan, plain, { paperLayout: true, levelId: "eg" })).toContain("BUEROXYZ_Architekten_AG_Plan_1");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,94 @@
|
||||
// Anonyme Wettbewerbs-Abgabe ([208]): EINE Stelle, die sagt, welche Angaben in eine Ausgabe dürfen. Ist
|
||||
// `Project.competition` anonym, trägt keine Ausgabe (PDF, IFC, DXF/DWG, SVG, CSV, Bilder, Blender-Paket, STEP …)
|
||||
// Büro, Bearbeiter:in, Projektname, Projektnummer, Adresse oder Benutzername — nur das Kennwort. Jeder Exporter holt
|
||||
// seine Angaben hier, statt `project.name` selbst zu lesen. Das Gegenstück im Kern: `src-tauri/core/src/competition.rs`
|
||||
// (IFC-Sammler, DXF-Blattnamen, Plankopf); dort gilt dieselbe Regel.
|
||||
//
|
||||
// Bezeichner englisch, Kommentare deutsch.
|
||||
|
||||
import type { Project } from "../model/types";
|
||||
|
||||
type CompetitionSource = Pick<Project, "competition">;
|
||||
|
||||
/** Fester Zeitstempel anonymer Ausgaben (2000-01-01 00:00:00 UTC): keine Spur, wann und wo gespeichert wurde. */
|
||||
export const NEUTRAL_DATE = new Date(Date.UTC(2000, 0, 1, 0, 0, 0));
|
||||
/** Derselbe Zeitstempel als ISO-Text ohne Zone (STEP-/IFC-Kopf). */
|
||||
export const NEUTRAL_ISO = "2000-01-01T00:00:00";
|
||||
|
||||
/** Ist die Abgabe anonym? */
|
||||
export function isAnonymous(project: CompetitionSource): boolean {
|
||||
return project.competition?.anonymous === true;
|
||||
}
|
||||
|
||||
/** Kennwort der Abgabe (getrimmt, leer ohne Wettbewerb). */
|
||||
export function competitionKeyword(project: CompetitionSource): string {
|
||||
return (project.competition?.keyword ?? "").trim();
|
||||
}
|
||||
|
||||
/** Projektname für Schriftfelder, Berichtsköpfe, Dateinamen und Metadaten der Exporte: bei anonymer Abgabe das Kennwort. */
|
||||
export function exportProjectName(project: Pick<Project, "name" | "competition">): string {
|
||||
return isAnonymous(project) ? competitionKeyword(project) : (project.name ?? "");
|
||||
}
|
||||
|
||||
/** Was eine Ausgabe über die Herkunft sagen darf. */
|
||||
export interface CompetitionIdentity {
|
||||
anonymous: boolean;
|
||||
keyword: string;
|
||||
/** Projektname der Ausgabe (anonym: das Kennwort). */
|
||||
projectName: string;
|
||||
/** Bearbeiter:in der Ausgabe (anonym: leer). */
|
||||
author(raw?: string | null): string;
|
||||
/** Zeitstempel der Ausgabe (anonym: fest {@link NEUTRAL_DATE}). */
|
||||
timestamp(now?: Date): Date;
|
||||
/** Erzeuger-/Programmangabe in Metadaten (anonym: leer). */
|
||||
creator(name?: string): string;
|
||||
}
|
||||
|
||||
/** Die Angaben, die in die Ausgaben dieses Projekts dürfen. */
|
||||
export function competitionIdentity(project: Pick<Project, "name" | "competition">): CompetitionIdentity {
|
||||
const anonymous = isAnonymous(project);
|
||||
return {
|
||||
anonymous,
|
||||
keyword: competitionKeyword(project),
|
||||
projectName: exportProjectName(project),
|
||||
author: (raw) => (anonymous ? "" : (raw ?? "")),
|
||||
timestamp: (now = new Date()) => (anonymous ? NEUTRAL_DATE : now),
|
||||
creator: (name = "Dossier") => (anonymous ? "" : name),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Angaben des Projekts, die eine anonyme Ausgabe nicht verraten darf (Name, Nummer, Titelblock-Bearbeiter:in):
|
||||
* Grundlage für den Gegenprüfer {@link identityLeaks} und die Tests.
|
||||
*/
|
||||
export function identifyingTexts(project: Project): string[] {
|
||||
const out: string[] = [];
|
||||
const add = (s: string | null | undefined) => {
|
||||
const v = (s ?? "").trim();
|
||||
if (v.length >= 3) out.push(v);
|
||||
};
|
||||
add(project.name);
|
||||
add(project.projectNumber);
|
||||
for (const m of project.masterLayouts ?? []) {
|
||||
add(m.titleBlock?.projectName);
|
||||
add(m.titleBlock?.author);
|
||||
}
|
||||
return [...new Set(out)];
|
||||
}
|
||||
|
||||
/** Kopf der Berichte (Flächen, Raumbuch, Kosten …): Projektname der Ausgabe und Anonym-Kennzeichen für das PDF. */
|
||||
export function reportHead(project: Pick<Project, "name" | "competition">): { projectName: string; anonymous?: boolean } {
|
||||
return isAnonymous(project) ? { projectName: competitionKeyword(project), anonymous: true } : { projectName: project.name ?? "" };
|
||||
}
|
||||
|
||||
/** STEP-Kopf anonym: der Zeitstempel in FILE_NAME wird fest ({@link NEUTRAL_ISO}); Autor und Organisation schreibt truck leer. */
|
||||
export function neutralizeStepText(text: string): string {
|
||||
const stamp = `${NEUTRAL_ISO.replace("T", " ")}.000`;
|
||||
return text.replace(/(FILE_NAME\('[^']*', ')\d{4}-\d{2}-\d{2}[ T]\d{2}:\d{2}:\d{2}(?:\.\d+)?(')/, `$1${stamp}$2`);
|
||||
}
|
||||
|
||||
/** Welche der Angaben stehen (ohne Beachtung der Gross-/Kleinschreibung) im Text? Leer = sauber. */
|
||||
export function identityLeaks(project: Project, text: string): string[] {
|
||||
const hay = text.toLowerCase();
|
||||
return identifyingTexts(project).filter((s) => hay.includes(s.toLowerCase()));
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
// dieselben Ausgaben (CSV über `areaReportToCsv`, Vektor-PDF über `buildAreaReportPdf`). Gerechnet wird im
|
||||
// Kern (`analysis/costEstimate.ts` → `kosten.rs`); hier nur Aufbau und Beschriftung mit `t()`.
|
||||
|
||||
import { reportHead } from "./competitionIdentity";
|
||||
import type { Project } from "../model/types";
|
||||
import { t } from "../i18n/translate";
|
||||
import { computeCostEstimate, formatChf } from "../analysis/costEstimate";
|
||||
@@ -48,7 +49,7 @@ export function buildCostReport(project: Project, result: CostResult = computeCo
|
||||
|
||||
return {
|
||||
title: t("costs.title"),
|
||||
projectName: project.name ?? "",
|
||||
...reportHead(project),
|
||||
sections: [
|
||||
{
|
||||
heading: `${t("costs.table")} · ${t(`costs.method.${r.method}`)}`,
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// `elementSchedule` und `uValue`); hier nur Beschriftung mit `t()` und das Berichtsmodell für CSV/SVG/PDF
|
||||
// (wie die Fenster-/Türliste, `openingSchedule.ts`).
|
||||
|
||||
import { reportHead } from "./competitionIdentity";
|
||||
import type { Layer, Project } from "../model/types";
|
||||
import { t } from "../i18n/translate";
|
||||
import { documentFor } from "../core/document";
|
||||
@@ -71,5 +72,5 @@ export function buildElementReport(project: Project): AreaReport {
|
||||
widths: [4, 1.6, 1.4, 1.3, 1.3, 1.4],
|
||||
rows: g.list.map((r): ReportRow => ({ cells: [r.typeName, r.floor, num(r.area, 2), num(r.thickness * 100, 1), r.u === null ? t("elemSchedule.incomplete") : num(r.u, 2), externalText(r.external)] })),
|
||||
}));
|
||||
return { title: t("elemSchedule.title"), projectName: project.name ?? "", sections, notes: [t("elemSchedule.foot")] };
|
||||
return { title: t("elemSchedule.title"), ...reportHead(project), sections, notes: [t("elemSchedule.foot")] };
|
||||
}
|
||||
@@ -13,6 +13,7 @@
|
||||
//
|
||||
// Koordinaten: Modell-Meter, X/Y = Grundriss, Z = Höhe (wie die Eingabe von render3d).
|
||||
|
||||
import { exportProjectName, isAnonymous, neutralizeStepText } from "./competitionIdentity";
|
||||
import type { Project } from "../model/types";
|
||||
import { documentFor } from "../core/document";
|
||||
import { exportStepSolids } from "../engine/truckSolid";
|
||||
@@ -52,8 +53,8 @@ export async function exportProjectStep(project: Project, fileName = ""): Promis
|
||||
const skipped: StepExportResult["skipped"] = [];
|
||||
// Erst alle zusammen versuchen (Normalfall); nur bei Fehler einzeln prüfen.
|
||||
try {
|
||||
const text = await exportStepSolids(specs, fileName || project.name);
|
||||
return { text, count: specs.length, skipped };
|
||||
const text = await exportStepSolids(specs, fileName || exportProjectName(project));
|
||||
return { text: isAnonymous(project) ? neutralizeStepText(text) : text, count: specs.length, skipped };
|
||||
} catch {
|
||||
/* einzeln weiter */
|
||||
}
|
||||
@@ -76,6 +77,6 @@ export async function exportProjectStep(project: Project, fileName = ""): Promis
|
||||
skipped.push({ index: i, error: e instanceof Error ? e.message : String(e) });
|
||||
}
|
||||
}
|
||||
const text = await exportStepSolids(good, fileName || project.name);
|
||||
return { text, count: good.length, skipped };
|
||||
const text = await exportStepSolids(good, fileName || exportProjectName(project));
|
||||
return { text: isAnonymous(project) ? neutralizeStepText(text) : text, count: good.length, skipped };
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
// und der Berichtsaufbau, damit CSV, SVG und PDF dieselbe Quelle haben wie der Flächennachweis
|
||||
// (`areaReport.ts`: `areaReportToCsv` / `areaReportToSvg` / `buildAreaReportPdf`).
|
||||
|
||||
import { reportHead } from "./competitionIdentity";
|
||||
import type { Project } from "../model/types";
|
||||
import { t } from "../i18n/translate";
|
||||
import { documentFor } from "../core/document";
|
||||
@@ -141,5 +142,5 @@ export function buildOpeningReport(project: Project): AreaReport {
|
||||
const doors = rows.filter((r) => r.kind === "door");
|
||||
if (windows.length) sections.push(windowSection(windows));
|
||||
if (doors.length) sections.push(doorSection(doors));
|
||||
return { title: t("openings.title"), projectName: project.name ?? "", sections, notes: rows.some((r) => r.revealAreas?.length) ? [t("openings.foot"), t("openings.revealFoot")] : [t("openings.foot")] };
|
||||
return { title: t("openings.title"), ...reportHead(project), sections, notes: rows.some((r) => r.revealAreas?.length) ? [t("openings.foot"), t("openings.revealFoot")] : [t("openings.foot")] };
|
||||
}
|
||||
+28
-14
@@ -7,21 +7,9 @@
|
||||
|
||||
import type { jsPDF } from "jspdf";
|
||||
import type { Project } from "../model/types";
|
||||
import { competitionKeyword, exportProjectName, isAnonymous } from "./competitionIdentity";
|
||||
|
||||
/** Ist die Abgabe anonym? */
|
||||
export function isAnonymous(project: Pick<Project, "competition">): boolean {
|
||||
return project.competition?.anonymous === true;
|
||||
}
|
||||
|
||||
/** Kennwort der Abgabe (getrimmt, leer ohne Wettbewerb). */
|
||||
export function competitionKeyword(project: Pick<Project, "competition">): string {
|
||||
return (project.competition?.keyword ?? "").trim();
|
||||
}
|
||||
|
||||
/** Projektname für Schriftfelder und Dateinamen der Exporte: bei anonymer Abgabe das Kennwort. */
|
||||
export function exportProjectName(project: Pick<Project, "name" | "competition">): string {
|
||||
return isAnonymous(project) ? competitionKeyword(project) : (project.name ?? "");
|
||||
}
|
||||
export { isAnonymous, competitionKeyword, exportProjectName };
|
||||
|
||||
/** Info-Felder, die ins PDF gehören: anonym nur das Kennwort als Titel, sonst Projektname und Autor des Titelblocks. */
|
||||
export function pdfInfoFields(project: Pick<Project, "name" | "competition">, author?: string): { title: string; author: string; subject: string; keywords: string; creator: string } {
|
||||
@@ -29,6 +17,32 @@ export function pdfInfoFields(project: Pick<Project, "name" | "competition">, au
|
||||
return { title: project.name ?? "", author: author ?? "", subject: "", keywords: "", creator: "Dossier" };
|
||||
}
|
||||
|
||||
/**
|
||||
* Anonymes jsPDF-Dokument: Info-Felder nur mit Kennwort, und `output("arraybuffer"|"blob")` sowie `save()` liefern die
|
||||
* nachbearbeiteten Bytes (jsPDF schreibt Producer und Datum selbst). So bleiben die Aufrufer (`doc.save(name)`) gleich.
|
||||
*/
|
||||
export function anonymizeJsPdf(doc: jsPDF, keyword: string): void {
|
||||
const project = { name: "", competition: { anonymous: true, keyword } };
|
||||
applyPdfInfo(doc, project);
|
||||
type Output = (type?: string, options?: unknown) => unknown;
|
||||
const output = (doc.output as unknown as Output).bind(doc);
|
||||
const bytes = () => finishPdfBytes(project, new Uint8Array(output("arraybuffer") as ArrayBuffer));
|
||||
(doc as unknown as { output: Output }).output = (type, options) => {
|
||||
if (type === "arraybuffer") return bytes().slice().buffer;
|
||||
if (type === "blob") return new Blob([bytes() as BlobPart], { type: "application/pdf" });
|
||||
return output(type, options);
|
||||
};
|
||||
doc.save = ((fileName?: string) => {
|
||||
const url = URL.createObjectURL(new Blob([bytes() as BlobPart], { type: "application/pdf" }));
|
||||
const a = document.createElement("a");
|
||||
a.href = url;
|
||||
a.download = fileName ?? "bericht.pdf";
|
||||
a.click();
|
||||
setTimeout(() => URL.revokeObjectURL(url), 1000);
|
||||
return doc;
|
||||
}) as typeof doc.save;
|
||||
}
|
||||
|
||||
/** Setzt die Info-Felder auf dem jsPDF-Dokument. */
|
||||
export function applyPdfInfo(doc: jsPDF, project: Pick<Project, "name" | "competition">, author?: string): void {
|
||||
doc.setProperties(pdfInfoFields(project, author));
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// (`areaReport.ts`), damit CSV, SVG und PDF dieselbe Quelle und denselben Seitenaufbau haben.
|
||||
// Die Zahlen rechnet der Kern (`analysis/roomProgram.ts`); hier nur die Beschriftung mit `t()`.
|
||||
|
||||
import { reportHead } from "./competitionIdentity";
|
||||
import type { Project } from "../model/types";
|
||||
import { t } from "../i18n/translate";
|
||||
import { compareRoomProgram } from "../analysis/roomProgram";
|
||||
@@ -75,5 +76,5 @@ export function buildProgramReport(project: Project): AreaReport {
|
||||
const notes = [t("program.report.note.tolerance", { pct: (c.tolerance * 100).toFixed(0), pct2: (c.tolerance * 200).toFixed(0) })];
|
||||
if (c.kinds.some((k) => k.key !== "")) notes.push(t("program.report.note.sia"));
|
||||
if (c.extra.length > 0) notes.push(t("program.compare.extra", { n: c.extra.length, area: c.extraArea.toFixed(1) }));
|
||||
return { title: t("program.report.title"), projectName: project.name ?? "", sections, notes };
|
||||
return { title: t("program.report.title"), ...reportHead(project), sections, notes };
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
// Beschriftung mit `t()` und der Berichtsaufbau, damit CSV, SVG und PDF dieselbe Quelle haben wie die
|
||||
// Fenster-/Türliste (`openingSchedule.ts`). Die Blatt-Tabelle (Quelle `roomBook`) rechnet der Kern selbst.
|
||||
|
||||
import { reportHead } from "./competitionIdentity";
|
||||
import type { Project, RoomUsage } from "../model/types";
|
||||
import { t } from "../i18n/translate";
|
||||
import type { TranslationKey } from "../i18n/translate";
|
||||
@@ -131,5 +132,5 @@ export function buildRoomBookReport(project: Project): AreaReport {
|
||||
const sections: ReportSection[] = [];
|
||||
if (b.rows.length) sections.push(roomSection(b.rows));
|
||||
if (b.quantities.length) sections.push(quantitySection(b.quantities));
|
||||
return { title: t("roomBook.title"), projectName: project.name ?? "", sections, notes: [t("roomBook.foot")] };
|
||||
return { title: t("roomBook.title"), ...reportHead(project), sections, notes: [t("roomBook.foot")] };
|
||||
}
|
||||
Reference in new issue
Block a user