2017-09-19 15:42:40 +01:00
|
|
|
// http://officeopenxml.com/WPtext.php
|
|
|
|
import { Break } from "./break";
|
|
|
|
import { Caps, SmallCaps } from "./caps";
|
2018-09-03 10:54:53 -03:00
|
|
|
import { Begin, End, Separate } from "./field";
|
2018-08-08 20:20:22 +01:00
|
|
|
import {
|
|
|
|
Bold,
|
|
|
|
BoldComplexScript,
|
|
|
|
Color,
|
|
|
|
DoubleStrike,
|
|
|
|
Italics,
|
|
|
|
ItalicsComplexScript,
|
|
|
|
RightToLeft,
|
|
|
|
Size,
|
|
|
|
SizeComplexScript,
|
|
|
|
Strike,
|
|
|
|
} from "./formatting";
|
2018-09-03 10:54:53 -03:00
|
|
|
import { Page } from "./page-number";
|
2017-09-19 15:42:40 +01:00
|
|
|
import { RunProperties } from "./properties";
|
|
|
|
import { RunFonts } from "./run-fonts";
|
|
|
|
import { SubScript, SuperScript } from "./script";
|
|
|
|
import { Style } from "./style";
|
|
|
|
import { Tab } from "./tab";
|
|
|
|
import { Underline } from "./underline";
|
|
|
|
|
2017-12-30 20:25:16 +00:00
|
|
|
import { XmlComponent } from "file/xml-components";
|
2017-09-19 15:42:40 +01:00
|
|
|
|
|
|
|
export class Run extends XmlComponent {
|
2018-06-25 19:49:46 +01:00
|
|
|
protected properties: RunProperties;
|
2017-09-19 15:42:40 +01:00
|
|
|
|
|
|
|
constructor() {
|
|
|
|
super("w:r");
|
|
|
|
this.properties = new RunProperties();
|
|
|
|
this.root.push(this.properties);
|
|
|
|
}
|
|
|
|
|
|
|
|
public bold(): Run {
|
|
|
|
this.properties.push(new Bold());
|
2018-08-08 20:20:22 +01:00
|
|
|
this.properties.push(new BoldComplexScript());
|
2017-09-19 15:42:40 +01:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public italic(): Run {
|
|
|
|
this.properties.push(new Italics());
|
2018-08-08 20:20:22 +01:00
|
|
|
this.properties.push(new ItalicsComplexScript());
|
2017-09-19 15:42:40 +01:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public underline(underlineType?: string, color?: string): Run {
|
|
|
|
this.properties.push(new Underline(underlineType, color));
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public color(color: string): Run {
|
|
|
|
this.properties.push(new Color(color));
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public size(size: number): Run {
|
|
|
|
this.properties.push(new Size(size));
|
2018-08-07 02:47:24 +01:00
|
|
|
this.properties.push(new SizeComplexScript(size));
|
2017-09-19 15:42:40 +01:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2018-08-07 02:47:24 +01:00
|
|
|
public rightToLeft(): Run {
|
|
|
|
this.properties.push(new RightToLeft());
|
2018-07-24 18:52:45 +03:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2017-09-19 15:42:40 +01:00
|
|
|
public break(): Run {
|
|
|
|
this.root.splice(1, 0, new Break());
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public tab(): Run {
|
|
|
|
this.root.splice(1, 0, new Tab());
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2018-05-12 20:04:54 -04:00
|
|
|
public pageNumber(): Run {
|
|
|
|
this.root.push(new Begin());
|
|
|
|
this.root.push(new Page());
|
|
|
|
this.root.push(new Separate());
|
|
|
|
this.root.push(new End());
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2017-09-19 15:42:40 +01:00
|
|
|
public smallCaps(): Run {
|
|
|
|
this.properties.push(new SmallCaps());
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public allCaps(): Run {
|
|
|
|
this.properties.push(new Caps());
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public strike(): Run {
|
|
|
|
this.properties.push(new Strike());
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public doubleStrike(): Run {
|
|
|
|
this.properties.push(new DoubleStrike());
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public subScript(): Run {
|
|
|
|
this.properties.push(new SubScript());
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public superScript(): Run {
|
|
|
|
this.properties.push(new SuperScript());
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2018-07-25 15:02:58 +03:00
|
|
|
public font(fontName: string, hint?: string | undefined): Run {
|
|
|
|
this.properties.push(new RunFonts(fontName, hint));
|
2017-09-19 15:42:40 +01:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public style(styleId: string): Run {
|
|
|
|
this.properties.push(new Style(styleId));
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
}
|