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

Дополнение к Revision: 51206

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@51226 954022d7-b5bf-4e40-9824-e11837661b57
parent 61e2a5b8
......@@ -3305,7 +3305,6 @@ UndoRedoWoorksheet.prototype = {
from = to;
to = temp;
}
var data = 1;
if(null != from && null != from.r1 && null != from.c1 && null != from.r2 && null != from.c2)
{
var aMerged = ws.mergeManager.get(from);
......@@ -3314,14 +3313,14 @@ UndoRedoWoorksheet.prototype = {
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(merged.bbox, merged);
break;
}
}
}
var data = 1;
if(null != to && null != to.r1 && null != to.c1 && null != to.r2 && null != to.c2)
ws.mergeManager.add(to, data, false);
ws.mergeManager.add(to, data);
}
else if(historyitem_Worksheet_ChangeHyperlink === Type){
var from = null;
......@@ -3337,7 +3336,7 @@ UndoRedoWoorksheet.prototype = {
to = temp;
}
//не делаем clone потому что предполагаем, что здесь могут быть только операции изменения рзмеров, перемещение или удаления одной ссылки
var data = Data.hyperlink;
var data = null;
if(null != from && null != from.r1 && null != from.c1 && null != from.r2 && null != from.c2)
{
var aHyperlinks = ws.hyperlinkManager.get(from);
......@@ -3346,16 +3345,18 @@ UndoRedoWoorksheet.prototype = {
var hyp = aHyperlinks.inner[i];
if(hyp.bbox.isEqual(from))
{
var elem = new RangeDataManagerElem(from, data);
ws.hyperlinkManager.remove(elem.bbox, elem, false);
data = hyp.data;
ws.hyperlinkManager.remove(hyp.bbox, hyp);
break;
}
}
}
if(null != to && null != to.r1 && null != to.c1 && null != to.r2 && null != to.c2)
if(null == data)
data = Data.hyperlink;
if(null != data && 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);
ws.hyperlinkManager.add(to, data);
}
}
}
......
......@@ -2177,7 +2177,7 @@ function Woorksheet(wb, _index, bAddUserId, sId){
this.aCommentsCoords = new Array();
var oThis = this;
this.mergeManager = new RangeDataManager(false, function(data, from, to){
if(null != from || null != to)
if(History.Is_On() && (null != from || null != to))
{
if(null != from)
from = from.clone();
......@@ -2190,20 +2190,22 @@ function Woorksheet(wb, _index, bAddUserId, sId){
}
});
this.hyperlinkManager = new RangeDataManager(true, function(data, from, to){
if(null != from || null != to)
if(History.Is_On() && (null != from || null != to))
{
if(null != from)
from = from.clone();
if(null != to)
{
to = to.clone();
data.Ref = oThis.getRange3(to.r1, to.c1, to.r2, to.c2);
}
var oHistoryRange = from;
if(null == oHistoryRange)
oHistoryRange = to;
History.Add(g_oUndoRedoWorksheet, historyitem_Worksheet_ChangeHyperlink, oThis.getId(), oHistoryRange, new UndoRedoData_FromToHyperlink(from, to, data));
var oHistoryData = null;
if(null == from || null == to)
oHistoryData = data.clone();
History.Add(g_oUndoRedoWorksheet, historyitem_Worksheet_ChangeHyperlink, oThis.getId(), oHistoryRange, new UndoRedoData_FromToHyperlink(from, to, oHistoryData));
}
if(null != to)
data.Ref = oThis.getRange3(to.r1, to.c1, to.r2, to.c2);
});
this.hyperlinkManager.setDependenceManager(this.mergeManager);
......@@ -3595,6 +3597,8 @@ Woorksheet.prototype._moveRange=function(oBBoxFrom, oBBoxTo){
}
}
}
if(false == this.workbook.bUndoChanges && false == this.workbook.bRedoChanges)
{
var aMerged = this.mergeManager.get(oBBoxFrom);
if(aMerged.inner.length > 0)
{
......@@ -3602,7 +3606,7 @@ Woorksheet.prototype._moveRange=function(oBBoxFrom, oBBoxTo){
for(var i = 0, length = aTempObj.merged.length; i < length; i++)
{
var elem = aTempObj.merged[i];
this.mergeManager.remove(elem.bbox, elem, false);
this.mergeManager.remove(elem.bbox, elem);
}
}
var aHyperlinks = this.hyperlinkManager.get(oBBoxFrom);
......@@ -3612,7 +3616,8 @@ Woorksheet.prototype._moveRange=function(oBBoxFrom, oBBoxTo){
for(var i = 0, length = aTempObj.hyperlinks.length; i < length; i++)
{
var elem = aTempObj.hyperlinks[i];
this.hyperlinkManager.remove(elem.bbox, elem, false);
this.hyperlinkManager.remove(elem.bbox, elem);
}
}
}
//удаляем to через историю, для undo
......@@ -3662,13 +3667,16 @@ Woorksheet.prototype._moveRange=function(oBBoxFrom, oBBoxTo){
// this.renameDependencyNodes( offset, oBBoxFrom );
// buildRecalc(this.workbook);
// unLockDraw(this.workbook);
History.TurnOn();
if(false == this.workbook.bUndoChanges && false == this.workbook.bRedoChanges)
{
if(null != aTempObj.merged)
{
for(var i = 0, length = aTempObj.merged.length; i < length; i++)
{
var elem = aTempObj.merged[i];
elem.bbox.setOffset(offset);
this.mergeManager.add(elem.bbox, elem.data, false);
this.mergeManager.add(elem.bbox, elem.data);
}
}
if(null != aTempObj.hyperlinks)
......@@ -3677,8 +3685,8 @@ Woorksheet.prototype._moveRange=function(oBBoxFrom, oBBoxTo){
{
var elem = aTempObj.hyperlinks[i];
elem.bbox.setOffset(offset);
elem.data.Ref.setOffset(offset);
this.hyperlinkManager.add(elem.bbox, elem.data, false);
this.hyperlinkManager.add(elem.bbox, elem.data);
}
}
}
//расширяем границы
......@@ -3690,7 +3698,6 @@ Woorksheet.prototype._moveRange=function(oBBoxFrom, oBBoxTo){
this.nRowsCount = oBBoxTo.r2 + 1;
if(oBBoxTo.c2 > this.nColsCount)
this.nColsCount = oBBoxTo.c2 + 1;
History.TurnOn();
History.Add(g_oUndoRedoWorksheet, historyitem_Worksheet_MoveRange,
this.getId(), new Asc.Range(0, 0, gc_nMaxCol0, gc_nMaxRow0),
......@@ -6861,7 +6868,7 @@ Range.prototype.hasMerged=function(){
return null;
};
Range.prototype.mergeOpen=function(){
this.worksheet.mergeManager.add(this.bbox, 1, false);
this.worksheet.mergeManager.add(this.bbox, 1);
}
Range.prototype.merge=function(type){
if(null == type)
......@@ -7170,7 +7177,7 @@ Range.prototype.merge=function(type){
if(type == c_oAscMergeOptions.MergeCenter)
this.setAlignHorizontal("center");
if(false == this.worksheet.workbook.bUndoChanges && false == this.worksheet.workbook.bRedoChanges)
this.worksheet.mergeManager.add(this.bbox, 1, true);
this.worksheet.mergeManager.add(this.bbox, 1);
History.EndTransaction();
};
Range.prototype.unmerge=function(bOnlyInRange){
......@@ -7178,7 +7185,7 @@ Range.prototype.unmerge=function(bOnlyInRange){
History.SetSelection(this.bbox.clone());
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);
History.EndTransaction();
};
Range.prototype._getHyperlinks=function(){
......@@ -7251,7 +7258,7 @@ Range.prototype.getHyperlinks=function(){
Range.prototype.setHyperlinkOpen=function(val){
if(null != val && false == val.isValid())
return;
this.worksheet.hyperlinkManager.add(val.Ref.getBBox0(), val, false);
this.worksheet.hyperlinkManager.add(val.Ref.getBBox0(), val);
}
Range.prototype.setHyperlink=function(val, bWithoutStyle){
if(null != val && false == val.isValid())
......@@ -7281,7 +7288,7 @@ Range.prototype.setHyperlink=function(val, bWithoutStyle){
{
var hyp = aHyperlinks.all[i];
if(hyp.bbox.isEqual(this.bbox))
this.worksheet.hyperlinkManager.remove(hyp.bbox, hyp, true);
this.worksheet.hyperlinkManager.remove(hyp.bbox, hyp);
}
}
//todo перейти на CellStyle
......@@ -7295,7 +7302,7 @@ Range.prototype.setHyperlink=function(val, bWithoutStyle){
this.setFont(oHyperlinkFont);
}
if(false == this.worksheet.workbook.bUndoChanges && false == this.worksheet.workbook.bRedoChanges)
this.worksheet.hyperlinkManager.add(val.Ref.getBBox0(), val, true);
this.worksheet.hyperlinkManager.add(val.Ref.getBBox0(), val);
History.EndTransaction();
}
};
......@@ -7311,7 +7318,7 @@ Range.prototype.removeHyperlink=function(val){
History.SetSelection(bbox.clone());
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);
History.EndTransaction();
}
Range.prototype.deleteCellsShiftUp=function(){
......@@ -7349,7 +7356,7 @@ Range.prototype._shiftLeftRight=function(bLeft){
var elem = aMerged.outer[i];
if(!(elem.bbox.c1 < oShiftGet.bbox.c1 && oShiftGet.bbox.r1 <= elem.bbox.r1 && elem.bbox.r2 <= oShiftGet.bbox.r2))
{
mergeManager.remove(elem.bbox, elem, true);
mergeManager.remove(elem.bbox, elem);
bChanged = true;
}
}
......@@ -7403,7 +7410,7 @@ Range.prototype._shiftUpDown=function(bUp){
var elem = aMerged.outer[i];
if(!(elem.bbox.r1 < oShiftGet.bbox.r1 && oShiftGet.bbox.c1 <= elem.bbox.c1 && elem.bbox.c2 <= oShiftGet.bbox.c2))
{
mergeManager.remove(elem.bbox, elem, true);
mergeManager.remove(elem.bbox, elem);
bChanged = true;
}
}
......@@ -7730,8 +7737,10 @@ Range.prototype._sortByArray=function(oBBox, aSortData, bUndo){
oSortedIndexes[nFrom] = nTo;
}
//сортируются только одинарные гиперссылки, все неодинарные оставляем
var aHyperlinks = this.worksheet.hyperlinkManager.get(this.bbox);
var aSortedHyperlinks = new Array();
if(false == this.worksheet.workbook.bUndoChanges && false == this.worksheet.workbook.bRedoChanges)
{
var aHyperlinks = this.worksheet.hyperlinkManager.get(this.bbox);
for(var i = 0, length = aHyperlinks.inner.length; i < length; i++)
{
var elem = aHyperlinks.inner[i];
......@@ -7744,13 +7753,14 @@ Range.prototype._sortByArray=function(oBBox, aSortData, bUndo){
{
//удаляем ссылки, а не перемеаем, чтобы не было конфликтов(например в случае если все ячейки имеют ссылки и их надо передвинуть)
var oTempBBox = hyp.Ref.getBBox0();
this.worksheet.hyperlinkManager.remove(oTempBBox, new RangeDataManagerElem(oTempBBox, hyp), false);
this.worksheet.hyperlinkManager.remove(oTempBBox, new RangeDataManagerElem(oTempBBox, hyp));
var oNewHyp = hyp.clone();
oNewHyp.Ref.setOffset({offsetCol: 0, offsetRow: nTo - nFrom});
aSortedHyperlinks.push(oNewHyp);
}
}
}
}
//окончательно устанавливаем ячейки
var nColFirst0 = oBBox.c1;
var nLastCol0 = oBBox.c2;
......@@ -7821,13 +7831,16 @@ Range.prototype._sortByArray=function(oBBox, aSortData, bUndo){
// this.worksheet.workbook.needRecalc = rec;
// recalc(this.worksheet.workbook);
if(false == this.worksheet.workbook.bUndoChanges && false == this.worksheet.workbook.bRedoChanges)
{
//восстанавливаем удаленые гиперссылки
if(aSortedHyperlinks.length > 0)
{
for(var i = 0, length = aSortedHyperlinks.length; i < length; i++)
{
var hyp = aSortedHyperlinks[i];
this.worksheet.hyperlinkManager.add(hyp.Ref.getBBox0(), hyp, false);
this.worksheet.hyperlinkManager.add(hyp.Ref.getBBox0(), hyp);
}
}
}
};
......
......@@ -3332,7 +3332,7 @@ function RangeDataManager(bAllowIntersect, fChange)
this.fChange = fChange;
}
RangeDataManager.prototype = {
add : function(bbox, data, bTriggerEvent)
add : function(bbox, data)
{
var oNewElem = new RangeDataManagerElem(new Asc.Range(bbox.c1, bbox.r1, bbox.c2, bbox.r2), data);
oNewElem.id = this.idGen++;
......@@ -3409,7 +3409,7 @@ RangeDataManager.prototype = {
}
this.oElements[this._getBBoxIndex(bbox)] = oNewElem;
this._recalculate();
if(false != bTriggerEvent)
if(null != this.fChange)
this.fChange.call(this, oNewElem.data, null, oNewElem.bbox);
},
_getExecElem : function(elem, oFindElems)
......@@ -3652,7 +3652,7 @@ RangeDataManager.prototype = {
}
return container;
},
remove : function(bbox, elemToDelete, bTriggerEvent)
remove : function(bbox, elemToDelete)
{
if(null != elemToDelete)
{
......@@ -3683,7 +3683,7 @@ RangeDataManager.prototype = {
this.oAll = this._removeExecElem(this.oAll, null, elemToDelete);
delete this.oElements[this._getBBoxIndex(elemToDelete.bbox)];
this._recalculate();
if(false != bTriggerEvent)
if(null != this.fChange)
this.fChange.call(this, elemToDelete.data, elemToDelete.bbox, null);
}
else
......@@ -3693,7 +3693,7 @@ RangeDataManager.prototype = {
for(var i = 0, length = aElems.all.length; i < length; ++i)
{
var elem = aElems.all[i];
this.remove(elem.bbox, elem, bTriggerEvent);
this.remove(elem.bbox, elem);
}
this.startRecalculate();
}
......@@ -3812,11 +3812,7 @@ RangeDataManager.prototype = {
{
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);
this.remove(elem.bbox, elem);
}
//добавляем измененные ячейки
for(var i = 0, length = aToChange.length; i < length; ++i)
......
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