Skip to content

Commit d0a5c6f

Browse files
committed
acpt: add scenarios for patterned fill
1 parent 159cece commit d0a5c6f

5 files changed

Lines changed: 468 additions & 5 deletions

File tree

‎docs/api/enum/MsoPatternType.rst‎

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
.. _MsoPatternType:
2+
3+
``MSO_PATTERN_TYPE``
4+
====================
5+
6+
Specifies the fill pattern used in a shape.
7+
8+
Alias: ``MSO_PATTERN``
9+
10+
Example::
11+
12+
from pptx.enum.dml import MSO_PATTERN
13+
14+
fill = shape.fill
15+
fill.patterned()
16+
fill.pattern == MSO_PATTERN.WAVE
17+
18+
----
19+
20+
CROSS
21+
Cross
22+
23+
DARK_DOWNWARD_DIAGONAL
24+
Dark Downward Diagonal
25+
26+
DARK_HORIZONTAL
27+
Dark Horizontal
28+
29+
DARK_UPWARD_DIAGONAL
30+
Dark Upward Diagonal
31+
32+
DARK_VERTICAL
33+
Dark Vertical
34+
35+
DASHED_DOWNWARD_DIAGONAL
36+
Dashed Downward Diagonal
37+
38+
DASHED_HORIZONTAL
39+
Dashed Horizontal
40+
41+
DASHED_UPWARD_DIAGONAL
42+
Dashed Upward Diagonal
43+
44+
DASHED_VERTICAL
45+
Dashed Vertical
46+
47+
DIAGONAL_BRICK
48+
Diagonal Brick
49+
50+
DIAGONAL_CROSS
51+
Diagonal Cross
52+
53+
DIVOT
54+
Pattern Divot
55+
56+
DOTTED_DIAMOND
57+
Dotted Diamond
58+
59+
DOTTED_GRID
60+
Dotted Grid
61+
62+
DOWNWARD_DIAGONAL
63+
Downward Diagonal
64+
65+
HORIZONTAL
66+
Horizontal
67+
68+
HORIZONTAL_BRICK
69+
Horizontal Brick
70+
71+
LARGE_CHECKER_BOARD
72+
Large Checker Board
73+
74+
LARGE_CONFETTI
75+
Large Confetti
76+
77+
LARGE_GRID
78+
Large Grid
79+
80+
LIGHT_DOWNWARD_DIAGONAL
81+
Light Downward Diagonal
82+
83+
LIGHT_HORIZONTAL
84+
Light Horizontal
85+
86+
LIGHT_UPWARD_DIAGONAL
87+
Light Upward Diagonal
88+
89+
LIGHT_VERTICAL
90+
Light Vertical
91+
92+
NARROW_HORIZONTAL
93+
Narrow Horizontal
94+
95+
NARROW_VERTICAL
96+
Narrow Vertical
97+
98+
OUTLINED_DIAMOND
99+
Outlined Diamond
100+
101+
PERCENT_10
102+
10% of the foreground color.
103+
104+
PERCENT_20
105+
20% of the foreground color.
106+
107+
PERCENT_25
108+
25% of the foreground color.
109+
110+
PERCENT_30
111+
30% of the foreground color.
112+
113+
PERCENT_40
114+
40% of the foreground color.
115+
116+
PERCENT_5
117+
5% of the foreground color.
118+
119+
PERCENT_50
120+
50% of the foreground color.
121+
122+
PERCENT_60
123+
60% of the foreground color.
124+
125+
PERCENT_70
126+
70% of the foreground color.
127+
128+
PERCENT_75
129+
75% of the foreground color.
130+
131+
PERCENT_80
132+
80% of the foreground color.
133+
134+
PERCENT_90
135+
90% of the foreground color.
136+
137+
PLAID
138+
Plaid
139+
140+
SHINGLE
141+
Shingle
142+
143+
SMALL_CHECKER_BOARD
144+
Small Checker Board
145+
146+
SMALL_CONFETTI
147+
Small Confetti
148+
149+
SMALL_GRID
150+
Small Grid
151+
152+
SOLID_DIAMOND
153+
Solid Diamond
154+
155+
SPHERE
156+
Sphere
157+
158+
TRELLIS
159+
Trellis
160+
161+
UPWARD_DIAGONAL
162+
Upward Diagonal
163+
164+
VERTICAL
165+
Vertical
166+
167+
WAVE
168+
Wave
169+
170+
WEAVE
171+
Weave
172+
173+
WIDE_DOWNWARD_DIAGONAL
174+
Wide Downward Diagonal
175+
176+
WIDE_UPWARD_DIAGONAL
177+
Wide Upward Diagonal
178+
179+
ZIG_ZAG
180+
Zig Zag
181+
182+
MIXED
183+
Mixed pattern.

‎docs/api/enum/index.rst‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ can be found here:
1414
MsoConnectorType
1515
MsoFillType
1616
MsoLanguageId
17+
MsoPatternType
1718
MsoShapeType
1819
MsoTextUnderlineType
1920
MsoThemeColorIndex

‎features/dml-fill.feature‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Feature: Control fill
44
I need properties and methods on FillFormat
55

66

7+
@wip
78
Scenario Outline: FillFormat type setters
89
Given a FillFormat object as fill
910
When I call fill.<type-setter>()
@@ -12,14 +13,44 @@ Feature: Control fill
1213
Examples: Fill types
1314
| type-setter | type-name |
1415
| background | BACKGROUND |
16+
| patterned | PATTERNED |
1517
| solid | SOLID |
1618

1719

20+
@wip
21+
Scenario: FillFormat.back_color
22+
Given a FillFormat object as fill
23+
When I call fill.patterned()
24+
Then fill.back_color is a ColorFormat object
25+
26+
27+
@wip
1828
Scenario Outline: FillFormat.fore_color
1929
Given a FillFormat object as fill
2030
When I call fill.<type-setter>()
2131
Then fill.fore_color is a ColorFormat object
2232

2333
Examples: Fill types
2434
| type-setter |
35+
| patterned |
2536
| solid |
37+
38+
39+
@wip
40+
Scenario Outline: FillFormat.pattern getter
41+
Given a FillFormat object as fill having <pattern> fill
42+
Then fill.pattern is <value>
43+
44+
Examples: Pattern fill types
45+
| pattern | value |
46+
| no pattern | None |
47+
| MSO_PATTERN.DIVOT | MSO_PATTERN.DIVOT |
48+
| MSO_PATTERN.WAVE | MSO_PATTERN.WAVE |
49+
50+
51+
@wip
52+
Scenario: FillFormat.pattern setter
53+
Given a FillFormat object as fill
54+
When I call fill.patterned()
55+
And I assign MSO_PATTERN.CROSS to fill.pattern
56+
Then fill.pattern is MSO_PATTERN.CROSS

‎features/steps/fill.py‎

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from behave import given, then, when
1010

1111
from pptx import Presentation
12-
from pptx.enum.dml import MSO_FILL
12+
from pptx.enum.dml import MSO_FILL, MSO_PATTERN
1313

1414
from helpers import test_pptx
1515

@@ -22,20 +22,57 @@ def given_a_FillFormat_object_as_fill(context):
2222
context.fill = fill
2323

2424

25+
@given('a FillFormat object as fill having {pattern} fill')
26+
def given_a_FillFormat_object_as_fill_having_pattern(context, pattern):
27+
shape_idx = {
28+
'no pattern': 0,
29+
'MSO_PATTERN.DIVOT': 1,
30+
'MSO_PATTERN.WAVE': 2,
31+
}[pattern]
32+
slide = Presentation(test_pptx('dml-fill')).slides[1]
33+
fill = slide.shapes[shape_idx].fill
34+
context.fill = fill
35+
36+
2537
# when =====================================================
2638

39+
@when("I assign {value} to fill.pattern")
40+
def when_I_assign_value_to_fill_pattern(context, value):
41+
pattern = {
42+
'None': None,
43+
'MSO_PATTERN.CROSS': MSO_PATTERN.CROSS,
44+
'MSO_PATTERN.DIVOT': MSO_PATTERN.DIVOT,
45+
'MSO_PATTERN.WAVE': MSO_PATTERN.WAVE,
46+
}[value]
47+
context.fill.pattern = pattern
48+
49+
2750
@when("I call fill.background()")
2851
def when_I_call_fill_background(context):
2952
context.fill.background()
3053

3154

55+
@when("I call fill.patterned()")
56+
def when_I_call_fill_patterned(context):
57+
context.fill.patterned()
58+
59+
3260
@when("I call fill.solid()")
3361
def when_I_call_fill_solid(context):
3462
context.fill.solid()
3563

3664

3765
# then =====================================================
3866

67+
@then('fill.back_color is a ColorFormat object')
68+
def then_fill_back_color_is_a_ColorFormat_object(context):
69+
class_name = context.fill.back_color.__class__.__name__
70+
expected_value = 'ColorFormat'
71+
assert class_name == expected_value, (
72+
'expected \'%s\', got \'%s\'' % (expected_value, class_name)
73+
)
74+
75+
3976
@then('fill.fore_color is a ColorFormat object')
4077
def then_fill_fore_color_is_a_ColorFormat_object(context):
4178
class_name = context.fill.fore_color.__class__.__name__
@@ -45,6 +82,20 @@ def then_fill_fore_color_is_a_ColorFormat_object(context):
4582
)
4683

4784

85+
@then('fill.pattern is {value}')
86+
def then_fill_pattern_is_value(context, value):
87+
fill_pattern = context.fill.pattern
88+
expected_value = {
89+
'None': None,
90+
'MSO_PATTERN.CROSS': MSO_PATTERN.CROSS,
91+
'MSO_PATTERN.DIVOT': MSO_PATTERN.DIVOT,
92+
'MSO_PATTERN.WAVE': MSO_PATTERN.WAVE,
93+
}[value]
94+
assert fill_pattern == expected_value, (
95+
'expected fill pattern %s, got %s' % (expected_value, fill_pattern)
96+
)
97+
98+
4899
@then('fill.type is MSO_FILL.{member_name}')
49100
def then_fill_type_is_MSO_FILL_member_name(context, member_name):
50101
fill_type = context.fill.type

0 commit comments

Comments
 (0)