r23695 by jghali - Scripter: add getLineStyles()

scribus-commit scribus-commit at lists.scribus.net
Tue May 5 17:03:51 UTC 2020


Author: jghali
Date: Tue May  5 17:03:51 2020
New Revision: 23695

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=23695
Log:
Scripter: add getLineStyles()

Modified:
    trunk/Scribus/doc/de/scripterapi-styles.html
    trunk/Scribus/doc/en/scripterapi-styles.html
    trunk/Scribus/doc/fr/scripterapi-styles.html
    trunk/Scribus/doc/it/scripterapi-styles.html
    trunk/Scribus/doc/ru/scripterapi-styles.html
    trunk/Scribus/scribus/plugins/scriptplugin/cmdstyle.cpp
    trunk/Scribus/scribus/plugins/scriptplugin/cmdstyle.h
    trunk/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp
    trunk/Scribus/scribus/scribusdoc.h

Modified: trunk/Scribus/doc/de/scripterapi-styles.html
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23695&path=/trunk/Scribus/doc/de/scripterapi-styles.html
==============================================================================
--- trunk/Scribus/doc/de/scripterapi-styles.html	(original)
+++ trunk/Scribus/doc/de/scripterapi-styles.html	Tue May  5 17:03:51 2020
@@ -191,6 +191,10 @@
 <dd><code>getCharStyles() -> list</code>
 <p>Return a list of the names of all character styles in the current document.</p></dd>
 
+<dt><a name="-getLineStyles"><strong>getLineStyles</strong></a>(...)</dt>
+<dd><code>getLineStyles() -> list</code>
+<p>Return a list of the names of all line styles in the current document.</p></dd>
+
 <dt><a name="-getParagraphStyles"><strong>getParagraphStyles</strong></a>(...)</dt>
 <dd><code>getParagraphStyles() -> list</code>
 <p>Return a list of the names of all paragraph styles in the current document.</p></dd>

Modified: trunk/Scribus/doc/en/scripterapi-styles.html
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23695&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:03:51 2020
@@ -191,6 +191,10 @@
 <dd><code>getCharStyles() -> list</code>
 <p>Return a list of the names of all character styles in the current document.</p></dd>
 
+<dt><a name="-getLineStyles"><strong>getLineStyles</strong></a>(...)</dt>
+<dd><code>getLineStyles() -> list</code>
+<p>Return a list of the names of all line styles in the current document.</p></dd>
+
 <dt><a name="-getParagraphStyles"><strong>getParagraphStyles</strong></a>(...)</dt>
 <dd><code>getParagraphStyles() -> list</code>
 <p>Return a list of the names of all paragraph styles in the current document.</p></dd>

Modified: trunk/Scribus/doc/fr/scripterapi-styles.html
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23695&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:03:51 2020
@@ -188,6 +188,10 @@
 <dd><tt>getCharStyles() -> liste</tt>
 <p>Retourne une liste des noms de l'ensemble des styles de caractère du document courant.</p></dd>
 
+<dt><a name="-getLineStyles"><strong>getLineStyles</strong></a>(...)</dt>
+<dd><tt>getLineStyles() -> liste</tt>
+<p>Retourne une liste des noms de l'ensemble des styles de filet du document courant.</p></dd>
+
 <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>

Modified: trunk/Scribus/doc/it/scripterapi-styles.html
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23695&path=/trunk/Scribus/doc/it/scripterapi-styles.html
==============================================================================
--- trunk/Scribus/doc/it/scripterapi-styles.html	(original)
+++ trunk/Scribus/doc/it/scripterapi-styles.html	Tue May  5 17:03:51 2020
@@ -191,6 +191,10 @@
 <dd><code>getCharStyles() -> list</code>
 <p>Return a list of the names of all character styles in the current document.</p></dd>
 
+<dt><a name="-getLineStyles"><strong>getLineStyles</strong></a>(...)</dt>
+<dd><code>getLineStyles() -> list</code>
+<p>Return a list of the names of all line styles in the current document.</p></dd>
+
 <dt><a name="-getParagraphStyles"><strong>getParagraphStyles</strong></a>(...)</dt>
 <dd><code>getParagraphStyles() -> list</code>
 <p>Return a list of the names of all paragraph styles in the current document.</p></dd>

Modified: trunk/Scribus/doc/ru/scripterapi-styles.html
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23695&path=/trunk/Scribus/doc/ru/scripterapi-styles.html
==============================================================================
--- trunk/Scribus/doc/ru/scripterapi-styles.html	(original)
+++ trunk/Scribus/doc/ru/scripterapi-styles.html	Tue May  5 17:03:51 2020
@@ -191,6 +191,10 @@
 <dd><code>getCharStyles() -> list</code>
 <p>Return a list of the names of all character styles in the current document.</p></dd>
 
+<dt><a name="-getLineStyles"><strong>getLineStyles</strong></a>(...)</dt>
+<dd><code>getLineStyles() -> list</code>
+<p>Return a list of the names of all line styles in the current document.</p></dd>
+
 <dt><a name="-getParagraphStyles"><strong>getParagraphStyles</strong></a>(...)</dt>
 <dd><code>getParagraphStyles() -> list</code>
 <p>Return a list of the names of all paragraph styles in the current document.</p></dd>

Modified: trunk/Scribus/scribus/plugins/scriptplugin/cmdstyle.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23695&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:03:51 2020
@@ -402,15 +402,15 @@
  */
 PyObject *scribus_getparagraphstyles(PyObject* /* self */)
 {
-	PyObject *styleList;
 	if (!checkHaveDocument())
 		return nullptr;
 	const auto& paragraphStyles = ScCore->primaryMainWindow()->doc->paragraphStyles();
 
-	styleList = PyList_New(0);
+	PyObject *styleList = PyList_New(0);
 	for (int i = 0; i < paragraphStyles.count(); ++i)
 	{
-		if (PyList_Append(styleList, PyUnicode_FromString(paragraphStyles[i].name().toUtf8())))
+		const QString& paraStyleName = paragraphStyles[i].name();
+		if (PyList_Append(styleList, PyUnicode_FromString(paraStyleName.toUtf8())))
 		{
 			// An exception will have already been set by PyList_Append apparently.
 			return nullptr;
@@ -421,21 +421,41 @@
 
 PyObject *scribus_getcharstylenames(PyObject* /* self */)
 {
-	PyObject *charStyleList;
 	if (!checkHaveDocument())
 		return nullptr;
 	const auto& charStyles = ScCore->primaryMainWindow()->doc->charStyles();
 
-	charStyleList = PyList_New(0);
+	PyObject *charStyleList = PyList_New(0);
 	for (int i = 0; i < charStyles.count(); ++i)
 	{
-		if (PyList_Append(charStyleList, PyUnicode_FromString(charStyles[i].name().toUtf8())))
+		const QString& charStyleName = charStyles[i].name();
+		if (PyList_Append(charStyleList, PyUnicode_FromString(charStyleName.toUtf8())))
 		{
 			// An exception will have already been set by PyList_Append apparently.
 			return nullptr;
 		}
 	}
 	return charStyleList;
+}
+
+PyObject *scribus_getlinestyles(PyObject* /* self */)
+{
+	if (!checkHaveDocument())
+		return nullptr;
+	const auto& lineStyles = ScCore->primaryMainWindow()->doc->lineStyles();
+
+	PyObject *lineStyleList = PyList_New(0);
+	auto itEnd = lineStyles.constEnd();
+	for (auto it = lineStyles.constBegin(); it != itEnd; ++it)
+	{
+		QString lineStyleName = it.key();
+		if (PyList_Append(lineStyleList, PyUnicode_FromString(lineStyleName.toUtf8())))
+		{
+			// An exception will have already been set by PyList_Append apparently.
+			return nullptr;
+		}
+	}
+	return lineStyleList;
 }
 
 /*! HACK: this removes "warning: 'blah' defined but not used" compiler warnings
@@ -449,5 +469,6 @@
 	   << scribus_createparagraphstyle__doc__
 	   << scribus_getallstyles__doc__
 	   << scribus_getcharstylenames__doc__
+	   << scribus_getlinestyles__doc__
 	   << scribus_getparagraphstyles__doc__;
 }

Modified: trunk/Scribus/scribus/plugins/scriptplugin/cmdstyle.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23695&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:03:51 2020
@@ -133,5 +133,14 @@
 "));
 PyObject *scribus_getcharstylenames(PyObject * /*self*/);
 
+
+/*! docstring */
+PyDoc_STRVAR(scribus_getlinestyles__doc__,
+QT_TR_NOOP("getLineStyles() -> list\n\
+\n\
+Return a list of the names of all line styles in the current document.\n\
+"));
+PyObject *scribus_getlinestyles(PyObject * /*self*/);
+
 #endif
 

Modified: trunk/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23695&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:03:51 2020
@@ -377,6 +377,7 @@
 	{const_cast<char*>("getLineJoin"), scribus_getlinejoin, METH_VARARGS, tr(scribus_getlinejoin__doc__)},
 	{const_cast<char*>("getLineSpacing"), scribus_getlinespace, METH_VARARGS, tr(scribus_getlinespace__doc__)},
 	{const_cast<char*>("getLineStyle"), scribus_getlinestyle, METH_VARARGS, tr(scribus_getlinestyle__doc__)},
+	{const_cast<char*>("getLineStyles"), (PyCFunction)scribus_getlinestyles, METH_VARARGS, tr(scribus_getlinestyles__doc__)},
 	{const_cast<char*>("getLineWidth"), scribus_getlinewidth, METH_VARARGS, tr(scribus_getlinewidth__doc__)},
 	{const_cast<char*>("getMasterPage"), scribus_getmasterpage, METH_VARARGS, tr(scribus_getmasterpage__doc__)},
 	{const_cast<char*>("getPageItems"), (PyCFunction)scribus_getpageitems, METH_NOARGS, tr(scribus_getpageitems__doc__)},

Modified: trunk/Scribus/scribus/scribusdoc.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23695&path=/trunk/Scribus/scribus/scribusdoc.h
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.h	(original)
+++ trunk/Scribus/scribus/scribusdoc.h	Tue May  5 17:03:51 2020
@@ -539,6 +539,8 @@
 	bool isDefaultStyle( const CharStyle& c ) const { return m_docCharStyles.isDefault(c); }
 // 	bool isDefaultStyle( LineStyle& l ) const { return MLineStyles......; }
 
+	const QHash<QString, multiLine>& lineStyles() const { return MLineStyles; }
+
 	/**
 	 * Returns the table style named @a name.
 	 */
@@ -1403,7 +1405,7 @@
 	bool isConverted {false};
 	QTimer * const autoSaveTimer;
 	QList<QString> autoSaveFiles;
-	QHash<QString,multiLine> MLineStyles;
+	QHash<QString, multiLine> MLineStyles;
 	QHash<QString, ScPattern> docPatterns;
 	QHash<QString, VGradient> docGradients;
 	QWidget* WinHan {nullptr};




More information about the scribus-commit mailing list