Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions docx/oxml/text/parfmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class CT_Ind(BaseOxmlElement):
left = OptionalAttribute('w:left', ST_SignedTwipsMeasure)
right = OptionalAttribute('w:right', ST_SignedTwipsMeasure)
firstLine = OptionalAttribute('w:firstLine', ST_TwipsMeasure)
firstLineChars = OptionalAttribute('w:firstLineChars', ST_TwipsMeasure)
hanging = OptionalAttribute('w:hanging', ST_TwipsMeasure)


Expand Down Expand Up @@ -91,6 +92,37 @@ def first_line_indent(self, value):
else:
ind.firstLine = value

@property
def first_line_chars_indent(self):
"""
A |Length| value calculated from the values of `w:ind/@w:firstLineChars`
and `w:ind/@w:hanging`. Returns |None| if the `w:ind` child is not
present.
"""
ind = self.ind
if ind is None:
return None
hanging = ind.hanging
if hanging is not None:
return Length(-hanging)
firstLine = ind.firstLineChars
if firstLine is None:
return None
return firstLine

@first_line_chars_indent.setter
def first_line_chars_indent(self, value):
if self.ind is None and value is None:
return
ind = self.get_or_add_ind()
ind.firstLineChars = ind.hanging = None
if value is None:
return
elif value < 0:
ind.hanging = -value
else:
ind.firstLineChars = value

@property
def ind_left(self):
"""
Expand Down
19 changes: 19 additions & 0 deletions docx/text/parfmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,25 @@ def first_line_indent(self, value):
pPr = self._element.get_or_add_pPr()
pPr.first_line_indent = value

@property
def first_line_chars_indent(self):
"""
|Length| value specifying the relative difference in indentation for
the first line of the paragraph. A positive value causes the first
line to be indented. A negative value produces a hanging indent.
|None| indicates first line indentation is inherited from the style
hierarchy.
"""
pPr = self._element.pPr
if pPr is None:
return None
return pPr.first_line_chars_indent

@first_line_chars_indent.setter
def first_line_chars_indent(self, value):
pPr = self._element.get_or_add_pPr()
pPr.first_line_chars_indent = value

@property
def keep_together(self):
"""
Expand Down