simplify section-properties

This commit is contained in:
Tom Hunkapiller
2021-05-23 07:33:43 +03:00
parent 5155cdaf45
commit 54ab55b92c
3 changed files with 12 additions and 43 deletions

View File

@ -24,15 +24,8 @@ export class LineNumberAttributes extends XmlAttributeComponent<ILineNumberAttri
}
export class LineNumberType extends XmlComponent {
constructor(countBy?: number, start?: number, restart?: LineNumberRestartFormat, dist?: number) {
constructor(options: ILineNumberAttributes) {
super("w:lnNumType");
this.root.push(
new LineNumberAttributes({
countBy: countBy,
start: start,
restart: restart,
distance: dist,
}),
);
this.root.push(new LineNumberAttributes(options));
}
}

View File

@ -40,14 +40,8 @@ export class PageNumberTypeAttributes extends XmlAttributeComponent<IPageNumberT
}
export class PageNumberType extends XmlComponent {
constructor(start?: number, numberFormat?: PageNumberFormat, separator?: PageNumberSeparator) {
constructor(options: IPageNumberTypeAttributes) {
super("w:pgNumType");
this.root.push(
new PageNumberTypeAttributes({
start: start,
formatType: numberFormat,
separator: separator,
}),
);
this.root.push(new PageNumberTypeAttributes(options));
}
}

View File

@ -64,23 +64,13 @@ export class SectionProperties extends XmlComponent {
footer = 708,
gutter = 0,
} = {},
pageNumbers: {
start: pageNumberStart = undefined,
formatType: pageNumberFormatType = undefined,
separator: pageNumberSeparator = undefined,
} = {},
borders: {
pageBorders = undefined,
pageBorderTop = undefined,
pageBorderRight = undefined,
pageBorderBottom = undefined,
pageBorderLeft = undefined,
} = {},
pageNumbers = {},
borders,
} = {},
grid: { linePitch = 360 } = {},
headerWrapperGroup = {},
footerWrapperGroup = {},
lineNumbers: { countBy: lineNumberCountBy, start: lineNumberStart, restart: lineNumberRestart, distance: lineNumberDistance } = {},
lineNumbers,
titlePage = false,
verticalAlign,
column: { space = 708, count = 1, separate = false } = {},
@ -98,23 +88,15 @@ export class SectionProperties extends XmlComponent {
this.root.push(new PageSize(width, height, orientation));
this.root.push(new PageMargin(top, right, bottom, left, header, footer, gutter));
if (pageBorders || pageBorderTop || pageBorderRight || pageBorderBottom || pageBorderLeft) {
this.root.push(
new PageBorders({
pageBorders: pageBorders,
pageBorderTop: pageBorderTop,
pageBorderRight: pageBorderRight,
pageBorderBottom: pageBorderBottom,
pageBorderLeft: pageBorderLeft,
}),
);
if (borders) {
this.root.push(new PageBorders(borders));
}
if (lineNumberCountBy || lineNumberStart || lineNumberRestart || lineNumberDistance) {
this.root.push(new LineNumberType(lineNumberCountBy, lineNumberStart, lineNumberRestart, lineNumberDistance));
if (lineNumbers) {
this.root.push(new LineNumberType(lineNumbers));
}
this.root.push(new PageNumberType(pageNumberStart, pageNumberFormatType, pageNumberSeparator));
this.root.push(new PageNumberType(pageNumbers));
this.root.push(new Columns(space, count, separate));