|
4 | 4 | Document parts such as _Document, and closely related classes. |
5 | 5 | """ |
6 | 6 |
|
7 | | -from docx.enum.shape import WD_INLINE_SHAPE |
8 | | -from docx.opc.constants import RELATIONSHIP_TYPE as RT |
9 | | -from docx.opc.oxml import serialize_part_xml |
10 | | -from docx.opc.package import Part |
11 | | -from docx.oxml.shape import CT_Inline, CT_Picture |
12 | | -from docx.oxml.shared import nsmap, oxml_fromstring |
13 | | -from docx.shared import lazyproperty, Parented |
14 | | -from docx.table import Table |
15 | | -from docx.text import Paragraph |
| 7 | +from __future__ import ( |
| 8 | + absolute_import, division, print_function, unicode_literals |
| 9 | +) |
| 10 | + |
| 11 | +from ..opc.constants import RELATIONSHIP_TYPE as RT |
| 12 | +from ..opc.oxml import serialize_part_xml |
| 13 | +from ..opc.package import Part |
| 14 | +from ..oxml.shared import nsmap, oxml_fromstring |
| 15 | +from ..shape import InlineShape |
| 16 | +from ..shared import lazyproperty, Parented |
| 17 | +from ..table import Table |
| 18 | +from ..text import Paragraph |
16 | 19 |
|
17 | 20 |
|
18 | 21 | class DocumentPart(Part): |
@@ -137,47 +140,6 @@ def tables(self): |
137 | 140 | return [Table(tbl) for tbl in self._body.tbl_lst] |
138 | 141 |
|
139 | 142 |
|
140 | | -class InlineShape(object): |
141 | | - """ |
142 | | - Proxy for an ``<wp:inline>`` element, representing the container for an |
143 | | - inline graphical object. |
144 | | - """ |
145 | | - def __init__(self, inline): |
146 | | - super(InlineShape, self).__init__() |
147 | | - self._inline = inline |
148 | | - |
149 | | - @classmethod |
150 | | - def new_picture(cls, r, image_part, rId, shape_id): |
151 | | - """ |
152 | | - Return a new |InlineShape| instance containing an inline picture |
153 | | - placement of *image_part* appended to run *r* and uniquely identified |
154 | | - by *shape_id*. |
155 | | - """ |
156 | | - cx, cy, filename = ( |
157 | | - image_part.default_cx, image_part.default_cy, image_part.filename |
158 | | - ) |
159 | | - pic_id = 0 |
160 | | - pic = CT_Picture.new(pic_id, filename, rId, cx, cy) |
161 | | - inline = CT_Inline.new(cx, cy, shape_id, pic) |
162 | | - r.add_drawing(inline) |
163 | | - return cls(inline) |
164 | | - |
165 | | - @property |
166 | | - def type(self): |
167 | | - graphicData = self._inline.graphic.graphicData |
168 | | - uri = graphicData.uri |
169 | | - if uri == nsmap['pic']: |
170 | | - blip = graphicData.pic.blipFill.blip |
171 | | - if blip.link is not None: |
172 | | - return WD_INLINE_SHAPE.LINKED_PICTURE |
173 | | - return WD_INLINE_SHAPE.PICTURE |
174 | | - if uri == nsmap['c']: |
175 | | - return WD_INLINE_SHAPE.CHART |
176 | | - if uri == nsmap['dgm']: |
177 | | - return WD_INLINE_SHAPE.SMART_ART |
178 | | - return WD_INLINE_SHAPE.NOT_IMPLEMENTED |
179 | | - |
180 | | - |
181 | 143 | class InlineShapes(Parented): |
182 | 144 | """ |
183 | 145 | Sequence of |InlineShape| instances, supporting len(), iteration, and |
|
0 commit comments