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 { export class LineNumberType extends XmlComponent {
constructor(countBy?: number, start?: number, restart?: LineNumberRestartFormat, dist?: number) { constructor(options: ILineNumberAttributes) {
super("w:lnNumType"); super("w:lnNumType");
this.root.push( this.root.push(new LineNumberAttributes(options));
new LineNumberAttributes({
countBy: countBy,
start: start,
restart: restart,
distance: dist,
}),
);
} }
} }

View File

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

View File

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