22
33from __future__ import annotations
44
5+ from typing import TYPE_CHECKING
6+
57from pptx .dml .fill import FillFormat
6- from pptx .enum .dml import MSO_FILL
8+ from pptx .enum .dml import MSO_FILL , MSO_LINE_END_SIZE , MSO_LINE_END_TYPE
79from pptx .util import Emu , lazyproperty
810
11+ if TYPE_CHECKING :
12+ from pptx .oxml .shapes .shared import CT_LineEndProperties
13+
914
1015class LineFormat (object ):
1116 """Provides access to line properties such as color, style, and width.
@@ -18,6 +23,69 @@ def __init__(self, parent):
1823 super (LineFormat , self ).__init__ ()
1924 self ._parent = parent
2025
26+ @property
27+ def begin_arrowhead_length (self ) -> MSO_LINE_END_SIZE | None :
28+ """Size of the arrowhead at the beginning of the line.
29+
30+ Read/write. Returns a member of :ref:`MsoArrowheadSize` or |None| if no explicit value
31+ has been set. Assigning |None| removes any existing value.
32+ """
33+ headEnd = self ._headEnd
34+ if headEnd is None :
35+ return None
36+ return headEnd .len
37+
38+ @begin_arrowhead_length .setter
39+ def begin_arrowhead_length (self , value : MSO_LINE_END_SIZE | None ) -> None :
40+ if value is None :
41+ headEnd = self ._headEnd
42+ if headEnd is not None :
43+ del headEnd .attrib ["len" ]
44+ return
45+ self ._get_or_add_headEnd ().len = value
46+
47+ @property
48+ def begin_arrowhead_style (self ) -> MSO_LINE_END_TYPE | None :
49+ """Type of arrowhead at the beginning of the line.
50+
51+ Read/write. Returns a member of :ref:`MsoArrowheadStyle` or |None| if no explicit value
52+ has been set. Assigning |None| removes any existing value.
53+ """
54+ headEnd = self ._headEnd
55+ if headEnd is None :
56+ return None
57+ return headEnd .type
58+
59+ @begin_arrowhead_style .setter
60+ def begin_arrowhead_style (self , value : MSO_LINE_END_TYPE | None ) -> None :
61+ if value is None :
62+ headEnd = self ._headEnd
63+ if headEnd is not None :
64+ del headEnd .attrib ["type" ]
65+ return
66+ self ._get_or_add_headEnd ().type = value
67+
68+ @property
69+ def begin_arrowhead_width (self ) -> MSO_LINE_END_SIZE | None :
70+ """Width of the arrowhead at the beginning of the line.
71+
72+ Read/write. Returns a member of :ref:`MsoArrowheadSize` or |None| if no explicit value
73+ has been set. Assigning |None| removes any existing value.
74+ """
75+ headEnd = self ._headEnd
76+ if headEnd is None :
77+ return None
78+ return headEnd .w
79+
80+ @begin_arrowhead_width .setter
81+ def begin_arrowhead_width (self , value : MSO_LINE_END_SIZE | None ) -> None :
82+ if value is None :
83+ headEnd = self ._headEnd
84+ if headEnd is not None :
85+ del headEnd .attrib ["w" ]
86+ return
87+ self ._get_or_add_headEnd ().w = value
88+
2189 @lazyproperty
2290 def color (self ):
2391 """
@@ -32,6 +100,69 @@ def color(self):
32100 self .fill .solid ()
33101 return self .fill .fore_color
34102
103+ @property
104+ def end_arrowhead_length (self ) -> MSO_LINE_END_SIZE | None :
105+ """Size of the arrowhead at the end of the line.
106+
107+ Read/write. Returns a member of :ref:`MsoArrowheadSize` or |None| if no explicit value
108+ has been set. Assigning |None| removes any existing value.
109+ """
110+ tailEnd = self ._tailEnd
111+ if tailEnd is None :
112+ return None
113+ return tailEnd .len
114+
115+ @end_arrowhead_length .setter
116+ def end_arrowhead_length (self , value : MSO_LINE_END_SIZE | None ) -> None :
117+ if value is None :
118+ tailEnd = self ._tailEnd
119+ if tailEnd is not None :
120+ del tailEnd .attrib ["len" ]
121+ return
122+ self ._get_or_add_tailEnd ().len = value
123+
124+ @property
125+ def end_arrowhead_style (self ) -> MSO_LINE_END_TYPE | None :
126+ """Type of arrowhead at the end of the line.
127+
128+ Read/write. Returns a member of :ref:`MsoArrowheadStyle` or |None| if no explicit value
129+ has been set. Assigning |None| removes any existing value.
130+ """
131+ tailEnd = self ._tailEnd
132+ if tailEnd is None :
133+ return None
134+ return tailEnd .type
135+
136+ @end_arrowhead_style .setter
137+ def end_arrowhead_style (self , value : MSO_LINE_END_TYPE | None ) -> None :
138+ if value is None :
139+ tailEnd = self ._tailEnd
140+ if tailEnd is not None :
141+ del tailEnd .attrib ["type" ]
142+ return
143+ self ._get_or_add_tailEnd ().type = value
144+
145+ @property
146+ def end_arrowhead_width (self ) -> MSO_LINE_END_SIZE | None :
147+ """Width of the arrowhead at the end of the line.
148+
149+ Read/write. Returns a member of :ref:`MsoArrowheadSize` or |None| if no explicit value
150+ has been set. Assigning |None| removes any existing value.
151+ """
152+ tailEnd = self ._tailEnd
153+ if tailEnd is None :
154+ return None
155+ return tailEnd .w
156+
157+ @end_arrowhead_width .setter
158+ def end_arrowhead_width (self , value : MSO_LINE_END_SIZE | None ) -> None :
159+ if value is None :
160+ tailEnd = self ._tailEnd
161+ if tailEnd is not None :
162+ del tailEnd .attrib ["w" ]
163+ return
164+ self ._get_or_add_tailEnd ().w = value
165+
35166 @property
36167 def dash_style (self ):
37168 """Return value indicating line style.
@@ -88,13 +219,37 @@ def width(self, emu):
88219 ln = self ._get_or_add_ln ()
89220 ln .w = emu
90221
222+ def _get_or_add_headEnd (self ) -> CT_LineEndProperties :
223+ """Return the `a:headEnd` element, creating it if not present."""
224+ return self ._get_or_add_ln ().get_or_add_headEnd ()
225+
91226 def _get_or_add_ln (self ):
92227 """
93228 Return the ``<a:ln>`` element containing the line format properties
94229 in the XML.
95230 """
96231 return self ._parent .get_or_add_ln ()
97232
233+ def _get_or_add_tailEnd (self ) -> CT_LineEndProperties :
234+ """Return the `a:tailEnd` element, creating it if not present."""
235+ return self ._get_or_add_ln ().get_or_add_tailEnd ()
236+
237+ @property
238+ def _headEnd (self ) -> CT_LineEndProperties | None :
239+ """Return `a:headEnd` element or None if not present."""
240+ ln = self ._ln
241+ if ln is None :
242+ return None
243+ return ln .headEnd
244+
98245 @property
99246 def _ln (self ):
100247 return self ._parent .ln
248+
249+ @property
250+ def _tailEnd (self ) -> CT_LineEndProperties | None :
251+ """Return `a:tailEnd` element or None if not present."""
252+ ln = self ._ln
253+ if ln is None :
254+ return None
255+ return ln .tailEnd
0 commit comments