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 @@
}
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));
tablePart.changeRef(null, -1, true);
......@@ -2203,7 +2203,7 @@
//History.TurnOn();
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._setColorStyleTable(tablePart.Ref, tablePart, null, isSetValue);
......@@ -2348,7 +2348,7 @@
if(redoObject)
{
oHistoryObject.activeCells = redoObject.activeCells ? redoObject.activeCells.clone() : null; // ToDo Слишком много клонирования, это долгая операция
oHistoryObject.activeCells = redoObject.activeCells.clone(); // ToDo Слишком много клонирования, это долгая операция
oHistoryObject.styleName = redoObject.styleName;
oHistoryObject.type = redoObject.type;
oHistoryObject.cellId = redoObject.cellId;
......
......@@ -8749,7 +8749,7 @@
this.handlers.trigger( "onErrorEvent", c_oAscError.ID.CannotMoveRange, c_oAscError.Level.NoCritical );
this._cleanSelectionMoveRange();
}
else if (resmove === -1) {
else if ( resmove === -1 && this.af_isCheckMoveRange( arnFrom, arnTo ) ) {
var t = this;
this.model.workbook.handlers.trigger( "asc_onConfirmAction", Asc.c_oAscConfirm.ConfirmReplaceRange, function ( can ) {
if ( can ) {
......@@ -12861,21 +12861,50 @@
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 endCol = this.activeRange.c2;
var startRow = this.activeRange.r1;
var endRow = this.activeRange.r2;
var newActiveRange = this.activeRange.clone();
var val = null;
var displayName = null;
var type = null;
switch(optionType)
{
case c_oAscInsertOptions.InsertTableRowAbove:
{
newActiveRange.c1 = tablePart.Ref.c1;
newActiveRange.c2 = tablePart.Ref.c2;
type = c_oAscInsertOptions.InsertCellsAndShiftDown;
val = c_oAscInsertOptions.InsertCellsAndShiftDown;
break;
}
case c_oAscInsertOptions.InsertTableRowBelow:
......@@ -12884,16 +12913,17 @@
newActiveRange.c2 = tablePart.Ref.c2;
newActiveRange.r1 = tablePart.Ref.r2 + 1;
newActiveRange.r2 = tablePart.Ref.r2 + 1;
displayName = tableName;
type = c_oAscInsertOptions.InsertCellsAndShiftDown;
val = c_oAscInsertOptions.InsertCellsAndShiftDown;
break;
}
case c_oAscInsertOptions.InsertTableColLeft:
{
newActiveRange.r1 = tablePart.Ref.r1;
newActiveRange.r2 = tablePart.Ref.r2;
type = c_oAscInsertOptions.InsertCellsAndShiftRight;
val = c_oAscInsertOptions.InsertCellsAndShiftRight;
break;
}
case c_oAscInsertOptions.InsertTableColRight:
......@@ -12902,25 +12932,14 @@
newActiveRange.c2 = tablePart.Ref.c2 + 1;
newActiveRange.r1 = tablePart.Ref.r1;
newActiveRange.r2 = tablePart.Ref.r2;
displayName = tableName;
type = c_oAscInsertOptions.InsertCellsAndShiftRight;
val = c_oAscInsertOptions.InsertCellsAndShiftRight;
break;
}
}
if(val !== null)
{
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;
}
insertCellsAndShiftDownRight(newActiveRange, displayName, type)
};
WorksheetView.prototype.af_deleteCellsInTable = function(tableName, optionType)
......@@ -12936,6 +12955,36 @@
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 endCol = this.activeRange.c2;
var startRow = this.activeRange.r1;
......@@ -12970,9 +13019,7 @@
if(val !== null)
{
t.activeRange = newActiveRange;
t.changeWorksheet("delCell", val);
t.activeRange = acitveRange;
deleteCellsAndShiftLeftTop(newActiveRange, val);
}
};
......
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