Skip to content

Commit 72dc01a

Browse files
MHoroszowskiclaude
andcommitted
fix: provide default color and attributes when creating outerShdw element
PowerPoint requires a color child element on a:outerShdw. Override _new_outerShdw on CT_EffectList to produce a valid default shadow (45-degree angle, 3pt distance, 4pt blur, 40% transparent black). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 1f26689 commit 72dc01a

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/pptx/oxml/dml/effect.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
from __future__ import annotations
44

5-
from typing import Callable
5+
from typing import Callable, cast
66

7+
from pptx.oxml import parse_xml
8+
from pptx.oxml.ns import nsdecls
79
from pptx.oxml.simpletypes import ST_Angle, ST_PositiveCoordinate, XsdBoolean
810
from pptx.oxml.xmlchemy import (
911
BaseOxmlElement,
@@ -60,3 +62,21 @@ class CT_EffectList(BaseOxmlElement):
6062
"a:outerShdw", successors=_tag_seq[5:]
6163
)
6264
del _tag_seq
65+
66+
def _new_outerShdw(self) -> CT_OuterShadowEffect:
67+
"""Return a new `a:outerShdw` element with default shadow properties.
68+
69+
PowerPoint requires a color child element on `a:outerShdw`, so this provides a reasonable
70+
default: 45-degree angle, 3pt distance, 4pt blur, 40% transparent black.
71+
"""
72+
return cast(
73+
CT_OuterShadowEffect,
74+
parse_xml(
75+
f'<a:outerShdw {nsdecls("a")} blurRad="50800" dist="38100"'
76+
f' dir="2700000" algn="tl" rotWithShape="0">'
77+
f' <a:srgbClr val="000000">'
78+
f' <a:alpha val="40000"/>'
79+
f" </a:srgbClr>"
80+
f"</a:outerShdw>"
81+
),
82+
)

0 commit comments

Comments
 (0)