Commit 31433402 authored by Ilya Kirillov's avatar Ilya Kirillov

Fixed bug with calculating table grid.

parent 9bc428f9
......@@ -276,28 +276,32 @@ CTable.prototype.private_RecalculateGrid = function()
}
var CurGridCol = 0;
for ( var Index = 0; Index < this.Content.length; Index++ )
for (var Index = 0; Index < this.Content.length; Index++)
{
var Row = this.Content[Index];
Row.Set_Index( Index );
Row.Set_Index(Index);
// Смотрим на ширину пропущенных колонок сетки в начале строки
var BeforeInfo = Row.Get_Before();
CurGridCol = BeforeInfo.GridBefore;
if ( CurGridCol > 0 && SumGrid[CurGridCol - 1] < BeforeInfo.WBefore.W )
SumGrid[CurGridCol - 1] = BeforeInfo.WBefore.W;
if (CurGridCol > 0 && SumGrid[CurGridCol - 1] < BeforeInfo.WBefore.W)
{
var nTempDiff = BeforeInfo.WBefore.W - SumGrid[CurGridCol - 1];
for (var nTempIndex = CurGridCol - 1; nTempIndex < SumGrid.length; ++nTempIndex)
SumGrid[nTempIndex] += nTempDiff;
}
var CellsCount = Row.Get_CellsCount();
for ( var CellIndex = 0; CellIndex < CellsCount; CellIndex++ )
for (var CellIndex = 0; CellIndex < CellsCount; CellIndex++)
{
var Cell = Row.Get_Cell( CellIndex );
Cell.Set_Index( CellIndex );
var Cell = Row.Get_Cell(CellIndex);
Cell.Set_Index(CellIndex);
var CellW = Cell.Get_W();
var GridSpan = Cell.Get_GridSpan();
if ( CurGridCol + GridSpan - 1 > SumGrid.length )
if (CurGridCol + GridSpan - 1 > SumGrid.length)
{
for ( var AddIndex = SumGrid.length; AddIndex <= CurGridCol + GridSpan - 1; AddIndex++ )
for (var AddIndex = SumGrid.length; AddIndex <= CurGridCol + GridSpan - 1; AddIndex++)
SumGrid[AddIndex] = SumGrid[AddIndex - 1] + 20; // Добавляем столбик шириной в 2 см
}
......@@ -310,7 +314,11 @@ CTable.prototype.private_RecalculateGrid = function()
CellWidth = CellW.W;
if (CellWidth + SumGrid[CurGridCol - 1] > SumGrid[CurGridCol + GridSpan - 1])
SumGrid[CurGridCol + GridSpan - 1] = CellWidth + SumGrid[CurGridCol - 1];
{
var nTempDiff = CellWidth + SumGrid[CurGridCol - 1] - SumGrid[CurGridCol + GridSpan - 1];
for (var nTempIndex = CurGridCol + GridSpan - 1; nTempIndex < SumGrid.length; ++nTempIndex)
SumGrid[nTempIndex] += nTempDiff;
}
}
CurGridCol += GridSpan;
......@@ -318,13 +326,18 @@ CTable.prototype.private_RecalculateGrid = function()
// Смотрим на ширину пропущенных колонок сетки в конце строки
var AfterInfo = Row.Get_After();
if ( CurGridCol + AfterInfo.GridAfter - 1 > SumGrid.length )
if (CurGridCol + AfterInfo.GridAfter - 1 > SumGrid.length)
{
for ( var AddIndex = SumGrid.length; AddIndex <= CurGridCol + AfterInfo.GridAfter - 1; AddIndex++ )
for (var AddIndex = SumGrid.length; AddIndex <= CurGridCol + AfterInfo.GridAfter - 1; AddIndex++)
SumGrid[AddIndex] = SumGrid[AddIndex - 1] + 20; // Добавляем столбик шириной в 2 см
}
if ( SumGrid[CurGridCol + AfterInfo.GridAfter - 1] < AfterInfo.WAfter + SumGrid[CurGridCol - 1] )
SumGrid[CurGridCol + AfterInfo.GridAfter - 1] = AfterInfo.WAfter + SumGrid[CurGridCol - 1];
if (SumGrid[CurGridCol + AfterInfo.GridAfter - 1] < AfterInfo.WAfter + SumGrid[CurGridCol - 1])
{
var nTempDiff = AfterInfo.WAfter + SumGrid[CurGridCol - 1] - SumGrid[CurGridCol + AfterInfo.GridAfter - 1];
for (var nTempIndex = CurGridCol + AfterInfo.GridAfter - 1; nTempIndex < SumGrid.length; ++nTempIndex)
SumGrid[nTempIndex] += nTempDiff;
}
}
// TODO: разобраться с минимальной шириной таблицы и ячеек
......
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