r22927 by jghali - Refactor scripter's scribus_getstylenames() and scribus_getcharstylenames()

scribus-commit scribus-commit at lists.scribus.net
Thu Apr 4 17:26:49 UTC 2019


Author: jghali
Date: Thu Apr  4 17:26:49 2019
New Revision: 22927

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=22927
Log:
Refactor scripter's scribus_getstylenames() and scribus_getcharstylenames()

Modified:
    trunk/Scribus/scribus/plugins/scriptplugin/cmdobj.cpp

Modified: trunk/Scribus/scribus/plugins/scriptplugin/cmdobj.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22927&path=/trunk/Scribus/scribus/plugins/scriptplugin/cmdobj.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/cmdobj.cpp	(original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/cmdobj.cpp	Thu Apr  4 17:26:49 2019
@@ -793,10 +793,12 @@
 	PyObject *styleList;
 	if (!checkHaveDocument())
 		return nullptr;
+	const auto& paragraphStyles = ScCore->primaryMainWindow()->doc->paragraphStyles();
+
 	styleList = PyList_New(0);
-	for (int i=0; i < ScCore->primaryMainWindow()->doc->paragraphStyles().count(); ++i)
-	{
-		if (PyList_Append(styleList, PyString_FromString(ScCore->primaryMainWindow()->doc->paragraphStyles()[i].name().toUtf8())))
+	for (int i = 0; i < paragraphStyles.count(); ++i)
+	{
+		if (PyList_Append(styleList, PyString_FromString(paragraphStyles[i].name().toUtf8())))
 		{
 			// An exception will have already been set by PyList_Append apparently.
 			return nullptr;
@@ -810,10 +812,12 @@
 	PyObject *charStyleList;
 	if (!checkHaveDocument())
 		return nullptr;
+	const auto& charStyles = ScCore->primaryMainWindow()->doc->charStyles();
+
 	charStyleList = PyList_New(0);
-	for (int i=0; i < ScCore->primaryMainWindow()->doc->charStyles().count(); ++i)
-	{
-		if (PyList_Append(charStyleList, PyString_FromString(ScCore->primaryMainWindow()->doc->charStyles()[i].name().toUtf8())))
+	for (int i = 0; i < charStyles.count(); ++i)
+	{
+		if (PyList_Append(charStyleList, PyString_FromString(charStyles[i].name().toUtf8())))
 		{
 			// An exception will have already been set by PyList_Append apparently.
 			return nullptr;




More information about the scribus-commit mailing list