2017-12-30 20:25:16 +00:00
|
|
|
import { XmlComponent } from "file/xml-components";
|
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";
|
2019-11-08 03:11:19 +00:00
|
|
|
import { INumberingOptions } from "../numbering";
|
2019-12-21 03:31:09 +00:00
|
|
|
import { HyperlinkType, Paragraph } from "../paragraph";
|
2019-10-04 02:37:22 +01:00
|
|
|
import { IStylesOptions } from "../styles";
|
2017-03-08 21:49:41 +00:00
|
|
|
import { Created, Creator, Description, Keywords, LastModifiedBy, Modified, Revision, Subject, Title } from "./components";
|
2016-04-03 20:00:30 +01:00
|
|
|
|
2019-12-21 03:31:09 +00:00
|
|
|
export interface IInternalHyperlinkDefinition {
|
|
|
|
readonly text: string;
|
|
|
|
readonly type: HyperlinkType.INTERNAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface IExternalHyperlinkDefinition {
|
|
|
|
readonly link: string;
|
|
|
|
readonly text: string;
|
|
|
|
readonly type: HyperlinkType.EXTERNAL;
|
|
|
|
}
|
|
|
|
|
2017-07-07 14:31:08 +01:00
|
|
|
export interface IPropertiesOptions {
|
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;
|
2019-12-03 23:04:48 +00:00
|
|
|
readonly footnotes?: Paragraph[];
|
2019-12-18 21:11:15 +00:00
|
|
|
readonly hyperlinks?: {
|
2019-12-21 03:31:09 +00:00
|
|
|
readonly [key: string]: IInternalHyperlinkDefinition | IExternalHyperlinkDefinition;
|
2019-12-18 21:11:15 +00:00
|
|
|
};
|
2020-10-27 01:54:40 +00:00
|
|
|
readonly background?: IDocumentBackgroundOptions;
|
2020-11-04 00:00:16 +00:00
|
|
|
readonly features?: {
|
|
|
|
readonly trackRevisions?: boolean;
|
|
|
|
};
|
2016-04-03 20:00:30 +01:00
|
|
|
}
|
|
|
|
|
2018-02-04 01:43:03 +00:00
|
|
|
export class CoreProperties extends XmlComponent {
|
2017-03-08 21:49:41 +00:00
|
|
|
constructor(options: IPropertiesOptions) {
|
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) {
|
|
|
|
this.root.push(new Title(options.title));
|
|
|
|
}
|
|
|
|
if (options.subject) {
|
|
|
|
this.root.push(new Subject(options.subject));
|
|
|
|
}
|
|
|
|
if (options.creator) {
|
|
|
|
this.root.push(new Creator(options.creator));
|
|
|
|
}
|
|
|
|
if (options.keywords) {
|
|
|
|
this.root.push(new Keywords(options.keywords));
|
|
|
|
}
|
|
|
|
if (options.description) {
|
|
|
|
this.root.push(new Description(options.description));
|
|
|
|
}
|
|
|
|
if (options.lastModifiedBy) {
|
|
|
|
this.root.push(new LastModifiedBy(options.lastModifiedBy));
|
|
|
|
}
|
|
|
|
if (options.revision) {
|
|
|
|
this.root.push(new Revision(options.revision));
|
|
|
|
}
|
2016-04-09 20:16:35 +01:00
|
|
|
this.root.push(new Created());
|
|
|
|
this.root.push(new Modified());
|
2016-04-03 20:00:30 +01:00
|
|
|
}
|
2017-03-08 21:49:41 +00:00
|
|
|
}
|