Skip to content

Commit 15729c5

Browse files
committed
fix: update SlidePlaceholder to inherit from Shape and enhance value handling in SlideLayoutProxy
1 parent f120376 commit 15729c5

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/tppt/pptx/shape/placeholder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
from tppt.pptx.presentation import PptxConvertible
88
from tppt.types._length import Length
99

10-
from . import BaseShape
10+
from . import Shape
1111

1212

13-
class SlidePlaceholder(BaseShape[PptxSlidePlaceholder]):
13+
class SlidePlaceholder(Shape[PptxSlidePlaceholder]):
1414
def __init__(self, pptx_obj: PptxSlidePlaceholder) -> None:
1515
self._pptx = pptx_obj
1616

src/tppt/template/slide_layout.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import datetime
12
from typing import (
23
TYPE_CHECKING,
34
Annotated,
@@ -14,6 +15,8 @@
1415
overload,
1516
)
1617

18+
from tppt.exception import InvalidSetterTypeError
19+
1720
if TYPE_CHECKING:
1821
from ..pptx.slide import SlideBuilder
1922
from ..pptx.slide_layout import SlideLayout as PptxConvertibleSlideLayout
@@ -152,6 +155,16 @@ def placeholder_registry(slide: Slide):
152155
for placeholder, value in zip(
153156
slide.placeholders, get_placeholders(self._slide_layout).values()
154157
):
158+
match value:
159+
case None:
160+
continue
161+
case str():
162+
pass
163+
case datetime.date():
164+
value = value.strftime("%Y%m/%d")
165+
case _:
166+
raise InvalidSetterTypeError(str, type(value))
167+
155168
placeholder.text = value
156169

157170
return SlideBuilder(

0 commit comments

Comments
 (0)