|
7 | 7 | from pptx.dml.color import ColorFormat |
8 | 8 | from pptx.dml.fill import FillFormat |
9 | 9 | from pptx.dml.line import LineFormat |
10 | | -from pptx.enum.dml import MSO_FILL, MSO_LINE, MSO_LINE_END_SIZE, MSO_LINE_END_TYPE |
| 10 | +from pptx.enum.dml import ( |
| 11 | + MSO_FILL, |
| 12 | + MSO_LINE, |
| 13 | + MSO_LINE_CAP_STYLE, |
| 14 | + MSO_LINE_END_SIZE, |
| 15 | + MSO_LINE_END_TYPE, |
| 16 | + MSO_LINE_JOIN_STYLE, |
| 17 | +) |
11 | 18 | from pptx.oxml.shapes.shared import CT_LineProperties |
12 | 19 | from pptx.shapes.autoshape import Shape |
13 | 20 |
|
@@ -172,6 +179,69 @@ def it_can_change_its_end_arrowhead_length( |
172 | 179 | LineFormat(spPr).end_arrowhead_length = value |
173 | 180 | assert spPr.xml == xml(expected_cxml) |
174 | 181 |
|
| 182 | + @pytest.mark.parametrize( |
| 183 | + ("spPr_cxml", "expected_value"), |
| 184 | + [ |
| 185 | + ("p:spPr", None), |
| 186 | + ("p:spPr/a:ln", None), |
| 187 | + ("p:spPr/a:ln{cap=rnd}", MSO_LINE_CAP_STYLE.ROUND), |
| 188 | + ("p:spPr/a:ln{cap=sq}", MSO_LINE_CAP_STYLE.SQUARE), |
| 189 | + ("p:spPr/a:ln{cap=flat}", MSO_LINE_CAP_STYLE.FLAT), |
| 190 | + ], |
| 191 | + ) |
| 192 | + def it_knows_its_cap_style( |
| 193 | + self, spPr_cxml: str, expected_value: MSO_LINE_CAP_STYLE | None |
| 194 | + ): |
| 195 | + line = LineFormat(element(spPr_cxml)) |
| 196 | + assert line.cap_style == expected_value |
| 197 | + |
| 198 | + @pytest.mark.parametrize( |
| 199 | + ("spPr_cxml", "value", "expected_cxml"), |
| 200 | + [ |
| 201 | + ("p:spPr{a:b=c}", MSO_LINE_CAP_STYLE.ROUND, "p:spPr{a:b=c}/a:ln{cap=rnd}"), |
| 202 | + ("p:spPr/a:ln{cap=rnd}", MSO_LINE_CAP_STYLE.SQUARE, "p:spPr/a:ln{cap=sq}"), |
| 203 | + ("p:spPr/a:ln{cap=sq}", None, "p:spPr/a:ln"), |
| 204 | + ], |
| 205 | + ) |
| 206 | + def it_can_change_its_cap_style( |
| 207 | + self, spPr_cxml: str, value: MSO_LINE_CAP_STYLE | None, expected_cxml: str |
| 208 | + ): |
| 209 | + spPr = element(spPr_cxml) |
| 210 | + LineFormat(spPr).cap_style = value |
| 211 | + assert spPr.xml == xml(expected_cxml) |
| 212 | + |
| 213 | + @pytest.mark.parametrize( |
| 214 | + ("spPr_cxml", "expected_value"), |
| 215 | + [ |
| 216 | + ("p:spPr", None), |
| 217 | + ("p:spPr/a:ln", None), |
| 218 | + ("p:spPr/a:ln/a:round", MSO_LINE_JOIN_STYLE.ROUND), |
| 219 | + ("p:spPr/a:ln/a:bevel", MSO_LINE_JOIN_STYLE.BEVEL), |
| 220 | + ("p:spPr/a:ln/a:miter", MSO_LINE_JOIN_STYLE.MITER), |
| 221 | + ], |
| 222 | + ) |
| 223 | + def it_knows_its_join_style( |
| 224 | + self, spPr_cxml: str, expected_value: MSO_LINE_JOIN_STYLE | None |
| 225 | + ): |
| 226 | + line = LineFormat(element(spPr_cxml)) |
| 227 | + assert line.join_style == expected_value |
| 228 | + |
| 229 | + @pytest.mark.parametrize( |
| 230 | + ("spPr_cxml", "value", "expected_cxml"), |
| 231 | + [ |
| 232 | + ("p:spPr{a:b=c}", MSO_LINE_JOIN_STYLE.ROUND, "p:spPr{a:b=c}/a:ln/a:round"), |
| 233 | + ("p:spPr/a:ln", MSO_LINE_JOIN_STYLE.BEVEL, "p:spPr/a:ln/a:bevel"), |
| 234 | + ("p:spPr/a:ln/a:round", MSO_LINE_JOIN_STYLE.MITER, "p:spPr/a:ln/a:miter"), |
| 235 | + ("p:spPr/a:ln/a:miter", None, "p:spPr/a:ln"), |
| 236 | + ], |
| 237 | + ) |
| 238 | + def it_can_change_its_join_style( |
| 239 | + self, spPr_cxml: str, value: MSO_LINE_JOIN_STYLE | None, expected_cxml: str |
| 240 | + ): |
| 241 | + spPr = element(spPr_cxml) |
| 242 | + LineFormat(spPr).join_style = value |
| 243 | + assert spPr.xml == xml(expected_cxml) |
| 244 | + |
175 | 245 | def it_knows_its_dash_style(self, dash_style_get_fixture): |
176 | 246 | line, expected_value = dash_style_get_fixture |
177 | 247 | assert line.dash_style == expected_value |
|
0 commit comments