OfficeXml/autoclass/docx/Relationships@DOCX.tsf

104 lines
2.8 KiB
Plaintext

type Relationships = 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: Relationships);override;
public
// attributes property
property xmlns read ReadXmlAttrxmlns write WriteXmlAttrxmlns;
function ReadXmlAttrxmlns();
function WriteXmlAttrxmlns(_value);
// multi property
property Relationships read ReadRelationships;
function ReadRelationships(_index);
function AddRelationship(): Relationship;
function AppendRelationship(): Relationship;
public
// Attributes
XmlAttrxmlns: OpenXmlAttribute;
// Children
end;
function Relationships.Create();overload;
begin
{self.}Create(nil, "", "Relationships");
end;
function Relationships.Create(_node: XmlNode);overload;
begin
class(OpenXmlElement).Create(_node: XmlNode);
end;
function Relationships.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 Relationships.Init();override;
begin
pre := {self.}Prefix ? {self.}Prefix + ":" : "";
attributes_ := array();
attributes_pf_ := array(
"xmlns": makeweakref(thisFunction(WriteXmlAttrxmlns)),
);
sorted_child_ := array(
"Relationship": array(0, makeweakref(thisFunction(AppendRelationship))),
);
container_ := new TSOfficeContainer(sorted_child_);
end;
function Relationships.Copy(_obj: Relationships);override;
begin
tslassigning_backup := tslassigning;
tslassigning := 1;
class(OpenXmlElement).Copy(_obj);
if not ifnil(_obj.xmlns) then
{self.}xmlns := _obj.xmlns;
tslassigning := tslassigning_backup;
end;
function Relationships.ReadXmlAttrxmlns();
begin
return {self.}XmlAttrxmlns.Value;
end;
function Relationships.WriteXmlAttrxmlns(_value);
begin
if ifnil({self.}XmlAttrxmlns) then
begin
{self.}XmlAttrxmlns := new OpenXmlAttribute("", "xmlns", nil);
attributes_[length(attributes_)] := {self.}XmlAttrxmlns;
end
{self.}XmlAttrxmlns.Value := _value;
end;
function Relationships.ReadRelationships(_index);
begin
ind := ifnil(_index) ? -2 : _index;
pre := {self.}Prefix ? {self.}Prefix + ":" : "";
return container_.Get("Relationship", ind);
end;
function Relationships.AddRelationship(): Relationship;
begin
obj := new Relationship(self, "", "Relationship");
container_.Insert(obj);
return obj;
end;
function Relationships.AppendRelationship(): Relationship;
begin
obj := new Relationship(self, "", "Relationship");
container_.Append(obj);
return obj;
end;