12
12
13
13
from docx .enum .section import WD_HEADER_FOOTER , WD_ORIENTATION , WD_SECTION_START
14
14
from docx .oxml .ns import nsmap
15
- from docx .oxml .shared import CT_OnOff
16
- from docx .oxml .simpletypes import ST_SignedTwipsMeasure , ST_TwipsMeasure , XsdString , ST_FtnPos , ST_NumberFormat , ST_RestartNumber
15
+ from docx .oxml .shared import CT_OnOff , CT_DecimalNumber
16
+ from docx .oxml .simpletypes import ST_SignedTwipsMeasure , ST_TwipsMeasure , XsdString , ST_FtnPos , ST_NumberFormat , ST_RestartNumber , ST_DecimalNumber
17
17
from docx .oxml .table import CT_Tbl
18
18
from docx .oxml .text .paragraph import CT_P
19
19
from docx .oxml .xmlchemy import (
@@ -35,13 +35,19 @@ class CT_FtnPos(BaseOxmlElement):
35
35
36
36
class CT_FtnProps (BaseOxmlElement ):
37
37
"""``<w:footnotePr>`` element, section wide footnote properties"""
38
+
39
+ get_or_add_pos : Callable [[], CT_FtnPos ]
40
+ get_or_add_numFmt : Callable [[], CT_NumFmt ]
41
+ get_or_add_numStart : Callable [[], CT_DecimalNumber ]
42
+ get_or_add_numRestart : Callable [[], CT_NumRestart ]
43
+
38
44
_tag_seq = (
39
45
'w:pos' , 'w:numFmt' , 'w:numStart' , 'w:numRestart'
40
46
)
41
- pos = ZeroOrOne ('w:pos' , successors = _tag_seq )
42
- numFmt = ZeroOrOne ('w:numFmt' , successors = _tag_seq [1 :])
43
- numStart = ZeroOrOne ('w:numStart' , successors = _tag_seq [2 :])
44
- numRestart = ZeroOrOne ('w:numRestart' , successors = _tag_seq [3 :])
47
+ pos : CT_FtnPos | None = ZeroOrOne ('w:pos' , successors = _tag_seq ) # pyright: ignore[reportGeneralTypeIssues]
48
+ numFmt : CT_NumFmt | None = ZeroOrOne ('w:numFmt' , successors = _tag_seq [1 :]) # pyright: ignore[reportGeneralTypeIssues]
49
+ numStart : CT_DecimalNumber | None = ZeroOrOne ('w:numStart' , successors = _tag_seq [2 :]) # pyright: ignore[reportGeneralTypeIssues]
50
+ numRestart : CT_NumRestart | None = ZeroOrOne ('w:numRestart' , successors = _tag_seq [3 :]) # pyright: ignore[reportGeneralTypeIssues]
45
51
46
52
47
53
class CT_HdrFtr (BaseOxmlElement ):
@@ -132,6 +138,7 @@ class CT_SectPr(BaseOxmlElement):
132
138
get_or_add_pgSz : Callable [[], CT_PageSz ]
133
139
get_or_add_titlePg : Callable [[], CT_OnOff ]
134
140
get_or_add_type : Callable [[], CT_SectType ]
141
+ get_or_add_footnotePr : Callable [[], CT_FtnProps ]
135
142
_add_footerReference : Callable [[], CT_HdrFtrRef ]
136
143
_add_headerReference : Callable [[], CT_HdrFtrRef ]
137
144
_remove_titlePg : Callable [[], None ]
@@ -173,7 +180,9 @@ class CT_SectPr(BaseOxmlElement):
173
180
titlePg : CT_OnOff | None = ZeroOrOne ( # pyright: ignore[reportAssignmentType]
174
181
"w:titlePg" , successors = _tag_seq [14 :]
175
182
)
176
- footnotePr = ZeroOrOne ("w:footnotePr" , successors = _tag_seq [1 :])
183
+ footnotePr : CT_FtnProps | None = ZeroOrOne ( # pyright: ignore[reportGeneralTypeIssues]
184
+ "w:footnotePr" , successors = _tag_seq [1 :]
185
+ )
177
186
del _tag_seq
178
187
179
188
def add_footerReference (self , type_ : WD_HEADER_FOOTER , rId : str ) -> CT_HdrFtrRef :
@@ -241,7 +250,7 @@ def footer(self, value: int | Length | None):
241
250
pgMar .footer = value if value is None or isinstance (value , Length ) else Length (value )
242
251
243
252
@property
244
- def footnote_number_format (self ):
253
+ def footnote_number_format (self ) -> ST_NumberFormat | None :
245
254
"""
246
255
The value of the ``w:val`` attribute in the ``<w:numFmt>`` child
247
256
element of ``<w:footnotePr>`` element, as a |String|, or |None| if either the element or the
@@ -253,13 +262,13 @@ def footnote_number_format(self):
253
262
return fPr .numFmt .val
254
263
255
264
@footnote_number_format .setter
256
- def footnote_number_format (self , value ):
265
+ def footnote_number_format (self , value : ST_NumberFormat | None ):
257
266
fPr = self .get_or_add_footnotePr ()
258
267
numFmt = fPr .get_or_add_numFmt ()
259
268
numFmt .val = value
260
269
261
270
@property
262
- def footnote_numbering_restart_location (self ):
271
+ def footnote_numbering_restart_location (self ) -> ST_RestartNumber | None :
263
272
"""
264
273
The value of the ``w:val`` attribute in the ``<w:numRestart>`` child
265
274
element of ``<w:footnotePr>`` element, as a |String|, or |None| if either the element or the
@@ -271,20 +280,20 @@ def footnote_numbering_restart_location(self):
271
280
return fPr .numRestart .val
272
281
273
282
@footnote_numbering_restart_location .setter
274
- def footnote_numbering_restart_location (self , value ):
283
+ def footnote_numbering_restart_location (self , value : ST_RestartNumber | None ):
275
284
fPr = self .get_or_add_footnotePr ()
276
285
numStart = fPr .get_or_add_numStart ()
277
286
numRestart = fPr .get_or_add_numRestart ()
278
287
numRestart .val = value
279
- if numStart is None or len (numStart .values ()) == 0 :
288
+ if len (numStart .values ()) == 0 :
280
289
numStart .val = 1
281
290
elif value != 'continuous' :
282
291
numStart .val = 1
283
292
msg = "When ``<w:numRestart> is not 'continuous', then ``<w:numStart>`` must be 1."
284
293
warn (msg , UserWarning , stacklevel = 2 )
285
294
286
295
@property
287
- def footnote_numbering_start_value (self ):
296
+ def footnote_numbering_start_value (self ) -> ST_DecimalNumber | None :
288
297
"""
289
298
The value of the ``w:val`` attribute in the ``<w:numStart>`` child
290
299
element of ``<w:footnotePr>`` element, as a |Number|, or |None| if either the element or the
@@ -296,20 +305,20 @@ def footnote_numbering_start_value(self):
296
305
return fPr .numStart .val
297
306
298
307
@footnote_numbering_start_value .setter
299
- def footnote_numbering_start_value (self , value ):
308
+ def footnote_numbering_start_value (self , value : ST_DecimalNumber | None ):
300
309
fPr = self .get_or_add_footnotePr ()
301
310
numStart = fPr .get_or_add_numStart ()
302
311
numRestart = fPr .get_or_add_numRestart ()
303
312
numStart .val = value
304
- if numRestart is None or len (numRestart .values ()) == 0 :
313
+ if len (numRestart .values ()) == 0 :
305
314
numRestart .val = 'continuous'
306
315
elif value != 1 :
307
316
numRestart .val = 'continuous'
308
317
msg = "When ``<w:numStart> is not 1, then ``<w:numRestart>`` must be 'continuous'."
309
318
warn (msg , UserWarning , stacklevel = 2 )
310
319
311
320
@property
312
- def footnote_position (self ):
321
+ def footnote_position (self ) -> ST_FtnPos | None :
313
322
"""
314
323
The value of the ``w:val`` attribute in the ``<w:pos>`` child
315
324
element of ``<w:footnotePr>`` element, as a |String|, or |None| if either the element or the
@@ -321,7 +330,7 @@ def footnote_position(self):
321
330
return fPr .pos .val
322
331
323
332
@footnote_position .setter
324
- def footnote_position (self , value ):
333
+ def footnote_position (self , value : ST_FtnPos | None ):
325
334
fPr = self .get_or_add_footnotePr ()
326
335
pos = fPr .get_or_add_pos ()
327
336
pos .val = value
0 commit comments