Commit bd5ca071 authored by Igor.Zotov's avatar Igor.Zotov Committed by Alexander.Trofimov

http://bugzserver/show_bug.cgi?id=29026 - [AutoSave] Повреждение файла после...

http://bugzserver/show_bug.cgi?id=29026 - [AutoSave] Повреждение файла после удаления столбцов форматированной таблицы

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@63884 954022d7-b5bf-4e40-9824-e11837661b57
parent 4c89ceaa
...@@ -4396,6 +4396,59 @@ TablePart.prototype.setHandlers = function(handlers) { ...@@ -4396,6 +4396,59 @@ TablePart.prototype.setHandlers = function(handlers) {
this.handlers = handlers; this.handlers = handlers;
}; };
TablePart.prototype.deleteTableColumns = function(activeRange)
{
if(!activeRange)
return;
var diff = null, startCol;
if(activeRange.c1 < this.Ref.c1 && activeRange.c2 > this.Ref.c1 && activeRange.c2 < this.Ref.c2)//until
{
diff = activeRange.c2 - this.Ref.c1 + 1;
startCol = 0;
}
else if(activeRange.c1 < this.Ref.c2 && activeRange.c2 > this.Ref.c2 && activeRange.c1 > this.Ref.c1)//after
{
diff = this.Ref.c2 - activeRange.c1 + 1;
startCol = activeRange.c1 - this.Ref.c1;
}
else if(activeRange.c1 >= this.Ref.c1 && activeRange.c2 <= this.Ref.c2)//inside
{
diff = activeRange.c2 - activeRange.c1 + 1;
startCol = activeRange.c1 - this.Ref.c1;
}
if(diff !== null)
this.TableColumns.splice(startCol, diff);
};
TablePart.prototype.addTableColumns = function(activeRange, aF)
{
var newTableColumns = [], num = 0;
for(var j = 0; j < this.TableColumns.length;)
{
var curCol = num + this.Ref.c1;
if(activeRange.c1 <= curCol && activeRange.c2 >= curCol)
{
var newNameColumn = aF._generateColumnName(newTableColumns.concat(this.TableColumns), curCol - 1);
var newTableColumn = new TableColumn();
newTableColumn.Name = newNameColumn;
newTableColumns[newTableColumns.length] = newTableColumn;
}
else
{
newTableColumns[newTableColumns.length] = this.TableColumns[j];
j++
}
num++;
}
this.TableColumns = newTableColumns;
};
/** @constructor */ /** @constructor */
function AutoFilter() { function AutoFilter() {
......
...@@ -1280,7 +1280,6 @@ var maxIndividualValues = 10000; ...@@ -1280,7 +1280,6 @@ var maxIndividualValues = 10000;
var ref = filter.Ref; var ref = filter.Ref;
var oldFilter = null; var oldFilter = null;
var diffColId = null; var diffColId = null;
var changeTableColumns = null;
if(activeRange.r1 <= ref.r1 && activeRange.r2 >= ref.r2) if(activeRange.r1 <= ref.r1 && activeRange.r2 >= ref.r2)
{ {
...@@ -1296,6 +1295,10 @@ var maxIndividualValues = 10000; ...@@ -1296,6 +1295,10 @@ var maxIndividualValues = 10000;
if(diff < 0) if(diff < 0)
{ {
diffColId = ref.c1 - activeRange.c2 - 1; diffColId = ref.c1 - activeRange.c2 - 1;
if(bTablePart)
filter.deleteTableColumns(activeRange);
filter.changeRef(-diffColId, null, true); filter.changeRef(-diffColId, null, true);
} }
...@@ -1305,15 +1308,26 @@ var maxIndividualValues = 10000; ...@@ -1305,15 +1308,26 @@ var maxIndividualValues = 10000;
{ {
oldFilter = filter.clone(null); oldFilter = filter.clone(null);
diffColId = activeRange.c1 - ref.c2 - 1; diffColId = activeRange.c1 - ref.c2 - 1;
filter.changeRef(diffColId);
if(diff < 0 && bTablePart)
filter.deleteTableColumns(activeRange);
else if(bTablePart)
filter.addTableColumns(activeRange, t);
filter.changeRef(diffColId);
} }
else if((activeRange.c1 >= ref.c1 && activeRange.c1 <= ref.c2 && activeRange.c2 <= ref.c2) || (activeRange.c1 > ref.c1 && activeRange.c2 >= ref.c2 && activeRange.c1 < ref.c2 && diff > 0))//inside else if((activeRange.c1 >= ref.c1 && activeRange.c1 <= ref.c2 && activeRange.c2 <= ref.c2) || (activeRange.c1 > ref.c1 && activeRange.c2 >= ref.c2 && activeRange.c1 < ref.c2 && diff > 0))//inside
{ {
oldFilter = filter.clone(null); oldFilter = filter.clone(null);
if(diff < 0 && bTablePart)
filter.deleteTableColumns(activeRange);
else if(bTablePart)
filter.addTableColumns(activeRange, t);
filter.changeRef(diff); filter.changeRef(diff);
diffColId = diff; diffColId = diff;
changeTableColumns = true;
} }
//change filterColumns //change filterColumns
...@@ -1341,41 +1355,6 @@ var maxIndividualValues = 10000; ...@@ -1341,41 +1355,6 @@ var maxIndividualValues = 10000;
} }
} }
//change TableColumns
if(oldFilter && bTablePart && changeTableColumns)
{
//add TableColumns
if(diff > 0)
{
var newTableColumns = [];
var num = 0;
for(var j = 0; j < filter.TableColumns.length;)
{
var curCol = num + filter.Ref.c1;
if(activeRange.c1 <= curCol && activeRange.c2 >= curCol)
{
var newNameColumn = t._generateColumnName(newTableColumns.concat(filter.TableColumns), curCol - 1);
var newTableColumn = new TableColumn();
newTableColumn.Name = newNameColumn;
newTableColumns[newTableColumns.length] = newTableColumn;
}
else
{
newTableColumns[newTableColumns.length] = filter.TableColumns[j];
j++
}
num++;
}
filter.TableColumns = newTableColumns;
}
else//delete TableColumns
{
filter.TableColumns.splice(activeRange.c1 - filter.Ref.c1, Math.abs(diff));
}
}
//History //History
if(!bUndoChanges && !bRedoChanges /*&& !notAddToHistory*/ && oldFilter) if(!bUndoChanges && !bRedoChanges /*&& !notAddToHistory*/ && oldFilter)
{ {
......
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