feat:zoom page header

pr675
Hufe921 3 years ago
parent debc6c1283
commit c0fee3ea14

@ -405,7 +405,7 @@ export class CommandAdapt {
const { startIndex, endIndex } = this.range.getRange()
if (!~startIndex && !~endIndex) return
const elementList = this.draw.getElementList()
const innerWidth = this.draw.getInnerWidth()
const innerWidth = this.draw.getOriginalInnerWidth()
// colgroup
const colgroup: IColgroup[] = []
const colWidth = innerWidth / col

@ -135,7 +135,7 @@ export class Draw {
this.i18n = new I18n()
this.historyManager = new HistoryManager()
this.position = new Position(this)
this.zone = new Zone()
this.zone = new Zone(this)
this.range = new RangeManager(this)
this.margin = new Margin(this)
this.background = new Background(this)
@ -215,10 +215,11 @@ export class Draw {
return Math.floor(this.getOriginalHeight() * this.options.scale)
}
public getOriginalMainHeight(): number {
const mainHeight = this.getOriginalHeight()
public getMainHeight(): number {
const pageHeight = this.getHeight()
const margins = this.getMargins()
const extraHeight = this.header.getExtraHeight()
return mainHeight - extraHeight
return pageHeight - margins[0] - margins[2] - extraHeight
}
public getCanvasWidth(pageNo = -1): number {
@ -804,8 +805,9 @@ export class Draw {
metrics.boundingBoxAscent = 0
// 表格分页处理(拆分表格)
const margins = this.getMargins()
const height = this.getOriginalMainHeight()
const marginHeight = margins[0] + margins[2]
const height = this.getHeight()
const headerExtraHeight = this.header.getExtraHeight()
const marginHeight = margins[0] + margins[2] + headerExtraHeight
let curPagePreHeight = marginHeight
for (let r = 0; r < rowList.length; r++) {
const row = rowList[r]
@ -816,7 +818,7 @@ export class Draw {
}
}
// 表格高度超过页面高度
const rowMarginHeight = rowMargin * 2
const rowMarginHeight = rowMargin * 2 * scale
if (curPagePreHeight + rowMarginHeight + elementHeight > height) {
const trList = element.trList!
// 计算需要移除的行数
@ -826,7 +828,8 @@ export class Draw {
if (trList.length > 1) {
for (let r = 0; r < trList.length; r++) {
const tr = trList[r]
if (curPagePreHeight + rowMarginHeight + preTrHeight + tr.height > height) {
const trHeight = tr.height * scale
if (curPagePreHeight + rowMarginHeight + preTrHeight + trHeight > height) {
// 是否跨列
if (element.colgroup?.length !== tr.tdList.length) {
deleteCount = 0
@ -835,7 +838,7 @@ export class Draw {
} else {
deleteStart = r + 1
deleteCount = trList.length - deleteStart
preTrHeight += tr.height
preTrHeight += trHeight
}
}
}
@ -970,9 +973,10 @@ export class Draw {
private _computePageList(): IRow[][] {
const pageRowList: IRow[][] = [[]]
const { pageMode } = this.options
const height = this.getOriginalMainHeight()
const height = this.getHeight()
const margins = this.getMargins()
const marginHeight = margins[0] + margins[2]
const headerExtraHeight = this.header.getExtraHeight()
const marginHeight = margins[0] + margins[2] + headerExtraHeight
let pageHeight = marginHeight
let pageNo = 0
if (pageMode === PageMode.CONTINUITY) {

@ -56,11 +56,11 @@ export class Header {
}
private _computePositionList() {
const { header: { top } } = this.options
const headerTop = this.getHeaderTop()
const innerWidth = this.draw.getInnerWidth()
const margins = this.draw.getMargins()
const startX = margins[3]
const startY = top
const startY = headerTop
this.position.computePageRowPosition({
positionList: this.positionList,
rowList: this.rowList,
@ -72,9 +72,14 @@ export class Header {
})
}
public getHeaderTop(): number {
const { header: { top }, scale } = this.options
return Math.floor(top * scale)
}
public getMaxHeight(): number {
const { header: { maxHeightRadio } } = this.options
const height = this.draw.getOriginalHeight()
const height = this.draw.getHeight()
return Math.floor(height * maxHeightRadioMapping[maxHeightRadio])
}
@ -89,10 +94,10 @@ export class Header {
}
public getExtraHeight(): number {
const { header: { top: headerTop } } = this.options
// 页眉上边距 + 实际高 - 页面上边距
const margins = this.draw.getOriginalMargins()
const margins = this.draw.getMargins()
const headerHeight = this.getHeight()
const headerTop = this.getHeaderTop()
const extraHeight = headerTop + headerHeight - margins[0]
return extraHeight <= 0 ? 0 : extraHeight
}

@ -12,12 +12,6 @@ function dblclick(host: CanvasEvent, evt: MouseEvent) {
})
if (!~positionContext.index && positionContext.zone) {
draw.getZone().setZone(positionContext.zone)
draw.getRange().clearRange()
draw.render({
isSubmitHistory: false,
isSetCursor: false,
isCompute: false
})
return
}
// 自动扩选文字

Loading…
Cancel
Save