|
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 |
| 10 | +from pptx.enum.dml import MSO_FILL, MSO_LINE, MSO_LINE_CAP_STYLE, MSO_LINE_JOIN_STYLE |
11 | 11 | from pptx.oxml.shapes.shared import CT_LineProperties |
12 | 12 | from pptx.shapes.autoshape import Shape |
13 | 13 |
|
|
17 | 17 |
|
18 | 18 |
|
19 | 19 | class DescribeLineFormat(object): |
| 20 | + @pytest.mark.parametrize( |
| 21 | + ("spPr_cxml", "expected_value"), |
| 22 | + [ |
| 23 | + ("p:spPr", None), |
| 24 | + ("p:spPr/a:ln", None), |
| 25 | + ("p:spPr/a:ln{cap=rnd}", MSO_LINE_CAP_STYLE.ROUND), |
| 26 | + ("p:spPr/a:ln{cap=sq}", MSO_LINE_CAP_STYLE.SQUARE), |
| 27 | + ("p:spPr/a:ln{cap=flat}", MSO_LINE_CAP_STYLE.FLAT), |
| 28 | + ], |
| 29 | + ) |
| 30 | + def it_knows_its_cap_style( |
| 31 | + self, spPr_cxml: str, expected_value: MSO_LINE_CAP_STYLE | None |
| 32 | + ): |
| 33 | + line = LineFormat(element(spPr_cxml)) |
| 34 | + assert line.cap_style == expected_value |
| 35 | + |
| 36 | + @pytest.mark.parametrize( |
| 37 | + ("spPr_cxml", "value", "expected_cxml"), |
| 38 | + [ |
| 39 | + ("p:spPr{a:b=c}", MSO_LINE_CAP_STYLE.ROUND, "p:spPr{a:b=c}/a:ln{cap=rnd}"), |
| 40 | + ("p:spPr/a:ln{cap=rnd}", MSO_LINE_CAP_STYLE.SQUARE, "p:spPr/a:ln{cap=sq}"), |
| 41 | + ("p:spPr/a:ln{cap=sq}", None, "p:spPr/a:ln"), |
| 42 | + ], |
| 43 | + ) |
| 44 | + def it_can_change_its_cap_style( |
| 45 | + self, spPr_cxml: str, value: MSO_LINE_CAP_STYLE | None, expected_cxml: str |
| 46 | + ): |
| 47 | + spPr = element(spPr_cxml) |
| 48 | + LineFormat(spPr).cap_style = value |
| 49 | + assert spPr.xml == xml(expected_cxml) |
| 50 | + |
| 51 | + @pytest.mark.parametrize( |
| 52 | + ("spPr_cxml", "expected_value"), |
| 53 | + [ |
| 54 | + ("p:spPr", None), |
| 55 | + ("p:spPr/a:ln", None), |
| 56 | + ("p:spPr/a:ln/a:round", MSO_LINE_JOIN_STYLE.ROUND), |
| 57 | + ("p:spPr/a:ln/a:bevel", MSO_LINE_JOIN_STYLE.BEVEL), |
| 58 | + ("p:spPr/a:ln/a:miter", MSO_LINE_JOIN_STYLE.MITER), |
| 59 | + ], |
| 60 | + ) |
| 61 | + def it_knows_its_join_style( |
| 62 | + self, spPr_cxml: str, expected_value: MSO_LINE_JOIN_STYLE | None |
| 63 | + ): |
| 64 | + line = LineFormat(element(spPr_cxml)) |
| 65 | + assert line.join_style == expected_value |
| 66 | + |
| 67 | + @pytest.mark.parametrize( |
| 68 | + ("spPr_cxml", "value", "expected_cxml"), |
| 69 | + [ |
| 70 | + ("p:spPr{a:b=c}", MSO_LINE_JOIN_STYLE.ROUND, "p:spPr{a:b=c}/a:ln/a:round"), |
| 71 | + ("p:spPr/a:ln", MSO_LINE_JOIN_STYLE.BEVEL, "p:spPr/a:ln/a:bevel"), |
| 72 | + ("p:spPr/a:ln/a:round", MSO_LINE_JOIN_STYLE.MITER, "p:spPr/a:ln/a:miter"), |
| 73 | + ("p:spPr/a:ln/a:miter", None, "p:spPr/a:ln"), |
| 74 | + ], |
| 75 | + ) |
| 76 | + def it_can_change_its_join_style( |
| 77 | + self, spPr_cxml: str, value: MSO_LINE_JOIN_STYLE | None, expected_cxml: str |
| 78 | + ): |
| 79 | + spPr = element(spPr_cxml) |
| 80 | + LineFormat(spPr).join_style = value |
| 81 | + assert spPr.xml == xml(expected_cxml) |
| 82 | + |
20 | 83 | def it_knows_its_dash_style(self, dash_style_get_fixture): |
21 | 84 | line, expected_value = dash_style_get_fixture |
22 | 85 | assert line.dash_style == expected_value |
|
0 commit comments