Commit 1c55fbc6 authored by Sergey.Konovalov's avatar Sergey.Konovalov Committed by Alexander.Trofimov

Bug 19380 - Ошибка в консоли "Mb" после возвращения вырезанной таблицы

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@48302 954022d7-b5bf-4e40-9824-e11837661b57
parent 2619e641
...@@ -1066,9 +1066,11 @@ CopyProcessor.prototype = ...@@ -1066,9 +1066,11 @@ CopyProcessor.prototype =
tr.appendChild(tc); tr.appendChild(tc);
}, },
CopyRow : function(oDomTarget, table, nCurRow, start, end) CopyRow : function(oDomTarget, table, nCurRow, elems, nMaxRow)
{ {
var row = table.Content[nCurRow]; var row = table.Content[nCurRow];
if(null == elems)
elems = {Start: 0, End: row.Content.length - 1};
var tr = document.createElement( "tr" ); var tr = document.createElement( "tr" );
//Pr //Pr
var grid = table.TableGrid; var grid = table.TableGrid;
...@@ -1112,7 +1114,7 @@ CopyProcessor.prototype = ...@@ -1112,7 +1114,7 @@ CopyProcessor.prototype =
tr.setAttribute("style", trStyle); tr.setAttribute("style", trStyle);
//tc //tc
var nSumGridSpan = nGridBefore; var nSumGridSpan = nGridBefore;
for(var i = start.Cell, length = row.Content.length; i <= end.Cell && i < length; ++i) for(var i = elems.Start; i <= elems.End; ++i)
{ {
var cell = row.Content[i]; var cell = row.Content[i];
var nGridSpan = 1; var nGridSpan = 1;
...@@ -1128,7 +1130,7 @@ CopyProcessor.prototype = ...@@ -1128,7 +1130,7 @@ CopyProcessor.prototype =
width += grid[nGridBefore + nSumGridSpan + j]; width += grid[nGridBefore + nSumGridSpan + j];
//��������� rowspan //��������� rowspan
var nRowSpan = 1; var nRowSpan = 1;
for(var j = nCurRow + 1, length2 = table.Content.length; j <= end.Row && j < length2; ++j) for(var j = nCurRow + 1; j <= nMaxRow; ++j)
{ {
var bContinue = false; var bContinue = false;
var oBottomRow = table.Content[j]; var oBottomRow = table.Content[j];
...@@ -1195,7 +1197,7 @@ CopyProcessor.prototype = ...@@ -1195,7 +1197,7 @@ CopyProcessor.prototype =
oDomTarget.appendChild(tr); oDomTarget.appendChild(tr);
}, },
CopyTable : function(oDomTarget, table, start, end) CopyTable : function(oDomTarget, table, oRowElems)
{ {
this.CommitList(oDomTarget); this.CommitList(oDomTarget);
var DomTable = document.createElement( "table" ); var DomTable = document.createElement( "table" );
...@@ -1276,8 +1278,23 @@ CopyProcessor.prototype = ...@@ -1276,8 +1278,23 @@ CopyProcessor.prototype =
DomTable.setAttribute("style", tblStyle); DomTable.setAttribute("style", tblStyle);
//rows //rows
for(var i = start.Row, length = table.Content.length; i < length && i <= end.Row; i++) if(null == oRowElems)
this.CopyRow(DomTable, table, i ,start, end); {
for(var i = 0, length = table.Content.length; i < length; i++)
this.CopyRow(DomTable, table, i , null, table.Content.length - 1);
}
else
{
var nMaxRow = 0;
for(var i in oRowElems)
{
var nCurRow = i - 0;
if(nCurRow > nMaxRow)
nMaxRow = nCurRow;
}
for(var i in oRowElems)
this.CopyRow(DomTable, table, i - 0, oRowElems[i], nMaxRow);
}
oDomTarget.appendChild(DomTable); oDomTarget.appendChild(DomTable);
}, },
...@@ -1344,26 +1361,29 @@ CopyProcessor.prototype = ...@@ -1344,26 +1361,29 @@ CopyProcessor.prototype =
else if(table_Selection_Cell == Item.Selection.Type) else if(table_Selection_Cell == Item.Selection.Type)
{ {
//������� �������� ����� //������� �������� �����
var start = {Row:Item.Rows, Cell: Item.Cols}; var oRowElems = new Object();
var end = {Row:0, Cell: 0}; if(Item.Selection.Data.length > 0)
{
for(var i = 0, length = Item.Selection.Data.length; i < length; ++i) for(var i = 0, length = Item.Selection.Data.length; i < length; ++i)
{ {
var elem = Item.Selection.Data[i]; var elem = Item.Selection.Data[i];
if(elem.Row > end.Row) var rowElem = oRowElems[elem.Row];
end.Row = elem.Row; if(null == rowElem)
if(elem.Row < start.Row) {
start.Row = elem.Row; rowElem = {Start: elem.Cell, End: elem.Cell}
if(elem.Cell > end.Cell) oRowElems[elem.Row] = rowElem;
end.Cell = elem.Cell; }
if(elem.Cell < start.Cell) if(elem.Cell < rowElem.Start)
start.Cell = elem.Cell; rowElem.Start = elem.Cell;
if(elem.Cell > rowElem.End)
rowElem.End = elem.Cell;
}
this.CopyTable(oDomTarget, Item, oRowElems);
} }
if(Item.Selection.Data.length > 0)
this.CopyTable(oDomTarget, Item, start, end);
} }
} }
else else
this.CopyTable(oDomTarget, Item, {Row:0, Cell: 0}, {Row:Item.Rows, Cell: Item.Cols}); this.CopyTable(oDomTarget, Item, null);
} }
else if ( type_Paragraph === Item.GetType() ) else if ( type_Paragraph === Item.GetType() )
{ {
...@@ -3585,7 +3605,7 @@ PasteProcessor.prototype = ...@@ -3585,7 +3605,7 @@ PasteProcessor.prototype =
this._MergeCells(table, item.start, item.rowspan, item.colspan); this._MergeCells(table, item.start, item.rowspan, item.colspan);
} }
//After,Before //After,Before
for(var i = 0; i < table.Rows; ++i) for(var i = 0; i < table.Content.length; ++i)
{ {
var Row = table.Content[i]; var Row = table.Content[i];
var nRowLength = Row.Content.length; var nRowLength = Row.Content.length;
......
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