` ` element, container for an inline shape.
| 66 | |
| 67 | |
| 68 | class CT_Inline(BaseOxmlElement): |
| 69 | """`<wp:inline>` element, container for an inline shape.""" |
| 70 | |
| 71 | extent: CT_PositiveSize2D = OneAndOnlyOne("wp:extent") # pyright: ignore[reportAssignmentType] |
| 72 | docPr: CT_NonVisualDrawingProps = OneAndOnlyOne( # pyright: ignore[reportAssignmentType] |
| 73 | "wp:docPr" |
| 74 | ) |
| 75 | graphic: CT_GraphicalObject = OneAndOnlyOne( # pyright: ignore[reportAssignmentType] |
| 76 | "a:graphic" |
| 77 | ) |
| 78 | |
| 79 | @classmethod |
| 80 | def new(cls, cx: Length, cy: Length, shape_id: int, pic: CT_Picture) -> CT_Inline: |
| 81 | """Return a new ``<wp:inline>`` element populated with the values passed as |
| 82 | parameters.""" |
| 83 | inline = cast(CT_Inline, parse_xml(cls._inline_xml())) |
| 84 | inline.extent.cx = cx |
| 85 | inline.extent.cy = cy |
| 86 | inline.docPr.id = shape_id |
| 87 | inline.docPr.name = "Picture %d" % shape_id |
| 88 | inline.graphic.graphicData.uri = "http://schemas.openxmlformats.org/drawingml/2006/picture" |
| 89 | inline.graphic.graphicData._insert_pic(pic) |
| 90 | return inline |
| 91 | |
| 92 | @classmethod |
| 93 | def new_pic_inline( |
| 94 | cls, shape_id: int, rId: str, filename: str, cx: Length, cy: Length |
| 95 | ) -> CT_Inline: |
| 96 | """Create `wp:inline` element containing a `pic:pic` element. |
| 97 | |
| 98 | The contents of the `pic:pic` element is taken from the argument values. |
| 99 | """ |
| 100 | pic_id = 0 # Word doesn't seem to use this, but does not omit it |
| 101 | pic = CT_Picture.new(pic_id, filename, rId, cx, cy) |
| 102 | inline = cls.new(cx, cy, shape_id, pic) |
| 103 | return inline |
| 104 | |
| 105 | @classmethod |
| 106 | def _inline_xml(cls): |
| 107 | return ( |
| 108 | "<wp:inline %s>\n" |
| 109 | ' <wp:extent cx="914400" cy="914400"/>\n' |
| 110 | ' <wp:docPr id="666" name="unnamed"/>\n' |
| 111 | " <wp:cNvGraphicFramePr>\n" |
| 112 | ' <a:graphicFrameLocks noChangeAspect="1"/>\n' |
| 113 | " </wp:cNvGraphicFramePr>\n" |
| 114 | " <a:graphic>\n" |
| 115 | ' <a:graphicData uri="URI not set"/>\n' |
| 116 | " </a:graphic>\n" |
| 117 | "</wp:inline>" % nsdecls("wp", "a", "pic", "r") |
| 118 | ) |
| 119 | |
| 120 | |
| 121 | class CT_NonVisualDrawingProps(BaseOxmlElement): |
nothing calls this directly
no test coverage detected
searching dependent graphs…