v2.1.1 大量更新,功能性更新见readme
This commit is contained in:
@@ -9,11 +9,9 @@ public
|
||||
function AppendChild(_element: OpenXmlElement);
|
||||
function InsertAfter(_element: OpenXmlElement; _pos_element: OpenXmlElement);
|
||||
function RemoveChild(_element: OpenXmlElement);
|
||||
function RemoveAttribute(_attr: OpenXmlAttribute);
|
||||
// function InsertBefore(_pos_obj: tslobj; _obj: tslobj);
|
||||
// function PrependChild(_obj: tslobj);
|
||||
// function SetAttribute(_obj: OpenXmlAttribute);
|
||||
// function RemoveAttribute();
|
||||
|
||||
public
|
||||
function GetOrCreateNode(_obj: tslobj);
|
||||
@@ -65,15 +63,16 @@ end;
|
||||
function OpenXmlCompositeElement.Serialize();override;
|
||||
begin
|
||||
if {self.}DeleteSelf() then return;
|
||||
{self.}GetNode();
|
||||
|
||||
// xmlns
|
||||
for k, v in xmlns_ do
|
||||
{self.}GetNode().SetAttribute(v.ElementName, v.Value);
|
||||
{self.}XmlNode.SetAttribute(v.ElementName, v.Value);
|
||||
|
||||
// Attributes
|
||||
for k, v in attributes_ do
|
||||
if not ifnil(v.Value) then
|
||||
{self.}GetNode().SetAttribute(v.ElementName, v.Value);
|
||||
{self.}XmlNode.SetAttribute(v.ElementName, v.Value);
|
||||
else if {self.}XmlNode then
|
||||
{self.}XmlNode.DeleteAttribute(v.ElementName);
|
||||
|
||||
@@ -152,8 +151,3 @@ begin
|
||||
_element.Removed := true;
|
||||
end;
|
||||
|
||||
function OpenXmlCompositeElement.RemoveAttribute(_attr: OpenXmlAttribute);
|
||||
begin
|
||||
_attr.Value := nil;
|
||||
end;
|
||||
|
||||
|
||||
@@ -9,11 +9,16 @@ public
|
||||
function Serialize();virtual;
|
||||
function Marshal(): tableArray;virtual;
|
||||
|
||||
function SetFallback(_fallback: OpenXmlElement);
|
||||
function RemoveAttribute(_attr: OpenXmlAttribute);
|
||||
function Attribute(_attr: string; _ns: string): OpenXmlAttribute;
|
||||
function Attributes(): array of OpenXmlAttribute;
|
||||
function Elements(): array of tslobj;
|
||||
function Xmlns(_prefix: string): string;
|
||||
|
||||
// 单位转换
|
||||
function ConvertToPoint();virtual;
|
||||
|
||||
protected
|
||||
function GetNode(): XmlNode;
|
||||
function DeleteSelf(): boolean;
|
||||
@@ -32,6 +37,7 @@ protected
|
||||
xmlns_: tableArray;
|
||||
sorted_child_: tableArray;
|
||||
container_: TSOfficeContainer;
|
||||
fallback_: OpenXmlElement; // 代理对象
|
||||
end;
|
||||
|
||||
function OpenXmlElement.Create(_node: XmlNode);overload;
|
||||
@@ -53,12 +59,18 @@ begin
|
||||
{self.}Removed := false;
|
||||
{self.}Init();
|
||||
xmlns_ := array();
|
||||
fallback_ := nil;
|
||||
end;
|
||||
|
||||
function OpenXmlElement.SetFallback(_fallback: OpenXmlElement);
|
||||
begin
|
||||
fallback_ := _fallback;
|
||||
end;
|
||||
|
||||
function OpenXmlElement.Attribute(_attr: string; _ns: string): OpenXmlAttribute;
|
||||
begin
|
||||
if ifnil(_ns) then
|
||||
attr_name := ifString({self.}Prefix) and {self.}Prefix <> "" ? format("%s:%%s", {self.}Prefix, _attr) : _attr;
|
||||
attr_name := ifString({self.}Prefix) and {self.}Prefix <> "" ? format("%s:%s", {self.}Prefix, _attr) : _attr;
|
||||
else
|
||||
attr_name := format("%s:%s", _ns, _attr);
|
||||
return attributes_[attr_name];
|
||||
@@ -67,8 +79,9 @@ end;
|
||||
function OpenXmlElement.Attributes(): array of OpenXmlAttribute;
|
||||
begin
|
||||
attrs := array();
|
||||
for k, v in attributes_ do
|
||||
attrs[length(attrs)] := v;
|
||||
for k,v in attributes_ do
|
||||
if not ifnil(v.Value) then
|
||||
attrs[length(attrs)] := v;
|
||||
return attrs;
|
||||
end;
|
||||
|
||||
@@ -105,3 +118,7 @@ begin
|
||||
return false;
|
||||
end;
|
||||
|
||||
function OpenXmlElement.RemoveAttribute(_attr: OpenXmlAttribute);
|
||||
begin
|
||||
_attr.Value := nil;
|
||||
end;
|
||||
|
||||
@@ -73,13 +73,16 @@ function OpenXmlSimpleType.Serialize();override;
|
||||
begin
|
||||
if not ifObj({self.}XmlNode) then
|
||||
begin
|
||||
if not ifnil({self.}XmlAttrVal.Value) then {self.}GetNode().SetAttribute({self.}XmlAttrVal.ElementName, {self.}XmlAttrVal.Value);
|
||||
{self.}GetNode();
|
||||
if not ifnil({self.}XmlAttrVal.Value) then {self.}XmlNode.SetAttribute({self.}XmlAttrVal.ElementName, {self.}XmlAttrVal.Value);
|
||||
end
|
||||
else begin
|
||||
if not {self.}Enable or {self.}Removed then
|
||||
{self.}Parent.XmlNode.DeleteChild({self.}XmlNode);
|
||||
else if not ifnil({self.}XmlAttrVal.Value) then
|
||||
{self.}XmlNode.SetAttribute({self.}XmlAttrVal.ElementName, {self.}XmlAttrVal.Value);
|
||||
else if ifnil({self.}XmlAttrVal.Value) then
|
||||
{self.}XmlNode.DeleteAttribute({self.}XmlAttrVal.ElementName);
|
||||
end
|
||||
end;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user