Commit d739cf67 authored by Ilya Kirillov's avatar Ilya Kirillov Committed by Alexander.Trofimov

В билдер добавлен кдасс ApiTableRowPr для работы с настройками строки таблицы....

В билдер добавлен кдасс ApiTableRowPr для работы с настройками строки таблицы. Класс ApiTable снаследован от класса ApiTableRowPr. Сделан тестовый пример для работы с настройками.
parent 729be7ba
......@@ -232,12 +232,14 @@ CTableRow.prototype =
// Сначала возьмем настройки по умолчанию для строки
var RowPr = TablePr.TableRowPr.Copy();
if (undefined !== TablePr.TablePr.TableCellSpacing)
RowPr.TableCellSpacing = TablePr.TablePr.TableCellSpacing;
// Совместим настройки с настройками для групп строк
if ( true === TableLook.Is_BandHor() )
{
var RowBandSize = TablePr.TablePr.TableStyleRowBandSize;
var _CurIndex = ( true != TableLook.Is_FirstRow() ? CurIndex : CurIndex - 1 )
var _CurIndex = ( true != TableLook.Is_FirstRow() ? CurIndex : CurIndex - 1 );
var GroupIndex = ( 1 != RowBandSize ? Math.floor( _CurIndex / RowBandSize ) : _CurIndex );
if ( 0 === GroupIndex % 2 )
RowPr.Merge(TablePr.TableBand1Horz.TableRowPr);
......@@ -288,6 +290,7 @@ CTableRow.prototype =
{
History.Add( this, { Type : AscDFH.historyitem_TableRow_Pr, Old : this.Pr, New : RowPr } );
this.Pr = RowPr;
this.Recalc_CompiledPr();
},
Get_Before : function()
......@@ -400,8 +403,7 @@ CTableRow.prototype =
Get_CellSpacing : function()
{
var RowPr = this.Get_CompiledPr( false );
return RowPr.TableCellSpacing;
return this.Get_CompiledPr(false).TableCellSpacing;
},
Set_CellSpacing : function(Value)
......
......@@ -43,7 +43,6 @@
ApiParagraph.superclass.constructor.call(this, this, Paragraph.Pr.Copy());
this.Paragraph = Paragraph;
}
AscCommon.extendClass(ApiParagraph, ApiParaPr);
/**
......@@ -87,7 +86,6 @@
ApiRun.superclass.constructor.call(this, this, Run.Pr.Copy());
this.Run = Run;
}
AscCommon.extendClass(ApiRun, ApiTextPr);
/**
......@@ -108,14 +106,26 @@
this.Section = Section;
}
/**
* Class representing a table row properties.
* @constructor
*/
function ApiTableRowPr(Parent, RowPr)
{
this.Parent = Parent;
this.RowPr = RowPr;
}
/**
* Class representing a table row.
* @constructor
*/
function ApiTableRow(Row)
{
ApiTableRow.superclass.constructor.call(this, this, Row.Pr.Copy());
this.Row = Row;
}
AscCommon.extendClass(ApiTableRow, ApiTableRowPr);
/**
* Class representing a table cell.
......@@ -938,16 +948,6 @@
return new ApiTableCell(this.Row.Content[nPos]);
};
/**
* Set the height of the current table row within the current table.
* @param {("auto" | "atLeast")} sHRule - Specifies the meaning of the height specified for this table row.
* @param {twips} nValue
*/
ApiTableRow.prototype.SetHeight = function(sHRule, nValue)
{
var HRule = ("auto" === sHRule ? Asc.linerule_Auto : Asc.linerule_AtLeast);
this.Row.Set_Height(private_Twips2MM(nValue), HRule);
};
//------------------------------------------------------------------------------------------------------------------
//
......@@ -1965,6 +1965,37 @@
this.private_OnChange();
};
//------------------------------------------------------------------------------------------------------------------
//
// ApiTableRowPr
//
//------------------------------------------------------------------------------------------------------------------
/**
* Set the height of the current table row within the current table.
* @param {("auto" | "atLeast")} sHRule - Specifies the meaning of the height specified for this table row.
* @param {twips} [nValue] - This value will be ignored if <code>sHRule="auto"</code>.
*/
ApiTableRowPr.prototype.SetHeight = function(sHRule, nValue)
{
if ("auto" === sHRule)
this.RowPr.Height = new CTableRowHeight(0, Asc.linerule_Auto);
else if ("atLeast" === sHRule)
this.RowPr.Height = new CTableRowHeight(private_Twips2MM(nValue), Asc.linerule_AtLeast);
this.private_OnChange();
};
/**
* Specifies that the current table row shall be repeated at the top of each new page on which part of this table
* is displayed. This gives this table row the behavior of a 'header' row on each of these pages. This element can
* be applied to any number of rows at the top of the table structure in order to generate multi-row table headers.
* @param {boolean} isHeader
*/
ApiTableRowPr.prototype.SetTableHeader = function(isHeader)
{
this.RowPr.TableHeader = private_GetBoolean(isHeader);
this.private_OnChange();
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Export
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
......@@ -2021,7 +2052,6 @@
ApiTableRow.prototype["GetCellsCount"] = ApiTableRow.prototype.GetCellsCount;
ApiTableRow.prototype["GetCell"] = ApiTableRow.prototype.GetCell;
ApiTableRow.prototype["SetHeight"] = ApiTableRow.prototype.SetHeight;
ApiTableCell.prototype["GetContent"] = ApiTableCell.prototype.GetContent;
ApiTableCell.prototype["SetWidth"] = ApiTableCell.prototype.SetWidth;
......@@ -2106,6 +2136,8 @@
ApiTablePr.prototype["SetWidth"] = ApiTablePr.prototype.SetWidth;
ApiTablePr.prototype["SetTableLayout"] = ApiTablePr.prototype.SetTableLayout;
ApiTableRowPr.prototype["SetHeight"] = ApiTableRowPr.prototype.SetHeight;
ApiTableRowPr.prototype["SetTableHeader"] = ApiTableRowPr.prototype.SetTableHeader;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Private area
......@@ -2328,6 +2360,11 @@
this.Num.Set_ParaPr(this.Lvl, oApiParaPr.ParaPr);
oApiParaPr.ParaPr = this.Num.Lvl[this.Lvl].ParaPr.Copy();
};
ApiTableRow.prototype.OnChangeTableRowPr = function(oApiTableRowPr)
{
this.Row.Set_Pr(oApiTableRowPr.RowPr);
oApiTableRowPr.RowPr = this.Row.Pr.Copy();
};
ApiTextPr.prototype.private_OnChange = function()
{
this.Parent.OnChangeTextPr(this);
......@@ -2340,6 +2377,10 @@
{
this.Parent.OnChangeTablePr(this);
};
ApiTableRowPr.prototype.private_OnChange = function()
{
this.Parent.OnChangeTableRowPr(this);
};
}(window, null));
......@@ -2854,6 +2895,10 @@ function TEST_BUILDER2()
//------------------------------------------------------------------------------------------------------------------
var Api = editor;
var oDocument = Api.GetDocument();
//------------------------------------------------------------------------------------------------------------------
// TextPr
//------------------------------------------------------------------------------------------------------------------
var oParagraph = Api.CreateParagraph();
oDocument.Push(oParagraph);
......@@ -2879,6 +2924,9 @@ function TEST_BUILDER2()
oParagraph.AddText("Language Russia").SetLanguage("ru-RU");
oParagraph.AddText("ShadeRed").SetShd("clear", 255, 0, 0);
//------------------------------------------------------------------------------------------------------------------
// ParaPr
//------------------------------------------------------------------------------------------------------------------
oParagraph = Api.CreateParagraph();
oParagraph.AddText("Normal paragraph");
oDocument.Push(oParagraph);
......@@ -3073,12 +3121,18 @@ function TEST_BUILDER2()
oDocument.Push(oParagraph);
}
//------------------------------------------------------------------------------------------------------------------
// Header - Footer
//------------------------------------------------------------------------------------------------------------------
var oSection = oDocument.GetFinalSection();
var oHeader = oSection.GetHeader("default", true);
oParagraph = oHeader.GetElement(0);
oParagraph.AddText("I'm in default header");
//------------------------------------------------------------------------------------------------------------------
// TablePr
//------------------------------------------------------------------------------------------------------------------
var oTable = Api.CreateTable(3, 3);
oDocument.Push(oTable);
oTable.SetJc("left");
......@@ -3143,6 +3197,27 @@ function TEST_BUILDER2()
oDocument.Push(oTable);
oTable.SetTableLayout("fixed");
//------------------------------------------------------------------------------------------------------------------
// TableRowPr
//------------------------------------------------------------------------------------------------------------------
oTable = Api.CreateTable(3, 3);
oDocument.Push(oTable);
var oTableRow = oTable.GetRow(0);
oTableRow.SetHeight("auto");
oTableRow = oTable.GetRow(1);
oTableRow.SetHeight("atLeast", 1000);
oTableRow = oTable.GetRow(2);
oTableRow.SetHeight("atLeast", 2000);
oTable = Api.CreateTable(10, 40);
oDocument.Push(oTable);
oTable.SetStyle(oTableStyle);
oTable.GetRow(0).SetTableHeader(true);
oTable.GetRow(1).SetTableHeader(true);
//------------------------------------------------------------------------------------------------------------------
// TableCellPr
//------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------
oLD.Recalculate_FromStart();
......
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