type BarChart = 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 InitAttributes();override; function InitChildren();override; function InitNode(_node: XmlNode);override; function Copy(_obj: BarChart);override; function AddSer(): Ser; function AddAxId(): PureVal; function AppendSer(): Ser; function AppendAxId(): PureVal; property Sers read ReadSers; property AxIds read ReadAxIds; function ReadSers(_index); function ReadAxIds(_index); public // Attributes // Children BarDir: PureVal; Grouping: PureVal; VaryColors: PureVal; GapWidth: PureVal; end; function BarChart.Create();overload; begin {self.}Create(nil, "c", "barChart"); end; function BarChart.Create(_node: XmlNode);overload; begin class(OpenXmlElement).Create(_node: XmlNode); end; function BarChart.Create(_parent: tslobj; _prefix: string; _local_name: string);overload; begin class(OpenXmlElement).Create(_parent, _prefix, _local_name); end; function BarChart.Init();override; begin {self.}BarDir := new PureVal(self, {self.}Prefix, "barDir"); {self.}Grouping := new PureVal(self, {self.}Prefix, "grouping"); {self.}VaryColors := new PureVal(self, {self.}Prefix, "varyColors"); {self.}GapWidth := new PureVal(self, {self.}Prefix, "gapWidth"); end; function BarChart.InitAttributes();override; begin attributes_ := array( ); end; function BarChart.InitChildren();override; begin child_elements_ := array( 0: {self.}BarDir, 1: {self.}Grouping, 2: {self.}VaryColors, 4: {self.}GapWidth, ); sorted_child_ := array( "": -1, {self.}BarDir.ElementName: 0, {self.}Grouping.ElementName: 1, {self.}VaryColors.ElementName: 2, {self.}GapWidth.ElementName: 4, ); end; function BarChart.InitNode(_node: XmlNode);override; begin if ifObj({self.}XmlNode) then for k,v in child_elements_ do v.InitNode(nil); {self.}XmlNode := ifObj(_node) ? _node : nil; node := ifObj(_node) ? _node.FirstChild() : nil; flag := false; if ifnil(child_elements_[0]) and length(child_elements_) > 0 then begin flag := true; arr := child_elements_; child_elements_ := array(); end pre := ifString({self.}Prefix) ? {self.}Prefix + ":" : ""; while ifObj(node) do begin node_name := node.GetName(); pos := sorted_child_[node_name]; if ifnil(pos) or pos = -1 then begin obj := nil; case node_name of pre + "ser": obj := {self.}AppendSer(); pre + "axId": obj := {self.}AppendAxId(); end; if ifObj(obj) then obj.InitNode(node); end else if flag then begin obj := arr[pos]; obj.InitNode(node); child_elements_[length(child_elements_)] := obj; end else begin child_elements_[pos].InitNode(node); end node := node.NextElement(); end end; function BarChart.Copy(_obj: BarChart);override; begin {self.}BarDir.Copy(_obj.BarDir); {self.}Grouping.Copy(_obj.Grouping); {self.}VaryColors.Copy(_obj.VaryColors); {self.}GapWidth.Copy(_obj.GapWidth); end; function BarChart.AddSer(): Ser; begin len := length(child_elements_); if len = 0 then i := -1; else begin for i:=len-1 downto 0 do if child_elements_[i].LocalName = "ser" then break; end obj := new Ser(self, {self.}Prefix, "ser"); {self.}InsertChild(obj, i+1); return obj; end; function BarChart.AddAxId(): PureVal; begin len := length(child_elements_); if len = 0 then i := -1; else begin for i:=len-1 downto 0 do if child_elements_[i].LocalName = "axId" then break; end obj := new PureVal(self, {self.}Prefix, "axId"); {self.}InsertChild(obj, i+1); return obj; end; function BarChart.AppendSer(): Ser; begin obj := new Ser(self, {self.}Prefix, "ser"); child_elements_[length(child_elements_)] := obj; return obj; end; function BarChart.AppendAxId(): PureVal; begin obj := new PureVal(self, {self.}Prefix, "axId"); child_elements_[length(child_elements_)] := obj; return obj; end; function BarChart.ReadSers(_index); begin ind := ifnil(_index) ? -2 : _index; arr := array(); for k,v in child_elements_ do begin if v.LocalName = "ser" then begin arr[length(arr)] := v; ind--; end; if ind = -1 then return v; end; return arr; end; function BarChart.ReadAxIds(_index); begin ind := ifnil(_index) ? -2 : _index; arr := array(); for k,v in child_elements_ do begin if v.LocalName = "axId" then begin arr[length(arr)] := v; ind--; end; if ind = -1 then return v; end; return arr; end;