r23168 by jghali - #15794: Add bullet support for scripter plugin

scribus-commit scribus-commit at lists.scribus.net
Fri Aug 30 08:01:20 UTC 2019


Author: jghali
Date: Fri Aug 30 08:01:20 2019
New Revision: 23168

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=23168
Log:
#15794: Add bullet support for scripter plugin

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/scribus/plugins/scriptplugin/cmdstyle.cpp
    trunk/Scribus/scribus/plugins/scriptplugin/cmdstyle.h

Modified: trunk/Scribus/doc/de/scripterapi-styles.html
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23168&path=/trunk/Scribus/doc/de/scripterapi-styles.html
==============================================================================
--- trunk/Scribus/doc/de/scripterapi-styles.html	(original)
+++ trunk/Scribus/doc/de/scripterapi-styles.html	Fri Aug 30 08:01:20 2019
@@ -162,12 +162,17 @@
 <li>dropcaplines [optional] -> height (in lines) of the caps if used</li>
 <li>dropcapoffset [optional] -> offset of the caps if used</li>
 <li>"charstyle" [optional] -> char style to use</li>
+<li>"bullet" [optional] -> string to use as bullet</li>
 </ul>
 </p>
-<p>If you wish to skip a number of settings, unfortunately, this command will not accept null values, i.e., a series of commas. You <i>must</i> put some integer value for each of the potential parameters. For example, imagine you wish to only specify a name for the Paragraph Style, and the Character Style. Your command should be something like:</p>
-<p><strong>scribus.createParagraphStyle("MyNewStyle",0,0,0,0,0,0,0,0,0,"MyCharStyle")</strong></p>
-<p>On the other hand, if you only wanted to specify a name and linespacing mode, you can quit whenever after you finished with non-zero data:</p>
-<p><strong>scribus.createParagraphStyle("MyOtherNewStyle",1)</strong></p>
+<p>If you wish to skip a number of settings, unfortunately, this command will not accept null values, i.e., a series of commas. You <i>must</i> put some integer value for each of the potential parameters. For example, imagine you wish to only specify a name for the Paragraph Style, and the Character Style. Your command should be something like:
+<ul style="list-style-type:none">
+    <li><code>scribus.createParagraphStyle("MyNewStyle", 0, 0, 0, 0, 0, 0, 0, 0, 0, "MyCharStyle"))</code></li>
+</ul></p>
+<p>On the other hand, if you only wanted to specify a name and linespacing mode, you can quit whenever after you finished with non-zero data:
+<ul style="list-style-type:none">
+    <li><code>scribus.createParagraphStyle("MyOtherNewStyle", 1)</code></li>
+</ul></p>
 </dd>
 
 <dt><a name="-getAllStyles"><strong>getAllStyles</strong></a>(...)</dt>

Modified: trunk/Scribus/doc/en/scripterapi-styles.html
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23168&path=/trunk/Scribus/doc/en/scripterapi-styles.html
==============================================================================
--- trunk/Scribus/doc/en/scripterapi-styles.html	(original)
+++ trunk/Scribus/doc/en/scripterapi-styles.html	Fri Aug 30 08:01:20 2019
@@ -162,12 +162,17 @@
 <li>dropcaplines [optional] -> height (in lines) of the caps if used</li>
 <li>dropcapoffset [optional] -> offset of the caps if used</li>
 <li>"charstyle" [optional] -> char style to use</li>
+<li>"bullet" [optional] -> string to use as bullet</li>
 </ul>
 </p>
-<p>If you wish to skip a number of settings, unfortunately, this command will not accept null values, i.e., a series of commas. You <i>must</i> put some integer value for each of the potential parameters. For example, imagine you wish to only specify a name for the Paragraph Style, and the Character Style. Your command should be something like:</p>
-<p><strong>scribus.createParagraphStyle("MyNewStyle",0,0,0,0,0,0,0,0,0,"MyCharStyle")</strong></p>
-<p>On the other hand, if you only wanted to specify a name and linespacing mode, you can quit whenever after you finished with non-zero data:</p>
-<p><strong>scribus.createParagraphStyle("MyOtherNewStyle",1)</strong></p>
+<p>If you wish to skip a number of settings, unfortunately, this command will not accept null values, i.e., a series of commas. You <i>must</i> put some integer value for each of the potential parameters. For example, imagine you wish to only specify a name for the Paragraph Style, and the Character Style. Your command should be something like:
+<ul style="list-style-type:none">
+    <li><code>scribus.createParagraphStyle("MyNewStyle", 0, 0, 0, 0, 0, 0, 0, 0, 0, "MyCharStyle"))</code></li>
+</ul></p>
+<p>On the other hand, if you only wanted to specify a name and linespacing mode, you can quit whenever after you finished with non-zero data:
+<ul style="list-style-type:none">
+    <li><code>scribus.createParagraphStyle("MyOtherNewStyle", 1)</code></li>
+</ul></p>
 </dd>
 
 <dt><a name="-getAllStyles"><strong>getAllStyles</strong></a>(...)</dt>

Modified: trunk/Scribus/doc/fr/scripterapi-styles.html
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23168&path=/trunk/Scribus/doc/fr/scripterapi-styles.html
==============================================================================
--- trunk/Scribus/doc/fr/scripterapi-styles.html	(original)
+++ trunk/Scribus/doc/fr/scripterapi-styles.html	Fri Aug 30 08:01:20 2019
@@ -159,12 +159,17 @@
 <li>dropcaplines [optionnel] -> la hauteur des lettrines en nombre de lignes si l'utilisation de lettrines est activée</li>
 <li>dropcapoffset [optionnel] -> décalage horizontal des lettrines si l'utilisation de lettrines est activée</li>
 <li>"charstyle" [optionnel] -> nom du style de caractère à utiliser</li>
+<li>"bullet" [optionnel] -> chaîne de caractère à utiliser pour les puces</li>
 </ul>
 </p>
-<p>Si vous désirez omettre un certain nombre d'éléments, cette fonction n'acceptera pas de valeurs null, i.e., une série de virgule. Vous <i>devez</i> spécifier un paramètre entier pour chacun des paramètres omis. Par example, si vous désirez spécifier uniquement un nom de style de paragraphe et un nom de style de caractère, votre appel de fonction ressemblera à ceci:</p>
-<p><strong>scribus.createParagraphStyle("MyNewStyle",0,0,0,0,0,0,0,0,0,"MyCharStyle")</strong></p>
-<p>Cependant, si vous désirez spécifier uniquement un nom de style et un mode d'interlignage, vous pouvez alors limiter le nombre d'argument passé dans votre appel de fonction:</p>
-<p><strong>scribus.createParagraphStyle("MyOtherNewStyle", 1)</strong></p>
+<p>Si vous désirez omettre un certain nombre d'éléments, cette fonction n'acceptera pas de valeurs null, i.e., une série de virgule. Vous <i>devez</i> spécifier un paramètre entier pour chacun des paramètres omis. Par example, si vous désirez spécifier uniquement un nom de style de paragraphe et un nom de style de caractère, votre appel de fonction ressemblera à ceci:
+<ul style="list-style-type:none">
+    <li><code>scribus.createParagraphStyle("MyNewStyle",0,0,0,0,0,0,0,0,0,"MyCharStyle")</code></li>
+</ul></p>
+<p>Cependant, si vous désirez spécifier uniquement un nom de style et un mode d'interlignage, vous pouvez alors limiter le nombre d'argument passé dans votre appel de fonction:
+<ul style="list-style-type:none">
+    <li><code>scribus.createParagraphStyle("MyOtherNewStyle", 1)</code></li>
+</ul></p>
 </dd>
 
 <dt><a name="-getAllStyles"><strong>getAllStyles</strong></a>(...)</dt>

Modified: trunk/Scribus/doc/it/scripterapi-styles.html
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23168&path=/trunk/Scribus/doc/it/scripterapi-styles.html
==============================================================================
--- trunk/Scribus/doc/it/scripterapi-styles.html	(original)
+++ trunk/Scribus/doc/it/scripterapi-styles.html	Fri Aug 30 08:01:20 2019
@@ -162,12 +162,17 @@
 <li>dropcaplines [optional] -> height (in lines) of the caps if used</li>
 <li>dropcapoffset [optional] -> offset of the caps if used</li>
 <li>"charstyle" [optional] -> char style to use</li>
+<li>"bullet" [optional] -> string to use as bullet</li>
 </ul>
 </p>
-<p>If you wish to skip a number of settings, unfortunately, this command will not accept null values, i.e., a series of commas. You <i>must</i> put some integer value for each of the potential parameters. For example, imagine you wish to only specify a name for the Paragraph Style, and the Character Style. Your command should be something like:</p>
-<p><strong>scribus.createParagraphStyle("MyNewStyle",0,0,0,0,0,0,0,0,0,"MyCharStyle")</strong></p>
-<p>On the other hand, if you only wanted to specify a name and linespacing mode, you can quit whenever after you finished with non-zero data:</p>
-<p><strong>scribus.createParagraphStyle("MyOtherNewStyle",1)</strong></p>
+<p>If you wish to skip a number of settings, unfortunately, this command will not accept null values, i.e., a series of commas. You <i>must</i> put some integer value for each of the potential parameters. For example, imagine you wish to only specify a name for the Paragraph Style, and the Character Style. Your command should be something like:
+<ul style="list-style-type:none">
+    <li><code>scribus.createParagraphStyle("MyNewStyle", 0, 0, 0, 0, 0, 0, 0, 0, 0, "MyCharStyle"))</code></li>
+</ul></p>
+<p>On the other hand, if you only wanted to specify a name and linespacing mode, you can quit whenever after you finished with non-zero data:
+<ul style="list-style-type:none">
+    <li><code>scribus.createParagraphStyle("MyOtherNewStyle", 1)</code></li>
+</ul></p>
 </dd>
 
 <dt><a name="-getAllStyles"><strong>getAllStyles</strong></a>(...)</dt>

Modified: trunk/Scribus/scribus/plugins/scriptplugin/cmdstyle.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23168&path=/trunk/Scribus/scribus/plugins/scriptplugin/cmdstyle.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/cmdstyle.cpp	(original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/cmdstyle.cpp	Fri Aug 30 08:01:20 2019
@@ -38,44 +38,74 @@
 			const_cast<char*>("dropcaplines"),
 			const_cast<char*>("dropcapoffset"),
 			const_cast<char*>("charstyle"),
+			const_cast<char*>("bullet"),
 			nullptr};
 	char *name = const_cast<char*>(""), *charStyle = const_cast<char*>("");
+	char *bullet = const_cast<char*>("");
 	int lineSpacingMode = 0, alignment = 0, dropCapLines = 2, hasDropCap = 0;
 	double lineSpacing = 15.0, leftMargin = 0.0, rightMargin = 0.0;
 	double gapBefore = 0.0, gapAfter = 0.0, firstIndent = 0.0, peOffset = 0;
-	if (!PyArg_ParseTupleAndKeywords(args, keywords, "es|ididddddiides",
+	if (!PyArg_ParseTupleAndKeywords(args, keywords, "es|ididddddiideses",
 		 keywordargs, "utf-8", &name, &lineSpacingMode, &lineSpacing, &alignment,
 		&leftMargin, &rightMargin, &gapBefore, &gapAfter, &firstIndent,
-		&hasDropCap, &dropCapLines, &peOffset, "utf-8", &charStyle))
+		&hasDropCap, &dropCapLines, &peOffset, "utf-8", &charStyle,
+		"utf-8", &bullet))
 		return nullptr;
 	if (!checkHaveDocument())
 		return nullptr;
 	if (strlen(name) == 0)
 	{
 		PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot have an empty paragraph style name.","python error").toLocal8Bit().constData());
+		return nullptr;
+	}
+	
+	if ((hasDropCap != 0) && (dropCapLines <= 1) )
+	{
+		PyErr_SetString(PyExc_ValueError, QObject::tr("hasdropcap is true but dropcaplines value is invalid","python error").toLocal8Bit().constData());
+		return nullptr;
+	}
+	
+	if (strlen(bullet) > 0 && (hasDropCap  != 0))
+	{
+		PyErr_SetString(PyExc_ValueError, QObject::tr("hasdropcap and bullet are not allowed to be specified together.","python error").toLocal8Bit().constData());
 		return nullptr;
 	}
 
 	ParagraphStyle tmpParagraphStyle;
 	tmpParagraphStyle.setName(name);
-	tmpParagraphStyle.setLineSpacingMode((ParagraphStyle::LineSpacingMode)lineSpacingMode);
+	tmpParagraphStyle.setLineSpacingMode((ParagraphStyle::LineSpacingMode) lineSpacingMode);
 	tmpParagraphStyle.setLineSpacing(lineSpacing);
-	tmpParagraphStyle.setAlignment((ParagraphStyle::AlignmentType)alignment);
+	tmpParagraphStyle.setAlignment((ParagraphStyle::AlignmentType) alignment);
 	tmpParagraphStyle.setLeftMargin(leftMargin);
 	tmpParagraphStyle.setFirstIndent(firstIndent);
 	tmpParagraphStyle.setRightMargin(rightMargin);
 	tmpParagraphStyle.setGapBefore(gapBefore);
 	tmpParagraphStyle.setGapAfter(gapAfter);
-	if (hasDropCap == 0)
+	
+	if (hasDropCap != 0)
+	{
+		tmpParagraphStyle.setDropCapLines(dropCapLines);
+		tmpParagraphStyle.setHasDropCap(true);
+		tmpParagraphStyle.setHasBullet(false);
+		tmpParagraphStyle.setHasNum(false);
+	}
+	else
+	{
 		tmpParagraphStyle.setHasDropCap(false);
-	else if (hasDropCap == 1)
-		tmpParagraphStyle.setHasDropCap(true);
+	}
+	
+	if (strlen(bullet) > 0)
+	{
+		tmpParagraphStyle.setBulletStr(QString::fromUtf8(bullet));
+		tmpParagraphStyle.setHasDropCap(false);
+		tmpParagraphStyle.setHasBullet(true);
+		tmpParagraphStyle.setHasNum(false);
+	}
 	else
 	{
-		PyErr_SetString(PyExc_ValueError, QObject::tr("hasdropcap has to be 0 or 1.","python error").toLocal8Bit().constData());
-		return nullptr;
-	}
-	tmpParagraphStyle.setDropCapLines(dropCapLines);
+		tmpParagraphStyle.setHasBullet(false);
+	}
+	
 	tmpParagraphStyle.setParEffectOffset(peOffset);
 	tmpParagraphStyle.charStyle().setParent(charStyle);
 

Modified: trunk/Scribus/scribus/plugins/scriptplugin/cmdstyle.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23168&path=/trunk/Scribus/scribus/plugins/scriptplugin/cmdstyle.h
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/cmdstyle.h	(original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/cmdstyle.h	Fri Aug 30 08:01:20 2019
@@ -40,6 +40,7 @@
 dropcaplines [optional] -> height (in lines) of the caps if used\n\n\
 dropcapoffset [optional] -> offset of the caps if used\n\n\
 \"charstyle\" [optional] -> char style to use\n\n\
+\"bullet\" [optional] -> string to use as bullet\n\n\
 "));
 /*! 02.01.2007 - 05.01.2007 : Joachim Neu : Create a paragraph style.
   		Special thanks go to avox for helping me! */




More information about the scribus-commit mailing list