View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0008650 | Scribus | Scripter | public | 2009-12-16 16:02 | 2010-01-02 23:37 |
Reporter | gpothier | Assigned To | jghali | ||
Priority | normal | Severity | feature | Reproducibility | N/A |
Status | closed | Resolution | fixed | ||
Product Version | 1.5.0svn | ||||
Fixed in Version | 1.5.0svn | ||||
Summary | 0008650: Patch adding two new Scripter API functions | ||||
Description | The attached patch (against svn trunk) adds two new functions to the Scripter API: - setLineSpacingMode(mode, "name"): sets the line spacing mode of a text frame. The values for the mode are the same as those described in createParagraphStyle (fixed linespacing: 0, automatic linespacing: 1, baseline grid linespacing: 2) - setBaseLine(grid, offset): sets the baseline guides parameters of the current document. The values are in the measurement units of the document. | ||||
Tags | No tags attached. | ||||
Patch | |||||
2009-12-16 16:02
|
funcs.diff (6,449 bytes)
Index: /home/gpothier/devel/scribus/Scribus/scribus/plugins/scriptplugin/cmddoc.h =================================================================== --- /home/gpothier/devel/scribus/Scribus/scribus/plugins/scriptplugin/cmddoc.h (revision 14416) +++ /home/gpothier/devel/scribus/Scribus/scribus/plugins/scriptplugin/cmddoc.h (working copy) @@ -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, Qt::DockLeft(grid), Qt::DockRight(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\ Index: /home/gpothier/devel/scribus/Scribus/scribus/plugins/scriptplugin/cmdtext.cpp =================================================================== --- /home/gpothier/devel/scribus/Scribus/scribus/plugins/scriptplugin/cmdtext.cpp (revision 14416) +++ /home/gpothier/devel/scribus/Scribus/scribus/plugins/scriptplugin/cmdtext.cpp (working copy) @@ -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: /home/gpothier/devel/scribus/Scribus/scribus/plugins/scriptplugin/cmddoc.cpp =================================================================== --- /home/gpothier/devel/scribus/Scribus/scribus/plugins/scriptplugin/cmddoc.cpp (revision 14416) +++ /home/gpothier/devel/scribus/Scribus/scribus/plugins/scriptplugin/cmddoc.cpp (working copy) @@ -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: /home/gpothier/devel/scribus/Scribus/scribus/plugins/scriptplugin/cmdtext.h =================================================================== --- /home/gpothier/devel/scribus/Scribus/scribus/plugins/scriptplugin/cmdtext.h (revision 14416) +++ /home/gpothier/devel/scribus/Scribus/scribus/plugins/scriptplugin/cmdtext.h (working copy) @@ -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: /home/gpothier/devel/scribus/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp =================================================================== --- /home/gpothier/devel/scribus/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp (revision 14416) +++ /home/gpothier/devel/scribus/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp (working copy) @@ -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__)}, |
|
Patch applied with some minor modification in the function description strings. Thanks! |
Date Modified | Username | Field | Change |
---|---|---|---|
2009-12-16 16:02 | gpothier | New Issue | |
2009-12-16 16:02 | gpothier | File Added: funcs.diff | |
2009-12-17 23:25 | jghali | Note Added: 0022980 | |
2009-12-17 23:25 | jghali | Status | new => resolved |
2009-12-17 23:25 | jghali | Fixed in Version | => 1.5.0svn |
2009-12-17 23:25 | jghali | Resolution | open => fixed |
2009-12-17 23:25 | jghali | Assigned To | => jghali |
2010-01-02 23:37 | cbradney | Status | resolved => closed |