Skip to content

Commit

Permalink
fix(sheet): merge align (#1537)
Browse files Browse the repository at this point in the history
  • Loading branch information
DR-Univer committed Mar 10, 2024
1 parent 1c77658 commit e0b49cc
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions packages/engine-render/src/components/sheets/extensions/font.ts
Expand Up @@ -218,7 +218,7 @@ export class Font extends SheetExtension {
}

ctx.translate(startX, startY);
this._renderDocuments(ctx, docsConfig, startX, startY, endX, endY, rowIndex, columnIndex);
this._renderDocuments(ctx, docsConfig, startX, startY, endX, endY, rowIndex, columnIndex, overflowCache);
ctx.restore();
});
});
Expand All @@ -233,7 +233,8 @@ export class Font extends SheetExtension {
endX: number,
endY: number,
row: number,
column: number
column: number,
overflowCache: ObjectMatrix<IRange>
) {
const documents = this.getDocuments() as Documents;

Expand All @@ -254,18 +255,20 @@ export class Font extends SheetExtension {

// Use fix https://github.com/dream-num/univer/issues/927, Set the actual width of the content to the page width of the document,
// so that the divide will be aligned when the skeleton is calculated.

const contentSize = getDocsSkeletonPageSize(documentSkeleton);
const documentStyle = documentSkeleton.getViewModel().getDataModel().getSnapshot().documentStyle;
if (contentSize && documentStyle) {
const { width } = contentSize;
const { marginRight = 0, marginLeft = 0 } = documentStyle;

documentSkeleton
.getViewModel()
.getDataModel()
.updateDocumentDataPageSize(width + marginLeft + marginRight);
documentSkeleton.calculate();
const overflowRectangle = overflowCache.getValue(row, column);
if (!(wrapStrategy === WrapStrategy.WRAP && !overflowRectangle && angle === 0)) {
const contentSize = getDocsSkeletonPageSize(documentSkeleton);
const documentStyle = documentSkeleton.getViewModel().getDataModel().getSnapshot().documentStyle;
if (contentSize && documentStyle) {
const { width } = contentSize;
const { marginRight = 0, marginLeft = 0 } = documentStyle;

documentSkeleton
.getViewModel()
.getDataModel()
.updateDocumentDataPageSize(width + marginLeft + marginRight);
documentSkeleton.calculate();
}
}

documentSkeleton.makeDirty(false);
Expand Down

0 comments on commit e0b49cc

Please sign in to comment.