simplify section-properties
This commit is contained in:
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
|
||||
|
Reference in New Issue
Block a user