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

Изменена структура хранения гиперссылок и merged ячеек для ускорения.Изменена...

Изменена структура хранения гиперссылок и merged ячеек для ускорения.Изменена функция moveRange,чтобы ее можно было использовать и на undo.

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@50149 954022d7-b5bf-4e40-9824-e11837661b57
parent d9eee431
......@@ -32,6 +32,8 @@ var historyitem_Worksheet_CreateCol = 21;
var historyitem_Worksheet_CreateCell = 22;
var historyitem_Worksheet_SetViewSettings = 23;
var historyitem_Worksheet_RemoveCellFormula = 24;
var historyitem_Worksheet_ChangeMerge = 25;
var historyitem_Worksheet_ChangeHyperlink = 26;
var historyitem_RowCol_Fontname = 1;
var historyitem_RowCol_Fontsize = 2;
......
......@@ -2152,8 +2152,6 @@ function BinaryWorksheetsTableWriter(memory, wb, oSharedStrings, oDrawings, aDxf
this.nBorderMapIndex = 0;
this.oNumMap = new Object();
this.nNumMapIndex = 0;
this.oMerged = new Object();
this.oHyperlinks = new Object();
this.idWorksheet = idWorksheet;
this.oAllColXfsId = null;
this._getCrc32FromObjWithProperty = function(val)
......@@ -2207,8 +2205,6 @@ function BinaryWorksheetsTableWriter(memory, wb, oSharedStrings, oDrawings, aDxf
for(var i = 0, length = this.wb.aWorksheets.length; i < length; ++i)
{
var ws = this.wb.aWorksheets[i];
this.oMerged = new Object();
this.oHyperlinks = new Object();
if(null == this.idWorksheet || this.idWorksheet == ws.getId())
this.bs.WriteItem(c_oSerWorksheetsTypes.Worksheet, function(){oThis.WriteWorksheet(ws, i);});
}
......@@ -2239,9 +2235,9 @@ function BinaryWorksheetsTableWriter(memory, wb, oSharedStrings, oDrawings, aDxf
this.bs.WriteItem(c_oSerWorksheetsTypes.SheetData, function(){oThis.WriteSheetData(ws);});
this.bs.WriteItem(c_oSerWorksheetsTypes.Hyperlinks, function(){oThis.WriteHyperlinks();});
this.bs.WriteItem(c_oSerWorksheetsTypes.Hyperlinks, function(){oThis.WriteHyperlinks(ws);});
this.bs.WriteItem(c_oSerWorksheetsTypes.MergeCells, function(){oThis.WriteMergeCells();});
this.bs.WriteItem(c_oSerWorksheetsTypes.MergeCells, function(){oThis.WriteMergeCells(ws);});
if ( ws.Drawings && (ws.Drawings.length) )
this.bs.WriteItem(c_oSerWorksheetsTypes.Drawings, function(){oThis.WriteDrawings(ws.Drawings);});
......@@ -2294,7 +2290,6 @@ function BinaryWorksheetsTableWriter(memory, wb, oSharedStrings, oDrawings, aDxf
aIndexes.push(i - 0);
aIndexes.sort(fSortAscending);
var fInitCol = function(col, nMin, nMax){
oThis.AddToMergedAndHyperlink(col);
var oRes = {BestFit: col.BestFit, hd: col.hd, Max: nMax, Min: nMin, xfsid: null, width: col.width, CustomWidth: col.CustomWidth};
if(null == oRes.width)
{
......@@ -2591,13 +2586,15 @@ function BinaryWorksheetsTableWriter(memory, wb, oSharedStrings, oDrawings, aDxf
this.memory.WriteBool(bHeadings);
}
};
this.WriteHyperlinks = function()
this.WriteHyperlinks = function(ws)
{
var oThis = this;
for(var i in this.oHyperlinks)
var oHyperlinks = ws.hyperlinkManager.getAll();
//todo sort
for(var i in oHyperlinks)
{
var hyp = this.oHyperlinks[i];
this.bs.WriteItem(c_oSerWorksheetsTypes.Hyperlink, function(){oThis.WriteHyperlink(hyp);});
var elem = oHyperlinks[i];
this.bs.WriteItem(c_oSerWorksheetsTypes.Hyperlink, function(){oThis.WriteHyperlink(elem.data);});
}
};
this.WriteHyperlink = function(oHyperlink)
......@@ -2623,13 +2620,21 @@ function BinaryWorksheetsTableWriter(memory, wb, oSharedStrings, oDrawings, aDxf
this.memory.WriteString2(oHyperlink.Tooltip);
}
};
this.WriteMergeCells = function()
this.WriteMergeCells = function(ws)
{
var oThis = this;
for(var i in this.oMerged)
var oMerged = ws.mergeManager.getAll();
for(var i in oMerged)
{
var elem = oMerged[i];
var bbox = elem.bbox;
if(bbox.r1 != bbox.r2 || bbox.c1 != bbox.c2)
{
var oFirst = new CellAddress(bbox.r1, bbox.c1, 0);
var oLast = new CellAddress(bbox.r2, bbox.c2, 0);
this.memory.WriteByte(c_oSerWorksheetsTypes.MergeCell);
this.memory.WriteString2(i);
this.memory.WriteString2(oFirst.getID() + ":" + oLast.getID());
}
}
};
this.WriteDrawings = function(aDrawings)
......@@ -2744,7 +2749,6 @@ function BinaryWorksheetsTableWriter(memory, wb, oSharedStrings, oDrawings, aDxf
var row = ws.aGCells[aIndexes[i]];
if(null != row)
{
this.AddToMergedAndHyperlink(row);
if(false == row.isEmptyToSave())
this.bs.WriteItem(c_oSerWorksheetsTypes.Row, function(){oThis.WriteRow(row);});
}
......@@ -2801,8 +2805,7 @@ function BinaryWorksheetsTableWriter(memory, wb, oSharedStrings, oDrawings, aDxf
var cell = aCells[aIndexes[i]];
//готовим ячейку к записи
var nXfsId = this.prepareXfs(cell.xfs);
this.AddToMergedAndHyperlink(cell);
if(0 != nXfsId || false == cell.isEmptyText() || null != cell.merged || cell.hyperlinks.length > 0)
if(0 != nXfsId || false == cell.isEmptyText())
this.bs.WriteItem(c_oSerRowTypes.Cell, function(){oThis.WriteCell(cell, nXfsId);});
}
};
......@@ -2921,19 +2924,6 @@ function BinaryWorksheetsTableWriter(memory, wb, oSharedStrings, oDrawings, aDxf
}
return nXfsId;
};
this.AddToMergedAndHyperlink = function(container)
{
if(null != container.merged)
this.oMerged[container.merged.getName()] = 1;
if(null != container.hyperlinks)
{
for(var i = 0, length = container.hyperlinks.length; i < length; ++i)
{
var hyperlink = container.hyperlinks[i];
this.oHyperlinks[hyperlink.Ref.getName()] = hyperlink;
}
}
}
this.WriteCell = function(cell, nXfsId)
{
var oThis = this;
......@@ -5020,7 +5010,7 @@ function Binary_WorksheetTableReader(stream, wb, aSharedStrings, aCellXfs, Dxfs,
{
var hyperlink = this.aHyperlinks[i];
if (null !== hyperlink.Ref)
hyperlink.Ref.setHyperlink(hyperlink, true);
hyperlink.Ref.setHyperlinkOpen(hyperlink);
}
oNewWorksheet.init();
this.wb.aWorksheets.push(oNewWorksheet);
......
......@@ -3154,98 +3154,15 @@ UndoRedoWoorksheet.prototype = {
}
else if(historyitem_Worksheet_MoveRange == Type)
{
if( bUndo ){
var rec = {length:0}, rec2;
for(var ind = 0; ind < Data.arr.to.length; ind++ ){
var nRow = Data.arr.to[ind].getCellAddress().getRow0(),
nCol = Data.arr.to[ind].getCellAddress().getCol0();
var c = ws._getCell(nRow, nCol)
if( c.sFormula ){
this.wb.cwf[ws.Id].cells[c.getName()] = null;
delete this.wb.cwf[ws.Id].cells[ c.getName()];
}
var oTargetRow = ws._getRow(nRow);
if(Data.arr.to[ind].isEmpty()){
delete oTargetRow.c[nCol];
continue;
}
else{
var sn = ws.workbook.dependencyFormulas.getSlaveNodes(ws.Id,Data.arr.to[ind].getName())
if( sn ){
for( var _id in sn){
rec[_id] = [ sn[_id].sheetId, sn[_id].cellId ];
rec.length++;
}
}
oTargetRow.c[nCol] = Data.arr.to[ind];
if( oTargetRow.c[nCol].sFormula ){
this.wb.cwf[ws.Id].cells[ oTargetRow.c[nCol].getName() ] = oTargetRow.c[nCol].getName();
rec[ getVertexId(ws.Id,oTargetRow.c[nCol].getName()) ] = [ ws.Id, oTargetRow.c[nCol].getName() ];
rec.length++;
}
}
}
for(var ind = 0; ind < Data.arr.from.length; ind++ ){
var nRow = Data.arr.from[ind].getCellAddress().getRow0(),
nCol = Data.arr.from[ind].getCellAddress().getCol0();
var c = ws._getCell(nRow, nCol)
if( c.sFormula ){
this.wb.cwf[ws.Id].cells[c.getName()] = null;
delete this.wb.cwf[ws.Id].cells[ c.getName()];
}
var oTargetRow = ws._getRow(nRow);
if(Data.arr.from[ind].isEmpty()){
delete oTargetRow.c[nCol];
continue;
}
else{
var sn = ws.workbook.dependencyFormulas.getSlaveNodes(ws.Id,Data.arr.from[ind].getName())
if( sn ){
for( var _id in sn){
rec[_id] = [ sn[_id].sheetId, sn[_id].cellId ];
rec.length++;
}
}
oTargetRow.c[nCol] = Data.arr.from[ind];
if( oTargetRow.c[nCol].sFormula ){
this.wb.cwf[ws.Id].cells[ oTargetRow.c[nCol].getName() ] = oTargetRow.c[nCol].getName();
rec[ getVertexId(ws.Id,oTargetRow.c[nCol].getName()) ] = [ ws.Id, oTargetRow.c[nCol].getName() ];
rec.length++;
}
}
}
var offset = { offsetRow : Data.from.r1 - Data.to.r1, offsetCol : Data.from.c1 - Data.to.c1 }
rec2 = ws._moveRecalcGraph(Data.to, offset);
this.wb.buildDependency();
rec.length += rec2.length;
for( var id in rec2 ){
if( id == "length" ) continue;
rec[id] = rec2[id];
}
this.wb.needRecalc = rec;
recalc(this.wb);
if(g_oUndoRedoAutoFiltersMoveData)
//todo worksheetView.autoFilters._moveAutoFilters(worksheetView ,null, null, g_oUndoRedoAutoFiltersMoveData);
var from = Data.from;
var to = Data.to;
if(bUndo)
{
var worksheetView = this.wb.oApi.wb.getWorksheetById(nSheetId);
worksheetView.autoFilters._moveAutoFilters(worksheetView ,null, null, g_oUndoRedoAutoFiltersMoveData);
g_oUndoRedoAutoFiltersMoveData = null;
}
var temp = from;
from = to;
to = temp;
}
else{
if(false != this.wb.bCollaborativeChanges)
{
var collaborativeEditing = this.wb.oApi.collaborativeEditing,
......@@ -3253,20 +3170,28 @@ UndoRedoWoorksheet.prototype = {
coBBoxTo = {r1:0,c1:0,r2:0,c2:0 },
coBBoxFrom = {r1:0,c1:0,r2:0,c2:0 };
coBBoxTo.r1 = collaborativeEditing.getLockOtherRow2( nSheetId, Data.to.r1);
coBBoxTo.c1 = collaborativeEditing.getLockOtherColumn2( nSheetId, Data.to.c1);
coBBoxTo.r2 = collaborativeEditing.getLockOtherRow2( nSheetId, Data.to.r2);
coBBoxTo.c2 = collaborativeEditing.getLockOtherColumn2( nSheetId, Data.to.c2);
coBBoxTo.r1 = collaborativeEditing.getLockOtherRow2( nSheetId, to.r1);
coBBoxTo.c1 = collaborativeEditing.getLockOtherColumn2( nSheetId, to.c1);
coBBoxTo.r2 = collaborativeEditing.getLockOtherRow2( nSheetId, to.r2);
coBBoxTo.c2 = collaborativeEditing.getLockOtherColumn2( nSheetId, to.c2);
coBBoxFrom.r1 = collaborativeEditing.getLockOtherRow2( nSheetId, Data.from.r1);
coBBoxFrom.c1 = collaborativeEditing.getLockOtherColumn2( nSheetId, Data.from.c1);
coBBoxFrom.r2 = collaborativeEditing.getLockOtherRow2( nSheetId, Data.from.r2);
coBBoxFrom.c2 = collaborativeEditing.getLockOtherColumn2( nSheetId, Data.from.c2);
coBBoxFrom.r1 = collaborativeEditing.getLockOtherRow2( nSheetId, from.r1);
coBBoxFrom.c1 = collaborativeEditing.getLockOtherColumn2( nSheetId, from.c1);
coBBoxFrom.r2 = collaborativeEditing.getLockOtherRow2( nSheetId, from.r2);
coBBoxFrom.c2 = collaborativeEditing.getLockOtherColumn2( nSheetId, from.c2);
ws._moveRange(coBBoxFrom, coBBoxTo);
}
else{
ws._moveRange(Data.from, Data.to);
ws._moveRange(from, to);
}
if(bUndo)
{
if(g_oUndoRedoAutoFiltersMoveData)
{
var worksheetView = this.wb.oApi.wb.getWorksheetById(nSheetId);
worksheetView.autoFilters._moveAutoFilters(worksheetView ,null, null, g_oUndoRedoAutoFiltersMoveData);
g_oUndoRedoAutoFiltersMoveData = null;
}
}
}
......@@ -3309,7 +3234,7 @@ UndoRedoWoorksheet.prototype = {
if(bUndo)
Ref.removeHyperlink(Data);
else
Ref.setHyperlink(Data);
Ref.setHyperlink(Data, true);
}
else if(historyitem_Worksheet_Rename == Type)
{
......
This diff is collapsed.
This diff is collapsed.
......@@ -226,6 +226,10 @@
return this.c1 <= c && c <= this.c2 && this.r1 <= r && r <= this.r2;
},
containsRange: function (range) {
return this.contains(range.c1, range.r1) && this.contains(range.c2, range.r2);
},
intersection: function (range) {
var s1 = this.clone(true),
s2 = range instanceof Range ? range.clone(true) :
......@@ -240,6 +244,17 @@
Math.min(s1.r2, s2.r2));
},
intersectionSimple: function (range) {
var oRes = null;
var r1 = Math.max(this.r1, range.r1);
var c1 = Math.max(this.c1, range.c1);
var r2 = Math.min(this.r2, range.r2);
var c2 = Math.min(this.c2, range.c2);
if(r1 <= r2 && c1 <= c2)
oRes = new Range(c1, r1, c2, r2);
return oRes;
},
union: function (range) {
var s1 = this.clone(true),
s2 = range instanceof Range ? range.clone(true) :
......@@ -255,6 +270,29 @@
this.c2 = Math.max(this.c2, range.c2);
this.r1 = Math.min(this.r1, range.r1);
this.r2 = Math.max(this.r2, range.r2);
},
setOffset : function(offset){
this.setOffsetFirst(offset);
this.setOffsetLast(offset);
},
setOffsetFirst : function(offset){
this.c1 += offset.offsetCol;
if( this.c1 < 0 )
this.c1 = 0;
this.r1 += offset.offsetRow;
if( this.r1 < 0 )
this.r1 = 0;
},
setOffsetLast : function(offset){
this.c2 += offset.offsetCol;
if( this.c2 < 0 )
this.c2 = 0;
this.r2 += offset.offsetRow;
if( this.r2 < 0 )
this.r2 = 0;
}
};
......
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