Preserve QPowerPoint hidden slides in PPTX
This commit is contained in:
@@ -307,6 +307,47 @@ describe("powerPointOffice helpers", () => {
|
||||
expect(exportedSlideXml).toContain("FCE4D6");
|
||||
});
|
||||
|
||||
it("импортирует и экспортирует скрытые слайды PPTX через атрибут show", async () => {
|
||||
const zip = new JSZip();
|
||||
zip.file(
|
||||
"ppt/presentation.xml",
|
||||
`<p:presentation xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><p:sldIdLst><p:sldId id="256" r:id="rId1"/></p:sldIdLst></p:presentation>`
|
||||
);
|
||||
zip.file(
|
||||
"ppt/_rels/presentation.xml.rels",
|
||||
`<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide" Target="slides/slide1.xml"/></Relationships>`
|
||||
);
|
||||
zip.file("ppt/slides/slide1.xml", slideXmlWithShow("Скрытый слайд", "0"));
|
||||
|
||||
const importedBlob = await zip.generateAsync({
|
||||
type: "blob",
|
||||
mimeType: "application/vnd.openxmlformats-officedocument.presentationml.presentation"
|
||||
});
|
||||
const imported = await importPptxFile(new File([importedBlob], "Скрытый.pptx", { type: importedBlob.type }));
|
||||
|
||||
expect(imported.slides[0]).toMatchObject({ title: "Скрытый слайд", hidden: true });
|
||||
|
||||
const exportedBlob = await exportPptxBlob({
|
||||
title: "Скрытый.pptx",
|
||||
slides: [
|
||||
{
|
||||
id: "slide-1",
|
||||
title: "Скрытый слайд",
|
||||
subtitle: "",
|
||||
notes: "",
|
||||
theme: "classic",
|
||||
hidden: true
|
||||
}
|
||||
]
|
||||
});
|
||||
const exportedZip = await JSZip.loadAsync(await exportedBlob.arrayBuffer());
|
||||
const exportedSlideXml = (await exportedZip.file("ppt/slides/slide1.xml")?.async("string")) ?? "";
|
||||
const reimported = await importPptxFile(new File([exportedBlob], "Скрытый.pptx", { type: exportedBlob.type }));
|
||||
|
||||
expect(exportedSlideXml).toContain('show="0"');
|
||||
expect(reimported.slides[0].hidden).toBe(true);
|
||||
});
|
||||
|
||||
it("импортирует и экспортирует цвет и размер текста слайда", async () => {
|
||||
const zip = new JSZip();
|
||||
zip.file(
|
||||
@@ -380,6 +421,10 @@ function slideXmlWithBackground(title: string, color: string) {
|
||||
return `<p:sld xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"><p:cSld><p:bg><p:bgPr><a:solidFill><a:srgbClr val="${color}"/></a:solidFill></p:bgPr></p:bg><p:spTree><p:sp><p:txBody><a:p><a:r><a:t>${title}</a:t></a:r></a:p></p:txBody></p:sp></p:spTree></p:cSld></p:sld>`;
|
||||
}
|
||||
|
||||
function slideXmlWithShow(title: string, show: string) {
|
||||
return `<p:sld show="${show}" xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"><p:cSld><p:spTree><p:sp><p:txBody><a:p><a:r><a:t>${title}</a:t></a:r></a:p></p:txBody></p:sp></p:spTree></p:cSld></p:sld>`;
|
||||
}
|
||||
|
||||
function slideXmlWithTextStyles(title: string, subtitle: string) {
|
||||
return `<p:sld xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"><p:cSld><p:spTree><p:sp><p:txBody><a:p><a:r><a:rPr sz="3400"><a:solidFill><a:srgbClr val="C2410C"/></a:solidFill><a:latin typeface="Courier New"/></a:rPr><a:t>${title}</a:t></a:r></a:p></p:txBody></p:sp><p:sp><p:txBody><a:p><a:r><a:rPr sz="2200"><a:solidFill><a:srgbClr val="0F766E"/></a:solidFill><a:latin typeface="Times New Roman"/></a:rPr><a:t>${subtitle}</a:t></a:r></a:p></p:txBody></p:sp></p:spTree></p:cSld></p:sld>`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user