OfficeXml/autoclass/docx/Tbl@DOCX.tsf

112 lines
2.9 KiB
Plaintext

type Tbl = class(OpenXmlElement)
public
function Create();overload;
function Create(_node: XmlNode);overload;
function Create(_parent: tslobj; _prefix: string; _local_name: string);overload;
function Init();override;
function Copy(_obj: Tbl);override;
public
// normal property
property TblPr read ReadXmlChildTblPr;
property TblGrid read ReadXmlChildTblGrid;
function ReadXmlChildTblPr();
function ReadXmlChildTblGrid();
// multi property
property Trs read ReadTrs;
function ReadTrs(_index);
function AddTr(): Tr;
function AppendTr(): Tr;
public
// Children
XmlChildTblPr: TblPr;
XmlChildTblGrid: TblGrid;
end;
function Tbl.Create();overload;
begin
{self.}Create(nil, "w", "tbl");
end;
function Tbl.Create(_node: XmlNode);overload;
begin
class(OpenXmlElement).Create(_node: XmlNode);
end;
function Tbl.Create(_parent: tslobj; _prefix: string; _local_name: string);overload;
begin
setsysparam(pn_calcctrlword(), getsysparam(pn_calcctrlword()) .| 0x200);
class(OpenXmlElement).Create(_parent, _prefix, _local_name);
end;
function Tbl.Init();override;
begin
pre := {self.}Prefix ? {self.}Prefix + ":" : "";
attributes_ := array();
attributes_pf_ := array(
);
sorted_child_ := array(
pre + "tblPr": array(0, makeweakref(thisFunction(ReadXmlChildTblPr))),
pre + "tblGrid": array(1, makeweakref(thisFunction(ReadXmlChildTblGrid))),
pre + "tr": array(2, makeweakref(thisFunction(AppendTr))),
);
container_ := new TSOfficeContainer(sorted_child_);
end;
function Tbl.Copy(_obj: Tbl);override;
begin
tslassigning_backup := tslassigning;
tslassigning := 1;
class(OpenXmlElement).Copy(_obj);
if not ifnil(_obj.XmlChildTblPr) then
{self.}TblPr.Copy(_obj.XmlChildTblPr);
if not ifnil(_obj.XmlChildTblGrid) then
{self.}TblGrid.Copy(_obj.XmlChildTblGrid);
tslassigning := tslassigning_backup;
end;
function Tbl.ReadXmlChildTblPr();
begin
if tslassigning and ifnil({self.}XmlChildTblPr) then
begin
{self.}XmlChildTblPr := new TblPr(self, {self.}Prefix, "tblPr");
container_.Set({self.}XmlChildTblPr);
end
return {self.}XmlChildTblPr;
end;
function Tbl.ReadXmlChildTblGrid();
begin
if tslassigning and ifnil({self.}XmlChildTblGrid) then
begin
{self.}XmlChildTblGrid := new TblGrid(self, {self.}Prefix, "tblGrid");
container_.Set({self.}XmlChildTblGrid);
end
return {self.}XmlChildTblGrid;
end;
function Tbl.ReadTrs(_index);
begin
ind := ifnil(_index) ? -2 : _index;
pre := {self.}Prefix ? {self.}Prefix + ":" : "";
return container_.Get(pre + "tr", ind);
end;
function Tbl.AddTr(): Tr;
begin
obj := new Tr(self, {self.}Prefix, "tr");
container_.Insert(obj);
return obj;
end;
function Tbl.AppendTr(): Tr;
begin
obj := new Tr(self, {self.}Prefix, "tr");
container_.Append(obj);
return obj;
end;