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): text rotation is not overflow when set overflow format (#663)
Ran Luoe4493272c695
diff --git a/examples/data/src/slides/rich-text/page5-richtext1.ts b/examples/data/src/slides/rich-text/page5-richtext1.tsindex 5a8d5275c4..91bb095737 100644--- a/examples/data/src/slides/rich-text/page5-richtext1.ts+++ b/examples/data/src/slides/rich-text/page5-richtext1.ts@@ -12,44 +12,53 @@ export const PAGE5_RICHTEXT_1: IDocumentData = {textRuns: [{st: 0,- ed: 66,+ ed: 67,ts: {bl: BooleanNumber.TRUE,fs: 24,cl: {- rgb: 'rgb(0,40,86)',+ rgb: 'rgb(205, 40, 86)',},},},{st: 68,- ed: 252,+ ed: 253,ts: {- fs: 18,+ fs: 16,cl: {- rgb: 'rgb(0,40,86)',+ rgb: 'rgb(0, 255, 86)',},},},{st: 254,- ed: 403,+ ed: 404,ts: {- fs: 16,+ fs: 14,+ cl: {+ rgb: 'rgb(0, 255, 255)',+ },},},{st: 405,- ed: 432,+ ed: 433,ts: {fs: 16,+ cl: {+ rgb: 'rgb(255, 255, 86)',+ },},},{st: 434,- ed: 483,+ ed: 484,ts: {fs: 16,+ cl: {+ rgb: 'rgb(0, 255, 186)',+ },},},{@@ -57,6 +66,9 @@ export const PAGE5_RICHTEXT_1: IDocumentData = {ed: 515,ts: {fs: 16,+ cl: {+ rgb: 'rgb(60, 255, 86)',+ },},},],@@ -123,7 +135,7 @@ export const PAGE5_RICHTEXT_1: IDocumentData = {startIndex: 517,columnProperties: [{- width: 150,+ width: 200,paddingEnd: 5,},],diff --git a/packages/engine-render/src/components/sheets/sheet-skeleton.ts b/packages/engine-render/src/components/sheets/sheet-skeleton.tsindex f4f22dd1c2..c1890b6467 100644--- a/packages/engine-render/src/components/sheets/sheet-skeleton.ts+++ b/packages/engine-render/src/components/sheets/sheet-skeleton.ts@@ -34,8 +34,8 @@ import {WrapStrategy,} from '@univerjs/core';-import { BORDER_TYPE, COLOR_BLACK_RGB, MAXIMUM_ROW_HEIGHT, ORIENTATION_TYPE } from '../../basics/const';-import { getRotateOffsetAndFarthestHypotenuse, getRotateOrientation } from '../../basics/draw';+import { BORDER_TYPE, COLOR_BLACK_RGB, MAXIMUM_ROW_HEIGHT } from '../../basics/const';+import { getRotateOffsetAndFarthestHypotenuse } from '../../basics/draw';import type { IDocumentSkeletonColumn } from '../../basics/i-document-skeleton-cached';import {degToRad,@@ -80,7 +80,6 @@ export function getDocsSkeletonPageSize(documentSkeleton: DocumentSkeleton, angllet allRotatedWidth = 0;let allRotatedHeight = 0;- const orientation = getRotateOrientation(angle);const widthArray: Array<{ rotatedWidth: number; spaceWidth: number }> = [];columnIterator([lastPage], (column: IDocumentSkeletonColumn) => {@@ -93,24 +92,14 @@ export function getDocsSkeletonPageSize(documentSkeleton: DocumentSkeleton, anglwidthArray.push({ rotatedWidth, spaceWidth });});- const tanTheta = Math.tan(angle);- const sinTheta = Math.sin(angle);-const widthCount = widthArray.length;for (let i = 0; i < widthCount; i++) {- const { rotatedWidth, spaceWidth } = widthArray[i];+ const { rotatedWidth } = widthArray[i];if (i === 0) {allRotatedWidth += rotatedWidth;}-- if (- (orientation === ORIENTATION_TYPE.UP && i === 0) ||- (orientation === ORIENTATION_TYPE.DOWN && i === widthCount - 1)- ) {- allRotatedWidth += (rotatedWidth + spaceWidth / sinTheta) / tanTheta;- }}return {diff --git a/packages/sheets-ui/src/controllers/editor/editing.controller.ts b/packages/sheets-ui/src/controllers/editor/editing.controller.tsindex 0a70506576..2cdee366b0 100644--- a/packages/sheets-ui/src/controllers/editor/editing.controller.ts+++ b/packages/sheets-ui/src/controllers/editor/editing.controller.ts@@ -117,7 +117,7 @@ export class EditingController extends RxDisposable {// console.log(res.sheetData, res.arrayFormulaRange);// });- console.log('calculate', this._formulaEngineService.calculate(`= -@A4:B5`, false));+ // console.log('calculate', this._formulaEngineService.calculate(`= -@A4:B5`, false));}private _commandExecutedListener() {}diff --git a/packages/sheets-ui/src/controllers/editor/end-edit.controller.ts b/packages/sheets-ui/src/controllers/editor/end-edit.controller.tsindex e73359e0f3..e9b33c9757 100644--- a/packages/sheets-ui/src/controllers/editor/end-edit.controller.ts+++ b/packages/sheets-ui/src/controllers/editor/end-edit.controller.ts@@ -223,6 +223,7 @@ export class EndEditController extends Disposable {const cell = this._editorBridgeService.interceptor.fetchThroughInterceptors(this._editorBridgeService.interceptor.getInterceptPoints().AFTER_CELL_EDIT)(cellData, context);+this._commandService.executeCommand(SetRangeValuesCommand.id, {worksheetId: sheetId,workbookId: unitId,diff --git a/packages/sheets/src/commands/mutations/set-range-values.mutation.ts b/packages/sheets/src/commands/mutations/set-range-values.mutation.tsindex 5dbfe67b47..82945a0d4a 100644--- a/packages/sheets/src/commands/mutations/set-range-values.mutation.ts+++ b/packages/sheets/src/commands/mutations/set-range-values.mutation.ts@@ -149,6 +149,7 @@ export const SetRangeValuesMutation: IMutation<ISetRangeValuesMutationParams, bocellMatrix?.setValue(row, col, {});} else {const oldVal = cellMatrix.getValue(row, col) || {};+const type =newVal.t === CellValueType.FORCE_STRING? newVal.t@@ -201,8 +202,8 @@ export const SetRangeValuesMutation: IMutation<ISetRangeValuesMutationParams, booldVal.s = styles.setValue(merge);}- // When the rich text sets the cell style, you need to modify the style of all rich text- if (oldVal.p) {+ // Only need to copy newValue.s to oldValue.p when you modify the cell style, not when you modify the cell value.+ if (!newVal.p && oldVal.p) {mergeRichTextStyle(oldVal.p, newVal.s ? (newVal.s as Nullable<IStyleData>) : null);}}