Skip to content

Commit

Permalink
fix/rtl (#146)
Browse files Browse the repository at this point in the history
[se] Rtl fix
Co-authored-by: GoshaZotov <[email protected]>
Co-committed-by: GoshaZotov <[email protected]>
  • Loading branch information
GoshaZotov committed Oct 7, 2024
1 parent fab7cf6 commit 4799a59
Show file tree
Hide file tree
Showing 11 changed files with 178 additions and 720 deletions.
6 changes: 6 additions & 0 deletions cell/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -4492,6 +4492,10 @@ var editor;
this.wb.getWorksheet().changeSheetViewSettings(AscCH.historyitem_Worksheet_SetShowFormulas, value);
};

spreadsheet_api.prototype.asc_setRightToLeft = function (value) {
this.wb.getWorksheet().changeSheetViewSettings(AscCH.historyitem_Worksheet_SetRightToLeft, value);
};

spreadsheet_api.prototype.asc_getShowFormulas = function () {
let ws = this.wb.getWorksheet();
return ws.model && ws.model.getShowFormulas();
Expand Down Expand Up @@ -9699,6 +9703,8 @@ var editor;
prot["asc_setShowZeros"] = prot.asc_setShowZeros;
prot["asc_setShowFormulas"] = prot.asc_setShowFormulas;
prot["asc_getShowFormulas"] = prot.asc_getShowFormulas;
prot["asc_setRightToLeft"] = prot.asc_setRightToLeft;



// Defined Names
Expand Down
2 changes: 1 addition & 1 deletion cell/model/CellComment.js
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,7 @@ CCellCommentator.prototype.cleanLastSelection = function() {

pos.dReverseLeftPX = this.worksheet.checkRtl(this.worksheet._getColLeft(left) - this.worksheet._getColLeft(fvc) +
headerCellsOffset.left + frozenOffset.offsetX);
let colWidth = (window.rightToleft ? -1 : 1) * this.worksheet.getColumnWidth(left, 0);
let colWidth = (this.worksheet.getRightToLeft() ? -1 : 1) * this.worksheet.getColumnWidth(left, 0);
pos.dLeftPX = pos.dReverseLeftPX + colWidth;
pos.dTopPX = this.worksheet._getRowTop(top) + ((this.worksheet._getRowHeight(top) / 2) | 0) -
this.worksheet._getRowTop(fvr) + headerCellsOffset.top + frozenOffset.offsetY;
Expand Down
1 change: 1 addition & 0 deletions cell/model/History.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ function (window, undefined) {
window['AscCH'].historyitem_Worksheet_SetTabColor = 27;
window['AscCH'].historyitem_Worksheet_RowHide = 28;
// Frozen cell
window['AscCH'].historyitem_Worksheet_SetRightToLeft = 29;
window['AscCH'].historyitem_Worksheet_ChangeFrozenCell = 30;
window['AscCH'].historyitem_Worksheet_SetDisplayGridlines = 31;
window['AscCH'].historyitem_Worksheet_SetDisplayHeadings = 32;
Expand Down
4 changes: 3 additions & 1 deletion cell/model/Serialize.js
Original file line number Diff line number Diff line change
Expand Up @@ -5426,6 +5426,8 @@
this.bs.WriteItem(c_oSer_SheetView.TopLeftCell, function(){oThis.memory.WriteString3(oSheetView.topLeftCell.getName());});
if (null !== oSheetView.view && !oThis.isCopyPaste)
this.bs.WriteItem(c_oSer_SheetView.View, function(){oThis.memory.WriteByte(oSheetView.view);});
if (null !== oSheetView.rightToLeft && !oThis.isCopyPaste)
this.bs.WriteItem(c_oSer_SheetView.RightToLeft, function(){oThis.memory.WriteBool(oSheetView.rightToLeft);});
};
this.WriteSheetViewPane = function (oPane) {
var oThis = this;
Expand Down Expand Up @@ -11478,7 +11480,7 @@
} else if (c_oSer_SheetView.DefaultGridColor === type) {
this.stream.GetBool();
} else if (c_oSer_SheetView.RightToLeft === type) {
this.stream.GetBool();
oSheetView.rightToLeft = this.stream.GetBool();
} else if (c_oSer_SheetView.ShowFormulas === type) {
oSheetView.showFormulas = this.stream.GetBool();
} else if (c_oSer_SheetView.ShowGridLines === type) {
Expand Down
18 changes: 16 additions & 2 deletions cell/model/Workbook.js
Original file line number Diff line number Diff line change
Expand Up @@ -6467,8 +6467,8 @@
Worksheet.prototype.getSheetView = function () {
return this.sheetViews[0];
};
Worksheet.prototype.getSheetViewSettings = function () {
return this.sheetViews[0].clone();
Worksheet.prototype.getSheetViewSettings = function (bNotClone) {
return bNotClone ? this.sheetViews[0] : this.sheetViews[0].clone();
};
Worksheet.prototype.setDisplayGridlines = function (value) {
var view = this.sheetViews[0];
Expand Down Expand Up @@ -6527,6 +6527,20 @@
}
}
};
Worksheet.prototype.setRightToLeft = function (value) {
var view = this.sheetViews[0];
if (value !== view.rightToLeft) {
/*AscCommon.History.Create_NewPoint();
AscCommon.History.Add(AscCommonExcel.g_oUndoRedoWorksheet, AscCH.historyitem_Worksheet_SetShowFormulas,
this.getId(), new Asc.Range(0, 0, gc_nMaxCol0, gc_nMaxRow0), new UndoRedoData_FromTo(view.showFormulas, value));*/
view.rightToLeft = value;

this.workbook.handlers.trigger("changeSheetViewSettings", this.getId(), AscCH.historyitem_Worksheet_SetRightToLeft);
if (!this.workbook.bCollaborativeChanges) {
this.workbook.handlers.trigger("asc_onUpdateFormulasViewSettings");
}
}
};
Worksheet.prototype.getShowFormulas = function () {
var view = this.sheetViews[0];
return view && view.showFormulas;
Expand Down
14 changes: 13 additions & 1 deletion cell/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2386,7 +2386,10 @@
oMatrix.tx = rect._x;
oMatrix.ty = rect._y;
//TODO !!!rtl print
if (window.rightToleft) {
let api = window.Asc.editor;
let wb = api && api.wb;
let ws = wb.getWorksheet();
if (ws && ws.getRightToLeft()) {
oMatrix.sx = -1;
oMatrix.tx = (ctx.getWidth() * vector_koef) - oMatrix.tx;
}
Expand Down Expand Up @@ -3097,6 +3100,7 @@
this.zoomScale = 100;

this.showZeros = null;
this.rightToLeft = null;
this.showFormulas = null;

this.topLeftCell = null;
Expand All @@ -3119,6 +3123,7 @@
}
result.showZeros = this.showZeros;
result.topLeftCell = this.topLeftCell;
result.rightToLeft = this.rightToLeft;
result.showFormulas = this.showFormulas;
return result;
},
Expand All @@ -3145,6 +3150,9 @@
asc_getShowFormulas: function () {
return false !== this.showFormulas;
},
asc_getRightToLeft: function () {
return this.rightToLeft;
},
asc_setShowGridLines: function (val) {
this.showGridLines = val;
},
Expand All @@ -3159,6 +3167,9 @@
},
asc_setShowFormulas: function (val) {
this.showFormulas = val;
},
asc_setRightToLeft: function (val) {
this.rightToLeft = val;
}
};

Expand Down Expand Up @@ -4075,6 +4086,7 @@
prot["asc_setShowRowColHeaders"] = prot.asc_setShowRowColHeaders;
prot["asc_setShowZeros"] = prot.asc_setShowZeros;
prot["asc_setShowFormulas"] = prot.asc_setShowFormulas;
prot["asc_setRightToLeft"] = prot.asc_setRightToLeft;

window["AscCommonExcel"].asc_CPane = asc_CPane;
window["AscCommonExcel"].asc_CSheetPr = asc_CSheetPr;
Expand Down
5 changes: 3 additions & 2 deletions cell/view/EventsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -1339,12 +1339,13 @@
};

if ((dc !== 0 || dr !== 0) && false === t.handlers.trigger("isGlobalLockEditCell")) {
if (window.rightToleft) {
const wb = window["Asc"]["editor"].wb;
let ws = wb.getWorksheet();
if (ws && ws.getRightToLeft()) {
dc = -dc;
}
if (isChangeVisibleAreaMode) {
t.handlers.trigger("changeVisibleArea", !shiftKey, dc, dr, false, function (d) {
const wb = window["Asc"]["editor"].wb;
if (t.targetInfo) {
wb._onUpdateWorksheet(t.targetInfo.coordX, t.targetInfo.coordY, false);
}
Expand Down
Loading

0 comments on commit 4799a59

Please sign in to comment.