The attached patch enables Python scripts running under Gnumeric to
insert rows and columns. I don't think it's quite right because when a
script adds a row or column, Gnumeric doesn't realize the spreadsheet
has changed, or offer undo for the change.
The patch applies cleanly against 1.10.13, and has done so for many
versions since 1.10.5, so it will likely apply against HEAD.
I'd like for something like this patch to be committed because I'm
tired of building custom Debian packages with this change in them
every time a new Gnumeric comes out into Debian unstable :)
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;
_______________________________________________
gnumeric-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/gnumeric-list