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

RedBlackTree для RangeDataManager

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@52785 954022d7-b5bf-4e40-9824-e11837661b57
parent 12c0509c
...@@ -5049,9 +5049,6 @@ function Binary_WorksheetTableReader(stream, wb, aSharedStrings, aCellXfs, Dxfs, ...@@ -5049,9 +5049,6 @@ function Binary_WorksheetTableReader(stream, wb, aSharedStrings, aCellXfs, Dxfs,
this.aMerged = new Array(); this.aMerged = new Array();
this.aHyperlinks = new Array(); this.aHyperlinks = new Array();
var oNewWorksheet = new Woorksheet(this.wb, wb.aWorksheets.length, false); var oNewWorksheet = new Woorksheet(this.wb, wb.aWorksheets.length, false);
//отключаем пересчет на открытие, потому что может быть много обьектов
oNewWorksheet.mergeManager.stopRecalculate();
oNewWorksheet.hyperlinkManager.stopRecalculate();
res = this.bcr.Read1(length, function(t,l){ res = this.bcr.Read1(length, function(t,l){
return oThis.ReadWorksheet(t,l, oNewWorksheet); return oThis.ReadWorksheet(t,l, oNewWorksheet);
}); });
......
...@@ -3326,7 +3326,7 @@ UndoRedoWoorksheet.prototype = { ...@@ -3326,7 +3326,7 @@ UndoRedoWoorksheet.prototype = {
var merged = aMerged.inner[i]; var merged = aMerged.inner[i];
if(merged.bbox.isEqual(from)) if(merged.bbox.isEqual(from))
{ {
ws.mergeManager.remove(merged.bbox, merged); ws.mergeManager.removeElement(merged);
break; break;
} }
} }
...@@ -3359,7 +3359,7 @@ UndoRedoWoorksheet.prototype = { ...@@ -3359,7 +3359,7 @@ UndoRedoWoorksheet.prototype = {
if(hyp.bbox.isEqual(from)) if(hyp.bbox.isEqual(from))
{ {
data = hyp.data; data = hyp.data;
ws.hyperlinkManager.remove(hyp.bbox, hyp); ws.hyperlinkManager.removeElement(hyp);
break; break;
} }
} }
......
...@@ -2161,7 +2161,7 @@ function Woorksheet(wb, _index, bAddUserId, sId){ ...@@ -2161,7 +2161,7 @@ function Woorksheet(wb, _index, bAddUserId, sId){
this.aComments = new Array(); this.aComments = new Array();
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(function(data, from, to){
if(History.Is_On() && (null != from || null != to)) if(History.Is_On() && (null != from || null != to))
{ {
if(null != from) if(null != from)
...@@ -2174,7 +2174,7 @@ function Woorksheet(wb, _index, bAddUserId, sId){ ...@@ -2174,7 +2174,7 @@ function Woorksheet(wb, _index, bAddUserId, sId){
History.Add(g_oUndoRedoWorksheet, historyitem_Worksheet_ChangeMerge, oThis.getId(), oHistoryRange, new UndoRedoData_FromTo(new UndoRedoData_BBox(from), new UndoRedoData_BBox(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(function(data, from, to){
if(History.Is_On() && (null != from || null != to)) if(History.Is_On() && (null != from || null != to))
{ {
if(null != from) if(null != from)
...@@ -2276,23 +2276,19 @@ Woorksheet.prototype.clone=function(sNewId){ ...@@ -2276,23 +2276,19 @@ Woorksheet.prototype.clone=function(sNewId){
for(var i in this.aGCells) for(var i in this.aGCells)
oNewWs.aGCells[i] = this.aGCells[i].clone(); oNewWs.aGCells[i] = this.aGCells[i].clone();
var aMerged = this.mergeManager.getAll(); var aMerged = this.mergeManager.getAll();
oNewWs.mergeManager.stopRecalculate();
for(var i in aMerged) for(var i in aMerged)
{ {
var elem = aMerged[i]; var elem = aMerged[i];
var range = oNewWs.getRange3(elem.bbox.r1, elem.bbox.c1, elem.bbox.r2, elem.bbox.c2); var range = oNewWs.getRange3(elem.bbox.r1, elem.bbox.c1, elem.bbox.r2, elem.bbox.c2);
range.mergeOpen(); range.mergeOpen();
} }
oNewWs.mergeManager.startRecalculate();
var aHyperlinks = this.hyperlinkManager.getAll(); var aHyperlinks = this.hyperlinkManager.getAll();
oNewWs.hyperlinkManager.stopRecalculate();
for(var i in aHyperlinks) for(var i in aHyperlinks)
{ {
var elem = aHyperlinks[i]; var elem = aHyperlinks[i];
var range = oNewWs.getRange3(elem.bbox.r1, elem.bbox.c1, elem.bbox.r2, elem.bbox.c2); var range = oNewWs.getRange3(elem.bbox.r1, elem.bbox.c1, elem.bbox.r2, elem.bbox.c2);
range.setHyperlinkOpen(elem.data); range.setHyperlinkOpen(elem.data);
} }
oNewWs.hyperlinkManager.startRecalculate();
if(null != this.Drawings && this.Drawings.length > 0) if(null != this.Drawings && this.Drawings.length > 0)
{ {
oNewWs.Drawings = []; oNewWs.Drawings = [];
...@@ -2435,8 +2431,6 @@ Woorksheet.prototype.init=function(){ ...@@ -2435,8 +2431,6 @@ Woorksheet.prototype.init=function(){
} }
}; };
Woorksheet.prototype.initPostOpen = function(){ Woorksheet.prototype.initPostOpen = function(){
this.mergeManager.startRecalculate();
this.hyperlinkManager.startRecalculate();
//chart //chart
if(null != this.Drawings) if(null != this.Drawings)
{ {
...@@ -3593,7 +3587,7 @@ Woorksheet.prototype._moveRange=function(oBBoxFrom, oBBoxTo, copyRange){ ...@@ -3593,7 +3587,7 @@ Woorksheet.prototype._moveRange=function(oBBoxFrom, oBBoxTo, copyRange){
for(var i = 0, length = aTempObj.merged.length; i < length; i++) for(var i = 0, length = aTempObj.merged.length; i < length; i++)
{ {
var elem = aTempObj.merged[i]; var elem = aTempObj.merged[i];
this.mergeManager.remove(elem.bbox, elem); this.mergeManager.removeElement(elem);
} }
} }
var aHyperlinks = this.hyperlinkManager.get(oBBoxFrom); var aHyperlinks = this.hyperlinkManager.get(oBBoxFrom);
...@@ -3603,7 +3597,7 @@ Woorksheet.prototype._moveRange=function(oBBoxFrom, oBBoxTo, copyRange){ ...@@ -3603,7 +3597,7 @@ Woorksheet.prototype._moveRange=function(oBBoxFrom, oBBoxTo, copyRange){
for(var i = 0, length = aTempObj.hyperlinks.length; i < length; i++) for(var i = 0, length = aTempObj.hyperlinks.length; i < length; i++)
{ {
var elem = aTempObj.hyperlinks[i]; var elem = aTempObj.hyperlinks[i];
this.hyperlinkManager.remove(elem.bbox, elem); this.hyperlinkManager.removeElement(elem);
} }
} }
} }
...@@ -7172,7 +7166,7 @@ Range.prototype.unmerge=function(bOnlyInRange){ ...@@ -7172,7 +7166,7 @@ Range.prototype.unmerge=function(bOnlyInRange){
History.Create_NewPoint(); History.Create_NewPoint();
History.StartTransaction(); History.StartTransaction();
if(false == this.worksheet.workbook.bUndoChanges && false == this.worksheet.workbook.bRedoChanges) if(false == this.worksheet.workbook.bUndoChanges && false == this.worksheet.workbook.bRedoChanges)
this.worksheet.mergeManager.remove(this.bbox, null); this.worksheet.mergeManager.remove(this.bbox);
History.EndTransaction(); History.EndTransaction();
}; };
Range.prototype._getHyperlinks=function(){ Range.prototype._getHyperlinks=function(){
...@@ -7274,7 +7268,7 @@ Range.prototype.setHyperlink=function(val, bWithoutStyle){ ...@@ -7274,7 +7268,7 @@ Range.prototype.setHyperlink=function(val, bWithoutStyle){
{ {
var hyp = aHyperlinks.all[i]; var hyp = aHyperlinks.all[i];
if(hyp.bbox.isEqual(this.bbox)) if(hyp.bbox.isEqual(this.bbox))
this.worksheet.hyperlinkManager.remove(hyp.bbox, hyp); this.worksheet.hyperlinkManager.removeElement(hyp);
} }
} }
//todo перейти на CellStyle //todo перейти на CellStyle
...@@ -7303,7 +7297,12 @@ Range.prototype.removeHyperlink=function(val){ ...@@ -7303,7 +7297,12 @@ Range.prototype.removeHyperlink=function(val){
History.Create_NewPoint(); History.Create_NewPoint();
History.StartTransaction(); History.StartTransaction();
if(false == this.worksheet.workbook.bUndoChanges && false == this.worksheet.workbook.bRedoChanges) if(false == this.worksheet.workbook.bUndoChanges && false == this.worksheet.workbook.bRedoChanges)
this.worksheet.hyperlinkManager.remove(bbox, elem); {
if(null != elem)
this.worksheet.hyperlinkManager.removeElement(elem);
else
this.worksheet.hyperlinkManager.remove(bbox);
}
History.EndTransaction(); History.EndTransaction();
} }
Range.prototype.deleteCellsShiftUp=function(){ Range.prototype.deleteCellsShiftUp=function(){
...@@ -7341,7 +7340,7 @@ Range.prototype._shiftLeftRight=function(bLeft){ ...@@ -7341,7 +7340,7 @@ Range.prototype._shiftLeftRight=function(bLeft){
var elem = aMerged.outer[i]; var elem = aMerged.outer[i];
if(!(elem.bbox.c1 < oShiftGet.bbox.c1 && oShiftGet.bbox.r1 <= elem.bbox.r1 && elem.bbox.r2 <= oShiftGet.bbox.r2)) if(!(elem.bbox.c1 < oShiftGet.bbox.c1 && oShiftGet.bbox.r1 <= elem.bbox.r1 && elem.bbox.r2 <= oShiftGet.bbox.r2))
{ {
mergeManager.remove(elem.bbox, elem); mergeManager.removeElement(elem);
bChanged = true; bChanged = true;
} }
} }
...@@ -7396,7 +7395,7 @@ Range.prototype._shiftUpDown=function(bUp){ ...@@ -7396,7 +7395,7 @@ Range.prototype._shiftUpDown=function(bUp){
var elem = aMerged.outer[i]; var elem = aMerged.outer[i];
if(!(elem.bbox.r1 < oShiftGet.bbox.r1 && oShiftGet.bbox.c1 <= elem.bbox.c1 && elem.bbox.c2 <= oShiftGet.bbox.c2)) if(!(elem.bbox.r1 < oShiftGet.bbox.r1 && oShiftGet.bbox.c1 <= elem.bbox.c1 && elem.bbox.c2 <= oShiftGet.bbox.c2))
{ {
mergeManager.remove(elem.bbox, elem); mergeManager.removeElement(elem);
bChanged = true; bChanged = true;
} }
} }
...@@ -7743,7 +7742,7 @@ Range.prototype._sortByArray=function(oBBox, aSortData, bUndo){ ...@@ -7743,7 +7742,7 @@ Range.prototype._sortByArray=function(oBBox, aSortData, bUndo){
{ {
//удаляем ссылки, а не перемеаем, чтобы не было конфликтов(например в случае если все ячейки имеют ссылки и их надо передвинуть) //удаляем ссылки, а не перемеаем, чтобы не было конфликтов(например в случае если все ячейки имеют ссылки и их надо передвинуть)
var oTempBBox = hyp.Ref.getBBox0(); var oTempBBox = hyp.Ref.getBBox0();
this.worksheet.hyperlinkManager.remove(oTempBBox, new RangeDataManagerElem(oTempBBox, hyp)); this.worksheet.hyperlinkManager.removeElement(new RangeDataManagerElem(oTempBBox, hyp));
var oNewHyp = hyp.clone(); var oNewHyp = hyp.clone();
oNewHyp.Ref.setOffset({offsetCol: 0, offsetRow: nTo - nFrom}); oNewHyp.Ref.setOffset({offsetCol: 0, offsetRow: nTo - nFrom});
aSortedHyperlinks.push(oNewHyp); aSortedHyperlinks.push(oNewHyp);
......
This diff is collapsed.
...@@ -254,6 +254,15 @@ ...@@ -254,6 +254,15 @@
oRes = new Range(c1, r1, c2, r2); oRes = new Range(c1, r1, c2, r2);
return oRes; return oRes;
}, },
isIntersect: function (range) {
var bRes = true;
if(range.r2 < this.r1 || this.r2 < range.r1)
bRes = false;
else if(range.c2 < this.c1 || this.c2 < range.c1)
bRes = false;
return bRes;
},
union: function (range) { union: function (range) {
var s1 = this.clone(true), var s1 = this.clone(true),
......
...@@ -7907,7 +7907,6 @@ ...@@ -7907,7 +7907,6 @@
var startCell = val.getCell( new CellAddress(activeCellsPasteFragment.r1, activeCellsPasteFragment.c1, 0)); var startCell = val.getCell( new CellAddress(activeCellsPasteFragment.r1, activeCellsPasteFragment.c1, 0));
val.mergeManager.bbox = startCell.bbox;
var isMergedStartCell = startCell.hasMerged(); var isMergedStartCell = startCell.hasMerged();
var firstValuesCol; var firstValuesCol;
...@@ -8036,8 +8035,7 @@ ...@@ -8036,8 +8035,7 @@
var startCell = val.getCell( new CellAddress(activeCellsPasteFragment.r1, activeCellsPasteFragment.c1, 0)); var startCell = val.getCell( new CellAddress(activeCellsPasteFragment.r1, activeCellsPasteFragment.c1, 0));
val.mergeManager.bbox = newVal.bbox curMerge = newVal.hasMerged();
curMerge = newVal.hasMerged()
if(undefined !== newVal) if(undefined !== newVal)
{ {
...@@ -8186,7 +8184,6 @@ ...@@ -8186,7 +8184,6 @@
if(angle) if(angle)
range.setAngle(angle); range.setAngle(angle);
val.hyperlinkManager.bbox = newVal.bbox;
var hyperLink = newVal.getHyperlink(); var hyperLink = newVal.getHyperlink();
if(hyperLink != null) if(hyperLink != null)
{ {
......
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