Commit 8be4a0eb authored by Sergey.Konovalov's avatar Sergey.Konovalov Committed by Alexander.Trofimov

проблемы с частичным удалением гиперссылок и merge ячеек при удалении ячеек

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@50232 954022d7-b5bf-4e40-9824-e11837661b57
parent 49b360a0
...@@ -359,7 +359,7 @@ CHistory.prototype = ...@@ -359,7 +359,7 @@ CHistory.prototype =
lockDraw(this.workbook); lockDraw(this.workbook);
this.workbook.handlers.trigger("lockDraw"); this.workbook.handlers.trigger("lockDraw");
this.workbook.bUndoRedoChanges = true; this.workbook.bUndoChanges = true;
var isReInit = false; var isReInit = false;
var oCurWorksheet = this.workbook.getWorksheet(this.workbook.getActive()); var oCurWorksheet = this.workbook.getWorksheet(this.workbook.getActive());
...@@ -391,7 +391,7 @@ CHistory.prototype = ...@@ -391,7 +391,7 @@ CHistory.prototype =
this._sendCanUndoRedo(); this._sendCanUndoRedo();
this.workbook.bUndoRedoChanges = false; this.workbook.bUndoChanges = false;
if (isReInit) if (isReInit)
this.workbook.handlers.trigger("reInit"); this.workbook.handlers.trigger("reInit");
this.workbook.handlers.trigger("drawWS"); this.workbook.handlers.trigger("drawWS");
...@@ -411,7 +411,7 @@ CHistory.prototype = ...@@ -411,7 +411,7 @@ CHistory.prototype =
lockDraw(this.workbook); lockDraw(this.workbook);
this.workbook.handlers.trigger("lockDraw"); this.workbook.handlers.trigger("lockDraw");
this.workbook.bUndoRedoChanges = true; this.workbook.bRedoChanges = true;
}, },
RedoAdd : function(oRedoObjectParam, Class, Type, sheetid, range, Data, LocalChange) RedoAdd : function(oRedoObjectParam, Class, Type, sheetid, range, Data, LocalChange)
{ {
...@@ -469,7 +469,7 @@ CHistory.prototype = ...@@ -469,7 +469,7 @@ CHistory.prototype =
this._sendCanUndoRedo(); this._sendCanUndoRedo();
this.workbook.bUndoRedoChanges = false; this.workbook.bRedoChanges = false;
if (oRedoObjectParam.bIsReInit) if (oRedoObjectParam.bIsReInit)
this.workbook.handlers.trigger("reInit"); this.workbook.handlers.trigger("reInit");
this.workbook.handlers.trigger("drawWS"); this.workbook.handlers.trigger("drawWS");
......
...@@ -295,7 +295,7 @@ var UndoRedoDataTypes = new function() { ...@@ -295,7 +295,7 @@ var UndoRedoDataTypes = new function() {
this.CellData = 4; this.CellData = 4;
this.FromTo = 5; this.FromTo = 5;
this.FromToRowCol = 6; this.FromToRowCol = 6;
this.FromToCell = 7; this.FromToHyperlink = 7;
this.IndexSimpleProp = 8; this.IndexSimpleProp = 8;
this.ColProp = 9; this.ColProp = 9;
this.RowProp = 10; this.RowProp = 10;
...@@ -369,7 +369,7 @@ var UndoRedoDataTypes = new function() { ...@@ -369,7 +369,7 @@ var UndoRedoDataTypes = new function() {
case this.CellSimpleData: return new UndoRedoData_CellSimpleData();break; case this.CellSimpleData: return new UndoRedoData_CellSimpleData();break;
case this.FromTo: return new UndoRedoData_FromTo();break; case this.FromTo: return new UndoRedoData_FromTo();break;
case this.FromToRowCol: return new UndoRedoData_FromToRowCol();break; case this.FromToRowCol: return new UndoRedoData_FromToRowCol();break;
case this.FromToCell: return new UndoRedoData_FromToCell();break; case this.FromToHyperlink: return new UndoRedoData_FromToHyperlink();break;
case this.IndexSimpleProp: return new UndoRedoData_IndexSimpleProp();break; case this.IndexSimpleProp: return new UndoRedoData_IndexSimpleProp();break;
case this.ColProp: return new UndoRedoData_ColProp();break; case this.ColProp: return new UndoRedoData_ColProp();break;
case this.RowProp: return new UndoRedoData_RowProp();break; case this.RowProp: return new UndoRedoData_RowProp();break;
...@@ -643,19 +643,20 @@ UndoRedoData_FromTo.prototype = { ...@@ -643,19 +643,20 @@ UndoRedoData_FromTo.prototype = {
} }
}; };
function UndoRedoData_FromToCell(oBBoxFrom, oBBoxTo, arr){ function UndoRedoData_FromToHyperlink(oBBoxFrom, oBBoxTo, hyperlink){
this.Properties = { this.Properties = {
from: 0, from: 0,
to: 1 to: 1,
hyperlink: 2
}; };
this.from = new UndoRedoData_BBox(oBBoxFrom); this.from = new UndoRedoData_BBox(oBBoxFrom);
this.to = new UndoRedoData_BBox(oBBoxTo); this.to = new UndoRedoData_BBox(oBBoxTo);
this.arr = arr; this.hyperlink = hyperlink;
} }
UndoRedoData_FromToCell.prototype = { UndoRedoData_FromToHyperlink.prototype = {
getType : function() getType : function()
{ {
return UndoRedoDataTypes.FromToCell; return UndoRedoDataTypes.FromToHyperlink;
}, },
getProperties : function() getProperties : function()
{ {
...@@ -667,6 +668,7 @@ UndoRedoData_FromToCell.prototype = { ...@@ -667,6 +668,7 @@ UndoRedoData_FromToCell.prototype = {
{ {
case this.Properties.from: return this.from;break; case this.Properties.from: return this.from;break;
case this.Properties.to: return this.to;break; case this.Properties.to: return this.to;break;
case this.Properties.hyperlink: return this.hyperlink;break;
} }
}, },
setProperty : function(nType, value) setProperty : function(nType, value)
...@@ -675,6 +677,7 @@ UndoRedoData_FromToCell.prototype = { ...@@ -675,6 +677,7 @@ UndoRedoData_FromToCell.prototype = {
{ {
case this.Properties.from: this.from = value;break; case this.Properties.from: this.from = value;break;
case this.Properties.to: this.to = value;break; case this.Properties.to: this.to = value;break;
case this.Properties.hyperlink: this.hyperlink = value;break;
} }
}, },
applyCollaborative : function(nSheetId, collaborativeEditing) applyCollaborative : function(nSheetId, collaborativeEditing)
...@@ -3289,6 +3292,33 @@ UndoRedoWoorksheet.prototype = { ...@@ -3289,6 +3292,33 @@ UndoRedoWoorksheet.prototype = {
} else if (historyitem_Worksheet_SetViewSettings === Type) { } else if (historyitem_Worksheet_SetViewSettings === Type) {
ws.setSheetViewSettings(bUndo ? Data.from : Data.to); ws.setSheetViewSettings(bUndo ? Data.from : Data.to);
} }
else if(historyitem_Worksheet_ChangeMerge === Type){
if(bUndo)
{
var data = 1;
if(null != Data.to)
{
//todo сделать через get/remove
var elem = new RangeDataManagerElem(Data.to, data);
ws.mergeManager.remove(elem.bbox, elem, false);
}
ws.mergeManager.add(Data.from, data);
}
}
else if(historyitem_Worksheet_ChangeHyperlink === Type){
if(bUndo)
{
var data = Data.hyperlink;
if(null != Data.to)
{
//todo сделать через get/remove
var elem = new RangeDataManagerElem(Data.to, data);
ws.hyperlinkManager.remove(elem.bbox, elem, false);
}
data.Ref = ws.getRange3(Data.from.r1, Data.from.c1, Data.from.r2, Data.from.c2);
ws.hyperlinkManager.add(Data.from, data);
}
}
} }
}; };
......
...@@ -1420,7 +1420,8 @@ function Workbook(sUrlPath, eventsHandlers, oApi){ ...@@ -1420,7 +1420,8 @@ function Workbook(sUrlPath, eventsHandlers, oApi){
this.startActionOn = false; this.startActionOn = false;
this.aCollaborativeActions = new Array(); this.aCollaborativeActions = new Array();
this.bCollaborativeChanges = false; this.bCollaborativeChanges = false;
this.bUndoRedoChanges = false; this.bUndoChanges = false;
this.bRedoChanges = false;
this.aCollaborativeChangeElements = new Array(); this.aCollaborativeChangeElements = new Array();
}; };
Workbook.prototype.initGlobalObjects=function(){ Workbook.prototype.initGlobalObjects=function(){
...@@ -2186,30 +2187,21 @@ function Woorksheet(wb, _index, bAddUserId, sId){ ...@@ -2186,30 +2187,21 @@ function Woorksheet(wb, _index, bAddUserId, sId){
if(null != from) if(null != from)
{ {
from = from.clone(); from = from.clone();
if(null == to) if(null != to)
History.Add(g_oUndoRedoWorksheet, historyitem_Worksheet_Unmerge, oThis.getId(), from, new UndoRedoData_BBox(from));
else
{
to = to.clone(); to = to.clone();
//todo History.Add(g_oUndoRedoWorksheet, historyitem_Worksheet_ChangeMerge, oThis.getId(), from, new UndoRedoData_FromTo(new UndoRedoData_BBox(from), new UndoRedoData_BBox(to)));
//нужно добавлять в историю только когда обрезается с краев, потому что на undo будет произведена вставка и ячеек, а диапазон не расширится
History.Add(g_oUndoRedoWorksheet, historyitem_Worksheet_ChangeMerge, oThis.getId(), from, new UndoRedoData_FromTo(new UndoRedoData_BBox(from), new UndoRedoData_BBox(to)));
}
} }
}); });
this.hyperlinkManager = new RangeDataManager(true, function(data, from, to){ this.hyperlinkManager = new RangeDataManager(true, function(data, from, to){
if(null != from) if(null != from)
{ {
from = from.clone(); from = from.clone();
if(null == to) if(null != to)
History.Add(g_oUndoRedoWorksheet, historyitem_Worksheet_RemoveHyperlink, oThis.getId(), from, data);
else
{ {
data.Ref = oThis.getRange3(to.r1, to.c1, to.r2, to.c2);
to = to.clone(); to = to.clone();
//нужно добавлять в историю только когда обрезается с краев, потому что на undo будет произведена вставка и ячеек, а диапазон не расширится data.Ref = oThis.getRange3(to.r1, to.c1, to.r2, to.c2);
History.Add(g_oUndoRedoWorksheet, historyitem_Worksheet_ChangeHyperlink, oThis.getId(), from, data);
} }
History.Add(g_oUndoRedoWorksheet, historyitem_Worksheet_ChangeHyperlink, oThis.getId(), from, new UndoRedoData_FromToHyperlink(from, to, data));
} }
}); });
this.hyperlinkManager.setDependenceManager(this.mergeManager); this.hyperlinkManager.setDependenceManager(this.mergeManager);
...@@ -2704,7 +2696,7 @@ Woorksheet.prototype._insertRowsBefore=function(index, count){ ...@@ -2704,7 +2696,7 @@ Woorksheet.prototype._insertRowsBefore=function(index, count){
this._moveCellVer(nIndex, j - 0, count); this._moveCellVer(nIndex, j - 0, count);
delete this.aGCells[nIndex]; delete this.aGCells[nIndex];
} }
if(null != oPrevRow && false == this.workbook.bUndoRedoChanges) if(null != oPrevRow && false == this.workbook.bUndoChanges && false == this.workbook.bRedoChanges)
{ {
for(var i = 0; i < count; ++i) for(var i = 0; i < count; ++i)
{ {
...@@ -2844,7 +2836,7 @@ Woorksheet.prototype._insertColsBefore=function(index, count){ ...@@ -2844,7 +2836,7 @@ Woorksheet.prototype._insertColsBefore=function(index, count){
for(var i = 0; i < count; ++i) for(var i = 0; i < count; ++i)
{ {
var oNewCol = null; var oNewCol = null;
if(null != oPrevCol && false == this.workbook.bUndoRedoChanges) if(null != oPrevCol && false == this.workbook.bUndoChanges && false == this.workbook.bRedoChanges)
{ {
oNewCol = oPrevCol.clone(); oNewCol = oPrevCol.clone();
oNewCol.hd = null; oNewCol.hd = null;
...@@ -7302,8 +7294,11 @@ Range.prototype._shiftLeftRight=function(bLeft){ ...@@ -7302,8 +7294,11 @@ Range.prototype._shiftLeftRight=function(bLeft){
else else
this.worksheet._insertColsBefore(oBBox.c1, nWidth); this.worksheet._insertColsBefore(oBBox.c1, nWidth);
} }
mergeManager.shift(this.bbox, !bLeft, true, oShiftGet); if(false == this.worksheet.workbook.bUndoChanges)
this.worksheet.hyperlinkManager.shift(this.bbox, !bLeft, true); {
mergeManager.shift(this.bbox, !bLeft, true, oShiftGet);
this.worksheet.hyperlinkManager.shift(this.bbox, !bLeft, true);
}
History.EndTransaction(); History.EndTransaction();
return true; return true;
}; };
...@@ -7350,8 +7345,11 @@ Range.prototype._shiftUpDown=function(bUp){ ...@@ -7350,8 +7345,11 @@ Range.prototype._shiftUpDown=function(bUp){
else else
this.worksheet._insertRowsBefore(oBBox.r1, nHeight); this.worksheet._insertRowsBefore(oBBox.r1, nHeight);
} }
mergeManager.shift(this.bbox, !bUp, false, oShiftGet); if(false == this.worksheet.workbook.bUndoChanges)
this.worksheet.hyperlinkManager.shift(this.bbox, !bUp, false); {
mergeManager.shift(this.bbox, !bUp, false, oShiftGet);
this.worksheet.hyperlinkManager.shift(this.bbox, !bUp, false);
}
History.EndTransaction(); History.EndTransaction();
return true; return true;
}; };
......
...@@ -3665,6 +3665,7 @@ RangeDataManager.prototype = { ...@@ -3665,6 +3665,7 @@ RangeDataManager.prototype = {
this.nStopRecalculate++; this.nStopRecalculate++;
if(null == oGetRes) if(null == oGetRes)
oGetRes = this.shiftGet(bbox, bHor); oGetRes = this.shiftGet(bbox, bHor);
var aToChange = [];
var elems = oGetRes.elems; var elems = oGetRes.elems;
//сдвигаем inner //сдвигаем inner
if(elems.inner.length > 0) if(elems.inner.length > 0)
...@@ -3680,11 +3681,6 @@ RangeDataManager.prototype = { ...@@ -3680,11 +3681,6 @@ RangeDataManager.prototype = {
offset.offsetCol = -offset.offsetCol; offset.offsetCol = -offset.offsetCol;
} }
for(var i = 0, length = elems.inner.length; i < length; i++) for(var i = 0, length = elems.inner.length; i < length; i++)
{
var elem = elems.inner[i];
this.remove(elem.bbox, elem, false);
}
for(var i = 0, length = elems.inner.length; i < length; i++)
{ {
var elem = elems.inner[i]; var elem = elems.inner[i];
var from = elem.bbox; var from = elem.bbox;
...@@ -3713,10 +3709,7 @@ RangeDataManager.prototype = { ...@@ -3713,10 +3709,7 @@ RangeDataManager.prototype = {
to.setOffset(offset); to.setOffset(offset);
} }
} }
if(null != to) aToChange.push({elem: elem, to: to});
this.add(to, elem.data);
if(null != this.fChange)
this.fChange.call(this, elem.data, from, to);
} }
} }
//меняем outer //меняем outer
...@@ -3764,15 +3757,27 @@ RangeDataManager.prototype = { ...@@ -3764,15 +3757,27 @@ RangeDataManager.prototype = {
} }
} }
if(null != to) if(null != to)
{ aToChange.push({elem: elem, to: to});
if(null != this.fChange)
this.fChange.call(this, elem.data, from, to);
elem.bbox = to;
delete this.oElements[this._getBBoxIndex(from)];
this.oElements[this._getBBoxIndex(to)] = elem;
}
} }
} }
//сначала удаляем все чтобы не было конфликтов
for(var i = 0, length = aToChange.length; i < length; ++i)
{
var item = aToChange[i];
var elem = item.elem;
var from = elem.bbox;
var to = item.to;
if(null != this.fChange)
this.fChange.call(this, elem.data, from, to);
this.remove(elem.bbox, elem, false);
}
//добавляем измененные ячейки
for(var i = 0, length = aToChange.length; i < length; ++i)
{
var item = aToChange[i];
if(null != item.to)
this.add(item.to, item.elem.data);
}
this.nStopRecalculate--; this.nStopRecalculate--;
this._recalculate(); this._recalculate();
}, },
......
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