Commit 13df0633 authored by Sergey.Konovalov's avatar Sergey.Konovalov Committed by Alexander.Trofimov

Bug 25916 - [CoEdit] Лист не отображается как активный при передаче данных...

Bug 25916 - [CoEdit] Лист не отображается как активный при передаче данных второму пользователю после Hide Sheet.
Bug 25654 - Фокус не возвращается на лист книги, восстановленный с помощью redo.
В историю сохраняется sheet для undo и redo, не меняем sheet в совместном редактировании.

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@57810 954022d7-b5bf-4e40-9824-e11837661b57
parent ef62fee9
...@@ -367,10 +367,16 @@ CHistory.prototype.UndoRedoEnd = function (Point, oRedoObjectParam, bUndo) { ...@@ -367,10 +367,16 @@ CHistory.prototype.UndoRedoEnd = function (Point, oRedoObjectParam, bUndo) {
oState = bUndo ? Point.SelectionState : ((this.Index === this.Points.length - 1) ? oState = bUndo ? Point.SelectionState : ((this.Index === this.Points.length - 1) ?
this.LastState : this.Points[this.Index + 1].SelectionState); this.LastState : this.Points[this.Index + 1].SelectionState);
// ToDo какое-то не очень решение брать 0-й элемент и у него получать индекс! if (this.workbook.bCollaborativeChanges) {
var nSheetId = (null !== oState) ? oState[0].worksheetId : Point.nLastSheetId; //active может поменяться только при remove, hide листов
if (null !== nSheetId) this.workbook.handlers.trigger('showWorksheet', this.workbook.getActive());
this.workbook.handlers.trigger('showWorksheet', nSheetId); }
else {
// ToDo какое-то не очень решение брать 0-й элемент и у него получать индекс!
var nSheetId = (null !== oState) ? oState[0].worksheetId : ((this.workbook.bRedoChanges && null != Point.RedoSheetId) ? Point.RedoSheetId : Point.UndoSheetId);
if (null !== nSheetId)
this.workbook.handlers.trigger('showWorksheet', nSheetId);
}
for (i in Point.UpdateRigions) for (i in Point.UpdateRigions)
this.workbook.handlers.trigger("cleanCellCache", i, Point.UpdateRigions[i], false, true); this.workbook.handlers.trigger("cleanCellCache", i, Point.UpdateRigions[i], false, true);
...@@ -586,18 +592,19 @@ CHistory.prototype.Create_NewPoint = function() ...@@ -586,18 +592,19 @@ CHistory.prototype.Create_NewPoint = function()
var Items = []; var Items = [];
var UpdateRigions = {}; var UpdateRigions = {};
var Time = new Date().getTime(); var Time = new Date().getTime();
var nLastSheetId = null, oSelectionState = this.workbook.handlers.trigger("getSelectionState"); var UndoSheetId = null, oSelectionState = this.workbook.handlers.trigger("getSelectionState");
// ToDo Берем всегда, т.к. в случае с LastState мы можем не попасть на нужный лист и не заселектить нужный диапазон! // ToDo Берем всегда, т.к. в случае с LastState мы можем не попасть на нужный лист и не заселектить нужный диапазон!
var oSelectRange = this.workbook.handlers.trigger("getSelection"); var oSelectRange = this.workbook.handlers.trigger("getSelection");
var wsActive = this.workbook.getWorksheet(this.workbook.getActive()); var wsActive = this.workbook.getWorksheet(this.workbook.getActive());
if (wsActive) if (wsActive)
nLastSheetId = wsActive.getId(); UndoSheetId = wsActive.getId();
this.CurPoint = { this.CurPoint = {
Items : Items, // Массив изменений, начиная с текущего момента Items : Items, // Массив изменений, начиная с текущего момента
UpdateRigions : UpdateRigions, UpdateRigions : UpdateRigions,
nLastSheetId : nLastSheetId, UndoSheetId: UndoSheetId,
RedoSheetId: null,
SelectRange : oSelectRange, SelectRange : oSelectRange,
SelectRangeRedo : oSelectRange, SelectRangeRedo : oSelectRange,
Time : Time, // Текущее время Time : Time, // Текущее время
...@@ -652,7 +659,7 @@ CHistory.prototype.Add = function(Class, Type, sheetid, range, Data, LocalChange ...@@ -652,7 +659,7 @@ CHistory.prototype.Add = function(Class, Type, sheetid, range, Data, LocalChange
Item.LocalChange = LocalChange; Item.LocalChange = LocalChange;
oCurPoint.Items.push( Item ); oCurPoint.Items.push( Item );
if(null != range) if (null != range && null != sheetid)
{ {
var updateRange = oCurPoint.UpdateRigions[sheetid]; var updateRange = oCurPoint.UpdateRigions[sheetid];
if(null != updateRange) if(null != updateRange)
...@@ -662,7 +669,7 @@ CHistory.prototype.Add = function(Class, Type, sheetid, range, Data, LocalChange ...@@ -662,7 +669,7 @@ CHistory.prototype.Add = function(Class, Type, sheetid, range, Data, LocalChange
oCurPoint.UpdateRigions[sheetid] = updateRange; oCurPoint.UpdateRigions[sheetid] = updateRange;
} }
if (null != sheetid) if (null != sheetid)
oCurPoint.nLastSheetId = sheetid; oCurPoint.UndoSheetId = sheetid;
if(1 == oCurPoint.Items.length) if(1 == oCurPoint.Items.length)
this._sendCanUndoRedo(); this._sendCanUndoRedo();
}; };
...@@ -720,6 +727,22 @@ CHistory.prototype.GetSelectionRedo = function() ...@@ -720,6 +727,22 @@ CHistory.prototype.GetSelectionRedo = function()
oRes = this.CurPoint.SelectRangeRedo; oRes = this.CurPoint.SelectRangeRedo;
return oRes; return oRes;
}; };
CHistory.prototype.SetSheetRedo = function (sheetId) {
if (0 !== this.TurnOffHistory)
return;
if (null == this.CurPoint)
return;
this.CurPoint.RedoSheetId = sheetId;
};
CHistory.prototype.SetSheetUndo = function (sheetId) {
if (0 !== this.TurnOffHistory)
return;
if (null == this.CurPoint)
return;
this.CurPoint.UndoSheetId = sheetId;
};
CHistory.prototype.TurnOff = function() CHistory.prototype.TurnOff = function()
{ {
this.TurnOffHistory++; this.TurnOffHistory++;
......
...@@ -2685,7 +2685,7 @@ UndoRedoWorkbook.prototype = { ...@@ -2685,7 +2685,7 @@ UndoRedoWorkbook.prototype = {
} }
else if(historyitem_Workbook_SheetPositions == Type) else if(historyitem_Workbook_SheetPositions == Type)
{ {
var wsActive = this.wb.aWorksheets[this.wb.nActive]; var wsActive = this.wb.getActiveWs();
//делаем вспомогательным map из sheetid //делаем вспомогательным map из sheetid
var oTempSheetMap = {}; var oTempSheetMap = {};
for(var i = 0, length = Data.positions.length; i < length; ++i) for(var i = 0, length = Data.positions.length; i < length; ++i)
...@@ -2744,8 +2744,7 @@ UndoRedoWorkbook.prototype = { ...@@ -2744,8 +2744,7 @@ UndoRedoWorkbook.prototype = {
if(bEmpty) if(bEmpty)
break; break;
} }
this.wb._updateWorksheetIndexes(); this.wb._updateWorksheetIndexes(wsActive);
this.wb.nActive = wsActive.getIndex();
} }
else if(historyitem_Workbook_ChangeColorScheme == Type) else if(historyitem_Workbook_ChangeColorScheme == Type)
{ {
......
...@@ -1284,6 +1284,9 @@ Workbook.prototype.getDefaultSize=function(){ ...@@ -1284,6 +1284,9 @@ Workbook.prototype.getDefaultSize=function(){
Workbook.prototype.getActive=function(){ Workbook.prototype.getActive=function(){
return this.nActive; return this.nActive;
}; };
Workbook.prototype.getActiveWs = function () {
return this.getWorksheet(this.nActive);
};
Workbook.prototype.setActive=function(index){ Workbook.prototype.setActive=function(index){
if(index >= 0 && index < this.aWorksheets.length){ if(index >= 0 && index < this.aWorksheets.length){
this.nActive = index; this.nActive = index;
...@@ -1321,6 +1324,7 @@ Workbook.prototype.getWorksheetCount=function(){ ...@@ -1321,6 +1324,7 @@ Workbook.prototype.getWorksheetCount=function(){
Workbook.prototype.createWorksheet=function(indexBefore, sName, sId){ Workbook.prototype.createWorksheet=function(indexBefore, sName, sId){
History.Create_NewPoint(); History.Create_NewPoint();
History.TurnOff(); History.TurnOff();
var wsActive = this.getActiveWs();
var oNewWorksheet = new Woorksheet(this, this.aWorksheets.length, sId); var oNewWorksheet = new Woorksheet(this, this.aWorksheets.length, sId);
if(null != sName) if(null != sName)
{ {
...@@ -1337,11 +1341,12 @@ Workbook.prototype.createWorksheet=function(indexBefore, sName, sId){ ...@@ -1337,11 +1341,12 @@ Workbook.prototype.createWorksheet=function(indexBefore, sName, sId){
this.aWorksheets.push(oNewWorksheet); this.aWorksheets.push(oNewWorksheet);
} }
this.aWorksheetsById[oNewWorksheet.getId()] = oNewWorksheet; this.aWorksheetsById[oNewWorksheet.getId()] = oNewWorksheet;
this._updateWorksheetIndexes(); this._updateWorksheetIndexes(wsActive);
this.setActive(oNewWorksheet.index);
History.TurnOn(); History.TurnOn();
this._insertWorksheetFormula(oNewWorksheet.index); this._insertWorksheetFormula(oNewWorksheet.index);
History.Add(g_oUndoRedoWorkbook, historyitem_Workbook_SheetAdd, null, null, new UndoRedoData_SheetAdd(indexBefore, oNewWorksheet.getName(), null, oNewWorksheet.getId())); History.Add(g_oUndoRedoWorkbook, historyitem_Workbook_SheetAdd, null, null, new UndoRedoData_SheetAdd(indexBefore, oNewWorksheet.getName(), null, oNewWorksheet.getId()));
History.SetSheetUndo(wsActive.getId());
History.SetSheetRedo(oNewWorksheet.getId());
return oNewWorksheet.index; return oNewWorksheet.index;
}; };
Workbook.prototype.copyWorksheet=function(index, insertBefore, sName, sId, bFromRedo){ Workbook.prototype.copyWorksheet=function(index, insertBefore, sName, sId, bFromRedo){
...@@ -1349,6 +1354,7 @@ Workbook.prototype.copyWorksheet=function(index, insertBefore, sName, sId, bFrom ...@@ -1349,6 +1354,7 @@ Workbook.prototype.copyWorksheet=function(index, insertBefore, sName, sId, bFrom
if(index >= 0 && index < this.aWorksheets.length){ if(index >= 0 && index < this.aWorksheets.length){
History.Create_NewPoint(); History.Create_NewPoint();
History.TurnOff(); History.TurnOff();
var wsActive = this.getActiveWs();
var wsFrom = this.aWorksheets[index]; var wsFrom = this.aWorksheets[index];
var newSheet = wsFrom.clone(sId); var newSheet = wsFrom.clone(sId);
if(null != sName) if(null != sName)
...@@ -1367,7 +1373,7 @@ Workbook.prototype.copyWorksheet=function(index, insertBefore, sName, sId, bFrom ...@@ -1367,7 +1373,7 @@ Workbook.prototype.copyWorksheet=function(index, insertBefore, sName, sId, bFrom
this.aWorksheets.push(newSheet); this.aWorksheets.push(newSheet);
} }
this.aWorksheetsById[newSheet.getId()] = newSheet; this.aWorksheetsById[newSheet.getId()] = newSheet;
this._updateWorksheetIndexes(); this._updateWorksheetIndexes(wsActive);
History.TurnOn(); History.TurnOn();
this._insertWorksheetFormula(insertBefore); this._insertWorksheetFormula(insertBefore);
//для формул. создаем копию this.cwf[this.Id] для нового листа. //для формул. создаем копию this.cwf[this.Id] для нового листа.
...@@ -1385,13 +1391,16 @@ Workbook.prototype.copyWorksheet=function(index, insertBefore, sName, sId, bFrom ...@@ -1385,13 +1391,16 @@ Workbook.prototype.copyWorksheet=function(index, insertBefore, sName, sId, bFrom
} }
sortDependency(this); sortDependency(this);
History.Add(g_oUndoRedoWorkbook, historyitem_Workbook_SheetAdd, null, null, new UndoRedoData_SheetAdd(insertBefore, newSheet.getName(), wsFrom.getId(), newSheet.getId())); History.Add(g_oUndoRedoWorkbook, historyitem_Workbook_SheetAdd, null, null, new UndoRedoData_SheetAdd(insertBefore, newSheet.getName(), wsFrom.getId(), newSheet.getId()));
History.SetSheetUndo(wsActive.getId());
History.SetSheetRedo(newSheet.getId());
if(!(bFromRedo === true)) if(!(bFromRedo === true))
{ {
wsFrom.copyDrawingObjects(newSheet, wsFrom); wsFrom.copyDrawingObjects(newSheet, wsFrom);
} }
} }
}; };
Workbook.prototype.insertWorksheet=function(index, sheet, cwf){ Workbook.prototype.insertWorksheet = function (index, sheet, cwf) {
var wsActive = this.getActiveWs();
if(null != index && index >= 0 && index < this.aWorksheets.length){ if(null != index && index >= 0 && index < this.aWorksheets.length){
//помещаем новый sheet перед insertBefore //помещаем новый sheet перед insertBefore
this.aWorksheets.splice(index, 0, sheet); this.aWorksheets.splice(index, 0, sheet);
...@@ -1401,7 +1410,7 @@ Workbook.prototype.insertWorksheet=function(index, sheet, cwf){ ...@@ -1401,7 +1410,7 @@ Workbook.prototype.insertWorksheet=function(index, sheet, cwf){
this.aWorksheets.push(sheet); this.aWorksheets.push(sheet);
} }
this.aWorksheetsById[sheet.getId()] = sheet; this.aWorksheetsById[sheet.getId()] = sheet;
this._updateWorksheetIndexes(); this._updateWorksheetIndexes(wsActive);
this._insertWorksheetFormula(index); this._insertWorksheetFormula(index);
//восстанавливаем список ячеек с формулами для sheet //восстанавливаем список ячеек с формулами для sheet
this.cwf[sheet.getId()] = cwf; this.cwf[sheet.getId()] = cwf;
...@@ -1434,6 +1443,7 @@ Workbook.prototype.replaceWorksheet=function(indexFrom, indexTo){ ...@@ -1434,6 +1443,7 @@ Workbook.prototype.replaceWorksheet=function(indexFrom, indexTo){
indexTo >= 0 && indexTo < this.aWorksheets.length){ indexTo >= 0 && indexTo < this.aWorksheets.length){
History.Create_NewPoint(); History.Create_NewPoint();
History.TurnOff(); History.TurnOff();
var wsActive = this.getActiveWs();
var oWsFrom = this.aWorksheets[indexFrom]; var oWsFrom = this.aWorksheets[indexFrom];
var oWsTo = this.aWorksheets[indexTo]; var oWsTo = this.aWorksheets[indexTo];
var tempW = { var tempW = {
...@@ -1474,7 +1484,7 @@ Workbook.prototype.replaceWorksheet=function(indexFrom, indexTo){ ...@@ -1474,7 +1484,7 @@ Workbook.prototype.replaceWorksheet=function(indexFrom, indexTo){
History.TurnOn(); History.TurnOn();
var movedSheet = this.aWorksheets.splice(indexFrom, 1); var movedSheet = this.aWorksheets.splice(indexFrom, 1);
this.aWorksheets.splice(indexTo, 0, movedSheet[0]); this.aWorksheets.splice(indexTo, 0, movedSheet[0]);
this._updateWorksheetIndexes(); this._updateWorksheetIndexes(wsActive);
this._insertWorksheetFormula(tempW.wTI); this._insertWorksheetFormula(tempW.wTI);
...@@ -1483,6 +1493,28 @@ Workbook.prototype.replaceWorksheet=function(indexFrom, indexTo){ ...@@ -1483,6 +1493,28 @@ Workbook.prototype.replaceWorksheet=function(indexFrom, indexTo){
unLockDraw(this); unLockDraw(this);
} }
}; };
Workbook.prototype.findSheetNoHidden = function (nIndex) {
var i, ws, oRes = null, bFound = false, countWorksheets = this.getWorksheetCount();
for (i = nIndex; i < countWorksheets; ++i) {
ws = this.getWorksheet(i);
if (false === ws.getHidden()) {
oRes = ws;
bFound = true;
break;
}
}
// Не нашли справа, ищем слева от текущего
if (!bFound) {
for (i = nIndex - 1; i >= 0; --i) {
ws = this.getWorksheet(i);
if (false === ws.getHidden()) {
oRes = ws;
break;
}
}
}
return oRes;
}
Workbook.prototype.removeWorksheet=function(nIndex, outputParams){ Workbook.prototype.removeWorksheet=function(nIndex, outputParams){
//проверяем останется ли хоть один нескрытый sheet //проверяем останется ли хоть один нескрытый sheet
var bEmpty = true; var bEmpty = true;
...@@ -1521,54 +1553,42 @@ Workbook.prototype.removeWorksheet=function(nIndex, outputParams){ ...@@ -1521,54 +1553,42 @@ Workbook.prototype.removeWorksheet=function(nIndex, outputParams){
} }
} }
} }
//по всем удаленным листам пробегаемся и удаляем из workbook.cwf (cwf - cells with forluma) элементы с названием соответствующего листа.
this.dependencyFormulas.removeNodeBySheetId(removedSheetId); this.dependencyFormulas.removeNodeBySheetId(removedSheetId);
History.TurnOff();
var nNewActive = this.nActive;
this.aWorksheets.splice(nIndex, 1);
//по всем удаленным листам пробегаемся и удаляем из workbook.cwf (cwf - cells with forluma) элементы с названием соответствующего листа.
var _cwf = this.cwf[removedSheetId]; var _cwf = this.cwf[removedSheetId];
delete this.cwf[removedSheetId]; delete this.cwf[removedSheetId];
delete this.aWorksheetsById[removedSheetId];
var wsActive = this.getActiveWs();
var bFind = false; var oVisibleWs = null;
if(nNewActive < this.aWorksheets.length) this.aWorksheets.splice(nIndex, 1);
{ delete this.aWorksheetsById[removedSheetId];
for(var i = nNewActive; i < this.aWorksheets.length; ++i) if (nIndex == this.getActive()) {
if(false == this.aWorksheets[i].getHidden()) oVisibleWs = this.findSheetNoHidden(nIndex);
{ if (null != oVisibleWs)
bFind = true; wsActive = oVisibleWs;
nNewActive = i;
break;
}
}
if(false == bFind)
{
for(var i = nNewActive - 1; i >= 0; --i)
if(false == this.aWorksheets[i].getHidden())
{
nNewActive = i;
break;
}
} }
History.TurnOn();
History.Add(g_oUndoRedoWorkbook, historyitem_Workbook_SheetRemove, null, null, new UndoRedoData_SheetRemove(nIndex, removedSheetId, removedSheet, _cwf)); History.Add(g_oUndoRedoWorkbook, historyitem_Workbook_SheetRemove, null, null, new UndoRedoData_SheetRemove(nIndex, removedSheetId, removedSheet, _cwf));
if (null != oVisibleWs) {
History.SetSheetUndo(removedSheetId);
History.SetSheetRedo(wsActive.getId());
}
if(null != outputParams) if(null != outputParams)
{ {
outputParams.sheet = removedSheet; outputParams.sheet = removedSheet;
outputParams.cwf = _cwf; outputParams.cwf = _cwf;
} }
this._updateWorksheetIndexes(); this._updateWorksheetIndexes(wsActive);
this.nActive = nNewActive;
buildRecalc(this); buildRecalc(this);
unLockDraw(this); unLockDraw(this);
return nNewActive; return wsActive.getIndex();
} }
return -1; return -1;
}; };
Workbook.prototype._updateWorksheetIndexes=function(){ Workbook.prototype._updateWorksheetIndexes = function (wsActive) {
for(var i = 0, length = this.aWorksheets.length; i < length; ++i) for(var i = 0, length = this.aWorksheets.length; i < length; ++i)
this.aWorksheets[i]._setIndex(i); this.aWorksheets[i]._setIndex(i);
if (null != wsActive)
this.setActive(wsActive.getIndex());
}; };
Workbook.prototype.checkUniqueSheetName=function(name){ Workbook.prototype.checkUniqueSheetName=function(name){
var workbookSheetCount = this.getWorksheetCount(); var workbookSheetCount = this.getWorksheetCount();
...@@ -1795,6 +1815,9 @@ Workbook.prototype.SerializeHistory = function(){ ...@@ -1795,6 +1815,9 @@ Workbook.prototype.SerializeHistory = function(){
if (historyitem_Workbook_SheetAdd == item.nActionType || historyitem_Workbook_SheetRemove == item.nActionType || historyitem_Workbook_SheetMove == item.nActionType) if (historyitem_Workbook_SheetAdd == item.nActionType || historyitem_Workbook_SheetRemove == item.nActionType || historyitem_Workbook_SheetMove == item.nActionType)
bChangeSheetPlace = true; bChangeSheetPlace = true;
} }
else if (g_oUndoRedoWorksheet === item.oClass && historyitem_Worksheet_Hide === item.nActionType) {
bChangeSheetPlace = true;
}
this._SerializeHistoryBase64(oMemory, item, aPointChangesBase64); this._SerializeHistoryBase64(oMemory, item, aPointChangesBase64);
} }
if (bChangeSheetPlace) { if (bChangeSheetPlace) {
...@@ -1874,24 +1897,17 @@ Workbook.prototype.DeserializeHistory = function(aChanges, fCallback){ ...@@ -1874,24 +1897,17 @@ Workbook.prototype.DeserializeHistory = function(aChanges, fCallback){
History.SetSelection(null); History.SetSelection(null);
History.SetSelectionRedo(null); History.SetSelectionRedo(null);
var oHistoryPositions = null;//нужен самый последний historyitem_Workbook_SheetPositions
var oRedoObjectParam = new Asc.RedoObjectParam(); var oRedoObjectParam = new Asc.RedoObjectParam();
History.UndoRedoPrepare(oRedoObjectParam, false); History.UndoRedoPrepare(oRedoObjectParam, false);
for (var i = 0, length = aUndoRedoElems.length; i < length; ++i) for (var i = 0, length = aUndoRedoElems.length; i < length; ++i)
{ {
var item = aUndoRedoElems[i]; var item = aUndoRedoElems[i];
if ((null != item.oClass || (item.oData && typeof item.oData.sChangedObjectId === "string")) && null != item.nActionType) { if ((null != item.oClass || (item.oData && typeof item.oData.sChangedObjectId === "string")) && null != item.nActionType) {
if (g_oUndoRedoWorkbook == item.oClass && historyitem_Workbook_SheetPositions == item.nActionType) // TODO if(g_oUndoRedoGraphicObjects == item.oClass && item.oData.drawingData)
oHistoryPositions = item; // item.oData.drawingData.bCollaborativeChanges = true;
else { History.RedoAdd(oRedoObjectParam, item.oClass, item.nActionType, item.nSheetId, item.oRange, item.oData);
// TODO if(g_oUndoRedoGraphicObjects == item.oClass && item.oData.drawingData)
// item.oData.drawingData.bCollaborativeChanges = true;
History.RedoAdd(oRedoObjectParam, item.oClass, item.nActionType, item.nSheetId, item.oRange, item.oData);
}
} }
} }
if(null != oHistoryPositions)
History.RedoAdd(oRedoObjectParam, oHistoryPositions.oClass, oHistoryPositions.nActionType, oHistoryPositions.nSheetId, oHistoryPositions.oRange, oHistoryPositions.oData);
History.UndoRedoEnd(null, oRedoObjectParam, false); History.UndoRedoEnd(null, oRedoObjectParam, false);
...@@ -2353,35 +2369,26 @@ Woorksheet.prototype.getHidden=function(){ ...@@ -2353,35 +2369,26 @@ Woorksheet.prototype.getHidden=function(){
return false != this.bHidden; return false != this.bHidden;
return false; return false;
}; };
Woorksheet.prototype.setHidden=function(hidden){ Woorksheet.prototype.setHidden = function (hidden) {
if(this.bHidden != hidden) var bOldHidden = this.bHidden, wb = this.workbook, wsActive = wb.getActiveWs(), oVisibleWs = null;
{ this.bHidden = hidden;
History.Create_NewPoint(); if (true == this.bHidden && this.getIndex() == wsActive.getIndex())
History.Add(g_oUndoRedoWorksheet, historyitem_Worksheet_Hide, this.getId(), null, new UndoRedoData_FromTo(this.bHidden, hidden)); {
} oVisibleWs = wb.findSheetNoHidden(this.getIndex());
this.bHidden = hidden; if (null != oVisibleWs) {
if(true == this.bHidden && this.getIndex() == this.workbook.getActive()) var nNewIndex = oVisibleWs.getIndex();
{ wb.setActive(nNewIndex);
//выбираем новый активный if (!wb.bUndoChanges && !wb.bRedoChanges)
var activeWorksheet = this.getIndex(); wb.handlers.trigger("undoRedoHideSheet", nNewIndex);
var countWorksheets = this.workbook.getWorksheetCount(); }
// Покажем следующий лист или предыдущий (если больше нет) }
var i, ws; if (bOldHidden != hidden) {
for (i = activeWorksheet + 1; i < countWorksheets; ++i) { History.Create_NewPoint();
ws = this.workbook.getWorksheet(i); History.Add(g_oUndoRedoWorksheet, historyitem_Worksheet_Hide, this.getId(), null, new UndoRedoData_FromTo(bOldHidden, hidden));
if (false === ws.getHidden()) { if (null != oVisibleWs) {
this.workbook.handlers.trigger("undoRedoHideSheet", i); History.SetSheetUndo(wsActive.getId());
return; History.SetSheetRedo(oVisibleWs.getId());
} }
}
// Не нашли справа, ищем слева от текущего
for (i = activeWorksheet - 1; i >= 0; --i) {
ws = this.workbook.getWorksheet(i);
if (false === ws.getHidden()) {
this.workbook.handlers.trigger("undoRedoHideSheet", i);
return;
}
}
} }
}; };
Woorksheet.prototype.getSheetViewSettings = function () { Woorksheet.prototype.getSheetViewSettings = function () {
......
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