Compare commits

..
7 Commits
Author SHA1 Message Date
csh c92fd3b638 patch1 2025-09-26 11:36:18 +08:00
csh 20a343f501 20250925 2025-09-25 17:57:23 +08:00
csh 67a7d27363 3.0.0 update 2025-09-16 11:29:58 +08:00
csh 0b60aeb006 v3.0.0 2025-08-06 18:23:02 +08:00
csh 16452c8362 improvement: 单位转换的调整 2025-08-06 18:16:15 +08:00
csh 9062457251 update README 2025-08-06 18:14:29 +08:00
csh 7a65e50157 feat: 支持clone方法
feat: 支持反序列化的缓存,第二次反序列化不会执行操作
feat: openxmlelement类支持Enable属性来控制节点是否生成
2025-08-06 18:14:09 +08:00
27 changed files with 23108 additions and 7594 deletions
+6
View File
@@ -0,0 +1,6 @@
unit OFFICEXML;
interface
const Version = "2025 09 25";
implementation
end.
+79
View File
@@ -146,6 +146,85 @@ ppr1.Jc.Val; // 得到"left"
ppr1.WordWrap.Val; // ppr1不存在wordWrap,但是ppr2存在wordWrap,所以回落到ppr2的wordWrap获取到"1"
```
### Copy
`copy`方法支持将其他的类属性和子节点的属性复制过来,注意:复数的类无法进行复制,因为不确定怎么进行复制
```xml
// pPr1
<w:pPr>
<w:jc w:val="left" />
<w:spacing w:after="160" />
</w:pPr>
// pPr2
<w:pPr>
<w:jc w:val="right" />
<w:wordWrap w:val="1" />
</w:pPr>
```
```go
// 假设要将ppr2的属性复制到ppr1
ppr1.Copy(ppr2);
```
```xml
// 复制完毕后ppr1 xml如下
// 因为ppr2没有w:spacing,所以保留ppr1的w:spacing
<w:pPr>
<w:jc w:val="right" />
<w:wordWrap w:val="1" />
<w:spacing w:after="160" />
</w:pPr>
```
```xml
// 这样是不能复制的,w:r是复数
<w:p>
<w:r w:rsidR="00CC4888">
<w:t>test</w:t>
</w:r>
<w:r w:rsidR="00CD1015">
<w:rPr>
<w:rFonts w:hint="eastAsia"/>
</w:rPr>
<w:t></w:t>
</w:r>
</w:p>
获取r并不是p.r进行获取,而是p.Rs();
```
### Clone
`Clone`方法是克隆出一个一样的对象出来,但是`Parent``nil`
```xml
<w:p>
<w:pPr>
<w:jc w:val="right" />
<w:wordWrap w:val="1" />
<w:spacing w:after="160" />
</w:pPr>
<w:r w:rsidR="00CC4888">
<w:t>test</w:t>
</w:r>
<w:r w:rsidR="00CD1015">
<w:rPr>
<w:rFonts w:hint="eastAsia"/>
</w:rPr>
<w:t></w:t>
</w:r>
</w:p>
```
```go
new_p := p.Clone(); // 与p的xml一致
echo new_p.Parent; // nil
document.InsertAfter(new_p, p); // 插入一样的段落在p之后,此时会自动设置new_p.Parent := document
```
## Unit 单元
- `DocxML`包含 `docx`文件独有的 xml 节点对象,一般 xml 的命名空间是 `w`,如 `w:p`
+7546 -3009
View File
File diff suppressed because it is too large Load Diff
-373
View File
@@ -1,373 +0,0 @@
unit DocxMLAdapter;
interface
type TabsAdapter = class
public
function Create(_obj: Tabs);
function Init();
function GetTabByVal(_key: string);
function SetTabByVal(_key: string; _value: tslobj);
private
object_: Tabs;
tab_hash_: tableArray;
end;
type SectPrAdapter = class
public
function Create(_obj: SectPr);
function Init();
function GetHeaderReferenceByType(_key: string);
function SetHeaderReferenceByType(_key: string; _value: tslobj);
function GetFooterReferenceByType(_key: string);
function SetFooterReferenceByType(_key: string; _value: tslobj);
private
object_: SectPr;
headerreference_hash_: tableArray;
footerreference_hash_: tableArray;
end;
type EndnotesAdapter = class
public
function Create(_obj: Endnotes);
function Init();
function GetEndnoteById(_key: string);
function SetEndnoteById(_key: string; _value: tslobj);
private
object_: Endnotes;
endnote_hash_: tableArray;
end;
type FootnotesAdapter = class
public
function Create(_obj: Footnotes);
function Init();
function GetFootnoteById(_key: string);
function SetFootnoteById(_key: string; _value: tslobj);
private
object_: Footnotes;
footnote_hash_: tableArray;
end;
type FootnotePrAdapter = class
public
function Create(_obj: FootnotePr);
function Init();
function GetFootnoteById(_key: string);
function SetFootnoteById(_key: string; _value: tslobj);
private
object_: FootnotePr;
footnote_hash_: tableArray;
end;
type EndnotePrAdapter = class
public
function Create(_obj: EndnotePr);
function Init();
function GetFootnoteById(_key: string);
function SetFootnoteById(_key: string; _value: tslobj);
private
object_: EndnotePr;
footnote_hash_: tableArray;
end;
type StylesAdapter = class
public
function Create(_obj: Styles);
function Init();
function GetStyleByStyleId(_key: string);
function SetStyleByStyleId(_key: string; _value: tslobj);
private
object_: Styles;
style_hash_: tableArray;
end;
type StyleAdapter = class
public
function Create(_obj: Style);
function Init();
function GetTblStylePrByType(_key: string);
function SetTblStylePrByType(_key: string; _value: tslobj);
private
object_: Style;
tblstylepr_hash_: tableArray;
end;
type NumberingAdapter = class
public
function Create(_obj: Numbering);
function Init();
function GetAbstractNumByAbstractNumId(_key: string);
function SetAbstractNumByAbstractNumId(_key: string; _value: tslobj);
function GetNumByNumId(_key: string);
function SetNumByNumId(_key: string; _value: tslobj);
private
object_: Numbering;
abstractnum_hash_: tableArray;
num_hash_: tableArray;
end;
implementation
function TabsAdapter.Create(_obj: Tabs);
begin
object_ := _obj;
tab_hash_ := array();
{self.}Init();
end;
function TabsAdapter.Init();
begin
elements := object_.Tabs();
for k,v in elements do
tab_hash_[v.Val] := v;
end;
function TabsAdapter.GetTabByVal(_key: string);
begin
return tab_hash_[_key];
end;
function TabsAdapter.SetTabByVal(_key: string; _value: tslobj);
begin
tab_hash_[_key] := _value;
end;
function SectPrAdapter.Create(_obj: SectPr);
begin
object_ := _obj;
headerreference_hash_ := array();
footerreference_hash_ := array();
{self.}Init();
end;
function SectPrAdapter.Init();
begin
elements := object_.HeaderReferences();
for k,v in elements do
headerreference_hash_[v.Type] := v;
elements := object_.FooterReferences();
for k,v in elements do
footerreference_hash_[v.Type] := v;
end;
function SectPrAdapter.GetHeaderReferenceByType(_key: string);
begin
return headerreference_hash_[_key];
end;
function SectPrAdapter.SetHeaderReferenceByType(_key: string; _value: tslobj);
begin
headerreference_hash_[_key] := _value;
end;
function SectPrAdapter.GetFooterReferenceByType(_key: string);
begin
return footerreference_hash_[_key];
end;
function SectPrAdapter.SetFooterReferenceByType(_key: string; _value: tslobj);
begin
footerreference_hash_[_key] := _value;
end;
function EndnotesAdapter.Create(_obj: Endnotes);
begin
object_ := _obj;
endnote_hash_ := array();
{self.}Init();
end;
function EndnotesAdapter.Init();
begin
elements := object_.Endnotes();
for k,v in elements do
endnote_hash_[v.Id] := v;
end;
function EndnotesAdapter.GetEndnoteById(_key: string);
begin
return endnote_hash_[_key];
end;
function EndnotesAdapter.SetEndnoteById(_key: string; _value: tslobj);
begin
endnote_hash_[_key] := _value;
end;
function FootnotesAdapter.Create(_obj: Footnotes);
begin
object_ := _obj;
footnote_hash_ := array();
{self.}Init();
end;
function FootnotesAdapter.Init();
begin
elements := object_.Footnotes();
for k,v in elements do
footnote_hash_[v.Id] := v;
end;
function FootnotesAdapter.GetFootnoteById(_key: string);
begin
return footnote_hash_[_key];
end;
function FootnotesAdapter.SetFootnoteById(_key: string; _value: tslobj);
begin
footnote_hash_[_key] := _value;
end;
function FootnotePrAdapter.Create(_obj: FootnotePr);
begin
object_ := _obj;
footnote_hash_ := array();
{self.}Init();
end;
function FootnotePrAdapter.Init();
begin
elements := object_.Footnotes();
for k,v in elements do
footnote_hash_[v.Id] := v;
end;
function FootnotePrAdapter.GetFootnoteById(_key: string);
begin
return footnote_hash_[_key];
end;
function FootnotePrAdapter.SetFootnoteById(_key: string; _value: tslobj);
begin
footnote_hash_[_key] := _value;
end;
function EndnotePrAdapter.Create(_obj: EndnotePr);
begin
object_ := _obj;
footnote_hash_ := array();
{self.}Init();
end;
function EndnotePrAdapter.Init();
begin
elements := object_.Footnotes();
for k,v in elements do
footnote_hash_[v.Id] := v;
end;
function EndnotePrAdapter.GetFootnoteById(_key: string);
begin
return footnote_hash_[_key];
end;
function EndnotePrAdapter.SetFootnoteById(_key: string; _value: tslobj);
begin
footnote_hash_[_key] := _value;
end;
function StylesAdapter.Create(_obj: Styles);
begin
object_ := _obj;
style_hash_ := array();
{self.}Init();
end;
function StylesAdapter.Init();
begin
elements := object_.Styles();
for k,v in elements do
style_hash_[v.StyleId] := v;
end;
function StylesAdapter.GetStyleByStyleId(_key: string);
begin
return style_hash_[_key];
end;
function StylesAdapter.SetStyleByStyleId(_key: string; _value: tslobj);
begin
style_hash_[_key] := _value;
end;
function StyleAdapter.Create(_obj: Style);
begin
object_ := _obj;
tblstylepr_hash_ := array();
{self.}Init();
end;
function StyleAdapter.Init();
begin
elements := object_.TblStylePrs();
for k,v in elements do
tblstylepr_hash_[v.Type] := v;
end;
function StyleAdapter.GetTblStylePrByType(_key: string);
begin
return tblstylepr_hash_[_key];
end;
function StyleAdapter.SetTblStylePrByType(_key: string; _value: tslobj);
begin
tblstylepr_hash_[_key] := _value;
end;
function NumberingAdapter.Create(_obj: Numbering);
begin
object_ := _obj;
abstractnum_hash_ := array();
num_hash_ := array();
{self.}Init();
end;
function NumberingAdapter.Init();
begin
elements := object_.AbstractNums();
for k,v in elements do
abstractnum_hash_[v.AbstractNumId] := v;
elements := object_.Nums();
for k,v in elements do
num_hash_[v.NumId] := v;
end;
function NumberingAdapter.GetAbstractNumByAbstractNumId(_key: string);
begin
return abstractnum_hash_[_key];
end;
function NumberingAdapter.SetAbstractNumByAbstractNumId(_key: string; _value: tslobj);
begin
abstractnum_hash_[_key] := _value;
end;
function NumberingAdapter.GetNumByNumId(_key: string);
begin
return num_hash_[_key];
end;
function NumberingAdapter.SetNumByNumId(_key: string; _value: tslobj);
begin
num_hash_[_key] := _value;
end;
end.
+527
View File
@@ -0,0 +1,527 @@
unit DocxMLAdapters;
interface
type Tabs = class
public
function create(_obj: Tabs);
function Init();
function GetTabByVal(_key: string);
function AddTab(_value: Tab);
function RemoveTab(_value: Tab);
property TabCount: uinteger read tab_count_;
private
object_: Tabs;
tab_val_hash_: hash;
tab_count_: uinteger;
end;
type SectPr = class
public
function create(_obj: SectPr);
function Init();
function GetHeaderReferenceByType(_key: string);
function AddHeaderReference(_value: HeaderReference);
function RemoveHeaderReference(_value: HeaderReference);
function GetFooterReferenceByType(_key: string);
function AddFooterReference(_value: FooterReference);
function RemoveFooterReference(_value: FooterReference);
property HeaderReferenceCount: uinteger read headerreference_count_;
property FooterReferenceCount: uinteger read footerreference_count_;
private
object_: SectPr;
headerreference_type_hash_: hash;
headerreference_count_: uinteger;
footerreference_type_hash_: hash;
footerreference_count_: uinteger;
end;
type Endnotes = class
public
function create(_obj: Endnotes);
function Init();
function GetEndnoteById(_key: string);
function AddEndnote(_value: Endnote);
function RemoveEndnote(_value: Endnote);
property EndnoteCount: uinteger read endnote_count_;
private
object_: Endnotes;
endnote_id_hash_: hash;
endnote_count_: uinteger;
end;
type Footnotes = class
public
function create(_obj: Footnotes);
function Init();
function GetFootnoteById(_key: string);
function AddFootnote(_value: Footnote);
function RemoveFootnote(_value: Footnote);
property FootnoteCount: uinteger read footnote_count_;
private
object_: Footnotes;
footnote_id_hash_: hash;
footnote_count_: uinteger;
end;
type FootnotePr = class
public
function create(_obj: FootnotePr);
function Init();
function GetFootnoteById(_key: string);
function AddFootnote(_value: Footnote);
function RemoveFootnote(_value: Footnote);
property FootnoteCount: uinteger read footnote_count_;
private
object_: FootnotePr;
footnote_id_hash_: hash;
footnote_count_: uinteger;
end;
type EndnotePr = class
public
function create(_obj: EndnotePr);
function Init();
function GetFootnoteById(_key: string);
function AddFootnote(_value: Footnote);
function RemoveFootnote(_value: Footnote);
property FootnoteCount: uinteger read footnote_count_;
private
object_: EndnotePr;
footnote_id_hash_: hash;
footnote_count_: uinteger;
end;
type Styles = class
public
function create(_obj: Styles);
function Init();
function GetStyleByStyleId(_key: string);
function GetStyleByName(_key: string);
function AddStyle(_value: Style);
function RemoveStyle(_value: Style);
property StyleCount: uinteger read style_count_;
private
object_: Styles;
style_styleid_hash_: hash;
style_name_hash_: hash;
style_count_: uinteger;
end;
type Style = class
public
function create(_obj: Style);
function Init();
function GetTblStylePrByType(_key: string);
function AddTblStylePr(_value: TblStylePr);
function RemoveTblStylePr(_value: TblStylePr);
property TblStylePrCount: uinteger read tblstylepr_count_;
private
object_: Style;
tblstylepr_type_hash_: hash;
tblstylepr_count_: uinteger;
end;
type Numbering = class
public
function create(_obj: Numbering);
function Init();
function GetAbstractNumByAbstractNumId(_key: string);
function AddAbstractNum(_value: AbstractNum);
function RemoveAbstractNum(_value: AbstractNum);
function GetNumByNumId(_key: string);
function AddNum(_value: Num);
function RemoveNum(_value: Num);
property AbstractNumCount: uinteger read abstractnum_count_;
property NumCount: uinteger read num_count_;
private
object_: Numbering;
abstractnum_abstractnumid_hash_: hash;
abstractnum_count_: uinteger;
num_numid_hash_: hash;
num_count_: uinteger;
end;
implementation
function Tabs.create(_obj: Tabs);
begin
object_ := _obj;
tab_count_ := 0;
tab_val_hash_ := array();
{self.}Init();
end;
function Tabs.Init();
begin
elements := object_.Tabs();
tab_count_ := length(elements);
for k,v in elements do
tab_val_hash_[v.Val] := v;
end;
function Tabs.GetTabByVal(_key: string);
begin
return tab_val_hash_[_key];
end;
function Tabs.AddTab(_value: Tab);
begin
tab_val_hash_[_value.Val] := _value;
tab_count_++;
end;
function Tabs.RemoveTab(_value: Tab);
begin
reindex(tab_val_hash_, array(_value.Val: nil));
tab_count_--;
end;
function SectPr.create(_obj: SectPr);
begin
object_ := _obj;
headerreference_count_ := 0;
headerreference_type_hash_ := array();
footerreference_count_ := 0;
footerreference_type_hash_ := array();
{self.}Init();
end;
function SectPr.Init();
begin
elements := object_.HeaderReferences();
headerreference_count_ := length(elements);
for k,v in elements do
headerreference_type_hash_[v.Type] := v;
elements := object_.FooterReferences();
footerreference_count_ := length(elements);
for k,v in elements do
footerreference_type_hash_[v.Type] := v;
end;
function SectPr.GetHeaderReferenceByType(_key: string);
begin
return headerreference_type_hash_[_key];
end;
function SectPr.AddHeaderReference(_value: HeaderReference);
begin
headerreference_type_hash_[_value.Type] := _value;
headerreference_count_++;
end;
function SectPr.RemoveHeaderReference(_value: HeaderReference);
begin
reindex(headerreference_type_hash_, array(_value.Type: nil));
headerreference_count_--;
end;
function SectPr.GetFooterReferenceByType(_key: string);
begin
return footerreference_type_hash_[_key];
end;
function SectPr.AddFooterReference(_value: FooterReference);
begin
footerreference_type_hash_[_value.Type] := _value;
footerreference_count_++;
end;
function SectPr.RemoveFooterReference(_value: FooterReference);
begin
reindex(footerreference_type_hash_, array(_value.Type: nil));
footerreference_count_--;
end;
function Endnotes.create(_obj: Endnotes);
begin
object_ := _obj;
endnote_count_ := 0;
endnote_id_hash_ := array();
{self.}Init();
end;
function Endnotes.Init();
begin
elements := object_.Endnotes();
endnote_count_ := length(elements);
for k,v in elements do
endnote_id_hash_[v.Id] := v;
end;
function Endnotes.GetEndnoteById(_key: string);
begin
return endnote_id_hash_[_key];
end;
function Endnotes.AddEndnote(_value: Endnote);
begin
endnote_id_hash_[_value.Id] := _value;
endnote_count_++;
end;
function Endnotes.RemoveEndnote(_value: Endnote);
begin
reindex(endnote_id_hash_, array(_value.Id: nil));
endnote_count_--;
end;
function Footnotes.create(_obj: Footnotes);
begin
object_ := _obj;
footnote_count_ := 0;
footnote_id_hash_ := array();
{self.}Init();
end;
function Footnotes.Init();
begin
elements := object_.Footnotes();
footnote_count_ := length(elements);
for k,v in elements do
footnote_id_hash_[v.Id] := v;
end;
function Footnotes.GetFootnoteById(_key: string);
begin
return footnote_id_hash_[_key];
end;
function Footnotes.AddFootnote(_value: Footnote);
begin
footnote_id_hash_[_value.Id] := _value;
footnote_count_++;
end;
function Footnotes.RemoveFootnote(_value: Footnote);
begin
reindex(footnote_id_hash_, array(_value.Id: nil));
footnote_count_--;
end;
function FootnotePr.create(_obj: FootnotePr);
begin
object_ := _obj;
footnote_count_ := 0;
footnote_id_hash_ := array();
{self.}Init();
end;
function FootnotePr.Init();
begin
elements := object_.Footnotes();
footnote_count_ := length(elements);
for k,v in elements do
footnote_id_hash_[v.Id] := v;
end;
function FootnotePr.GetFootnoteById(_key: string);
begin
return footnote_id_hash_[_key];
end;
function FootnotePr.AddFootnote(_value: Footnote);
begin
footnote_id_hash_[_value.Id] := _value;
footnote_count_++;
end;
function FootnotePr.RemoveFootnote(_value: Footnote);
begin
reindex(footnote_id_hash_, array(_value.Id: nil));
footnote_count_--;
end;
function EndnotePr.create(_obj: EndnotePr);
begin
object_ := _obj;
footnote_count_ := 0;
footnote_id_hash_ := array();
{self.}Init();
end;
function EndnotePr.Init();
begin
elements := object_.Footnotes();
footnote_count_ := length(elements);
for k,v in elements do
footnote_id_hash_[v.Id] := v;
end;
function EndnotePr.GetFootnoteById(_key: string);
begin
return footnote_id_hash_[_key];
end;
function EndnotePr.AddFootnote(_value: Footnote);
begin
footnote_id_hash_[_value.Id] := _value;
footnote_count_++;
end;
function EndnotePr.RemoveFootnote(_value: Footnote);
begin
reindex(footnote_id_hash_, array(_value.Id: nil));
footnote_count_--;
end;
function Styles.create(_obj: Styles);
begin
object_ := _obj;
style_count_ := 0;
style_styleid_hash_ := array();
style_name_hash_ := array();
{self.}Init();
end;
function Styles.Init();
begin
elements := object_.Styles();
style_count_ := length(elements);
for k,v in elements do
begin
style_styleid_hash_[v.StyleId] := v;
style_name_hash_[v.Name.Val] := v;
end
end;
function Styles.GetStyleByStyleId(_key: string);
begin
return style_styleid_hash_[_key];
end;
function Styles.GetStyleByName(_key: string);
begin
return style_name_hash_[_key];
end;
function Styles.AddStyle(_value: Style);
begin
style_styleid_hash_[_value.StyleId] := _value;
style_name_hash_[_value.Name.Val] := _value;
style_count_++;
end;
function Styles.RemoveStyle(_value: Style);
begin
reindex(style_styleid_hash_, array(_value.StyleId: nil));
reindex(style_name_hash_, array(_value.Name.Val: nil));
style_count_--;
end;
function Style.create(_obj: Style);
begin
object_ := _obj;
tblstylepr_count_ := 0;
tblstylepr_type_hash_ := array();
{self.}Init();
end;
function Style.Init();
begin
elements := object_.TblStylePrs();
tblstylepr_count_ := length(elements);
for k,v in elements do
tblstylepr_type_hash_[v.Type] := v;
end;
function Style.GetTblStylePrByType(_key: string);
begin
return tblstylepr_type_hash_[_key];
end;
function Style.AddTblStylePr(_value: TblStylePr);
begin
tblstylepr_type_hash_[_value.Type] := _value;
tblstylepr_count_++;
end;
function Style.RemoveTblStylePr(_value: TblStylePr);
begin
reindex(tblstylepr_type_hash_, array(_value.Type: nil));
tblstylepr_count_--;
end;
function Numbering.create(_obj: Numbering);
begin
object_ := _obj;
abstractnum_count_ := 0;
abstractnum_abstractnumid_hash_ := array();
num_count_ := 0;
num_numid_hash_ := array();
{self.}Init();
end;
function Numbering.Init();
begin
elements := object_.AbstractNums();
abstractnum_count_ := length(elements);
for k,v in elements do
abstractnum_abstractnumid_hash_[v.AbstractNumId] := v;
elements := object_.Nums();
num_count_ := length(elements);
for k,v in elements do
num_numid_hash_[v.NumId] := v;
end;
function Numbering.GetAbstractNumByAbstractNumId(_key: string);
begin
return abstractnum_abstractnumid_hash_[_key];
end;
function Numbering.AddAbstractNum(_value: AbstractNum);
begin
abstractnum_abstractnumid_hash_[_value.AbstractNumId] := _value;
abstractnum_count_++;
end;
function Numbering.RemoveAbstractNum(_value: AbstractNum);
begin
reindex(abstractnum_abstractnumid_hash_, array(_value.AbstractNumId: nil));
abstractnum_count_--;
end;
function Numbering.GetNumByNumId(_key: string);
begin
return num_numid_hash_[_key];
end;
function Numbering.AddNum(_value: Num);
begin
num_numid_hash_[_value.NumId] := _value;
num_count_++;
end;
function Numbering.RemoveNum(_value: Num);
begin
reindex(num_numid_hash_, array(_value.NumId: nil));
num_count_--;
end;
end.
File diff suppressed because it is too large Load Diff
+8015 -1864
View File
File diff suppressed because it is too large Load Diff
-6
View File
@@ -1,6 +0,0 @@
unit DrawingMLAdapter;
interface
implementation
end.
+6
View File
@@ -0,0 +1,6 @@
unit DrawingMLAdapters;
interface
implementation
end.
File diff suppressed because it is too large Load Diff
+89 -71
View File
@@ -3,28 +3,30 @@ interface
type SldLayoutId = class(OpenXmlCompositeElement)
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: SldLayoutId);override;
public
// attributes property
property Id read ReadXmlAttrId write WriteXmlAttrId;
property Id read ReadXmlAttrId write WriteXmlAttrId;
property Id read ReadXmlAttrId write WriteXmlAttrId;
function ReadXmlAttrId();
function WriteXmlAttrId(_value);
function ReadXmlAttrId();
function WriteXmlAttrId(_value);
function ReadXmlAttrId();
function WriteXmlAttrId(_value);
function Create();overload;
function Create(_node: XmlNode);overload;
function Create(_parent: tslobj; _prefix: string; _local_name: string);overload;
function Init();override;
function Copy(_obj: SldLayoutId);override;
function ConvertToPoint();override;
public
// Attributes
XmlAttrId: OpenXmlAttribute;
XmlAttrId: OpenXmlAttribute;
XmlAttrId: OpenXmlAttribute;
// attributes property
property Id read ReadXmlAttrId write WriteXmlAttrId;
property IdN read ReadXmlAttrIdN write WriteXmlAttrIdN;
property RId read ReadXmlAttrRId write WriteXmlAttrRId;
function ReadXmlAttrId(_ns: string);
function WriteXmlAttrId(_p1: any; _p2: any);
function ReadXmlAttrIdN();
function WriteXmlAttrIdN(_value: any);
function ReadXmlAttrRId();
function WriteXmlAttrRId(_value: any);
public
// Attributes
XmlAttrId: OpenXmlAttribute;
XmlAttrIdN: OpenXmlAttribute;
XmlAttrRId: OpenXmlAttribute;
end;
@@ -32,91 +34,107 @@ implementation
function SldLayoutId.Create();overload;
begin
{self.}Create(nil, "p", "sldLayoutId");
{self.}Create(nil, "p", "sldLayoutId");
end;
function SldLayoutId.Create(_node: XmlNode);overload;
begin
class(OpenXmlCompositeElement).Create(_node: XmlNode);
inherited Create(_node);
end;
function SldLayoutId.Create(_parent: tslobj; _prefix: string; _local_name: string);overload;
begin
setsysparam(pn_calcctrlword(), getsysparam(pn_calcctrlword()) .| 0x200);
class(OpenXmlCompositeElement).Create(_parent, _prefix, _local_name);
setsysparam(pn_calcctrlword(), getsysparam(pn_calcctrlword()) .| 0x200);
inherited Create(_parent, _prefix, _local_name);
end;
function SldLayoutId.Init();override;
begin
pre := {self.}Prefix ? {self.}Prefix + ":" : "";
attributes_ := array();
attributes_pf_ := array(
pre + "id": makeweakref(thisFunction(WriteXmlAttrId)),
"id": makeweakref(thisFunction(WriteXmlAttrId)),
"r:id": makeweakref(thisFunction(WriteXmlAttrId)),
);
sorted_child_ := array(
);
container_ := new TSOfficeContainer(sorted_child_);
pre := {self.}Prefix ? {self.}Prefix + ":" : "";
attributes_ := array();
attributes_pf_ := array(
pre + "id": makeweakref(thisFunction(WriteXmlAttrId)),
"id": makeweakref(thisFunction(WriteXmlAttrIdN)),
"r:id": makeweakref(thisFunction(WriteXmlAttrRId)),
);
sorted_child_ := array(
);
container_ := new TSOfficeContainer(sorted_child_);
end;
function SldLayoutId.Copy(_obj: SldLayoutId);override;
begin
tslassigning_backup := tslassigning;
tslassigning := 1;
class(OpenXmlCompositeElement).Copy(_obj);
if not ifnil(_obj.Id) then
{self.}Id := _obj.Id;
if not ifnil(_obj.Id) then
{self.}Id := _obj.Id;
if not ifnil(_obj.Id) then
{self.}Id := _obj.Id;
tslassigning := tslassigning_backup;
tslassigning_backup := tslassigning;
tslassigning := 1;
class(OpenXmlCompositeElement).Copy(_obj);
if not ifnil(_obj.Id) then
{self.}Id := _obj.Id;
if not ifnil(_obj.IdN) then
{self.}IdN := _obj.IdN;
if not ifnil(_obj.RId) then
{self.}RId := _obj.RId;
tslassigning := tslassigning_backup;
end;
function SldLayoutId.ReadXmlAttrId();
function SldLayoutId.ConvertToPoint();override;
begin
return {self.}XmlAttrId.Value;
end;
function SldLayoutId.WriteXmlAttrId(_value);
function SldLayoutId.ReadXmlAttrId(_ns: string);
begin
if ifnil({self.}XmlAttrId) then
begin
{self.}XmlAttrId := new OpenXmlAttribute({self.}Prefix, "id", nil);
attributes_[length(attributes_)] := {self.}XmlAttrId;
end
{self.}XmlAttrId.Value := _value;
if _ns = "" then
return {self.}ReadXmlAttrIdN();
if _ns = "r" then
return {self.}ReadXmlAttrRId();
return ifnil({self.}XmlAttrId.Value) ? fallback_.XmlAttrId.Value : {self.}XmlAttrId.Value;
end;
function SldLayoutId.ReadXmlAttrId();
function SldLayoutId.WriteXmlAttrId(_p1: any; _p2: any);
begin
return {self.}XmlAttrId.Value;
if realparamcount = 2 then
begin
if _p1 = "" then
return {self.}WriteXmlAttrIdN(_p2);
if _p1 = "r" then
return {self.}WriteXmlAttrRId(_p2);
end
if ifnil({self.}XmlAttrId) then
begin
{self.}XmlAttrId := new OpenXmlAttribute({self.}Prefix, "id", nil);
attributes_[{self.}Prefix ? {self.}Prefix + ":" + "id" : "id"] := {self.}XmlAttrId;
end
{self.}XmlAttrId.Value := realparamcount = 1 ? _p1 : _p2;
end;
function SldLayoutId.WriteXmlAttrId(_value);
function SldLayoutId.ReadXmlAttrIdN();
begin
if ifnil({self.}XmlAttrId) then
begin
{self.}XmlAttrId := new OpenXmlAttribute("", "id", nil);
attributes_[length(attributes_)] := {self.}XmlAttrId;
end
{self.}XmlAttrId.Value := _value;
return ifnil({self.}XmlAttrIdN.Value) ? fallback_.XmlAttrIdN.Value : {self.}XmlAttrIdN.Value;
end;
function SldLayoutId.ReadXmlAttrId();
function SldLayoutId.WriteXmlAttrIdN(_value: any);
begin
return {self.}XmlAttrId.Value;
if ifnil({self.}XmlAttrIdN) then
begin
{self.}XmlAttrIdN := new OpenXmlAttribute("", "id", nil);
attributes_["id"] := {self.}XmlAttrIdN;
end
{self.}XmlAttrIdN.Value := _value;
end;
function SldLayoutId.WriteXmlAttrId(_value);
function SldLayoutId.ReadXmlAttrRId();
begin
if ifnil({self.}XmlAttrId) then
begin
{self.}XmlAttrId := new OpenXmlAttribute("r", "id", nil);
attributes_[length(attributes_)] := {self.}XmlAttrId;
end
{self.}XmlAttrId.Value := _value;
return ifnil({self.}XmlAttrRId.Value) ? fallback_.XmlAttrRId.Value : {self.}XmlAttrRId.Value;
end;
function SldLayoutId.WriteXmlAttrRId(_value: any);
begin
if ifnil({self.}XmlAttrRId) then
begin
{self.}XmlAttrRId := new OpenXmlAttribute("r", "id", nil);
attributes_["r:id"] := {self.}XmlAttrRId;
end
{self.}XmlAttrRId.Value := _value;
end;
end.
-6
View File
@@ -1,6 +0,0 @@
unit PptxMLAdapter;
interface
implementation
end.
+4245 -777
View File
File diff suppressed because it is too large Load Diff
-43
View File
@@ -1,43 +0,0 @@
unit SharedMLAdapter;
interface
type RelationshipsAdapter = class
public
function Create(_obj: Relationships);
function Init();
function GetRelationshipById(_key: string);
function SetRelationshipById(_key: string; _value: tslobj);
private
object_: Relationships;
relationship_hash_: tableArray;
end;
implementation
function RelationshipsAdapter.Create(_obj: Relationships);
begin
object_ := _obj;
relationship_hash_ := array();
{self.}Init();
end;
function RelationshipsAdapter.Init();
begin
elements := object_.Relationships();
for k,v in elements do
relationship_hash_[v.Id] := v;
end;
function RelationshipsAdapter.GetRelationshipById(_key: string);
begin
return relationship_hash_[_key];
end;
function RelationshipsAdapter.SetRelationshipById(_key: string; _value: tslobj);
begin
relationship_hash_[_key] := _value;
end;
end.
+148
View File
@@ -0,0 +1,148 @@
unit SharedMLAdapters;
interface
type Relationships = class
public
function create(_obj: Relationships);
function Init();
function GetRelationshipById(_key: string);
function GetRelationshipByTarget(_key: string);
function AddRelationship(_value: Relationship);
function RemoveRelationship(_value: Relationship);
property RelationshipCount: uinteger read relationship_count_;
private
object_: Relationships;
relationship_id_hash_: hash;
relationship_target_hash_: hash;
relationship_count_: uinteger;
end;
type Types = class
public
function create(_obj: Types);
function Init();
function GetDefaultByExtension(_key: string);
function AddDefault(_value: Default);
function RemoveDefault(_value: Default);
function Get_OverrideByPartName(_key: string);
function Add_Override(_value: _Override);
function Remove_Override(_value: _Override);
property DefaultCount: uinteger read default_count_;
property _OverrideCount: uinteger read _override_count_;
private
object_: Types;
default_extension_hash_: hash;
default_count_: uinteger;
_override_partname_hash_: hash;
_override_count_: uinteger;
end;
implementation
function Relationships.create(_obj: Relationships);
begin
object_ := _obj;
relationship_count_ := 0;
relationship_id_hash_ := array();
relationship_target_hash_ := array();
{self.}Init();
end;
function Relationships.Init();
begin
elements := object_.Relationships();
relationship_count_ := length(elements);
for k,v in elements do
begin
relationship_id_hash_[v.Id] := v;
relationship_target_hash_[v.Target] := v;
end
end;
function Relationships.GetRelationshipById(_key: string);
begin
return relationship_id_hash_[_key];
end;
function Relationships.GetRelationshipByTarget(_key: string);
begin
return relationship_target_hash_[_key];
end;
function Relationships.AddRelationship(_value: Relationship);
begin
relationship_id_hash_[_value.Id] := _value;
relationship_target_hash_[_value.Target] := _value;
relationship_count_++;
end;
function Relationships.RemoveRelationship(_value: Relationship);
begin
reindex(relationship_id_hash_, array(_value.Id: nil));
reindex(relationship_target_hash_, array(_value.Target: nil));
relationship_count_--;
end;
function Types.create(_obj: Types);
begin
object_ := _obj;
default_count_ := 0;
default_extension_hash_ := array();
_override_count_ := 0;
_override_partname_hash_ := array();
{self.}Init();
end;
function Types.Init();
begin
elements := object_.Defaults();
default_count_ := length(elements);
for k,v in elements do
default_extension_hash_[v.Extension] := v;
elements := object_.Overrides();
_override_count_ := length(elements);
for k,v in elements do
_override_partname_hash_[v.PartName] := v;
end;
function Types.GetDefaultByExtension(_key: string);
begin
return default_extension_hash_[_key];
end;
function Types.AddDefault(_value: Default);
begin
default_extension_hash_[_value.Extension] := _value;
default_count_++;
end;
function Types.RemoveDefault(_value: Default);
begin
reindex(default_extension_hash_, array(_value.Extension: nil));
default_count_--;
end;
function Types.Get_OverrideByPartName(_key: string);
begin
return _override_partname_hash_[_key];
end;
function Types.Add_Override(_value: _Override);
begin
_override_partname_hash_[_value.PartName] := _value;
_override_count_++;
end;
function Types.Remove_Override(_value: _Override);
begin
reindex(_override_partname_hash_, array(_value.PartName: nil));
_override_count_--;
end;
end.
+114 -114
View File
@@ -4,7 +4,7 @@ uses SharedML, TSSafeUnitConverter;
type MathPrUnitDecorator = class(MathPr)
public
function Create(_obj: MathPr);
function create(_obj: MathPr);
function GetObject();
function Convert();
private
@@ -13,7 +13,7 @@ end;
type OMathParaUnitDecorator = class(OMathPara)
public
function Create(_obj: OMathPara);
function create(_obj: OMathPara);
function GetObject();
function Convert();
private
@@ -22,7 +22,7 @@ end;
type OMathParaPrUnitDecorator = class(OMathParaPr)
public
function Create(_obj: OMathParaPr);
function create(_obj: OMathParaPr);
function GetObject();
function Convert();
private
@@ -31,7 +31,7 @@ end;
type PureMValUnitDecorator = class(PureMVal)
public
function Create(_obj: PureMVal);
function create(_obj: PureMVal);
function GetObject();
function Convert();
private
@@ -40,7 +40,7 @@ end;
type OMathUnitDecorator = class(OMath)
public
function Create(_obj: OMath);
function create(_obj: OMath);
function GetObject();
function Convert();
private
@@ -49,7 +49,7 @@ end;
type RUnitDecorator = class(R)
public
function Create(_obj: R);
function create(_obj: R);
function GetObject();
function Convert();
private
@@ -58,7 +58,7 @@ end;
type RPrUnitDecorator = class(RPr)
public
function Create(_obj: RPr);
function create(_obj: RPr);
function GetObject();
function Convert();
private
@@ -67,7 +67,7 @@ end;
type TUnitDecorator = class(T)
public
function Create(_obj: T);
function create(_obj: T);
function GetObject();
function Convert();
private
@@ -76,7 +76,7 @@ end;
type DUnitDecorator = class(D)
public
function Create(_obj: D);
function create(_obj: D);
function GetObject();
function Convert();
private
@@ -85,7 +85,7 @@ end;
type DPrUnitDecorator = class(DPr)
public
function Create(_obj: DPr);
function create(_obj: DPr);
function GetObject();
function Convert();
private
@@ -94,7 +94,7 @@ end;
type CtrlPrUnitDecorator = class(CtrlPr)
public
function Create(_obj: CtrlPr);
function create(_obj: CtrlPr);
function GetObject();
function Convert();
private
@@ -103,7 +103,7 @@ end;
type SSupUnitDecorator = class(SSup)
public
function Create(_obj: SSup);
function create(_obj: SSup);
function GetObject();
function Convert();
private
@@ -112,7 +112,7 @@ end;
type SSupPrUnitDecorator = class(SSupPr)
public
function Create(_obj: SSupPr);
function create(_obj: SSupPr);
function GetObject();
function Convert();
private
@@ -121,7 +121,7 @@ end;
type FUnitDecorator = class(F)
public
function Create(_obj: F);
function create(_obj: F);
function GetObject();
function Convert();
private
@@ -130,7 +130,7 @@ end;
type FPrUnitDecorator = class(FPr)
public
function Create(_obj: FPr);
function create(_obj: FPr);
function GetObject();
function Convert();
private
@@ -139,7 +139,7 @@ end;
type RadUnitDecorator = class(Rad)
public
function Create(_obj: Rad);
function create(_obj: Rad);
function GetObject();
function Convert();
private
@@ -148,7 +148,7 @@ end;
type RadPrUnitDecorator = class(RadPr)
public
function Create(_obj: RadPr);
function create(_obj: RadPr);
function GetObject();
function Convert();
private
@@ -157,7 +157,7 @@ end;
type SSubUnitDecorator = class(SSub)
public
function Create(_obj: SSub);
function create(_obj: SSub);
function GetObject();
function Convert();
private
@@ -166,7 +166,7 @@ end;
type SSubPrUnitDecorator = class(SSubPr)
public
function Create(_obj: SSubPr);
function create(_obj: SSubPr);
function GetObject();
function Convert();
private
@@ -175,7 +175,7 @@ end;
type NaryUnitDecorator = class(Nary)
public
function Create(_obj: Nary);
function create(_obj: Nary);
function GetObject();
function Convert();
private
@@ -184,7 +184,7 @@ end;
type NaryPrUnitDecorator = class(NaryPr)
public
function Create(_obj: NaryPr);
function create(_obj: NaryPr);
function GetObject();
function Convert();
private
@@ -193,7 +193,7 @@ end;
type FuncUnitDecorator = class(Func)
public
function Create(_obj: Func);
function create(_obj: Func);
function GetObject();
function Convert();
private
@@ -202,7 +202,7 @@ end;
type FNameUnitDecorator = class(FName)
public
function Create(_obj: FName);
function create(_obj: FName);
function GetObject();
function Convert();
private
@@ -211,7 +211,7 @@ end;
type FuncPrUnitDecorator = class(FuncPr)
public
function Create(_obj: FuncPr);
function create(_obj: FuncPr);
function GetObject();
function Convert();
private
@@ -220,7 +220,7 @@ end;
type CorePropertiesUnitDecorator = class(CoreProperties)
public
function Create(_obj: CoreProperties);
function create(_obj: CoreProperties);
function GetObject();
function Convert();
private
@@ -229,7 +229,7 @@ end;
type CreatedUnitDecorator = class(Created)
public
function Create(_obj: Created);
function create(_obj: Created);
function GetObject();
function Convert();
private
@@ -238,7 +238,7 @@ end;
type ModifiedUnitDecorator = class(Modified)
public
function Create(_obj: Modified);
function create(_obj: Modified);
function GetObject();
function Convert();
private
@@ -247,7 +247,7 @@ end;
type RelationshipsUnitDecorator = class(Relationships)
public
function Create(_obj: Relationships);
function create(_obj: Relationships);
function GetObject();
function Convert();
private
@@ -256,7 +256,7 @@ end;
type RelationshipUnitDecorator = class(Relationship)
public
function Create(_obj: Relationship);
function create(_obj: Relationship);
function GetObject();
function Convert();
private
@@ -265,7 +265,7 @@ end;
type TypesUnitDecorator = class(Types)
public
function Create(_obj: Types);
function create(_obj: Types);
function GetObject();
function Convert();
private
@@ -274,7 +274,7 @@ end;
type DefaultUnitDecorator = class(Default)
public
function Create(_obj: Default);
function create(_obj: Default);
function GetObject();
function Convert();
private
@@ -283,7 +283,7 @@ end;
type _OverrideUnitDecorator = class(_Override)
public
function Create(_obj: _Override);
function create(_obj: _Override);
function GetObject();
function Convert();
private
@@ -292,7 +292,7 @@ end;
type NumUnitDecorator = class(Num)
public
function Create(_obj: Num);
function create(_obj: Num);
function GetObject();
function Convert();
private
@@ -301,7 +301,7 @@ end;
type DegUnitDecorator = class(Deg)
public
function Create(_obj: Deg);
function create(_obj: Deg);
function GetObject();
function Convert();
private
@@ -310,7 +310,7 @@ end;
type EUnitDecorator = class(E)
public
function Create(_obj: E);
function create(_obj: E);
function GetObject();
function Convert();
private
@@ -319,7 +319,7 @@ end;
type SupUnitDecorator = class(Sup)
public
function Create(_obj: Sup);
function create(_obj: Sup);
function GetObject();
function Convert();
private
@@ -328,7 +328,7 @@ end;
type DenUnitDecorator = class(Den)
public
function Create(_obj: Den);
function create(_obj: Den);
function GetObject();
function Convert();
private
@@ -337,7 +337,7 @@ end;
type SubUnitDecorator = class(Sub)
public
function Create(_obj: Sub);
function create(_obj: Sub);
function GetObject();
function Convert();
private
@@ -346,9 +346,9 @@ end;
implementation
function MathPrUnitDecorator.Create(_obj: MathPr);
function MathPrUnitDecorator.create(_obj: MathPr);
begin
class(MathPr).Create();
class(MathPr).create();
object_ := _obj;
{self.}Convert();
end;
@@ -387,9 +387,9 @@ begin
tslassigning := tslassigning_backup;
end;
function OMathParaUnitDecorator.Create(_obj: OMathPara);
function OMathParaUnitDecorator.create(_obj: OMathPara);
begin
class(OMathPara).Create();
class(OMathPara).create();
object_ := _obj;
{self.}Convert();
end;
@@ -410,9 +410,9 @@ begin
tslassigning := tslassigning_backup;
end;
function OMathParaPrUnitDecorator.Create(_obj: OMathParaPr);
function OMathParaPrUnitDecorator.create(_obj: OMathParaPr);
begin
class(OMathParaPr).Create();
class(OMathParaPr).create();
object_ := _obj;
{self.}Convert();
end;
@@ -431,9 +431,9 @@ begin
tslassigning := tslassigning_backup;
end;
function PureMValUnitDecorator.Create(_obj: PureMVal);
function PureMValUnitDecorator.create(_obj: PureMVal);
begin
class(PureMVal).Create();
class(PureMVal).create();
object_ := _obj;
{self.}Convert();
end;
@@ -452,9 +452,9 @@ begin
tslassigning := tslassigning_backup;
end;
function OMathUnitDecorator.Create(_obj: OMath);
function OMathUnitDecorator.create(_obj: OMath);
begin
class(OMath).Create();
class(OMath).create();
object_ := _obj;
{self.}Convert();
end;
@@ -495,9 +495,9 @@ begin
tslassigning := tslassigning_backup;
end;
function RUnitDecorator.Create(_obj: R);
function RUnitDecorator.create(_obj: R);
begin
class(R).Create();
class(R).create();
object_ := _obj;
{self.}Convert();
end;
@@ -522,9 +522,9 @@ begin
tslassigning := tslassigning_backup;
end;
function RPrUnitDecorator.Create(_obj: RPr);
function RPrUnitDecorator.create(_obj: RPr);
begin
class(RPr).Create();
class(RPr).create();
object_ := _obj;
{self.}Convert();
end;
@@ -543,9 +543,9 @@ begin
tslassigning := tslassigning_backup;
end;
function TUnitDecorator.Create(_obj: T);
function TUnitDecorator.create(_obj: T);
begin
class(T).Create();
class(T).create();
object_ := _obj;
{self.}Convert();
end;
@@ -564,9 +564,9 @@ begin
tslassigning := tslassigning_backup;
end;
function DUnitDecorator.Create(_obj: D);
function DUnitDecorator.create(_obj: D);
begin
class(D).Create();
class(D).create();
object_ := _obj;
{self.}Convert();
end;
@@ -587,9 +587,9 @@ begin
tslassigning := tslassigning_backup;
end;
function DPrUnitDecorator.Create(_obj: DPr);
function DPrUnitDecorator.create(_obj: DPr);
begin
class(DPr).Create();
class(DPr).create();
object_ := _obj;
{self.}Convert();
end;
@@ -620,9 +620,9 @@ begin
tslassigning := tslassigning_backup;
end;
function CtrlPrUnitDecorator.Create(_obj: CtrlPr);
function CtrlPrUnitDecorator.create(_obj: CtrlPr);
begin
class(CtrlPr).Create();
class(CtrlPr).create();
object_ := _obj;
{self.}Convert();
end;
@@ -643,9 +643,9 @@ begin
tslassigning := tslassigning_backup;
end;
function SSupUnitDecorator.Create(_obj: SSup);
function SSupUnitDecorator.create(_obj: SSup);
begin
class(SSup).Create();
class(SSup).create();
object_ := _obj;
{self.}Convert();
end;
@@ -668,9 +668,9 @@ begin
tslassigning := tslassigning_backup;
end;
function SSupPrUnitDecorator.Create(_obj: SSupPr);
function SSupPrUnitDecorator.create(_obj: SSupPr);
begin
class(SSupPr).Create();
class(SSupPr).create();
object_ := _obj;
{self.}Convert();
end;
@@ -689,9 +689,9 @@ begin
tslassigning := tslassigning_backup;
end;
function FUnitDecorator.Create(_obj: F);
function FUnitDecorator.create(_obj: F);
begin
class(F).Create();
class(F).create();
object_ := _obj;
{self.}Convert();
end;
@@ -714,9 +714,9 @@ begin
tslassigning := tslassigning_backup;
end;
function FPrUnitDecorator.Create(_obj: FPr);
function FPrUnitDecorator.create(_obj: FPr);
begin
class(FPr).Create();
class(FPr).create();
object_ := _obj;
{self.}Convert();
end;
@@ -737,9 +737,9 @@ begin
tslassigning := tslassigning_backup;
end;
function RadUnitDecorator.Create(_obj: Rad);
function RadUnitDecorator.create(_obj: Rad);
begin
class(Rad).Create();
class(Rad).create();
object_ := _obj;
{self.}Convert();
end;
@@ -762,9 +762,9 @@ begin
tslassigning := tslassigning_backup;
end;
function RadPrUnitDecorator.Create(_obj: RadPr);
function RadPrUnitDecorator.create(_obj: RadPr);
begin
class(RadPr).Create();
class(RadPr).create();
object_ := _obj;
{self.}Convert();
end;
@@ -785,9 +785,9 @@ begin
tslassigning := tslassigning_backup;
end;
function SSubUnitDecorator.Create(_obj: SSub);
function SSubUnitDecorator.create(_obj: SSub);
begin
class(SSub).Create();
class(SSub).create();
object_ := _obj;
{self.}Convert();
end;
@@ -810,9 +810,9 @@ begin
tslassigning := tslassigning_backup;
end;
function SSubPrUnitDecorator.Create(_obj: SSubPr);
function SSubPrUnitDecorator.create(_obj: SSubPr);
begin
class(SSubPr).Create();
class(SSubPr).create();
object_ := _obj;
{self.}Convert();
end;
@@ -831,9 +831,9 @@ begin
tslassigning := tslassigning_backup;
end;
function NaryUnitDecorator.Create(_obj: Nary);
function NaryUnitDecorator.create(_obj: Nary);
begin
class(Nary).Create();
class(Nary).create();
object_ := _obj;
{self.}Convert();
end;
@@ -858,9 +858,9 @@ begin
tslassigning := tslassigning_backup;
end;
function NaryPrUnitDecorator.Create(_obj: NaryPr);
function NaryPrUnitDecorator.create(_obj: NaryPr);
begin
class(NaryPr).Create();
class(NaryPr).create();
object_ := _obj;
{self.}Convert();
end;
@@ -889,9 +889,9 @@ begin
tslassigning := tslassigning_backup;
end;
function FuncUnitDecorator.Create(_obj: Func);
function FuncUnitDecorator.create(_obj: Func);
begin
class(Func).Create();
class(Func).create();
object_ := _obj;
{self.}Convert();
end;
@@ -914,9 +914,9 @@ begin
tslassigning := tslassigning_backup;
end;
function FNameUnitDecorator.Create(_obj: FName);
function FNameUnitDecorator.create(_obj: FName);
begin
class(FName).Create();
class(FName).create();
object_ := _obj;
{self.}Convert();
end;
@@ -936,9 +936,9 @@ begin
tslassigning := tslassigning_backup;
end;
function FuncPrUnitDecorator.Create(_obj: FuncPr);
function FuncPrUnitDecorator.create(_obj: FuncPr);
begin
class(FuncPr).Create();
class(FuncPr).create();
object_ := _obj;
{self.}Convert();
end;
@@ -957,9 +957,9 @@ begin
tslassigning := tslassigning_backup;
end;
function CorePropertiesUnitDecorator.Create(_obj: CoreProperties);
function CorePropertiesUnitDecorator.create(_obj: CoreProperties);
begin
class(CoreProperties).Create();
class(CoreProperties).create();
object_ := _obj;
{self.}Convert();
end;
@@ -988,9 +988,9 @@ begin
tslassigning := tslassigning_backup;
end;
function CreatedUnitDecorator.Create(_obj: Created);
function CreatedUnitDecorator.create(_obj: Created);
begin
class(Created).Create();
class(Created).create();
object_ := _obj;
{self.}Convert();
end;
@@ -1009,9 +1009,9 @@ begin
tslassigning := tslassigning_backup;
end;
function ModifiedUnitDecorator.Create(_obj: Modified);
function ModifiedUnitDecorator.create(_obj: Modified);
begin
class(Modified).Create();
class(Modified).create();
object_ := _obj;
{self.}Convert();
end;
@@ -1030,9 +1030,9 @@ begin
tslassigning := tslassigning_backup;
end;
function RelationshipsUnitDecorator.Create(_obj: Relationships);
function RelationshipsUnitDecorator.create(_obj: Relationships);
begin
class(Relationships).Create();
class(Relationships).create();
object_ := _obj;
{self.}Convert();
end;
@@ -1052,9 +1052,9 @@ begin
tslassigning := tslassigning_backup;
end;
function RelationshipUnitDecorator.Create(_obj: Relationship);
function RelationshipUnitDecorator.create(_obj: Relationship);
begin
class(Relationship).Create();
class(Relationship).create();
object_ := _obj;
{self.}Convert();
end;
@@ -1077,9 +1077,9 @@ begin
tslassigning := tslassigning_backup;
end;
function TypesUnitDecorator.Create(_obj: Types);
function TypesUnitDecorator.create(_obj: Types);
begin
class(Types).Create();
class(Types).create();
object_ := _obj;
{self.}Convert();
end;
@@ -1102,9 +1102,9 @@ begin
tslassigning := tslassigning_backup;
end;
function DefaultUnitDecorator.Create(_obj: Default);
function DefaultUnitDecorator.create(_obj: Default);
begin
class(Default).Create();
class(Default).create();
object_ := _obj;
{self.}Convert();
end;
@@ -1125,9 +1125,9 @@ begin
tslassigning := tslassigning_backup;
end;
function _OverrideUnitDecorator.Create(_obj: _Override);
function _OverrideUnitDecorator.create(_obj: _Override);
begin
class(_Override).Create();
class(_Override).create();
object_ := _obj;
{self.}Convert();
end;
@@ -1148,9 +1148,9 @@ begin
tslassigning := tslassigning_backup;
end;
function NumUnitDecorator.Create(_obj: Num);
function NumUnitDecorator.create(_obj: Num);
begin
class(Num).Create();
class(Num).create();
object_ := _obj;
{self.}Convert();
end;
@@ -1193,9 +1193,9 @@ begin
tslassigning := tslassigning_backup;
end;
function DegUnitDecorator.Create(_obj: Deg);
function DegUnitDecorator.create(_obj: Deg);
begin
class(Deg).Create();
class(Deg).create();
object_ := _obj;
{self.}Convert();
end;
@@ -1238,9 +1238,9 @@ begin
tslassigning := tslassigning_backup;
end;
function EUnitDecorator.Create(_obj: E);
function EUnitDecorator.create(_obj: E);
begin
class(E).Create();
class(E).create();
object_ := _obj;
{self.}Convert();
end;
@@ -1283,9 +1283,9 @@ begin
tslassigning := tslassigning_backup;
end;
function SupUnitDecorator.Create(_obj: Sup);
function SupUnitDecorator.create(_obj: Sup);
begin
class(Sup).Create();
class(Sup).create();
object_ := _obj;
{self.}Convert();
end;
@@ -1328,9 +1328,9 @@ begin
tslassigning := tslassigning_backup;
end;
function DenUnitDecorator.Create(_obj: Den);
function DenUnitDecorator.create(_obj: Den);
begin
class(Den).Create();
class(Den).create();
object_ := _obj;
{self.}Convert();
end;
@@ -1373,9 +1373,9 @@ begin
tslassigning := tslassigning_backup;
end;
function SubUnitDecorator.Create(_obj: Sub);
function SubUnitDecorator.create(_obj: Sub);
begin
class(Sub).Create();
class(Sub).create();
object_ := _obj;
{self.}Convert();
end;
+972 -397
View File
File diff suppressed because it is too large Load Diff
@@ -1,4 +1,4 @@
unit VMLAdapter;
unit VMLAdapters;
interface
implementation
+54 -50
View File
@@ -4,7 +4,7 @@ uses VML, TSSafeUnitConverter;
type ShapetypeUnitDecorator = class(Shapetype)
public
function Create(_obj: Shapetype);
function create(_obj: Shapetype);
function GetObject();
function Convert();
private
@@ -13,7 +13,7 @@ end;
type FormulasUnitDecorator = class(Formulas)
public
function Create(_obj: Formulas);
function create(_obj: Formulas);
function GetObject();
function Convert();
private
@@ -22,7 +22,7 @@ end;
type LockUnitDecorator = class(Lock)
public
function Create(_obj: Lock);
function create(_obj: Lock);
function GetObject();
function Convert();
private
@@ -31,7 +31,7 @@ end;
type FUnitDecorator = class(F)
public
function Create(_obj: F);
function create(_obj: F);
function GetObject();
function Convert();
private
@@ -40,7 +40,7 @@ end;
type StrokeUnitDecorator = class(Stroke)
public
function Create(_obj: Stroke);
function create(_obj: Stroke);
function GetObject();
function Convert();
private
@@ -49,7 +49,7 @@ end;
type PathUnitDecorator = class(Path)
public
function Create(_obj: Path);
function create(_obj: Path);
function GetObject();
function Convert();
private
@@ -58,7 +58,7 @@ end;
type TextpathUnitDecorator = class(Textpath)
public
function Create(_obj: Textpath);
function create(_obj: Textpath);
function GetObject();
function Convert();
private
@@ -67,7 +67,7 @@ end;
type HandlesUnitDecorator = class(Handles)
public
function Create(_obj: Handles);
function create(_obj: Handles);
function GetObject();
function Convert();
private
@@ -76,7 +76,7 @@ end;
type HUnitDecorator = class(H)
public
function Create(_obj: H);
function create(_obj: H);
function GetObject();
function Convert();
private
@@ -85,7 +85,7 @@ end;
type ShapeUnitDecorator = class(Shape)
public
function Create(_obj: Shape);
function create(_obj: Shape);
function GetObject();
function Convert();
private
@@ -94,7 +94,7 @@ end;
type WrapUnitDecorator = class(Wrap)
public
function Create(_obj: Wrap);
function create(_obj: Wrap);
function GetObject();
function Convert();
private
@@ -103,7 +103,7 @@ end;
type FillUnitDecorator = class(Fill)
public
function Create(_obj: Fill);
function create(_obj: Fill);
function GetObject();
function Convert();
private
@@ -112,7 +112,7 @@ end;
type ImagedataUnitDecorator = class(Imagedata)
public
function Create(_obj: Imagedata);
function create(_obj: Imagedata);
function GetObject();
function Convert();
private
@@ -121,7 +121,7 @@ end;
type TextboxUnitDecorator = class(Textbox)
public
function Create(_obj: Textbox);
function create(_obj: Textbox);
function GetObject();
function Convert();
private
@@ -130,7 +130,7 @@ end;
type OLEObjectUnitDecorator = class(OLEObject)
public
function Create(_obj: OLEObject);
function create(_obj: OLEObject);
function GetObject();
function Convert();
private
@@ -139,9 +139,9 @@ end;
implementation
function ShapetypeUnitDecorator.Create(_obj: Shapetype);
function ShapetypeUnitDecorator.create(_obj: Shapetype);
begin
class(Shapetype).Create();
class(Shapetype).create();
object_ := _obj;
{self.}Convert();
end;
@@ -167,8 +167,8 @@ begin
{self.}Adj := object_.XmlAttrAdj.Value;
if not ifnil(object_.XmlAttrPreferrelative) then
{self.}Preferrelative := object_.XmlAttrPreferrelative.Value;
if not ifnil(object_.XmlAttrPath) then
{self.}Path := object_.XmlAttrPath.Value;
if not ifnil(object_.XmlAttrAttrPath) then
{self.}AttrPath := object_.XmlAttrAttrPath.Value;
if not ifnil(object_.XmlAttrFilled) then
{self.}Filled := object_.XmlAttrFilled.Value;
if not ifnil(object_.XmlAttrStroked) then
@@ -188,9 +188,9 @@ begin
tslassigning := tslassigning_backup;
end;
function FormulasUnitDecorator.Create(_obj: Formulas);
function FormulasUnitDecorator.create(_obj: Formulas);
begin
class(Formulas).Create();
class(Formulas).create();
object_ := _obj;
{self.}Convert();
end;
@@ -206,13 +206,13 @@ begin
tslassigning := 1;
elems := object_.Fs();
for _,elem in elems do
{self.}AppendChild(new ShapetypeUnitDecorator(elem));
{self.}AppendChild(new FUnitDecorator(elem));
tslassigning := tslassigning_backup;
end;
function LockUnitDecorator.Create(_obj: Lock);
function LockUnitDecorator.create(_obj: Lock);
begin
class(Lock).Create();
class(Lock).create();
object_ := _obj;
{self.}Convert();
end;
@@ -230,12 +230,16 @@ begin
{self.}Ext := object_.XmlAttrExt.Value;
if not ifnil(object_.XmlAttrAspectration) then
{self.}Aspectration := object_.XmlAttrAspectration.Value;
if not ifnil(object_.XmlAttrText) then
{self.}Text := object_.XmlAttrText.Value;
if not ifnil(object_.XmlAttrShapetype) then
{self.}Shapetype := object_.XmlAttrShapetype.Value;
tslassigning := tslassigning_backup;
end;
function FUnitDecorator.Create(_obj: F);
function FUnitDecorator.create(_obj: F);
begin
class(F).Create();
class(F).create();
object_ := _obj;
{self.}Convert();
end;
@@ -254,9 +258,9 @@ begin
tslassigning := tslassigning_backup;
end;
function StrokeUnitDecorator.Create(_obj: Stroke);
function StrokeUnitDecorator.create(_obj: Stroke);
begin
class(Stroke).Create();
class(Stroke).create();
object_ := _obj;
{self.}Convert();
end;
@@ -275,9 +279,9 @@ begin
tslassigning := tslassigning_backup;
end;
function PathUnitDecorator.Create(_obj: Path);
function PathUnitDecorator.create(_obj: Path);
begin
class(Path).Create();
class(Path).create();
object_ := _obj;
{self.}Convert();
end;
@@ -306,9 +310,9 @@ begin
tslassigning := tslassigning_backup;
end;
function TextpathUnitDecorator.Create(_obj: Textpath);
function TextpathUnitDecorator.create(_obj: Textpath);
begin
class(Textpath).Create();
class(Textpath).create();
object_ := _obj;
{self.}Convert();
end;
@@ -333,9 +337,9 @@ begin
tslassigning := tslassigning_backup;
end;
function HandlesUnitDecorator.Create(_obj: Handles);
function HandlesUnitDecorator.create(_obj: Handles);
begin
class(Handles).Create();
class(Handles).create();
object_ := _obj;
{self.}Convert();
end;
@@ -354,9 +358,9 @@ begin
tslassigning := tslassigning_backup;
end;
function HUnitDecorator.Create(_obj: H);
function HUnitDecorator.create(_obj: H);
begin
class(H).Create();
class(H).create();
object_ := _obj;
{self.}Convert();
end;
@@ -370,16 +374,16 @@ function HUnitDecorator.Convert();
begin
tslassigning_backup := tslassigning;
tslassigning := 1;
if not ifnil(object_.XmlAttrXrange) then
{self.}Xrange := object_.XmlAttrXrange.Value;
if not ifnil(object_.XmlAttrPosition) then
{self.}Position := object_.XmlAttrPosition.Value;
if not ifnil(object_.XmlAttrXrange) then
{self.}Xrange := object_.XmlAttrXrange.Value;
tslassigning := tslassigning_backup;
end;
function ShapeUnitDecorator.Create(_obj: Shape);
function ShapeUnitDecorator.create(_obj: Shape);
begin
class(Shape).Create();
class(Shape).create();
object_ := _obj;
{self.}Convert();
end;
@@ -426,9 +430,9 @@ begin
tslassigning := tslassigning_backup;
end;
function WrapUnitDecorator.Create(_obj: Wrap);
function WrapUnitDecorator.create(_obj: Wrap);
begin
class(Wrap).Create();
class(Wrap).create();
object_ := _obj;
{self.}Convert();
end;
@@ -449,9 +453,9 @@ begin
tslassigning := tslassigning_backup;
end;
function FillUnitDecorator.Create(_obj: Fill);
function FillUnitDecorator.create(_obj: Fill);
begin
class(Fill).Create();
class(Fill).create();
object_ := _obj;
{self.}Convert();
end;
@@ -470,9 +474,9 @@ begin
tslassigning := tslassigning_backup;
end;
function ImagedataUnitDecorator.Create(_obj: Imagedata);
function ImagedataUnitDecorator.create(_obj: Imagedata);
begin
class(Imagedata).Create();
class(Imagedata).create();
object_ := _obj;
{self.}Convert();
end;
@@ -493,9 +497,9 @@ begin
tslassigning := tslassigning_backup;
end;
function TextboxUnitDecorator.Create(_obj: Textbox);
function TextboxUnitDecorator.create(_obj: Textbox);
begin
class(Textbox).Create();
class(Textbox).create();
object_ := _obj;
{self.}Convert();
end;
@@ -514,9 +518,9 @@ begin
tslassigning := tslassigning_backup;
end;
function OLEObjectUnitDecorator.Create(_obj: OLEObject);
function OLEObjectUnitDecorator.create(_obj: OLEObject);
begin
class(OLEObject).Create();
class(OLEObject).create();
object_ := _obj;
{self.}Convert();
end;
+20 -8
View File
@@ -9,7 +9,7 @@ public
function AppendChild(_element: OpenXmlElement);
function InsertAfter(_element: OpenXmlElement; _pos_element: OpenXmlElement);
function RemoveChild(_element: OpenXmlElement);
// function InsertBefore(_pos_obj: tslobj; _obj: tslobj);
function InsertBefore(_element: OpenXmlElement; _pos_element: OpenXmlElement);
// function PrependChild(_obj: tslobj);
// function SetAttribute(_obj: OpenXmlAttribute);
@@ -37,11 +37,12 @@ begin
node := node.NextElement();
end
tslassigning := tslassigning_backup;
deserialized_ := false;
end;
function OpenXmlCompositeElement.Deserialize();override;
begin
if not ifObj({self.}XmlNode) then return;
if deserialized_ or not ifObj({self.}XmlNode) then return;
attrs := {self.}XmlNode.Attributes();
for k, v in attrs do
begin
@@ -58,23 +59,27 @@ begin
child_elements := container_.GetElements();
for k, v in child_elements do
v.Deserialize();
deserialized_ := true;
end;
function OpenXmlCompositeElement.Serialize();override;
begin
if {self.}DeleteSelf() then return;
{self.}GetNode();
if {self.}Enable then {self.}GetNode();
// xmlns
for k, v in xmlns_ do
{self.}XmlNode.SetAttribute(v.ElementName, v.Value);
if not ifnil(v.Value) then
{self.}GetNode().SetAttribute(v.ElementName, v.Value);
else if {self.}XmlNode then
{self.}GetNode().DeleteAttribute(v.ElementName);
// Attributes
for k, v in attributes_ do
if not ifnil(v.Value) then
{self.}XmlNode.SetAttribute(v.ElementName, v.Value);
{self.}GetNode().SetAttribute(v.ElementName, v.Value);
else if {self.}XmlNode then
{self.}XmlNode.DeleteAttribute(v.ElementName);
{self.}GetNode().DeleteAttribute(v.ElementName);
// Children
child_elements := container_.GetElements();
@@ -89,7 +94,7 @@ begin
for k, v in child_elements do
begin
arr := array("type": "element", "name": v.ElementName, "attributes": array());
if v is Class(OpenXmlTextElement) or v is Class(OpenXmlCompositeElement) then
if v is class(OpenXmlTextElement) or v is class(OpenXmlCompositeElement) then
begin
marshal := v.Marshal();
if length(marshal["children"]) = 0 and length(marshal["attributes"]) = 0 then continue;
@@ -97,7 +102,7 @@ begin
arr["attributes"] union= marshal["attributes"];
child_arr[length(child_arr)] := arr;
end
else if v is Class(OpenXmlSimpleType) then
else if v is class(OpenXmlSimpleType) then
begin
marshal := v.Marshal();
if length(marshal) > 0 then child_arr[length(child_arr)] := arr;
@@ -138,11 +143,13 @@ end;
function OpenXmlCompositeElement.AppendChild(_element: OpenXmlElement);
begin
_element.Parent := self;
container_.Append(_element);
end;
function OpenXmlCompositeElement.InsertAfter(_element: OpenXmlElement; _pos_element: OpenXmlElement);
begin
_element.Parent := self;
container_.InsertAfter(_element, _pos_element);
end;
@@ -151,3 +158,8 @@ begin
_element.Removed := true;
end;
function OpenXmlCompositeElement.InsertBefore(_element: OpenXmlElement; _pos_element: OpenXmlElement);
begin
_element.Parent := self;
container_.InsertBefore(_element, _pos_element);
end;
+6
View File
@@ -5,6 +5,7 @@ public
function Init();virtual;
function InitNode(_node: XmlNode);virtual;
function Copy(_obj: tslobj);virtual;
function Clone(): OpenXmlElement;virtual;
function Deserialize();virtual;
function Serialize();virtual;
function Marshal(): tableArray;virtual;
@@ -31,6 +32,8 @@ public
ElementName: string;
Removed: boolean; // 节点删除标记,最后Serialize时候统一删除
Enable: boolean; // 是否启用 <b /> 没有属性
protected
attributes_: array of OpenXmlAttribute; // 属性
attributes_pf_: tableArray;
@@ -38,6 +41,7 @@ protected
sorted_child_: tableArray;
container_: TSOfficeContainer;
fallback_: OpenXmlElement; // 代理对象
deserialized_: boolean; // 是否已反序列化
end;
function OpenXmlElement.Create(_node: XmlNode);overload;
@@ -57,9 +61,11 @@ begin
{self.}XmlNode := nil;
{self.}ElementName := ifString({self.}Prefix) and {self.}Prefix <> "" ? format("%s:%s", {self.}Prefix, {self.}LocalName) : {self.}LocalName;
{self.}Removed := false;
{self.}Enable := false;
{self.}Init();
xmlns_ := array();
fallback_ := nil;
deserialized_ := false;
end;
function OpenXmlElement.SetFallback(_fallback: OpenXmlElement);
+16 -7
View File
@@ -3,6 +3,7 @@ public
function Init();override;
function InitNode(_node: XmlNode);override;
function Copy(_obj: tslobj);override;
function Clone(): OpenXmlSimpleType;override;
function Deserialize();override;
function Serialize();override;
function Marshal(): tableArray;override;
@@ -18,27 +19,33 @@ public
// IsApplied: boolean; // 是否已经应用,和val值有关
property IsApplied read ReadIsApplied;
function ReadIsApplied();
public
Enable: boolean; // 是否启用 <b /> 没有属性,需要通过val写属性
end;
function OpenXmlSimpleType.Init();override;
begin
{self.}Enable := false;
// {self.}Enable := false;
end;
function OpenXmlSimpleType.InitNode(_node: XmlNode);override;
begin
{self.}XmlNode := ifObj(_node) ? _node : nil;
deserialized_ := false;
end;
function OpenXmlSimpleType.Copy(_obj: tslobj);override;
begin
if not ifnil(_obj.Enable) then {self.}Enable := _obj.Enable;
{self.}Enable := _obj.Enable;
if not ifnil(_obj.XmlAttrVal.Value) then {self.}Val := _obj.XmlAttrVal.Value;
end;
function OpenXmlSimpleType.Clone(): OpenXmlSimpleType;override;
begin
obj := new OpenXmlSimpleType(nil, {self.}Prefix, {self.}LocalName);
obj.Enable := {self.}Enable;
if not ifnil({self.}XmlAttrVal.Value) then obj.Val := {self.}XmlAttrVal.Value;
return obj;
end;
function OpenXmlSimpleType.Marshal(): tableArray;override;
begin
if not {self.}Enable then return array();
@@ -50,6 +57,7 @@ end;
function OpenXmlSimpleType.Deserialize();override;
begin
if deserialized_ then return;
if ifObj({self.}XmlNode) then
begin
attrs := {self.}XmlNode.Attributes();
@@ -67,13 +75,14 @@ begin
{self.}Enable := false;
{self.}XmlAttrVal := nil;
end
deserialized_ := true;
end;
function OpenXmlSimpleType.Serialize();override;
begin
if not ifObj({self.}XmlNode) then
begin
{self.}GetNode();
if {self.}Enable then {self.}GetNode();
if not ifnil({self.}XmlAttrVal.Value) then {self.}XmlNode.SetAttribute({self.}XmlAttrVal.ElementName, {self.}XmlAttrVal.Value);
end
else begin
@@ -102,6 +111,6 @@ end;
function OpenXmlSimpleType.ReadIsApplied();
begin
if {self.}Enable then
return {self.}XmlAttrVal.Value = "0" or {self.}XmlAttrVal.Value = "false" ? false : true;
return {self.}XmlAttrVal.Value = "0" or {self.}XmlAttrVal.Value = "false" or {self.}XmlAttrVal.Value = "off" ? false : true;
return false;
end;
+11 -1
View File
@@ -2,6 +2,7 @@ type OpenXmlTextElement = class(OpenXmlElement)
public
function InitNode(_node: XmlNode);override;
function Copy(_obj: tslobj);virtual;
function Clone(): OpenXmlTextElement;virtual;
function Deserialize();override;
function Serialize();override;
function Marshal(): tableArray;override;
@@ -13,6 +14,7 @@ end;
function OpenXmlTextElement.InitNode(_node: XmlNode);override;
begin
{self.}XmlNode := ifObj(_node) ? _node : nil;
deserialized_ := false;
end;
function OpenXmlTextElement.Copy(_obj: tslobj);virtual;
@@ -20,6 +22,13 @@ begin
if not ifnil(_obj.Text) then {self.}Text := _obj.Text;
end;
function OpenXmlTextElement.Clone(): OpenXmlTextElement;virtual;
begin
obj := new OpenXmlTextElement(nil, {self.}Prefix, {self.}LocalName);
if not ifnil({self.}Text) then obj.Text := {self.}Text;
return obj;
end
function OpenXmlTextElement.Marshal(): tableArray;override;
begin
arr := array("type": "element", "name": name_, "attributes": array(), "children": array());
@@ -31,7 +40,7 @@ end;
function OpenXmlTextElement.Deserialize();override;
begin
if not ifObj({self.}XmlNode) then return;
if deserialized_ or not ifObj({self.}XmlNode) then return;
{self.}Text := {self.}XmlNode.GetText();
attrs := {self.}XmlNode.Attributes();
for k, v in attrs do
@@ -46,6 +55,7 @@ begin
if ifnil(pf) then continue;
pf.Do(v);
end
deserialized_ := true;
end;
function OpenXmlTextElement.Serialize();override;
+40 -2
View File
@@ -7,6 +7,7 @@ public
function Append(data: any): boolean;
function Insert(data: any): boolean;
function InsertAfter(data: any; pos_data: any);
function InsertBefore(data: any; pos_data: any);
function Get(name: string; index: integer);
function GetElements(include_removed: boolean): array of tslobj;
@@ -17,7 +18,7 @@ private
bucket_: array of LinkList;
child_: array of string;
current_index_: integer;
min_index_; integer;
min_index_: integer;
max_index_: integer;
end;
@@ -28,6 +29,7 @@ public
function Add(data: any);
function Delete(data: any): boolean;
function InsertAfter(data: any; pos_data: any): boolean;
function InsertBefore(data: any; pos_data: any): boolean;
function Name(): string;
function Size(): integer;
function First(): Node;
@@ -194,10 +196,20 @@ begin
end
end;
function TSOfficeContainer.InsertBefore(data: any; pos_data: any);
begin
for i:=0 to current_index_ do
begin
obj := bucket_[i];
if ifObj(obj) then
if obj.InsertBefore(data, pos_data) then break;
end
end;
function TSOfficeContainer.GetElements(include_removed: boolean = true): array of tslobj;
begin
arr := array();
for i:=min_index_ to current_index_ do
pf := function(arr, i)
begin
obj := bucket_[i];
if ifObj(obj) then
@@ -211,6 +223,10 @@ begin
end
end
end
for i:=0 to current_index_ do
##pf(arr, i);
for i:=min_index_ to -1 do
##pf(arr, i);
return arr;
end;
@@ -329,6 +345,28 @@ begin
return false;
end;
function LinkList.InsertBefore(data: any; pos_data: any): boolean;
begin
node := {self.}First();
prev := nil;
while ifObj(node) do
begin
if node.data = pos_data then
begin
new_node := new Node();
new_node.data := data;
new_node.next := node;
if ifnil(prev) then head_.next := new_node;
else prev.next := new_node;
size_++;
return true;
end
prev := node;
node := node.next;
end
return false;
end;
function LinkList.Delete(data: any): boolean;
begin
node := {self.}First();
+111 -37
View File
@@ -1,70 +1,144 @@
unit TSSafeUnitConverter;
interface
function PointsToTwips(value): real;
function TwipsToPoints(value): real;
function CentimetersToPoints(value): real;
function EmusToPoints(value): real;
function HalfPointToPoints(value): real;
function InchesToPoints(value): real;
function LinesToPoints(value): real;
function MillimetersToPoints(value): real;
function PicasToPoints(value): real;
function PixelsToPoints(value): real; // TODO 不实现,与DPI有关
function TwipsToPoints(value): real;
// points -> other
function PointsToCentimeters(value): real;
function PointsToEmus(value): real;
function PointsToInches(value): real;
function PointsToLines(value): real;
function PointsToMillimeters(value);
function PointsToPicas(value);
function PointsToPixels(value); // TODO
function PointsToTwips(value): real;
// other
function HalfPointsToPoints(value): real;
function PointsToHalfPoints(value): real;
function EighthPointsToPoints(value): real;
function PercentToNumber(value): real;
function NumberToPercent(value): real;
function ToInt(value): integer;
function EighthPointToPoints(value): real;
implementation
uses TSUnitConverter;
function PointsToTwips(value): real;
function SafeConvert(value, convert_func): real;
begin
if ifNil(value) then return 0;
new_value := ifString(value) ? strToFloat(value) : value;
return TSUnitConverter.PointsToTwips(new_value);
new_value := ifString(value) ? strToFloatDef(value, 0) : value;
return ##convert_func(new_value);
end;
function TwipsToPoints(value): real;
function CentimetersToPoints(value): real;
begin
if ifNil(value) then return 0;
new_value := ifString(value) ? strToFloat(value) : value;
return TSUnitConverter.TwipsToPoints(new_value);
end;
function HalfPointToPoints(value): real;
begin
if ifNil(value) then return 0;
new_value := ifString(value) ? strToFloat(value) : value;
return TSUnitConverter.HalfPointToPoints(new_value);
return SafeConvert(value, thisFunction(TSUnitConverter.CentimetersToPoints));
end;
function EmusToPoints(value): real;
begin
if ifNil(value) then return 0;
new_value := ifString(value) ? strToFloat(value) : value;
return TSUnitConverter.EmusToPoints(new_value);
return SafeConvert(value, thisFunction(TSUnitConverter.EmusToPoints));
end;
function InchesToPoints(value): real;
begin
return SafeConvert(value, thisFunction(TSUnitConverter.InchesToPoints));
end;
function LinesToPoints(value): real;
begin
return SafeConvert(value, thisFunction(TSUnitConverter.LinesToPoints));
end;
function MillimetersToPoints(value): real;
begin
return SafeConvert(value, thisFunction(TSUnitConverter.MillimetersToPoints));
end;
function PicasToPoints(value): real;
begin
return SafeConvert(value, thisFunction(TSUnitConverter.PicasToPoints));
end;
function TwipsToPoints(value): real;
begin
return SafeConvert(value, thisFunction(TSUnitConverter.TwipsToPoints));
end;
// points -> other
function PointsToCentimeters(value): real;
begin
return SafeConvert(value, thisFunction(TSUnitConverter.PointsToCentimeters));
end;
function PointsToEmus(value): real;
begin
return SafeConvert(value, thisFunction(TSUnitConverter.PointsToEmus));
end;
function PointsToInches(value): real;
begin
return SafeConvert(value, thisFunction(TSUnitConverter.PointsToInches));
end;
function PointsToLines(value): real;
begin
return SafeConvert(value, thisFunction(TSUnitConverter.PointsToLines));
end;
function PointsToMillimeters(value);
begin
return SafeConvert(value, thisFunction(TSUnitConverter.PointsToMillimeters));
end;
function PointsToPicas(value);
begin
return SafeConvert(value, thisFunction(TSUnitConverter.PointsToPicas));
end;
function PointsToTwips(value): real;
begin
return SafeConvert(value, thisFunction(TSUnitConverter.PointsToTwips));
end;
// other
function HalfPointsToPoints(value): real;
begin
return SafeConvert(value, thisFunction(TSUnitConverter.HalfPointsToPoints));
end;
function PointsToHalfPoints(value): real;
begin
return SafeConvert(value, thisFunction(TSUnitConverter.PointsToHalfPoints));
end;
function EighthPointsToPoints(value): real;
begin
return SafeConvert(value, thisFunction(TSUnitConverter.EighthPointsToPoints));
end;
function PercentToNumber(value): real;
begin
if ifNil(value) then return 0;
new_value := ifString(value) ? strToFloat(value) : value;
return TSUnitConverter.PercentToNumber(new_value);
return SafeConvert(value, thisFunction(TSUnitConverter.PercentToNumber));
end;
function NumberToPercent(value): real;
begin
if ifNil(value) then return 0;
new_value := ifString(value) ? strToFloat(value) : value;
return TSUnitConverter.NumberToPercent(new_value);
return SafeConvert(value, thisFunction(TSUnitConverter.NumberToPercent));
end;
function ToInt(value): integer;
function ToInt(value): real;
begin
if ifNil(value) then return 0;
return strtoIntDef(value, 0);
end;
function EighthPointToPoints(value): real;
begin
if ifNil(value) then return 0;
new_value := ifString(value) ? strToFloat(value) : value;
return TSUnitConverter.EighthPointToPoints(new_value);
if ifnumber(value) then return integer(value);
if ifstring(value) then return strToIntDef(value, 0);
return 0;
end;
end.
+103 -21
View File
@@ -1,48 +1,130 @@
unit TSUnitConverter;
interface
function PointsToTwips(value): real;
function TwipsToPoints(value: real): real;
function EmusToPoints(value: real): real;
function HalfPointToPoints(value: real): real;
function EighthPointToPoints(value: real): real;
function PercentToNumber(value: real): real;
function NumberToPercent(value: real): real;
// other -> points
function CentimetersToPoints(centimeters: real): real;
function EmusToPoints(emus: real): real;
function InchesToPoints(inches: real): real;
function LinesToPoints(lines: real): real;
function MillimetersToPoints(millimeters: real): real;
function PicasToPoints(picas: real): real;
function PixelsToPoints(pixels: real; f_vertical: boolean = false): real; // TODO 不实现,与DPI有关
function TwipsToPoints(twips: real): real;
// points -> other
function PointsToCentimeters(points: real): real;
function PointsToEmus(points: real): real;
function PointsToInches(points: real): real;
function PointsToLines(points: real): real;
function PointsToMillimeters(points: real);
function PointsToPicas(points: real);
function PointsToPixels(points: real); // TODO
function PointsToTwips(points): real;
// other
function HalfPointsToPoints(half_points: real): real;
function PointsToHalfPoints(points: real): real;
function EighthPointsToPoints(eighth_points: real): real;
function PercentToNumber(percent: real): real;
function NumberToPercent(number: real): real;
implementation
function PointsToTwips(value): real;
function CentimetersToPoints(centimeters: real): real;
begin
return value * 20;
return centimeters * 28.346456692913385826771653543307;
end;
function TwipsToPoints(value: real): real;
function EmusToPoints(emus: real): real;
begin
return value / 20;
return emus / 12700;
end;
function EmusToPoints(value: real): real;
function InchesToPoints(inches: real): real;
begin
return value / 12700;
return inches * 72;
end;
function HalfPointToPoints(value: real): real;
function LinesToPoints(lines: real): real;
begin
return value / 2;
return lines * 12; // Assuming 1 line = 12 points
end;
function PercentToNumber(value: real): real;
function MillimetersToPoints(millimeters: real): real;
begin
return value / 100;
return millimeters * 2.8346456692913385826771653543307;
end;
function NumberToPercent(value: real): real;
function PicasToPoints(picas: real): real;
begin
return value * 100;
return picas * 12;
end;
function EighthPointToPoints(value: real): real;
function TwipsToPoints(twips: real): real;
begin
return value / 8;
return twips / 20;
end;
// Points -> others
function PointsToCentimeters(points: real): real;
begin
return points / 28.346456692913385826771653543307;
end;
function PointsToEmus(points: real): real;
begin
return points * 12700;
end;
function PointsToInches(points: real): real;
begin
return points / 72;
end;
function PointsToLines(points: real): real;
begin
return points / 12;
end;
function PointsToMillimeters(points: real);
begin
return points / 2.8346456692913385826771653543307;
end;
function PointsToTwips(points): real;
begin
return points * 20;
end;
function PointsToPicas(points: real);
begin
return points / 12;
end;
// other
function HalfPointsToPoints(half_points: real): real;
begin
return half_points / 2;
end;
function PointsToHalfPoints(points: real): real;
begin
return points * 2;
end;
function EighthPointsToPoints(eighth_points: real): real;
begin
return eighth_points / 8;
end;
function PercentToNumber(percent: real): real;
begin
return percent / 100;
end;
function NumberToPercent(number: real): real;
begin
return number * 100;
end;
end.
+18
View File
@@ -27,3 +27,21 @@
4. 新增`OpenXmlCompositeElement`复杂类型的节点类,提供各种操作的方法,大部分有子节点的类均继承于该类。如`RPr`会有`B I Sz`等子节点元素,而`B I`这类的元素是`<x />`的`OpenXmlSimpleType`类型的
影响范围:列表暂无;具体可见对应类的`// simple_type property`下的属性
## v3.0.0
对`adapter`做了`break changes`的更新
1. `unit`文件更名为`adapters`复数结尾,如`DocxMLAdapter` -> `DocxMLAdapters`
2. 移除冗余的命名方式(移除每个类的`Adapter`后缀),`StylesAdapter` -> `Styles`
```pascal
// 弃用
uses DocxMLAdapter;
styles_adapter := new DocxMLAdapter.StylesAdapter(styles);
// 迁移
uses DocxMLAdapters; // 复数s
styles_adapter := new DocxMLAdapters.Styles(styles); // 移除冗余
```