예제 #1
0
 def add_sldId(self, rId):
     """
     Return a reference to a newly created <p:sldId> child element having
     its r:id attribute set to *rId*.
     """
     sldId = SubElement(self, 'p:sldId', id=self._next_id)
     sldId.set(qn('r:id'), rId)
     return sldId
예제 #2
0
    def new_placeholder_sp(id_, name, ph_type, orient, sz, idx):
        """
        Return a new ``<p:sp>`` element tree configured as a placeholder
        shape.
        """
        xml = CT_Shape._ph_sp_tmpl % (id_, name)
        sp = parse_xml_bytes(xml)

        # placeholder shapes get a "no group" lock
        SubElement(sp.nvSpPr.cNvSpPr, 'a:spLocks')
        sp.nvSpPr.cNvSpPr[qn('a:spLocks')].set('noGrp', '1')

        # placeholder (ph) element attributes values vary by type
        ph = SubElement(sp.nvSpPr.nvPr, 'p:ph')
        if ph_type != PH_TYPE_OBJ:
            ph.set('type', ph_type)
        if orient != PH_ORIENT_HORZ:
            ph.set('orient', orient)
        if sz != PH_SZ_FULL:
            ph.set('sz', sz)
        if idx != 0:
            ph.set('idx', str(idx))

        placeholder_types_that_have_a_text_frame = (
            PH_TYPE_TITLE, PH_TYPE_CTRTITLE, PH_TYPE_SUBTITLE, PH_TYPE_BODY,
            PH_TYPE_OBJ)

        if ph_type in placeholder_types_that_have_a_text_frame:
            sp.append(CT_TextBody.new_txBody())

        objectify.deannotate(sp, cleanup_namespaces=True)
        return sp
예제 #3
0
 def rewrite_guides(self, guides):
     """
     Remove any ``<a:gd>`` element children of ``<a:avLst>`` and replace
     them with ones having (name, val) in *guides*.
     """
     try:
         avLst = self.avLst
     except AttributeError:
         avLst = SubElement(self, 'a:avLst')
     if hasattr(self.avLst, 'gd'):
         for gd_elm in self.avLst.gd[:]:
             avLst.remove(gd_elm)
     for name, val in guides:
         gd = SubElement(avLst, 'a:gd')
         gd.set('name', name)
         gd.set('fmla', 'val %d' % val)