8000 hdr: add Section.first_page_header · python-openxml/python-docx@569b880 · GitHub
[go: up one dir, main page]

Skip to content

Commit 569b880

Browse files
committed
hdr: add Section.first_page_header
1 parent 68a28ab commit 569b880

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

docx/section.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,15 @@ def first_page_footer(self):
101101
"""
102102
return _Footer(self._sectPr, self._document_part, WD_HEADER_FOOTER.FIRST_PAGE)
103103

104+
@property
105+
def first_page_header(self):
106+
"""|_Header| object defining header content for the first page of this section.
107+
108+
The content of this header definition is ignored unless the property
109+
:attr:`.different_first_page_header_header` is set True.
110+
"""
111+
return _Header(self._sectPr, self._document_part, WD_HEADER_FOOTER.FIRST_PAGE)
112+
104113
@lazyproperty
105114
def footer(self):
106115
"""|_Footer| object representing default page footer for this section.

features/sct-section.feature

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ Feature: Access and change section properties
4242
Then section.first_page_footer is a _Footer object
4343

4444

45-
@wip
4645
Scenario: Section.first_page_header
4746
Given a Section object as section
4847
Then section.first_page_header is a _Header object

tests/test_section.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,20 @@ def it_provides_access_to_its_first_page_footer(
154154
)
155155
assert footer is footer_
156156

157+
def it_provides_access_to_its_first_page_header(
158+
self, document_part_, _Header_, header_
159+
):
160+
sectPr = element("w:sectPr")
161+
_Header_.return_value = header_
162+
section = Section(sectPr, document_part_)
163+
164+
header = section.first_page_header
165+
166+
_Header_.assert_called_once_with(
167+
sectPr, document_part_, WD_HEADER_FOOTER.FIRST_PAGE
168+
)
169+
assert header is header_
170+
157171
def it_provides_access_to_its_default_footer(
158172
self, document_part_, _Footer_, footer_
159173
):

0 commit comments

Comments
 (0)
163C
0