v1.7.3
This commit is contained in:
parent
0e35cc0463
commit
2d423ca1fb
|
|
@ -1,4 +1,4 @@
|
||||||
// Version 1.7.2
|
// Version 1.7.3
|
||||||
Function TOfficeObj(n);
|
Function TOfficeObj(n);
|
||||||
Begin
|
Begin
|
||||||
case lowercase(n) of
|
case lowercase(n) of
|
||||||
|
|
@ -14034,7 +14034,6 @@ Type TDocumentBody = Class(DocObject)
|
||||||
end
|
end
|
||||||
End
|
End
|
||||||
else if TOfficeApi().Get('CELLFLAG') and ifarray(numIds) and name = 'w:tbl' then Begin
|
else if TOfficeApi().Get('CELLFLAG') and ifarray(numIds) and name = 'w:tbl' then Begin
|
||||||
println("enter...");
|
|
||||||
tbl := TOfficeObj('TTable');
|
tbl := TOfficeObj('TTable');
|
||||||
tbl.Init(pNode);
|
tbl.Init(pNode);
|
||||||
rows := tbl.Rows();
|
rows := tbl.Rows();
|
||||||
|
|
@ -14058,7 +14057,6 @@ Type TDocumentBody = Class(DocObject)
|
||||||
End;
|
End;
|
||||||
pNode := pNode.NextElement();
|
pNode := pNode.NextElement();
|
||||||
End;
|
End;
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
End;
|
End;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Version 1.7.2
|
// Version 1.7.3
|
||||||
Type TSDocxFile = Class
|
Type TSDocxFile = Class
|
||||||
///Version: V1.0 2022-09-20
|
///Version: V1.0 2022-09-20
|
||||||
///适用于 Microsoft Word docx格式文件
|
///适用于 Microsoft Word docx格式文件
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Version 1.7.2
|
// Version 1.7.3
|
||||||
Type TSXlsxFile = Class
|
Type TSXlsxFile = Class
|
||||||
///Version: V1.0 2022-08-08
|
///Version: V1.0 2022-08-08
|
||||||
///适用于 Microsoft Excel? 2007 及以上版本创建的电子表格文档。支持 XLSX / XLSM / XLTM / XLTX 等多种文档格式。
|
///适用于 Microsoft Excel? 2007 及以上版本创建的电子表格文档。支持 XLSX / XLSM / XLTM / XLTX 等多种文档格式。
|
||||||
|
|
|
||||||
|
|
@ -101,6 +101,56 @@ private
|
||||||
end
|
end
|
||||||
End;
|
End;
|
||||||
|
|
||||||
|
Function SetRObject(node);
|
||||||
|
Begin
|
||||||
|
image_data_node := class(TSXml).GetNode(node, 'v:shape/v:imagedata');
|
||||||
|
if not ifObj(node) then return;
|
||||||
|
rid := image_data_node.GetAttribute('r:id');
|
||||||
|
id := CopyRidContent(rid, 'media/image', 'image');
|
||||||
|
if id then image_data_node.SetAttribute('r:id', 'rId' $ id);
|
||||||
|
ole_node := class(TSXml).GetNode(node, 'o:OLEObject');
|
||||||
|
if not ifObj(node) then return;
|
||||||
|
rid := ole_node.GetAttribute('r:id');
|
||||||
|
id := CopyRidContent(rid, 'embeddings/oleObject', 'oleObject');
|
||||||
|
if id then ole_node.SetAttribute('r:id', 'rId' $ id);
|
||||||
|
End;
|
||||||
|
|
||||||
|
function CopyRidContent(id, tar_prefix, type_postfix);
|
||||||
|
begin
|
||||||
|
rels := new_docx_obj_.Zip().Get('word/_rels/document.xml.rels');
|
||||||
|
target := class(TSXml).FindRelationshipTarget(rels, id);
|
||||||
|
image_file := new_docx_obj_.Zip().Get('word/' $ target).Data();
|
||||||
|
|
||||||
|
// 比较新文件的图片在旧文件中是否存在
|
||||||
|
zip := old_docx_obj_.Zip();
|
||||||
|
xml := zip.Get('word/_rels/document.xml.rels');
|
||||||
|
files := sselect ['FileName'] from zip.Files() where AnsiStartsText('word/' $ tar_prefix, ['FileName']) end;
|
||||||
|
for i:=0 to length(files)-1 do Begin
|
||||||
|
if zip.Diff(files[i], image_file) = 0 then Begin
|
||||||
|
prefix := ReplaceStr(files[i], 'word/', '');
|
||||||
|
[maxRid, imageFile, rid] := class(TSXml).FindRelationshipRid(xml, prefix);
|
||||||
|
End;
|
||||||
|
End;
|
||||||
|
if rid = 0 then
|
||||||
|
begin
|
||||||
|
image_cnt := length(files) + 1;
|
||||||
|
if ParseRegExpr("\\w+$", target, "", result, Mpos, Mlen) then
|
||||||
|
begin
|
||||||
|
postfix := result[0][0];
|
||||||
|
image_path := tar_prefix $ image_cnt $ '.' $ postfix;
|
||||||
|
[rid, tar] := class(TSXml).FindRelationshipRid(xml, '');
|
||||||
|
rid ++;
|
||||||
|
class(TSXml).AddRelationshipRid(xml, image_path, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/' $ type_postfix, 'rId' $ rid);
|
||||||
|
zip.Add('word/' + image_path, image_file);
|
||||||
|
contentXml := zip.Get('[Content_Types].xml');
|
||||||
|
if postfix = 'wmf' then content_type := 'image/x-wmf';
|
||||||
|
else if postfix = 'bin' then content_type := 'application/vnd.openxmlformats-officedocument.oleObject';
|
||||||
|
class(TSXml).AddDefaultContentType(contentXml, postfix, content_type);
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return rid;
|
||||||
|
end;
|
||||||
|
|
||||||
Function SetPic(node);
|
Function SetPic(node);
|
||||||
Begin
|
Begin
|
||||||
// 获取新文件的图片
|
// 获取新文件的图片
|
||||||
|
|
@ -224,6 +274,9 @@ private
|
||||||
begin
|
begin
|
||||||
CopyFootnote(run);
|
CopyFootnote(run);
|
||||||
CopyStyle(run, 'w:rPr/w:rStyle');
|
CopyStyle(run, 'w:rPr/w:rStyle');
|
||||||
|
obj_node := class(TSXml).GetNode(run, 'w:object');
|
||||||
|
if ifObj(obj_node) then
|
||||||
|
SetRObject(obj_node);
|
||||||
run := run.NextElement();
|
run := run.NextElement();
|
||||||
end
|
end
|
||||||
End;
|
End;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue