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

@ -26,8 +26,13 @@ class TableBordersElement extends XmlComponent {
}
}
class TableBordersAttributes extends XmlAttributeComponent<{ value: string; size: number; space: number; color: string }> {
protected xmlKeys = {
class TableBordersAttributes extends XmlAttributeComponent<{
readonly value: string;
readonly size: number;
readonly space: number;
readonly color: string;
}> {
protected readonly xmlKeys = {
value: "w:val",
size: "w:sz",
space: "w:space",

View File

@ -2,8 +2,8 @@ import { IXmlableObject, XmlAttributeComponent, XmlComponent } from "file/xml-co
import { WidthType } from "../table-cell";
class TableCellMarginAttributes extends XmlAttributeComponent<{ type: WidthType; value: number }> {
protected xmlKeys = { value: "w:w", type: "w:sz" };
class TableCellMarginAttributes extends XmlAttributeComponent<{ readonly type: WidthType; readonly value: number }> {
protected readonly xmlKeys = { value: "w:w", type: "w:sz" };
}
class BaseTableCellMargin extends XmlComponent {

View File

@ -32,7 +32,7 @@ export interface ITableFloatOptions {
* text - relative to the vertical edge of the text margin for the column in which the anchor paragraph is located
* If omitted, the value is assumed to be page.
*/
horizontalAnchor?: TableAnchorType;
readonly horizontalAnchor?: TableAnchorType;
/**
* Specifies an absolute horizontal position for the table, relative to the horizontalAnchor.
@ -41,7 +41,7 @@ export interface ITableFloatOptions {
* If relativeHorizontalPosition is also specified, then the absoluteHorizontalPosition attribute is ignored.
* If the attribute is omitted, the value is assumed to be zero.
*/
absoluteHorizontalPosition?: number;
readonly absoluteHorizontalPosition?: number;
/**
* Specifies a relative horizontal position for the table, relative to the horizontalAnchor attribute.
@ -53,7 +53,7 @@ export interface ITableFloatOptions {
* outside - the table should be outside of the anchor
* right - the table should be right aligned with respect to the anchor
*/
relativeHorizontalPosition?: RelativeHorizontalPosition;
readonly relativeHorizontalPosition?: RelativeHorizontalPosition;
/**
* Specifies the vertical anchor or the base object from which the vertical positioning
@ -63,7 +63,7 @@ export interface ITableFloatOptions {
* text - relative to the horizontal edge of the text margin for the column in which the anchor paragraph is located
* If omitted, the value is assumed to be page.
*/
verticalAnchor?: TableAnchorType;
readonly verticalAnchor?: TableAnchorType;
/**
* Specifies an absolute vertical position for the table, relative to the verticalAnchor anchor.
@ -72,7 +72,7 @@ export interface ITableFloatOptions {
* If relativeVerticalPosition is also specified, then the absoluteVerticalPosition attribute is ignored.
* If the attribute is omitted, the value is assumed to be zero.
*/
absoluteVerticalPosition?: number;
readonly absoluteVerticalPosition?: number;
/**
* Specifies a relative vertical position for the table, relative to the verticalAnchor attribute.
@ -84,35 +84,35 @@ export interface ITableFloatOptions {
* inline - the table should be vertically aligned in line with the surrounding text (so as to not allow any text wrapping around it)
* top - the table should be vertically aligned to the top edge of the anchor
*/
relativeVerticalPosition?: RelativeVerticalPosition;
readonly relativeVerticalPosition?: RelativeVerticalPosition;
/**
* Specifies the minimun distance to be maintained between the table and the top of text in the paragraph
* below the table. The value is in twentieths of a point. If omitted, the value is assumed to be zero.
*/
bottomFromText?: number;
readonly bottomFromText?: number;
/**
* Specifies the minimun distance to be maintained between the table and the bottom edge of text in the paragraph
* above the table. The value is in twentieths of a point. If omitted, the value is assumed to be zero.
*/
topFromText?: number;
readonly topFromText?: number;
/**
* Specifies the minimun distance to be maintained between the table and the edge of text in the paragraph
* to the left of the table. The value is in twentieths of a point. If omitted, the value is assumed to be zero.
*/
leftFromText?: number;
readonly leftFromText?: number;
/**
* Specifies the minimun distance to be maintained between the table and the edge of text in the paragraph
* to the right of the table. The value is in twentieths of a point. If omitted, the value is assumed to be zero.
*/
rightFromText?: number;
readonly rightFromText?: number;
}
export class TableFloatOptionsAttributes extends XmlAttributeComponent<ITableFloatOptions> {
protected xmlKeys = {
protected readonly xmlKeys = {
horizontalAnchor: "w:horzAnchor",
verticalAnchor: "w:vertAnchor",
absoluteHorizontalPosition: "w:tblpX",

View File

@ -5,8 +5,8 @@ export enum TableLayoutType {
FIXED = "fixed",
}
class TableLayoutAttributes extends XmlAttributeComponent<{ type: TableLayoutType }> {
protected xmlKeys = { type: "w:type" };
class TableLayoutAttributes extends XmlAttributeComponent<{ readonly type: TableLayoutType }> {
protected readonly xmlKeys = { type: "w:type" };
}
export class TableLayout extends XmlComponent {

View File

@ -3,12 +3,12 @@ import { XmlAttributeComponent, XmlComponent } from "file/xml-components";
import { WidthType } from "../table-cell";
interface ITableWidth {
type: WidthType;
w: number | string;
readonly type: WidthType;
readonly w: number | string;
}
class TableWidthAttributes extends XmlAttributeComponent<ITableWidth> {
protected xmlKeys = { type: "w:type", w: "w:w" };
protected readonly xmlKeys = { type: "w:type", w: "w:w" };
}
export class PreferredTableWidth extends XmlComponent {