File tree Expand file tree Collapse file tree 4 files changed +35
-8
lines changed
Expand file tree Collapse file tree 4 files changed +35
-8
lines changed Original file line number Diff line number Diff line change 2525if TYPE_CHECKING :
2626 from pptx .opc .package import Part
2727
28- __version__ = "1.0.2 +PPTAgent"
28+ __version__ = "1.0.3 +PPTAgent"
2929
3030sys .modules ["pptx.exceptions" ] = exceptions
3131del sys
Original file line number Diff line number Diff line change @@ -106,6 +106,16 @@ def _validate_brightness_value(self, value):
106106 )
107107 raise ValueError (msg )
108108
109+ @property
110+ def value (self ):
111+ if self .type == MSO_COLOR_TYPE .RGB :
112+ return str (self .rgb )
113+ elif self .type == MSO_COLOR_TYPE .SCHEME :
114+ return "ThemeColor-" + str (self .theme_color )
115+ elif self .type is None :
116+ return None
117+ return str (self .type ).split ()[0 ]
118+
109119
110120class _Color (object ):
111121 """
Original file line number Diff line number Diff line change @@ -160,6 +160,28 @@ def type(self) -> MSO_FILL_TYPE:
160160 """The type of this fill, e.g. `MSO_FILL_TYPE.SOLID`."""
161161 return self ._fill .type
162162
163+ @property
164+ def value (self ):
165+ """Return a value appropriate to the fill type.
166+
167+ For solid fills, returns the foreground color.
168+ For pattern fills, returns the pattern type.
169+ For gradient fills, returns the gradient stops.
170+ For picture fills, returns "Picture".
171+ For group fills, returns "Group".
172+ For background (no fill), returns "Background".
173+ Returns None if no fill is applied.
174+ """
175+ if self .type == MSO_FILL .SOLID :
176+ return self .fore_color .value
177+ elif self .type == MSO_FILL .PATTERNED or self .type == MSO_FILL .TEXTURED :
178+ return "Texture"
179+ elif self .type == MSO_FILL .GRADIENT :
180+ return "GradientColor"
181+ elif self .type == MSO_FILL .PICTURE :
182+ return "Picture"
183+ return None
184+
163185
164186class _Fill (object ):
165187 """
Original file line number Diff line number Diff line change @@ -353,14 +353,9 @@ def bold(self, value: bool | None):
353353 self ._rPr .b = value
354354
355355 @lazyproperty
356- def color (self ) -> ColorFormat :
356+ def color (self ) -> str | None :
357357 """The |ColorFormat| instance that provides access to the color settings for this font."""
358- if self .fill .type != MSO_FILL .SOLID :
359- self .fill .solid ()
360- try :
361- return str (self .fill .fore_color .rgb )
362- except :
363- return None
358+ return self .fill .value
364359
365360 @lazyproperty
366361 def fill (self ) -> FillFormat :
You can’t perform that action at this time.
0 commit comments