埋め込みには、バイナリファイルなどをオブジェクトとして埋め込むものと、Office文書(パッケージ)の埋め込みがあります。外部参照も指定できますが、パッケージに含める場合、いずれも物理的なファイルはembeddingsフォルダ内に格納します。
埋め込まれたファイルの扱いはアプリケーションに任されます。埋め込まれたそれぞれのオブジェクトまたはパッケージは、メイン文書上では関連イメージ画像が代わりに表示できる必要があります。
線画、SmartArtなど
OOXMLでは、WordprocessingML文書での線画やクリップアート、スマートアートなどは、DrawingMLおよびVMLという2種類の描画のためのXML仕様を使って、直接document.xmlに記述されます。
Word 2019で図形(四角)を挿入した場合
<w:document xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
<w:body>
<w:p>
<w:r>
<w:pict>
<v:rect id="_x0000_s1026" style="position:absolute;margin-left:14.15pt;margin-top:25.55pt;width:248.8pt;height:77.6pt;z-index:251658240">
<v:textbox inset="5.85pt,.7pt,5.85pt,.7pt"/>
</v:rect>
</w:pict>
</w:r>
...
</w:p>
...
</w:body>
<w:document>
この場合、画像データとしてのpict要素の子要素としてVMLのrect要素を使って四角形が定義されています。pict要素はVMLオブジェクトを定義するための親要素です。
スマートアートを挿入した場合
<w:document xmlns:v="urn:schemas-microsoft-com:vml" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:w="...">
<w:body>
(省略)
<w:drawing>
<wp:inline distT="0" distB="0" distL="0" distR="0">
<wp:extent cx="5400040" cy="3150235"/>
<wp:effectExtent l="38100" t="0" r="10160" b="0"/>
<wp:docPr id="1" name="図表 1"/>
<wp:cNvGraphicFramePr/>
<a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
<a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/diagram">
<dgm:relIds
xmlns:dgm="http://schemas.openxmlformats.org/drawingml/2006/diagram"
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
r:dm="rId4" r:lo="rId5" r:qs="rId6" r:cs="rId7"/>
</a:graphicData>
</a:graphic>
</wp:inline>
</w:drawing>
<w:body>
<w:p>
<w:r>
<w:pict>
<v:rect id="_x0000_s1026" style="position:absolute;margin-left:14.15pt;
margin-top:25.55pt;width:248.8pt;height:77.6pt;z-index:251658240">
<v:textbox inset="5.85pt,.7pt,5.85pt,.7pt"/>
</v:rect>
</w:pict>
</w:r>
このスマートアートは、DrawingMLを使って画像が定義されています。WordprocessingMLで定義されているdrawing要素はDrawingMLオブジェクトを定義するための親要素です。
Excel表の埋め込み
Wordでは文書にExcelファイル(SpreadsheetML文書)を埋め込んでExcelと同じ作業を行うことができます。この場合、Excelのデータは埋め込みデータとしてExcelファイルそのものがWordprocessingML文書パッケージ内に保存されます。
WordへのExcel表の埋め込み
このように、Word文書にExcelワークシートを挿入して、Excelと同じ操作を行うことが可能です。
埋め込まれたExcelオブジェクトのために、wordフォルダ下にembeddingsフォルダが作成されています。word/embeddingsフォルダの内容は、次のようになっています。
この文書のメイン文書パーツではVMLでの表の描画とExcelオブジェクトの定義がされています。
Excelファイルを埋め込んだメイン文書パーツ(document.xml)
<w:document xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
> <w:body> (省略) <w:r> <w:object w:dxaOrig="7117"
w:dyaOrig="2468"> <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:formulas>
<v:path o:extrusionok="f" gradientshapeok="t"
o:connecttype="rect"/>
<o:lock v:ext="edit" aspectratio="t"/>
</v:shapetype>
<v:shape id="_x0000_i1025" type="#_x0000_t75"
style="width:356pt;height:123.2pt" o:ole=""> <v:imagedata
r:id="rId5" o:title=""/> </v:shape> <o:OLEObject
Type="Embed" ProgID="Excel.Sheet.12" ShapeID="_x0000_i1025"
DrawAspect="Content" ObjectID="_1243112331" r:id="rId6"/>
</w:object>
</w:r>
...
</w:body>
</w:document>
埋め込まれたオブジェクトはobject要素によって表されます。さらに、object要素内でVML(vの名前空間指定子)の要素によって表がシェイプとして描画されています。shapetype要素はシェイプの種別や塗りつぶしなどを定義します。shape要素でシェイプのサイズなどのスタイルを定義しています。
この例では省略しましたが、v:formula要素の中でExcelで使われる関数(数式)が定義されています。
Excelオブジェクトへの参照は、object要素内に参照idが定義されています。
object要素内のExcelオブジェクトへの参照id
<o:OLEObject Type="Embed" ProgID="Excel.Sheet.12" ShapeID="_x0000_i1025"
DrawAspect="Content" ObjectID="_1243112331" r:id="rId6"/>
このとき、メイン文書パーツの関連付けファイルには次のようにExcelファイルのURIが追記されています。
関連付けファイルでSpreadsheetMLパッケージURIの追記
<Relationship Id="rId6"
Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"
Target="embeddings/Microsoft_Office_Excel_______1.xlsx"/>