added heading styles

This commit is contained in:
Dolan Miu
2016-05-08 17:01:20 +01:00
parent c6291f57ab
commit a1b4facb40
5 changed files with 79 additions and 11 deletions

View File

@ -4,9 +4,9 @@ import {RunPropertiesDefaults} from "./run-properties";
export class DocumentDefaults extends XmlComponent {
constructor() {
constructor(runPropertiesDefaults: RunPropertiesDefaults, paragraphPropertiesDefaults: ParagraphPropertiesDefaults) {
super("w:docDefaults");
this.root.push(new RunPropertiesDefaults());
this.root.push(new ParagraphPropertiesDefaults());
this.root.push(runPropertiesDefaults);
this.root.push(paragraphPropertiesDefaults);
}
}

View File

@ -1,133 +0,0 @@
import {XmlComponent, Attributes} from "../../docx/xml-components";
export class Bold extends XmlComponent {
constructor() {
super("w:b");
this.root.push(new Attributes({
val: true
}));
}
}
export class Italics extends XmlComponent {
constructor() {
super("w:i");
this.root.push(new Attributes({
val: true
}));
}
}
// needs work. add more types of underline
export class Underline extends XmlComponent {
constructor() {
super("w:u");
this.root.push(new Attributes({
val: true
}));
}
}
export class Caps extends XmlComponent {
constructor() {
super("w:caps");
this.root.push(new Attributes({
val: true
}));
}
}
export class Color extends XmlComponent {
constructor(color: string) {
super("w:color");
this.root.push(new Attributes({
val: color
}));
}
}
export class DoubleStrike extends XmlComponent {
constructor() {
super("w:dstrike");
this.root.push(new Attributes({
val: true
}));
}
}
export class Emboss extends XmlComponent {
constructor() {
super("w:emboss");
this.root.push(new Attributes({
val: true
}));
}
}
export class Imprint extends XmlComponent {
constructor() {
super("w:imprint");
this.root.push(new Attributes({
val: true
}));
}
}
export class Shadow extends XmlComponent {
constructor() {
super("w:shadow");
this.root.push(new Attributes({
val: true
}));
}
}
export class SmallCaps extends XmlComponent {
constructor() {
super("w:smallCaps");
this.root.push(new Attributes({
val: true
}));
}
}
export class Strike extends XmlComponent {
constructor() {
super("w:strike");
this.root.push(new Attributes({
val: true
}));
}
}
export class Size extends XmlComponent {
constructor(size: number) {
super("w:sz");
this.root.push(new Attributes({
val: size
}));
}
}
// needs work
export class VerticalAlign extends XmlComponent {
constructor() {
super("w:vertAlign");
this.root.push(new Attributes({
val: "superscript"
}));
}
}

View File

@ -56,8 +56,11 @@ export class UnhideWhenUsed extends XmlComponent {
}
export class QFormat extends XmlComponent {
export class QuickFormat extends XmlComponent {
constructor() {
super("w:qFormat");
}
}
export class TableProperties extends XmlComponent {

View File

@ -1,18 +1,83 @@
import {XmlComponent} from "../../docx/xml-components";
import {StyleAttributes} from "./attributes";
import {ParagraphProperties} from "../../docx/paragraph/properties";
import {RunProperties} from "../../docx/run/properties";
import {Name, BasedOn, Next, QuickFormat} from "./components";
export class Style extends XmlComponent {
constructor(attributes: StyleAttributes) {
super("w:style");
this.root.push(attributes);
}
push(styleSegment: XmlComponent): void {
this.root.push(styleSegment);
}
}
export class ParagraphStyle extends XmlComponent {
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 {
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);
}
}