Exemple #1
0
 def table(self):
     """
     The |Table| object contained in this graphic frame. Raises
     |ValueError| if this graphic frame does not contain a table.
     """
     if not self.has_table:
         raise ValueError('shape does not contain a table')
     tbl = self._element.graphic.graphicData.tbl
     return Table(tbl, self)
    def it_provides_access_to_its_cells(self, tbl_, tc_, _Cell_, cell_):
        row_idx, col_idx = 4, 2
        tbl_.tc.return_value = tc_
        _Cell_.return_value = cell_
        table = Table(tbl_, None)

        cell = table.cell(row_idx, col_idx)

        tbl_.tc.assert_called_once_with(row_idx, col_idx)
        _Cell_.assert_called_once_with(tc_, table)
        assert cell is cell_
Exemple #3
0
    def it_provides_access_to_its_rows(self, request):
        rows_ = instance_mock(request, _RowCollection)
        _RowCollection_ = class_mock(request,
                                     "pptx.table._RowCollection",
                                     return_value=rows_)
        tbl = element("a:tbl")
        table = Table(tbl, None)

        rows = table.rows

        _RowCollection_.assert_called_once_with(tbl, table)
        assert rows is rows_
Exemple #4
0
    def it_provides_access_to_its_columns(self, request):
        columns_ = instance_mock(request, _ColumnCollection)
        _ColumnCollection_ = class_mock(request,
                                        "pptx.table._ColumnCollection",
                                        return_value=columns_)
        tbl = element("a:tbl")
        table = Table(tbl, None)

        columns = table.columns

        _ColumnCollection_.assert_called_once_with(tbl, table)
        assert columns is columns_
    def it_can_iterate_its_grid_cells(self, request, _Cell_):
        tbl = element('a:tbl/(a:tr/(a:tc,a:tc),a:tr/(a:tc,a:tc))')
        expected_tcs = tbl.xpath('.//a:tc')
        expected_cells = _Cell_.side_effect = [
            instance_mock(request, _Cell, name='cell%d' % idx)
            for idx in range(4)
        ]
        table = Table(tbl, None)

        cells = list(table.iter_cells())

        assert cells == expected_cells
        assert _Cell_.call_args_list == [
            call(tc, table) for tc in expected_tcs
        ]
 def dy_fixture(self, graphic_frame_):
     tbl_cxml = 'a:tbl/(a:tr{h=100},a:tr{h=200})'
     table = Table(element(tbl_cxml), graphic_frame_)
     expected_height = 300
     return table, expected_height
 def dx_fixture(self, graphic_frame_):
     tbl_cxml = 'a:tbl/a:tblGrid/(a:gridCol{w=111},a:gridCol{w=222})'
     table = Table(element(tbl_cxml), graphic_frame_)
     expected_width = 333
     return table, expected_width
 def boolprop_set_fixture(self, request):
     tbl_cxml, boolprop_name, new_value, expected_tbl_cxml = request.param
     table = Table(element(tbl_cxml), None)
     expected_xml = xml(expected_tbl_cxml)
     return table, boolprop_name, new_value, expected_xml
 def boolprop_get_fixture(self, request):
     tbl_cxml, boolprop_name, expected_value = request.param
     table = Table(element(tbl_cxml), None)
     return table, boolprop_name, expected_value
 def table(self):
     return Table(element('a:tbl'), None)
 def table(self):
     return Table(element("a:tbl"), None)