|
|
|
@@ -1,4 +1,4 @@
|
|
|
|
|
// Version 1.8.0
|
|
|
|
|
// Version 1.8.1
|
|
|
|
|
Function TOfficeObj(n);
|
|
|
|
|
Begin
|
|
|
|
|
case lowercase(n) of
|
|
|
|
@@ -11343,6 +11343,65 @@ Type TRun = Class(DocObject, TRunImpl)
|
|
|
|
|
Begin
|
|
|
|
|
n := node_.InsertFirstChild('element', 'w:tab');
|
|
|
|
|
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
|
|
|
|
|