now extends XmlComponent

This commit is contained in:
Dolan Miu
2016-04-09 20:16:35 +01:00
parent 84610bd72f
commit f68a2aff56
33 changed files with 180 additions and 371 deletions

View File

@ -1,15 +1,10 @@
import {XmlComponent, Attributes} from "../../xml-components"; import {XmlComponent, Attributes} from "../../xml-components";
export class Columns implements XmlComponent { export class Columns extends XmlComponent {
private cols: Array<XmlComponent>;
xmlKeys = {
cols: 'w:cols'
}
constructor() { constructor() {
this.cols = new Array<XmlComponent>(); super("w:cols");
this.cols.push(new Attributes({ this.root.push(new Attributes({
space: "708" space: "708"
})); }));
} }

View File

@ -1,15 +1,10 @@
import {XmlComponent, Attributes} from "../../xml-components"; import {XmlComponent, Attributes} from "../../xml-components";
export class DocumentGrid implements XmlComponent { export class DocumentGrid extends XmlComponent {
private docGrid: Array<XmlComponent>;
xmlKeys = {
docGrid: 'w:docGrid'
}
constructor() { constructor() {
this.docGrid = new Array<XmlComponent>(); super("w:docGrid");
this.docGrid.push(new Attributes({ this.root.push(new Attributes({
linePitch: "360" linePitch: "360"
})); }));
} }

View File

@ -1,20 +1,15 @@
import {XmlComponent, Attributes} from "../../xml-components"; import {XmlComponent, Attributes} from "../../xml-components";
import {SectionProperties} from "./section-properties"; import {SectionProperties} from "./section-properties";
export class Body implements XmlComponent { export class Body extends XmlComponent {
private body: Array<XmlComponent>;
xmlKeys = {
body: 'w:body'
}
constructor() { constructor() {
this.body = new Array<XmlComponent>(); super("w:body");
//this.body.push(new SectionProperties()); not actually needed //this.root.push(new SectionProperties()); not actually needed
} }
push(component: XmlComponent) { push(component: XmlComponent) {
//this.body.splice(this.body.length - 1, 0, component); //this.root.splice(this.body.length - 1, 0, component);
this.body.push(component); this.root.push(component);
} }
} }

View File

@ -1,15 +1,10 @@
import {XmlComponent, Attributes} from "../../xml-components"; import {XmlComponent, Attributes} from "../../xml-components";
export class PageMargin implements XmlComponent { export class PageMargin extends XmlComponent {
private pgMar: Array<XmlComponent>;
xmlKeys = {
pgMar: 'w:pgMar'
}
constructor() { constructor() {
this.pgMar = new Array<XmlComponent>(); super("w:pgMar");
this.pgMar.push(new Attributes({ this.root.push(new Attributes({
top: "1440", top: "1440",
right: "1440", right: "1440",
bottom: "1440", bottom: "1440",

View File

@ -1,15 +1,10 @@
import {XmlComponent, Attributes} from "../../xml-components"; import {XmlComponent, Attributes} from "../../xml-components";
export class PageSize implements XmlComponent { export class PageSize extends XmlComponent {
private pgSz: Array<XmlComponent>;
xmlKeys = {
pgSz: 'w:pgSz'
}
constructor() { constructor() {
this.pgSz = new Array<XmlComponent>(); super("w:pgSz");
this.pgSz.push(new Attributes({ this.root.push(new Attributes({
w: "11906", w: "11906",
h: "16838" h: "16838"
})); }));

View File

@ -4,23 +4,18 @@ import {PageMargin} from "./page-margin";
import {Columns} from "./columns"; import {Columns} from "./columns";
import {DocumentGrid} from "./doc-grid"; import {DocumentGrid} from "./doc-grid";
export class SectionProperties implements XmlComponent { export class SectionProperties extends XmlComponent {
private sectPr: Array<XmlComponent>;
xmlKeys = {
sectPr: 'w:sectPr'
}
constructor() { constructor() {
this.sectPr = new Array<XmlComponent>(); super("w:sectPr");
this.sectPr.push(new Attributes({ this.root.push(new Attributes({
rsidR: "00B64E8F", rsidR: "00B64E8F",
rsidRPr: "00D842E4", rsidRPr: "00D842E4",
rsidSect: "000A6AD0" rsidSect: "000A6AD0"
})); }));
this.sectPr.push(new PageSize()); this.root.push(new PageSize());
this.sectPr.push(new PageMargin()); this.root.push(new PageMargin());
this.sectPr.push(new Columns()); this.root.push(new Columns());
this.sectPr.push(new DocumentGrid()); this.root.push(new DocumentGrid());
} }
} }

View File

@ -3,8 +3,7 @@ import {DocumentAttributes} from "../xml-components/document-attributes"
import {Body} from "./body"; import {Body} from "./body";
import {Paragraph} from "../paragraph"; import {Paragraph} from "../paragraph";
export class Document implements XmlComponent { export class Document extends XmlComponent {
private document: Array<XmlComponent>;
private body: Body; private body: Body;
xmlKeys = { xmlKeys = {
@ -13,8 +12,8 @@ export class Document implements XmlComponent {
}; };
constructor() { constructor() {
this.document = new Array<XmlComponent>(); super("w:document");
this.document.push(new DocumentAttributes({ this.root.push(new DocumentAttributes({
wpc: 'http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas', wpc: 'http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas',
mc: 'http://schemas.openxmlformats.org/markup-compatibility/2006', mc: 'http://schemas.openxmlformats.org/markup-compatibility/2006',
o: 'urn:schemas-microsoft-com:office:office', o: 'urn:schemas-microsoft-com:office:office',
@ -34,7 +33,7 @@ export class Document implements XmlComponent {
Ignorable: 'w14 w15 wp14' Ignorable: 'w14 w15 wp14'
})); }));
this.body = new Body(); this.body = new Body();
this.document.push(this.body); this.root.push(this.body);
} }
addParagraph(paragraph: Paragraph) { addParagraph(paragraph: Paragraph) {

View File

@ -1,15 +1,10 @@
import {XmlComponent, Attributes} from "../xml-components"; import {XmlComponent, Attributes} from "../xml-components";
class Border implements XmlComponent { class Border extends XmlComponent {
private bottom: Array<XmlComponent>;
xmlKeys = {
bottom: 'w:bottom'
}
constructor() { constructor() {
this.bottom = new Array<XmlComponent>(); super("w:bottom");
this.bottom.push(new Attributes({ this.root.push(new Attributes({
color: "auto", color: "auto",
space: "1", space: "1",
val: "single", val: "single",
@ -18,15 +13,10 @@ class Border implements XmlComponent {
} }
} }
export class ThematicBreak implements XmlComponent { export class ThematicBreak extends XmlComponent {
private pBdr: Array<XmlComponent>;
xmlKeys = {
pBdr: 'w:pBdr'
}
constructor() { constructor() {
this.pBdr = new Array<XmlComponent>(); super("w:pBdr");
this.pBdr.push(new Border()); this.root.push(new Border());
} }
} }

View File

@ -7,39 +7,29 @@ import {TabStop} from "../tab-stop";
import {Style} from "./style"; import {Style} from "./style";
import {NumberProperties} from "./unordered-list"; import {NumberProperties} from "./unordered-list";
class Alignment implements XmlComponent { class Alignment extends XmlComponent {
private jc: Array<XmlComponent>;
xmlKeys = {
jc: 'w:jc'
}
constructor(type: string) { constructor(type: string) {
this.jc = new Array<XmlComponent>(); super("w:jc");
this.jc.push(new Attributes({ this.root.push(new Attributes({
val: type val: type
})); }));
} }
} }
export class Paragraph implements XmlComponent { export class Paragraph extends XmlComponent {
private p: Array<XmlComponent>;
private properties: ParagraphProperties; private properties: ParagraphProperties;
xmlKeys = {
p: 'w:p'
}
constructor(text?: string) { constructor(text?: string) {
this.p = new Array<XmlComponent>(); super("w:p");
this.p.push(new Attributes()); this.root.push(new Attributes());
this.properties = new ParagraphProperties(); this.properties = new ParagraphProperties();
this.p.push(this.properties); this.root.push(this.properties);
this.p.push(new TextRun(text)); this.root.push(new TextRun(text));
} }
addText(run: TextRun): Paragraph { addText(run: TextRun): Paragraph {
this.p.push(run); this.root.push(run);
return this; return this;
} }

View File

@ -1,18 +1,13 @@
import {XmlComponent, Attributes} from "../xml-components"; import {XmlComponent, Attributes} from "../xml-components";
import {Run} from "../run"; import {Run} from "../run";
class Break implements XmlComponent { class Break extends XmlComponent {
private br: Array<XmlComponent>;
xmlKeys = {
br: 'w:br'
}
constructor() { constructor() {
this.br = new Array<XmlComponent>(); super("w:br");
this.br.push(new Attributes({ this.root.push(new Attributes({
type: "page" type: "page"
})) }));
} }
} }
@ -20,6 +15,6 @@ export class PageBreak extends Run {
constructor() { constructor() {
super(); super();
this.r.push(new Break()); this.root.push(new Break());
} }
} }

View File

@ -1,18 +1,13 @@
import {XmlComponent, Attributes} from "../xml-components"; import {XmlComponent, Attributes} from "../xml-components";
export class ParagraphProperties implements XmlComponent { export class ParagraphProperties extends XmlComponent {
private pPr: Array<XmlComponent>;
xmlKeys = {
pPr: 'w:rPr'
}
constructor() { constructor() {
this.pPr = new Array<XmlComponent>(); super("w:rPr");
this.pPr.push(new Attributes()); this.root.push(new Attributes());
} }
push(item: XmlComponent): void { push(item: XmlComponent): void {
this.pPr.push(item); this.root.push(item);
} }
} }

View File

@ -1,15 +1,10 @@
import {XmlComponent, Attributes} from "../xml-components"; import {XmlComponent, Attributes} from "../xml-components";
export class Style implements XmlComponent { export class Style extends XmlComponent {
private pStyle: Array<XmlComponent>;
xmlKeys = {
pStyle: 'w:pStyle'
}
constructor(type: string) { constructor(type: string) {
this.pStyle = new Array<XmlComponent>(); super("w:pStyle");
this.pStyle.push(new Attributes({ this.root.push(new Attributes({
val: type val: type
})); }));
} }

View File

@ -1,45 +1,29 @@
import {XmlComponent, Attributes} from "../xml-components"; import {XmlComponent, Attributes} from "../xml-components";
import {Style} from "./style"; import {Style} from "./style";
export class NumberProperties implements XmlComponent { export class NumberProperties extends XmlComponent {
private numPr: Array<XmlComponent>;
xmlKeys = {
numPr: 'w:numPr'
}
constructor() { constructor() {
this.numPr = new Array<XmlComponent>(); super("w:numPr");
this.numPr.push(new IndentLevel(0)); this.root.push(new IndentLevel(0));
this.numPr.push(new NumberId(1)); this.root.push(new NumberId(1));
} }
} }
export class IndentLevel implements XmlComponent { export class IndentLevel extends XmlComponent {
private ilvl: Array<XmlComponent>;
xmlKeys = {
ilvl: 'w:ilvl'
}
constructor(level: number) { constructor(level: number) {
this.ilvl = new Array<XmlComponent>(); super("w:ilvl");
this.ilvl.push(new Attributes({ this.root.push(new Attributes({
val: level val: level
})); }));
} }
} }
export class NumberId implements XmlComponent { export class NumberId extends XmlComponent {
private ilvl: Array<XmlComponent>;
xmlKeys = {
ilvl: 'w:ilvl'
}
constructor(id: number) { constructor(id: number) {
this.ilvl = new Array<XmlComponent>(); super("w:numId");
this.ilvl.push(new Attributes({ this.root.push(new Attributes({
val: id val: id
})); }));
} }

View File

@ -1,45 +1,30 @@
import {XmlComponent, Attributes} from "../xml-components"; import {XmlComponent, Attributes} from "../xml-components";
export class Bold implements XmlComponent { export class Bold extends XmlComponent {
private b: Array<XmlComponent>;
xmlKeys = {
b: 'w:b'
}
constructor() { constructor() {
this.b = new Array<XmlComponent>(); super("w:b");
this.b.push(new Attributes({ this.root.push(new Attributes({
val: true val: true
})); }));
} }
} }
export class Italics { export class Italics extends XmlComponent {
private i: Array<XmlComponent>;
xmlKeys = {
i: 'w:i'
}
constructor() { constructor() {
this.i = new Array<XmlComponent>(); super("w:i");
this.i.push(new Attributes({ this.root.push(new Attributes({
val: true val: true
})); }));
} }
} }
export class Underline { export class Underline extends XmlComponent {
private u: Array<XmlComponent>;
xmlKeys = {
u: 'w:u'
}
constructor() { constructor() {
this.u = new Array<XmlComponent>(); super("w:u");
this.u.push(new Attributes({ this.root.push(new Attributes({
val: true val: true
})); }));
} }

View File

@ -2,18 +2,14 @@ import {XmlComponent, Attributes} from "../xml-components";
import {RunProperties} from "./properties"; import {RunProperties} from "./properties";
import {Bold, Italics, Underline} from "./emphasis"; import {Bold, Italics, Underline} from "./emphasis";
export class Run implements XmlComponent { export class Run extends XmlComponent {
protected r: Array<XmlComponent>;
private properties: RunProperties; private properties: RunProperties;
xmlKeys = {
r: 'w:r'
}
constructor() { constructor() {
this.r = new Array<XmlComponent>(); super("w:r");
this.properties = new RunProperties(); this.properties = new RunProperties();
this.r.push(this.properties); this.root.push(this.properties);
} }
bold(): Run { bold(): Run {

View File

@ -1,17 +1,12 @@
import {XmlComponent, Attributes} from "../xml-components"; import {XmlComponent, Attributes} from "../xml-components";
export class RunProperties implements XmlComponent { export class RunProperties extends XmlComponent {
private rPr: Array<XmlComponent>;
xmlKeys = {
rPr: 'w:rPr'
}
constructor() { constructor() {
this.rPr = new Array<XmlComponent>(); super("w:rPr");
} }
push(item: XmlComponent): void { push(item: XmlComponent): void {
this.rPr.push(item); this.root.push(item);
} }
} }

View File

@ -5,6 +5,6 @@ export class TextRun extends Run {
constructor(text: string) { constructor(text: string) {
super(); super();
this.r.push(new Text(text)); this.root.push(new Text(text));
} }
} }

View File

@ -1,5 +1,5 @@
import {XmlComponent, Attributes} from "./xml-components"; import {XmlComponent, Attributes} from "./xml-components";
export class TabStop implements XmlComponent{ export class TabStop extends XmlComponent{
xmlKeys = {} xmlKeys = {}
} }

View File

@ -1,11 +1,12 @@
import {XmlComponent} from "./"; import {XmlComponent} from "./";
export abstract class BaseAttributes implements XmlComponent { export abstract class BaseAttributes extends XmlComponent {
private _attr: Object; private _attr: Object;
xmlKeys = {}; xmlKeys = {};
constructor(xmlKeys: Object, properties?: any) { constructor(xmlKeys: Object, properties?: any) {
super("_attr");
this._attr = properties this._attr = properties
if (!properties) { if (!properties) {

View File

@ -26,7 +26,7 @@ interface DocumentAttributesProperties {
type?: string; type?: string;
} }
export class DocumentAttributes implements XmlComponent { export class DocumentAttributes extends XmlComponent {
private _attr: Object; private _attr: Object;
xmlKeys = { xmlKeys = {
@ -56,6 +56,7 @@ export class DocumentAttributes implements XmlComponent {
}; };
constructor(properties?: DocumentAttributesProperties) { constructor(properties?: DocumentAttributesProperties) {
super("_attr");
this._attr = properties this._attr = properties
if (!properties) { if (!properties) {

View File

@ -1,5 +1,11 @@
export interface XmlComponent { export abstract class XmlComponent {
xmlKeys: Object; protected root: Array<XmlComponent>;
protected rootKey: string;
constructor(rootKey: string) {
this.root = new Array<XmlComponent>();
this.rootKey = rootKey;
}
} }
interface AttributesProperties { interface AttributesProperties {
@ -23,7 +29,7 @@ interface AttributesProperties {
linePitch?: string; linePitch?: string;
} }
export class Attributes implements XmlComponent { export class Attributes extends XmlComponent {
private _attr: Object; private _attr: Object;
xmlKeys = { xmlKeys = {
@ -48,6 +54,7 @@ export class Attributes implements XmlComponent {
}; };
constructor(properties?: AttributesProperties) { constructor(properties?: AttributesProperties) {
super("_attr");
this._attr = properties this._attr = properties
if (!properties) { if (!properties) {
@ -58,7 +65,7 @@ export class Attributes implements XmlComponent {
} }
} }
export class Text implements XmlComponent { export class Text extends XmlComponent {
private t: string; private t: string;
xmlKeys = { xmlKeys = {
@ -66,6 +73,7 @@ export class Text implements XmlComponent {
} }
constructor(text: string) { constructor(text: string) {
super("w:t");
this.t = text; this.t = text;
} }
} }

View File

@ -1,114 +1,74 @@
import {XmlComponent} from "../docx/xml-components"; import {XmlComponent} from "../docx/xml-components";
import {DocumentAttributes} from "../docx/xml-components/document-attributes"; import {DocumentAttributes} from "../docx/xml-components/document-attributes";
abstract class Component { abstract class Component extends XmlComponent {
protected createNullBlockOrValue(value: string): Object { protected createNullBlockOrValue(value: string): XmlComponent {
if (value === undefined) { /*if (value === undefined) {
return [{}]; return [{}];
} else { } else {
return value; return value;
}*/
return null;
} }
} }
} export class Title extends Component {
export class Title extends Component implements XmlComponent {
private title: Object;
xmlKeys = {
title: "dc:title"
}
constructor(value: string) { constructor(value: string) {
super(); super("dc:title");
var title = this.createNullBlockOrValue(value); this.root.push(this.createNullBlockOrValue(value));
this.title = title;
} }
} }
export class Subject extends Component implements XmlComponent { export class Subject extends Component {
private subject: Object;
xmlKeys = {
subject: "dc:subject"
}
constructor(value: string) { constructor(value: string) {
super(); super("dc:subject");
var subject = this.createNullBlockOrValue(value); this.root.push(this.createNullBlockOrValue(value));
this.subject = subject;
} }
} }
export class Creator extends Component implements XmlComponent { export class Creator extends Component {
private creator: Object;
xmlKeys = {
creator: "dc:creator"
}
constructor(value: string) { constructor(value: string) {
super(); super("dc:creator");
var creator = this.createNullBlockOrValue(value); this.root.push(this.createNullBlockOrValue(value));
this.creator = creator;
} }
} }
export class Keywords extends Component implements XmlComponent { export class Keywords extends Component {
private keywords: Object;
xmlKeys = {
keywords: "cp:keywords"
}
constructor(value: string) { constructor(value: string) {
super(); super("cp:keywords");
var keywords = this.createNullBlockOrValue(value); this.root.push(this.createNullBlockOrValue(value));
this.keywords = keywords;
} }
} }
export class Description extends Component implements XmlComponent { export class Description extends Component {
private description: Object;
xmlKeys = {
description: "dc:description"
}
constructor(value: string) { constructor(value: string) {
super(); super("dc:description");
var description = this.createNullBlockOrValue(value); this.root.push(this.createNullBlockOrValue(value));
this.description = description;
} }
} }
export class LastModifiedBy extends Component implements XmlComponent { export class LastModifiedBy extends Component {
private lastModifiedBy: Object;
xmlKeys = {
lastModifiedBy: "cp:lastModifiedBy"
}
constructor(value: string) { constructor(value: string) {
super(); super("cp:lastModifiedBy");
var lastModifiedBy = this.createNullBlockOrValue(value); this.root.push(this.createNullBlockOrValue(value));
this.lastModifiedBy = lastModifiedBy;
} }
} }
export class Revision extends Component implements XmlComponent { export class Revision extends Component {
private revision: Object;
xmlKeys = {
revision: "cp:revision"
}
constructor(value: string) { constructor(value: string) {
super(); super("cp:revision");
var revision = this.createNullBlockOrValue(value); var revision = this.createNullBlockOrValue(value);
this.revision = revision; this.root.push(this.createNullBlockOrValue(value));
} }
} }
abstract class DateComponent { abstract class DateComponent extends XmlComponent {
protected getCurrentDate(): any { protected getCurrentDate(): any {
var date = new Date(), var date = new Date(),
year = date.getFullYear(), year = date.getFullYear(),
@ -122,36 +82,24 @@ abstract class DateComponent {
} }
} }
export class Created extends DateComponent implements XmlComponent { export class Created extends DateComponent {
private created: Array<XmlComponent>;
xmlKeys = {
created: "dcterms:created"
}
constructor() { constructor() {
super(); super("dcterms:created");
this.created = new Array<XmlComponent>(); this.root.push(new DocumentAttributes({
this.created.push(new DocumentAttributes({
type: "dcterms:W3CDTF" type: "dcterms:W3CDTF"
})); }));
this.created.push(this.getCurrentDate()); this.root.push(this.getCurrentDate());
} }
} }
export class Modified extends DateComponent implements XmlComponent { export class Modified extends DateComponent implements XmlComponent {
private modified: Array<XmlComponent>;
xmlKeys = {
modified: "dcterms:modified"
}
constructor() { constructor() {
super(); super("dcterms:modified");
this.modified = new Array<XmlComponent>(); this.root.push(new DocumentAttributes({
this.modified.push(new DocumentAttributes({
type: "dcterms:W3CDTF" type: "dcterms:W3CDTF"
})); }));
this.modified.push(this.getCurrentDate()); this.root.push(this.getCurrentDate());
} }
} }

View File

@ -12,30 +12,25 @@ interface PropertiesOptions {
revision?: string; revision?: string;
} }
export class Properties implements XmlComponent { export class Properties extends XmlComponent {
private coreProperties: Array<XmlComponent>;
xmlKeys = {
coreProperties: "cp:coreProperties"
}
constructor(options: PropertiesOptions) { constructor(options: PropertiesOptions) {
this.coreProperties = new Array<XmlComponent>(); super("cp:coreProperties");
this.coreProperties.push(new DocumentAttributes({ this.root.push(new DocumentAttributes({
cp: "http://schemas.openxmlformats.org/package/2006/metadata/core-properties", cp: "http://schemas.openxmlformats.org/package/2006/metadata/core-properties",
dc: "http://purl.org/dc/elements/1.1/", dc: "http://purl.org/dc/elements/1.1/",
dcterms: "http://purl.org/dc/terms/", dcterms: "http://purl.org/dc/terms/",
dcmitype: "http://purl.org/dc/dcmitype/", dcmitype: "http://purl.org/dc/dcmitype/",
xsi: "http://www.w3.org/2001/XMLSchema-instance" xsi: "http://www.w3.org/2001/XMLSchema-instance"
})); }));
this.coreProperties.push(new Title(options.title)); this.root.push(new Title(options.title));
this.coreProperties.push(new Subject(options.subject)); this.root.push(new Subject(options.subject));
this.coreProperties.push(new Creator(options.creator)); this.root.push(new Creator(options.creator));
this.coreProperties.push(new Keywords(options.keywords)); this.root.push(new Keywords(options.keywords));
this.coreProperties.push(new Description(options.description)); this.root.push(new Description(options.description));
this.coreProperties.push(new LastModifiedBy(options.lastModifiedBy)); this.root.push(new LastModifiedBy(options.lastModifiedBy));
this.coreProperties.push(new Revision(options.revision)); this.root.push(new Revision(options.revision));
this.coreProperties.push(new Created()); this.root.push(new Created());
this.coreProperties.push(new Modified()); this.root.push(new Modified());
} }
} }

View File

@ -2,16 +2,11 @@ import {XmlComponent} from "../../docx/xml-components";
import {ParagraphPropertiesDefaults} from "./paragraph-properties"; import {ParagraphPropertiesDefaults} from "./paragraph-properties";
import {RunPropertiesDefaults} from "./run-properties"; import {RunPropertiesDefaults} from "./run-properties";
export class DocumentDefaults implements XmlComponent { export class DocumentDefaults extends XmlComponent {
private docDefaults: Array<XmlComponent>;
xmlKeys = {
docDefaults: "w:docDefaults"
}
constructor() { constructor() {
this.docDefaults = new Array<XmlComponent>(); super("w:docDefaults");
this.docDefaults.push(new RunPropertiesDefaults()); this.root.push(new RunPropertiesDefaults());
this.docDefaults.push(new ParagraphPropertiesDefaults()); this.root.push(new ParagraphPropertiesDefaults());
} }
} }

View File

@ -1,15 +1,10 @@
import {XmlComponent} from "../../docx/xml-components"; import {XmlComponent} from "../../docx/xml-components";
import {ParagraphProperties} from "../../docx/paragraph/properties"; import {ParagraphProperties} from "../../docx/paragraph/properties";
export class ParagraphPropertiesDefaults implements XmlComponent { export class ParagraphPropertiesDefaults extends XmlComponent {
private pPrDefault: Array<XmlComponent>;
xmlKeys = {
pPrDefault: "w:pPrDefault"
}
constructor() { constructor() {
this.pPrDefault = new Array<XmlComponent>(); super("w:pPrDefault");
this.pPrDefault.push(new ParagraphProperties()); this.root.push(new ParagraphProperties());
} }
} }

View File

@ -1,15 +1,10 @@
import {XmlComponent} from "../../docx/xml-components"; import {XmlComponent} from "../../docx/xml-components";
import {RunProperties} from "../../docx/run/properties"; import {RunProperties} from "../../docx/run/properties";
export class RunPropertiesDefaults implements XmlComponent { export class RunPropertiesDefaults extends XmlComponent {
private rPrDefault: Array<XmlComponent>;
xmlKeys = {
rPrDefault: "w:rPrDefault"
}
constructor() { constructor() {
this.rPrDefault = new Array<XmlComponent>(); super("w:rPrDefault");
this.rPrDefault.push(new RunProperties()); this.root.push(new RunProperties());
} }
} }

View File

@ -5,16 +5,11 @@ import {LatentStyles} from "./latent-styles";
import {LatentStyleException} from "./latent-styles/exceptions"; import {LatentStyleException} from "./latent-styles/exceptions";
import {LatentStyleExceptionAttributes} from "./latent-styles/exceptions/attributes"; import {LatentStyleExceptionAttributes} from "./latent-styles/exceptions/attributes";
export class Styles implements XmlComponent { export class Styles extends XmlComponent {
private styles: Array<XmlComponent>;
xmlKeys = {
styles: 'w:styles'
}
constructor() { constructor() {
this.styles = new Array<XmlComponent>(); super("w:styles");
this.styles.push(new DocumentAttributes({ this.root.push(new DocumentAttributes({
mc: 'http://schemas.openxmlformats.org/markup-compatibility/2006', mc: 'http://schemas.openxmlformats.org/markup-compatibility/2006',
r: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships', r: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships',
w: 'http://schemas.openxmlformats.org/wordprocessingml/2006/main', w: 'http://schemas.openxmlformats.org/wordprocessingml/2006/main',
@ -22,15 +17,15 @@ export class Styles implements XmlComponent {
w15: 'http://schemas.microsoft.com/office/word/2012/wordml', w15: 'http://schemas.microsoft.com/office/word/2012/wordml',
Ignorable: 'w14 w15' Ignorable: 'w14 w15'
})) }))
this.styles.push(new DocumentDefaults()); this.root.push(new DocumentDefaults());
var latentStyles = new LatentStyles(); var latentStyles = new LatentStyles();
//latentStyles.push(new LatentStyleException(new LatentStyleExceptionAttributes({ //latentStyles.push(new LatentStyleException(new LatentStyleExceptionAttributes({
// name: "Normal" // name: "Normal"
//}))); //})));
this.styles.push(latentStyles); this.root.push(latentStyles);
} }
push(style: XmlComponent): void { push(style: XmlComponent): void {
this.styles.push(style); this.root.push(style);
} }
} }

View File

@ -8,7 +8,7 @@ interface LatentStyleExceptionAttributesProperties {
unhideWhenUsed?: string unhideWhenUsed?: string
} }
export class LatentStyleExceptionAttributes implements XmlComponent { export class LatentStyleExceptionAttributes extends XmlComponent {
private _attr: Object; private _attr: Object;
xmlKeys = { xmlKeys = {
@ -20,6 +20,7 @@ export class LatentStyleExceptionAttributes implements XmlComponent {
}; };
constructor(properties?: LatentStyleExceptionAttributesProperties) { constructor(properties?: LatentStyleExceptionAttributesProperties) {
super("_attr");
this._attr = properties this._attr = properties
if (!properties) { if (!properties) {

View File

@ -1,15 +1,10 @@
import {XmlComponent} from "../../../docx/xml-components"; import {XmlComponent} from "../../../docx/xml-components";
import {LatentStyleExceptionAttributes} from "./attributes"; import {LatentStyleExceptionAttributes} from "./attributes";
export class LatentStyleException implements XmlComponent { export class LatentStyleException extends XmlComponent {
private lsdException: Array<XmlComponent>;
xmlKeys = {
lsdException: "w:lsdException"
}
constructor(attributes: LatentStyleExceptionAttributes) { constructor(attributes: LatentStyleExceptionAttributes) {
this.lsdException = new Array<XmlComponent>(); super("w:lsdException");
this.lsdException.push(attributes); this.root.push(attributes);
} }
} }

View File

@ -1,18 +1,13 @@
import {XmlComponent} from "../../docx/xml-components"; import {XmlComponent} from "../../docx/xml-components";
import {LatentStyleException} from "./exceptions"; import {LatentStyleException} from "./exceptions";
export class LatentStyles implements XmlComponent { export class LatentStyles extends XmlComponent {
private latentStyles: Array<XmlComponent>;
xmlKeys = {
latentStyles: "w:latentStyles"
}
constructor() { constructor() {
this.latentStyles = new Array<XmlComponent>(); super("w:latentStyles");
} }
push(latentException: LatentStyleException): void { push(latentException: LatentStyleException): void {
this.latentStyles.push(latentException); this.root.push(latentException);
} }
} }

View File

@ -7,7 +7,7 @@ interface StyleAttributesProperties {
customStyle?: string; customStyle?: string;
} }
export class StyleAttributes implements XmlComponent { export class StyleAttributes extends XmlComponent {
private _attr: Object; private _attr: Object;
xmlKeys = { xmlKeys = {
@ -18,6 +18,7 @@ export class StyleAttributes implements XmlComponent {
}; };
constructor(properties?: StyleAttributesProperties) { constructor(properties?: StyleAttributesProperties) {
super("_attr");
this._attr = properties this._attr = properties
if (!properties) { if (!properties) {

View File

@ -1,14 +1,9 @@
import {XmlComponent} from "../../docx/xml-components"; import {XmlComponent} from "../../docx/xml-components";
export class Name implements XmlComponent { export class Name extends XmlComponent {
private name: Array<XmlComponent>;
xmlKeys = {
}
constructor() { constructor() {
this.name = new Array<XmlComponent>(); super("w:name");
} }
} }

View File

@ -1,19 +1,14 @@
import {XmlComponent} from "../../docx/xml-components"; import {XmlComponent} from "../../docx/xml-components";
import {StyleAttributes} from "./attributes"; import {StyleAttributes} from "./attributes";
export class Style implements XmlComponent { export class Style extends XmlComponent {
private style: Array<XmlComponent>;
xmlKeys = {
style: "w:style"
}
constructor(attributes: StyleAttributes) { constructor(attributes: StyleAttributes) {
this.style = new Array<XmlComponent>(); super("w:style");
this.style.push(attributes); this.root.push(attributes);
} }
push(styleSegment: XmlComponent): void { push(styleSegment: XmlComponent): void {
this.style.push(styleSegment); this.root.push(styleSegment);
} }
} }