View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0012758 | Scribus | Scripter | public | 2014-10-08 17:51 | 2014-10-22 11:50 |
Reporter | william | Assigned To | cbradney | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Platform | Intel 64 bit | OS | Fedora Linux | OS Version | 20 |
Fixed in Version | 1.5.0svn | ||||
Summary | 0012758: [patch] Add applyMasterPage command to scripter in Scribus 1.5 | ||||
Description | This patch by Juraj creates a scribus.applyMasterPage(name, page) function where name is a master page and page is a page number. | ||||
Steps To Reproduce | Test script: import scribus scribus.newDocument(scribus.PAPER_A4, (15,15, 20, 20), scribus.PORTRAIT, 1, scribus.UNIT_POINTS, scribus.PAGE_2, 1, 8) def create_mp(name): scribus.createMasterPage(name) scribus.editMasterPage(name) txt=scribus.createText(250, 70, 120, 30) scribus.setText(name, txt) scribus.closeMasterPage() return name odd = create_mp('Odd Master Page') even = create_mp('Even Master Page') for p in range(8): page = p+1 name = odd if page%2 == 0: name = even print (name, page) scribus.applyMasterPage(name, page) scribus.saveDocAs('masterpage.sla') pdf = scribus.PDFfile() pdf.save() #scribus.applyMasterPage('Wrong Name', 1) #scribus.applyMasterPage(even, 42) | ||||
Tags | No tags attached. | ||||
Patch | |||||
related to | 0011490 | closed | Add commands like "getMasterPage() and setMasterPage()" |
|
0001-Add-applyMasterPage-command-to-scripter.patch (4,358 bytes)
From 8653e16bf117ee7ea5d362b1bedccdb4fddd7e98 Mon Sep 17 00:00:00 2001 From: Juraj Fedel <wtxnh-scribus@yahoo.com.au> Date: Wed, 8 Oct 2014 17:38:29 +0200 Subject: [PATCH] Add applyMasterPage command to scripter --- scribus/plugins/scriptplugin/cmddoc.cpp | 31 +++++++++++++++++++++++++ scribus/plugins/scriptplugin/cmddoc.h | 7 +++++ scribus/plugins/scriptplugin/scriptplugin.cpp | 1 + 3 files changed, 39 insertions(+), 0 deletions(-) diff --git a/scribus/plugins/scriptplugin/cmddoc.cpp b/scribus/plugins/scriptplugin/cmddoc.cpp index a4deda5..7d026f2 100644 --- a/scribus/plugins/scriptplugin/cmddoc.cpp +++ b/scribus/plugins/scriptplugin/cmddoc.cpp @@ -389,6 +389,36 @@ PyObject* scribus_deletemasterpage(PyObject* /* self */, PyObject* args) 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 */ @@ -396,4 +426,5 @@ void cmddocdocwarnings() { 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__ << scribus_setbaseline__doc__; + s << scribus_applymasterpage__doc__; } diff --git a/scribus/plugins/scriptplugin/cmddoc.h b/scribus/plugins/scriptplugin/cmddoc.h index 8c5cdc5..80a7285 100644 --- a/scribus/plugins/scriptplugin/cmddoc.h +++ b/scribus/plugins/scriptplugin/cmddoc.h @@ -277,6 +277,13 @@ Delete the named master page.\n\ ")); 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 diff --git a/scribus/plugins/scriptplugin/scriptplugin.cpp b/scribus/plugins/scriptplugin/scriptplugin.cpp index 51cc98e..0985b7b 100644 --- a/scribus/plugins/scriptplugin/scriptplugin.cpp +++ b/scribus/plugins/scriptplugin/scriptplugin.cpp @@ -299,6 +299,7 @@ char* tr(const char* docstringConstant) 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__)}, -- 1.7.2.3 |
|
When you 'Report Issue' there should be a place for you to specify which Scribus Project to post under. It seems the 'Contributor Builds' keeps getting used instead of 'Scribus'. Perhaps 'Contributor Builds' was set to default and you don't get prompted anymore. Can you confirm ? |
|
I have attached a screen capture of what I see when I click on "Report Issue". Under "Category", the only options are "(select)" and "[All Projects] General". |
|
I see it now. There is a "Project" pull down at the upper right. |
|
Bingo :) There is also a screen right before the screen you captured in the screenshot that asks what project you want to post the report under. It doesn't always show up. Not sure why. |
|
changed Category to Scripter and deleted screenshot |
Date Modified | Username | Field | Change |
---|---|---|---|
2014-10-08 17:51 | william | New Issue | |
2014-10-08 17:51 | william | File Added: 0001-Add-applyMasterPage-command-to-scripter.patch | |
2014-10-08 19:40 | Kunda | Project | Contributor Builds => Scribus |
2014-10-08 19:42 | Kunda | Note Added: 0033939 | |
2014-10-08 19:51 | cbradney | Status | new => resolved |
2014-10-08 19:51 | cbradney | Fixed in Version | => 1.4.5.svn |
2014-10-08 19:51 | cbradney | Resolution | open => fixed |
2014-10-08 19:51 | cbradney | Assigned To | => cbradney |
2014-10-08 20:05 | william | Note Added: 0033942 | |
2014-10-08 20:06 | william | File Added: mantis-8oct14.gif | |
2014-10-08 20:07 | william | Note Added: 0033943 | |
2014-10-08 20:23 | Kunda | Note Added: 0033946 | |
2014-10-08 20:24 | Kunda | Note Edited: 0033946 | |
2014-10-09 00:05 | Kunda | Category | General => Scripter |
2014-10-09 00:06 | Kunda | File Deleted: mantis-8oct14.gif | |
2014-10-09 00:06 | Kunda | Note Added: 0033954 | |
2014-10-09 00:06 | Kunda | Note Edited: 0033954 | |
2014-10-10 04:11 | cbradney | Fixed in Version | 1.4.5.svn => 1.5.0svn |
2014-10-14 20:07 | cbradney | Status | resolved => closed |
2014-10-22 11:50 | Kunda | Relationship added | related to 0011490 |