2021-05-26 09:27:05 +03:00
|
|
|
import { StringContainer, XmlComponent } from "file/xml-components";
|
2021-03-07 21:27:38 +00:00
|
|
|
import { ICustomPropertyOptions } from "../custom-properties";
|
2020-10-27 01:54:40 +00:00
|
|
|
import { IDocumentBackgroundOptions } from "../document";
|
2019-10-04 02:37:22 +01:00
|
|
|
|
2017-12-20 00:58:24 +00:00
|
|
|
import { DocumentAttributes } from "../document/document-attributes";
|
2021-03-19 20:53:56 +00:00
|
|
|
import { ISectionOptions } from "../file";
|
2019-11-08 03:11:19 +00:00
|
|
|
import { INumberingOptions } from "../numbering";
|
2021-02-27 19:23:29 +00:00
|
|
|
import { Paragraph } from "../paragraph";
|
2019-10-04 02:37:22 +01:00
|
|
|
import { IStylesOptions } from "../styles";
|
2021-05-26 10:14:19 +03:00
|
|
|
import { dateTimeValue } from "../values";
|
2016-04-03 20:00:30 +01:00
|
|
|
|
2017-07-07 14:31:08 +01:00
|
|
|
export interface IPropertiesOptions {
|
2021-03-19 20:53:56 +00:00
|
|
|
readonly sections: ISectionOptions[];
|
2018-11-02 02:51:57 +00:00
|
|
|
readonly title?: string;
|
|
|
|
readonly subject?: string;
|
|
|
|
readonly creator?: string;
|
|
|
|
readonly keywords?: string;
|
|
|
|
readonly description?: string;
|
|
|
|
readonly lastModifiedBy?: string;
|
|
|
|
readonly revision?: string;
|
|
|
|
readonly externalStyles?: string;
|
2019-10-04 02:37:22 +01:00
|
|
|
readonly styles?: IStylesOptions;
|
2019-11-08 03:11:19 +00:00
|
|
|
readonly numbering?: INumberingOptions;
|
2020-01-01 20:22:42 +00:00
|
|
|
readonly footnotes?: {
|
|
|
|
readonly [key: string]: {
|
|
|
|
readonly children: Paragraph[];
|
|
|
|
};
|
|
|
|
};
|
2020-10-27 01:54:40 +00:00
|
|
|
readonly background?: IDocumentBackgroundOptions;
|
2020-11-04 00:00:16 +00:00
|
|
|
readonly features?: {
|
|
|
|
readonly trackRevisions?: boolean;
|
2021-05-26 08:36:05 +03:00
|
|
|
readonly updateFields?: boolean;
|
2019-12-18 21:11:15 +00:00
|
|
|
};
|
2021-02-27 01:40:55 +00:00
|
|
|
readonly compatabilityModeVersion?: number;
|
2021-03-07 21:27:38 +00:00
|
|
|
readonly customProperties?: ICustomPropertyOptions[];
|
2021-03-16 00:57:27 +00:00
|
|
|
readonly evenAndOddHeaderAndFooters?: boolean;
|
2016-04-03 20:00:30 +01:00
|
|
|
}
|
|
|
|
|
2021-05-26 09:27:05 +03:00
|
|
|
// <xs:element name="coreProperties" type="CT_CoreProperties"/>
|
|
|
|
|
|
|
|
// <xs:complexType name="CT_CoreProperties">
|
|
|
|
// <xs:all>
|
|
|
|
// <xs:element name="category" minOccurs="0" maxOccurs="1" type="xs:string"/>
|
|
|
|
// <xs:element name="contentStatus" minOccurs="0" maxOccurs="1" type="xs:string"/>
|
|
|
|
// <xs:element ref="dcterms:created" minOccurs="0" maxOccurs="1"/>
|
|
|
|
// <xs:element ref="dc:creator" minOccurs="0" maxOccurs="1"/>
|
|
|
|
// <xs:element ref="dc:description" minOccurs="0" maxOccurs="1"/>
|
|
|
|
// <xs:element ref="dc:identifier" minOccurs="0" maxOccurs="1"/>
|
|
|
|
// <xs:element name="keywords" minOccurs="0" maxOccurs="1" type="CT_Keywords"/>
|
|
|
|
// <xs:element ref="dc:language" minOccurs="0" maxOccurs="1"/>
|
|
|
|
// <xs:element name="lastModifiedBy" minOccurs="0" maxOccurs="1" type="xs:string"/>
|
|
|
|
// <xs:element name="lastPrinted" minOccurs="0" maxOccurs="1" type="xs:dateTime"/>
|
|
|
|
// <xs:element ref="dcterms:modified" minOccurs="0" maxOccurs="1"/>
|
|
|
|
// <xs:element name="revision" minOccurs="0" maxOccurs="1" type="xs:string"/>
|
|
|
|
// <xs:element ref="dc:subject" minOccurs="0" maxOccurs="1"/>
|
|
|
|
// <xs:element ref="dc:title" minOccurs="0" maxOccurs="1"/>
|
|
|
|
// <xs:element name="version" minOccurs="0" maxOccurs="1" type="xs:string"/>
|
|
|
|
// </xs:all>
|
|
|
|
// </xs:complexType>
|
|
|
|
|
2018-02-04 01:43:03 +00:00
|
|
|
export class CoreProperties extends XmlComponent {
|
2021-03-19 20:53:56 +00:00
|
|
|
constructor(options: Omit<IPropertiesOptions, "sections">) {
|
2016-04-09 20:16:35 +01:00
|
|
|
super("cp:coreProperties");
|
2018-01-23 01:33:12 +00:00
|
|
|
this.root.push(
|
|
|
|
new DocumentAttributes({
|
|
|
|
cp: "http://schemas.openxmlformats.org/package/2006/metadata/core-properties",
|
|
|
|
dc: "http://purl.org/dc/elements/1.1/",
|
|
|
|
dcterms: "http://purl.org/dc/terms/",
|
|
|
|
dcmitype: "http://purl.org/dc/dcmitype/",
|
|
|
|
xsi: "http://www.w3.org/2001/XMLSchema-instance",
|
|
|
|
}),
|
|
|
|
);
|
2017-03-09 19:50:33 +01:00
|
|
|
if (options.title) {
|
2021-05-26 09:27:05 +03:00
|
|
|
this.root.push(new StringContainer("dc:title", options.title));
|
2017-03-09 19:50:33 +01:00
|
|
|
}
|
|
|
|
if (options.subject) {
|
2021-05-26 09:27:05 +03:00
|
|
|
this.root.push(new StringContainer("dc:subject", options.subject));
|
2017-03-09 19:50:33 +01:00
|
|
|
}
|
|
|
|
if (options.creator) {
|
2021-05-26 09:27:05 +03:00
|
|
|
this.root.push(new StringContainer("dc:creator", options.creator));
|
2017-03-09 19:50:33 +01:00
|
|
|
}
|
|
|
|
if (options.keywords) {
|
2021-05-26 09:27:05 +03:00
|
|
|
this.root.push(new StringContainer("cp:keywords", options.keywords));
|
2017-03-09 19:50:33 +01:00
|
|
|
}
|
|
|
|
if (options.description) {
|
2021-05-26 09:27:05 +03:00
|
|
|
this.root.push(new StringContainer("dc:description", options.description));
|
2017-03-09 19:50:33 +01:00
|
|
|
}
|
|
|
|
if (options.lastModifiedBy) {
|
2021-05-26 09:27:05 +03:00
|
|
|
this.root.push(new StringContainer("cp:lastModifiedBy", options.lastModifiedBy));
|
2017-03-09 19:50:33 +01:00
|
|
|
}
|
|
|
|
if (options.revision) {
|
2021-05-26 09:27:05 +03:00
|
|
|
this.root.push(new StringContainer("cp:revision", options.revision));
|
2017-03-09 19:50:33 +01:00
|
|
|
}
|
2021-05-26 09:27:05 +03:00
|
|
|
this.root.push(new TimestampElement("dcterms:created"));
|
|
|
|
this.root.push(new TimestampElement("dcterms:modified"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class TimestampElement extends XmlComponent {
|
|
|
|
constructor(name: string) {
|
|
|
|
super(name);
|
|
|
|
this.root.push(
|
|
|
|
new DocumentAttributes({
|
|
|
|
type: "dcterms:W3CDTF",
|
|
|
|
}),
|
|
|
|
);
|
2021-05-26 10:14:19 +03:00
|
|
|
this.root.push(dateTimeValue(new Date()));
|
2016-04-03 20:00:30 +01:00
|
|
|
}
|
2017-03-08 21:49:41 +00:00
|
|
|
}
|