예제 #1
0
 def new_table(self, rows, cols, left, top, width, height):
     _id = -1
     name = "Table %d" % (_id)
     graphicFrame = CT_GraphicalObjectFrame()
     gf_tbl = graphicFrame.new_table_graphicFrame(_id, name, rows, cols,
                                                  left, top, width, height)
     return self._shape_factory(gf_tbl)
예제 #2
0
 def it_can_construct_a_new_table_graphicFrame(
         self, new_table_graphicFrame_fixture):
     id_, name, rows, cols, x, y, cx, cy, expected_xml = (
         new_table_graphicFrame_fixture)
     graphicFrame = CT_GraphicalObjectFrame.new_table_graphicFrame(
         id_, name, rows, cols, x, y, cx, cy)
     assert graphicFrame.xml == expected_xml
예제 #3
0
 def it_can_construct_a_new_table_graphicFrame(self, new_table_graphicFrame_fixture):
     id_, name, rows, cols, x, y, cx, cy, expected_xml = (
         new_table_graphicFrame_fixture
     )
     graphicFrame = CT_GraphicalObjectFrame.new_table_graphicFrame(
         id_, name, rows, cols, x, y, cx, cy
     )
     assert graphicFrame.xml == expected_xml
예제 #4
0
 def _new_chart_graphicFrame(self, rId, x, y, cx, cy):
     """
     Return a newly created `p:graphicFrame` element having the specified
     position and size and containing the chart identified by *rId*.
     """
     id_, name = self.shape_id, self.name
     return CT_GraphicalObjectFrame.new_chart_graphicFrame(
         id_, name, rId, x, y, cx, cy)
예제 #5
0
 def add_table(self, id_, name, rows, cols, x, y, cx, cy):
     """
     Append a ``<p:graphicFrame>`` shape containing a table as specified
     in call.
     """
     graphicFrame = CT_GraphicalObjectFrame.new_table_graphicFrame(
         id_, name, rows, cols, x, y, cx, cy)
     self.insert_element_before(graphicFrame, 'p:extLst')
     return graphicFrame
예제 #6
0
 def add_table(self, id_, name, rows, cols, x, y, cx, cy):
     """
     Append a ``<p:graphicFrame>`` shape containing a table as specified
     in call.
     """
     graphicFrame = CT_GraphicalObjectFrame.new_table_graphicFrame(
         id_, name, rows, cols, x, y, cx, cy
     )
     self.insert_element_before(graphicFrame, "p:extLst")
     return graphicFrame
예제 #7
0
 def _new_placeholder_table(self, rows, cols):
     """
     Return a newly added `p:graphicFrame` element containing an empty
     table with *rows* rows and *cols* columns, positioned at the location
     of this placeholder and having its same width. The table's height is
     determined by the number of rows.
     """
     shape_id, name, height = self.shape_id, self.name, Emu(rows * 370840)
     return CT_GraphicalObjectFrame.new_table_graphicFrame(
         shape_id, name, rows, cols, self.left, self.top, self.width,
         height)
예제 #8
0
 def _add_chart_graphicFrame(self, rId, x, y, cx, cy):
     """
     Add a new ``<p:graphicFrame>`` element to this shape tree having the
     specified position and size and referring to the chart part
     identified by *rId*.
     """
     shape_id = self._next_shape_id
     name = 'Chart %d' % (shape_id - 1)
     graphicFrame = CT_GraphicalObjectFrame.new_chart_graphicFrame(
         shape_id, name, rId, x, y, cx, cy)
     self._spTree.append(graphicFrame)
     return graphicFrame
예제 #9
0
    def _add_chart_graphicFrame(self, rId, x, y, cx, cy):
        """Return new `p:graphicFrame` element appended to this shape tree.

        The `p:graphicFrame` element has the specified position and size and
        refers to the chart part identified by *rId*.
        """
        shape_id = self._next_shape_id
        name = "Chart %d" % (shape_id - 1)
        graphicFrame = CT_GraphicalObjectFrame.new_chart_graphicFrame(
            shape_id, name, rId, x, y, cx, cy)
        self._spTree.append(graphicFrame)
        return graphicFrame
예제 #10
0
    def _add_chart_graphicFrame(self, rId, x, y, cx, cy):
        """Return new `p:graphicFrame` element appended to this shape tree.

        The `p:graphicFrame` element has the specified position and size and
        refers to the chart part identified by *rId*.
        """
        shape_id = self._next_shape_id
        name = "Chart %d" % (shape_id - 1)
        graphicFrame = CT_GraphicalObjectFrame.new_chart_graphicFrame(
            shape_id, name, rId, x, y, cx, cy
        )
        self._spTree.append(graphicFrame)
        return graphicFrame
예제 #11
0
 def _graphicFrame(self):
     """Newly-created `p:graphicFrame` element referencing embedded OLE-object."""
     return CT_GraphicalObjectFrame.new_ole_object_graphicFrame(
         self._shape_id,
         self._shape_name,
         self._ole_object_rId,
         self._progId,
         self._icon_rId,
         self._x,
         self._y,
         self._cx,
         self._cy,
     )
예제 #12
0
 def test_has_table_return_value(self):
     """CT_GraphicalObjectFrame.has_table property has correct value"""
     # setup ------------------------
     id_, name = 9, 'Table 8'
     left, top, width, height = 111, 222, 333, 444
     tbl_uri = 'http://schemas.openxmlformats.org/drawingml/2006/table'
     chart_uri = 'http://schemas.openxmlformats.org/drawingml/2006/chart'
     graphicFrame = CT_GraphicalObjectFrame.new_graphicFrame(
         id_, name, left, top, width, height)
     graphicData = graphicFrame[qn('a:graphic')].graphicData
     # verify -----------------------
     graphicData.set('uri', tbl_uri)
     assert_that(graphicFrame.has_table, is_(equal_to(True)))
     graphicData.set('uri', chart_uri)
     assert_that(graphicFrame.has_table, is_(equal_to(False)))
예제 #13
0
 def test_has_table_return_value(self):
     """CT_GraphicalObjectFrame.has_table property has correct value"""
     # setup ------------------------
     id_, name = 9, 'Table 8'
     left, top, width, height = 111, 222, 333, 444
     tbl_uri = 'http://schemas.openxmlformats.org/drawingml/2006/table'
     chart_uri = 'http://schemas.openxmlformats.org/drawingml/2006/chart'
     graphicFrame = CT_GraphicalObjectFrame.new_graphicFrame(
         id_, name, left, top, width, height)
     graphicData = graphicFrame[qn('a:graphic')].graphicData
     # verify -----------------------
     graphicData.set('uri', tbl_uri)
     assert_that(graphicFrame.has_table, is_(equal_to(True)))
     graphicData.set('uri', chart_uri)
     assert_that(graphicFrame.has_table, is_(equal_to(False)))
예제 #14
0
 def test_new_table_generates_correct_xml(self):
     """CT_GraphicalObjectFrame.new_table() returns correct XML"""
     # setup ------------------------
     id_, name = 9, 'Table 8'
     rows, cols = 2, 3
     left, top, width, height = 111, 222, 334, 445
     xml = (
         '<p:graphicFrame %s>\n  <p:nvGraphicFramePr>\n    <p:cNvP''r id="'
         '%d" name="%s"/>\n    <p:cNvGraphicFramePr>\n      <a:graphicFram'
         'eLocks noGrp="1"/>\n    </p:cNvGraphicFramePr>\n    <p:nvPr/>\n '
         ' </p:nvGraphicFramePr>\n  <p:xfrm>\n    <a:off x="%d" y="%d"/>\n'
         '    <a:ext cx="%d" cy="%d"/>\n  </p:xfrm>\n  <a:graphic>\n    <a'
         ':graphicData uri="http://schemas.openxmlformats.org/drawingml/20'
         '06/table">\n      <a:tbl>\n        <a:tblPr firstRow="1" bandRow'
         '="1">\n          <a:tableStyleId>{5C22544A-7EE6-4342-B048-85BDC9'
         'FD1C3A}</a:tableStyleId>\n        </a:tblPr>\n        <a:tblGrid'
         '>\n          <a:gridCol w="111"/>\n          <a:gridCol w="111"/'
         '>\n          <a:gridCol w="112"/>\n        </a:tblGrid>\n       '
         ' <a:tr 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: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: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:bodyPr/>\n              <a:lstS'
         'tyle/>\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   '
         ' </a:graphicData>\n  </a:graphic>\n</p:graphicFrame>\n' %
         (nsdecls('a', 'p'), id_, name, left, top, width, height)
     )
     # exercise ---------------------
     graphicFrame = CT_GraphicalObjectFrame.new_table(
         id_, name, rows, cols, left, top, width, height)
     # verify -----------------------
     self.assertEqualLineByLine(xml, graphicFrame)
예제 #15
0
 def test_new_table_generates_correct_xml(self):
     """CT_GraphicalObjectFrame.new_table() returns correct XML"""
     # setup ------------------------
     id_, name = 9, 'Table 8'
     rows, cols = 2, 3
     left, top, width, height = 111, 222, 334, 445
     xml = (
         '<p:graphicFrame %s>\n  <p:nvGraphicFramePr>\n    <p:cNvP'
         'r id="'
         '%d" name="%s"/>\n    <p:cNvGraphicFramePr>\n      <a:graphicFram'
         'eLocks noGrp="1"/>\n    </p:cNvGraphicFramePr>\n    <p:nvPr/>\n '
         ' </p:nvGraphicFramePr>\n  <p:xfrm>\n    <a:off x="%d" y="%d"/>\n'
         '    <a:ext cx="%d" cy="%d"/>\n  </p:xfrm>\n  <a:graphic>\n    <a'
         ':graphicData uri="http://schemas.openxmlformats.org/drawingml/20'
         '06/table">\n      <a:tbl>\n        <a:tblPr firstRow="1" bandRow'
         '="1">\n          <a:tableStyleId>{5C22544A-7EE6-4342-B048-85BDC9'
         'FD1C3A}</a:tableStyleId>\n        </a:tblPr>\n        <a:tblGrid'
         '>\n          <a:gridCol w="111"/>\n          <a:gridCol w="111"/'
         '>\n          <a:gridCol w="112"/>\n        </a:tblGrid>\n       '
         ' <a:tr 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: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: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:bodyPr/>\n              <a:lstS'
         'tyle/>\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   '
         ' </a:graphicData>\n  </a:graphic>\n</p:graphicFrame>\n' %
         (nsdecls('a', 'p'), id_, name, left, top, width, height))
     # exercise ---------------------
     graphicFrame = CT_GraphicalObjectFrame.new_table(
         id_, name, rows, cols, left, top, width, height)
     # verify -----------------------
     self.assertEqualLineByLine(xml, graphicFrame)
예제 #16
0
 def test_new_graphicFrame_generates_correct_xml(self):
     """CT_GraphicalObjectFrame.new_graphicFrame() returns correct XML"""
     # setup ------------------------
     id_, name = 9, 'Table 8'
     left, top, width, height = 111, 222, 333, 444
     xml = (
         '<p:graphicFrame %s>\n  <p:nvGraphicFramePr>\n    <p:cNvPr id="%d'
         '" name="%s"/>\n    <p:cNvGraphicFramePr>\n      <a:graphicFrameL'
         'ocks noGrp="1"/>\n    </p:cNvGraphicFramePr>\n    <p:nvPr/>\n  <'
         '/p:nvGraphicFramePr>\n  <p:xfrm>\n    <a:off x="%d" y="%d"/>\n  '
         '  <a:ext cx="%d" cy="%d"/>\n  </p:xfrm>\n  <a:graphic>\n    <a:g'
         'raphicData/>\n  </a:graphic>\n</p:graphicFrame>\n' %
         (nsdecls('a', 'p'), id_, name, left, top, width, height))
     # exercise ---------------------
     graphicFrame = CT_GraphicalObjectFrame.new_graphicFrame(
         id_, name, left, top, width, height)
     # verify -----------------------
     self.assertEqualLineByLine(xml, graphicFrame)
예제 #17
0
 def test_new_graphicFrame_generates_correct_xml(self):
     """CT_GraphicalObjectFrame.new_graphicFrame() returns correct XML"""
     # setup ------------------------
     id_, name = 9, 'Table 8'
     left, top, width, height = 111, 222, 333, 444
     xml = (
         '<p:graphicFrame %s>\n  <p:nvGraphicFramePr>\n    <p:cNvPr id="%d'
         '" name="%s"/>\n    <p:cNvGraphicFramePr>\n      <a:graphicFrameL'
         'ocks noGrp="1"/>\n    </p:cNvGraphicFramePr>\n    <p:nvPr/>\n  <'
         '/p:nvGraphicFramePr>\n  <p:xfrm>\n    <a:off x="%d" y="%d"/>\n  '
         '  <a:ext cx="%d" cy="%d"/>\n  </p:xfrm>\n  <a:graphic>\n    <a:g'
         'raphicData/>\n  </a:graphic>\n</p:graphicFrame>\n' %
         (nsdecls('a', 'p'), id_, name, left, top, width, height)
     )
     # exercise ---------------------
     graphicFrame = CT_GraphicalObjectFrame.new_graphicFrame(
         id_, name, left, top, width, height)
     # verify -----------------------
     self.assertEqualLineByLine(xml, graphicFrame)
예제 #18
0
 def __init__(self, rows, cols, left, top, width, height):
     self.graphicFrame = CT_GraphicalObjectFrame.new_table_graphicFrame(
         -1, None, rows, cols, left, top, width, height)
 def it_can_construct_a_new_chart_graphicFrame(self, new_chart_graphicFrame_fixture):
     id_, name, rId, x, y, cx, cy, expected_xml = new_chart_graphicFrame_fixture
     graphicFrame = CT_GraphicalObjectFrame.new_chart_graphicFrame(
         id_, name, rId, x, y, cx, cy
     )
     assert graphicFrame.xml == expected_xml