Skip to content

Commit

Permalink
fix(enum): replace read-only enum values
Browse files Browse the repository at this point in the history
Some enum values like `MSO_SHAPE_TYPE.MIXED` are never produced by
`python-pptx` and so were removed during the enum modernization in
commit `01b86e64`. However, in at least one downstream system these
values are referenced even though they can never actually occur.

Replace these "read-only" values to avoid downstream breakage.
  • Loading branch information
scanny committed Aug 6, 2024
1 parent 0f980cd commit c21b93b
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 12 deletions.
7 changes: 5 additions & 2 deletions src/pptx/enum/chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,9 @@ class XL_DATA_LABEL_POSITION(BaseXmlEnum):
LEFT = (-4131, "l", "The data label is positioned to the left of the data point.")
"""The data label is positioned to the left of the data point."""

MIXED = (6, "", "Data labels are in multiple positions (read-only).")
"""Data labels are in multiple positions (read-only)."""

OUTSIDE_END = (
2,
"outEnd",
Expand Down Expand Up @@ -370,8 +373,8 @@ class XL_LEGEND_POSITION(BaseXmlEnum):
CORNER = (2, "tr", "In the upper-right corner of the chart border.")
"""In the upper-right corner of the chart border."""

CUSTOM = (-4161, "", "A custom position.")
"""A custom position."""
CUSTOM = (-4161, "", "A custom position (read-only).")
"""A custom position (read-only)."""

LEFT = (-4131, "l", "Left of the chart.")
"""Left of the chart."""
Expand Down
12 changes: 8 additions & 4 deletions src/pptx/enum/dml.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,8 @@ class MSO_PATTERN_TYPE(BaseXmlEnum):
ZIG_ZAG = (38, "zigZag", "Zig Zag")
"""Zig Zag"""

MIXED = (-2, "", "Mixed pattern")
"""Mixed pattern"""
MIXED = (-2, "", "Mixed pattern (read-only).")
"""Mixed pattern (read-only)."""


MSO_PATTERN = MSO_PATTERN_TYPE
Expand Down Expand Up @@ -394,8 +394,12 @@ class MSO_THEME_COLOR_INDEX(BaseXmlEnum):
TEXT_2 = (15, "tx2", "Specifies the Text 2 theme color.")
"""Specifies the Text 2 theme color."""

MIXED = (-2, "", "Indicates multiple theme colors are used, such as in a group shape.")
"""Indicates multiple theme colors are used, such as in a group shape."""
MIXED = (
-2,
"",
"Indicates multiple theme colors are used, such as in a group shape (read-only).",
)
"""Indicates multiple theme colors are used, such as in a group shape (read-only)."""


MSO_THEME_COLOR = MSO_THEME_COLOR_INDEX
3 changes: 3 additions & 0 deletions src/pptx/enum/lang.py
Original file line number Diff line number Diff line change
Expand Up @@ -680,3 +680,6 @@ class MSO_LANGUAGE_ID(BaseXmlEnum):

ZULU = (1077, "zu-ZA", "The Zulu language.")
"""The Zulu language."""

MIXED = (-2, "", "More than one language in specified range (read-only).")
"""More than one language in specified range (read-only)."""
28 changes: 22 additions & 6 deletions src/pptx/enum/shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,9 @@ class MSO_CONNECTOR_TYPE(BaseXmlEnum):
STRAIGHT = (1, "line", "Straight line connector.")
"""Straight line connector."""

MIXED = (-2, "", "Return value only; indicates a combination of other states.")
"""Return value only; indicates a combination of other states."""


MSO_CONNECTOR = MSO_CONNECTOR_TYPE

Expand Down Expand Up @@ -843,6 +846,9 @@ class MSO_SHAPE_TYPE(BaseEnum):
WEB_VIDEO = (26, "Web video")
"""Web video"""

MIXED = (-2, "Multiple shape types (read-only).")
"""Multiple shape types (read-only)."""


MSO = MSO_SHAPE_TYPE

Expand Down Expand Up @@ -871,6 +877,16 @@ class PP_MEDIA_TYPE(BaseEnum):
SOUND = (1, "Audio media such as MP3.")
"""Audio media such as MP3."""

MIXED = (
-2,
"Return value only; indicates multiple media types, typically for a collection of shapes."
" May not be applicable in python-pptx.",
)
"""Return value only; indicates multiple media types.
Typically for a collection of shapes. May not be applicable in python-pptx.
"""


class PP_PLACEHOLDER_TYPE(BaseXmlEnum):
"""Specifies one of the 18 distinct types of placeholder.
Expand Down Expand Up @@ -937,14 +953,14 @@ class PP_PLACEHOLDER_TYPE(BaseXmlEnum):
TITLE = (1, "title", "Title")
"""Title"""

VERTICAL_BODY = (6, "", "Vertical Body")
"""Vertical Body"""
VERTICAL_BODY = (6, "", "Vertical Body (read-only).")
"""Vertical Body (read-only)."""

VERTICAL_OBJECT = (17, "", "Vertical Object")
"""Vertical Object"""
VERTICAL_OBJECT = (17, "", "Vertical Object (read-only).")
"""Vertical Object (read-only)."""

VERTICAL_TITLE = (5, "", "Vertical Title")
"""Vertical Title"""
VERTICAL_TITLE = (5, "", "Vertical Title (read-only).")
"""Vertical Title (read-only)."""

MIXED = (-2, "", "Return value only; multiple placeholders of differing types.")
"""Return value only; multiple placeholders of differing types."""
Expand Down
12 changes: 12 additions & 0 deletions src/pptx/enum/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ class MSO_AUTO_SIZE(BaseEnum):
)
"""The font size is reduced as necessary to fit the text within the shape."""

MIXED = (-2, "Return value only; indicates a combination of automatic sizing schemes are used.")
"""Return value only; indicates a combination of automatic sizing schemes are used."""


class MSO_TEXT_UNDERLINE_TYPE(BaseXmlEnum):
"""
Expand Down Expand Up @@ -134,6 +137,9 @@ class MSO_TEXT_UNDERLINE_TYPE(BaseXmlEnum):
WORDS = (1, "words", "Specifies underlining words.")
"""Specifies underlining words."""

MIXED = (-2, "", "Specifies a mix of underline types (read-only).")
"""Specifies a mix of underline types (read-only)."""


MSO_UNDERLINE = MSO_TEXT_UNDERLINE_TYPE

Expand Down Expand Up @@ -161,6 +167,9 @@ class MSO_VERTICAL_ANCHOR(BaseXmlEnum):
BOTTOM = (4, "b", "Aligns text to bottom of text frame")
"""Aligns text to bottom of text frame"""

MIXED = (-2, "", "Return value only; indicates a combination of the other states.")
"""Return value only; indicates a combination of the other states."""


MSO_ANCHOR = MSO_VERTICAL_ANCHOR

Expand Down Expand Up @@ -214,5 +223,8 @@ class PP_PARAGRAPH_ALIGNMENT(BaseXmlEnum):
THAI_DISTRIBUTE = (6, "thaiDist", "Thai distributed")
"""Thai distributed"""

MIXED = (-2, "", "Multiple alignments are present in a set of paragraphs (read-only).")
"""Multiple alignments are present in a set of paragraphs (read-only)."""


PP_ALIGN = PP_PARAGRAPH_ALIGNMENT

0 comments on commit c21b93b

Please sign in to comment.