View Issue Details

IDProjectCategoryView StatusLast Update
0015493ScribusScripterpublic2020-04-12 21:09
ReporterIam_TJ Assigned Tocbradney  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version1.5.4.svn 
Target VersionFixed in Version1.5.6.svn 
Summary0015493: [PATCH] scriptplugin: Add setBleeds to API
DescriptionAdd a ScribusDoc::setBleeds() method and allow the scripter API access to it.
Tagspatch
PatchYes

Activities

Iam_TJ

2018-11-25 18:58

reporter  

0001-scriptplugin-Add-setBleeds-to-API.patch (5,953 bytes)
From 4264c5a83a3a2c21b634c1f25cc6f83a96212809 Mon Sep 17 00:00:00 2001
From: TJ <hacker@iam.tj>
Date: Sun, 25 Nov 2018 18:27:56 +0000
Subject: [PATCH] scriptplugin: Add setBleeds() to API

Signed-off-by: TJ <hacker@iam.tj>
---
 doc/en/scripterapi-doc.html                   |  4 ++++
 scribus/plugins/scriptplugin/cmddoc.cpp       | 20 +++++++++++++++++++
 scribus/plugins/scriptplugin/cmddoc.h         | 11 ++++++++++
 scribus/plugins/scriptplugin/scriptplugin.cpp |  1 +
 scribus/scribusdoc.cpp                        | 13 ++++++++++++
 scribus/scribusdoc.h                          |  7 ++++++-
 6 files changed, 55 insertions(+), 1 deletion(-)

diff --git a/doc/en/scripterapi-doc.html b/doc/en/scripterapi-doc.html
index 3bba9c334..2421ccf3c 100644
--- a/doc/en/scripterapi-doc.html
+++ b/doc/en/scripterapi-doc.html
@@ -154,6 +154,10 @@ relative path).</p>
 <dd><code>setInfo("author", "info", "description") -&gt; bool</code>
 <p>Sets the document information. "Author", "Info", "Description" are strings.</p></dd>
 
+<dt><a name="-setBleeds"><strong>setBleeds</strong></a>(...)</dt>
+<dd><code>setBleeds(lr, rr, tr, br)</code>
+<p>Sets the bleeds of the document, Left(lr), Right(rr), Top(tr) and Bottom(br) bleeds are given in the measurement units of the document - see UNIT_&lt;type&gt; constants.</p></dd>
+
 <dt><a name="-setMargins"><strong>setMargins</strong></a>(...)</dt>
 <dd><code>setMargins(lr, rr, tr, br)</code>
 <p>Sets the margins of the document, Left(lr), Right(rr), Top(tr) and Bottom(br) margins are given in the measurement units of the document - see UNIT_&lt;type&gt; constants.</p></dd>
diff --git a/scribus/plugins/scriptplugin/cmddoc.cpp b/scribus/plugins/scriptplugin/cmddoc.cpp
index 8cfe8020b..d1fd2bcf0 100644
--- a/scribus/plugins/scriptplugin/cmddoc.cpp
+++ b/scribus/plugins/scriptplugin/cmddoc.cpp
@@ -112,6 +112,26 @@ PyObject *scribus_newdoc(PyObject* /* self */, PyObject* args)
 	return PyInt_FromLong(static_cast<long>(ret));
 }
 
+PyObject *scribus_setbleeds(PyObject* /* self */, PyObject* args)
+{
+	double lr, tpr, btr, rr;
+	if (!PyArg_ParseTuple(args, "dddd", &lr, &rr, &tpr, &btr))
+		return nullptr;
+	if (!checkHaveDocument())
+		return nullptr;
+	MarginStruct bleeds(ValueToPoint(tpr), ValueToPoint(lr), ValueToPoint(btr), ValueToPoint(rr));
+
+	ScribusDoc* currentDoc = ScCore->primaryMainWindow()->doc;
+	ScribusView* currentView = ScCore->primaryMainWindow()->view;
+	if (currentDoc->setBleeds(bleeds))
+	{
+		currentView->reformPages();
+		currentDoc->setModified(true);
+		currentView->DrawNew();
+	}
+	Py_RETURN_NONE;
+}
+
 PyObject *scribus_setmargins(PyObject* /* self */, PyObject* args)
 {
 	double lr, tpr, btr, rr;
diff --git a/scribus/plugins/scriptplugin/cmddoc.h b/scribus/plugins/scriptplugin/cmddoc.h
index a4946fc8c..4237548c1 100644
--- a/scribus/plugins/scriptplugin/cmddoc.h
+++ b/scribus/plugins/scriptplugin/cmddoc.h
@@ -173,6 +173,17 @@ strings.\n\
 /** Sets document infos - author, title and description */
 PyObject *scribus_setinfo(PyObject * /*self*/, PyObject* args);
 
+/*! docstring */
+PyDoc_STRVAR(scribus_setbleeds__doc__,
+QT_TR_NOOP("setBleeds(lr, rr, tr, br)\n\
+\n\
+Sets the bleeds of the document, Left(lr), Right(rr), Top(tr) and Bottom(br)\n\
+bleeds are given in the measurement units of the document - see UNIT_<type>\n\
+constants.\n\
+"));
+/** Sets document bleeds - left, right, top and bottom. */
+PyObject *scribus_setbleeds(PyObject * /*self*/, PyObject* args);
+
 /*! docstring */
 PyDoc_STRVAR(scribus_setmargins__doc__,
 QT_TR_NOOP("setMargins(lr, rr, tr, br)\n\
diff --git a/scribus/plugins/scriptplugin/scriptplugin.cpp b/scribus/plugins/scriptplugin/scriptplugin.cpp
index d85675dbc..e6b79de73 100644
--- a/scribus/plugins/scriptplugin/scriptplugin.cpp
+++ b/scribus/plugins/scriptplugin/scriptplugin.cpp
@@ -535,6 +535,7 @@ PyMethodDef scribus_methods[] = {
 	{const_cast<char*>("setLineSpacingMode"), scribus_setlinespacemode, METH_VARARGS, tr(scribus_setlinespacemode__doc__)},
 	{const_cast<char*>("setLineStyle"), scribus_setlinestyle, METH_VARARGS, tr(scribus_setlinestyle__doc__)},
 	{const_cast<char*>("setLineWidth"), scribus_setlinewidth, METH_VARARGS, tr(scribus_setlinewidth__doc__)},
+	{const_cast<char*>("setBleeds"), scribus_setbleeds, METH_VARARGS, tr(scribus_setbleeds__doc__)},
 	{const_cast<char*>("setMargins"), scribus_setmargins, METH_VARARGS, tr(scribus_setmargins__doc__)},
 	{const_cast<char*>("setBaseLine"), scribus_setbaseline, METH_VARARGS, tr(scribus_setbaseline__doc__)},
 	{const_cast<char*>("setMultiLine"), scribus_setmultiline, METH_VARARGS, tr(scribus_setmultiline__doc__)},
diff --git a/scribus/scribusdoc.cpp b/scribus/scribusdoc.cpp
index f7f6e0be2..5c2f6ead7 100644
--- a/scribus/scribusdoc.cpp
+++ b/scribus/scribusdoc.cpp
@@ -6298,6 +6298,19 @@ double ScribusDoc::getYOffsetForPage(const int pageNumber)
 	return -1.0;
 }
 
+bool ScribusDoc::setBleeds(MarginStruct& bleedData)
+{
+	bool result = false;
+	auto& bleeds = m_docPrefsData.docSetupPrefs.bleeds;
+	if (bleedData.left() >= 0 && bleedData.right() >= 0 &&
+		bleedData.top() >= 0 && bleedData.bottom() >= 0)
+	{
+        bleeds.set(bleedData.top(), bleedData.left(), bleedData.bottom(), bleedData.right());
+		result = true;
+	}
+	return result;
+}
+
 void ScribusDoc::getBleeds(int pageNumber, MarginStruct &bleedData)
 {
 	if (pageNumber >= 0 && pageNumber < Pages->size())
diff --git a/scribus/scribusdoc.h b/scribus/scribusdoc.h
index 88bbae4ee..d41cb634c 100644
--- a/scribus/scribusdoc.h
+++ b/scribus/scribusdoc.h
@@ -896,7 +896,12 @@ public:
 	void getBleeds(int pageNumber, MarginStruct& bleedData);
 	void getBleeds(const ScPage* page, MarginStruct& bleedData);
 	void getBleeds(const ScPage* page, const MarginStruct& baseValues, MarginStruct& bleedData);
-	
+
+	/**
+	 * @brief set the document bleed values
+	 */
+	bool setBleeds(MarginStruct& bleedData);
+
 	/**
 	 * @brief Item type conversion functions
 	 */
-- 
2.17.1

ale

2019-07-05 14:39

manager   ~0046367

this has also been requested through github:

https://github.com/scribusproject/scribus/issues/121

is there any reason why this patch has not been accepted yet?

Issue History

Date Modified Username Field Change
2018-11-25 18:37 Iam_TJ New Issue
2018-11-25 18:37 Iam_TJ File Added: 0001-scriptplugin-Add-setBleeds-to-API.patch
2018-11-25 18:57 Iam_TJ File Deleted: 0001-scriptplugin-Add-setBleeds-to-API.patch
2018-11-25 18:58 Iam_TJ File Added: 0001-scriptplugin-Add-setBleeds-to-API.patch
2019-07-05 14:39 ale Note Added: 0046367
2019-07-05 14:39 ale Summary scriptplugin: Add setBleeds to API => [PATCH] scriptplugin: Add setBleeds to API
2019-07-05 14:39 ale Tag Attached: patch
2020-04-12 21:09 cbradney Assigned To => cbradney
2020-04-12 21:09 cbradney Status new => resolved
2020-04-12 21:09 cbradney Resolution open => fixed
2020-04-12 21:09 cbradney Fixed in Version => 1.5.6.svn