Exemple #1
0
 def add_placeholder(self, id_, name, ph_type, orient, sz, idx):
     """
     Append a newly-created placeholder ``<p:sp>`` shape having the
     specified placeholder properties.
     """
     sp = CT_Shape.new_placeholder_sp(id_, name, ph_type, orient, sz, idx)
     self.insert_element_before(sp, 'p:extLst')
     return sp
Exemple #2
0
 def add_placeholder(self, id_, name, ph_type, orient, sz, idx):
     """
     Append a newly-created placeholder ``<p:sp>`` shape having the
     specified placeholder properties.
     """
     sp = CT_Shape.new_placeholder_sp(id_, name, ph_type, orient, sz, idx)
     self.insert_element_before(sp, "p:extLst")
     return sp
Exemple #3
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)
 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)
 def it_knows_how_to_create_a_new_placeholder_sp(self, new_ph_sp_fixture):
     id_, name, ph_type, orient, sz, idx, expected_xml = new_ph_sp_fixture
     sp = CT_Shape.new_placeholder_sp(id_, name, ph_type, orient, sz, idx)
     assert sp.xml == expected_xml
 def it_knows_how_to_create_a_new_placeholder_sp(self, new_ph_sp_fixture):
     id_, name, ph_type, orient, sz, idx, expected_xml = new_ph_sp_fixture
     sp = CT_Shape.new_placeholder_sp(
         id_, name, ph_type, orient, sz, idx
     )
     assert sp.xml == expected_xml