11"""Shape wrapper implementation."""
22
3- from typing import TYPE_CHECKING , Self , TypedDict
3+ from typing import TYPE_CHECKING , TypedDict
44
5- from pptx .enum .shapes import MSO_AUTO_SHAPE_TYPE
6- from pptx .opc .package import XmlPart
75from pptx .shapes import Subshape as PptxSubshape
86from pptx .shapes .autoshape import Shape as PptxShape
97from pptx .shapes .base import BaseShape as PptxBaseShape
8+ from pptx .util import Length as PptxLength
109from typing_extensions import TypeVar
1110
12- from tppt .pptx .converter import PptxConvertible
13- from tppt .types ._length import Length , LiteralLength
11+ from tppt .pptx .converter import PptxConvertible , to_pptx_length
12+ from tppt .types ._length import Length , LiteralLength , to_length
1413
1514if TYPE_CHECKING :
15+ from pptx .enum .shapes import MSO_AUTO_SHAPE_TYPE , MSO_SHAPE_TYPE
16+ from pptx .oxml .shapes import ShapeElement as PptxShapeElement
17+ from pptx .parts .slide import BaseSlidePart as PptxBaseSlidePart
18+ from pptx .shapes .base import _PlaceholderFormat as PptxPlaceholderFormat
19+
20+ from tppt .pptx .action import ActionSetting
21+ from tppt .pptx .dml .effect import ShadowFormat
1622 from tppt .pptx .dml .fill import FillFormat
1723 from tppt .pptx .dml .line import LineFormat
1824 from tppt .pptx .text .text_frame import TextFrame
3238
3339
3440class BaseShape (PptxConvertible [GenericPptxBaseShape ]):
35- def __init__ (self , pptx_shape : GenericPptxBaseShape ) -> None :
36- self ._pptx : GenericPptxBaseShape = pptx_shape
41+ def __eq__ (self , other : object ) -> bool :
42+ if not isinstance (other , BaseShape ):
43+ return False
44+ return self ._pptx is other ._pptx
45+
46+ def __ne__ (self , other : object ) -> bool :
47+ if not isinstance (other , BaseShape ):
48+ return True
49+ return self ._pptx is not other ._pptx
50+
51+ @property
52+ def click_action (self ) -> "ActionSetting" :
53+ from tppt .pptx .action import ActionSetting
54+
55+ return ActionSetting (self ._pptx .click_action )
56+
57+ @property
58+ def element (self ) -> "PptxShapeElement" :
59+ return self ._pptx .element
60+
61+ @property
62+ def height (self ) -> Length :
63+ return to_length (self ._pptx .height )
64+
65+ @height .setter
66+ def height (self , value : Length | LiteralLength | PptxLength ) -> None :
67+ self ._pptx .height = to_pptx_length (value )
68+
69+ @property
70+ def left (self ) -> Length :
71+ return to_length (self ._pptx .left )
72+
73+ @left .setter
74+ def left (self , value : Length | LiteralLength | PptxLength ) -> None :
75+ self ._pptx .left = to_pptx_length (value )
76+
77+ @property
78+ def name (self ) -> str :
79+ return self ._pptx .name
80+
81+ @name .setter
82+ def name (self , value : str ) -> None :
83+ self ._pptx .name = value
84+
85+ @property
86+ def part (self ) -> "PptxBaseSlidePart" :
87+ return self ._pptx .part
88+
89+ @property
90+ def placeholder_format (self ) -> "PptxPlaceholderFormat" :
91+ return self ._pptx .placeholder_format
92+
93+ @property
94+ def rotation (self ) -> float :
95+ return self ._pptx .rotation
96+
97+ @rotation .setter
98+ def rotation (self , value : float ) -> None :
99+ self ._pptx .rotation = value
100+
101+ @property
102+ def shadow (self ) -> "ShadowFormat" :
103+ from tppt .pptx .dml .effect import ShadowFormat
104+
105+ return ShadowFormat (self ._pptx .shadow )
106+
107+ @property
108+ def shape_id (self ) -> int :
109+ return self ._pptx .shape_id
110+
111+ @property
112+ def shape_type (self ) -> "MSO_SHAPE_TYPE" :
113+ return self ._pptx .shape_type
114+
115+ @property
116+ def top (self ) -> Length :
117+ return to_length (self ._pptx .top )
37118
38- def to_pptx (self ) -> GenericPptxBaseShape :
39- return self ._pptx
119+ @top .setter
120+ def top (self , value : Length | LiteralLength | PptxLength ) -> None :
121+ self ._pptx .top = to_pptx_length (value )
122+
123+ @property
124+ def width (self ) -> Length :
125+ return to_length (self ._pptx .width )
40126
41- @classmethod
42- def from_pptx ( cls , pptx_obj : GenericPptxBaseShape ) -> Self :
43- return cls ( pptx_obj )
127+ @width . setter
128+ def width ( self , value : Length | LiteralLength | PptxLength ) -> None :
129+ self . _pptx . width = to_pptx_length ( value )
44130
45131
46132class Shape (BaseShape [GenericPptxShape ]):
@@ -49,7 +135,7 @@ def adjustments(self) -> list[float]:
49135 return [self ._pptx .adjustments [i ] for i in range (len (self ._pptx .adjustments ))]
50136
51137 @property
52- def auto_shape_type (self ) -> MSO_AUTO_SHAPE_TYPE | None :
138+ def auto_shape_type (self ) -> " MSO_AUTO_SHAPE_TYPE | None" :
53139 return self ._pptx .auto_shape_type
54140
55141 @property
@@ -83,19 +169,7 @@ def text_frame(self) -> "TextFrame":
83169
84170
85171class SubShape (PptxConvertible [_GenericPptxSubshape ]):
86- def __init__ (self , pptx_shape : _GenericPptxSubshape ) -> None :
87- self ._pptx : _GenericPptxSubshape = pptx_shape
88-
89- @property
90- def part (self ) -> XmlPart :
91- return self ._pptx .part
92-
93- def to_pptx (self ) -> _GenericPptxSubshape :
94- return self ._pptx
95-
96- @classmethod
97- def from_pptx (cls , pptx_obj : _GenericPptxSubshape ) -> Self :
98- return cls (pptx_obj )
172+ pass
99173
100174
101175class RangeProps (TypedDict ):
0 commit comments