Files
TSOffice/funcext/TSOffice/document/docxDocument.tsf
T
2023-11-14 11:38:27 +08:00

53 lines
1.1 KiB
Plaintext

Type docxDocument = Class
/// word/document.xml对象
///缺省构造函数
Function Create(z); overload;
Begin
zipfile_ := z;
document_ := zipfile_.Get('word/document.xml');
root_ := document_.FirstChildElement('w:document');
bodyNode_ := root_.FirstChildElement('w:body');
body_ := TOfficeObj('TwBody');
body_.InitNode(bodyNode_);
body_.InitRootNode(bodyNode_);
body_.zipfile_ := z;
body_.document_ := self;
bookmarkid_ := -1;
End;
Function Body();
Begin
return body_;
End;
Function GetBookMarkID();
Begin
if bookmarkid_ < 0 then Begin
bookmarkid_ := 0;
p := body_.node_.FirstChildElement('w:p');
while ifObj(p) do Begin
markStart := p.FirstChildElement('w:bookmarkStart');
if ifObj(markStart) then Begin
id := markStart.GetAttribute('w:id');
if ifstring(id) and id <> '' then Begin
iVal := strtoint(id);
if bookmarkid_ <= iVal then
bookmarkid_ := iVal + 1;
End;
End;
p := p.NextElement('w:p');
End;
End
else
bookmarkid_++;
return bookmarkid_;
End;
private
root_;//w:document
bodyNode_;//w:body
body_;
document_;
bookmarkid_;
End;