r23697 by jghali - Scripter: add getCellStyles() and getTableStyles()
scribus-commit
scribus-commit at lists.scribus.net
Tue May 5 17:24:44 UTC 2020
Author: jghali
Date: Tue May 5 17:24:44 2020
New Revision: 23697
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=23697
Log:
Scripter: add getCellStyles() and getTableStyles()
Modified:
trunk/Scribus/doc/en/scripterapi-styles.html
trunk/Scribus/doc/fr/scripterapi-styles.html
trunk/Scribus/scribus/plugins/scriptplugin/cmdstyle.cpp
trunk/Scribus/scribus/plugins/scriptplugin/cmdstyle.h
trunk/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp
Modified: trunk/Scribus/doc/en/scripterapi-styles.html
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23697&path=/trunk/Scribus/doc/en/scripterapi-styles.html
==============================================================================
--- trunk/Scribus/doc/en/scripterapi-styles.html (original)
+++ trunk/Scribus/doc/en/scripterapi-styles.html Tue May 5 17:24:44 2020
@@ -187,6 +187,10 @@
<dd><code>getAllStyles() -> list</code>
<p>Deprecated, use getParagraphStyles() instead.</p></dd>
+<dt><a name="-getCellStyles"><strong>getCellStyles</strong></a>(...)</dt>
+<dd><code>getCellStyles() -> list</code>
+<p>Return a list of the names of all cell styles in the current document.</p></dd>
+
<dt><a name="-getCharStyles"><strong>getCharStyles</strong></a>(...)</dt>
<dd><code>getCharStyles() -> list</code>
<p>Return a list of the names of all character styles in the current document.</p></dd>
@@ -199,6 +203,10 @@
<dd><code>getParagraphStyles() -> list</code>
<p>Return a list of the names of all paragraph styles in the current document.</p></dd>
+<dt><a name="-getTableStyles"><strong>getTableStyles</strong></a>(...)</dt>
+<dd><code>getTableStyles() -> list</code>
+<p>Return a list of the names of all table styles in the current document.</p></dd>
+
</dl>
</body>
</html>
Modified: trunk/Scribus/doc/fr/scripterapi-styles.html
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23697&path=/trunk/Scribus/doc/fr/scripterapi-styles.html
==============================================================================
--- trunk/Scribus/doc/fr/scripterapi-styles.html (original)
+++ trunk/Scribus/doc/fr/scripterapi-styles.html Tue May 5 17:24:44 2020
@@ -184,6 +184,10 @@
<dd><tt>getAllStyles() -> liste</tt>
<p>Obsolète. Veuillez utiliser getParagraphStyles() en lieu et place.</p></dd>
+<dt><a name="-getCellStyles"><strong>getCellStyles</strong></a>(...)</dt>
+<dd><tt>getCellStyles() -> liste</tt>
+<p>Retourne une liste des noms de l'ensemble des styles de cellule du document courant.</p></dd>
+
<dt><a name="-getCharStyles"><strong>getCharStyles</strong></a>(...)</dt>
<dd><tt>getCharStyles() -> liste</tt>
<p>Retourne une liste des noms de l'ensemble des styles de caractère du document courant.</p></dd>
@@ -195,6 +199,10 @@
<dt><a name="-getParagraphStyles"><strong>getParagraphStyles</strong></a>(...)</dt>
<dd><tt>getParagraphStyles() -> liste</tt>
<p>Retourne une liste des noms de l'ensemble des styles de paragraphe du document courant.</p></dd>
+
+<dt><a name="-getTableStyles"><strong>getTableStyles</strong></a>(...)</dt>
+<dd><tt>getTableStyles() -> liste</tt>
+<p>Retourne une liste des noms de l'ensemble des styles de tableau du document courant.</p></dd>
</dl>
</body>
Modified: trunk/Scribus/scribus/plugins/scriptplugin/cmdstyle.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23697&path=/trunk/Scribus/scribus/plugins/scriptplugin/cmdstyle.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/cmdstyle.cpp (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/cmdstyle.cpp Tue May 5 17:24:44 2020
@@ -419,6 +419,9 @@
return styleList;
}
+/*
+ * Enumerate all known character styles
+ */
PyObject *scribus_getcharstylenames(PyObject* /* self */)
{
if (!checkHaveDocument())
@@ -438,6 +441,9 @@
return charStyleList;
}
+/*
+ * Enumerate all known line styles
+ */
PyObject *scribus_getlinestyles(PyObject* /* self */)
{
if (!checkHaveDocument())
@@ -456,6 +462,50 @@
}
}
return lineStyleList;
+}
+
+/*
+ * Enumerate all known cell styles
+ */
+PyObject *scribus_getcellstyles(PyObject* /* self */)
+{
+ if (!checkHaveDocument())
+ return nullptr;
+ const auto& cellStyles = ScCore->primaryMainWindow()->doc->cellStyles();
+
+ PyObject *styleList = PyList_New(0);
+ for (int i = 0; i < cellStyles.count(); ++i)
+ {
+ const QString& cellStyleName = cellStyles[i].name();
+ if (PyList_Append(styleList, PyUnicode_FromString(cellStyleName.toUtf8())))
+ {
+ // An exception will have already been set by PyList_Append apparently.
+ return nullptr;
+ }
+ }
+ return styleList;
+}
+
+/*
+ * Enumerate all known table styles
+ */
+PyObject *scribus_gettablestyles(PyObject* /* self */)
+{
+ if (!checkHaveDocument())
+ return nullptr;
+ const auto& tableStyles = ScCore->primaryMainWindow()->doc->tableStyles();
+
+ PyObject *styleList = PyList_New(0);
+ for (int i = 0; i < tableStyles.count(); ++i)
+ {
+ const QString& tableStyleName = tableStyles[i].name();
+ if (PyList_Append(styleList, PyUnicode_FromString(tableStyleName.toUtf8())))
+ {
+ // An exception will have already been set by PyList_Append apparently.
+ return nullptr;
+ }
+ }
+ return styleList;
}
/*! HACK: this removes "warning: 'blah' defined but not used" compiler warnings
Modified: trunk/Scribus/scribus/plugins/scriptplugin/cmdstyle.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23697&path=/trunk/Scribus/scribus/plugins/scriptplugin/cmdstyle.h
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/cmdstyle.h (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/cmdstyle.h Tue May 5 17:24:44 2020
@@ -133,7 +133,6 @@
"));
PyObject *scribus_getcharstylenames(PyObject * /*self*/);
-
/*! docstring */
PyDoc_STRVAR(scribus_getlinestyles__doc__,
QT_TR_NOOP("getLineStyles() -> list\n\
@@ -142,5 +141,21 @@
"));
PyObject *scribus_getlinestyles(PyObject * /*self*/);
+/*! docstring */
+PyDoc_STRVAR(scribus_getcellstyles__doc__,
+QT_TR_NOOP("getCellStyles() -> list\n\
+\n\
+Return a list of the names of all cell styles in the current document.\n\
+"));
+PyObject *scribus_getcellstyles(PyObject * /*self*/);
+
+/*! docstring */
+PyDoc_STRVAR(scribus_gettablestyles__doc__,
+QT_TR_NOOP("getTableStyles() -> list\n\
+\n\
+Return a list of the names of all table styles in the current document.\n\
+"));
+PyObject *scribus_gettablestyles(PyObject * /*self*/);
+
#endif
Modified: trunk/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23697&path=/trunk/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp Tue May 5 17:24:44 2020
@@ -335,6 +335,7 @@
{const_cast<char*>("getAllStyles"), (PyCFunction)scribus_getparagraphstyles, METH_NOARGS, tr(scribus_getallstyles__doc__)}, //Deprecated
{const_cast<char*>("getAllText"), scribus_getalltext, METH_VARARGS, tr(scribus_getalltext__doc__)},
{const_cast<char*>("getCellStyle"), scribus_getcellstyle, METH_VARARGS, tr(scribus_getcellstyle__doc__)},
+ {const_cast<char*>("getCellStyles"), (PyCFunction)scribus_getcellstyles, METH_VARARGS, tr(scribus_getcellstyles__doc__)},
{const_cast<char*>("getCellColumnSpan"), scribus_getcellcolumnspan, METH_VARARGS, tr(scribus_getcellcolumnspan__doc__)},
{const_cast<char*>("getCellRowSpan"), scribus_getcellrowspan, METH_VARARGS, tr(scribus_getcellrowspan__doc__)},
{const_cast<char*>("getCellFillColor"), scribus_getcellfillcolor, METH_VARARGS, tr(scribus_getcellfillcolor__doc__)},
@@ -400,6 +401,7 @@
{const_cast<char*>("getTableColumns"), scribus_gettablecolumns, METH_VARARGS, tr(scribus_gettablecolumns__doc__)},
{const_cast<char*>("getTableColumnWidth"), scribus_gettablecolumnwidth, METH_VARARGS, tr(scribus_gettablecolumnwidth__doc__)},
{const_cast<char*>("getTableStyle"), scribus_gettablestyle, METH_VARARGS, tr(scribus_gettablestyle__doc__)},
+ {const_cast<char*>("getTableStyles"), (PyCFunction)scribus_gettablestyles, METH_VARARGS, tr(scribus_gettablestyles__doc__)},
{const_cast<char*>("getTableFillColor"), scribus_gettablefillcolor, METH_VARARGS, tr(scribus_gettablefillcolor__doc__)},
{const_cast<char*>("getText"), scribus_getframetext, METH_VARARGS, tr(scribus_gettext__doc__)}, // Deprecated
{const_cast<char*>("getTextColor"), scribus_gettextcolor, METH_VARARGS, tr(scribus_gettextcolor__doc__)},
More information about the scribus-commit
mailing list