Esempio n. 1
0
 def coreProperties(self):
     if self.props_xml:
         coreProperties = (
             '<cp:coreProperties %s>\n%s</cp:coreProperties>\n' %
             (nsdecls(*self._ns_prefixes), self.props_xml))
     else:
         coreProperties = ('<cp:coreProperties %s/>\n' %
                           nsdecls('cp', 'dc', 'dcterms'))
     return coreProperties
Esempio n. 2
0
 def coreProperties(self):
     if self.props_xml:
         coreProperties = (
             '<cp:coreProperties %s>\n%s</cp:coreProperties>\n' %
             (nsdecls(*self._ns_prefixes), self.props_xml)
         )
     else:
         coreProperties = (
             '<cp:coreProperties %s/>\n' % nsdecls('cp', 'dc', 'dcterms')
         )
     return coreProperties
Esempio n. 3
0
 def _pic_tmpl(cls):
     return ("<p:pic %s>\n"
             "  <p:nvPicPr>\n"
             '    <p:cNvPr id="%%d" name="%%s" descr="%%s"/>\n'
             "    <p:cNvPicPr>\n"
             '      <a:picLocks noChangeAspect="1"/>\n'
             "    </p:cNvPicPr>\n"
             "    <p:nvPr/>\n"
             "  </p:nvPicPr>\n"
             "  <p:blipFill>\n"
             '    <a:blip r:embed="%%s"/>\n'
             "    <a:stretch>\n"
             "      <a:fillRect/>\n"
             "    </a:stretch>\n"
             "  </p:blipFill>\n"
             "  <p:spPr>\n"
             "    <a:xfrm>\n"
             '      <a:off x="%%d" y="%%d"/>\n'
             '      <a:ext cx="%%d" cy="%%d"/>\n'
             "    </a:xfrm>\n"
             '    <a:prstGeom prst="rect">\n'
             "      <a:avLst/>\n"
             "    </a:prstGeom>\n"
             "  </p:spPr>\n"
             "</p:pic>" % nsdecls("a", "p", "r"))
Esempio n. 4
0
 def _a_txBody_tmpl(cls):
     return (
         "<a:txBody %s>\n"
         "  <a:bodyPr/>\n"
         "  <a:p/>\n"
         "</a:txBody>\n" % (nsdecls("a"))
     )
Esempio n. 5
0
    def it_can_create_a_new_pic_element(self, desc, xml_desc):
        """`desc` attr (often filename) is XML-escaped to handle special characters.

        In particular, ampersand ('&'), less/greater-than ('</>') etc.
        """
        pic = CT_Picture.new_pic(
            shape_id=9, name="Picture 8", desc=desc, rId="rId42", x=1, y=2, cx=3, cy=4
        )

        assert pic.xml == (
            "<p:pic %s>\n"
            "  <p:nvPicPr>\n"
            '    <p:cNvPr id="9" name="Picture 8" descr="%s"/>\n'
            "    <p:cNvPicPr>\n"
            '      <a:picLocks noChangeAspect="1"/>\n'
            "    </p:cNvPicPr>\n"
            "    <p:nvPr/>\n"
            "  </p:nvPicPr>\n"
            "  <p:blipFill>\n"
            '    <a:blip r:embed="rId42"/>\n'
            "    <a:stretch>\n"
            "      <a:fillRect/>\n"
            "    </a:stretch>\n"
            "  </p:blipFill>\n"
            "  <p:spPr>\n"
            "    <a:xfrm>\n"
            '      <a:off x="1" y="2"/>\n'
            '      <a:ext cx="3" cy="4"/>\n'
            "    </a:xfrm>\n"
            '    <a:prstGeom prst="rect">\n'
            "      <a:avLst/>\n"
            "    </a:prstGeom>\n"
            "  </p:spPr>\n"
            "</p:pic>\n" % (nsdecls("a", "p", "r"), xml_desc)
        )
Esempio n. 6
0
 def setUp(self):
     tbl_xml = (
         '<a:tbl %s><a:tblGrid><a:gridCol w="3048000"/><a:gridCol w="30480'
         '00"/></a:tblGrid></a:tbl>' % nsdecls('a')
     )
     test_tbl_elm = parse_xml_bytes(tbl_xml)
     self.columns = _ColumnCollection(test_tbl_elm, Mock(name='table'))
Esempio n. 7
0
 def setUp(self):
     tr_xml = (
         '<a:tr %s h="370840"><a:tc><a:txBody><a:p/></a:txBody></a:tc><a:t'
         'c><a:txBody><a:p/></a:txBody></a:tc></a:tr>' % nsdecls('a')
     )
     test_tr_elm = parse_xml_bytes(tr_xml)
     self.row = _Row(test_tr_elm, Mock(name='table'))
Esempio n. 8
0
    def new_dLbl(cls):
        """Return a newly created "loose" `c:dLbl` element.

        The `c:dLbl` element contains the same (fairly extensive) default
        subtree added by PowerPoint when an individual data label is
        customized in the UI. Note that the idx value must be set by the
        client. Failure to set the idx value will likely result in any
        changes not being visible and may result in a repair error on open.
        """
        return parse_xml(
            "<c:dLbl %s>\n"
            '  <c:idx val="666"/>\n'
            "  <c:spPr/>\n"
            "  <c:txPr>\n"
            "    <a:bodyPr/>\n"
            "    <a:lstStyle/>\n"
            "    <a:p>\n"
            "      <a:pPr>\n"
            "        <a:defRPr/>\n"
            "      </a:pPr>\n"
            "    </a:p>\n"
            "  </c:txPr>\n"
            '  <c:showLegendKey val="0"/>\n'
            '  <c:showVal val="1"/>\n'
            '  <c:showCatName val="0"/>\n'
            '  <c:showSerName val="0"/>\n'
            '  <c:showPercent val="0"/>\n'
            '  <c:showBubbleSize val="0"/>\n'
            "</c:dLbl>" % nsdecls("c", "a")
        )
Esempio n. 9
0
 def pic_fixture(self):
     shape_id, name, desc, rId = 9, "Diam. > 1 mm", "desc", "rId1"
     x, y, cx, cy = 1, 2, 3, 4
     expected_xml = (
         '<p:pic %s>\n  <p:nvPicPr>\n    <p:cNvPr id="%d" name="%s" descr'
         '="%s"/>\n    <p:cNvPicPr>\n      <a:picLocks noChangeAspect="1"'
         "/>\n    </p:cNvPicPr>\n    <p:nvPr/>\n  </p:nvPicPr>\n  <p:blip"
         'Fill>\n    <a:blip r:embed="%s"/>\n    <a:stretch>\n      <a:fi'
         "llRect/>\n    </a:stretch>\n  </p:blipFill>\n  <p:spPr>\n    <a"
         ':xfrm>\n      <a:off x="%d" y="%d"/>\n      <a:ext cx="%d" cy="'
         '%d"/>\n    </a:xfrm>\n    <a:prstGeom prst="rect">\n      <a:av'
         "Lst/>\n    </a:prstGeom>\n  </p:spPr>\n</p:pic>\n"
         % (
             nsdecls("a", "p", "r"),
             shape_id,
             "Diam. &gt; 1 mm",
             desc,
             rId,
             x,
             y,
             cx,
             cy,
         )
     )
     return shape_id, name, desc, rId, x, y, cx, cy, expected_xml
Esempio n. 10
0
def create_footer(slide, footercopy):
    footer = None
    pageno = None
    for shape in slide.placeholders:
        if "SLIDE_NUMBER" in str(shape.placeholder_format.type
                                 ):  # Master must have placeholder to function
            pageno = slide.placeholders[shape.placeholder_format.idx]
        elif "FOOTER" in str(shape.placeholder_format.type
                             ):  # Master must have placeholder to function
            footer = slide.placeholders[shape.placeholder_format.idx]

    footer_text_frame = footer.text_frame
    footer_pageno = pageno.text_frame.paragraphs[0]._p
    # edits XML directly—not ideal, but can't be updated until Python-pptx adds support.
    fld_xml = (
        '<a:fld %s id="{1F4E2DE4-8ADA-4D4E-9951-90A1D26586E7}" type="slidenum">\n'
        '  <a:rPr lang="en-US" smtClean="0"/>\n'
        '  <a:t>2</a:t>\n'
        '</a:fld>\n' % nsdecls("a"))
    fld = parse_xml(fld_xml)
    footer_pageno.append(fld)
    footer_a = 'Note: Due to small base, data is directional'

    for para_idx, para in enumerate(footercopy):
        new_para = para.replace("'", "", -1)
        footercopy[para_idx] = new_para

    insert_text(footercopy, footer_text_frame, one_level=True)
Esempio n. 11
0
 def test_new_tbl_generates_correct_xml(self):
     """CT_Table._new_tbl() returns correct XML"""
     # setup ------------------------
     rows, cols = 2, 3
     width, height = 334, 445
     xml = (
         '<a:tbl %s>\n  <a:tblPr firstRow="1" bandRow="1">\n    <a:tableSt'
         'yleId>{5C22544A-7EE6-4342-B048-85BDC9FD1C3A}</a:tableStyleId>\n '
         ' </a:tblPr>\n  <a:tblGrid>\n    <a:gridCol w="111"/>\n    <a:gri'
         'dCol w="111"/>\n    <a:gridCol w="112"/>\n  </a:tblGrid>\n  <a:t'
         'r h="222">\n    <a:tc>\n      <a:txBody>\n        <a:bodyPr/>\n '
         '       <a:lstStyle/>\n        <a:p/>\n      </a:txBody>\n      <'
         'a:tcPr/>\n    </a:tc>\n    <a:tc>\n      <a:txBody>\n        <a:'
         'bodyPr/>\n        <a:lstStyle/>\n        <a:p/>\n      </a:txBod'
         'y>\n      <a:tcPr/>\n    </a:tc>\n    <a:tc>\n      <a:txBody>\n'
         '        <a:bodyPr/>\n        <a:lstStyle/>\n        <a:p/>\n    '
         '  </a:txBody>\n      <a:tcPr/>\n    </a:tc>\n  </a:tr>\n  <a:tr '
         'h="223">\n    <a:tc>\n      <a:txBody>\n        <a:bodyPr/>\n   '
         '     <a:lstStyle/>\n        <a:p/>\n      </a:txBody>\n      <a:'
         'tcPr/>\n    </a:tc>\n    <a:tc>\n      <a:txBody>\n        <a:bo'
         'dyPr/>\n        <a:lstStyle/>\n        <a:p/>\n      </a:txBody>'
         '\n      <a:tcPr/>\n    </a:tc>\n    <a:tc>\n      <a:txBody>\n  '
         '      <a:bodyPr/>\n        <a:lstStyle/>\n        <a:p/>\n      '
         '</a:txBody>\n      <a:tcPr/>\n    </a:tc>\n  </a:tr>\n</a:tbl>\n'
         % nsdecls('a')
     )
     # exercise ---------------------
     tbl = CT_Table.new_tbl(rows, cols, width, height)
     # verify -----------------------
     self.assertEqualLineByLine(xml, tbl)
Esempio n. 12
0
 def new_ph_sp_fixture(self, request):
     id_, name, ph_type, orient, sz, idx, expected_attrs = request.param
     expected_xml_tmpl = ('<p:sp %s>\n'
                          '  <p:nvSpPr>\n'
                          '    <p:cNvPr id="%s" name="%s"/>\n'
                          '    <p:cNvSpPr>\n'
                          '      <a:spLocks noGrp="1"/>\n'
                          '    </p:cNvSpPr>\n'
                          '    <p:nvPr>\n'
                          '      <p:ph%s/>\n'
                          '    </p:nvPr>\n'
                          '  </p:nvSpPr>\n'
                          '  <p:spPr/>\n'
                          '%s'
                          '</p:sp>\n' %
                          (nsdecls('a', 'p'), '%d', '%s', '%s', '%s'))
     txBody_snippet = ('  <p:txBody>\n'
                       '    <a:bodyPr/>\n'
                       '    <a:lstStyle/>\n'
                       '    <a:p/>\n'
                       '  </p:txBody>\n')
     txBody_str = txBody_snippet if id_ in (2, 4, 8) else ''
     expected_values = (id_, name, expected_attrs, txBody_str)
     expected_xml = expected_xml_tmpl % expected_values
     return id_, name, ph_type, orient, sz, idx, expected_xml
Esempio n. 13
0
 def _textbox_sp_tmpl():
     return (
         "<p:sp %s>\n"
         "  <p:nvSpPr>\n"
         '    <p:cNvPr id="%s" name="%s"/>\n'
         '    <p:cNvSpPr txBox="1"/>\n'
         "    <p:nvPr/>\n"
         "  </p:nvSpPr>\n"
         "  <p:spPr>\n"
         "    <a:xfrm>\n"
         '      <a:off x="%s" y="%s"/>\n'
         '      <a:ext cx="%s" cy="%s"/>\n'
         "    </a:xfrm>\n"
         '    <a:prstGeom prst="rect">\n'
         "      <a:avLst/>\n"
         "    </a:prstGeom>\n"
         "    <a:noFill/>\n"
         "  </p:spPr>\n"
         "  <p:txBody>\n"
         '    <a:bodyPr wrap="none">\n'
         "      <a:spAutoFit/>\n"
         "    </a:bodyPr>\n"
         "    <a:lstStyle/>\n"
         "    <a:p/>\n"
         "  </p:txBody>\n"
         "</p:sp>" % (nsdecls("a", "p"), "%d", "%s", "%d", "%d", "%d", "%d")
     )
 def new_ph_sp_fixture(self, request):
     id_, name, ph_type, orient, sz, idx, expected_attrs = request.param
     expected_xml_tmpl = ("<p:sp %s>\n"
                          "  <p:nvSpPr>\n"
                          '    <p:cNvPr id="%s" name="%s"/>\n'
                          "    <p:cNvSpPr>\n"
                          '      <a:spLocks noGrp="1"/>\n'
                          "    </p:cNvSpPr>\n"
                          "    <p:nvPr>\n"
                          "      <p:ph%s/>\n"
                          "    </p:nvPr>\n"
                          "  </p:nvSpPr>\n"
                          "  <p:spPr/>\n"
                          "%s"
                          "</p:sp>\n" %
                          (nsdecls("a", "p"), "%d", "%s", "%s", "%s"))
     txBody_snippet = ("  <p:txBody>\n"
                       "    <a:bodyPr/>\n"
                       "    <a:lstStyle/>\n"
                       "    <a:p/>\n"
                       "  </p:txBody>\n")
     txBody_str = txBody_snippet if id_ in (2, 4, 8) else ""
     expected_values = (id_, name, expected_attrs, txBody_str)
     expected_xml = expected_xml_tmpl % expected_values
     return id_, name, ph_type, orient, sz, idx, expected_xml
Esempio n. 15
0
 def it_can_create_a_new_tbl_element_tree(self):
     """
     Indirectly tests that column widths are a proportional split of total
     width and that row heights a proportional split of total height.
     """
     expected_xml = (
         '<a:tbl %s>\n  <a:tblPr firstRow="1" bandRow="1">\n    <a:tableSt'
         'yleId>{5C22544A-7EE6-4342-B048-85BDC9FD1C3A}</a:tableStyleId>\n '
         ' </a:tblPr>\n  <a:tblGrid>\n    <a:gridCol w="111"/>\n    <a:gri'
         'dCol w="111"/>\n    <a:gridCol w="112"/>\n  </a:tblGrid>\n  <a:t'
         'r h="222">\n    <a:tc>\n      <a:txBody>\n        <a:bodyPr/>\n '
         '       <a:lstStyle/>\n        <a:p/>\n      </a:txBody>\n      <'
         'a:tcPr/>\n    </a:tc>\n    <a:tc>\n      <a:txBody>\n        <a:'
         'bodyPr/>\n        <a:lstStyle/>\n        <a:p/>\n      </a:txBod'
         'y>\n      <a:tcPr/>\n    </a:tc>\n    <a:tc>\n      <a:txBody>\n'
         '        <a:bodyPr/>\n        <a:lstStyle/>\n        <a:p/>\n    '
         '  </a:txBody>\n      <a:tcPr/>\n    </a:tc>\n  </a:tr>\n  <a:tr '
         'h="223">\n    <a:tc>\n      <a:txBody>\n        <a:bodyPr/>\n   '
         '     <a:lstStyle/>\n        <a:p/>\n      </a:txBody>\n      <a:'
         'tcPr/>\n    </a:tc>\n    <a:tc>\n      <a:txBody>\n        <a:bo'
         'dyPr/>\n        <a:lstStyle/>\n        <a:p/>\n      </a:txBody>'
         '\n      <a:tcPr/>\n    </a:tc>\n    <a:tc>\n      <a:txBody>\n  '
         '      <a:bodyPr/>\n        <a:lstStyle/>\n        <a:p/>\n      '
         '</a:txBody>\n      <a:tcPr/>\n    </a:tc>\n  </a:tr>\n</a:tbl>\n'
         % nsdecls('a')
     )
     tbl = CT_Table.new_tbl(2, 3, 334, 445)
     assert tbl.xml == expected_xml
Esempio n. 16
0
 def _p_txBody_tmpl(cls):
     return (
         "<p:txBody %s>\n"
         "  <a:bodyPr/>\n"
         "  <a:p/>\n"
         "</p:txBody>\n" % (nsdecls("p", "a"))
     )
Esempio n. 17
0
 def setUp(self):
     tr_xml = (
         '<a:tr %s h="370840"><a:tc><a:txBody><a:p/></a:txBody></a:tc><a:t'
         'c><a:txBody><a:p/></a:txBody></a:tc></a:tr>' % nsdecls('a')
     )
     test_tr_elm = parse_xml_bytes(tr_xml)
     self.row = _Row(test_tr_elm, Mock(name='table'))
 def it_knows_how_to_create_a_new_autoshape_sp(self):
     # setup ------------------------
     id_ = 9
     name = "Rounded Rectangle 8"
     prst = "roundRect"
     left, top, width, height = 111, 222, 333, 444
     xml = (
         '<p:sp %s>\n  <p:nvSpPr>\n    <p:cNvPr id="%d" name="%s"/>\n    <'
         "p:cNvSpPr/>\n    <p:nvPr/>\n  </p:nvSpPr>\n  <p:spPr>\n    <a:xf"
         'rm>\n      <a:off x="%d" y="%d"/>\n      <a:ext cx="%d" cy="%d"/'
         '>\n    </a:xfrm>\n    <a:prstGeom prst="%s">\n      <a:avLst/>\n'
         '    </a:prstGeom>\n  </p:spPr>\n  <p:style>\n    <a:lnRef idx="1'
         '">\n      <a:schemeClr val="accent1"/>\n    </a:lnRef>\n    <a:f'
         'illRef idx="3">\n      <a:schemeClr val="accent1"/>\n    </a:fil'
         'lRef>\n    <a:effectRef idx="2">\n      <a:schemeClr val="accent'
         '1"/>\n    </a:effectRef>\n    <a:fontRef idx="minor">\n      <a:'
         'schemeClr val="lt1"/>\n    </a:fontRef>\n  </p:style>\n  <p:txBo'
         'dy>\n    <a:bodyPr rtlCol="0" anchor="ctr"/>\n    <a:lstStyle/>'
         '\n    <a:p>\n      <a:pPr algn="ctr"/>\n    </a:p>\n  </p:txBody'
         ">\n</p:sp>\n" %
         (nsdecls("a", "p"), id_, name, left, top, width, height, prst))
     # exercise ---------------------
     sp = CT_Shape.new_autoshape_sp(id_, name, prst, left, top, width,
                                    height)
     # verify -----------------------
     assert sp.xml == xml
Esempio n. 19
0
 def new_ph_sp_fixture(self, request):
     id_, name, ph_type, orient, sz, idx, expected_attrs = request.param
     expected_xml_tmpl = (
         '<p:sp %s>\n'
         '  <p:nvSpPr>\n'
         '    <p:cNvPr id="%s" name="%s"/>\n'
         '    <p:cNvSpPr>\n'
         '      <a:spLocks noGrp="1"/>\n'
         '    </p:cNvSpPr>\n'
         '    <p:nvPr>\n'
         '      <p:ph%s/>\n'
         '    </p:nvPr>\n'
         '  </p:nvSpPr>\n'
         '  <p:spPr/>\n'
         '%s'
         '</p:sp>\n' % (nsdecls('a', 'p'), '%d', '%s', '%s', '%s')
     )
     txBody_snippet = (
         '  <p:txBody>\n'
         '    <a:bodyPr/>\n'
         '    <a:lstStyle/>\n'
         '    <a:p/>\n'
         '  </p:txBody>\n'
     )
     txBody_str = txBody_snippet if id_ in (2, 4, 8) else ''
     expected_values = (id_, name, expected_attrs, txBody_str)
     expected_xml = expected_xml_tmpl % expected_values
     return id_, name, ph_type, orient, sz, idx, expected_xml
Esempio n. 20
0
 def test_new_tbl_generates_correct_xml(self):
     """CT_Table._new_tbl() returns correct XML"""
     # setup ------------------------
     rows, cols = 2, 3
     width, height = 334, 445
     xml = (
         '<a:tbl %s>\n  <a:tblPr firstRow="1" bandRow="1">\n    <a:tableSt'
         'yleId>{5C22544A-7EE6-4342-B048-85BDC9FD1C3A}</a:tableStyleId>\n '
         ' </a:tblPr>\n  <a:tblGrid>\n    <a:gridCol w="111"/>\n    <a:gri'
         'dCol w="111"/>\n    <a:gridCol w="112"/>\n  </a:tblGrid>\n  <a:t'
         'r h="222">\n    <a:tc>\n      <a:txBody>\n        <a:bodyPr/>\n '
         '       <a:lstStyle/>\n        <a:p/>\n      </a:txBody>\n      <'
         'a:tcPr/>\n    </a:tc>\n    <a:tc>\n      <a:txBody>\n        <a:'
         'bodyPr/>\n        <a:lstStyle/>\n        <a:p/>\n      </a:txBod'
         'y>\n      <a:tcPr/>\n    </a:tc>\n    <a:tc>\n      <a:txBody>\n'
         '        <a:bodyPr/>\n        <a:lstStyle/>\n        <a:p/>\n    '
         '  </a:txBody>\n      <a:tcPr/>\n    </a:tc>\n  </a:tr>\n  <a:tr '
         'h="223">\n    <a:tc>\n      <a:txBody>\n        <a:bodyPr/>\n   '
         '     <a:lstStyle/>\n        <a:p/>\n      </a:txBody>\n      <a:'
         'tcPr/>\n    </a:tc>\n    <a:tc>\n      <a:txBody>\n        <a:bo'
         'dyPr/>\n        <a:lstStyle/>\n        <a:p/>\n      </a:txBody>'
         '\n      <a:tcPr/>\n    </a:tc>\n    <a:tc>\n      <a:txBody>\n  '
         '      <a:bodyPr/>\n        <a:lstStyle/>\n        <a:p/>\n      '
         '</a:txBody>\n      <a:tcPr/>\n    </a:tc>\n  </a:tr>\n</a:tbl>\n'
         % nsdecls('a'))
     # exercise ---------------------
     tbl = CT_Table.new_tbl(rows, cols, width, height)
     # verify -----------------------
     self.assertEqualLineByLine(xml, tbl)
Esempio n. 21
0
 def textbox(self):
     """Generic text box XML"""
     return ('<p:sp %s>\n'
             '  <p:nvSpPr>\n'
             '    <p:cNvPr id="9" name="TextBox 8"/>\n'
             '    <p:cNvSpPr txBox="1"/>\n'
             '    <p:nvPr/>\n'
             '  </p:nvSpPr>\n'
             '  <p:spPr>\n'
             '    <a:xfrm>\n'
             '      <a:off x="111" y="222"/>\n'
             '      <a:ext cx="333" cy="444"/>\n'
             '    </a:xfrm>\n'
             '    <a:prstGeom prst="rect">\n'
             '      <a:avLst/>\n'
             '    </a:prstGeom>\n'
             '    <a:noFill/>\n'
             '  </p:spPr>\n'
             '  <p:txBody>\n'
             '    <a:bodyPr wrap="none">\n'
             '      <a:spAutoFit/>\n'
             '    </a:bodyPr>\n'
             '    <a:lstStyle/>\n'
             '    <a:p/>\n'
             '  </p:txBody>\n'
             '</p:sp>' % nsdecls('a', 'p'))
Esempio n. 22
0
 def textbox(self):
     """Generic text box XML"""
     return (
         '<p:sp %s>\n'
         '  <p:nvSpPr>\n'
         '    <p:cNvPr id="9" name="TextBox 8"/>\n'
         '    <p:cNvSpPr txBox="1"/>\n'
         '    <p:nvPr/>\n'
         '  </p:nvSpPr>\n'
         '  <p:spPr>\n'
         '    <a:xfrm>\n'
         '      <a:off x="111" y="222"/>\n'
         '      <a:ext cx="333" cy="444"/>\n'
         '    </a:xfrm>\n'
         '    <a:prstGeom prst="rect">\n'
         '      <a:avLst/>\n'
         '    </a:prstGeom>\n'
         '    <a:noFill/>\n'
         '  </p:spPr>\n'
         '  <p:txBody>\n'
         '    <a:bodyPr wrap="none">\n'
         '      <a:spAutoFit/>\n'
         '    </a:bodyPr>\n'
         '    <a:lstStyle/>\n'
         '    <a:p/>\n'
         '  </p:txBody>\n'
         '</p:sp>' % nsdecls('a', 'p')
     )
Esempio n. 23
0
 def it_knows_how_to_create_a_new_autoshape_sp(self):
     # setup ------------------------
     id_ = 9
     name = "Rounded Rectangle 8"
     prst = "roundRect"
     left, top, width, height = 111, 222, 333, 444
     xml = (
         '<p:sp %s>\n  <p:nvSpPr>\n    <p:cNvPr id="%d" name="%s"/>\n    <'
         "p:cNvSpPr/>\n    <p:nvPr/>\n  </p:nvSpPr>\n  <p:spPr>\n    <a:xf"
         'rm>\n      <a:off x="%d" y="%d"/>\n      <a:ext cx="%d" cy="%d"/'
         '>\n    </a:xfrm>\n    <a:prstGeom prst="%s">\n      <a:avLst/>\n'
         '    </a:prstGeom>\n  </p:spPr>\n  <p:style>\n    <a:lnRef idx="1'
         '">\n      <a:schemeClr val="accent1"/>\n    </a:lnRef>\n    <a:f'
         'illRef idx="3">\n      <a:schemeClr val="accent1"/>\n    </a:fil'
         'lRef>\n    <a:effectRef idx="2">\n      <a:schemeClr val="accent'
         '1"/>\n    </a:effectRef>\n    <a:fontRef idx="minor">\n      <a:'
         'schemeClr val="lt1"/>\n    </a:fontRef>\n  </p:style>\n  <p:txBo'
         'dy>\n    <a:bodyPr rtlCol="0" anchor="ctr"/>\n    <a:lstStyle/>'
         '\n    <a:p>\n      <a:pPr algn="ctr"/>\n    </a:p>\n  </p:txBody'
         ">\n</p:sp>\n"
         % (nsdecls("a", "p"), id_, name, left, top, width, height, prst)
     )
     # exercise ---------------------
     sp = CT_Shape.new_autoshape_sp(id_, name, prst, left, top, width, height)
     # verify -----------------------
     assert sp.xml == xml
Esempio n. 24
0
 def new_ph_sp_fixture(self, request):
     id_, name, ph_type, orient, sz, idx, expected_attrs = request.param
     expected_xml_tmpl = (
         "<p:sp %s>\n"
         "  <p:nvSpPr>\n"
         '    <p:cNvPr id="%s" name="%s"/>\n'
         "    <p:cNvSpPr>\n"
         '      <a:spLocks noGrp="1"/>\n'
         "    </p:cNvSpPr>\n"
         "    <p:nvPr>\n"
         "      <p:ph%s/>\n"
         "    </p:nvPr>\n"
         "  </p:nvSpPr>\n"
         "  <p:spPr/>\n"
         "%s"
         "</p:sp>\n" % (nsdecls("a", "p"), "%d", "%s", "%s", "%s")
     )
     txBody_snippet = (
         "  <p:txBody>\n"
         "    <a:bodyPr/>\n"
         "    <a:lstStyle/>\n"
         "    <a:p/>\n"
         "  </p:txBody>\n"
     )
     txBody_str = txBody_snippet if id_ in (2, 4, 8) else ""
     expected_values = (id_, name, expected_attrs, txBody_str)
     expected_xml = expected_xml_tmpl % expected_values
     return id_, name, ph_type, orient, sz, idx, expected_xml
Esempio n. 25
0
 def setUp(self):
     tr_xml = (
         '<a:tr %s h="370840"><a:tc><a:txBody><a:p/></a:txBody></a:tc><a:t'
         'c><a:txBody><a:p/></a:txBody></a:tc></a:tr>' % nsdecls('a')
     )
     test_tr_elm = parse_xml_bytes(tr_xml)
     self.cells = _CellCollection(test_tr_elm, None)
Esempio n. 26
0
 def setUp(self):
     tr_xml = (
         '<a:tr %s h="370840"><a:tc><a:txBody><a:p/></a:txBody></a:tc><a:t'
         'c><a:txBody><a:p/></a:txBody></a:tc></a:tr>' % nsdecls('a')
     )
     test_tr_elm = parse_xml_bytes(tr_xml)
     self.cells = _CellCollection(test_tr_elm, None)
Esempio n. 27
0
 def _textbox_sp_tmpl():
     return ('<p:sp %s>\n'
             '  <p:nvSpPr>\n'
             '    <p:cNvPr id="%s" name="%s"/>\n'
             '    <p:cNvSpPr txBox="1"/>\n'
             '    <p:nvPr/>\n'
             '  </p:nvSpPr>\n'
             '  <p:spPr>\n'
             '    <a:xfrm>\n'
             '      <a:off x="%s" y="%s"/>\n'
             '      <a:ext cx="%s" cy="%s"/>\n'
             '    </a:xfrm>\n'
             '    <a:prstGeom prst="rect">\n'
             '      <a:avLst/>\n'
             '    </a:prstGeom>\n'
             '    <a:noFill/>\n'
             '  </p:spPr>\n'
             '  <p:txBody>\n'
             '    <a:bodyPr wrap="none">\n'
             '      <a:spAutoFit/>\n'
             '    </a:bodyPr>\n'
             '    <a:lstStyle/>\n'
             '    <a:p/>\n'
             '  </p:txBody>\n'
             '</p:sp>' %
             (nsdecls('a', 'p'), '%d', '%s', '%d', '%d', '%d', '%d'))
Esempio n. 28
0
 def setUp(self):
     tbl_xml = (
         '<a:tbl %s><a:tblGrid><a:gridCol w="3048000"/><a:gridCol w="30480'
         '00"/></a:tblGrid></a:tbl>' % nsdecls('a')
     )
     test_tbl_elm = parse_xml_bytes(tbl_xml)
     self.columns = _ColumnCollection(test_tbl_elm, Mock(name='table'))
Esempio n. 29
0
 def _new_bgClr(self):
     """Override default to add minimum subtree."""
     xml = ("<a:bgClr %s>\n"
            ' <a:srgbClr val="FFFFFF"/>\n'
            "</a:bgClr>\n") % nsdecls("a")
     bgClr = parse_xml(xml)
     return bgClr
Esempio n. 30
0
 def test_new_autoshape_sp_generates_correct_xml(self):
     """CT_Shape._new_autoshape_sp() returns correct XML"""
     # setup ------------------------
     id_ = 9
     name = 'Rounded Rectangle 8'
     prst = 'roundRect'
     left, top, width, height = 111, 222, 333, 444
     xml = (
         '<p:sp %s>\n  <p:nvSpPr>\n    <p:cNvPr id="%d" name="%s"/>\n    <'
         'p:cNvSpPr/>\n    <p:nvPr/>\n  </p:nvSpPr>\n  <p:spPr>\n    <a:xf'
         'rm>\n      <a:off x="%d" y="%d"/>\n      <a:ext cx="%d" cy="%d"/'
         '>\n    </a:xfrm>\n    <a:prstGeom prst="%s">\n      <a:avLst/>\n'
         '    </a:prstGeom>\n  </p:spPr>\n  <p:style>\n    <a:lnRef idx="1'
         '">\n      <a:schemeClr val="accent1"/>\n    </a:lnRef>\n    <a:f'
         'illRef idx="3">\n      <a:schemeClr val="accent1"/>\n    </a:fil'
         'lRef>\n    <a:effectRef idx="2">\n      <a:schemeClr val="accent'
         '1"/>\n    </a:effectRef>\n    <a:fontRef idx="minor">\n      <a:'
         'schemeClr val="lt1"/>\n    </a:fontRef>\n  </p:style>\n  <p:txBo'
         'dy>\n    <a:bodyPr rtlCol="0" anchor="ctr"/>\n    <a:lstStyle/>'
         '\n    <a:p>\n      <a:pPr algn="ctr"/>\n    </a:p>\n  </p:txBody'
         '>\n</p:sp>\n' %
         (nsdecls('a', 'p'), id_, name, left, top, width, height, prst))
     # exercise ---------------------
     sp = CT_Shape.new_autoshape_sp(id_, name, prst, left, top, width,
                                    height)
     # verify -----------------------
     self.assertEqualLineByLine(xml, sp)
Esempio n. 31
0
 def _tbl_tmpl(cls):
     return ('<a:tbl %s>\n'
             '  <a:tblPr firstRow="1" bandRow="1">\n'
             '    <a:tableStyleId>%s</a:tableStyleId>\n'
             '  </a:tblPr>\n'
             '  <a:tblGrid/>\n'
             '</a:tbl>' % (nsdecls('a'), '%s'))
Esempio n. 32
0
    def new_dLbl(cls):
        """Return a newly created "loose" `c:dLbl` element.

        The `c:dLbl` element contains the same (fairly extensive) default
        subtree added by PowerPoint when an individual data label is
        customized in the UI. Note that the idx value must be set by the
        client. Failure to set the idx value will likely result in any
        changes not being visible and may result in a repair error on open.
        """
        return parse_xml('<c:dLbl %s>\n'
                         '  <c:idx val="666"/>\n'
                         '  <c:spPr/>\n'
                         '  <c:txPr>\n'
                         '    <a:bodyPr/>\n'
                         '    <a:lstStyle/>\n'
                         '    <a:p>\n'
                         '      <a:pPr>\n'
                         '        <a:defRPr/>\n'
                         '      </a:pPr>\n'
                         '    </a:p>\n'
                         '  </c:txPr>\n'
                         '  <c:showLegendKey val="0"/>\n'
                         '  <c:showVal val="1"/>\n'
                         '  <c:showCatName val="0"/>\n'
                         '  <c:showSerName val="0"/>\n'
                         '  <c:showPercent val="0"/>\n'
                         '  <c:showBubbleSize val="0"/>\n'
                         '</c:dLbl>' % nsdecls('c', 'a'))
Esempio n. 33
0
 def _new_fgClr(self):
     """Override default to add minimum subtree."""
     xml = ('<a:fgClr %s>\n'
            ' <a:srgbClr val="000000"/>\n'
            '</a:fgClr>\n') % nsdecls('a')
     fgClr = parse_xml(xml)
     return fgClr
Esempio n. 34
0
 def test_new_autoshape_sp_generates_correct_xml(self):
     """CT_Shape._new_autoshape_sp() returns correct XML"""
     # setup ------------------------
     id_ = 9
     name = 'Rounded Rectangle 8'
     prst = 'roundRect'
     left, top, width, height = 111, 222, 333, 444
     xml = (
         '<p:sp %s>\n  <p:nvSpPr>\n    <p:cNvPr id="%d" name="%s"/>\n    <'
         'p:cNvSpPr/>\n    <p:nvPr/>\n  </p:nvSpPr>\n  <p:spPr>\n    <a:xf'
         'rm>\n      <a:off x="%d" y="%d"/>\n      <a:ext cx="%d" cy="%d"/'
         '>\n    </a:xfrm>\n    <a:prstGeom prst="%s">\n      <a:avLst/>\n'
         '    </a:prstGeom>\n  </p:spPr>\n  <p:style>\n    <a:lnRef idx="1'
         '">\n      <a:schemeClr val="accent1"/>\n    </a:lnRef>\n    <a:f'
         'illRef idx="3">\n      <a:schemeClr val="accent1"/>\n    </a:fil'
         'lRef>\n    <a:effectRef idx="2">\n      <a:schemeClr val="accent'
         '1"/>\n    </a:effectRef>\n    <a:fontRef idx="minor">\n      <a:'
         'schemeClr val="lt1"/>\n    </a:fontRef>\n  </p:style>\n  <p:txBo'
         'dy>\n    <a:bodyPr rtlCol="0" anchor="ctr"/>\n    <a:lstStyle/>'
         '\n    <a:p>\n      <a:pPr algn="ctr"/>\n    </a:p>\n  </p:txBody'
         '>\n</p:sp>\n' %
         (nsdecls('a', 'p'), id_, name, left, top, width, height, prst)
     )
     # exercise ---------------------
     sp = CT_Shape.new_autoshape_sp(id_, name, prst, left, top,
                                    width, height)
     # verify -----------------------
     self.assertEqualLineByLine(xml, sp)
Esempio n. 35
0
 def _textbox_sp_tmpl():
     return ("<p:sp %s>\n"
             "  <p:nvSpPr>\n"
             '    <p:cNvPr id="%s" name="%s"/>\n'
             '    <p:cNvSpPr txBox="1"/>\n'
             "    <p:nvPr/>\n"
             "  </p:nvSpPr>\n"
             "  <p:spPr>\n"
             "    <a:xfrm>\n"
             '      <a:off x="%s" y="%s"/>\n'
             '      <a:ext cx="%s" cy="%s"/>\n'
             "    </a:xfrm>\n"
             '    <a:prstGeom prst="rect">\n'
             "      <a:avLst/>\n"
             "    </a:prstGeom>\n"
             "    <a:noFill/>\n"
             "  </p:spPr>\n"
             "  <p:txBody>\n"
             '    <a:bodyPr wrap="none">\n'
             "      <a:spAutoFit/>\n"
             "    </a:bodyPr>\n"
             "    <a:lstStyle/>\n"
             "    <a:p/>\n"
             "  </p:txBody>\n"
             "</p:sp>" %
             (nsdecls("a", "p"), "%d", "%s", "%d", "%d", "%d", "%d"))
Esempio n. 36
0
 def _tbl_tmpl(cls):
     return ("<a:tbl %s>\n"
             '  <a:tblPr firstRow="1" bandRow="1">\n'
             "    <a:tableStyleId>%s</a:tableStyleId>\n"
             "  </a:tblPr>\n"
             "  <a:tblGrid/>\n"
             "</a:tbl>" % (nsdecls("a"), "%s"))
Esempio n. 37
0
 def it_can_create_a_new_tbl_element_tree(self):
     """
     Indirectly tests that column widths are a proportional split of total
     width and that row heights a proportional split of total height.
     """
     expected_xml = (
         '<a:tbl %s>\n  <a:tblPr firstRow="1" bandRow="1">\n    <a:tableSt'
         'yleId>{5C22544A-7EE6-4342-B048-85BDC9FD1C3A}</a:tableStyleId>\n '
         ' </a:tblPr>\n  <a:tblGrid>\n    <a:gridCol w="111"/>\n    <a:gri'
         'dCol w="111"/>\n    <a:gridCol w="112"/>\n  </a:tblGrid>\n  <a:t'
         'r h="222">\n    <a:tc>\n      <a:txBody>\n        <a:bodyPr/>\n '
         '       <a:lstStyle/>\n        <a:p/>\n      </a:txBody>\n      <'
         'a:tcPr/>\n    </a:tc>\n    <a:tc>\n      <a:txBody>\n        <a:'
         'bodyPr/>\n        <a:lstStyle/>\n        <a:p/>\n      </a:txBod'
         'y>\n      <a:tcPr/>\n    </a:tc>\n    <a:tc>\n      <a:txBody>\n'
         '        <a:bodyPr/>\n        <a:lstStyle/>\n        <a:p/>\n    '
         '  </a:txBody>\n      <a:tcPr/>\n    </a:tc>\n  </a:tr>\n  <a:tr '
         'h="223">\n    <a:tc>\n      <a:txBody>\n        <a:bodyPr/>\n   '
         '     <a:lstStyle/>\n        <a:p/>\n      </a:txBody>\n      <a:'
         'tcPr/>\n    </a:tc>\n    <a:tc>\n      <a:txBody>\n        <a:bo'
         'dyPr/>\n        <a:lstStyle/>\n        <a:p/>\n      </a:txBody>'
         '\n      <a:tcPr/>\n    </a:tc>\n    <a:tc>\n      <a:txBody>\n  '
         '      <a:bodyPr/>\n        <a:lstStyle/>\n        <a:p/>\n      '
         '</a:txBody>\n      <a:tcPr/>\n    </a:tc>\n  </a:tr>\n</a:tbl>\n'
         % nsdecls('a'))
     tbl = CT_Table.new_tbl(2, 3, 334, 445)
     assert tbl.xml == expected_xml
Esempio n. 38
0
 def test__clone_layout_placeholder_xml(self):
     """ShapeCollection._clone_layout_placeholder() emits correct XML"""
     # setup ------------------------
     layout_shapes = _sldLayout1_shapes()
     layout_ph_shapes = [sp for sp in layout_shapes if sp.is_placeholder]
     shapes = test_shapes.empty_shape_collection
     expected_xml_tmpl = (
         '<p:sp %s>\n  <p:nvSpPr>\n    <p:cNvPr id="%s" name="%s"/>\n    <'
         'p:cNvSpPr>\n      <a:spLocks noGrp="1"/>\n    </p:cNvSpPr>\n    '
         '<p:nvPr>\n      <p:ph type="%s"%s/>\n    </p:nvPr>\n  </p:nvSpPr'
         '>\n  <p:spPr/>\n%s</p:sp>\n' %
         (nsdecls('p', 'a'), '%d', '%s', '%s', '%s', '%s')
     )
     txBody_snippet = (
         '  <p:txBody>\n    <a:bodyPr/>\n    <a:lstStyle/>\n    <a:p/>\n  '
         '</p:txBody>\n')
     expected_values = [
         (2, 'Title 1', PH_TYPE_CTRTITLE, '', txBody_snippet),
         (3, 'Date Placeholder 2', PH_TYPE_DT, ' sz="half" idx="10"', ''),
         (4, 'Vertical Subtitle 3', PH_TYPE_SUBTITLE,
             ' orient="vert" idx="1"', txBody_snippet),
         (5, 'Table Placeholder 4', PH_TYPE_TBL,
             ' sz="quarter" idx="14"', ''),
         (6, 'Slide Number Placeholder 5', PH_TYPE_SLDNUM,
             ' sz="quarter" idx="12"', ''),
         (7, 'Footer Placeholder 6', PH_TYPE_FTR,
             ' sz="quarter" idx="11"', '')]
                 # verify ----------------------
     for idx, layout_ph_sp in enumerate(layout_ph_shapes):
         layout_ph = Placeholder(layout_ph_sp)
         sp = shapes._clone_layout_placeholder(layout_ph)
         ph = Placeholder(sp)
         expected_xml = expected_xml_tmpl % expected_values[idx]
         self.assertEqualLineByLine(expected_xml, ph._element)
Esempio n. 39
0
 def new_title():
     """Return "loose" `c:title` element containing default children."""
     return parse_xml(
         "<c:title %s>"
         "  <c:layout/>"
         '  <c:overlay val="0"/>'
         "</c:title>" % nsdecls("c")
     )
Esempio n. 40
0
 def new_title():
     """Return "loose" `c:title` element containing default children."""
     return parse_xml(
         "<c:title %s>"
         "  <c:layout/>"
         '  <c:overlay val="0"/>'
         "</c:title>" % nsdecls("c")
     )
Esempio n. 41
0
 def _txBody_tmpl(cls):
     return (
         "<p:txBody %s>\n"
         "  <a:bodyPr/>\n"
         "  <a:lstStyle/>\n"
         "  <a:p/>\n"
         "</p:txBody>\n" % (nsdecls("a", "p"))
     )
Esempio n. 42
0
 def _tmpl(self):
     return (
             '<a:cubicBezTo %s>\n'
             '   <a:pt x="%s" y="%s" />\n'
             '   <a:pt x="%s" y="%s" />\n'
             '   <a:pt x="%s" y="%s" />\n'
             '</a:cubicBezTo>'
     ) % (nsdecls('a'), '%d', '%d', '%d', '%d', '%d', '%d')
Esempio n. 43
0
 def setUp(self):
     tbl_xml = (
         '<a:tbl %s><a:tr h="370840"><a:tc><a:txBody><a:p/></a:txBody></a:'
         'tc><a:tc><a:txBody><a:p/></a:txBody></a:tc></a:tr><a:tr h="37084'
         '0"><a:tc><a:txBody><a:p/></a:txBody></a:tc><a:tc><a:txBody><a:p/'
         '></a:txBody></a:tc></a:tr></a:tbl>' % nsdecls('a')
     )
     test_tbl_elm = parse_xml_bytes(tbl_xml)
     self.rows = _RowCollection(test_tbl_elm, Mock(name='table'))
Esempio n. 44
0
    def _new_showCatName(self):
        """Return a new `c:showCatName` with value initialized.

        This method is called by the metaclass-generated code whenever a new
        `c:showCatName` element is required. In this case, it defaults to
        `val=true`, which is not what we need so we override to make val
        explicitly False.
        """
        return parse_xml('<c:showCatName %s val="0"/>' % nsdecls("c"))
Esempio n. 45
0
 def empty_spTree(self):
     return ('<p:spTree %s>\n'
             '  <p:nvGrpSpPr>\n'
             '    <p:cNvPr id="1" name=""/>\n'
             '    <p:cNvGrpSpPr/>\n'
             '    <p:nvPr/>\n'
             '  </p:nvGrpSpPr>\n'
             '  <p:grpSpPr/>\n'
             '</p:spTree>\n' % nsdecls('p', 'a'))
Esempio n. 46
0
 def setUp(self):
     tbl_xml = (
         '<a:tbl %s><a:tr h="370840"><a:tc><a:txBody><a:p/></a:txBody></a:'
         'tc><a:tc><a:txBody><a:p/></a:txBody></a:tc></a:tr><a:tr h="37084'
         '0"><a:tc><a:txBody><a:p/></a:txBody></a:tc><a:tc><a:txBody><a:p/'
         '></a:txBody></a:tc></a:tr></a:tbl>' % nsdecls('a')
     )
     test_tbl_elm = parse_xml_bytes(tbl_xml)
     self.rows = _RowCollection(test_tbl_elm, Mock(name='table'))
Esempio n. 47
0
    def _new_showCatName(self):
        """Return a new `c:showCatName` with value initialized.

        This method is called by the metaclass-generated code whenever a new
        `c:showCatName` element is required. In this case, it defaults to
        `val=true`, which is not what we need so we override to make val
        explicitly False.
        """
        return parse_xml('<c:showCatName %s val="0"/>' % nsdecls('c'))
Esempio n. 48
0
 def with_nsdecls(self, *nspfxs):
     """
     Cause the element to contain namespace declarations. By default, the
     namespace prefixes defined in the Builder class are used. These can
     be overridden by providing exlicit prefixes, e.g.
     ``with_nsdecls('a', 'r')``.
     """
     if not nspfxs:
         nspfxs = self.__nspfxs__
     self._nsdecls = ' %s' % nsdecls(*nspfxs)
     return self
Esempio n. 49
0
 def empty_spTree(self):
     return (
         '<p:spTree %s>\n'
         '  <p:nvGrpSpPr>\n'
         '    <p:cNvPr id="1" name=""/>\n'
         '    <p:cNvGrpSpPr/>\n'
         '    <p:nvPr/>\n'
         '  </p:nvGrpSpPr>\n'
         '  <p:grpSpPr/>\n'
         '</p:spTree>\n' % nsdecls('p', 'a')
     )
Esempio n. 50
0
 def test_level_setter_generates_correct_xml(self, paragraph_with_text):
     """_Paragraph.level setter generates correct XML"""
     # setup ------------------------
     expected_xml = (
         '<a:p %s>\n  <a:pPr lvl="2"/>\n  <a:r>\n    <a:t>test text</a:t>'
         '\n  </a:r>\n</a:p>\n' % nsdecls('a')
     )
     # exercise ---------------------
     paragraph_with_text.level = 2
     # verify -----------------------
     assert actual_xml(paragraph_with_text._p) == expected_xml
Esempio n. 51
0
 def _new_rich(self):
     return parse_xml(
         "<c:rich %s>"
         "  <a:bodyPr/>"
         "  <a:lstStyle/>"
         "  <a:p>"
         "    <a:pPr>"
         "      <a:defRPr/>"
         "    </a:pPr>"
         "  </a:p>"
         "</c:rich>" % nsdecls("c", "a")
     )
Esempio n. 52
0
 def _ph_sp_tmpl():
     return (
         "<p:sp %s>\n"
         "  <p:nvSpPr>\n"
         '    <p:cNvPr id="%s" name="%s"/>\n'
         "    <p:cNvSpPr>\n"
         '      <a:spLocks noGrp="1"/>\n'
         "    </p:cNvSpPr>\n"
         "    <p:nvPr/>\n"
         "  </p:nvSpPr>\n"
         "  <p:spPr/>\n"
         "</p:sp>" % (nsdecls("a", "p"), "%d", "%s")
     )
Esempio n. 53
0
 def new_dLbls(cls):
     """Return a newly created "loose" `c:dLbls` element."""
     return parse_xml(
         "<c:dLbls %s>\n"
         '  <c:showLegendKey val="0"/>\n'
         '  <c:showVal val="0"/>\n'
         '  <c:showCatName val="0"/>\n'
         '  <c:showSerName val="0"/>\n'
         '  <c:showPercent val="0"/>\n'
         '  <c:showBubbleSize val="0"/>\n'
         '  <c:showLeaderLines val="1"/>\n'
         "</c:dLbls>" % nsdecls("c")
     )
Esempio n. 54
0
 def test_new_placeholder_sp_generates_correct_xml(self):
     """CT_Shape._new_placeholder_sp() returns correct XML"""
     # setup ------------------------
     expected_xml_tmpl = (
         '<p:sp %s>\n  <p:nvSpPr>\n    <p:cNvPr id="%s" name="%s"/>\n    <'
         'p:cNvSpPr>\n      <a:spLocks noGrp="1"/>\n    </p:cNvSpPr>\n    '
         '<p:nvPr>\n      <p:ph%s/>\n    </p:nvPr>\n  </p:nvSpPr>\n  <p:sp'
         'Pr/>\n%s</p:sp>\n' % (nsdecls('a', 'p'), '%d', '%s', '%s', '%s')
     )
     txBody_snippet = (
         '  <p:txBody>\n    <a:bodyPr/>\n    <a:lstStyle/>\n    <a:p/>\n  '
         '</p:txBody>\n')
     test_cases = (
         (2, 'Title 1', ST_PlaceholderType.CTR_TITLE, ST_Direction.HORZ,
          ST_PlaceholderSize.FULL, 0),
         (3, 'Date Placeholder 2', ST_PlaceholderType.DT,
          ST_Direction.HORZ, ST_PlaceholderSize.HALF, 10),
         (4, 'Vertical Subtitle 3', ST_PlaceholderType.SUB_TITLE,
          ST_Direction.VERT, ST_PlaceholderSize.FULL, 1),
         (5, 'Table Placeholder 4', ST_PlaceholderType.TBL,
          ST_Direction.HORZ, ST_PlaceholderSize.QUARTER, 14),
         (6, 'Slide Number Placeholder 5', ST_PlaceholderType.SLD_NUM,
          ST_Direction.HORZ, ST_PlaceholderSize.QUARTER, 12),
         (7, 'Footer Placeholder 6', ST_PlaceholderType.FTR,
          ST_Direction.HORZ, ST_PlaceholderSize.QUARTER, 11),
         (8, 'Content Placeholder 7', ST_PlaceholderType.OBJ,
          ST_Direction.HORZ, ST_PlaceholderSize.FULL, 15)
     )
     expected_values = (
         (2, 'Title 1', ' type="%s"' % ST_PlaceholderType.CTR_TITLE,
          txBody_snippet),
         (3, 'Date Placeholder 2', ' type="%s" sz="half" idx="10"' %
          ST_PlaceholderType.DT, ''),
         (4, 'Vertical Subtitle 3', ' type="%s" orient="vert" idx="1"' %
          ST_PlaceholderType.SUB_TITLE, txBody_snippet),
         (5, 'Table Placeholder 4', ' type="%s" sz="quarter" idx="14"' %
          ST_PlaceholderType.TBL, ''),
         (6, 'Slide Number Placeholder 5', ' type="%s" sz="quarter" '
          'idx="12"' % ST_PlaceholderType.SLD_NUM, ''),
         (7, 'Footer Placeholder 6', ' type="%s" sz="quarter" idx="11"' %
          ST_PlaceholderType.FTR, ''),
         (8, 'Content Placeholder 7', ' idx="15"', txBody_snippet)
     )
     # exercise ---------------------
     for case_idx, argv in enumerate(test_cases):
         id_, name, ph_type, orient, sz, idx = argv
         sp = CT_Shape.new_placeholder_sp(id_, name, ph_type, orient, sz,
                                          idx)
         # verify ------------------
         expected_xml = expected_xml_tmpl % expected_values[case_idx]
         self.assertEqualLineByLine(expected_xml, sp)
Esempio n. 55
0
 def top_aligned_cell(self):
     """
     XML for empty top-aligned table cell
     """
     return (
         '<a:tc %s>\n'
         '  <a:txBody>\n'
         '    <a:bodyPr/>\n'
         '    <a:lstStyle/>\n'
         '    <a:p/>\n'
         '  </a:txBody>\n'
         '  <a:tcPr anchor="t"/>\n'
         '</a:tc>\n' % nsdecls('a')
     )
Esempio n. 56
0
 def cell(self):
     """
     XML for empty default table cell
     """
     return (
         '<a:tc %s>\n'
         '  <a:txBody>\n'
         '    <a:bodyPr/>\n'
         '    <a:lstStyle/>\n'
         '    <a:p/>\n'
         '  </a:txBody>\n'
         '  <a:tcPr/>\n'
         '</a:tc>\n' % nsdecls('a')
     )
Esempio n. 57
0
 def cell_with_margins(self):
     """
     XML for cell having top, left, right, and bottom margin settings
     """
     return (
         '<a:tc %s>\n'
         '  <a:txBody>\n'
         '    <a:bodyPr/>\n'
         '    <a:lstStyle/>\n'
         '    <a:p/>\n'
         '  </a:txBody>\n'
         '  <a:tcPr marT="12" marR="34" marB="56" marL="78"/>\n'
         '</a:tc>\n' % nsdecls('a')
     )
Esempio n. 58
0
 def new_fixture(self):
     id_, name, desc, rId = 9, 'Diam. > 1 mm', 'desc', 'rId1'
     x, y, cx, cy = 1, 2, 3, 4
     expected_xml = (
         '<p:pic %s>\n  <p:nvPicPr>\n    <p:cNvPr id="%d" name="%s" descr'
         '="%s"/>\n    <p:cNvPicPr>\n      <a:picLocks noChangeAspect="1"'
         '/>\n    </p:cNvPicPr>\n    <p:nvPr/>\n  </p:nvPicPr>\n  <p:blip'
         'Fill>\n    <a:blip r:embed="%s"/>\n    <a:stretch>\n      <a:fi'
         'llRect/>\n    </a:stretch>\n  </p:blipFill>\n  <p:spPr>\n    <a'
         ':xfrm>\n      <a:off x="%d" y="%d"/>\n      <a:ext cx="%d" cy="'
         '%d"/>\n    </a:xfrm>\n    <a:prstGeom prst="rect">\n      <a:av'
         'Lst/>\n    </a:prstGeom>\n  </p:spPr>\n</p:pic>\n' % (
             nsdecls('a', 'p', 'r'), id_, 'Diam. &gt; 1 mm', desc, rId,
             x, y, cx, cy
         )
     )
     return id_, name, desc, rId, x, y, cx, cy, expected_xml
Esempio n. 59
0
 def _freeform_sp_tmpl():
     return (
         "<p:sp %s>\n"
         "  <p:nvSpPr>\n"
         '    <p:cNvPr id="%s" name="%s"/>\n'
         "    <p:cNvSpPr/>\n"
         "    <p:nvPr/>\n"
         "  </p:nvSpPr>\n"
         "  <p:spPr>\n"
         "    <a:xfrm>\n"
         '      <a:off x="%s" y="%s"/>\n'
         '      <a:ext cx="%s" cy="%s"/>\n'
         "    </a:xfrm>\n"
         "    <a:custGeom>\n"
         "      <a:avLst/>\n"
         "      <a:gdLst/>\n"
         "      <a:ahLst/>\n"
         "      <a:cxnLst/>\n"
         '      <a:rect l="l" t="t" r="r" b="b"/>\n'
         "      <a:pathLst/>\n"
         "    </a:custGeom>\n"
         "  </p:spPr>\n"
         "  <p:style>\n"
         '    <a:lnRef idx="1">\n'
         '      <a:schemeClr val="accent1"/>\n'
         "    </a:lnRef>\n"
         '    <a:fillRef idx="3">\n'
         '      <a:schemeClr val="accent1"/>\n'
         "    </a:fillRef>\n"
         '    <a:effectRef idx="2">\n'
         '      <a:schemeClr val="accent1"/>\n'
         "    </a:effectRef>\n"
         '    <a:fontRef idx="minor">\n'
         '      <a:schemeClr val="lt1"/>\n'
         "    </a:fontRef>\n"
         "  </p:style>\n"
         "  <p:txBody>\n"
         '    <a:bodyPr rtlCol="0" anchor="ctr"/>\n'
         "    <a:lstStyle/>\n"
         "    <a:p>\n"
         '      <a:pPr algn="ctr"/>\n'
         "    </a:p>\n"
         "  </p:txBody>\n"
         "</p:sp>" % (nsdecls("a", "p"), "%d", "%s", "%d", "%d", "%d", "%d")
     )