Commit cd93bfe2 authored by GoshaZotov's avatar GoshaZotov Committed by Alexander.Trofimov

change functions af_deleteCellsInTable and af_insertCellsInTable

parent 6c12b72e
...@@ -2178,7 +2178,7 @@ ...@@ -2178,7 +2178,7 @@
} }
else else
{ {
worksheet.getRange3(tablePart.Ref.r2, tablePart.Ref.c1, tablePart.Ref.r2, tablePart.Ref.c2).addCellsShiftBottom(); worksheet.getRange3(tablePart.Ref.r2 + 1, tablePart.Ref.c1, tablePart.Ref.r2 + 1, tablePart.Ref.c2).addCellsShiftBottom();
worksheet._moveRange(tablePart.Ref, new Asc.Range(tablePart.Ref.c1, tablePart.Ref.r1 + 1, tablePart.Ref.c2, tablePart.Ref.r2 + 1)); worksheet._moveRange(tablePart.Ref, new Asc.Range(tablePart.Ref.c1, tablePart.Ref.r1 + 1, tablePart.Ref.c2, tablePart.Ref.r2 + 1));
tablePart.changeRef(null, -1, true); tablePart.changeRef(null, -1, true);
...@@ -2203,7 +2203,7 @@ ...@@ -2203,7 +2203,7 @@
//History.TurnOn(); //History.TurnOn();
this._addHistoryObj({oldFilter: oldFilter, newFilterRef: tablePart.Ref.clone()}, historyitem_AutoFilter_ChangeTableInfo, this._addHistoryObj({oldFilter: oldFilter, newFilterRef: tablePart.Ref.clone()}, historyitem_AutoFilter_ChangeTableInfo,
{activeCells: null, type: optionType, val: val, displayName: tableName}); {activeCells: tablePart.Ref.clone(), type: optionType, val: val, displayName: tableName});
this._cleanStyleTable(tablePart.Ref); this._cleanStyleTable(tablePart.Ref);
this._setColorStyleTable(tablePart.Ref, tablePart, null, isSetValue); this._setColorStyleTable(tablePart.Ref, tablePart, null, isSetValue);
...@@ -2348,7 +2348,7 @@ ...@@ -2348,7 +2348,7 @@
if(redoObject) if(redoObject)
{ {
oHistoryObject.activeCells = redoObject.activeCells ? redoObject.activeCells.clone() : null; // ToDo Слишком много клонирования, это долгая операция oHistoryObject.activeCells = redoObject.activeCells.clone(); // ToDo Слишком много клонирования, это долгая операция
oHistoryObject.styleName = redoObject.styleName; oHistoryObject.styleName = redoObject.styleName;
oHistoryObject.type = redoObject.type; oHistoryObject.type = redoObject.type;
oHistoryObject.cellId = redoObject.cellId; oHistoryObject.cellId = redoObject.cellId;
......
...@@ -8749,7 +8749,7 @@ ...@@ -8749,7 +8749,7 @@
this.handlers.trigger( "onErrorEvent", c_oAscError.ID.CannotMoveRange, c_oAscError.Level.NoCritical ); this.handlers.trigger( "onErrorEvent", c_oAscError.ID.CannotMoveRange, c_oAscError.Level.NoCritical );
this._cleanSelectionMoveRange(); this._cleanSelectionMoveRange();
} }
else if (resmove === -1) { else if ( resmove === -1 && this.af_isCheckMoveRange( arnFrom, arnTo ) ) {
var t = this; var t = this;
this.model.workbook.handlers.trigger( "asc_onConfirmAction", Asc.c_oAscConfirm.ConfirmReplaceRange, function ( can ) { this.model.workbook.handlers.trigger( "asc_onConfirmAction", Asc.c_oAscConfirm.ConfirmReplaceRange, function ( can ) {
if ( can ) { if ( can ) {
...@@ -12861,21 +12861,50 @@ ...@@ -12861,21 +12861,50 @@
return false; return false;
} }
var insertCellsAndShiftDownRight = function(arn, displayName, type)
{
var range = t.model.getRange3( arn.r1, arn.c1, arn.r2, arn.c2 );
var isCheckChangeAutoFilter = t.af_checkInsDelCells( arn, type, "insCell" );
if ( isCheckChangeAutoFilter === false ) {
return;
}
var callback = function (isSuccess) {
if ( false === isSuccess ) {
return;
}
History.Create_NewPoint();
History.StartTransaction();
var shiftCells = type === c_oAscInsertOptions.InsertCellsAndShiftRight ? range.addCellsShiftRight(displayName) : range.addCellsShiftBottom(displayName);
if ( shiftCells ) {
t.cellCommentator.updateCommentsDependencies( true, type, arn );
t.objectRender.updateDrawingObject( true, type, arn );
t._onUpdateFormatTable(range, false, true);
}
History.EndTransaction();
};
var changedRange = new asc_Range( arn.c1, arn.r1, arn.c2, gc_nMaxRow0 );
t._isLockedCells( changedRange, null, callback );
};
var startCol = this.activeRange.c1; var startCol = this.activeRange.c1;
var endCol = this.activeRange.c2; var endCol = this.activeRange.c2;
var startRow = this.activeRange.r1; var startRow = this.activeRange.r1;
var endRow = this.activeRange.r2; var endRow = this.activeRange.r2;
var newActiveRange = this.activeRange.clone(); var newActiveRange = this.activeRange.clone();
var val = null; var displayName = null;
var type = null;
switch(optionType) switch(optionType)
{ {
case c_oAscInsertOptions.InsertTableRowAbove: case c_oAscInsertOptions.InsertTableRowAbove:
{ {
newActiveRange.c1 = tablePart.Ref.c1; newActiveRange.c1 = tablePart.Ref.c1;
newActiveRange.c2 = tablePart.Ref.c2; newActiveRange.c2 = tablePart.Ref.c2;
type = c_oAscInsertOptions.InsertCellsAndShiftDown;
val = c_oAscInsertOptions.InsertCellsAndShiftDown;
break; break;
} }
case c_oAscInsertOptions.InsertTableRowBelow: case c_oAscInsertOptions.InsertTableRowBelow:
...@@ -12884,16 +12913,17 @@ ...@@ -12884,16 +12913,17 @@
newActiveRange.c2 = tablePart.Ref.c2; newActiveRange.c2 = tablePart.Ref.c2;
newActiveRange.r1 = tablePart.Ref.r2 + 1; newActiveRange.r1 = tablePart.Ref.r2 + 1;
newActiveRange.r2 = tablePart.Ref.r2 + 1; newActiveRange.r2 = tablePart.Ref.r2 + 1;
displayName = tableName;
type = c_oAscInsertOptions.InsertCellsAndShiftDown;
val = c_oAscInsertOptions.InsertCellsAndShiftDown;
break; break;
} }
case c_oAscInsertOptions.InsertTableColLeft: case c_oAscInsertOptions.InsertTableColLeft:
{ {
newActiveRange.r1 = tablePart.Ref.r1; newActiveRange.r1 = tablePart.Ref.r1;
newActiveRange.r2 = tablePart.Ref.r2; newActiveRange.r2 = tablePart.Ref.r2;
type = c_oAscInsertOptions.InsertCellsAndShiftRight;
val = c_oAscInsertOptions.InsertCellsAndShiftRight;
break; break;
} }
case c_oAscInsertOptions.InsertTableColRight: case c_oAscInsertOptions.InsertTableColRight:
...@@ -12902,25 +12932,14 @@ ...@@ -12902,25 +12932,14 @@
newActiveRange.c2 = tablePart.Ref.c2 + 1; newActiveRange.c2 = tablePart.Ref.c2 + 1;
newActiveRange.r1 = tablePart.Ref.r1; newActiveRange.r1 = tablePart.Ref.r1;
newActiveRange.r2 = tablePart.Ref.r2; newActiveRange.r2 = tablePart.Ref.r2;
displayName = tableName;
type = c_oAscInsertOptions.InsertCellsAndShiftRight;
val = c_oAscInsertOptions.InsertCellsAndShiftRight;
break; break;
} }
} }
if(val !== null) insertCellsAndShiftDownRight(newActiveRange, displayName, type)
{
t.activeRange = newActiveRange;
if(optionType === c_oAscInsertOptions.InsertTableColRight || optionType === c_oAscInsertOptions.InsertTableRowBelow)
{
t.changeWorksheet("insCell", val, tableName);
}
else
{
t.changeWorksheet("insCell", val);
}
t.activeRange = activeRange;
}
}; };
WorksheetView.prototype.af_deleteCellsInTable = function(tableName, optionType) WorksheetView.prototype.af_deleteCellsInTable = function(tableName, optionType)
...@@ -12936,6 +12955,36 @@ ...@@ -12936,6 +12955,36 @@
return false; return false;
} }
var deleteCellsAndShiftLeftTop = function(arn, type)
{
var range = t.model.getRange3( arn.r1, arn.c1, arn.r2, arn.c2 );
var isCheckChangeAutoFilter = t.af_checkInsDelCells( arn, type, "delCell" );
if ( isCheckChangeAutoFilter === false ) {
return;
}
var callback = function () {
History.Create_NewPoint();
History.StartTransaction();
if ( isCheckChangeAutoFilter === true ) {
t.model.autoFilters.isEmptyAutoFilters( arn, type );
}
var deleteCells = type === c_oAscInsertOptions.InsertCellsAndShiftRight ? range.deleteCellsShiftLeft() : range.deleteCellsShiftUp();
if ( deleteCells ) {
t.cellCommentator.updateCommentsDependencies( true, type, arn );
t.objectRender.updateDrawingObject( true, type, arn );
t._onUpdateFormatTable(range, false, true);
}
History.EndTransaction();
};
var changedRange = new asc_Range( arn.c1, arn.r1, gc_nMaxCol0, arn.r2 );
t._isLockedCells( changedRange, null, callback );
};
var startCol = this.activeRange.c1; var startCol = this.activeRange.c1;
var endCol = this.activeRange.c2; var endCol = this.activeRange.c2;
var startRow = this.activeRange.r1; var startRow = this.activeRange.r1;
...@@ -12970,9 +13019,7 @@ ...@@ -12970,9 +13019,7 @@
if(val !== null) if(val !== null)
{ {
t.activeRange = newActiveRange; deleteCellsAndShiftLeftTop(newActiveRange, val);
t.changeWorksheet("delCell", val);
t.activeRange = acitveRange;
} }
}; };
......
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