Commit 1fbf072f authored by Dmitry.Shahtanov's avatar Dmitry.Shahtanov Committed by Alexander.Trofimov

для Bug 18063 - Добавить возможность копирования диапазона с помощью Drag&Drop и зажатым Ctrl

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@52649 954022d7-b5bf-4e40-9824-e11837661b57
parent 663e3ba4
...@@ -608,13 +608,15 @@ UndoRedoData_FromToRowCol.prototype = { ...@@ -608,13 +608,15 @@ UndoRedoData_FromToRowCol.prototype = {
} }
}; };
function UndoRedoData_FromTo(from, to){ function UndoRedoData_FromTo(from, to, copyRange){
this.Properties = { this.Properties = {
from: 0, from: 0,
to: 1 to: 1,
copyRange: 2
}; };
this.from = from; this.from = from;
this.to = to; this.to = to;
this.copyRange = copyRange;
} }
UndoRedoData_FromTo.prototype = { UndoRedoData_FromTo.prototype = {
getType : function() getType : function()
...@@ -631,6 +633,7 @@ UndoRedoData_FromTo.prototype = { ...@@ -631,6 +633,7 @@ UndoRedoData_FromTo.prototype = {
{ {
case this.Properties.from: return this.from;break; case this.Properties.from: return this.from;break;
case this.Properties.to: return this.to;break; case this.Properties.to: return this.to;break;
case this.Properties.copyRange: return this.copyRange;break;
} }
}, },
setProperty : function(nType, value) setProperty : function(nType, value)
...@@ -639,6 +642,7 @@ UndoRedoData_FromTo.prototype = { ...@@ -639,6 +642,7 @@ UndoRedoData_FromTo.prototype = {
{ {
case this.Properties.from: this.from = value;break; case this.Properties.from: this.from = value;break;
case this.Properties.to: this.to = value;break; case this.Properties.to: this.to = value;break;
case this.Properties.copyRange: this.copyRange = value;break;
} }
} }
}; };
...@@ -3162,6 +3166,7 @@ UndoRedoWoorksheet.prototype = { ...@@ -3162,6 +3166,7 @@ UndoRedoWoorksheet.prototype = {
//todo worksheetView.autoFilters._moveAutoFilters(worksheetView ,null, null, g_oUndoRedoAutoFiltersMoveData); //todo worksheetView.autoFilters._moveAutoFilters(worksheetView ,null, null, g_oUndoRedoAutoFiltersMoveData);
var from = Asc.Range(Data.from.c1, Data.from.r1, Data.from.c2, Data.from.r2); var from = Asc.Range(Data.from.c1, Data.from.r1, Data.from.c2, Data.from.r2);
var to = Asc.Range(Data.to.c1, Data.to.r1, Data.to.c2, Data.to.r2); var to = Asc.Range(Data.to.c1, Data.to.r1, Data.to.c2, Data.to.r2);
var copyRange = Data.copyRange;
if(bUndo) if(bUndo)
{ {
...@@ -3186,10 +3191,10 @@ UndoRedoWoorksheet.prototype = { ...@@ -3186,10 +3191,10 @@ UndoRedoWoorksheet.prototype = {
coBBoxFrom.r2 = collaborativeEditing.getLockOtherRow2( nSheetId, from.r2); coBBoxFrom.r2 = collaborativeEditing.getLockOtherRow2( nSheetId, from.r2);
coBBoxFrom.c2 = collaborativeEditing.getLockOtherColumn2( nSheetId, from.c2); coBBoxFrom.c2 = collaborativeEditing.getLockOtherColumn2( nSheetId, from.c2);
ws._moveRange(coBBoxFrom, coBBoxTo); ws._moveRange(coBBoxFrom, coBBoxTo, copyRange);
} }
else{ else{
ws._moveRange(from, to); ws._moveRange(from, to, copyRange);
} }
var worksheetView = this.wb.oApi.wb.getWorksheetById(nSheetId); var worksheetView = this.wb.oApi.wb.getWorksheetById(nSheetId);
if(bUndo)//если на Undo перемещается диапазон из форматированной таблицы - стиль форматированной таблицы не должен цепляться if(bUndo)//если на Undo перемещается диапазон из форматированной таблицы - стиль форматированной таблицы не должен цепляться
......
...@@ -3555,7 +3555,7 @@ Woorksheet.prototype._moveRecalcGraph=function(oBBoxFrom, offset){ ...@@ -3555,7 +3555,7 @@ Woorksheet.prototype._moveRecalcGraph=function(oBBoxFrom, offset){
return rec; return rec;
} }
Woorksheet.prototype._moveRange=function(oBBoxFrom, oBBoxTo){ Woorksheet.prototype._moveRange=function(oBBoxFrom, oBBoxTo, copyRange){
if(oBBoxFrom.isEqual(oBBoxTo)) if(oBBoxFrom.isEqual(oBBoxTo))
return; return;
var oThis = this; var oThis = this;
...@@ -3575,12 +3575,16 @@ Woorksheet.prototype._moveRange=function(oBBoxFrom, oBBoxTo){ ...@@ -3575,12 +3575,16 @@ Woorksheet.prototype._moveRange=function(oBBoxFrom, oBBoxTo){
for(var j = oBBoxFrom.c1; j <= oBBoxFrom.c2; j++) for(var j = oBBoxFrom.c1; j <= oBBoxFrom.c2; j++)
{ {
var cell = row.c[j]; var cell = row.c[j];
if(null != cell) if(null != cell){
oTempRow[j + offset.offsetCol] = cell; if(copyRange)
oTempRow[j + offset.offsetCol] = cell.clone();
else
oTempRow[j + offset.offsetCol] = cell;
}
} }
} }
} }
if(false == this.workbook.bUndoChanges && false == this.workbook.bRedoChanges) if(false == this.workbook.bUndoChanges && false == this.workbook.bRedoChanges && !copyRange)
{ {
var aMerged = this.mergeManager.get(oBBoxFrom); var aMerged = this.mergeManager.get(oBBoxFrom);
if(aMerged.inner.length > 0) if(aMerged.inner.length > 0)
...@@ -3610,56 +3614,56 @@ Woorksheet.prototype._moveRange=function(oBBoxFrom, oBBoxTo){ ...@@ -3610,56 +3614,56 @@ Woorksheet.prototype._moveRange=function(oBBoxFrom, oBBoxTo){
//перемещаем без истории //перемещаем без истории
History.TurnOff(); History.TurnOff();
//удаляем from без истории, потому что эти данные не терются а перемещаются //удаляем from без истории, потому что эти данные не терются а перемещаются
var oRangeFrom = this.getRange3(oBBoxFrom.r1, oBBoxFrom.c1, oBBoxFrom.r2, oBBoxFrom.c2); var oRangeFrom = this.getRange3(oBBoxFrom.r1, oBBoxFrom.c1, oBBoxFrom.r2, oBBoxFrom.c2 ), rec = {length:0};
oRangeFrom._setPropertyNoEmpty(null, null, function(cell, nRow0, nCol0, nRowStart, nColStart){ if(!copyRange || (copyRange && this.workbook.bUndoChanges)){
var row = oThis._getRowNoEmpty(nRow0); oRangeFrom._setPropertyNoEmpty(null, null, function(cell, nRow0, nCol0, nRowStart, nColStart){
if(null != row) var row = oThis._getRowNoEmpty(nRow0);
delete row.c[nCol0]; if(null != row)
}); delete row.c[nCol0];
//lockDraw(this.workbook); });
var rec = this._moveRecalcGraph(oBBoxFrom, offset); }
for(var i in aTempObj.cells) if(!copyRange){
{ rec = this._moveRecalcGraph(oBBoxFrom, offset);
var oTempRow = aTempObj.cells[i]; }
var row = this._getRow(i - 0);
for(var j in oTempRow) for ( var i in aTempObj.cells ) {
{ var oTempRow = aTempObj.cells[i];
var oTempCell = oTempRow[j]; var row = this._getRow( i - 0 );
if(null != oTempCell) for ( var j in oTempRow ) {
{ var oTempCell = oTempRow[j];
oTempCell.moveHor(offset.offsetCol); if ( null != oTempCell ) {
oTempCell.moveVer(offset.offsetRow); oTempCell.moveHor( offset.offsetCol );
row.c[j] = oTempCell; oTempCell.moveVer( offset.offsetRow );
// var sFormula = oTempCell.getFormula(); row.c[j] = oTempCell;
// if("" != sFormula)
// oTempCell.setValue("=" + sFormula);
if( oTempCell.sFormula ){ if ( oTempCell.sFormula ) {
this.workbook.cwf[this.Id].cells[oTempCell.getName()] = oTempCell.getName(); this.workbook.cwf[this.Id].cells[oTempCell.getName()] = oTempCell.getName();
rec[ oTempCell.getName() ] = [ this.Id, oTempCell.getName() ]; rec[ oTempCell.getName() ] = [ this.Id, oTempCell.getName() ];
rec.length++; rec.length++;
if(copyRange){
oTempCell.formulaParsed = new parserFormula( oTempCell.sFormula, oTempCell.oId.getID(), this );
oTempCell.formulaParsed.parse();
oTempCell.formulaParsed = oTempCell.formulaParsed.changeOffset(offset);
oTempCell.sFormula = oTempCell.formulaParsed.assemble();
}
} }
} }
} }
} }
var move = this.workbook.dependencyFormulas.helper(oBBoxTo,this.Id); if(!copyRange){
for(var id in move.recalc){ var move = this.workbook.dependencyFormulas.helper(oBBoxTo,this.Id);
var n = move.recalc[id]; for(var id in move.recalc){
var _sn = n.getSlaveEdges2(); var n = move.recalc[id];
for( var _id in _sn ){ var _sn = n.getSlaveEdges2();
rec[_sn[_id].nodeId] = [ _sn[_id].sheetId, _sn[_id].cellId ]; for( var _id in _sn ){
rec.length++; rec[_sn[_id].nodeId] = [ _sn[_id].sheetId, _sn[_id].cellId ];
rec.length++;
}
} }
} }
this.workbook.buildDependency();
this.workbook.needRecalc = rec;
recalc(this.workbook);
// this.renameDependencyNodes( offset, oBBoxFrom );
// buildRecalc(this.workbook);
// unLockDraw(this.workbook);
History.TurnOn(); History.TurnOn();
if(false == this.workbook.bUndoChanges && false == this.workbook.bRedoChanges) if(false == this.workbook.bUndoChanges && false == this.workbook.bRedoChanges)
{ {
...@@ -3691,10 +3695,14 @@ Woorksheet.prototype._moveRange=function(oBBoxFrom, oBBoxTo){ ...@@ -3691,10 +3695,14 @@ Woorksheet.prototype._moveRange=function(oBBoxFrom, oBBoxTo){
this.nRowsCount = oBBoxTo.r2 + 1; this.nRowsCount = oBBoxTo.r2 + 1;
if(oBBoxTo.c2 > this.nColsCount) if(oBBoxTo.c2 > this.nColsCount)
this.nColsCount = oBBoxTo.c2 + 1; this.nColsCount = oBBoxTo.c2 + 1;
History.Add(g_oUndoRedoWorksheet, historyitem_Worksheet_MoveRange,
this.workbook.buildDependency();
this.workbook.needRecalc = rec;
recalc(this.workbook);
History.Add(g_oUndoRedoWorksheet, historyitem_Worksheet_MoveRange,
this.getId(), new Asc.Range(0, 0, gc_nMaxCol0, gc_nMaxRow0), this.getId(), new Asc.Range(0, 0, gc_nMaxCol0, gc_nMaxRow0),
new UndoRedoData_FromTo(new UndoRedoData_BBox(oBBoxFrom), new UndoRedoData_BBox(oBBoxTo))); new UndoRedoData_FromTo(new UndoRedoData_BBox(oBBoxFrom), new UndoRedoData_BBox(oBBoxTo), copyRange));
History.EndTransaction(); History.EndTransaction();
return true; return true;
} }
...@@ -4015,8 +4023,9 @@ Woorksheet.prototype.renameDependencyNodes = function(offset, oBBox, rec, noDele ...@@ -4015,8 +4023,9 @@ Woorksheet.prototype.renameDependencyNodes = function(offset, oBBox, rec, noDele
} }
} }
for( var _id in _sn ){ for( var _id in _sn ){
var cell = _sn[_id].returnCell(), cellName = cell.getName(); var cell = _sn[_id].returnCell(), cellName;
if( cell && cell.formulaParsed ){ if( cell && cell.formulaParsed ){
cellName = cell.getName();
cell.formulaParsed.stretchArea( objForRebuldFormula.stretch[id].offset, oBBox, n, this.Id ); cell.formulaParsed.stretchArea( objForRebuldFormula.stretch[id].offset, oBBox, n, this.Id );
cell.setFormula(cell.formulaParsed.assemble()); cell.setFormula(cell.formulaParsed.assemble());
c[cellName] = cell; c[cellName] = cell;
......
...@@ -1336,6 +1336,12 @@ ...@@ -1336,6 +1336,12 @@
// Режим перемещения диапазона // Режим перемещения диапазона
if (t.isMoveRangeMode) { if (t.isMoveRangeMode) {
if(event.ctrlKey){
event.currentTarget.style.cursor = "copy";
}
else{
event.currentTarget.style.cursor = "move";
}
t._moveRangeHandle(event); t._moveRangeHandle(event);
return true; return true;
} }
......
...@@ -641,6 +641,10 @@ ...@@ -641,6 +641,10 @@
// Отсылаем эвент с объектами // Отсылаем эвент с объектами
this.handlers.trigger("asc_onMouseMove", arrMouseMoveObjects); this.handlers.trigger("asc_onMouseMove", arrMouseMoveObjects);
if(ct.target === "moveRange" && ctrlKey && ct.cursor == "move"){
ct.cursor = "copy";
}
if (canvasElem.style.cursor !== ct.cursor) { if (canvasElem.style.cursor !== ct.cursor) {
canvasElem.style.cursor = ct.cursor; canvasElem.style.cursor = ct.cursor;
} }
......
...@@ -6828,18 +6828,20 @@ ...@@ -6828,18 +6828,20 @@
History.SetSelection(arnFrom.clone()); History.SetSelection(arnFrom.clone());
History.SetSelectionRedo(arnTo.clone()); History.SetSelectionRedo(arnTo.clone());
History.StartTransaction(); History.StartTransaction();
t.autoFilters._preMoveAutoFilters(arnFrom); if( !copyRange ) t.autoFilters._preMoveAutoFilters(arnFrom);
t.model._moveRange(arnFrom, arnTo, copyRange); t.model._moveRange(arnFrom, arnTo, copyRange);
t._updateCellsRange(arnTo); t._updateCellsRange(arnTo);
t.cleanSelection(); t.cleanSelection();
t.activeRange = arnTo.clone(true); t.activeRange = arnTo.clone(true);
t.cellCommentator.moveRangeComments(arnFrom, arnTo); t.cellCommentator.moveRangeComments(arnFrom, arnTo);
t.objectRender.moveRangeDrawingObject(arnFrom, arnTo, false); t.objectRender.moveRangeDrawingObject(arnFrom, arnTo, false);
t.autoFilters._moveAutoFilters(arnTo, arnFrom); if( !copyRange ) {
// Вызываем функцию пересчета для заголовков форматированной таблицы t.autoFilters._moveAutoFilters(arnTo, arnFrom);
t.autoFilters._renameTableColumn(arnFrom); // Вызываем функцию пересчета для заголовков форматированной таблицы
t.autoFilters._renameTableColumn(arnTo); t.autoFilters._renameTableColumn( arnFrom );
t.autoFilters.reDrawFilter(arnFrom); t.autoFilters._renameTableColumn( arnTo );
t.autoFilters.reDrawFilter( arnFrom );
}
History.EndTransaction(); History.EndTransaction();
} }
......
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