Introduce some functional programming techniques

This commit is contained in:
Dolan
2018-11-02 02:51:57 +00:00
parent 9cfd835171
commit 7980f14efb
108 changed files with 749 additions and 659 deletions

View File

@ -2,16 +2,16 @@ import { XmlAttributeComponent } from "file/xml-components";
import { IDistance } from "../drawing";
export interface IAnchorAttributes extends IDistance {
allowOverlap?: "0" | "1";
behindDoc?: "0" | "1";
layoutInCell?: "0" | "1";
locked?: "0" | "1";
relativeHeight?: number;
simplePos?: "0" | "1";
readonly allowOverlap?: "0" | "1";
readonly behindDoc?: "0" | "1";
readonly layoutInCell?: "0" | "1";
readonly locked?: "0" | "1";
readonly relativeHeight?: number;
readonly simplePos?: "0" | "1";
}
export class AnchorAttributes extends XmlAttributeComponent<IAnchorAttributes> {
protected xmlKeys = {
protected readonly xmlKeys = {
distT: "distT",
distB: "distB",
distL: "distL",

View File

@ -1,13 +1,13 @@
import { XmlAttributeComponent } from "file/xml-components";
export interface IDocPropertiesAttributes {
id?: number;
name?: string;
descr?: string;
readonly id?: number;
readonly name?: string;
readonly descr?: string;
}
export class DocPropertiesAttributes extends XmlAttributeComponent<IDocPropertiesAttributes> {
protected xmlKeys = {
protected readonly xmlKeys = {
id: "id",
name: "name",
descr: "descr",

View File

@ -11,16 +11,16 @@ export enum PlacementPosition {
}
export interface IDistance {
distT?: number;
distB?: number;
distL?: number;
distR?: number;
readonly distT?: number;
readonly distB?: number;
readonly distL?: number;
readonly distR?: number;
}
export interface IDrawingOptions {
position?: PlacementPosition;
textWrapping?: ITextWrapping;
floating?: IFloating;
readonly position?: PlacementPosition;
readonly textWrapping?: ITextWrapping;
readonly floating?: IFloating;
}
const defaultDrawingOptions: IDrawingOptions = {

View File

@ -1,14 +1,14 @@
import { XmlAttributeComponent } from "file/xml-components";
export interface IEffectExtentAttributes {
b?: number;
l?: number;
r?: number;
t?: number;
readonly b?: number;
readonly l?: number;
readonly r?: number;
readonly t?: number;
}
export class EffectExtentAttributes extends XmlAttributeComponent<IEffectExtentAttributes> {
protected xmlKeys = {
protected readonly xmlKeys = {
b: "b",
l: "l",
r: "r",

View File

@ -1,12 +1,12 @@
import { XmlAttributeComponent } from "file/xml-components";
export interface IExtentAttributes {
cx?: number;
cy?: number;
readonly cx?: number;
readonly cy?: number;
}
export class ExtentAttributes extends XmlAttributeComponent<IExtentAttributes> {
protected xmlKeys = {
protected readonly xmlKeys = {
cx: "cx",
cy: "cy",
};

View File

@ -39,22 +39,22 @@ export enum VerticalPositionAlign {
}
export interface IHorizontalPositionOptions {
relative: HorizontalPositionRelativeFrom;
align?: HorizontalPositionAlign;
offset?: number;
readonly relative: HorizontalPositionRelativeFrom;
readonly align?: HorizontalPositionAlign;
readonly offset?: number;
}
export interface IVerticalPositionOptions {
relative: VerticalPositionRelativeFrom;
align?: VerticalPositionAlign;
offset?: number;
readonly relative: VerticalPositionRelativeFrom;
readonly align?: VerticalPositionAlign;
readonly offset?: number;
}
export interface IFloating {
horizontalPosition: IHorizontalPositionOptions;
verticalPosition: IVerticalPositionOptions;
allowOverlap?: boolean;
lockAnchor?: boolean;
behindDocument?: boolean;
layoutInCell?: boolean;
readonly horizontalPosition: IHorizontalPositionOptions;
readonly verticalPosition: IVerticalPositionOptions;
readonly allowOverlap?: boolean;
readonly lockAnchor?: boolean;
readonly behindDocument?: boolean;
readonly layoutInCell?: boolean;
}

View File

@ -5,11 +5,11 @@ import { HorizontalPositionRelativeFrom, IHorizontalPositionOptions } from "./fl
import { PositionOffset } from "./position-offset";
interface IHorizontalPositionAttributes {
relativeFrom: HorizontalPositionRelativeFrom;
readonly relativeFrom: HorizontalPositionRelativeFrom;
}
class HorizontalPositionAttributes extends XmlAttributeComponent<IHorizontalPositionAttributes> {
protected xmlKeys = {
protected readonly xmlKeys = {
relativeFrom: "relativeFrom",
};
}

View File

@ -2,12 +2,12 @@
import { XmlAttributeComponent, XmlComponent } from "file/xml-components";
interface ISimplePosAttributes {
x: number;
y: number;
readonly x: number;
readonly y: number;
}
class SimplePosAttributes extends XmlAttributeComponent<ISimplePosAttributes> {
protected xmlKeys = {
protected readonly xmlKeys = {
x: "x",
y: "y",
};

View File

@ -5,11 +5,11 @@ import { IVerticalPositionOptions, VerticalPositionRelativeFrom } from "./floati
import { PositionOffset } from "./position-offset";
interface IVerticalPositionAttributes {
relativeFrom: VerticalPositionRelativeFrom;
readonly relativeFrom: VerticalPositionRelativeFrom;
}
class VerticalPositionAttributes extends XmlAttributeComponent<IVerticalPositionAttributes> {
protected xmlKeys = {
protected readonly xmlKeys = {
relativeFrom: "relativeFrom",
};
}

View File

@ -1,12 +1,12 @@
import { XmlAttributeComponent } from "file/xml-components";
export interface IGraphicFrameLockAttributes {
xmlns?: string;
noChangeAspect?: number;
readonly xmlns?: string;
readonly noChangeAspect?: number;
}
export class GraphicFrameLockAttributes extends XmlAttributeComponent<IGraphicFrameLockAttributes> {
protected xmlKeys = {
protected readonly xmlKeys = {
xmlns: "xmlns:a",
noChangeAspect: "noChangeAspect",
};

View File

@ -1,11 +1,11 @@
import { XmlAttributeComponent } from "file/xml-components";
export interface IGraphicDataAttributes {
uri?: string;
readonly uri?: string;
}
export class GraphicDataAttributes extends XmlAttributeComponent<IGraphicDataAttributes> {
protected xmlKeys = {
protected readonly xmlKeys = {
uri: "uri",
};
}

View File

@ -1,12 +1,12 @@
import { XmlAttributeComponent, XmlComponent } from "file/xml-components";
interface IBlipProperties {
embed: string;
cstate: string;
readonly embed: string;
readonly cstate: string;
}
class BlipAttributes extends XmlAttributeComponent<IBlipProperties> {
protected xmlKeys = {
protected readonly xmlKeys = {
embed: "r:embed",
cstate: "cstate",
};

View File

@ -1,12 +1,12 @@
import { XmlAttributeComponent } from "file/xml-components";
export interface IPicLocksAttributes {
noChangeAspect?: number;
noChangeArrowheads?: number;
readonly noChangeAspect?: number;
readonly noChangeArrowheads?: number;
}
export class PicLocksAttributes extends XmlAttributeComponent<IPicLocksAttributes> {
protected xmlKeys = {
protected readonly xmlKeys = {
noChangeAspect: "noChangeAspect",
noChangeArrowheads: "noChangeArrowheads",
};

View File

@ -1,13 +1,13 @@
import { XmlAttributeComponent } from "file/xml-components";
export interface INonVisualPropertiesAttributes {
id?: number;
name?: string;
descr?: string;
readonly id?: number;
readonly name?: string;
readonly descr?: string;
}
export class NonVisualPropertiesAttributes extends XmlAttributeComponent<INonVisualPropertiesAttributes> {
protected xmlKeys = {
protected readonly xmlKeys = {
id: "id",
name: "name",
descr: "desc",

View File

@ -1,11 +1,11 @@
import { XmlAttributeComponent } from "file/xml-components";
export interface IPicAttributes {
xmlns?: string;
readonly xmlns?: string;
}
export class PicAttributes extends XmlAttributeComponent<IPicAttributes> {
protected xmlKeys = {
protected readonly xmlKeys = {
xmlns: "xmlns:pic",
};
}

View File

@ -1,12 +1,12 @@
import { XmlAttributeComponent } from "file/xml-components";
export interface IExtentsAttributes {
cx?: number;
cy?: number;
readonly cx?: number;
readonly cy?: number;
}
export class ExtentsAttributes extends XmlAttributeComponent<IExtentsAttributes> {
protected xmlKeys = {
protected readonly xmlKeys = {
cx: "cx",
cy: "cy",
};

View File

@ -1,12 +1,12 @@
import { XmlAttributeComponent } from "file/xml-components";
export interface IOffsetAttributes {
x?: number;
y?: number;
readonly x?: number;
readonly y?: number;
}
export class OffsetAttributes extends XmlAttributeComponent<IOffsetAttributes> {
protected xmlKeys = {
protected readonly xmlKeys = {
x: "x",
y: "y",
};

View File

@ -1,11 +1,11 @@
import { XmlAttributeComponent } from "file/xml-components";
export interface IPresetGeometryAttributes {
prst?: string;
readonly prst?: string;
}
export class PresetGeometryAttributes extends XmlAttributeComponent<IPresetGeometryAttributes> {
protected xmlKeys = {
protected readonly xmlKeys = {
prst: "prst",
};
}

View File

@ -1,11 +1,11 @@
import { XmlAttributeComponent } from "file/xml-components";
export interface IShapePropertiesAttributes {
bwMode?: string;
readonly bwMode?: string;
}
export class ShapePropertiesAttributes extends XmlAttributeComponent<IShapePropertiesAttributes> {
protected xmlKeys = {
protected readonly xmlKeys = {
bwMode: "bwMode",
};
}

View File

@ -2,11 +2,11 @@ import { XmlAttributeComponent, XmlComponent } from "file/xml-components";
import { GraphicData } from "./graphic-data";
interface IGraphicProperties {
a: string;
readonly a: string;
}
class GraphicAttributes extends XmlAttributeComponent<IGraphicProperties> {
protected xmlKeys = {
protected readonly xmlKeys = {
a: "xmlns:a",
};
}

View File

@ -5,7 +5,7 @@ import { IDistance } from "../drawing";
export interface IInlineAttributes extends IDistance {}
export class InlineAttributes extends XmlAttributeComponent<IInlineAttributes> {
protected xmlKeys = {
protected readonly xmlKeys = {
distT: "distT",
distB: "distB",
distL: "distL",

View File

@ -16,7 +16,7 @@ export enum WrapTextOption {
}
export interface ITextWrapping {
textWrapStyle: TextWrapStyle;
wrapTextOption?: WrapTextOption;
distanceFromText?: IDistance;
readonly textWrapStyle: TextWrapStyle;
readonly wrapTextOption?: WrapTextOption;
readonly distanceFromText?: IDistance;
}

View File

@ -4,11 +4,11 @@ import { ITextWrapping, WrapTextOption } from ".";
import { IDistance } from "../drawing";
interface IWrapSquareAttributes extends IDistance {
wrapText?: WrapTextOption;
readonly wrapText?: WrapTextOption;
}
class WrapSquareAttributes extends XmlAttributeComponent<IWrapSquareAttributes> {
protected xmlKeys = {
protected readonly xmlKeys = {
distT: "distT",
distB: "distB",
distL: "distL",

View File

@ -3,25 +3,25 @@ import { XmlAttributeComponent, XmlComponent } from "file/xml-components";
import { IDistance } from "../drawing";
interface IWrapTightAttributes {
distT?: number;
distB?: number;
readonly distT?: number;
readonly distB?: number;
}
class WrapTightAttributes extends XmlAttributeComponent<IWrapTightAttributes> {
protected xmlKeys = {
protected readonly xmlKeys = {
distT: "distT",
distB: "distB",
};
}
export class WrapTight extends XmlComponent {
constructor(distanceFromText?: IDistance) {
super("wp:wrapTight");
distanceFromText = distanceFromText || {
constructor(
distanceFromText: IDistance = {
distT: 0,
distB: 0,
};
},
) {
super("wp:wrapTight");
this.root.push(
new WrapTightAttributes({

View File

@ -3,25 +3,25 @@ import { XmlAttributeComponent, XmlComponent } from "file/xml-components";
import { IDistance } from "../drawing";
interface IWrapTopAndBottomAttributes {
distT?: number;
distB?: number;
readonly distT?: number;
readonly distB?: number;
}
class WrapTopAndBottomAttributes extends XmlAttributeComponent<IWrapTopAndBottomAttributes> {
protected xmlKeys = {
protected readonly xmlKeys = {
distT: "distT",
distB: "distB",
};
}
export class WrapTopAndBottom extends XmlComponent {
constructor(distanceFromText?: IDistance) {
super("wp:wrapTopAndBottom");
distanceFromText = distanceFromText || {
constructor(
distanceFromText: IDistance = {
distT: 0,
distB: 0,
};
},
) {
super("wp:wrapTopAndBottom");
this.root.push(
new WrapTopAndBottomAttributes({