Skip to content

Commit

Permalink
[se] Fix rtl
Browse files Browse the repository at this point in the history
Changes for switch rtl/ltr mode + scroll fix
  • Loading branch information
GoshaZotov committed Oct 7, 2024
1 parent 83e406b commit db37d38
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
14 changes: 14 additions & 0 deletions cell/view/WorkbookView.js
Original file line number Diff line number Diff line change
Expand Up @@ -2444,6 +2444,7 @@
});

}
this.checkScrollRtl(ws.getRightToLeft());
this._onScrollReinitialize(AscCommonExcel.c_oAscScrollType.ScrollVertical | AscCommonExcel.c_oAscScrollType.ScrollHorizontal);
// Zoom теперь на каждом листе одинаковый, не отправляем смену

Expand Down Expand Up @@ -5887,6 +5888,19 @@
return this.smoothScroll;
};

WorkbookView.prototype.checkScrollRtl = function(val) {
let controller = this.controller;
let hsbApi = controller && controller.hsbApi;
let ctx = hsbApi && hsbApi.context;
if (ctx) {
if (val) {
ctx.setTransform(-1,0,0,1,hsbApi.canvasW,0);
} else {
ctx.setTransform(1,0,0,1,0,0);
}
}
};

//временно добавляю сюда. в идеале - использовать общий класс из документов(или сделать базовый, от него наследоваться) - CDocumentSearch
function CDocumentSearchExcel(wb) {
this.wb = wb;
Expand Down
18 changes: 3 additions & 15 deletions cell/view/WorksheetView.js
Original file line number Diff line number Diff line change
Expand Up @@ -10679,16 +10679,7 @@
ctxW - (this._getColLeft(oldEnd) - leftOldStart + this.cellsLeft + diffWidth) : 0;


let drawingTransform = null;
if (this.getRightToLeft()) {
let drawingTransform = this.drawingGraphicCtx.Transform ? this.drawingGraphicCtx.Transform.clone() : new AscCommon.CMatrix();
let transformMatrix = new AscCommon.CMatrix();
transformMatrix.sx = -1;
transformMatrix.tx = ctx.getWidth();
let newTransformMatrix = drawingTransform.Multiply(transformMatrix);
this.drawingGraphicCtx.setTransform(newTransformMatrix.sx, newTransformMatrix.shy, newTransformMatrix.shx, newTransformMatrix.sy, newTransformMatrix.tx, newTransformMatrix.ty);
this.drawingGraphicCtx.updateTransforms();
}
this._startRtlRendering();


// Перемещаем область
Expand Down Expand Up @@ -10766,11 +10757,6 @@
ctx.RemoveClipRect();
}

if (drawingTransform) {
this.drawingGraphicCtx.setTransform(drawingTransform.sx, drawingTransform.shy, drawingTransform.shx, drawingTransform.sy, drawingTransform.tx, drawingTransform.ty);
this.drawingGraphicCtx.updateTransforms();
}

// Отрисовывать нужно всегда, вдруг бордеры
this._drawFrozenPaneLines();
this._fixSelectionOfMergedCells();
Expand Down Expand Up @@ -10803,6 +10789,7 @@
this.cellCommentator.drawCommentCells();
window['AscCommon'].g_specialPasteHelper.SpecialPasteButton_Update_Position();
this.handlers.trigger("toggleAutoCorrectOptions", true);
this._endRtlRendering();
//this.model.updateTopLeftCell(this.visibleRange);
return this;
};
Expand Down Expand Up @@ -16269,6 +16256,7 @@
fullUpdate = true;
} else if (AscCH.historyitem_Worksheet_SetRightToLeft === type) {
t.model.setRightToLeft(val);
t.workbook.checkScrollRtl(val);
fullUpdate = true;
} else {
t.model.setDisplayGridlines(val);
Expand Down
3 changes: 0 additions & 3 deletions common/scroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -1036,9 +1036,6 @@ CArrowDrawer.prototype.InitSize = function ( sizeW, sizeH )
let api = window.Asc.editor;
let wb = api && api.wb;
let ws = wb && wb.getWorksheet();
if (ws && ws.getRightToLeft()) {
that.context.setTransform(-1,0,0,1,that.canvasW,0)
}

if (that.settings.isVerticalScroll) {
var _y = that.settings.showArrows ? that.arrowPosition : 0,
Expand Down

0 comments on commit db37d38

Please sign in to comment.