Skip to content

Commit 15c1cfe

Browse files
author
Steve Canny
committed
style: add _LatentStyle.priority getter
1 parent e0a27fa commit 15c1cfe

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

docx/oxml/styles.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ class CT_LsdException(BaseOxmlElement):
7979
a named latent style.
8080
"""
8181
name = RequiredAttribute('w:name', ST_String)
82+
uiPriority = OptionalAttribute('w:uiPriority', ST_DecimalNumber)
8283

8384

8485
class CT_Style(BaseOxmlElement):

docx/styles/latent.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,10 @@ def name(self):
132132
The name of the built-in style this exception applies to.
133133
"""
134134
return self._element.name
135+
136+
@property
137+
def priority(self):
138+
"""
139+
The integer sort key for this latent style in the Word UI.
140+
"""
141+
return self._element.uiPriority

features/sty-latent-props.feature

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ Feature: Get and set latent style properties
3838
Then latent_style.name is the known name
3939

4040

41-
@wip
4241
Scenario Outline: Get latent style display sort order
4342
Given a latent style having priority of <setting>
4443
Then latent_style.priority is <value>

tests/styles/test_latent.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ def it_knows_its_name(self, name_get_fixture):
2121
latent_style, expected_value = name_get_fixture
2222
assert latent_style.name == expected_value
2323

24+
def it_knows_its_priority(self, priority_get_fixture):
25+
latent_style, expected_value = priority_get_fixture
26+
assert latent_style.priority == expected_value
27+
2428
# fixtures -------------------------------------------------------
2529

2630
@pytest.fixture(params=[
@@ -31,6 +35,15 @@ def name_get_fixture(self, request):
3135
latent_style = _LatentStyle(element(lsdException_cxml))
3236
return latent_style, expected_value
3337

38+
@pytest.fixture(params=[
39+
('w:lsdException', None),
40+
('w:lsdException{w:uiPriority=42}', 42),
41+
])
42+
def priority_get_fixture(self, request):
43+
lsdException_cxml, expected_value = request.param
44+
latent_style = _LatentStyle(element(lsdException_cxml))
45+
return latent_style, expected_value
46+
3447

3548
class DescribeLatentStyles(object):
3649

0 commit comments

Comments
 (0)