r14427 by jghali - #8650: new Scripter API functions Add functions for setting baseline grid spacing/offset and line spacing mode
scribus-commit
scribus-commit at lists.scribus.net
Fri Dec 18 00:25:35 CET 2009
Revision: 14427
Author: jghali
Date: 2009-12-17T11:55:50.045075Z
Commit message: #8650: new Scripter API functions
Add functions for setting baseline grid spacing/offset and line spacing mode
Changeset:
M /trunk/Scribus/scribus/plugins/scriptplugin/cmdtext.cpp
M /trunk/Scribus/scribus/plugins/scriptplugin/cmddoc.cpp
M /trunk/Scribus/scribus/plugins/scriptplugin/cmdtext.h
M /trunk/Scribus/scribus/plugins/scriptplugin/cmddoc.h
M /trunk/Scribus/doc/en/scripterapi-textframes.html
M /trunk/Scribus/doc/en/scripterapi-doc.html
M /trunk/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp
Diffs:
Index: doc/en/scripterapi-textframes.html
===================================================================
--- doc/en/scripterapi-textframes.html (revision 14426)
+++ doc/en/scripterapi-textframes.html (revision 14427)
@@ -112,6 +112,11 @@
<p>Sets the line spacing ("leading") of the text frame "name" to "size". "size" is a value in points. If "name" is not given the currently selected item is used.</p>
<p>May throw ValueError if the line spacing is out of bounds.</p></dd>
+<dt><a name="-setLineSpacingMode"><strong>setLineSpacingMode</strong></a>(...)</dt>
+<dd><code>setLineSpacingMode(mode, ["name"])</code>
+<p>Sets the line spacing mode of the text frame "name" to "mode". If "name" is not given the currently selected item is used. Mode values are the same as in createParagraphStyle.</p>
+<p>May throw ValueError if the line spacing mode is out of bounds.</p></dd>
+
<dt><a name="-setPDFBookmark"><strong>setPDFBookmark</strong>(...)</a></dt>
<dd><code>setPDFBookmark("toggle", ["name"])</code>
<p>Sets wether (toggle = 1) the text frame "name" is a bookmark nor not. If "name" is not given the currently selected item is used.</p>
Index: doc/en/scripterapi-doc.html
===================================================================
--- doc/en/scripterapi-doc.html (revision 14426)
+++ doc/en/scripterapi-doc.html (revision 14427)
@@ -148,6 +148,10 @@
<p>Changes the measurement unit of the document. Possible values for "unit" are defined as constants UNIT_<type>.</p>
<p>May raise ValueError if an invalid unit is passed.</p></dd>
+<dt><a name="-setBaseLine"><strong>setBaseLine</strong></a>(...)</dt>
+<dd><code>setBaseLine(grid, offset)</code>
+<p>Sets the base line settings of the document, grid spacing(grid), grid offset(offset). Values are given in the measurement units of the document - see UNIT_<type> constants.</p></dd>
+
<dt><a name="-scrollDocument"><strong>scrollDocument</strong>(...)</a></dt>
<dd><code>scrollDocument(x,y)</code>
<p>Scroll the document in main GUI window by x and y.</p></dd>
Index: scribus/plugins/scriptplugin/cmddoc.h
===================================================================
--- scribus/plugins/scriptplugin/cmddoc.h (revision 14426)
+++ scribus/plugins/scriptplugin/cmddoc.h (revision 14427)
@@ -177,7 +177,7 @@
PyDoc_STRVAR(scribus_setmargins__doc__,
QT_TR_NOOP("setMargins(lr, rr, tr, br)\n\
\n\
-Sets the margins of the document, Qt::DockLeft(lr), Qt::DockRight(rr), Qt::DockTop(tr) and Qt::DockBottom(br)\n\
+Sets the margins of the document, Left(lr), Right(rr), Top(tr) and Bottom(br)\n\
margins are given in the measurement units of the document - see UNIT_<type>\n\
constants.\n\
"));
@@ -185,6 +185,17 @@
PyObject *scribus_setmargins(PyObject * /*self*/, PyObject* args);
/*! docstring */
+PyDoc_STRVAR(scribus_setbaseline__doc__,
+QT_TR_NOOP("setBaseLine(grid, offset)\n\
+\n\
+Sets the base line settings of the document, grid spacing(grid), grid offset(offset).\n\
+Values are given in the measurement units of the document - see UNIT_<type>\n\
+constants.\n\
+"));
+/** Sets document baseline settings - grid and offset. */
+PyObject *scribus_setbaseline(PyObject * /*self*/, PyObject* args);
+
+/*! docstring */
PyDoc_STRVAR(scribus_setunit__doc__,
QT_TR_NOOP("setUnit(type)\n\
\n\
@@ -268,3 +279,4 @@
#endif
+
Index: scribus/plugins/scriptplugin/cmdtext.cpp
===================================================================
--- scribus/plugins/scriptplugin/cmdtext.cpp (revision 14426)
+++ scribus/plugins/scriptplugin/cmdtext.cpp (revision 14427)
@@ -461,6 +461,40 @@
Py_RETURN_NONE;
}
+PyObject *scribus_setlinespacemode(PyObject* /* self */, PyObject* args)
+{
+ char *Name = const_cast<char*>("");
+ int w;
+ if (!PyArg_ParseTuple(args, "i|es", &w, "utf-8", &Name))
+ return NULL;
+ if(!checkHaveDocument())
+ return NULL;
+ if (w < 0 || w > 3) // Use constants?
+ {
+ PyErr_SetString(PyExc_ValueError, QObject::tr("Line space mode invalid, must be 0, 1 or 2","python error").toLocal8Bit().constData());
+ return NULL;
+ }
+ PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
+ if (i == NULL)
+ return NULL;
+ if (!i->asTextFrame())
+ {
+ PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set line spacing mode on a non-text frame.","python error").toLocal8Bit().constData());
+ return NULL;
+ }
+
+ int Apm = ScCore->primaryMainWindow()->doc->appMode;
+ ScCore->primaryMainWindow()->doc->m_Selection->clear();
+ ScCore->primaryMainWindow()->doc->m_Selection->addItem(i);
+ if (i->HasSel)
+ ScCore->primaryMainWindow()->doc->appMode = modeEdit;
+ ScCore->primaryMainWindow()->doc->itemSelection_SetLineSpacingMode(w);
+ ScCore->primaryMainWindow()->doc->appMode = Apm;
+ ScCore->primaryMainWindow()->view->Deselect();
+
+ Py_RETURN_NONE;
+}
+
PyObject *scribus_settextdistances(PyObject* /* self */, PyObject* args)
{
char *Name = const_cast<char*>("");
Index: scribus/plugins/scriptplugin/cmddoc.cpp
===================================================================
--- scribus/plugins/scriptplugin/cmddoc.cpp (revision 14426)
+++ scribus/plugins/scriptplugin/cmddoc.cpp (revision 14427)
@@ -128,6 +128,25 @@
Py_RETURN_NONE;
}
+PyObject *scribus_setbaseline(PyObject* /* self */, PyObject* args)
+{
+ double grid, offset;
+ if (!PyArg_ParseTuple(args, "dd", &grid, &offset))
+ return NULL;
+ if(!checkHaveDocument())
+ return NULL;
+ ScCore->primaryMainWindow()->doc->guidesSettings.valueBaselineGrid = ValueToPoint(grid);
+ ScCore->primaryMainWindow()->doc->guidesSettings.offsetBaselineGrid = ValueToPoint(offset);
+ //ScCore->primaryMainWindow()->view->reformPages();
+ ScCore->primaryMainWindow()->doc->setModified(true);
+ //ScCore->primaryMainWindow()->view->GotoPage(ScCore->primaryMainWindow()->doc->currentPageNumber());
+ ScCore->primaryMainWindow()->view->DrawNew();
+// Py_INCREF(Py_None);
+// return Py_None;
+ Py_RETURN_NONE;
+}
+
+
PyObject *scribus_closedoc(PyObject* /* self */)
{
if(!checkHaveDocument())
Index: scribus/plugins/scriptplugin/cmdtext.h
===================================================================
--- scribus/plugins/scriptplugin/cmdtext.h (revision 14426)
+++ scribus/plugins/scriptplugin/cmdtext.h (revision 14427)
@@ -188,6 +188,20 @@
PyObject *scribus_setlinespace(PyObject * /*self*/, PyObject* args);
/*! docstring */
+PyDoc_STRVAR(scribus_setlinespacemode__doc__,
+QT_TR_NOOP("setLineSpacingMode(mode, [\"name\"])\n\
+\n\
+Sets the line spacing mode of the text frame \"name\" to \"mode\".\n\
+If \"name\" is not given the currently selected\n\
+item is used.\n\
+Mode values are the same as in createParagraphStyle.\n\
+\n\
+May throw ValueError if the mode is out of bounds.\n\
+"));
+/*! Set line space mode */
+PyObject *scribus_setlinespacemode(PyObject * /*self*/, PyObject* args);
+
+/*! docstring */
PyDoc_STRVAR(scribus_settextdistances__doc__,
QT_TR_NOOP("setTextDistances(left, right, top, bottom, [\"name\"])\n\
\n\
Index: scribus/plugins/scriptplugin/scriptplugin.cpp
===================================================================
--- scribus/plugins/scriptplugin/scriptplugin.cpp (revision 14426)
+++ scribus/plugins/scriptplugin/scriptplugin.cpp (revision 14427)
@@ -456,9 +456,11 @@
{const_cast<char*>("setLineJoin"), scribus_setlinejoin, METH_VARARGS, tr(scribus_setlinejoin__doc__)},
{const_cast<char*>("setLineShade"), scribus_setlineshade, METH_VARARGS, tr(scribus_setlineshade__doc__)},
{const_cast<char*>("setLineSpacing"), scribus_setlinespace, METH_VARARGS, tr(scribus_setlinespace__doc__)},
+ {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*>("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__)},
// duplicity? {"setMultiLine", scribus_setmultiline, METH_VARARGS, "TODO: docstring"},
{const_cast<char*>("setRedraw"), scribus_setredraw, METH_VARARGS, tr(scribus_setredraw__doc__)},
More information about the scribus-commit
mailing list