Files
docx-js/ts/styles/style/index.ts

83 lines
2.7 KiB
TypeScript
Raw Normal View History

2016-04-09 04:27:49 +01:00
import {XmlComponent} from "../../docx/xml-components";
import {StyleAttributes} from "./attributes";
2016-05-08 17:01:20 +01:00
import {ParagraphProperties} from "../../docx/paragraph/properties";
import {RunProperties} from "../../docx/run/properties";
import {Name, BasedOn, Next, QuickFormat} from "./components";
2016-04-09 04:27:49 +01:00
2016-04-09 20:16:35 +01:00
export class Style extends XmlComponent {
2016-05-08 17:01:20 +01:00
2016-04-09 04:27:49 +01:00
constructor(attributes: StyleAttributes) {
2016-04-09 20:16:35 +01:00
super("w:style");
this.root.push(attributes);
2016-04-09 04:27:49 +01:00
}
2016-05-08 17:01:20 +01:00
2016-04-09 04:27:49 +01:00
push(styleSegment: XmlComponent): void {
2016-04-09 20:16:35 +01:00
this.root.push(styleSegment);
2016-04-09 04:27:49 +01:00
}
2016-05-07 20:17:18 +01:00
}
2016-05-08 17:01:20 +01:00
export class ParagraphStyle extends Style {
constructor(styleId: string, paragraphProperties: ParagraphProperties, runProperties: RunProperties) {
var attributes = new StyleAttributes({
type: "paragraph",
styleId: styleId
});
super(attributes);
this.root.push(paragraphProperties);
this.root.push(runProperties);
}
}
export class HeadingStyle extends ParagraphStyle {
constructor(styleId: string, name: string, paragraphProperties: ParagraphProperties, runProperties: RunProperties) {
super(styleId, paragraphProperties, runProperties);
this.root.push(new Name(name));
this.root.push(new BasedOn("Normal"));
this.root.push(new Next("Normal"));
this.root.push(new QuickFormat());
}
}
export class Heading1Style extends HeadingStyle {
constructor(paragraphProperties: ParagraphProperties, runProperties: RunProperties) {
super("Heading1", "Heading 1", paragraphProperties, runProperties);
}
}
export class Heading2Style extends HeadingStyle {
2016-05-07 20:17:18 +01:00
2016-05-08 17:01:20 +01:00
constructor(paragraphProperties: ParagraphProperties, runProperties: RunProperties) {
super("Heading2", "Heading 2", paragraphProperties, runProperties);
}
}
export class Heading3Style extends HeadingStyle {
constructor(paragraphProperties: ParagraphProperties, runProperties: RunProperties) {
super("Heading3", "Heading 3", paragraphProperties, runProperties);
}
}
export class Heading4Style extends HeadingStyle {
constructor(paragraphProperties: ParagraphProperties, runProperties: RunProperties) {
super("Heading4", "Heading 4", paragraphProperties, runProperties);
}
}
export class Heading5Style extends HeadingStyle {
constructor(paragraphProperties: ParagraphProperties, runProperties: RunProperties) {
super("Heading5", "Heading 5", paragraphProperties, runProperties);
}
}
export class Heading6Style extends HeadingStyle {
constructor(paragraphProperties: ParagraphProperties, runProperties: RunProperties) {
super("Heading6", "Heading 6", paragraphProperties, runProperties);
}
2016-04-09 04:27:49 +01:00
}