1
0
mirror of https://github.com/fumiama/go-docx.git synced 2026-06-05 07:40:24 +08:00

refactor: Paragraph.Children to []interface{}

This commit is contained in:
源文雨
2023-02-22 21:05:15 +08:00
parent 9f0dbc43d1
commit 8f87a17722
9 changed files with 81 additions and 555 deletions

View File

@@ -37,10 +37,10 @@ func TestUnmarshalPlainStructure(t *testing.T) {
t.Fatalf("We were not able to parse paragraph %d", i)
}
for _, child := range p.Children {
if child.Link == nil && child.Properties == nil && child.Run == nil {
if child == nil {
t.Fatalf("There are Paragraph children with all fields nil")
}
if child.Link != nil && child.Link.ID == "" {
if o, ok := child.(*Hyperlink); ok && o.ID == "" {
t.Fatalf("We have a link without ID")
}
}
@@ -48,510 +48,6 @@ func TestUnmarshalPlainStructure(t *testing.T) {
}
}
const drawing_doc = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<w:document xmlns:wpc="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas"
xmlns:cx="http://schemas.microsoft.com/office/drawing/2014/chartex"
xmlns:cx1="http://schemas.microsoft.com/office/drawing/2015/9/8/chartex"
xmlns:cx2="http://schemas.microsoft.com/office/drawing/2015/10/21/chartex"
xmlns:cx3="http://schemas.microsoft.com/office/drawing/2016/5/9/chartex"
xmlns:cx4="http://schemas.microsoft.com/office/drawing/2016/5/10/chartex"
xmlns:cx5="http://schemas.microsoft.com/office/drawing/2016/5/11/chartex"
xmlns:cx6="http://schemas.microsoft.com/office/drawing/2016/5/12/chartex"
xmlns:cx7="http://schemas.microsoft.com/office/drawing/2016/5/13/chartex"
xmlns:cx8="http://schemas.microsoft.com/office/drawing/2016/5/14/chartex"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:aink="http://schemas.microsoft.com/office/drawing/2016/ink"
xmlns:am3d="http://schemas.microsoft.com/office/drawing/2017/model3d"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:oel="http://schemas.microsoft.com/office/2019/extlst"
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math"
xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing"
xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"
xmlns:w10="urn:schemas-microsoft-com:office:word"
xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml"
xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml"
xmlns:w16cex="http://schemas.microsoft.com/office/word/2018/wordml/cex"
xmlns:w16cid="http://schemas.microsoft.com/office/word/2016/wordml/cid"
xmlns:w16="http://schemas.microsoft.com/office/word/2018/wordml"
xmlns:w16sdtdh="http://schemas.microsoft.com/office/word/2020/wordml/sdtdatahash"
xmlns:w16se="http://schemas.microsoft.com/office/word/2015/wordml/symex"
xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup"
xmlns:wpi="http://schemas.microsoft.com/office/word/2010/wordprocessingInk"
xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml"
xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape" mc:Ignorable="w14 w15 w16se w16cid w16 w16cex w16sdtdh wp14">
<w:body>
<w:p w14:paraId="53D18053" w14:textId="034941A2" w:rsidR="00EE4CB0" w:rsidRDefault="00EE4CB0">
<w:pPr>
<w:rPr>
<w:rFonts w:hint="eastAsia"/>
</w:rPr>
</w:pPr>
<w:r>
<w:rPr>
<w:rFonts w:hint="eastAsia"/>
</w:rPr>
<w:t>直接粘贴</w:t>
</w:r>
<w:r w:rsidR="00F71D77">
<w:rPr>
<w:rFonts w:hint="eastAsia"/>
</w:rPr>
<w:t xml:space="preserve"></w:t>
</w:r>
<w:r w:rsidR="00F71D77">
<w:t>inline</w:t>
</w:r>
</w:p>
<w:p w14:paraId="525D8E7A" w14:textId="19079AFC" w:rsidR="00694680" w:rsidRDefault="00D04928">
<w:r>
<w:rPr>
<w:noProof/>
</w:rPr>
<w:drawing>
<wp:inline distT="0" distB="1" distL="2" distR="3" wp14:anchorId="mock-anchor-p1-c0" wp14:editId="mock-edit-p1-c0">
<wp:extent cx="5274310" cy="3369310"/>
<wp:effectExtent l="0" t="0" r="0" b="0"/>
<wp:docPr id="1" name="图片 1"/>
<wp:cNvGraphicFramePr>
<a:graphicFrameLocks xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" noChangeAspect="1"/>
</wp:cNvGraphicFramePr>
<a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
<a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/picture">
<pic:pic xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture">
<pic:nvPicPr>
<pic:cNvPr id="1" name="图片 1"/>
<pic:cNvPicPr/>
</pic:nvPicPr>
<pic:blipFill>
<a:blip r:embed="rId4" cstate="print">
<a:extLst>
<a:ext uri="{28A0092B-C50C-407E-A947-70E740481C1C}">
<a14:useLocalDpi xmlns:a14="http://schemas.microsoft.com/office/drawing/2010/main" val="0"/>
</a:ext>
</a:extLst>
</a:blip>
<a:stretch>
<a:fillRect/>
</a:stretch>
</pic:blipFill>
<pic:spPr>
<a:xfrm>
<a:off x="0" y="0"/>
<a:ext cx="5274310" cy="3369310"/>
</a:xfrm>
<a:prstGeom prst="rect">
<a:avLst/>
</a:prstGeom>
</pic:spPr>
</pic:pic>
</a:graphicData>
</a:graphic>
</wp:inline>
</w:drawing>
</w:r>
</w:p>
<w:p w14:paraId="272A3387" w14:textId="6FF6E032" w:rsidR="00EE4CB0" w:rsidRDefault="00A549AD">
<w:pPr>
<w:rPr>
<w:rFonts w:hint="eastAsia"/>
</w:rPr>
</w:pPr>
<w:r>
<w:rPr>
<w:rFonts w:hint="eastAsia"/>
</w:rPr>
<w:t xml:space="preserve">一行2个 </w:t>
</w:r>
<w:r>
<w:t>inline</w:t>
</w:r>
</w:p>
<w:p w14:paraId="03284AA8" w14:textId="5134D375" w:rsidR="00EE4CB0" w:rsidRDefault="00EE4CB0">
<w:r>
<w:rPr>
<w:noProof/>
</w:rPr>
<w:drawing>
<wp:inline distT="0" distB="1" distL="2" distR="3" wp14:anchorId="mock-anchor-p3-c0" wp14:editId="mock-edit-p3-c0">
<wp:extent cx="2339163" cy="1494293"/>
<wp:effectExtent l="0" t="0" r="0" b="4445"/>
<wp:docPr id="2" name="图片 2"/>
<wp:cNvGraphicFramePr>
<a:graphicFrameLocks xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" noChangeAspect="1"/>
</wp:cNvGraphicFramePr>
<a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
<a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/picture">
<pic:pic xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture">
<pic:nvPicPr>
<pic:cNvPr id="1" name="图片 1"/>
<pic:cNvPicPr/>
</pic:nvPicPr>
<pic:blipFill>
<a:blip r:embed="rId5" cstate="print">
<a:extLst>
<a:ext uri="{28A0092B-C50C-407E-A947-70E740481C1C}">
<a14:useLocalDpi xmlns:a14="http://schemas.microsoft.com/office/drawing/2010/main" val="0"/>
</a:ext>
</a:extLst>
</a:blip>
<a:stretch>
<a:fillRect/>
</a:stretch>
</pic:blipFill>
<pic:spPr>
<a:xfrm>
<a:off x="0" y="0"/>
<a:ext cx="2378569" cy="1519466"/>
</a:xfrm>
<a:prstGeom prst="rect">
<a:avLst/>
</a:prstGeom>
</pic:spPr>
</pic:pic>
</a:graphicData>
</a:graphic>
</wp:inline>
</w:drawing>
</w:r>
<w:r>
<w:rPr>
<w:noProof/>
</w:rPr>
<w:drawing>
<wp:inline distT="0" distB="1" distL="2" distR="3" wp14:anchorId="mock-anchor-p3-c1" wp14:editId="mock-edit-p3-c1">
<wp:extent cx="2339163" cy="1494293"/>
<wp:effectExtent l="0" t="0" r="0" b="4445"/>
<wp:docPr id="4" name="图片 4"/>
<wp:cNvGraphicFramePr>
<a:graphicFrameLocks xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" noChangeAspect="1"/>
</wp:cNvGraphicFramePr>
<a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
<a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/picture">
<pic:pic xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture">
<pic:nvPicPr>
<pic:cNvPr id="1" name="图片 1"/>
<pic:cNvPicPr/>
</pic:nvPicPr>
<pic:blipFill>
<a:blip r:embed="rId5" cstate="print">
<a:extLst>
<a:ext uri="{28A0092B-C50C-407E-A947-70E740481C1C}">
<a14:useLocalDpi xmlns:a14="http://schemas.microsoft.com/office/drawing/2010/main" val="0"/>
</a:ext>
</a:extLst>
</a:blip>
<a:stretch>
<a:fillRect/>
</a:stretch>
</pic:blipFill>
<pic:spPr>
<a:xfrm>
<a:off x="0" y="0"/>
<a:ext cx="2378569" cy="1519466"/>
</a:xfrm>
<a:prstGeom prst="rect">
<a:avLst/>
</a:prstGeom>
</pic:spPr>
</pic:pic>
</a:graphicData>
</a:graphic>
</wp:inline>
</w:drawing>
</w:r>
</w:p>
<w:p w14:paraId="72A11E8B" w14:textId="0CEBAF2D" w:rsidR="00084CD5" w:rsidRDefault="00084CD5">
<w:pPr>
<w:rPr>
<w:rFonts w:hint="eastAsia"/>
</w:rPr>
</w:pPr>
<w:r>
<w:rPr>
<w:rFonts w:hint="eastAsia"/>
</w:rPr>
<w:t xml:space="preserve">一行2个组合 </w:t>
</w:r>
<w:r>
<w:t>inline</w:t>
</w:r>
</w:p>
<w:p w14:paraId="6C280000" w14:textId="64F61F86" w:rsidR="00EE4CB0" w:rsidRDefault="0056103D">
<w:r>
<w:rPr>
<w:rFonts w:hint="eastAsia"/>
<w:noProof/>
</w:rPr>
<mc:AlternateContent>
<mc:Choice Requires="wpg">
<w:drawing>
<wp:inline distT="0" distB="1" distL="2" distR="3" wp14:anchorId="mock-anchor-p5-c0" wp14:editId="mock-edit-p5-c0">
<wp:extent cx="4677868" cy="1494155"/>
<wp:effectExtent l="0" t="0" r="0" b="4445"/>
<wp:docPr id="7" name="组合 7"/>
<wp:cNvGraphicFramePr/>
<a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
<a:graphicData uri="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup">
<wpg:wgp>
<wpg:cNvGrpSpPr/>
<wpg:grpSpPr>
<a:xfrm>
<a:off x="0" y="0"/>
<a:ext cx="4677868" cy="1494155"/>
<a:chOff x="0" y="0"/>
<a:chExt cx="4677868" cy="1494155"/>
</a:xfrm>
</wpg:grpSpPr>
<pic:pic xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture">
<pic:nvPicPr>
<pic:cNvPr id="6" name="图片 6"/>
<pic:cNvPicPr>
<a:picLocks noChangeAspect="1"/>
</pic:cNvPicPr>
</pic:nvPicPr>
<pic:blipFill>
<a:blip r:embed="rId6" cstate="print">
<a:extLst>
<a:ext uri="{28A0092B-C50C-407E-A947-70E740481C1C}">
<a14:useLocalDpi xmlns:a14="http://schemas.microsoft.com/office/drawing/2010/main" val="0"/>
</a:ext>
</a:extLst>
</a:blip>
<a:stretch>
<a:fillRect/>
</a:stretch>
</pic:blipFill>
<pic:spPr>
<a:xfrm>
<a:off x="2339163" y="0"/>
<a:ext cx="2338705" cy="1494155"/>
</a:xfrm>
<a:prstGeom prst="rect">
<a:avLst/>
</a:prstGeom>
</pic:spPr>
</pic:pic>
<pic:pic xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture">
<pic:nvPicPr>
<pic:cNvPr id="5" name="图片 5"/>
<pic:cNvPicPr>
<a:picLocks noChangeAspect="1"/>
</pic:cNvPicPr>
</pic:nvPicPr>
<pic:blipFill>
<a:blip r:embed="rId6" cstate="print">
<a:extLst>
<a:ext uri="{28A0092B-C50C-407E-A947-70E740481C1C}">
<a14:useLocalDpi xmlns:a14="http://schemas.microsoft.com/office/drawing/2010/main" val="0"/>
</a:ext>
</a:extLst>
</a:blip>
<a:stretch>
<a:fillRect/>
</a:stretch>
</pic:blipFill>
<pic:spPr>
<a:xfrm>
<a:off x="0" y="0"/>
<a:ext cx="2338705" cy="1494155"/>
</a:xfrm>
<a:prstGeom prst="rect">
<a:avLst/>
</a:prstGeom>
</pic:spPr>
</pic:pic>
</wpg:wgp>
</a:graphicData>
</a:graphic>
</wp:inline>
</w:drawing>
</mc:Choice>
<mc:Fallback>
<w:pict>
<v:group w14:anchorId="27116046" id="组合 7" o:spid="_x0000_s1026" style="width:368.35pt;height:117.65pt;mso-position-horizontal-relative:char;mso-position-vertical-relative:line" coordsize="46778,14941" o:gfxdata="UEsDBBQABgAIAAAAIQCxgme2CgEAABMCAAATAAAAW0NvbnRlbnRfVHlwZXNdLnhtbJSRwU7DMAyG&#xD;&#xA;70i8Q5QralN2QAit3YGOIyA0HiBK3DaicaI4lO3tSbpNgokh7Rjb3+8vyXK1tSObIJBxWPPbsuIM&#xD;&#xA;UDltsK/5++apuOeMokQtR4dQ8x0QXzXXV8vNzgOxRCPVfIjRPwhBagArqXQeMHU6F6yM6Rh64aX6&#xD;&#xA;kD2IRVXdCeUwAsYi5gzeLFvo5OcY2XqbynsTjz1nj/u5vKrmxmY+18WfRICRThDp/WiUjOluYkJ9&#xD;&#xA;4lUcnMpEzjM0GE83SfzMhtz57fRzwYF7SY8ZjAb2KkN8ljaZCx1IwMK1TpX/Z2RJS4XrOqOgbAOt&#xD;&#xA;Z+rodC5buy8MMF0a3ibsDaZjupi/tPkGAAD//wMAUEsDBBQABgAIAAAAIQA4/SH/1gAAAJQBAAAL&#xD;&#xA;AAAAX3JlbHMvLnJlbHOkkMFqwzAMhu+DvYPRfXGawxijTi+j0GvpHsDYimMaW0Yy2fr2M4PBMnrb&#xD;&#xA;Ub/Q94l/f/hMi1qRJVI2sOt6UJgd+ZiDgffL8ekFlFSbvV0oo4EbChzGx4f9GRdb25HMsYhqlCwG&#xD;&#xA;5lrLq9biZkxWOiqY22YiTra2kYMu1l1tQD30/bPm3wwYN0x18gb45AdQl1tp5j/sFB2T0FQ7R0nT&#xD;&#xA;NEV3j6o9feQzro1iOWA14Fm+Q8a1a8+Bvu/d/dMb2JY5uiPbhG/ktn4cqGU/er3pcvwCAAD//wMA&#xD;&#xA;UEsDBBQABgAIAAAAIQDcfKgKYwIAAFoHAAAOAAAAZHJzL2Uyb0RvYy54bWzsVVtqGzEU/S90D0L/&#xD;&#xA;8fhtZ7AdSt2YQmhNHwuQNZoZkdGDK/m1gtI1dC/dTek2eqWZuLEdcMlHodAPy9Lo6uqcc4+kyc1O&#xD;&#xA;VWQjwEmjp7TTalMiNDeZ1MWUfv50ezWmxHmmM1YZLaZ0Lxy9mb18MdnaVHRNaapMAMEk2qVbO6Wl&#xD;&#xA;9zZNEsdLoZhrGSs0TuYGFPM4hCLJgG0xu6qSbrs9TLYGMguGC+fw67yepLOYP88F9+/z3AlPqilF&#xD;&#xA;bD62ENtVaJPZhKUFMFtK3sBgz0ChmNS46SHVnHlG1iDPUinJwTiT+xY3KjF5LrmIHJBNp33CZgFm&#xD;&#xA;bSOXIt0W9iATSnui07PT8nebBdiPdgmoxNYWqEUcBS67HFT4R5RkFyXbHyQTO084fuwPR6PxEIvM&#xD;&#xA;ca7Tv+53BoNaVF6i8mfrePnmwsrkYePkCI6VPMVfowH2zjS47BVc5dcgaJNE/VEOxeB+ba+wXJZ5&#xD;&#xA;uZKV9PtoPSxMAKU3S8mXUA9QziUQmU3pkBLNFDr+x7fvP79+IcOgSogPIfUCFgjdGX7viDavS6YL&#xD;&#xA;8cpZtCwqGaKT4/A4PNptVUl7K6sqFCn0G15o7xN7PCFNbb254WsltK/PEogKKRrtSmkdJZAKtRLI&#xD;&#xA;Bd5mHawwnmOPhCxI7esaOw/......">
<v:shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f">
<v:stroke joinstyle="miter"/>
<v:formulas>
<v:f eqn="if lineDrawn pixelLineWidth 0"/>
<v:f eqn="sum @0 1 0"/>
<v:f eqn="sum 0 0 @1"/>
<v:f eqn="prod @2 1 2"/>
<v:f eqn="prod @3 21600 pixelWidth"/>
<v:f eqn="prod @3 21600 pixelHeight"/>
<v:f eqn="sum @0 0 1"/>
<v:f eqn="prod @6 1 2"/>
<v:f eqn="prod @7 21600 pixelWidth"/>
<v:f eqn="sum @8 21600 0"/>
<v:f eqn="prod @7 21600 pixelHeight"/>
<v:f eqn="sum @10 21600 0"/>
</v:formulas>
<v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"/>
<o:lock v:ext="edit" aspectratio="t"/>
</v:shapetype>
<v:shape id="图片 6" o:spid="_x0000_s1027" type="#_x0000_t75" style="position:absolute;left:23391;width:23387;height:14941;visibility:visible;mso-wrap-style:square" o:gfxdata="UEsDBBQABgAIAAAAIQDb4fbL7gAAAIUBAAATAAAAW0NvbnRlbnRfVHlwZXNdLnhtbHyQz07DMAyH&#xD;&#xA;70i8Q+QralM4IITa7kDhCAiNB7ASt43WOlEcyvb2pNu4IODoPz9/n1xv9vOkForiPDdwXVagiI23&#xD;&#xA;jocG3rdPxR0oScgWJ8/UwIEENu3lRb09BBKV0ywNjCmFe63FjDSjlD4Q50nv44wpl3HQAc0OB9I3&#xD;&#xA;VXWrjedEnIq03oC27qjHjympx31un0wiTQLq4bS4shrAECZnMGVTvbD9QSnOhDInjzsyuiBXWQP0&#xD;&#xA;r4R18jfgnHvJr4nOknrFmJ5xzhraRtHWf3Kkpfz/yGo5S+H73hkquyhdjr3R8m2lj09svwAAAP//&#xD;&#xA;AwBQSwMEFAAGAAgAAAAhAFr0LFu/AAAAFQEAAAsAAABfcmVscy8ucmVsc2zPwWrDMAwG4Ptg72B0&#xD;&#xA;X5TuUMaI01uh19I+gLGVxCy2jGSy9e1nemrHjpL4P0nD4SetZiPRyNnCruvBUPYcYp4tXC/Htw8w&#xD;&#xA;Wl0ObuVMFm6kcBhfX4Yzra62kC6xqGlKVgtLreUTUf1CyWnHhXKbTCzJ1VbKjMX5LzcTvvf9HuXR&#xD;&#xA;gPHJNKdgQU5hB+ZyK23zHztFL6w81c5zQp6m6P9TMfB3PtPWFCczVQtB9N4U2rp2HOA44NMz4y8A&#xD;&#xA;AAD//wMAUEsDBBQABgAIAAAAIQDK/ILfyAAAAN8AAAAPAAAAZHJzL2Rvd25yZXYueG1sRI9Ba8JA&#xD;&#xA;FITvgv9heYXezKYegkZXaZVSLx7UFnp8zT6TtNm3aXY1q7++WxC8DAzDfMPMl8E04kydqy0reEpS&#xD;&#xA;EMSF1TWXCt4Pr6MJCOeRNTaWScGFHCwXw8Ecc2173tF570sRIexyVFB53+ZSuqIigy6xLXHMjrYz&#xD;&#xA;6KPtSqk77CPcNHKcppk0WHNcqLClVUXFz/5kFHxc377T7Oto/e7yErbhs/zdTHulHh/CehbleQbC&#xD;&#xA;U/D3xg2x0Qoy+P8Tv4Bc/AEAAP//AwBQSwECLQAUAAYACAAAACEA2+H2y+4AAACFAQAAEwAAAAAA&#xD;&#xA;AAAAAAAAAAAAAAAAW0NvbnRlbnRfVHlwZXNdLnhtbFBLAQItABQABgAIAAAAIQBa9CxbvwAAABUB&#xD;&#xA;AAALAAAAAAAAAAAAAAAAAB8BAABfcmVscy8ucmVsc1BLAQItABQABgAIAAAAIQDK/ILfyAAAAN8A&#xD;&#xA;AAAPAAAAAAAAAAAAAAAAAAcCAABkcnMvZG93bnJldi54bWxQSwUGAAAAAAMAAwC3AAAA/AIAAAAA&#xD;&#xA;">
<v:imagedata r:id="rId7" o:title=""/>
</v:shape>
<v:shape id="图片 5" o:spid="_x0000_s1028" type="#_x0000_t75" style="position:absolute;width:23387;height:14941;visibility:visible;mso-wrap-style:square" o:gfxdata="UEsDBBQABgAIAAAAIQDb4fbL7gAAAIUBAAATAAAAW0NvbnRlbnRfVHlwZXNdLnhtbHyQz07DMAyH&#xD;&#xA;70i8Q+QralM4IITa7kDhCAiNB7ASt43WOlEcyvb2pNu4IODoPz9/n1xv9vOkForiPDdwXVagiI23&#xD;&#xA;jocG3rdPxR0oScgWJ8/UwIEENu3lRb09BBKV0ywNjCmFe63FjDSjlD4Q50nv44wpl3HQAc0OB9I3&#xD;&#xA;VXWrjedEnIq03oC27qjHjympx31un0wiTQLq4bS4shrAECZnMGVTvbD9QSnOhDInjzsyuiBXWQP0&#xD;&#xA;r4R18jfgnHvJr4nOknrFmJ5xzhraRtHWf3Kkpfz/yGo5S+H73hkquyhdjr3R8m2lj09svwAAAP//&#xD;&#xA;AwBQSwMEFAAGAAgAAAAhAFr0LFu/AAAAFQEAAAsAAABfcmVscy8ucmVsc2zPwWrDMAwG4Ptg72B0&#xD;&#xA;X5TuUMaI01uh19I+gLGVxCy2jGSy9e1nemrHjpL4P0nD4SetZiPRyNnCruvBUPYcYp4tXC/Htw8w&#xD;&#xA;Wl0ObuVMFm6kcBhfX4Yzra62kC6xqGlKVgtLreUTUf1CyWnHhXKbTCzJ1VbKjMX5LzcTvvf9HuXR&#xD;&#xA;gPHJNKdgQU5hB+ZyK23zHztFL6w81c5zQp6m6P9TMfB3PtPWFCczVQtB9N4U2rp2HOA44NMz4y8A&#xD;&#xA;AAD//wMAUEsDBBQABgAIAAAAIQA6LhyoyAAAAN8AAAAPAAAAZHJzL2Rvd25yZXYueG1sRI9BawIx&#xD;&#xA;FITvgv8hPKE3zVqotKtRbEX00oO2BY/PzXN3dfOy3UQ39tc3guBlYBjmG2YyC6YSF2pcaVnBcJCA&#xD;&#xA;IM6sLjlX8P217L+CcB5ZY2WZFFzJwWza7Uww1bblDV22PhcRwi5FBYX3dSqlywoy6Aa2Jo7ZwTYG&#xD;&#xA;fbRNLnWDbYSbSj4nyUgaLDkuFFjTR0HZaXs2Cn7+VsdktD9Yv7m+h8+wy3/Xb61ST72wGEeZj0F4&#xD;&#xA;Cv7RuCPWWsEL3P7ELyCn/wAAAP//AwBQSwECLQAUAAYACAAAACEA2+H2y+4AAACFAQAAEwAAAAAA&#xD;&#xA;AAAAAAAAAAAAAAAAW0NvbnRlbnRfVHlwZXNdLnhtbFBLAQItABQABgAIAAAAIQBa9CxbvwAAABUB&#xD;&#xA;AAALAAAAAAAAAAAAAAAAAB8BAABfcmVscy8ucmVsc1BLAQItABQABgAIAAAAIQA6LhyoyAAAAN8A&#xD;&#xA;AAAPAAAAAAAAAAAAAAAAAAcCAABkcnMvZG93bnJldi54bWxQSwUGAAAAAAMAAwC3AAAA/AIAAAAA&#xD;&#xA;">
<v:imagedata r:id="rId7" o:title=""/>
</v:shape>
<w10:anchorlock/>
</v:group>
</w:pict>
</mc:Fallback>
</mc:AlternateContent>
</w:r>
</w:p>
<w:p w14:paraId="51243B69" w14:textId="039F28AD" w:rsidR="0056103D" w:rsidRDefault="00AF7765">
<w:r>
<w:rPr>
<w:rFonts w:hint="eastAsia"/>
</w:rPr>
<w:t>一个 浮于上方</w:t>
</w:r>
<w:r w:rsidR="009A179B">
<w:rPr>
<w:rFonts w:hint="eastAsia"/>
</w:rPr>
<w:t xml:space="preserve"> 右侧对齐</w:t>
</w:r>
<w:r w:rsidR="0079003D">
<w:rPr>
<w:rFonts w:hint="eastAsia"/>
</w:rPr>
<w:t xml:space="preserve"> 左</w:t>
</w:r>
<w:r w:rsidR="0079003D">
<w:t xml:space="preserve">11.32cm </w:t>
</w:r>
<w:r w:rsidR="0079003D">
<w:rPr>
<w:rFonts w:hint="eastAsia"/>
</w:rPr>
<w:t>顶</w:t>
</w:r>
<w:r w:rsidR="0079003D">
<w:t>23.73cm</w:t>
</w:r>
</w:p>
<w:p w14:paraId="7D425D3C" w14:textId="05800C1E" w:rsidR="00AF7765" w:rsidRDefault="0079003D">
<w:pPr>
<w:rPr>
<w:rFonts w:hint="eastAsia"/>
</w:rPr>
</w:pPr>
<w:r>
<w:rPr>
<w:noProof/>
</w:rPr>
<w:drawing>
<wp:anchor distT="0" distB="1" distL="2" distR="3" simplePos="0" relativeHeight="251658240" behindDoc="0" locked="0" layoutInCell="1" allowOverlap="1" wp14:anchorId="mock-anchor-px-cx" wp14:editId="mock-edit-px-cx">
<wp:simplePos x="0" y="0"/>
<wp:positionH relativeFrom="column">
<wp:posOffset>2935605</wp:posOffset>
</wp:positionH>
<wp:positionV relativeFrom="paragraph">
<wp:posOffset>97790</wp:posOffset>
</wp:positionV>
<wp:extent cx="2339163" cy="1494293"/>
<wp:effectExtent l="0" t="0" r="0" b="4445"/>
<wp:wrapNone/>
<wp:docPr id="8" name="图片 8"/>
<wp:cNvGraphicFramePr>
<a:graphicFrameLocks xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" noChangeAspect="1"/>
</wp:cNvGraphicFramePr>
<a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
<a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/picture">
<pic:pic xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture">
<pic:nvPicPr>
<pic:cNvPr id="1" name="图片 1"/>
<pic:cNvPicPr/>
</pic:nvPicPr>
<pic:blipFill>
<a:blip r:embed="rId6" cstate="print">
<a:extLst>
<a:ext uri="{28A0092B-C50C-407E-A947-70E740481C1C}">
<a14:useLocalDpi xmlns:a14="http://schemas.microsoft.com/office/drawing/2010/main" val="0"/>
</a:ext>
</a:extLst>
</a:blip>
<a:stretch>
<a:fillRect/>
</a:stretch>
</pic:blipFill>
<pic:spPr>
<a:xfrm>
<a:off x="0" y="0"/>
<a:ext cx="2339163" cy="1494293"/>
</a:xfrm>
<a:prstGeom prst="rect">
<a:avLst/>
</a:prstGeom>
</pic:spPr>
</pic:pic>
</a:graphicData>
</a:graphic>
<wp14:sizeRelH relativeFrom="page">
<wp14:pctWidth>0</wp14:pctWidth>
</wp14:sizeRelH>
<wp14:sizeRelV relativeFrom="page">
<wp14:pctHeight>0</wp14:pctHeight>
</wp14:sizeRelV>
</wp:anchor>
</w:drawing>
</w:r>
</w:p>
<w:sectPr w:rsidR="00AF7765">
<w:pgSz w:w="11906" w:h="16838"/>
<w:pgMar w:top="1440" w:right="1800" w:bottom="1440" w:left="1800" w:header="851" w:footer="992" w:gutter="0"/>
<w:cols w:space="425"/>
<w:docGrid w:type="lines" w:linePitch="312"/>
</w:sectPr>
</w:body>
</w:document>`
func TestUnmarshalDrawingStructure(t *testing.T) {
doc := Document{
XMLW: XMLNS_W,
XMLR: XMLNS_R,
XMLWP: XMLNS_WP,
// XMLWP14: XMLNS_WP14,
XMLName: xml.Name{Space: XMLNS_W, Local: "document"}}
err := xml.Unmarshal(StringToBytes(drawing_doc), &doc)
if err != nil {
t.Fatal(err)
}
if len(doc.Body.Paragraphs) != 8 {
t.Fatalf("We expected %d paragraphs, we got %d", 8, len(doc.Body.Paragraphs))
}
for i, p := range doc.Body.Paragraphs {
if len(p.Children) == 0 {
t.Fatalf("We were not able to parse paragraph %d", i)
}
for j, child := range p.Children {
if child.Link == nil && child.Properties == nil && child.Run == nil {
t.Fatalf("There are Paragraph children with all fields nil")
}
if child.Run != nil && child.Run.Text == nil && child.Run.InstrText == "" && child.Run.Drawing == nil {
t.Fatalf("We have a run with no text and drawing")
}
if child.Link != nil && child.Link.ID == "" {
t.Fatalf("We have a link without ID")
}
if child.Run != nil && child.Run.Drawing != nil {
t.Log("fild drawing at aragraph", i, ", child", j)
if child.Run.Drawing.Inline != nil {
if child.Run.Drawing.Inline.DistT != 0 || child.Run.Drawing.Inline.DistB != 1 || child.Run.Drawing.Inline.DistL != 2 || child.Run.Drawing.Inline.DistR != 3 {
t.Fatal("unexpected inline dist")
}
}
}
}
}
}
func TestInlineDrawingStructure(t *testing.T) {
w := NewA4()
// add new paragraph
@@ -563,6 +59,8 @@ func TestInlineDrawingStructure(t *testing.T) {
t.Fatal(err)
}
r.Drawing.Anchor.Graphic.GraphicData.Pic.BlipFill.Blip.AlphaModFix = &AAlphaModFix{Amount: 50000}
r.Drawing.Anchor.Graphic.GraphicData.Pic.NonVisualPicProperties.CNvPicPr.Locks = &APicLocks{NoChangeAspect: 1}
r.Drawing.Anchor.Graphic.GraphicData.Pic.SpPr.Xfrm.Rot = 50000
para2 := w.AddParagraph().Justification("center")
para2.AddInlineDrawingFrom("testdata/fumiama.JPG")
para2.AddTab().AddTab().AppendTab().AppendTab()