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