def line_height(self) -> Union[float, Emu, None]: ln_spc_spc_pct = first_or_none( self.xml.xpath('a:lnSpc[1]/a:spcPct[1]', namespaces=pptx_xml_ns)) if ln_spc_spc_pct is not None: val_str = ln_spc_spc_pct.get('val') if val_str is not None: return int(val_str) ln_spc_spc_pts = first_or_none( self.xml.xpath('a:lnSpc[1]/a:spcPts[1]', namespaces=pptx_xml_ns)) if ln_spc_spc_pts is not None: val_str = ln_spc_spc_pct.get('val') if val_str is not None: return float(val_str) if self.do_use_defaults_when_null: return self._default_line_height return None
def _parse_alpha(clr_xml: ElementTree) -> float: alpha_el = first_or_none( clr_xml.xpath('a:alpha[1]', namespaces=pptx_xml_ns)) if alpha_el is None: return 1 alpha_str = alpha_el.attrib['val'] return int(alpha_str) / 100000
def margin_bottom(self) -> Optional[Emu]: spc_aft_spc_pts = first_or_none( self.xml.xpath('a:spcAft[1]/a:spcPts[1]', namespaces=pptx_xml_ns)) if spc_aft_spc_pts is not None: val = spc_aft_spc_pts.get('val') if val is not None: return Emu.from_centripoints(val) if self.do_use_defaults_when_null: return self._default_margin_bottom return None
def _get_color(self) -> Optional[Color]: # find xml fill_xml = self._get_elem( 'a:solidFill', do_recursive_find=self.do_use_defaults_when_null) if fill_xml is not None: clr_xml = first_or_none(list(fill_xml)) if clr_xml is not None: color_resolver = self.paragraph.text_frame.shape.color_maker return color_resolver.make_color(clr_xml) # use theme if self.do_use_defaults_when_null: theme = self.paragraph.text_frame.shape.slide.theme return CustomSetColor(theme.color_rgbs['tx1']) return None
def _solid_fill(self) -> Optional[ElementTree]: return first_or_none( self.xml.xpath('p:spPr[1]/a:solidFill[1]', namespaces=pptx_xml_ns))
def _gs_lst(self) -> Optional[ElementTree]: if self._grad_fill is None: return None return first_or_none( self._grad_fill.xpath('a:gsLst[1]', namespaces=pptx_xml_ns))
def _xfrm_ch_off(self) -> Optional[ElementTree]: if self._xfrm is None: return None return first_or_none( self._xfrm.xpath('a:chOff[1]', namespaces=pptx_xml_ns))
def _tx_body(self) -> Optional[ElementTree]: return first_or_none( self.xml.xpath('p:txBody[1]', namespaces=pptx_xml_ns))
def _xfrm(self) -> Optional[ElementTree]: if self._sp_pr is None: return None return first_or_none( self._sp_pr.xpath('a:xfrm[1]', namespaces=pptx_xml_ns))
def _sp_pr(self) -> Optional[ElementTree]: return first_or_none( self.xml.xpath(f'p:{self._sp_pr_name}[1]', namespaces=pptx_xml_ns))
def _path(self) -> ElementTree: return first_or_none(self.xml.xpath('p:spPr[1]/a:custGeom[1]/a:pathLst[1]/a:path[1]'))
def _body_pr(self) -> Optional[ElementTree]: return first_or_none( self.xml.xpath('a:bodyPr[1]', namespaces=pptx_xml_ns))
def _list_def_r_pr(self) -> Optional[ElementTree]: return first_or_none( self.xml.xpath('a:lstStyle[1]/a:lvl1pPr[1]/a:defRPr[1]', namespaces=pptx_xml_ns))
def _def_r_pr(self) -> Optional[ElementTree]: if self._p_pr is None: return None return first_or_none( self._p_pr.xpath('a:defRPr[1]', namespaces=pptx_xml_ns))
def _sld_sz(self) -> Optional[ElementTree]: return first_or_none( self.xml.xpath('p:sldSz[1]', namespaces=pptx_xml_ns))
def find(): return first_or_none(self.xml.xpath('p:cSld[1]/p:spTree[1]', namespaces=pptx_xml_ns))
def _c_nv_pr(self) -> Optional[ElementTree]: return first_or_none( self.xml.xpath('.//p:cNvPr[1]', namespaces=pptx_xml_ns))
def _src_rect(self) -> Optional[ElementTree]: return first_or_none(self._blip_fill.xpath('a:srcRect[1]', namespaces=pptx_xml_ns))