Commit 3092544d authored by konovalovsergey's avatar konovalovsergey

remove historyitem_Workbook_SheetPositions; assemble(true) on formula ...

remove historyitem_Workbook_SheetPositions; assemble(true) on formula  modification; addition to 353121c3
parent d8aac83c
......@@ -1558,10 +1558,10 @@ cName.prototype.Calculate = function () {
return this.wb.getDefinesNames( this.value, this.ws ? this.ws.getId() : null );
};
cName.prototype.changeDefName = function (from, to) {
var LocalSheetId = this.ws ? this.ws.getIndex() : null;
if (AscCommonExcel.getDefNameIndex(this.value) == AscCommonExcel.getDefNameIndex(from.Name) &&
(null == from.LocalSheetId || LocalSheetId == from.LocalSheetId )) {
this.value = to.Name;
var sheetId = this.ws ? this.ws.getId() : null;
if (AscCommonExcel.getDefNameIndex(this.value) == AscCommonExcel.getDefNameIndex(from.name) &&
(null == from.sheetId || sheetId == from.sheetId )) {
this.value = to.name;
}
};
......@@ -3755,25 +3755,23 @@ function parserFormula( formula, parent, _ws ) {
this.parent.onFormulaEvent(AscCommon.c_oNotifyParentType.Change, eventData);
}
} else {
var assembleType = AscCommon.c_oNotifyParentAssemble.Normal;
var needAssemble = true;
this.removeDependencies();
if (AscCommon.c_oNotifyType.Shift === data.type || AscCommon.c_oNotifyType.Move === data.type ||
AscCommon.c_oNotifyType.Delete === data.type) {
this.shiftCells(data.type, data.sheetId, data.bbox, data.offset);
assembleType = AscCommon.c_oNotifyParentAssemble.Flag;
eventData.isRebuild = false;
} else if (AscCommon.c_oNotifyType.ChangeDefName === data.type) {
if (data.from.Name != data.to.Name) {
if (data.from.name != data.to.name) {
this.changeDefName(data.from, data.to);
} else if (data.from.isTable) {
assembleType = AscCommon.c_oNotifyParentAssemble.Current;
needAssemble = false;
eventData.isRebuild = true;
}
} else if (AscCommon.c_oNotifyType.Rebuild === data.type) {
assembleType = AscCommon.c_oNotifyParentAssemble.Normal;
eventData.isRebuild = true;
} else if (AscCommon.c_oNotifyType.ChangeSheet === data.type) {
assembleType = AscCommon.c_oNotifyParentAssemble.Current;
needAssemble = false;
if (this.is3D) {
var changeData = data.data;
if (changeData.insert) {
......@@ -3787,27 +3785,21 @@ function parserFormula( formula, parent, _ws ) {
moveSheetRes = this.removeSheet(changeData.remove);
}
if (2 === moveSheetRes) {
assembleType = AscCommon.c_oNotifyParentAssemble.Normal;
needAssemble = true;
} else if (1 !== moveSheetRes) {
eventData.isRebuild = false;
}
} else if (changeData.rename) {
this.renameSheet(changeData.rename.from, changeData.rename.to);
assembleType = AscCommon.c_oNotifyParentAssemble.Normal;
needAssemble = true;
eventData.isRebuild = false;
}
}
}
switch (assembleType) {
case AscCommon.c_oNotifyParentAssemble.Normal:
eventData.assemble = this.assemble();
break;
case AscCommon.c_oNotifyParentAssemble.Flag:
eventData.assemble = this.assemble(true);
break;
case AscCommon.c_oNotifyParentAssemble.Current:
eventData.assemble = this.Formula;
break;
if (needAssemble) {
eventData.assemble = this.assemble(true);
} else {
eventData.assemble = this.Formula;
}
if (this.parent && this.parent.onFormulaEvent) {
this.parent.onFormulaEvent(AscCommon.c_oNotifyParentType.ChangeFormula, eventData);
......@@ -4737,26 +4729,26 @@ parserFormula.prototype.calculate = function(opt_defName, opt_range) {
return elem;
};
parserFormula.prototype.changeDefName = function(from, to) {
var i, elem, LocalSheetId;
var i, elem, sheetId;
for (i = 0; i < this.outStack.length; i++) {
elem = this.outStack[i];
if (elem.type == cElementType.name || elem.type == cElementType.name3D) {
elem.changeDefName(from, to);
} else if (elem.type == cElementType.table) {
LocalSheetId = elem.ws ? elem.ws.getIndex() : null;
if (elem.tableName == from.Name && (null == from.LocalSheetId || LocalSheetId == from.LocalSheetId )) {
elem.tableName = to.Name;
sheetId = elem.ws ? elem.ws.getId() : null;
if (elem.tableName == from.name && (null == from.sheetId || sheetId == from.sheetId )) {
elem.tableName = to.name;
}
}
}
};
parserFormula.prototype.removeTableName = function(defName) {
var i, elem, LocalSheetId;
var i, elem, sheetId;
for (i = 0; i < this.outStack.length; i++) {
elem = this.outStack[i];
if (elem.type == cElementType.table) {
LocalSheetId = elem.ws ? elem.ws.getIndex() : null;
if (elem.tableName == defName.Name && (null == defName.LocalSheetId || LocalSheetId == defName.LocalSheetId )) {
sheetId = elem.ws ? elem.ws.getId() : null;
if (elem.tableName == defName.name && (null == defName.sheetId || sheetId == defName.sheetId )) {
var rangeCell = null;
if (this.parent && this.parent.onFormulaEvent) {
rangeCell = this.parent.onFormulaEvent(AscCommon.c_oNotifyParentType.GetRangeCell);
......@@ -4938,6 +4930,11 @@ parserFormula.prototype.calculate = function(opt_defName, opt_range) {
this.outStack[i] = new cError(cErrorType.bad_reference);
nRes = 2;
}
} else if (cElementType.name3D === elem.type) {
if (elem.ws.getId() == sheetId) {
this.outStack[i] = new cError(cErrorType.bad_reference);
nRes = 2;
}
}
}
}
......
......@@ -45,7 +45,6 @@ function (window, undefined) {
window['AscCH'].historyitem_Workbook_SheetAdd = 1;
window['AscCH'].historyitem_Workbook_SheetRemove = 2;
window['AscCH'].historyitem_Workbook_SheetMove = 3;
window['AscCH'].historyitem_Workbook_SheetPositions = 4;
window['AscCH'].historyitem_Workbook_ChangeColorScheme = 5;
window['AscCH'].historyitem_Workbook_AddFont = 6;
window['AscCH'].historyitem_Workbook_DefinedNamesChange = 7;
......@@ -478,7 +477,7 @@ CHistory.prototype._addRedoObjectParam = function (oRedoObjectParam, Point) {
}
else if (AscCommonExcel.g_oUndoRedoWorksheet === Point.Class && (AscCH.historyitem_Worksheet_RowProp == Point.Type || AscCH.historyitem_Worksheet_ColProp == Point.Type || AscCH.historyitem_Worksheet_RowHide == Point.Type))
oRedoObjectParam.oChangeWorksheetUpdate[Point.SheetId] = Point.SheetId;
else if (AscCommonExcel.g_oUndoRedoWorkbook === Point.Class && (AscCH.historyitem_Workbook_SheetAdd === Point.Type || AscCH.historyitem_Workbook_SheetRemove === Point.Type || AscCH.historyitem_Workbook_SheetMove === Point.Type || AscCH.historyitem_Workbook_SheetPositions === Point.Type)) {
else if (AscCommonExcel.g_oUndoRedoWorkbook === Point.Class && (AscCH.historyitem_Workbook_SheetAdd === Point.Type || AscCH.historyitem_Workbook_SheetRemove === Point.Type || AscCH.historyitem_Workbook_SheetMove === Point.Type)) {
oRedoObjectParam.bUpdateWorksheetByModel = true;
oRedoObjectParam.bOnSheetsChanged = true;
}
......
......@@ -393,7 +393,6 @@ var UndoRedoDataTypes = new function() {
this.ChartSeriesData = 24;
this.SheetAdd = 25;
this.SheetRemove = 26;
this.SheetPositions = 27;
this.ClrScheme = 28;
this.AutoFilter = 29;
this.AutoFiltersOptions = 30;
......@@ -474,7 +473,6 @@ var UndoRedoDataTypes = new function() {
case this.ChartSeriesData: return new AscFormat.asc_CChartSeria();break;
case this.SheetAdd: return new UndoRedoData_SheetAdd();break;
case this.SheetRemove: return new UndoRedoData_SheetRemove();break;
case this.SheetPositions: return new UndoRedoData_SheetPositions();break;
case this.ClrScheme: return new UndoRedoData_ClrScheme();break;
case this.AutoFilter: return new UndoRedoData_AutoFilter(); break;
case this.AutoFiltersOptions: return new Asc.AutoFiltersOptions(); break;
......@@ -1516,7 +1514,8 @@ var g_oUndoRedoData_SheetAddProperties = {
name: 0,
sheetidfrom: 1,
sheetid: 2,
tableNames: 3
tableNames: 3,
insertBefore: 4
};
function UndoRedoData_SheetAdd(insertBefore, name, sheetidfrom, sheetid, tableNames){
this.Properties = g_oUndoRedoData_SheetAddProperties;
......@@ -1546,6 +1545,7 @@ UndoRedoData_SheetAdd.prototype = {
case this.Properties.sheetidfrom: return this.sheetidfrom;break;
case this.Properties.sheetid: return this.sheetid;break;
case this.Properties.tableNames: return this.tableNames;break;
case this.Properties.insertBefore: return this.insertBefore;break;
}
return null;
},
......@@ -1557,6 +1557,7 @@ UndoRedoData_SheetAdd.prototype = {
case this.Properties.sheetidfrom: this.sheetidfrom = value;break;
case this.Properties.sheetid: this.sheetid = value;break;
case this.Properties.tableNames: this.tableNames = value;break;
case this.Properties.insertBefore: this.insertBefore = value;break;
}
}
};
......@@ -1597,38 +1598,6 @@ UndoRedoData_SheetRemove.prototype = {
}
}
};
var g_oUndoRedoData_SheetPositionsProperties = {
positions: 0
};
function UndoRedoData_SheetPositions(positions){
this.Properties = g_oUndoRedoData_SheetPositionsProperties;
this.positions = positions;
}
UndoRedoData_SheetPositions.prototype = {
getType : function()
{
return UndoRedoDataTypes.SheetPositions;
},
getProperties : function()
{
return this.Properties;
},
getProperty : function(nType)
{
switch(nType)
{
case this.Properties.positions: return this.positions;break;
}
return null;
},
setProperty : function(nType, value)
{
switch(nType)
{
case this.Properties.positions: this.positions = value;break;
}
}
};
var g_oUndoRedoData_DefinedNamesProperties = {
name: 0,
......@@ -2885,72 +2854,6 @@ UndoRedoWorkbook.prototype = {
}
wb.handlers.trigger("updateWorksheetByModel");
}
else if(AscCH.historyitem_Workbook_SheetPositions == Type)
{
if(Data.positions){
var wsActive = wb.getActiveWs();
//делаем вспомогательным map из sheetid
var oTempSheetMap = {};
for(var i = 0, length = Data.positions.length; i < length; ++i)
oTempSheetMap[Data.positions[i]] = 1;
//находим sheet уникальные для данного пользователя и запоминаем перед каким sheetid они идут
var oUniqueSheetId = {};
var nLastId = null;
for(var i = 0, length = wb.aWorksheets.length; i < length; ++i)
{
var ws = wb.aWorksheets[i];
var id = ws.getId();
if(null == oTempSheetMap[id])
{
if(i < length - 1)
oUniqueSheetId[wb.aWorksheets[i + 1].getId()] = id;
else
nLastId = id;
}
}
//расставляем в соответствии с изменениями
wb.aWorksheets = [];
for(var i = 0, length = Data.positions.length; i < length; ++i)
{
var sheetId = Data.positions[i];
var ws = wb.aWorksheetsById[sheetId];
if(null != ws)
wb.aWorksheets.push(ws);
}
if(null != nLastId)
{
var ws = wb.aWorksheetsById[nLastId];
if(null != ws)
wb.aWorksheets.push(ws);
}
//не стал оптимизировать по скорости, потому что много добавленых sheet быть не может
while(true)
{
for(var i = 0, length = wb.aWorksheets.length; i < length; ++i)
{
var ws = wb.aWorksheets[i];
var insertId = oUniqueSheetId[ws.getId()];
if(null != insertId)
{
var insertWs = wb.aWorksheetsById[insertId];
if(null != insertWs)
wb.aWorksheets.splice(i, 0, insertWs);
delete oUniqueSheetId[ws.getId()];
}
}
var bEmpty = true;
for(var i in oUniqueSheetId)
{
bEmpty = false;
break;
}
if(bEmpty)
break;
}
wb._updateWorksheetIndexes(wsActive);
wb.handlers.trigger("updateWorksheetByModel");
}
}
else if(AscCH.historyitem_Workbook_ChangeColorScheme == Type)
{
bNeedTrigger = false;
......@@ -3893,7 +3796,6 @@ UndoRedoAutoFilters.prototype = {
window['AscCommonExcel'].UndoRedoData_SortData = UndoRedoData_SortData;
window['AscCommonExcel'].UndoRedoData_SheetAdd = UndoRedoData_SheetAdd;
window['AscCommonExcel'].UndoRedoData_SheetRemove = UndoRedoData_SheetRemove;
window['AscCommonExcel'].UndoRedoData_SheetPositions = UndoRedoData_SheetPositions;
window['AscCommonExcel'].UndoRedoData_DefinedNames = UndoRedoData_DefinedNames;
window['AscCommonExcel'].UndoRedoData_ClrScheme = UndoRedoData_ClrScheme;
window['AscCommonExcel'].UndoRedoData_AutoFilter = UndoRedoData_AutoFilter;
......
......@@ -58,7 +58,6 @@ var UndoRedoData_FromTo = AscCommonExcel.UndoRedoData_FromTo;
var UndoRedoData_IndexSimpleProp = AscCommonExcel.UndoRedoData_IndexSimpleProp;
var UndoRedoData_BBox = AscCommonExcel.UndoRedoData_BBox;
var UndoRedoData_SheetAdd = AscCommonExcel.UndoRedoData_SheetAdd;
var UndoRedoData_SheetPositions = AscCommonExcel.UndoRedoData_SheetPositions;
var UndoRedoData_DefinedNames = AscCommonExcel.UndoRedoData_DefinedNames;
var g_oDefaultFormat = AscCommonExcel.g_oDefaultFormat;
var Border = AscCommonExcel.Border;
......@@ -1582,7 +1581,7 @@ Workbook.prototype.replaceWorksheet=function(indexFrom, indexTo){
this._insertWorksheetFormula(indexTo);
History.Add(AscCommonExcel.g_oUndoRedoWorkbook, AscCH.historyitem_Workbook_SheetMove, null, null, new UndoRedoData_FromTo(indexFrom, indexTo), true);
History.Add(AscCommonExcel.g_oUndoRedoWorkbook, AscCH.historyitem_Workbook_SheetMove, null, null, new UndoRedoData_FromTo(indexFrom, indexTo));
this.dependencyFormulas.unlockRecal();
}
};
......@@ -1823,34 +1822,13 @@ Workbook.prototype.SerializeHistory = function(){
if(aActions.length > 0)
{
var oMemory = new AscCommon.CMemory();
var bChangeSheetPlace = false;
for(var i = 0, length = aActions.length; i < length; ++i)
{
var aPointChanges = aActions[i];
bChangeSheetPlace = false;
for (j = 0, length2 = aPointChanges.length; j < length2; ++j) {
var item = aPointChanges[j];
if (AscCommonExcel.g_oUndoRedoWorkbook == item.oClass) {
if (AscCH.historyitem_Workbook_SheetAdd == item.nActionType || AscCH.historyitem_Workbook_SheetRemove == item.nActionType || AscCH.historyitem_Workbook_SheetMove == item.nActionType)
bChangeSheetPlace = true;
}
else if (AscCommonExcel.g_oUndoRedoWorksheet === item.oClass && AscCH.historyitem_Worksheet_Hide === item.nActionType) {
bChangeSheetPlace = true;
}
this._SerializeHistoryBase64(oMemory, item, aRes);
}
var oUndoRedoData_SheetPositions;
if (bChangeSheetPlace) {
//создаем еще один элемент в undo/redo - взаимное расположение Sheet, чтобы не запутываться в add, move событиях
//добавляем не после конца aActions, чтобы можно было делать undo/redo и просто удалять хвост изменений.
var oSheetPlaceData = [];
for (j = 0, length2 = this.aWorksheets.length; j < length2; ++j)
oSheetPlaceData.push(this.aWorksheets[j].getId());
oUndoRedoData_SheetPositions = new UndoRedoData_SheetPositions(oSheetPlaceData);
}
else
oUndoRedoData_SheetPositions = new UndoRedoData_SheetPositions();
this._SerializeHistoryBase64(oMemory, new UndoRedoItemSerializable(AscCommonExcel.g_oUndoRedoWorkbook, AscCH.historyitem_Workbook_SheetPositions, null, null, oUndoRedoData_SheetPositions), aRes);
}
this.aCollaborativeActions = [];
this.snapshot = this._getSnapshot();
......@@ -2508,7 +2486,7 @@ Woorksheet.prototype.copyFrom=function(wsFrom, sName, tableNames){ var i, elem,
if (wsFrom.sheetPr)
this.sheetPr = wsFrom.sheetPr.clone();
oNewWs.selectionRange = this.selectionRange.clone(oNewWs);
this.selectionRange = wsFrom.selectionRange.clone(this);
return renameParams;
};
......@@ -8149,6 +8127,9 @@ function promoteFromTo(from, wsFrom, to, wsTo) {
};
Range.prototype.promote=function(bCtrl, bVertical, nIndex, oCanPromote){
//todo отдельный метод для promote в таблицах и merge в таблицах
if (!oCanPromote) {
oCanPromote = this.canPromote(bCtrl, bVertical, nIndex);
}
var oBBox = this.bbox;
var nWidth = oBBox.c2 - oBBox.c1 + 1;
var nHeight = oBBox.r2 - oBBox.r1 + 1;
......
......@@ -815,12 +815,6 @@
GetRangeCell: 4
};
var c_oNotifyParentAssemble = {
Normal: 0,
Flag: 1,
Current: 2
};
var c_oDashType = {
dash : 0,
dashDot : 1,
......@@ -1643,7 +1637,6 @@
window["AscCommon"].c_oZoomType = c_oZoomType;
window["AscCommon"].c_oNotifyType = c_oNotifyType;
window["AscCommon"].c_oNotifyParentType = c_oNotifyParentType;
window["AscCommon"].c_oNotifyParentAssemble = c_oNotifyParentAssemble;
window["AscCommon"].c_oAscEncodings = c_oAscEncodings;
window["AscCommon"].c_oAscEncodingsMap = c_oAscEncodingsMap;
window["AscCommon"].c_oAscCodePageUtf8 = c_oAscCodePageUtf8;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment