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

Bug 21722 - [CoEdit] Применение Unmerge к объединенным ячейкам не передается другому пользователю

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@51206 954022d7-b5bf-4e40-9824-e11837661b57
parent 94689ceb
...@@ -3293,30 +3293,69 @@ UndoRedoWoorksheet.prototype = { ...@@ -3293,30 +3293,69 @@ UndoRedoWoorksheet.prototype = {
ws.setSheetViewSettings(bUndo ? Data.from : Data.to); ws.setSheetViewSettings(bUndo ? Data.from : Data.to);
} }
else if(historyitem_Worksheet_ChangeMerge === Type){ else if(historyitem_Worksheet_ChangeMerge === Type){
var from = null;
if(null != Data.from)
from = new Asc.Range(Data.from.c1, Data.from.r1, Data.from.c2, Data.from.r2);
var to = null;
if(null != Data.to)
to = new Asc.Range(Data.to.c1, Data.to.r1, Data.to.c2, Data.to.r2);
if(bUndo) if(bUndo)
{ {
var temp = from;
from = to;
to = temp;
}
var data = 1; var data = 1;
if(null != Data.to) if(null != from && null != from.r1 && null != from.c1 && null != from.r2 && null != from.c2)
{ {
//todo сделать через get/remove var aMerged = ws.mergeManager.get(from);
var elem = new RangeDataManagerElem(Data.to, data); for(var i in aMerged.inner)
{
var merged = aMerged.inner[i];
if(merged.bbox.isEqual(from))
{
var elem = new RangeDataManagerElem(from, data);
ws.mergeManager.remove(elem.bbox, elem, false); ws.mergeManager.remove(elem.bbox, elem, false);
break;
} }
ws.mergeManager.add(Data.from, data);
} }
} }
if(null != to && null != to.r1 && null != to.c1 && null != to.r2 && null != to.c2)
ws.mergeManager.add(to, data, false);
}
else if(historyitem_Worksheet_ChangeHyperlink === Type){ else if(historyitem_Worksheet_ChangeHyperlink === Type){
var from = null;
if(null != Data.from)
from = new Asc.Range(Data.from.c1, Data.from.r1, Data.from.c2, Data.from.r2);
var to = null;
if(null != Data.to)
to = new Asc.Range(Data.to.c1, Data.to.r1, Data.to.c2, Data.to.r2);
if(bUndo) if(bUndo)
{ {
var temp = from;
from = to;
to = temp;
}
//не делаем clone потому что предполагаем, что здесь могут быть только операции изменения рзмеров, перемещение или удаления одной ссылки
var data = Data.hyperlink; var data = Data.hyperlink;
if(null != Data.to) if(null != from && null != from.r1 && null != from.c1 && null != from.r2 && null != from.c2)
{
var aHyperlinks = ws.hyperlinkManager.get(from);
for(var i in aHyperlinks.inner)
{ {
//todo сделать через get/remove var hyp = aHyperlinks.inner[i];
var elem = new RangeDataManagerElem(Data.to, data); if(hyp.bbox.isEqual(from))
{
var elem = new RangeDataManagerElem(from, data);
ws.hyperlinkManager.remove(elem.bbox, elem, false); ws.hyperlinkManager.remove(elem.bbox, elem, false);
break;
}
} }
data.Ref = ws.getRange3(Data.from.r1, Data.from.c1, Data.from.r2, Data.from.c2); }
ws.hyperlinkManager.add(Data.from, data); if(null != to && null != to.r1 && null != to.c1 && null != to.r2 && null != to.c2)
{
data.Ref = ws.getRange3(to.r1, to.c1, to.r2, to.c2);
ws.hyperlinkManager.add(to, data, false);
} }
} }
} }
......
...@@ -2171,24 +2171,32 @@ function Woorksheet(wb, _index, bAddUserId, sId){ ...@@ -2171,24 +2171,32 @@ function Woorksheet(wb, _index, bAddUserId, sId){
this.aCommentsCoords = new Array(); this.aCommentsCoords = new Array();
var oThis = this; var oThis = this;
this.mergeManager = new RangeDataManager(false, function(data, from, to){ this.mergeManager = new RangeDataManager(false, function(data, from, to){
if(null != from) if(null != from || null != to)
{ {
if(null != from)
from = from.clone(); from = from.clone();
if(null != to) if(null != to)
to = to.clone(); to = to.clone();
History.Add(g_oUndoRedoWorksheet, historyitem_Worksheet_ChangeMerge, oThis.getId(), from, new UndoRedoData_FromTo(new UndoRedoData_BBox(from), new UndoRedoData_BBox(to))); var oHistoryRange = from;
if(null == oHistoryRange)
oHistoryRange = to;
History.Add(g_oUndoRedoWorksheet, historyitem_Worksheet_ChangeMerge, oThis.getId(), oHistoryRange, 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 || null != to)
{ {
if(null != from)
from = from.clone(); from = from.clone();
if(null != to) if(null != to)
{ {
to = to.clone(); to = to.clone();
data.Ref = oThis.getRange3(to.r1, to.c1, to.r2, to.c2); 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)); var oHistoryRange = from;
if(null == oHistoryRange)
oHistoryRange = to;
History.Add(g_oUndoRedoWorksheet, historyitem_Worksheet_ChangeHyperlink, oThis.getId(), oHistoryRange, new UndoRedoData_FromToHyperlink(from, to, data));
} }
}); });
this.hyperlinkManager.setDependenceManager(this.mergeManager); this.hyperlinkManager.setDependenceManager(this.mergeManager);
...@@ -3654,7 +3662,7 @@ Woorksheet.prototype._moveRange=function(oBBoxFrom, oBBoxTo){ ...@@ -3654,7 +3662,7 @@ Woorksheet.prototype._moveRange=function(oBBoxFrom, oBBoxTo){
{ {
var elem = aTempObj.merged[i]; var elem = aTempObj.merged[i];
elem.bbox.setOffset(offset); elem.bbox.setOffset(offset);
this.mergeManager.add(elem.bbox, elem.data); this.mergeManager.add(elem.bbox, elem.data, false);
} }
} }
if(null != aTempObj.hyperlinks) if(null != aTempObj.hyperlinks)
...@@ -3664,7 +3672,7 @@ Woorksheet.prototype._moveRange=function(oBBoxFrom, oBBoxTo){ ...@@ -3664,7 +3672,7 @@ Woorksheet.prototype._moveRange=function(oBBoxFrom, oBBoxTo){
var elem = aTempObj.hyperlinks[i]; var elem = aTempObj.hyperlinks[i];
elem.bbox.setOffset(offset); elem.bbox.setOffset(offset);
elem.data.Ref.setOffset(offset); elem.data.Ref.setOffset(offset);
this.hyperlinkManager.add(elem.bbox, elem.data); this.hyperlinkManager.add(elem.bbox, elem.data, false);
} }
} }
//расширяем границы //расширяем границы
...@@ -6847,7 +6855,7 @@ Range.prototype.hasMerged=function(){ ...@@ -6847,7 +6855,7 @@ Range.prototype.hasMerged=function(){
return null; return null;
}; };
Range.prototype.mergeOpen=function(){ Range.prototype.mergeOpen=function(){
this.worksheet.mergeManager.add(this.bbox, 1); this.worksheet.mergeManager.add(this.bbox, 1, false);
} }
Range.prototype.merge=function(type){ Range.prototype.merge=function(type){
if(null == type) if(null == type)
...@@ -7155,14 +7163,15 @@ Range.prototype.merge=function(type){ ...@@ -7155,14 +7163,15 @@ Range.prototype.merge=function(type){
}); });
if(type == c_oAscMergeOptions.MergeCenter) if(type == c_oAscMergeOptions.MergeCenter)
this.setAlignHorizontal("center"); this.setAlignHorizontal("center");
this.worksheet.mergeManager.add(this.bbox, 1); if(false == this.worksheet.workbook.bUndoChanges && false == this.worksheet.workbook.bRedoChanges)
History.Add(g_oUndoRedoWorksheet, historyitem_Worksheet_Merge, this.worksheet.getId(), new Asc.Range(oBBox.c1, oBBox.r1, oBBox.c2, oBBox.r2), new UndoRedoData_BBox(oBBox)); this.worksheet.mergeManager.add(this.bbox, 1, true);
History.EndTransaction(); History.EndTransaction();
}; };
Range.prototype.unmerge=function(bOnlyInRange){ Range.prototype.unmerge=function(bOnlyInRange){
History.Create_NewPoint(); History.Create_NewPoint();
History.SetSelection(this.bbox.clone()); History.SetSelection(this.bbox.clone());
History.StartTransaction(); History.StartTransaction();
if(false == this.worksheet.workbook.bUndoChanges && false == this.worksheet.workbook.bRedoChanges)
this.worksheet.mergeManager.remove(this.bbox, null, true); this.worksheet.mergeManager.remove(this.bbox, null, true);
History.EndTransaction(); History.EndTransaction();
}; };
...@@ -7236,7 +7245,7 @@ Range.prototype.getHyperlinks=function(){ ...@@ -7236,7 +7245,7 @@ Range.prototype.getHyperlinks=function(){
Range.prototype.setHyperlinkOpen=function(val){ Range.prototype.setHyperlinkOpen=function(val){
if(null != val && false == val.isValid()) if(null != val && false == val.isValid())
return; return;
this.worksheet.hyperlinkManager.add(val.Ref.getBBox0(), val); this.worksheet.hyperlinkManager.add(val.Ref.getBBox0(), val, false);
} }
Range.prototype.setHyperlink=function(val, bWithoutStyle){ Range.prototype.setHyperlink=function(val, bWithoutStyle){
if(null != val && false == val.isValid()) if(null != val && false == val.isValid())
...@@ -7259,6 +7268,8 @@ Range.prototype.setHyperlink=function(val, bWithoutStyle){ ...@@ -7259,6 +7268,8 @@ Range.prototype.setHyperlink=function(val, bWithoutStyle){
History.Create_NewPoint(); History.Create_NewPoint();
History.SetSelection(this.bbox.clone()); History.SetSelection(this.bbox.clone());
History.StartTransaction(); History.StartTransaction();
if(false == this.worksheet.workbook.bUndoChanges && false == this.worksheet.workbook.bRedoChanges)
{
//удаляем ссылки с тем же адресом //удаляем ссылки с тем же адресом
for(var i = 0, length = aHyperlinks.all.length; i < length; i++) for(var i = 0, length = aHyperlinks.all.length; i < length; i++)
{ {
...@@ -7266,6 +7277,7 @@ Range.prototype.setHyperlink=function(val, bWithoutStyle){ ...@@ -7266,6 +7277,7 @@ Range.prototype.setHyperlink=function(val, bWithoutStyle){
if(hyp.bbox.isEqual(this.bbox)) if(hyp.bbox.isEqual(this.bbox))
this.worksheet.hyperlinkManager.remove(hyp.bbox, hyp, true); this.worksheet.hyperlinkManager.remove(hyp.bbox, hyp, true);
} }
}
//todo перейти на CellStyle //todo перейти на CellStyle
if(true != bWithoutStyle) if(true != bWithoutStyle)
{ {
...@@ -7276,8 +7288,8 @@ Range.prototype.setHyperlink=function(val, bWithoutStyle){ ...@@ -7276,8 +7288,8 @@ Range.prototype.setHyperlink=function(val, bWithoutStyle){
oHyperlinkFont.c = g_oColorManager.getThemeColor(g_nColorHyperlink); oHyperlinkFont.c = g_oColorManager.getThemeColor(g_nColorHyperlink);
this.setFont(oHyperlinkFont); this.setFont(oHyperlinkFont);
} }
this.worksheet.hyperlinkManager.add(val.Ref.getBBox0(), val); if(false == this.worksheet.workbook.bUndoChanges && false == this.worksheet.workbook.bRedoChanges)
History.Add(g_oUndoRedoWorksheet, historyitem_Worksheet_SetHyperlink, this.worksheet.getId(), this.bbox.clone(), val.clone()); this.worksheet.hyperlinkManager.add(val.Ref.getBBox0(), val, true);
History.EndTransaction(); History.EndTransaction();
} }
}; };
...@@ -7292,6 +7304,7 @@ Range.prototype.removeHyperlink=function(val){ ...@@ -7292,6 +7304,7 @@ Range.prototype.removeHyperlink=function(val){
History.Create_NewPoint(); History.Create_NewPoint();
History.SetSelection(bbox.clone()); History.SetSelection(bbox.clone());
History.StartTransaction(); History.StartTransaction();
if(false == this.worksheet.workbook.bUndoChanges && false == this.worksheet.workbook.bRedoChanges)
this.worksheet.hyperlinkManager.remove(bbox, elem, true); this.worksheet.hyperlinkManager.remove(bbox, elem, true);
History.EndTransaction(); History.EndTransaction();
} }
...@@ -7314,12 +7327,14 @@ Range.prototype._shiftLeftRight=function(bLeft){ ...@@ -7314,12 +7327,14 @@ Range.prototype._shiftLeftRight=function(bLeft){
if(c_oRangeType.Range != nRangeType && c_oRangeType.Col != nRangeType) if(c_oRangeType.Range != nRangeType && c_oRangeType.Col != nRangeType)
return false; return false;
var mergeManager = this.worksheet.mergeManager; var mergeManager = this.worksheet.mergeManager;
var oShiftGet = mergeManager.shiftGet(this.bbox, true);
var aMerged = oShiftGet.elems;
//todo вставить предупреждение, что будет unmerge //todo вставить предупреждение, что будет unmerge
History.Create_NewPoint(); History.Create_NewPoint();
History.SetSelection(new Asc.Range(oBBox.c1, oBBox.r1, oBBox.c2, oBBox.r2)); History.SetSelection(new Asc.Range(oBBox.c1, oBBox.r1, oBBox.c2, oBBox.r2));
History.StartTransaction(); History.StartTransaction();
if(false == this.worksheet.workbook.bUndoChanges && false == this.worksheet.workbook.bRedoChanges)
{
var oShiftGet = mergeManager.shiftGet(this.bbox, true);
var aMerged = oShiftGet.elems;
if(null != aMerged.outer && aMerged.outer.length > 0) if(null != aMerged.outer && aMerged.outer.length > 0)
{ {
var bChanged = false; var bChanged = false;
...@@ -7335,6 +7350,7 @@ Range.prototype._shiftLeftRight=function(bLeft){ ...@@ -7335,6 +7350,7 @@ Range.prototype._shiftLeftRight=function(bLeft){
if(bChanged) if(bChanged)
oShiftGet = null; oShiftGet = null;
} }
}
//сдвигаем ячейки //сдвигаем ячейки
if(bLeft) if(bLeft)
{ {
...@@ -7350,7 +7366,7 @@ Range.prototype._shiftLeftRight=function(bLeft){ ...@@ -7350,7 +7366,7 @@ Range.prototype._shiftLeftRight=function(bLeft){
else else
this.worksheet._insertColsBefore(oBBox.c1, nWidth); this.worksheet._insertColsBefore(oBBox.c1, nWidth);
} }
if(false == this.worksheet.workbook.bUndoChanges) if(false == this.worksheet.workbook.bUndoChanges && false == this.worksheet.workbook.bRedoChanges)
{ {
mergeManager.shift(this.bbox, !bLeft, true, oShiftGet); mergeManager.shift(this.bbox, !bLeft, true, oShiftGet);
this.worksheet.hyperlinkManager.shift(this.bbox, !bLeft, true); this.worksheet.hyperlinkManager.shift(this.bbox, !bLeft, true);
...@@ -7365,12 +7381,14 @@ Range.prototype._shiftUpDown=function(bUp){ ...@@ -7365,12 +7381,14 @@ Range.prototype._shiftUpDown=function(bUp){
if(c_oRangeType.Range != nRangeType && c_oRangeType.Row != nRangeType) if(c_oRangeType.Range != nRangeType && c_oRangeType.Row != nRangeType)
return false; return false;
var mergeManager = this.worksheet.mergeManager; var mergeManager = this.worksheet.mergeManager;
var oShiftGet = mergeManager.shiftGet(this.bbox, false);
var aMerged = oShiftGet.elems;
//todo вставить предупреждение, что будет unmerge //todo вставить предупреждение, что будет unmerge
History.Create_NewPoint(); History.Create_NewPoint();
History.SetSelection(new Asc.Range(oBBox.c1, oBBox.r1, oBBox.c2, oBBox.r2)); History.SetSelection(new Asc.Range(oBBox.c1, oBBox.r1, oBBox.c2, oBBox.r2));
History.StartTransaction(); History.StartTransaction();
if(false == this.worksheet.workbook.bUndoChanges && false == this.worksheet.workbook.bRedoChanges)
{
var oShiftGet = mergeManager.shiftGet(this.bbox, false);
var aMerged = oShiftGet.elems;
if(null != aMerged.outer && aMerged.outer.length > 0) if(null != aMerged.outer && aMerged.outer.length > 0)
{ {
var bChanged = false; var bChanged = false;
...@@ -7386,6 +7404,7 @@ Range.prototype._shiftUpDown=function(bUp){ ...@@ -7386,6 +7404,7 @@ Range.prototype._shiftUpDown=function(bUp){
if(bChanged) if(bChanged)
oShiftGet = null; oShiftGet = null;
} }
}
//сдвигаем ячейки //сдвигаем ячейки
if(bUp) if(bUp)
{ {
...@@ -7401,7 +7420,7 @@ Range.prototype._shiftUpDown=function(bUp){ ...@@ -7401,7 +7420,7 @@ Range.prototype._shiftUpDown=function(bUp){
else else
this.worksheet._insertRowsBefore(oBBox.r1, nHeight); this.worksheet._insertRowsBefore(oBBox.r1, nHeight);
} }
if(false == this.worksheet.workbook.bUndoChanges) if(false == this.worksheet.workbook.bUndoChanges && false == this.worksheet.workbook.bRedoChanges)
{ {
mergeManager.shift(this.bbox, !bUp, false, oShiftGet); mergeManager.shift(this.bbox, !bUp, false, oShiftGet);
this.worksheet.hyperlinkManager.shift(this.bbox, !bUp, false); this.worksheet.hyperlinkManager.shift(this.bbox, !bUp, false);
...@@ -7802,7 +7821,7 @@ Range.prototype._sortByArray=function(oBBox, aSortData, bUndo){ ...@@ -7802,7 +7821,7 @@ Range.prototype._sortByArray=function(oBBox, aSortData, bUndo){
for(var i = 0, length = aSortedHyperlinks.length; i < length; i++) for(var i = 0, length = aSortedHyperlinks.length; i < length; i++)
{ {
var hyp = aSortedHyperlinks[i]; var hyp = aSortedHyperlinks[i];
this.worksheet.hyperlinkManager.add(hyp.Ref.getBBox0(), hyp); this.worksheet.hyperlinkManager.add(hyp.Ref.getBBox0(), hyp, false);
} }
} }
}; };
......
...@@ -3332,7 +3332,7 @@ function RangeDataManager(bAllowIntersect, fChange) ...@@ -3332,7 +3332,7 @@ function RangeDataManager(bAllowIntersect, fChange)
this.fChange = fChange; this.fChange = fChange;
} }
RangeDataManager.prototype = { RangeDataManager.prototype = {
add : function(bbox, data) add : function(bbox, data, bTriggerEvent)
{ {
var oNewElem = new RangeDataManagerElem(new Asc.Range(bbox.c1, bbox.r1, bbox.c2, bbox.r2), data); var oNewElem = new RangeDataManagerElem(new Asc.Range(bbox.c1, bbox.r1, bbox.c2, bbox.r2), data);
oNewElem.id = this.idGen++; oNewElem.id = this.idGen++;
...@@ -3409,6 +3409,8 @@ RangeDataManager.prototype = { ...@@ -3409,6 +3409,8 @@ RangeDataManager.prototype = {
} }
this.oElements[this._getBBoxIndex(bbox)] = oNewElem; this.oElements[this._getBBoxIndex(bbox)] = oNewElem;
this._recalculate(); this._recalculate();
if(false != bTriggerEvent)
this.fChange.call(this, oNewElem.data, null, oNewElem.bbox);
}, },
_getExecElem : function(elem, oFindElems) _getExecElem : function(elem, oFindElems)
{ {
...@@ -3679,10 +3681,10 @@ RangeDataManager.prototype = { ...@@ -3679,10 +3681,10 @@ RangeDataManager.prototype = {
} }
else if(c_oRangeType.All == nRangeType) else if(c_oRangeType.All == nRangeType)
this.oAll = this._removeExecElem(this.oAll, null, elemToDelete); this.oAll = this._removeExecElem(this.oAll, null, elemToDelete);
if(false != bTriggerEvent)
this.fChange.call(this, elemToDelete.data, elemToDelete.bbox, null);
delete this.oElements[this._getBBoxIndex(elemToDelete.bbox)]; delete this.oElements[this._getBBoxIndex(elemToDelete.bbox)];
this._recalculate(); this._recalculate();
if(false != bTriggerEvent)
this.fChange.call(this, elemToDelete.data, elemToDelete.bbox, null);
} }
else else
{ {
......
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