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";
export class Columns implements XmlComponent {
private cols: Array<XmlComponent>;
xmlKeys = {
cols: 'w:cols'
}
export class Columns extends XmlComponent {
constructor() {
this.cols = new Array<XmlComponent>();
this.cols.push(new Attributes({
super("w:cols");
this.root.push(new Attributes({
space: "708"
}));
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -12,30 +12,25 @@ interface PropertiesOptions {
revision?: string;
}
export class Properties implements XmlComponent {
private coreProperties: Array<XmlComponent>;
xmlKeys = {
coreProperties: "cp:coreProperties"
}
export class Properties extends XmlComponent {
constructor(options: PropertiesOptions) {
this.coreProperties = new Array<XmlComponent>();
this.coreProperties.push(new DocumentAttributes({
super("cp:coreProperties");
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"
}));
this.coreProperties.push(new Title(options.title));
this.coreProperties.push(new Subject(options.subject));
this.coreProperties.push(new Creator(options.creator));
this.coreProperties.push(new Keywords(options.keywords));
this.coreProperties.push(new Description(options.description));
this.coreProperties.push(new LastModifiedBy(options.lastModifiedBy));
this.coreProperties.push(new Revision(options.revision));
this.coreProperties.push(new Created());
this.coreProperties.push(new Modified());
this.root.push(new Title(options.title));
this.root.push(new Subject(options.subject));
this.root.push(new Creator(options.creator));
this.root.push(new Keywords(options.keywords));
this.root.push(new Description(options.description));
this.root.push(new LastModifiedBy(options.lastModifiedBy));
this.root.push(new Revision(options.revision));
this.root.push(new Created());
this.root.push(new Modified());
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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