33import os
44from typing import IO , TYPE_CHECKING , Any , Callable , Generic , Self , cast , overload
55
6- from pptx .presentation import Presentation as PptxPresentation
6+ from pptx .parts .coreprops import CorePropertiesPart as _PptxCorePropertiesPart
7+ from pptx .presentation import Presentation as _PptxPresentation
8+ from pptx .slide import NotesMaster as _PptxNotesMaster
9+ from pptx .slide import _BaseMaster as _PptxBaseMaster
710
811from tppt .pptx .tree import ppt2tree
912from tppt .template .default import DefaultSlideMaster
1720
1821from .converter import PptxConvertible , to_pptx_length , to_tppt_length
1922from .slide import SlideBuilder
20- from .slide_master import SlideMaster
2123
2224if TYPE_CHECKING :
25+ from tppt .pptx .shape .placeholder import MasterPlaceholder
2326 from tppt .pptx .slide import Slide
2427
28+ from .slide_master import SlideMaster
2529
26- class Presentation (PptxConvertible [PptxPresentation ]):
30+
31+ class Presentation (PptxConvertible [_PptxPresentation ]):
2732 """Presentation wrapper with type safety."""
2833
2934 def __init__ (
3035 self ,
31- pptx : PptxPresentation | FilePath ,
36+ pptx : _PptxPresentation | FilePath ,
3237 ) -> None :
3338 """Initialize presentation."""
3439 if isinstance (pptx , (os .PathLike , str )):
@@ -37,6 +42,16 @@ def __init__(
3742 pptx = Presentation (os .fspath (pptx ))
3843 self ._pptx = pptx
3944
45+ @property
46+ def core_properties (self ) -> _PptxCorePropertiesPart :
47+ """Get the core properties."""
48+ return self ._pptx .core_properties
49+
50+ @property
51+ def notes_master (self ) -> "NotesMaster" :
52+ """Get the notes master."""
53+ return NotesMaster .from_pptx (self ._pptx .notes_master )
54+
4055 @property
4156 def slides (self ) -> "list[Slide]" :
4257 """Get the slides."""
@@ -45,12 +60,14 @@ def slides(self) -> "list[Slide]":
4560 return [Slide .from_pptx (slide ) for slide in self ._pptx .slides ]
4661
4762 @property
48- def slide_master (self ) -> SlideMaster :
63+ def slide_master (self ) -> " SlideMaster" :
4964 """
5065 Get the slide master.
5166
5267 This tool supports only one slide master.
5368 """
69+ from .slide_master import SlideMaster
70+
5471 return SlideMaster .from_pptx (self ._pptx .slide_masters [0 ])
5572
5673 @property
@@ -104,12 +121,12 @@ def save(self, file: FilePath | IO[bytes]) -> None:
104121 file = os .fspath (file )
105122 self ._pptx .save (file )
106123
107- def to_pptx (self ) -> PptxPresentation :
124+ def to_pptx (self ) -> _PptxPresentation :
108125 """Convert to pptx presentation."""
109126 return self ._pptx
110127
111128 @classmethod
112- def from_pptx (cls , pptx_obj : PptxPresentation ) -> Self :
129+ def from_pptx (cls , pptx_obj : _PptxPresentation ) -> Self :
113130 """Create from pptx presentation."""
114131 return cls (pptx_obj )
115132
@@ -177,3 +194,22 @@ def build(self) -> Presentation:
177194 def save (self , file : FilePath | IO [bytes ]) -> None :
178195 """Save the presentation to a file."""
179196 self .build ().save (file )
197+
198+
199+ class _BaseMaster (PptxConvertible [_PptxBaseMaster ]):
200+ @property
201+ def placeholders (self ) -> "list[MasterPlaceholder]" :
202+ """Get the placeholders."""
203+ from tppt .pptx .shape .placeholder import MasterPlaceholder
204+
205+ return [
206+ MasterPlaceholder (placeholder ) for placeholder in self ._pptx .placeholders
207+ ]
208+
209+
210+ class NotesMaster (_BaseMaster ):
211+ """Notes master."""
212+
213+ def __init__ (self , pptx_obj : _PptxNotesMaster ) -> None :
214+ """Initialize the notes master."""
215+ super ().__init__ (pptx_obj )
0 commit comments