Skip to content

Commit 3180a99

Browse files
author
Steve Canny
committed
oxml: convert CT_Blip to xmlchemy
1 parent 82c080b commit 3180a99

3 files changed

Lines changed: 30 additions & 30 deletions

File tree

docs/dev/analysis/features/picture.rst

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,7 @@ Schema definitions
114114
</xsd:sequence>
115115
</xsd:complexType>
116116

117-
<xsd:attributeGroup name="AG_Blob">
118-
<xsd:attribute ref="r:embed" use="optional" default=""/>
119-
<xsd:attribute ref="r:link" use="optional" default=""/>
120-
</xsd:attributeGroup>
121-
122-
<xsd:complexType name="CT_Blip">
117+
<xsd:complexType name="CT_Blip"> <!-- denormalized -->
123118
<xsd:sequence>
124119
<xsd:choice minOccurs="0" maxOccurs="unbounded">
125120
<xsd:element name="alphaBiLevel" type="CT_AlphaBiLevelEffect"/>
@@ -142,18 +137,23 @@ Schema definitions
142137
</xsd:choice>
143138
<xsd:element name="extLst" type="CT_OfficeArtExtensionList" minOccurs="0"/>
144139
</xsd:sequence>
145-
<xsd:attributeGroup ref="AG_Blob"/>
146-
<xsd:attribute name="cstate" type="ST_BlipCompression" use="optional" default="none"/>
140+
<xsd:attribute ref="r:embed" type="ST_RelationshipId" default=""/>
141+
<xsd:attribute ref="r:link" type="ST_RelationshipId" default=""/>
142+
<xsd:attribute name="cstate" type="ST_BlipCompression" default="none"/>
147143
</xsd:complexType>
148144

145+
<xsd:simpleType name="ST_RelationshipId">
146+
<xsd:restriction base="xsd:string"/>
147+
</xsd:simpleType>
148+
149149
<xsd:complexType name="CT_BlipFillProperties">
150150
<xsd:sequence>
151151
<xsd:element name="blip" type="CT_Blip" minOccurs="0"/>
152152
<xsd:element name="srcRect" type="CT_RelativeRect" minOccurs="0"/>
153153
<xsd:group ref="EG_FillModeProperties" minOccurs="0"/>
154154
</xsd:sequence>
155-
<xsd:attribute name="dpi" type="xsd:unsignedInt" use="optional"/>
156-
<xsd:attribute name="rotWithShape" type="xsd:boolean" use="optional"/>
155+
<xsd:attribute name="dpi" type="xsd:unsignedInt"/>
156+
<xsd:attribute name="rotWithShape" type="xsd:boolean"/>
157157
</xsd:complexType>
158158

159159
<xsd:complexType name="CT_NonVisualDrawingProps">
@@ -164,17 +164,17 @@ Schema definitions
164164
</xsd:sequence>
165165
<xsd:attribute name="id" type="ST_DrawingElementId" use="required"/>
166166
<xsd:attribute name="name" type="xsd:string" use="required"/>
167-
<xsd:attribute name="descr" type="xsd:string" use="optional" default=""/>
168-
<xsd:attribute name="hidden" type="xsd:boolean" use="optional" default="false"/>
169-
<xsd:attribute name="title" type="xsd:string" use="optional" default=""/>
167+
<xsd:attribute name="descr" type="xsd:string" default=""/>
168+
<xsd:attribute name="hidden" type="xsd:boolean" default="false"/>
169+
<xsd:attribute name="title" type="xsd:string" default=""/>
170170
</xsd:complexType>
171171

172172
<xsd:complexType name="CT_NonVisualPictureProperties">
173173
<xsd:sequence>
174174
<xsd:element name="picLocks" type="CT_PictureLocking" minOccurs="0"/>
175175
<xsd:element name="extLst" type="CT_OfficeArtExtensionList" minOccurs="0"/>
176176
</xsd:sequence>
177-
<xsd:attribute name="preferRelativeResize" type="xsd:boolean" use="optional" default="true"/>
177+
<xsd:attribute name="preferRelativeResize" type="xsd:boolean" default="true"/>
178178
</xsd:complexType>
179179

180180
<xsd:complexType name="CT_PictureNonVisual">
@@ -202,10 +202,10 @@ Schema definitions
202202
</xsd:complexType>
203203

204204
<xsd:complexType name="CT_RelativeRect">
205-
<xsd:attribute name="l" type="ST_Percentage" use="optional" default="0%"/>
206-
<xsd:attribute name="t" type="ST_Percentage" use="optional" default="0%"/>
207-
<xsd:attribute name="r" type="ST_Percentage" use="optional" default="0%"/>
208-
<xsd:attribute name="b" type="ST_Percentage" use="optional" default="0%"/>
205+
<xsd:attribute name="l" type="ST_Percentage" default="0%"/>
206+
<xsd:attribute name="t" type="ST_Percentage" default="0%"/>
207+
<xsd:attribute name="r" type="ST_Percentage" default="0%"/>
208+
<xsd:attribute name="b" type="ST_Percentage" default="0%"/>
209209
</xsd:complexType>
210210

211211
<xsd:complexType name="CT_ShapeProperties">
@@ -219,7 +219,7 @@ Schema definitions
219219
<xsd:element name="sp3d" type="CT_Shape3D" minOccurs="0"/>
220220
<xsd:element name="extLst" type="CT_OfficeArtExtensionList" minOccurs="0"/>
221221
</xsd:sequence>
222-
<xsd:attribute name="bwMode" type="ST_BlackWhiteMode" use="optional"/>
222+
<xsd:attribute name="bwMode" type="ST_BlackWhiteMode"/>
223223
</xsd:complexType>
224224

225225
<xsd:complexType name="CT_StretchInfoProperties">
@@ -233,9 +233,9 @@ Schema definitions
233233
<xsd:element name="off" type="CT_Point2D" minOccurs="0"/>
234234
<xsd:element name="ext" type="CT_PositiveSize2D" minOccurs="0"/>
235235
</xsd:sequence>
236-
<xsd:attribute name="rot" type="ST_Angle" use="optional" default="0"/>
237-
<xsd:attribute name="flipH" type="xsd:boolean" use="optional" default="false"/>
238-
<xsd:attribute name="flipV" type="xsd:boolean" use="optional" default="false"/>
236+
<xsd:attribute name="rot" type="ST_Angle" default="0"/>
237+
<xsd:attribute name="flipH" type="xsd:boolean" default="false"/>
238+
<xsd:attribute name="flipV" type="xsd:boolean" default="false"/>
239239
</xsd:complexType>
240240

241241
<xsd:group name="EG_FillModeProperties">

docx/oxml/shape.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,17 @@
77
from . import OxmlElement
88
from ..shared import Emu
99
from .ns import nsmap, nspfxmap, qn
10-
from .xmlchemy import BaseOxmlElement
10+
from .simpletypes import ST_RelationshipId
11+
from .xmlchemy import BaseOxmlElement, OptionalAttribute
1112

1213

1314
class CT_Blip(BaseOxmlElement):
1415
"""
1516
``<a:blip>`` element, specifies image source and adjustments such as
1617
alpha and tint.
1718
"""
18-
@property
19-
def embed(self):
20-
return self.get(qn('r:embed'))
21-
22-
@property
23-
def link(self):
24-
return self.get(qn('r:link'))
19+
embed = OptionalAttribute('r:embed', ST_RelationshipId)
20+
link = OptionalAttribute('r:link', ST_RelationshipId)
2521

2622
@classmethod
2723
def new(cls, rId):

docx/oxml/simpletypes.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,3 +153,7 @@ def validate(cls, value):
153153

154154
class ST_DecimalNumber(XsdInt):
155155
pass
156+
157+
158+
class ST_RelationshipId(XsdString):
159+
pass

0 commit comments

Comments
 (0)