v3.0.0
This commit is contained in:
parent
16452c8362
commit
0b60aeb006
|
|
@ -364,7 +364,7 @@ styles.xml 部分如下
|
|||
```
|
||||
|
||||
```go
|
||||
uses DocxMLAdapter;
|
||||
uses DocxMLAdapters;
|
||||
component := new DocxComponents(); // 创建对象
|
||||
component.Open("", "xxx.docx"); // 打开文件
|
||||
document := component.Document; // 获取document.xml,生成Document对象
|
||||
|
|
@ -372,7 +372,7 @@ document.Deserialize(); // 将xml对象的数据反序列化到tsl对象
|
|||
|
||||
styles := document.Styles;
|
||||
// 现在需要通过styleId获取Style对象
|
||||
styles_adapter := new StylesAdapter(styles);
|
||||
styles_adapter := new DocxMLAdapters.Styles(styles); // 建议指定unit,否则容易冲突
|
||||
// 通过StyleId获取Style对象
|
||||
style := styles_adapter.GetStyleByStyleId("a6");
|
||||
echo style.Name; // 输出的是"页脚 字符"
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -0,0 +1,449 @@
|
|||
unit DocxMLAdapters;
|
||||
interface
|
||||
|
||||
type Tabs = class
|
||||
public
|
||||
function create(_obj: Tabs);
|
||||
function Init();
|
||||
|
||||
function GetTabByVal(_key: string);
|
||||
function AddTab(_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 GetFooterReferenceByType(_key: string);
|
||||
function AddFooterReference(_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);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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 GetNumByNumId(_key: string);
|
||||
function AddNum(_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();
|
||||
for k,v in elements do
|
||||
tab_val_hash_[v.Val] := v;
|
||||
tab_count_++;
|
||||
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 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();
|
||||
for k,v in elements do
|
||||
headerreference_type_hash_[v.Type] := v;
|
||||
headerreference_count_++;
|
||||
elements := object_.FooterReferences();
|
||||
for k,v in elements do
|
||||
footerreference_type_hash_[v.Type] := v;
|
||||
footerreference_count_++;
|
||||
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.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 Endnotes.create(_obj: Endnotes);
|
||||
begin
|
||||
object_ := _obj;
|
||||
endnote_count_ := 0;
|
||||
endnote_id_hash_ := array();
|
||||
{self.}Init();
|
||||
end;
|
||||
|
||||
function Endnotes.Init();
|
||||
begin
|
||||
elements := object_.Endnotes();
|
||||
for k,v in elements do
|
||||
endnote_id_hash_[v.Id] := v;
|
||||
endnote_count_++;
|
||||
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 Footnotes.create(_obj: Footnotes);
|
||||
begin
|
||||
object_ := _obj;
|
||||
footnote_count_ := 0;
|
||||
footnote_id_hash_ := array();
|
||||
{self.}Init();
|
||||
end;
|
||||
|
||||
function Footnotes.Init();
|
||||
begin
|
||||
elements := object_.Footnotes();
|
||||
for k,v in elements do
|
||||
footnote_id_hash_[v.Id] := v;
|
||||
footnote_count_++;
|
||||
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 FootnotePr.create(_obj: FootnotePr);
|
||||
begin
|
||||
object_ := _obj;
|
||||
footnote_count_ := 0;
|
||||
footnote_id_hash_ := array();
|
||||
{self.}Init();
|
||||
end;
|
||||
|
||||
function FootnotePr.Init();
|
||||
begin
|
||||
elements := object_.Footnotes();
|
||||
for k,v in elements do
|
||||
footnote_id_hash_[v.Id] := v;
|
||||
footnote_count_++;
|
||||
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 EndnotePr.create(_obj: EndnotePr);
|
||||
begin
|
||||
object_ := _obj;
|
||||
footnote_count_ := 0;
|
||||
footnote_id_hash_ := array();
|
||||
{self.}Init();
|
||||
end;
|
||||
|
||||
function EndnotePr.Init();
|
||||
begin
|
||||
elements := object_.Footnotes();
|
||||
for k,v in elements do
|
||||
footnote_id_hash_[v.Id] := v;
|
||||
footnote_count_++;
|
||||
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 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();
|
||||
for k,v in elements do
|
||||
begin
|
||||
style_styleid_hash_[v.StyleId] := v;
|
||||
style_name_hash_[v.Name.Val] := v;
|
||||
style_count_++;
|
||||
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 Style.create(_obj: Style);
|
||||
begin
|
||||
object_ := _obj;
|
||||
tblstylepr_count_ := 0;
|
||||
tblstylepr_type_hash_ := array();
|
||||
{self.}Init();
|
||||
end;
|
||||
|
||||
function Style.Init();
|
||||
begin
|
||||
elements := object_.TblStylePrs();
|
||||
for k,v in elements do
|
||||
tblstylepr_type_hash_[v.Type] := v;
|
||||
tblstylepr_count_++;
|
||||
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 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();
|
||||
for k,v in elements do
|
||||
abstractnum_abstractnumid_hash_[v.AbstractNumId] := v;
|
||||
abstractnum_count_++;
|
||||
elements := object_.Nums();
|
||||
for k,v in elements do
|
||||
num_numid_hash_[v.NumId] := v;
|
||||
num_count_++;
|
||||
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.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;
|
||||
|
||||
end.
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
unit DrawingMLAdapter;
|
||||
interface
|
||||
|
||||
implementation
|
||||
|
||||
end.
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
unit DrawingMLAdapters;
|
||||
interface
|
||||
|
||||
implementation
|
||||
|
||||
end.
|
||||
|
|
@ -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.
|
||||
|
|
@ -0,0 +1,126 @@
|
|||
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);
|
||||
|
||||
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 GetOverrideByPartName(_key: string);
|
||||
function AddOverride(_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();
|
||||
for k,v in elements do
|
||||
begin
|
||||
relationship_id_hash_[v.Id] := v;
|
||||
relationship_target_hash_[v.Target] := v;
|
||||
relationship_count_++;
|
||||
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 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();
|
||||
for k,v in elements do
|
||||
default_extension_hash_[v.Extension] := v;
|
||||
default_count_++;
|
||||
elements := object_.Overrides();
|
||||
for k,v in elements do
|
||||
override_partname_hash_[v.PartName] := v;
|
||||
override_count_++;
|
||||
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.GetOverrideByPartName(_key: string);
|
||||
begin
|
||||
return override_partname_hash_[_key];
|
||||
end;
|
||||
|
||||
function Types.AddOverride(_value: Override);
|
||||
begin
|
||||
override_partname_hash_[_value.PartName] := _value;
|
||||
override_count_++;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
unit VMLAdapter;
|
||||
unit VMLAdapters;
|
||||
interface
|
||||
|
||||
implementation
|
||||
18
迁移指南.md
18
迁移指南.md
|
|
@ -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 := DocxMLAdapter.StylesAdapter(styles);
|
||||
|
||||
// 迁移
|
||||
uses DocxMLAdapters; // 复数s
|
||||
styles_adapter := DocxMLAdapters.Styles(styles); // 移除冗余
|
||||
```
|
||||
Loading…
Reference in New Issue