Files
docx-js/ts/properties/components.ts

96 lines
2.3 KiB
TypeScript
Raw Normal View History

2016-05-01 23:48:45 +01:00
import {XmlUnitComponent} from "../docx/xml-components";
2016-04-03 20:00:30 +01:00
import {XmlComponent} from "../docx/xml-components";
2016-05-01 22:49:40 +01:00
import {DocumentAttributes} from "../docx/document/document-attributes";
2016-04-03 20:00:30 +01:00
2016-05-02 00:00:45 +01:00
export class Title extends XmlUnitComponent {
2016-04-03 20:00:30 +01:00
constructor(value: string) {
2016-04-09 20:16:35 +01:00
super("dc:title");
2016-05-02 00:00:45 +01:00
this.root = value;
2016-04-03 20:00:30 +01:00
}
}
2016-05-02 00:00:45 +01:00
export class Subject extends XmlUnitComponent {
2016-04-03 20:00:30 +01:00
constructor(value: string) {
2016-04-09 20:16:35 +01:00
super("dc:subject");
2016-05-02 00:00:45 +01:00
this.root = value;
2016-04-03 20:00:30 +01:00
}
}
2016-05-02 00:00:45 +01:00
export class Creator extends XmlUnitComponent {
2016-04-03 20:00:30 +01:00
constructor(value: string) {
2016-04-09 20:16:35 +01:00
super("dc:creator");
2016-05-02 00:00:45 +01:00
this.root = value;
2016-04-03 20:00:30 +01:00
}
}
2016-05-02 00:00:45 +01:00
export class Keywords extends XmlUnitComponent {
2016-04-03 20:00:30 +01:00
constructor(value: string) {
2016-04-09 20:16:35 +01:00
super("cp:keywords");
2016-05-02 00:00:45 +01:00
this.root = value;
2016-04-03 20:00:30 +01:00
}
}
2016-05-02 00:00:45 +01:00
export class Description extends XmlUnitComponent {
2016-04-03 20:00:30 +01:00
constructor(value: string) {
2016-04-09 20:16:35 +01:00
super("dc:description");
2016-05-02 00:00:45 +01:00
this.root = value;
2016-04-03 20:00:30 +01:00
}
}
2016-05-02 00:00:45 +01:00
export class LastModifiedBy extends XmlUnitComponent {
2016-04-09 20:16:35 +01:00
2016-04-03 20:00:30 +01:00
constructor(value: string) {
2016-04-09 20:16:35 +01:00
super("cp:lastModifiedBy");
2016-05-02 00:00:45 +01:00
this.root = value;
2016-04-03 20:00:30 +01:00
}
}
2016-05-02 00:00:45 +01:00
export class Revision extends XmlUnitComponent {
2016-04-03 20:00:30 +01:00
constructor(value: string) {
2016-04-09 20:16:35 +01:00
super("cp:revision");
2016-05-02 00:00:45 +01:00
var revision = value;
this.root = value;
2016-04-03 20:00:30 +01:00
}
}
2016-04-09 20:16:35 +01:00
abstract class DateComponent extends XmlComponent {
2016-04-03 20:00:30 +01:00
protected getCurrentDate(): any {
var date = new Date(),
year = date.getFullYear(),
month = ('0' + (date.getMonth() + 1)).slice(-2),
day = ('0' + date.getDate()).slice(-2),
hours = ('0' + date.getHours()).slice(-2),
minutes = ('0' + date.getMinutes()).slice(-2),
seconds = ('0' + date.getSeconds()).slice(-2);
return year + '-' + month + '-' + day + 'T' + hours + ':' + minutes + ':' + seconds + 'Z';
}
}
2016-04-09 20:16:35 +01:00
export class Created extends DateComponent {
2016-04-03 20:00:30 +01:00
constructor() {
2016-04-09 20:16:35 +01:00
super("dcterms:created");
this.root.push(new DocumentAttributes({
2016-04-03 20:00:30 +01:00
type: "dcterms:W3CDTF"
}));
2016-04-09 20:16:35 +01:00
this.root.push(this.getCurrentDate());
2016-04-03 20:00:30 +01:00
}
}
2016-05-02 00:00:45 +01:00
export class Modified extends DateComponent {
2016-04-03 20:00:30 +01:00
constructor() {
2016-04-09 20:16:35 +01:00
super("dcterms:modified");
this.root.push(new DocumentAttributes({
2016-04-03 20:00:30 +01:00
type: "dcterms:W3CDTF"
}));
2016-04-09 20:16:35 +01:00
this.root.push(this.getCurrentDate());
2016-04-03 20:00:30 +01:00
}
}