Skip to content

Commit

Permalink
Merge pull request 'fix/bug-72952-2' (#627) from fix/bug-72952-2 into…
Browse files Browse the repository at this point in the history
  • Loading branch information
K0R0L committed Feb 3, 2025
2 parents fdcb678 + 575871f commit 537f430
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 69 deletions.
144 changes: 80 additions & 64 deletions cell/model/UndoRedo.js
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,11 @@ function (window, undefined) {
};
UndoRedoItemSerializable.prototype.CommuteRelated = function (oActionToUndo, oActionOther) {
if (oActionToUndo.oClass && oActionToUndo.oClass.CommuteRelated) {
//ничего не делаем если есть изменения на удаленном листе
if (!AscCommonExcel.g_oUndoRedoWorkbook.CommuteRelatedRemoveSheet(oActionToUndo.nSheetId, oActionOther)) {
return false;
}

//todo don't use global api
let api = window["Asc"]["editor"];
if (api && api.wbModel && api.collaborativeEditing.oRedoObjectParam && api.collaborativeEditing.oRedoObjectParam.snapshot) {
Expand Down Expand Up @@ -2914,6 +2919,9 @@ function (window, undefined) {
}
return new UndoRedoItemSerializable(ToClass, Type, nSheetId, oRange, Data, LocalChange);
};
UndoRedoWorkbook.prototype.CommuteRelatedRemoveSheet = function (sheetId, oActionOther) {
return !(AscCH.historyitem_Workbook_SheetRemove === oActionOther.nActionType && oActionOther.oData && sheetId === oActionOther.oData.sheetId);
}
UndoRedoWorkbook.prototype.CommuteRelated = function (oActionToUndo, oActionOther) {
return true;
}
Expand Down Expand Up @@ -3523,7 +3531,9 @@ function (window, undefined) {
//нужно для того, чтобы грамотно выставлялись цвета в ф/т при ручном скрытии строк, затрагивающих ф/т(undo/redo)
//TODO для случая скрытия строк фильтром(undo), может два раза вызываться функция setColorStyleTable - пересмотреть
workSheetView = wb.oApi.wb.getWorksheetById(nSheetId);
workSheetView.model.autoFilters.reDrawFilter(null, index);
if (workSheetView) {
workSheetView.model.autoFilters.reDrawFilter(null, index);
}
} else if (AscCH.historyitem_Worksheet_RowHide === Type) {
from = Data.from;
to = Data.to;
Expand All @@ -3547,7 +3557,9 @@ function (window, undefined) {
ws.setRowHidden(nRow, from, to);

workSheetView = wb.oApi.wb.getWorksheetById(nSheetId);
workSheetView.model.autoFilters.reDrawFilter(new Asc.Range(0, from, ws.nColsCount - 1, to));
if (workSheetView) {
workSheetView.model.autoFilters.reDrawFilter(new Asc.Range(0, from, ws.nColsCount - 1, to));
}
} else if (AscCH.historyitem_Worksheet_AddRows === Type || AscCH.historyitem_Worksheet_RemoveRows === Type) {
from = Data.from;
to = Data.to;
Expand Down Expand Up @@ -3582,16 +3594,17 @@ function (window, undefined) {

// ToDo Так делать неправильно, нужно поправить (перенести логику в model, а отрисовку отделить)
worksheetView = wb.oApi.wb.getWorksheetById(nSheetId);
worksheetView.cellCommentator.updateCommentsDependencies(bInsert, operType, range);
worksheetView.shiftCellWatches(bInsert, operType, range);
if (workSheetView) {
worksheetView.cellCommentator.updateCommentsDependencies(bInsert, operType, range);
worksheetView.shiftCellWatches(bInsert, operType, range);

if (wb.bCollaborativeChanges) {
changeFreezePane = worksheetView._getFreezePaneOffset(operType, range, bInsert);
if (changeFreezePane) {
worksheetView._updateFreezePane(changeFreezePane.col, changeFreezePane.row, true);
if (wb.bCollaborativeChanges) {
changeFreezePane = worksheetView._getFreezePaneOffset(operType, range, bInsert);
if (changeFreezePane) {
worksheetView._updateFreezePane(changeFreezePane.col, changeFreezePane.row, true);
}
}
}

//ws.shiftDataValidation(bInsert, operType, range);
} else if (AscCH.historyitem_Worksheet_AddCols === Type || AscCH.historyitem_Worksheet_RemoveCols === Type) {
from = Data.from;
Expand Down Expand Up @@ -3628,16 +3641,17 @@ function (window, undefined) {

// ToDo Так делать неправильно, нужно поправить (перенести логику в model, а отрисовку отделить)
worksheetView = wb.oApi.wb.getWorksheetById(nSheetId);
worksheetView.cellCommentator.updateCommentsDependencies(bInsert, operType, range);
worksheetView.shiftCellWatches(bInsert, operType, range);
if (workSheetView) {
worksheetView.cellCommentator.updateCommentsDependencies(bInsert, operType, range);
worksheetView.shiftCellWatches(bInsert, operType, range);

if (wb.bCollaborativeChanges) {
changeFreezePane = worksheetView._getFreezePaneOffset(operType, range, bInsert);
if (changeFreezePane) {
worksheetView._updateFreezePane(changeFreezePane.col, changeFreezePane.row, true);
if (wb.bCollaborativeChanges) {
changeFreezePane = worksheetView._getFreezePaneOffset(operType, range, bInsert);
if (changeFreezePane) {
worksheetView._updateFreezePane(changeFreezePane.col, changeFreezePane.row, true);
}
}
}

//ws.shiftDataValidation(bInsert, operType, range)
} else if (AscCH.historyitem_Worksheet_ShiftCellsLeft === Type ||
AscCH.historyitem_Worksheet_ShiftCellsRight === Type) {
Expand Down Expand Up @@ -3674,8 +3688,10 @@ function (window, undefined) {

// ToDo Так делать неправильно, нужно поправить (перенести логику в model, а отрисовку отделить)
worksheetView = wb.oApi.wb.getWorksheetById(nSheetId);
worksheetView.cellCommentator.updateCommentsDependencies(bInsert, operType, range.bbox);
worksheetView.shiftCellWatches(bInsert, operType, range.bbox);
if (workSheetView) {
worksheetView.cellCommentator.updateCommentsDependencies(bInsert, operType, range.bbox);
worksheetView.shiftCellWatches(bInsert, operType, range.bbox);
}
} else if (AscCH.historyitem_Worksheet_ShiftCellsTop === Type ||
AscCH.historyitem_Worksheet_ShiftCellsBottom === Type) {
r1 = Data.r1;
Expand Down Expand Up @@ -3711,8 +3727,10 @@ function (window, undefined) {

// ToDo Так делать неправильно, нужно поправить (перенести логику в model, а отрисовку отделить)
worksheetView = wb.oApi.wb.getWorksheetById(nSheetId);
worksheetView.cellCommentator.updateCommentsDependencies(bInsert, operType, range.bbox);
worksheetView.shiftCellWatches(bInsert, operType, range.bbox);
if (workSheetView) {
worksheetView.cellCommentator.updateCommentsDependencies(bInsert, operType, range.bbox);
worksheetView.shiftCellWatches(bInsert, operType, range.bbox);
}
} else if (AscCH.historyitem_Worksheet_Sort == Type) {
var bbox = Data.bbox;
var places = Data.places;
Expand All @@ -3737,53 +3755,59 @@ function (window, undefined) {
range._sortByArray(bbox, places, null, sortByRow);

worksheetView = wb.oApi.wb.getWorksheetById(nSheetId);
worksheetView.model.autoFilters.resetTableStyles(bbox);
if (workSheetView) {
worksheetView.model.autoFilters.resetTableStyles(bbox);
}
} else if (AscCH.historyitem_Worksheet_MoveRange == Type) {
//todo worksheetView.autoFilters._moveAutoFilters(worksheetView ,null, null, g_oUndoRedoAutoFiltersMoveData);
from = new Asc.Range(Data.from.c1, Data.from.r1, Data.from.c2, Data.from.r2);
to = new Asc.Range(Data.to.c1, Data.to.r1, Data.to.c2, Data.to.r2);
var copyRange = Data.copyRange;

var wsTo = wb.getWorksheetById(Data.sheetIdTo);
if (bUndo) {
temp = from;
from = to;
to = temp;
if (wsTo) {
temp = wsTo;
wsTo = ws;
ws = temp;
if (wsTo) {
if (bUndo) {
temp = from;
from = to;
to = temp;
if (wsTo) {
temp = wsTo;
wsTo = ws;
ws = temp;
}
}
}
if (wb.bCollaborativeChanges) {
var coBBoxTo = new Asc.Range(0, 0, 0, 0), coBBoxFrom = new Asc.Range(0, 0, 0, 0);
if (wb.bCollaborativeChanges) {
var coBBoxTo = new Asc.Range(0, 0, 0, 0), coBBoxFrom = new Asc.Range(0, 0, 0, 0);

coBBoxTo.r1 = collaborativeEditing.getLockOtherRow2(nSheetId, to.r1);
coBBoxTo.c1 = collaborativeEditing.getLockOtherColumn2(nSheetId, to.c1);
coBBoxTo.r2 = collaborativeEditing.getLockOtherRow2(nSheetId, to.r2);
coBBoxTo.c2 = collaborativeEditing.getLockOtherColumn2(nSheetId, to.c2);
coBBoxTo.r1 = collaborativeEditing.getLockOtherRow2(nSheetId, to.r1);
coBBoxTo.c1 = collaborativeEditing.getLockOtherColumn2(nSheetId, to.c1);
coBBoxTo.r2 = collaborativeEditing.getLockOtherRow2(nSheetId, to.r2);
coBBoxTo.c2 = collaborativeEditing.getLockOtherColumn2(nSheetId, to.c2);

coBBoxFrom.r1 = collaborativeEditing.getLockOtherRow2(nSheetId, from.r1);
coBBoxFrom.c1 = collaborativeEditing.getLockOtherColumn2(nSheetId, from.c1);
coBBoxFrom.r2 = collaborativeEditing.getLockOtherRow2(nSheetId, from.r2);
coBBoxFrom.c2 = collaborativeEditing.getLockOtherColumn2(nSheetId, from.c2);
coBBoxFrom.r1 = collaborativeEditing.getLockOtherRow2(nSheetId, from.r1);
coBBoxFrom.c1 = collaborativeEditing.getLockOtherColumn2(nSheetId, from.c1);
coBBoxFrom.r2 = collaborativeEditing.getLockOtherRow2(nSheetId, from.r2);
coBBoxFrom.c2 = collaborativeEditing.getLockOtherColumn2(nSheetId, from.c2);

ws._moveRange(coBBoxFrom, coBBoxTo, copyRange, wsTo);
} else {
ws._moveRange(from, to, copyRange, wsTo);
ws._moveRange(coBBoxFrom, coBBoxTo, copyRange, wsTo);
} else {
ws._moveRange(from, to, copyRange, wsTo);
}
}
worksheetView = wb.oApi.wb.getWorksheetById(nSheetId);
if (bUndo)//если на Undo перемещается диапазон из форматированной таблицы - стиль форматированной таблицы не должен цепляться
{
worksheetView.model.autoFilters._cleanStyleTable(to);
}
if (workSheetView) {
if (bUndo)//если на Undo перемещается диапазон из форматированной таблицы - стиль форматированной таблицы не должен цепляться
{
worksheetView.model.autoFilters._cleanStyleTable(to);
}

worksheetView.model.autoFilters.reDrawFilter(to);
worksheetView.model.autoFilters.reDrawFilter(from);
worksheetView.model.autoFilters.reDrawFilter(to);
worksheetView.model.autoFilters.reDrawFilter(from);

// clear traces
if (worksheetView.traceDependentsManager) {
worksheetView.traceDependentsManager.clearAll();
// clear traces
if (worksheetView.traceDependentsManager) {
worksheetView.traceDependentsManager.clearAll();
}
}
} else if (AscCH.historyitem_Worksheet_Rename == Type) {
if (bUndo) {
Expand Down Expand Up @@ -3893,7 +3917,6 @@ function (window, undefined) {
ws.hyperlinkManager.add(to, data);
}
} else if (AscCH.historyitem_Worksheet_ChangeFrozenCell === Type) {
worksheetView = wb.oApi.wb.getWorksheetById(nSheetId);
var updateData = bUndo ? Data.from : Data.to;

var _r1 = updateData.r1 > 0 ? collaborativeEditing.getLockOtherRow2(nSheetId, updateData.r1 - 1) : null;
Expand All @@ -3909,8 +3932,10 @@ function (window, undefined) {
} else {
_c1 = updateData.c1;
}

worksheetView._updateFreezePane(_c1, _r1, /*lockDraw*/true);
worksheetView = wb.oApi.wb.getWorksheetById(nSheetId);
if (workSheetView) {
worksheetView._updateFreezePane(_c1, _r1, /*lockDraw*/true);
}
} else if (AscCH.historyitem_Worksheet_SetTabColor === Type) {
ws.setTabColor(bUndo ? Data.from : Data.to);
} else if (AscCH.historyitem_Worksheet_SetSummaryRight === Type) {
Expand Down Expand Up @@ -5175,15 +5200,6 @@ function (window, undefined) {
case AscCH.historyitem_PivotTable_SetDataCaption:
pivotTable.asc_setDataCaption(value);
break;
case AscCH.historyitem_PivotTable_SetRowHeaderCaption:
pivotTable.asc_setRowHeaderCaption(value);
break;
case AscCH.historyitem_PivotTable_SetColHeaderCaption:
pivotTable.asc_setColHeaderCaption(value);
break;
case AscCH.historyitem_PivotTable_SetDataCaption:
pivotTable.asc_setDataCaption(value);
break;
case AscCH.historyitem_PivotTable_SetRowGrandTotals:
pivotTable.asc_setRowGrandTotals(value);
break;
Expand Down
5 changes: 2 additions & 3 deletions common/Native/native.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,8 @@ function NativeCreateApi(options)
Api.setOpenedAt(options["documentLayout"]["openedAt"]);
if (options && options["documentLayout"] && undefined !== options["documentLayout"]["headingsColor"])
{
let rgba = window["AscCommon"]["RgbaTextToRGBA"](options["documentLayout"]["headingsColor"]);
if (window["AscWord"] && window["AscWord"]["setDefaultHeadingColor"])
window["AscWord"]["setDefaultHeadingColor"](rgba.R, rgba.G, rgba.B);
if (window["AscWord"] && window["AscWord"]["setDefaultHeadingColorStr"])
window["AscWord"]["setDefaultHeadingColorStr"](options["documentLayout"]["headingsColor"]);
}
break;
}
Expand Down
6 changes: 6 additions & 0 deletions word/Editor/Styles/default-styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -1241,6 +1241,11 @@
}
}
}
function setDefaultHeadingColorStr(rgbStr)
{
let rgba = AscCommon.RgbaTextToRGBA(rgbStr);
setDefaultHeadingColor(rgba.R, rgba.G, rgba.B);
}

//--------------------------------------------------------export----------------------------------------------------
AscWord.DEFAULT_STYLE_LIST = DEFAULT_STYLE_LIST;
Expand All @@ -1249,4 +1254,5 @@
AscWord.getDefaultStyleObject = getDefaultStyleObject;
AscWord.getDefaultStyleName = getDefaultStyleName;
AscWord["setDefaultHeadingColor"] = AscWord.setDefaultHeadingColor = setDefaultHeadingColor;
AscWord["setDefaultHeadingColorStr"] = AscWord.setDefaultHeadingColorStr = setDefaultHeadingColorStr;
})(window);
3 changes: 1 addition & 2 deletions word/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -9837,8 +9837,7 @@ background-repeat: no-repeat;\

if (this.headingsColor)
{
let rgba = AscCommon.RgbaTextToRGBA(this.headingsColor);
AscWord.setDefaultHeadingColor(rgba.R, rgba.G, rgba.B)
AscWord.setDefaultHeadingColorStr(this.headingsColor);
}

History = AscCommon.History;
Expand Down

0 comments on commit 537f430

Please sign in to comment.