v1.8.1
This commit is contained in:
parent
d57631a19a
commit
ca03e53285
|
|
@ -1,4 +1,4 @@
|
||||||
// Version 1.8.0
|
// Version 1.8.1
|
||||||
Function TOfficeObj(n);
|
Function TOfficeObj(n);
|
||||||
Begin
|
Begin
|
||||||
case lowercase(n) of
|
case lowercase(n) of
|
||||||
|
|
@ -11343,6 +11343,65 @@ Type TRun = Class(DocObject, TRunImpl)
|
||||||
Begin
|
Begin
|
||||||
n := node_.InsertFirstChild('element', 'w:tab');
|
n := node_.InsertFirstChild('element', 'w:tab');
|
||||||
End;
|
End;
|
||||||
|
|
||||||
|
Function SetDrawing(picture, docx);
|
||||||
|
Begin
|
||||||
|
if ifObj(docx) then Begin
|
||||||
|
zipfile := docx.Zip();
|
||||||
|
{self.}Drawing.WInline.ID := docx.GetDocPrId();
|
||||||
|
End;
|
||||||
|
if not ifBinary(picture.Image) or length(picture.Image)=0 then
|
||||||
|
raise 'Invalid Image Data.';
|
||||||
|
if not ifObj(zipfile) then
|
||||||
|
raise 'no support';
|
||||||
|
image := new TSImage(picture.Image);
|
||||||
|
xml := zipfile.Get('word/_rels/document.xml.rels');
|
||||||
|
files := sselect ['FileName'] from zipfile.Files() where AnsiStartsText('word/media/image', ['FileName']) end;
|
||||||
|
for i:=0 to length(files)-1 do Begin
|
||||||
|
if zipfile.Diff(files[i], picture.Image) = 0 then Begin
|
||||||
|
prefix := ReplaceStr(files[i], 'word/', '');
|
||||||
|
[maxRid, imageFile, rid] := class(TSXml).FindRelationshipRid(xml, prefix);
|
||||||
|
End;
|
||||||
|
End;
|
||||||
|
if rid = 0 then Begin
|
||||||
|
imageCnt := length(files) + 1;
|
||||||
|
imageFile := 'media/image' $ imageCnt $ '.' $ image.ExtFileName;
|
||||||
|
[rid, target] := class(TSXml).FindRelationshipRid(xml, '');
|
||||||
|
rid ++;
|
||||||
|
class(TSXml).AddRelationshipRid(xml, imageFile, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image', 'rId' $ rid);
|
||||||
|
zipfile.Add('word/' + imageFile, picture.Image);
|
||||||
|
contentXml := zipfile.Get('[Content_Types].xml');
|
||||||
|
class(TSXml).AddDefaultContentType(contentXml, image.ExtFileName, 'image/' $ image.ExtFileName);
|
||||||
|
End;
|
||||||
|
[cx, cy] := picture.ScaledDimensions(image);//extent 元素通过其属性指定此对象的高度和宽度为 [cx,cy] ETU (英语公制单位)
|
||||||
|
Drawing.WInline.Graphic.GraphicData.Pic.BlipFill.blip.Embed := 'rId' $ rid;
|
||||||
|
Drawing.WInline.Graphic.GraphicData.Pic.BlipFill.Stretch.FillRect := 1;
|
||||||
|
picId := docx.Body().getPictureMaxId() + 1;
|
||||||
|
Drawing.WInline.Name := '图片 ' $ picId;
|
||||||
|
Drawing.WInline.Descr := class(TSXml).CurCodePageToUtf8(picture.Descr);
|
||||||
|
Drawing.WInline.cNvGraphicFramePr.xmlns := 'http://schemas.openxmlformats.org/drawingml/2006/main';
|
||||||
|
Drawing.WInline.cNvGraphicFramePr.noChangeAspect := 1;
|
||||||
|
Drawing.WInline.Graphic.xmlns := 'http://schemas.openxmlformats.org/drawingml/2006/main';
|
||||||
|
Drawing.WInline.Graphic.GraphicData.uri := 'http://schemas.openxmlformats.org/drawingml/2006/picture';
|
||||||
|
Drawing.WInline.Graphic.GraphicData.Pic.xmlns := 'http://schemas.openxmlformats.org/drawingml/2006/picture';
|
||||||
|
Drawing.WInline.Graphic.GraphicData.Pic.nvPicPr.CNvPr.ID := Drawing.WInline.ID;
|
||||||
|
Drawing.WInline.Graphic.GraphicData.Pic.nvPicPr.CNvPr.Name := Drawing.WInline.Name;
|
||||||
|
Drawing.WInline.Graphic.GraphicData.Pic.nvPicPr.CNvPr.Descr := Drawing.WInline.Descr;
|
||||||
|
Drawing.WInline.Graphic.GraphicData.Pic.nvPicPr.cNvPicPr.NodeName := 'pic:cNvPicPr';
|
||||||
|
Drawing.WInline.Graphic.GraphicData.Pic.nvPicPr.cNvPicPr.PicLocks := 1;
|
||||||
|
Drawing.WInline.Graphic.GraphicData.Pic.spPr.PrstGeom.prst := 'rect';
|
||||||
|
Drawing.WInline.Graphic.GraphicData.Pic.spPr.PrstGeom.avLst := true;
|
||||||
|
Drawing.WInline.Graphic.GraphicData.Pic.spPr.XFrm.Off.X := 0;
|
||||||
|
Drawing.WInline.Graphic.GraphicData.Pic.spPr.XFrm.Off.Y := 0;
|
||||||
|
Drawing.WInline.Graphic.GraphicData.Pic.spPr.XFrm.Ext.CX := cx;
|
||||||
|
Drawing.WInline.Graphic.GraphicData.Pic.spPr.XFrm.Ext.CY := cy;
|
||||||
|
Drawing.WInline.distR := 114300;
|
||||||
|
Drawing.WInline.distL := 114300;
|
||||||
|
Drawing.WInline.distB := 0;
|
||||||
|
Drawing.WInline.distT := 0;
|
||||||
|
Drawing.WInline.cy := cy;
|
||||||
|
Drawing.WInline.cx := cx;
|
||||||
|
End;
|
||||||
|
|
||||||
///添加文字
|
///添加文字
|
||||||
///[isUtf8]:可选参数,当前字符集是否utf8,缺省false
|
///[isUtf8]:可选参数,当前字符集是否utf8,缺省false
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Version 1.8.0
|
// Version 1.8.1
|
||||||
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.8.0
|
// Version 1.8.1
|
||||||
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 等多种文档格式。
|
||||||
|
|
|
||||||
25
更新日志.md
25
更新日志.md
|
|
@ -1,5 +1,30 @@
|
||||||
# 更新日志
|
# 更新日志
|
||||||
|
|
||||||
|
## 2025-7-22
|
||||||
|
|
||||||
|
### V1.8.1
|
||||||
|
|
||||||
|
#### word
|
||||||
|
|
||||||
|
1. **feat**: 支持同一段落多图片文字
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
picture := TOfficeObj('TPicture');
|
||||||
|
picture.Descr := '插入图像案例';
|
||||||
|
picture.Image := TOfficeTemplate('tinysoft.gif',true);
|
||||||
|
|
||||||
|
docx := new TSDocxFile();
|
||||||
|
docx.NewFile();
|
||||||
|
p := new TOfficeObj('TParagraph');
|
||||||
|
r := p.AddRun();
|
||||||
|
r.SetText("abc");
|
||||||
|
r := p.AddRun();
|
||||||
|
r.SetDrawing(picture, docx); // 需要一个图片对象和TSDocxFile对象
|
||||||
|
r := p.AddRun();
|
||||||
|
r.SetText("def");
|
||||||
|
docx.AddParagraph(p, -1);
|
||||||
|
```
|
||||||
|
|
||||||
## 2025-6-23
|
## 2025-6-23
|
||||||
|
|
||||||
### V1.8.0
|
### V1.8.0
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue