r19564 by craig - #12758: Add applyMasterPage command to scripter
scribus-commit
scribus-commit at lists.scribus.net
Wed Oct 8 19:51:25 UTC 2014
Author: craig
Date: Wed Oct 8 19:51:25 2014
New Revision: 19564
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=19564
Log:
#12758: Add applyMasterPage command to scripter
Modified:
branches/Version14x/Scribus/scribus/plugins/scriptplugin/cmddoc.cpp
branches/Version14x/Scribus/scribus/plugins/scriptplugin/cmddoc.h
branches/Version14x/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp
Modified: branches/Version14x/Scribus/scribus/plugins/scriptplugin/cmddoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19564&path=/branches/Version14x/Scribus/scribus/plugins/scriptplugin/cmddoc.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/plugins/scriptplugin/cmddoc.cpp (original)
+++ branches/Version14x/Scribus/scribus/plugins/scriptplugin/cmddoc.cpp Wed Oct 8 19:51:25 2014
@@ -367,6 +367,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 */
@@ -374,4 +404,5 @@
{
QStringList s;
s << scribus_newdocument__doc__ << scribus_newdoc__doc__ << scribus_closedoc__doc__ << scribus_havedoc__doc__ << scribus_opendoc__doc__ << scribus_savedoc__doc__ << scribus_getdocname__doc__ << scribus_savedocas__doc__ << scribus_setinfo__doc__ <<scribus_setmargins__doc__ <<scribus_setunit__doc__ <<scribus_getunit__doc__ <<scribus_loadstylesfromfile__doc__ <<scribus_setdoctype__doc__ <<scribus_closemasterpage__doc__ <<scribus_masterpagenames__doc__ <<scribus_editmasterpage__doc__ <<scribus_createmasterpage__doc__ <<scribus_deletemasterpage__doc__;
-}
+ s << scribus_applymasterpage__doc__;
+}
Modified: branches/Version14x/Scribus/scribus/plugins/scriptplugin/cmddoc.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19564&path=/branches/Version14x/Scribus/scribus/plugins/scriptplugin/cmddoc.h
==============================================================================
--- branches/Version14x/Scribus/scribus/plugins/scriptplugin/cmddoc.h (original)
+++ branches/Version14x/Scribus/scribus/plugins/scriptplugin/cmddoc.h Wed Oct 8 19:51:25 2014
@@ -266,5 +266,12 @@
"));
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: branches/Version14x/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19564&path=/branches/Version14x/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp (original)
+++ branches/Version14x/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp Wed Oct 8 19:51:25 2014
@@ -281,6 +281,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*>("closeDoc"), (PyCFunction)scribus_closedoc, METH_NOARGS, tr(scribus_closedoc__doc__)},
{const_cast<char*>("closeMasterPage"), (PyCFunction)scribus_closemasterpage, METH_NOARGS, tr(scribus_closemasterpage__doc__)},
More information about the scribus-commit
mailing list