r19563 by craig - #12758: Add applyMasterPage command to scripter

scribus-commit scribus-commit at lists.scribus.net
Wed Oct 8 19:51:11 UTC 2014


Author: craig
Date: Wed Oct  8 19:51:11 2014
New Revision: 19563

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=19563
Log:
#12758: Add applyMasterPage command to scripter

Modified:
    trunk/Scribus/scribus/plugins/scriptplugin/cmddoc.cpp
    trunk/Scribus/scribus/plugins/scriptplugin/cmddoc.h
    trunk/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp

Modified: trunk/Scribus/scribus/plugins/scriptplugin/cmddoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19563&path=/trunk/Scribus/scribus/plugins/scriptplugin/cmddoc.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/cmddoc.cpp (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/cmddoc.cpp Wed Oct  8 19:51:11 2014
@@ -389,6 +389,36 @@
 	Py_RETURN_NONE;
 }
 
+PyObject* scribus_applymasterpage(PyObject* /* self */, PyObject* args)
+{
+	char* name = 0;
+	int page = 0;
+	if (!PyArg_ParseTuple(args, "esi", const_cast<char*>("utf-8"), &name, &page))
+		return NULL;
+	if(!checkHaveDocument())
+		return NULL;
+	const QString masterPageName(name);
+	if (!ScCore->primaryMainWindow()->doc->MasterNames.contains(masterPageName))
+	{
+		PyErr_SetString(PyExc_ValueError, QObject::tr("Master page does not exist: '%1'","python error").arg(masterPageName).toLocal8Bit().constData());
+		return NULL;
+	}
+	if ((page < 1) || (page > static_cast<int>(ScCore->primaryMainWindow()->doc->Pages->count())))
+	{
+		PyErr_SetString(PyExc_IndexError, QObject::tr("Page number out of range: %1.","python error").arg(page).toLocal8Bit().constData());
+		return NULL;
+	}
+
+	if (!ScCore->primaryMainWindow()->doc->applyMasterPage(masterPageName, page-1))
+	{
+		PyErr_SetString(ScribusException, QObject::tr("Failed to apply masterpage '%1' on page: %2","python error").arg(masterPageName).arg(page).toLocal8Bit().constData());
+		return NULL;
+	}
+//	Py_INCREF(Py_None);
+//	return Py_None;
+	Py_RETURN_NONE;
+}
+
 /*! HACK: this removes "warning: 'blah' defined but not used" compiler warnings
 with header files structure untouched (docstrings are kept near declarations)
 PV */

Modified: trunk/Scribus/scribus/plugins/scriptplugin/cmddoc.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19563&path=/trunk/Scribus/scribus/plugins/scriptplugin/cmddoc.h
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/cmddoc.h (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/cmddoc.h Wed Oct  8 19:51:11 2014
@@ -277,6 +277,13 @@
 "));
 PyObject* scribus_deletemasterpage(PyObject* self, PyObject* args);
 
+PyDoc_STRVAR(scribus_applymasterpage__doc__,
+QT_TR_NOOP("applyMasterPage(mastePageName, pageNumber)\n\
+\n\
+Apply master page masterPageName on page pageNumber.\n\
+"));
+PyObject* scribus_applymasterpage(PyObject* self, PyObject* args);
+
 #endif
 
 

Modified: trunk/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19563&path=/trunk/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp Wed Oct  8 19:51:11 2014
@@ -300,6 +300,7 @@
 PyMethodDef scribus_methods[] = {
 	// 2004/10/03 pv - aliases with common Python syntax - ClassName methodName
 	// 2004-11-06 cr - move aliasing to dynamically generated wrapper functions, sort methoddef
+	{const_cast<char*>("applyMasterPage"), scribus_applymasterpage, METH_VARARGS, tr(scribus_applymasterpage__doc__)},
 	{const_cast<char*>("changeColor"), scribus_setcolor, METH_VARARGS, tr(scribus_setcolor__doc__)},
 	{const_cast<char*>("changeColorRGB"), scribus_setcolorrgb, METH_VARARGS, tr(scribus_setcolorrgb__doc__)},
 	{const_cast<char*>("changeColorCMYK"), scribus_setcolorcmyk, METH_VARARGS, tr(scribus_setcolorcmyk__doc__)},




More information about the scribus-commit mailing list