This patch adds insert_rows and insert_columns methods to the Sheet object exposed in the Python interpreter. --- gnumeric-1.10.11.orig/plugins/python-loader/py-gnumeric.c +++ gnumeric-1.10.11/plugins/python-loader/py-gnumeric.c @@ -140,6 +140,8 @@ Sheet: - get_extent - rename - get_name_unquoted + - insert_rows + - insert_columns subscript ([col,row] == cell_fetch) Workbook: @@ -1422,6 +1424,10 @@ static PyObject * py_sheet_rename_method (py_Sheet_object *self, PyObject *args); static PyObject * py_sheet_get_name_unquoted_method (py_Sheet_object *self, PyObject *args); +static PyObject * +py_sheet_insert_rows (py_Sheet_object *self, PyObject *args); +static PyObject * +py_sheet_insert_columns (py_Sheet_object *self, PyObject *args); static struct PyMethodDef py_Sheet_object_methods[] = { {(char *) "cell_fetch", @@ -1440,6 +1446,10 @@ static struct PyMethodDef py_Sheet_objec (PyCFunction) py_sheet_rename_method, METH_VARARGS}, {(char *) "get_name_unquoted", (PyCFunction) py_sheet_get_name_unquoted_method, METH_VARARGS}, + {(char *) "insert_rows", + (PyCFunction) py_sheet_insert_rows, METH_VARARGS}, + {(char *) "insert_columns", + (PyCFunction) py_sheet_insert_columns, METH_VARARGS}, {NULL, NULL} }; @@ -1587,6 +1597,43 @@ py_sheet_get_name_unquoted_method (py_Sh } static PyObject * +py_sheet_insert_rows (py_Sheet_object *self, PyObject *args) +{ + gint row, howmany; + gboolean failed; + if (!PyArg_ParseTuple (args, (char *) "ii", &row, &howmany)) { + return NULL; + } + + failed = sheet_insert_rows (self->sheet, row, howmany, NULL, NULL); + + if(failed) { + Py_RETURN_FALSE; + } else { + Py_RETURN_TRUE; + } +} + +static PyObject * +py_sheet_insert_columns (py_Sheet_object *self, PyObject *args) +{ + gint column, howmany; + gboolean failed; + if (!PyArg_ParseTuple (args, (char *) "ii", &column, &howmany)) { + return NULL; + } + + failed = sheet_insert_columns (self->sheet, column, howmany, NULL, + NULL); + + if(failed) { + Py_RETURN_FALSE; + } else { + Py_RETURN_TRUE; + } +} + +static PyObject * py_sheet_subscript (py_Sheet_object *self, PyObject *key) { gint col, row;