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