Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
fix(sheet): wrap and rotation (#1517)
Univer9e8cc4500f71
diff --git a/packages/engine-render/src/components/docs/document.ts b/packages/engine-render/src/components/docs/document.tsindex 768dabb4f9..03f16910bc 100644--- a/packages/engine-render/src/components/docs/document.ts+++ b/packages/engine-render/src/components/docs/document.ts@@ -235,8 +235,8 @@ export class Documents extends DocComponent {renderConfig = {},} = page;const {- verticalAlign = VerticalAlign.TOP,- horizontalAlign = HorizontalAlign.LEFT,+ verticalAlign = VerticalAlign.UNSPECIFIED,+ horizontalAlign = HorizontalAlign.UNSPECIFIED,centerAngle: centerAngleDeg = 0,vertexAngle: vertexAngleDeg = 0,wrapStrategy = WrapStrategy.UNSPECIFIED,@@ -247,7 +247,8 @@ export class Documents extends DocComponent {actualWidth,pagePaddingLeft,pagePaddingRight,- horizontalAlign+ horizontalAlign,+ vertexAngleDeg);const verticalOffsetNoAngle = this._verticalHandler(@@ -310,7 +311,8 @@ export class Documents extends DocComponent {exceedWidthFix,pagePaddingLeft,pagePaddingRight,- horizontalAlign+ horizontalAlign,+ vertexAngle);const verticalOffset = this._verticalHandler(@@ -454,7 +456,8 @@ export class Documents extends DocComponent {pageWidth: number,pagePaddingLeft: number,pagePaddingRight: number,- horizontalAlign: HorizontalAlign+ horizontalAlign: HorizontalAlign,+ angle: number = 0) {let offsetLeft = 0;if (horizontalAlign === HorizontalAlign.CENTER) {@@ -462,7 +465,15 @@ export class Documents extends DocComponent {} else if (horizontalAlign === HorizontalAlign.RIGHT) {offsetLeft = this.width - pageWidth - pagePaddingRight;} else {- offsetLeft = pagePaddingLeft;+ /**+ * In Excel, if horizontal alignment is not specified,+ * rotated text aligns to the right when rotated downwards and aligns to the left when rotated upwards.+ */+ if (horizontalAlign === HorizontalAlign.UNSPECIFIED && angle > 0) {+ offsetLeft = this.width - pageWidth - pagePaddingRight;+ } else {+ offsetLeft = pagePaddingLeft;+ }}return offsetLeft;diff --git a/packages/engine-render/src/components/sheets/extensions/font.ts b/packages/engine-render/src/components/sheets/extensions/font.tsindex 1189309e18..ded24a5ee7 100644--- a/packages/engine-render/src/components/sheets/extensions/font.ts+++ b/packages/engine-render/src/components/sheets/extensions/font.ts@@ -254,19 +254,18 @@ 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.- if (wrapStrategy !== WrapStrategy.WRAP) {- 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 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);