r14143 by cbradney - #8255: Add getPageNSize(i) to allow getting of a particular page's size, add getPageNMargins(i) for added bonus

scribus-commit scribus-commit at lists.scribus.net
Sun Oct 11 23:10:51 CEST 2009


Revision: 14143
Author: cbradney
Date: 2009-10-11T20:04:47.886423Z
Commit message: #8255: Add getPageNSize(i) to allow getting of a particular page's size, add getPageNMargins(i) for added bonus

Changeset: 
M  /branches/Version135/Scribus/scribus/plugins/scriptplugin/cmdpage.h
M  /branches/Version135/Scribus/scribus/plugins/scriptplugin/cmdpage.cpp
M  /branches/Version135/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp

Diffs:
Index: scribus/plugins/scriptplugin/cmdpage.cpp
===================================================================
--- scribus/plugins/scriptplugin/cmdpage.cpp	(revision 14142)
+++ scribus/plugins/scriptplugin/cmdpage.cpp	(revision 14143)
@@ -177,6 +177,49 @@
 	return t;
 }
 
+PyObject *scribus_pagensize(PyObject* /* self */, PyObject* args)
+{
+	int e;
+	if (!PyArg_ParseTuple(args, "i", &e))
+		return NULL;
+	if(!checkHaveDocument())
+		return NULL;
+	e--;
+	if ((e < 0) || (e > static_cast<int>(ScCore->primaryMainWindow()->doc->Pages->count())-1))
+	{
+		PyErr_SetString(PyExc_IndexError, QObject::tr("Page number out of range.","python error").toLocal8Bit().constData());
+		return NULL;
+	}
+	PyObject *t;
+	t = Py_BuildValue(
+			"(dd)",
+			PointToValue(ScCore->primaryMainWindow()->doc->Pages->at(e)->width()),
+			PointToValue(ScCore->primaryMainWindow()->doc->Pages->at(e)->height())
+		);
+	return t;
+}
+
+PyObject *scribus_pagenmargins(PyObject* /* self */, PyObject* args)
+{
+	int e;
+	if (!PyArg_ParseTuple(args, "i", &e))
+		return NULL;
+	if(!checkHaveDocument())
+		return NULL;
+	e--;
+	if ((e < 0) || (e > static_cast<int>(ScCore->primaryMainWindow()->doc->Pages->count())-1))
+	{
+		PyErr_SetString(PyExc_IndexError, QObject::tr("Page number out of range.","python error").toLocal8Bit().constData());
+		return NULL;
+	}
+	PyObject *margins = NULL;
+	margins = Py_BuildValue("ffff", PointToValue(ScCore->primaryMainWindow()->doc->Pages->at(e)->Margins.Top),
+									PointToValue(ScCore->primaryMainWindow()->doc->Pages->at(e)->Margins.Left),
+									PointToValue(ScCore->primaryMainWindow()->doc->Pages->at(e)->Margins.Right),
+									PointToValue(ScCore->primaryMainWindow()->doc->Pages->at(e)->Margins.Bottom));
+	return margins;
+}
+
 PyObject *scribus_getpageitems(PyObject* /* self */)
 {
 	if(!checkHaveDocument())
@@ -469,5 +512,6 @@
 	  << scribus_getHguides__doc__     << scribus_setHguides__doc__
 	  << scribus_getVguides__doc__     << scribus_setVguides__doc__
 	  << scribus_pagedimension__doc__  << scribus_getpageitems__doc__
-	  << scribus_getpagemargins__doc__ << scribus_importpage__doc__;
+	  << scribus_getpagemargins__doc__ << scribus_importpage__doc__
+	  << scribus_pagensize__doc__      << scribus_pagenmargins__doc__;
 }
Index: scribus/plugins/scriptplugin/cmdpage.h
===================================================================
--- scribus/plugins/scriptplugin/cmdpage.h	(revision 14142)
+++ scribus/plugins/scriptplugin/cmdpage.h	(revision 14143)
@@ -157,6 +157,32 @@
 PyObject *scribus_pagedimension(PyObject * /*self*/);
 
 /*! docstring */
+PyDoc_STRVAR(scribus_pagensize__doc__,
+QT_TR_NOOP("getPageNSize() -> tuple\n\
+\n\
+Returns a tuple with a particular page's size measured in the document's current units.\n\
+See UNIT_<type> constants and getPageMargins()\n\
+"));
+/**
+returns a tuple with a particular page's size  in used system
+e.g. when is the doc in picas returns picas ;)
+*/
+PyObject *scribus_pagensize(PyObject * /*self*/, PyObject* args);
+
+/*! docstring */
+PyDoc_STRVAR(scribus_pagenmargins__doc__,
+QT_TR_NOOP("getPageNMargins() -> tuple\n\
+\n\
+Returns a tuple with a particular page's margins measured in the document's current units.\n\
+See UNIT_<type> constants and getPageMargins()\n\
+"));
+/**
+returns a tuple with a particular page's size  in used system
+e.g. when is the doc in picas returns picas ;)
+*/
+PyObject *scribus_pagenmargins(PyObject * /*self*/, PyObject* args);
+
+/*! docstring */
 PyDoc_STRVAR(scribus_getpageitems__doc__,
 QT_TR_NOOP("getPageItems() -> list\n\
 \n\
Index: scribus/plugins/scriptplugin/scriptplugin.cpp
===================================================================
--- scribus/plugins/scriptplugin/scriptplugin.cpp	(revision 14142)
+++ scribus/plugins/scriptplugin/scriptplugin.cpp	(revision 14143)
@@ -348,6 +348,8 @@
 	{const_cast<char*>("getPageMargins"), (PyCFunction)scribus_getpagemargins, METH_NOARGS, tr(scribus_getpagemargins__doc__)},
 	{const_cast<char*>("getPageType"), (PyCFunction)scribus_pageposition, METH_VARARGS, tr(scribus_pageposition__doc__)},
 	{const_cast<char*>("getPageSize"), (PyCFunction)scribus_pagedimension, METH_NOARGS, tr(scribus_pagedimension__doc__)}, // just an alias to PageDimension()
+	{const_cast<char*>("getPageNSize"), scribus_pagensize, METH_VARARGS, tr(scribus_pagensize__doc__)},
+	{const_cast<char*>("getPageNMargins"), scribus_pagenmargins, METH_VARARGS, tr(scribus_pagenmargins__doc__)},
 	{const_cast<char*>("importPage"), scribus_importpage, METH_VARARGS, tr(scribus_importpage__doc__)},
 	{const_cast<char*>("getPosition"), scribus_getposi, METH_VARARGS, tr(scribus_getposi__doc__)},
 	{const_cast<char*>("getRotation"), scribus_getrotation, METH_VARARGS, tr(scribus_getrotation__doc__)},




More information about the scribus-commit mailing list