Author: jghali
Date: Tue May  5 15:09:57 2020
New Revision: 23689

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=23689
Log:
#16000: Scripter: behavior of setCharacterStyle() depends on the frame name 
being defined

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

Modified: trunk/Scribus/doc/de/scripterapi-manobj.html
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=23689&path=/trunk/Scribus/doc/de/scripterapi-manobj.html
==============================================================================
--- trunk/Scribus/doc/de/scripterapi-manobj.html        (original)
+++ trunk/Scribus/doc/de/scripterapi-manobj.html        Tue May  5 15:09:57 2020
@@ -11,7 +11,7 @@
 <dt><a name="-combinePolygons"><strong>combinePolygons()</strong></a></dt>
 <dd><code>combinePolygons()</code>
 <p>Combines two or more selected polygons.</p>
-<p>May raise WrongFrameTypeError.</p></dd>
+<p>May raise <a 
href="scripterapi.html#WrongFrameTypeError">WrongFrameTypeError</a>.</p></dd>
 
 <dt><a name="-copyObject"><strong>copyObject</strong>(...)</a></dt>
 <dd><code>copyObject(["name"]) -&gt; string</code>
@@ -23,15 +23,15 @@
 
 <dt><a 
name="-getCharacterStyle"><strong>getCharacterStyle</strong></a>(...)</dt>
 <dd><code>getCharacterStyle(["name"])</code>
-<p>Return name of character style applied to object named "name". If "name" is 
not given, the currently selected object is used.<p>
+<p>Return name of character style applied to object named "name". If "name" is 
not given, the currently selected object is used.</p>
 <p>If current object has a text selection, the name of style applied to start 
of selection is returned. Otherwise the name of the item default character 
style is returned.</p>
-<p>May raise WrongFrameTypeError.</p></dd>
+<p>May raise <a 
href="scripterapi.html#WrongFrameTypeError">WrongFrameTypeError</a> if target 
frame is not a text frame.</p></dd>
 
 <dt><a 
name="-getParagraphStyle"><strong>getParagraphStyle</strong></a>(...)</dt>
 <dd><code>getParagraphStyle(["name"])</code>
-<p>Return name of paragraph style applied to object named "name". If "name" is 
not given, the currently selected object is used.<p>
+<p>Return name of paragraph style applied to object named "name". If "name" is 
not given, the currently selected object is used.</p>
 <p>If current object has a text selection, the name of style applied to start 
of selection is returned. Otherwise the name of the item default style is 
returned.</p>
-<p>May raise WrongFrameTypeError.</p></dd>
+<p>May raise <a 
href="scripterapi.html#WrongFrameTypeError">WrongFrameTypeError</a> if target 
frame is not a text frame.</p></dd>
 
 <dt><a name="-getStyle"><strong>getStyle</strong></a>(...)</dt>
 <dd><code>getStyle(["name"])</code>
@@ -52,7 +52,7 @@
 <dt><a name="-moveObject"><strong>moveObject</strong></a>(...)</dt>
 <dd><code>moveObject(dx, dy [, "name"])</code>
 <p>Moves the object "name" by dx and dy relative to its current position. The 
distances are expressed in the current measurement unit of the document (see 
UNIT constants). If "name" is not given the currently selected item is used. If 
the object "name" belongs to a group, the whole group is moved.</p>
-<p>If what you wish to do is to move an object to a different page or layer, 
it may be more efficient to do the sequence <em>copyObject(...)</em>, followed 
by <em>pasteObject(...)</em>, and then finally <em>deleteObject(...)</em> to 
delete the original.</dd>
+<p>If what you wish to do is to move an object to a different page or layer, 
it may be more efficient to do the sequence <em>copyObject(...)</em>, followed 
by <em>pasteObject(...)</em>, and then finally <em>deleteObject(...)</em> to 
delete the original.</p></dd>
 
 <dt><a name="-moveObjectAbs"><strong>moveObjectAbs</strong></a>(...)</dt>
 <dd><code>moveObjectAbs(x, y [, "name"])</code>
@@ -60,7 +60,7 @@
 
 <dt><a name="-pasteObject"><strong>pasteObject</strong>(...)</a></dt>
 <dd><code>pasteObject(["name"]) -&gt; string</code>
-<p>pastes an Object from the clipboard. This will be used only or most 
sensibly following <em>copyObject(...)</em>, since otherwise there will likely 
be nothing in the clipboard to paste.</p></dd>
+<p>Pastes an Object from the clipboard. This will be used only or most 
sensibly following <em>copyObject(...)</em>, since otherwise there will likely 
be nothing in the clipboard to paste.</p></dd>
 
 <dt><a name="-rotateObject"><strong>rotateObject</strong></a>(...)</dt>
 <dd><code>rotateObject(rot [, "name"])</code>
@@ -77,21 +77,29 @@
 
 <dt><a 
name="-setCharacterStyle"><strong>setCharacterStyle</strong></a>(...)</dt>
 <dd><code>setCharacterStyle("style" [, "name"])</code>
-<p>Apply the named character "style" to the object named "name". If object 
name is given, style is applied to the current text selection in object "name". 
If no object name is given, style is applied on selected object.</p></dd>
+<p>Apply the named character "style" to the object named "name".</p>
+<p>If object name is not provided, style is applied on current object 
selection.</p>
+<p>If multiple objects are selected or if selected object has no text 
selection, style is applied on selected object(s). Otherwise style is applied 
to the current text selection.</p>
+<p>May raise <a 
href="scripterapi.html#WrongFrameTypeError">WrongFrameTypeError</a> if the 
target frame is not a text frame.</p>
+<p>May raise <a href="scripterapi.html#NotFoundError">NotFoundError</a> if 
specified style name does not exist in current document.</p></dd>
 
 <dt><a 
name="-setParagraphStyle"><strong>setParagraphStyle</strong></a>(...)</dt>
 <dd><code>setParagraphStyle("style" [, "name"])</code>
-<p>Apply the named paragraph "style" to the object named "name". If object 
name is given, style is applied to the current text selection in object "name". 
If no object name is given, style is applied on selected object.</p></dd>
+<p>Apply the named paragraph "style" to the object named "name".</p>
+<p>If object name is not provided, style is applied on current object 
selection.</p>
+<p>If multiple objects are selected or if selected object has no text 
selection, style is applied on selected object(s). Otherwise style is applied 
to the current text selection.</p>
+<p>May raise <a 
href="scripterapi.html#WrongFrameTypeError">WrongFrameTypeError</a> if the 
target frame is not a text frame.</p>
+<p>May raise <a href="scripterapi.html#NotFoundError">NotFoundError</a> if 
specified style name does not exist in current document.</p></dd>
 
 <dt><a 
name="-setScaleFrameToImage"><strong>setScaleFrameToImage</strong></a>(...)</dt>
 <dd><code>setScaleFrameToImage([name])</code>
 <p>Set frame size on the selected or specified image frame to image size.</p>
-<p>May raise WrongFrameTypeError.</p></dd>
+<p>May raise <a 
href="scripterapi.html#WrongFrameTypeError">WrongFrameTypeError</a>.</p></dd>
 
 <dt><a 
name="-setScaleImageToFrame"><strong>setScaleImageToFrame</strong></a>(...)</dt>
 <dd><code>setScaleImageToFrame(scaletoframe, proportional=None, 
name=&lt;selection&gt;)</code>
 <p>Sets the scale to frame on the selected or specified image frame to 
`scaletoframe'. If `proportional' is specified, set fixed aspect ratio scaling 
to `proportional'. Both `scaletoframe' and `proportional' are boolean.</p>
-<p>May raise WrongFrameTypeError.</p></dd>
+<p>May raise <a 
href="scripterapi.html#WrongFrameTypeError">WrongFrameTypeError</a>.</p></dd>
 
 <dt><a name="-setStyle"><strong>setStyle</strong></a>(...)</dt>
 <dd><code>setStyle("style" [, "name"])</code>
@@ -103,11 +111,12 @@
 
 <dt><a name="-unGroupObjects"><strong>unGroupObjects</strong></a>(...)</dt>
 <dd><code>unGroupObjects("name")</code>
-<p>Destructs the group the object "name" belongs to.If "name" is not given the 
currently selected item is used.</p></dd>
+<p>Destructs the group the object "name" belongs to. If "name" is not given 
the currently selected item is used.</p></dd>
 
 <dt><a name="-textFlowMode"><strong>textFlowMode</strong>(...)</a></dt>
 <dd><code>textFlowMode("name" [, state])</code>
-<p>Enables/disables "Text Flows Around Frame" feature for object "name". 
Called with parameters string name and optional int "state" (0 &lt;= state 
&lt;= 3). Setting "state" to 0 will disable text flow. Setting "state" to 1 
will make text flow around object frame. Setting "state" to 2 will make text 
flow around bounding box. Setting "state" to 3 will make text flow around 
contour line. If "state" is not passed, text flow is toggled.</p></dd>
+<p>Enables/disables "Text Flows Around Frame" feature for object "name".</p>
+<p>Called with parameters string name and optional int "state" (0 &lt;= state 
&lt;= 3). Setting "state" to 0 will disable text flow. Setting "state" to 1 
will make text flow around object frame. Setting "state" to 2 will make text 
flow around bounding box. Setting "state" to 3 will make text flow around 
contour line. If "state" is not passed, text flow is toggled.</p></dd>
 
 </dl>
 </body>

Modified: trunk/Scribus/doc/en/scripterapi-manobj.html
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=23689&path=/trunk/Scribus/doc/en/scripterapi-manobj.html
==============================================================================
--- trunk/Scribus/doc/en/scripterapi-manobj.html        (original)
+++ trunk/Scribus/doc/en/scripterapi-manobj.html        Tue May  5 15:09:57 2020
@@ -11,7 +11,7 @@
 <dt><a name="-combinePolygons"><strong>combinePolygons()</strong></a></dt>
 <dd><code>combinePolygons()</code>
 <p>Combines two or more selected polygons.</p>
-<p>May raise WrongFrameTypeError.</p></dd>
+<p>May raise <a 
href="scripterapi.html#WrongFrameTypeError">WrongFrameTypeError</a>.</p></dd>
 
 <dt><a name="-copyObject"><strong>copyObject</strong>(...)</a></dt>
 <dd><code>copyObject(["name"]) -&gt; string</code>
@@ -23,15 +23,15 @@
 
 <dt><a 
name="-getCharacterStyle"><strong>getCharacterStyle</strong></a>(...)</dt>
 <dd><code>getCharacterStyle(["name"])</code>
-<p>Return name of character style applied to object named "name". If "name" is 
not given, the currently selected object is used.<p>
+<p>Return name of character style applied to object named "name". If "name" is 
not given, the currently selected object is used.</p>
 <p>If current object has a text selection, the name of style applied to start 
of selection is returned. Otherwise the name of the item default character 
style is returned.</p>
-<p>May raise WrongFrameTypeError.</p></dd>
+<p>May raise <a 
href="scripterapi.html#WrongFrameTypeError">WrongFrameTypeError</a> if target 
frame is not a text frame.</p></dd>
 
 <dt><a 
name="-getParagraphStyle"><strong>getParagraphStyle</strong></a>(...)</dt>
 <dd><code>getParagraphStyle(["name"])</code>
-<p>Return name of paragraph style applied to object named "name". If "name" is 
not given, the currently selected object is used.<p>
+<p>Return name of paragraph style applied to object named "name". If "name" is 
not given, the currently selected object is used.</p>
 <p>If current object has a text selection, the name of style applied to start 
of selection is returned. Otherwise the name of the item default style is 
returned.</p>
-<p>May raise WrongFrameTypeError.</p></dd>
+<p>May raise <a 
href="scripterapi.html#WrongFrameTypeError">WrongFrameTypeError</a> if target 
frame is not a text frame.</p></dd>
 
 <dt><a name="-getStyle"><strong>getStyle</strong></a>(...)</dt>
 <dd><code>getStyle(["name"])</code>
@@ -52,7 +52,7 @@
 <dt><a name="-moveObject"><strong>moveObject</strong></a>(...)</dt>
 <dd><code>moveObject(dx, dy [, "name"])</code>
 <p>Moves the object "name" by dx and dy relative to its current position. The 
distances are expressed in the current measurement unit of the document (see 
UNIT constants). If "name" is not given the currently selected item is used. If 
the object "name" belongs to a group, the whole group is moved.</p>
-<p>If what you wish to do is to move an object to a different page or layer, 
it may be more efficient to do the sequence <em>copyObject(...)</em>, followed 
by <em>pasteObject(...)</em>, and then finally <em>deleteObject(...)</em> to 
delete the original.</dd>
+<p>If what you wish to do is to move an object to a different page or layer, 
it may be more efficient to do the sequence <em>copyObject(...)</em>, followed 
by <em>pasteObject(...)</em>, and then finally <em>deleteObject(...)</em> to 
delete the original.</p></dd>
 
 <dt><a name="-moveObjectAbs"><strong>moveObjectAbs</strong></a>(...)</dt>
 <dd><code>moveObjectAbs(x, y [, "name"])</code>
@@ -60,7 +60,7 @@
 
 <dt><a name="-pasteObject"><strong>pasteObject</strong>(...)</a></dt>
 <dd><code>pasteObject(["name"]) -&gt; string</code>
-<p>pastes an Object from the clipboard. This will be used only or most 
sensibly following <em>copyObject(...)</em>, since otherwise there will likely 
be nothing in the clipboard to paste.</p></dd>
+<p>Pastes an Object from the clipboard. This will be used only or most 
sensibly following <em>copyObject(...)</em>, since otherwise there will likely 
be nothing in the clipboard to paste.</p></dd>
 
 <dt><a name="-rotateObject"><strong>rotateObject</strong></a>(...)</dt>
 <dd><code>rotateObject(rot [, "name"])</code>
@@ -77,21 +77,29 @@
 
 <dt><a 
name="-setCharacterStyle"><strong>setCharacterStyle</strong></a>(...)</dt>
 <dd><code>setCharacterStyle("style" [, "name"])</code>
-<p>Apply the named character "style" to the object named "name". If object 
name is given, style is applied to the current text selection in object "name". 
If no object name is given, style is applied on selected object.</p></dd>
+<p>Apply the named character "style" to the object named "name".</p>
+<p>If object name is not provided, style is applied on current object 
selection.</p>
+<p>If multiple objects are selected or if selected object has no text 
selection, style is applied on selected object(s). Otherwise style is applied 
to the current text selection.</p>
+<p>May raise <a 
href="scripterapi.html#WrongFrameTypeError">WrongFrameTypeError</a> if the 
target frame is not a text frame.</p>
+<p>May raise <a href="scripterapi.html#NotFoundError">NotFoundError</a> if 
specified style name does not exist in current document.</p></dd>
 
 <dt><a 
name="-setParagraphStyle"><strong>setParagraphStyle</strong></a>(...)</dt>
 <dd><code>setParagraphStyle("style" [, "name"])</code>
-<p>Apply the named paragraph "style" to the object named "name". If object 
name is given, style is applied to the current text selection in object "name". 
If no object name is given, style is applied on selected object.</p></dd>
+<p>Apply the named paragraph "style" to the object named "name".</p>
+<p>If object name is not provided, style is applied on current object 
selection.</p>
+<p>If multiple objects are selected or if selected object has no text 
selection, style is applied on selected object(s). Otherwise style is applied 
to the current text selection.</p>
+<p>May raise <a 
href="scripterapi.html#WrongFrameTypeError">WrongFrameTypeError</a> if the 
target frame is not a text frame.</p>
+<p>May raise <a href="scripterapi.html#NotFoundError">NotFoundError</a> if 
specified style name does not exist in current document.</p></dd>
 
 <dt><a 
name="-setScaleFrameToImage"><strong>setScaleFrameToImage</strong></a>(...)</dt>
 <dd><code>setScaleFrameToImage([name])</code>
 <p>Set frame size on the selected or specified image frame to image size.</p>
-<p>May raise WrongFrameTypeError.</p></dd>
+<p>May raise <a 
href="scripterapi.html#WrongFrameTypeError">WrongFrameTypeError</a>.</p></dd>
 
 <dt><a 
name="-setScaleImageToFrame"><strong>setScaleImageToFrame</strong></a>(...)</dt>
 <dd><code>setScaleImageToFrame(scaletoframe, proportional=None, 
name=&lt;selection&gt;)</code>
 <p>Sets the scale to frame on the selected or specified image frame to 
`scaletoframe'. If `proportional' is specified, set fixed aspect ratio scaling 
to `proportional'. Both `scaletoframe' and `proportional' are boolean.</p>
-<p>May raise WrongFrameTypeError.</p></dd>
+<p>May raise <a 
href="scripterapi.html#WrongFrameTypeError">WrongFrameTypeError</a>.</p></dd>
 
 <dt><a name="-setStyle"><strong>setStyle</strong></a>(...)</dt>
 <dd><code>setStyle("style" [, "name"])</code>
@@ -103,11 +111,12 @@
 
 <dt><a name="-unGroupObjects"><strong>unGroupObjects</strong></a>(...)</dt>
 <dd><code>unGroupObjects("name")</code>
-<p>Destructs the group the object "name" belongs to.If "name" is not given the 
currently selected item is used.</p></dd>
+<p>Destructs the group the object "name" belongs to. If "name" is not given 
the currently selected item is used.</p></dd>
 
 <dt><a name="-textFlowMode"><strong>textFlowMode</strong>(...)</a></dt>
 <dd><code>textFlowMode("name" [, state])</code>
-<p>Enables/disables "Text Flows Around Frame" feature for object "name". 
Called with parameters string name and optional int "state" (0 &lt;= state 
&lt;= 3). Setting "state" to 0 will disable text flow. Setting "state" to 1 
will make text flow around object frame. Setting "state" to 2 will make text 
flow around bounding box. Setting "state" to 3 will make text flow around 
contour line. If "state" is not passed, text flow is toggled.</p></dd>
+<p>Enables/disables "Text Flows Around Frame" feature for object "name".</p>
+<p>Called with parameters string name and optional int "state" (0 &lt;= state 
&lt;= 3). Setting "state" to 0 will disable text flow. Setting "state" to 1 
will make text flow around object frame. Setting "state" to 2 will make text 
flow around bounding box. Setting "state" to 3 will make text flow around 
contour line. If "state" is not passed, text flow is toggled.</p></dd>
 
 </dl>
 </body>

Modified: trunk/Scribus/doc/fr/scripterapi-manobj.html
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=23689&path=/trunk/Scribus/doc/fr/scripterapi-manobj.html
==============================================================================
--- trunk/Scribus/doc/fr/scripterapi-manobj.html        (original)
+++ trunk/Scribus/doc/fr/scripterapi-manobj.html        Tue May  5 15:09:57 2020
@@ -11,7 +11,7 @@
 <dt><a name="-combinePolygons"><strong>combinePolygons()</strong></a></dt>
 <dd><code>combinePolygons()</code>
 <p>Combine deux polygones ou plus.</p>
-<p>Peut générer l'exception WrongFrameTypeError.</p></dd>
+<p>Peut générer l'exception <a 
href="scripterapi.html#WrongFrameTypeError">WrongFrameTypeError</a>.</p></dd>
 
 <dt><a name="-copyObject"><strong>copyObject</strong>(...)</a></dt>
 <dd><code>copyObject(["nom"]) -&gt; chaîne</code>
@@ -24,14 +24,14 @@
 <dt><a 
name="-getCharacterStyle"><strong>getCharacterStyle</strong></a>(...)</dt>
 <dd><code>getCharacterStyle(["nom"])  -&gt; chaîne</code>
 <p>Retourne le nom du style de caractère appliqué à l'objet "nom". Si aucun 
nom d'objet n'est fourni, l'élément sélectionné est utilisé.</p> 
-<p>Si l'objet courant poss&egrave;de une sélection de texte, le nom retourné 
est celui du style appliqué au début de la sélection. Sinon le nom retourné 
est celui du style de caractère appliqué par défaut.</p>
-<p>Peut générer l'exception WrongFrameTypeError.</p></dd>
+<p>Si l'objet courant possède une sélection de texte, le nom retourné est 
celui du style appliqué au début de la sélection. Sinon le nom retourné est 
celui du style de caractère appliqué par défaut.</p>
+<p>Peut générer l'exception <a 
href="scripterapi.html#WrongFrameTypeError">WrongFrameTypeError</a>.</p></dd>
 
 <dt><a 
name="-getParagraphStyle"><strong>getParagraphStyle</strong></a>(...)</dt>
 <dd><code>getParagraphStyle(["nom"])  -&gt; chaîne</code>
 <p>Retourne le nom du style de paragraphe appliqué à l'objet "nom". Si aucun 
nom d'objet n'est fourni, l'élément sélectionné est utilisé.</p> 
-<p>Si l'objet courant poss&egrave;de une sélection de texte, le nom retourné 
est celui du style appliqué au début de la sélection. Sinon le nom retourné 
est celui du style appliqué par défaut.</p>
-<p>Peut générer l'exception WrongFrameTypeError.</p></dd>
+<p>Si l'objet courant possède une sélection de texte, le nom retourné est 
celui du style appliqué au début de la sélection. Sinon le nom retourné est 
celui du style appliqué par défaut.</p>
+<p>Peut générer l'exception <a 
href="scripterapi.html#WrongFrameTypeError">WrongFrameTypeError</a>.</p></dd>
 
 <dt><a name="-getStyle"><strong>getStyle</strong></a>(...)</dt>
 <dd><code>getStyle(["nom"])  -&gt; chaîne</code>
@@ -76,27 +76,34 @@
 <dd><code>scaleGroup(facteur
 [,"nom"])</code>
 <p>Redimensionne le groupe auquel l'objet "nom" appartient. Les valeurs 
supérieures à 1 agrandissent le groupe, les valeurs inférieures à 1 rendent 
le groupe plus petit, par exemple une valeur de 0.5 redimensionne le groupe à 
50 % de sa taille originale, tandis qu'une valeur de 1.5 redimensionne le 
groupe à 150 % de sa taille originale. La valeur de "facteur" doit &ecirc;tre 
supérieure à 0. Si le "nom" n'est pas fourni, l'élément sélectionné 
courant est utilisé.</p>
-<p>Peut générer ValueError si le facteur de redimensionnement n'est
-pas valide.</p></dd>
+<p>Peut générer ValueError si le facteur de redimensionnement n'est pas 
valide.</p></dd>
 
 <dt><a 
name="-setCharacterStyle"><strong>setCharacterStyle</strong></a>(...)</dt>
 <dd><code>setCharacterStyle("style" [, "nom"])</code>
-<p>Applique le "style" de caract&egrave;re désigné à l'objet "nom". Si un 
nom d'objet est fourni, le style est appliqué à la sélection de texte 
courante de l'objet donné. Si aucun objet n'est fourni, le style est appliqué 
à l'objet sélectionné.</p></dd>
+<p>Applique le "style" de caractère spécifié à l'objet "nom".</p>
+<p>Si le nom d'objet "nom" n'est pas spécifié, le style est appliqué à la 
sélection d'objets courante.</p>
+<p>Si de multiples objets sont sélectionnés ou si l'objet sélectionné ne 
comporte aucune sélection de texte, le style est appliqué aux objets 
sélectionnés. Dans le cas contraire, le style est appliqué à la sélection 
de texte courante.</p>
+<p>Peut générer l'exception <a 
href="scripterapi.html#WrongFrameTypeError">WrongFrameTypeError</a> si l'objet 
cible n'est pas un cadre de texte.</p>
+<p>Peut générer l'exception <a 
href="scripterapi.html#NotFoundError">NotFoundError</a> si le nom de style 
spécifié n'appartient pas au document courant.</p></dd>
 
 <dt><a 
name="-setParagraphStyle"><strong>setParagraphStyle</strong></a>(...)</dt>
 <dd><code>setParagraphStyle("style" [, "nom"])</code>
-<p>Applique le "style" de paragraphe désigné à l'objet "nom". Si un nom 
d'objet est fourni, le style est appliqué à la sélection de texte courante 
de l'objet donné. Si aucun objet n'est fourni, le style est appliqué à 
l'objet sélectionné.</p></dd>
+<p>Applique le "style" de paragraphe  spécifié à l'objet "nom".</p>
+<p>Si le nom d'objet "nom" n'est pas spécifié, le style est appliqué à la 
sélection d'objets courante.</p>
+<p>Si de multiples objets sont sélectionnés ou si l'objet sélectionné ne 
comporte aucune sélection de texte, le style est appliqué aux objets 
sélectionnés. Dans le cas contraire, le style est appliqué à la sélection 
de texte courante.</p>
+<p>Peut générer l'exception <a 
href="scripterapi.html#WrongFrameTypeError">WrongFrameTypeError</a> si l'objet 
cible n'est pas un cadre de texte.</p>
+<p>Peut générer l'exception <a 
href="scripterapi.html#NotFoundError">NotFoundError</a> si le nom de style 
spécifié n'appartient pas au document courant.</p></dd>
 
 <dt><a 
name="-setScaleFrameToImage"><strong>setScaleFrameToImage</strong></a>(...)</dt>
 <dd><code>setScaleFrameToImage([nom])</code>
 <p>Redimensionne l'objet "nom" aux dimensions de l'image. Si "nom" n'est pas 
fourni, l'élément sélectionné est utilisé</p>
-<p>Peut générer l'exception WrongFrameTypeError.</p></dd>
+<p>Peut générer l'exception <a 
href="scripterapi.html#WrongFrameTypeError">WrongFrameTypeError</a>.</p></dd>
 
 <dt><a 
name="-setScaleImageToFrame"><strong>setScaleImageToFrame</strong></a>(...)</dt>
 <dd><code>setScaleImageToFrame(redimAuCadre, proportionnel=None, 
nom=&lt;selection&gt;)</code>
 <p>&Eacute;tablit le mode de redimensionnement par rapport au cadre d'image 
sélectionné, ou spécifié dans 'redimAuCadre'. 
 Si 'proportionnel' est spécifié, établit le redimensionnement en maintenant 
des proportions fixes. 'redimAuCadre' et 'proportionnel' sont booléens.</p>
-<p>Peut générer l'exception WrongFrameTypeError.</p></dd>
+<p>Peut générer l'exception <a 
href="scripterapi.html#WrongFrameTypeError">WrongFrameTypeError</a>.</p></dd>
 
 <dt><a name="-setStyle"><strong>setStyle</strong></a>(...)</dt>
 <dd><code>setStyle("style" [, "nom"])</code>
@@ -110,11 +117,13 @@
 <dd><code>unGroupObjects("nom")</code>
 <p>Détruit le groupe auquel appartient l'objet "nom". Si le "nom" n'est pas 
fourni, l'élément sélectionné est utilisé.</p></dd>
 
-<dt><a 
name="-textFlowsAroundFrame"><strong>textFlowsAroundFrame</strong></a>(...)</dt>
-<dd><code>textFlowsAroundFrame("nom" [, etat])</code>
-<p>Active ou désactive l'"habillage" (le texte défile autour de l'objet) 
pour l'objet "nom". 
-Appelé avec les param&egrave;tres chaîne "nom" et le booléen optionnel 
"état". Si
-"état" n'est pas passé, cette fonctionnalité change de valeur (activée si 
inactive ou désactivée si active).</p></dd>
+<dt><a name="-textFlowMode"><strong>textFlowMode</strong></a>(...)</dt>
+<dd><code>textFlowMode("nom" [, etat])</code>
+<p>Active ou désactive l'habillage du texte pour l'objet "nom".</p>
+<p>Appelé avec les paramètres chaîne "nom" et l'entier optionnel "état" (0 
&lt;= "état" &lt;= 3).
+Paramétrer "état" à la valeur 0 désactivera l'habillage du texte. 
Paramétrer "état" à la valeur 1 habillera le texte selon le cadre de l'objet.
+Paramétrer "état" à la valeur 2 habillera le texte selon la bounding box de 
l'objet. Paramétrer "état" à la valeur 3 habillera le texte selon la ligne 
de contourde l'objet.
+Si l'argument"état" n'est pas passé, cette fonctionnalité change de valeur 
(activée si inactive ou désactivée si active).</p></dd>
 
 </dl>
 </body>

Modified: trunk/Scribus/doc/it/scripterapi-manobj.html
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=23689&path=/trunk/Scribus/doc/it/scripterapi-manobj.html
==============================================================================
--- trunk/Scribus/doc/it/scripterapi-manobj.html        (original)
+++ trunk/Scribus/doc/it/scripterapi-manobj.html        Tue May  5 15:09:57 2020
@@ -11,7 +11,7 @@
 <dt><a name="-combinePolygons"><strong>combinePolygons()</strong></a></dt>
 <dd><code>combinePolygons()</code>
 <p>Combines two or more selected polygons.</p>
-<p>May raise WrongFrameTypeError.</p></dd>
+<p>May raise <a 
href="scripterapi.html#WrongFrameTypeError">WrongFrameTypeError</a>.</p></dd>
 
 <dt><a name="-copyObject"><strong>copyObject</strong>(...)</a></dt>
 <dd><code>copyObject(["name"]) -&gt; string</code>
@@ -23,15 +23,15 @@
 
 <dt><a 
name="-getCharacterStyle"><strong>getCharacterStyle</strong></a>(...)</dt>
 <dd><code>getCharacterStyle(["name"])</code>
-<p>Return name of character style applied to object named "name". If "name" is 
not given, the currently selected object is used.<p>
+<p>Return name of character style applied to object named "name". If "name" is 
not given, the currently selected object is used.</p>
 <p>If current object has a text selection, the name of style applied to start 
of selection is returned. Otherwise the name of the item default character 
style is returned.</p>
-<p>May raise WrongFrameTypeError.</p></dd>
+<p>May raise <a 
href="scripterapi.html#WrongFrameTypeError">WrongFrameTypeError</a> if target 
frame is not a text frame.</p></dd>
 
 <dt><a 
name="-getParagraphStyle"><strong>getParagraphStyle</strong></a>(...)</dt>
 <dd><code>getParagraphStyle(["name"])</code>
-<p>Return name of paragraph style applied to object named "name". If "name" is 
not given, the currently selected object is used.<p>
+<p>Return name of paragraph style applied to object named "name". If "name" is 
not given, the currently selected object is used.</p>
 <p>If current object has a text selection, the name of style applied to start 
of selection is returned. Otherwise the name of the item default style is 
returned.</p>
-<p>May raise WrongFrameTypeError.</p></dd>
+<p>May raise <a 
href="scripterapi.html#WrongFrameTypeError">WrongFrameTypeError</a> if target 
frame is not a text frame.</p></dd>
 
 <dt><a name="-getStyle"><strong>getStyle</strong></a>(...)</dt>
 <dd><code>getStyle(["name"])</code>
@@ -52,7 +52,7 @@
 <dt><a name="-moveObject"><strong>moveObject</strong></a>(...)</dt>
 <dd><code>moveObject(dx, dy [, "name"])</code>
 <p>Moves the object "name" by dx and dy relative to its current position. The 
distances are expressed in the current measurement unit of the document (see 
UNIT constants). If "name" is not given the currently selected item is used. If 
the object "name" belongs to a group, the whole group is moved.</p>
-<p>If what you wish to do is to move an object to a different page or layer, 
it may be more efficient to do the sequence <em>copyObject(...)</em>, followed 
by <em>pasteObject(...)</em>, and then finally <em>deleteObject(...)</em> to 
delete the original.</dd>
+<p>If what you wish to do is to move an object to a different page or layer, 
it may be more efficient to do the sequence <em>copyObject(...)</em>, followed 
by <em>pasteObject(...)</em>, and then finally <em>deleteObject(...)</em> to 
delete the original.</p></dd>
 
 <dt><a name="-moveObjectAbs"><strong>moveObjectAbs</strong></a>(...)</dt>
 <dd><code>moveObjectAbs(x, y [, "name"])</code>
@@ -60,7 +60,7 @@
 
 <dt><a name="-pasteObject"><strong>pasteObject</strong>(...)</a></dt>
 <dd><code>pasteObject(["name"]) -&gt; string</code>
-<p>pastes an Object from the clipboard. This will be used only or most 
sensibly following <em>copyObject(...)</em>, since otherwise there will likely 
be nothing in the clipboard to paste.</p></dd>
+<p>Pastes an Object from the clipboard. This will be used only or most 
sensibly following <em>copyObject(...)</em>, since otherwise there will likely 
be nothing in the clipboard to paste.</p></dd>
 
 <dt><a name="-rotateObject"><strong>rotateObject</strong></a>(...)</dt>
 <dd><code>rotateObject(rot [, "name"])</code>
@@ -77,21 +77,29 @@
 
 <dt><a 
name="-setCharacterStyle"><strong>setCharacterStyle</strong></a>(...)</dt>
 <dd><code>setCharacterStyle("style" [, "name"])</code>
-<p>Apply the named character "style" to the object named "name". If object 
name is given, style is applied to the current text selection in object "name". 
If no object name is given, style is applied on selected object.</p></dd>
+<p>Apply the named character "style" to the object named "name".</p>
+<p>If object name is not provided, style is applied on current object 
selection.</p>
+<p>If multiple objects are selected or if selected object has no text 
selection, style is applied on selected object(s). Otherwise style is applied 
to the current text selection.</p>
+<p>May raise <a 
href="scripterapi.html#WrongFrameTypeError">WrongFrameTypeError</a> if the 
target frame is not a text frame.</p>
+<p>May raise <a href="scripterapi.html#NotFoundError">NotFoundError</a> if 
specified style name does not exist in current document.</p></dd>
 
 <dt><a 
name="-setParagraphStyle"><strong>setParagraphStyle</strong></a>(...)</dt>
 <dd><code>setParagraphStyle("style" [, "name"])</code>
-<p>Apply the named paragraph "style" to the object named "name". If object 
name is given, style is applied to the current text selection in object "name". 
If no object name is given, style is applied on selected object.</p></dd>
+<p>Apply the named paragraph "style" to the object named "name".</p>
+<p>If object name is not provided, style is applied on current object 
selection.</p>
+<p>If multiple objects are selected or if selected object has no text 
selection, style is applied on selected object(s). Otherwise style is applied 
to the current text selection.</p>
+<p>May raise <a 
href="scripterapi.html#WrongFrameTypeError">WrongFrameTypeError</a> if the 
target frame is not a text frame.</p>
+<p>May raise <a href="scripterapi.html#NotFoundError">NotFoundError</a> if 
specified style name does not exist in current document.</p></dd>
 
 <dt><a 
name="-setScaleFrameToImage"><strong>setScaleFrameToImage</strong></a>(...)</dt>
 <dd><code>setScaleFrameToImage([name])</code>
 <p>Set frame size on the selected or specified image frame to image size.</p>
-<p>May raise WrongFrameTypeError.</p></dd>
+<p>May raise <a 
href="scripterapi.html#WrongFrameTypeError">WrongFrameTypeError</a>.</p></dd>
 
 <dt><a 
name="-setScaleImageToFrame"><strong>setScaleImageToFrame</strong></a>(...)</dt>
 <dd><code>setScaleImageToFrame(scaletoframe, proportional=None, 
name=&lt;selection&gt;)</code>
 <p>Sets the scale to frame on the selected or specified image frame to 
`scaletoframe'. If `proportional' is specified, set fixed aspect ratio scaling 
to `proportional'. Both `scaletoframe' and `proportional' are boolean.</p>
-<p>May raise WrongFrameTypeError.</p></dd>
+<p>May raise <a 
href="scripterapi.html#WrongFrameTypeError">WrongFrameTypeError</a>.</p></dd>
 
 <dt><a name="-setStyle"><strong>setStyle</strong></a>(...)</dt>
 <dd><code>setStyle("style" [, "name"])</code>
@@ -103,11 +111,12 @@
 
 <dt><a name="-unGroupObjects"><strong>unGroupObjects</strong></a>(...)</dt>
 <dd><code>unGroupObjects("name")</code>
-<p>Destructs the group the object "name" belongs to.If "name" is not given the 
currently selected item is used.</p></dd>
+<p>Destructs the group the object "name" belongs to. If "name" is not given 
the currently selected item is used.</p></dd>
 
 <dt><a name="-textFlowMode"><strong>textFlowMode</strong>(...)</a></dt>
 <dd><code>textFlowMode("name" [, state])</code>
-<p>Enables/disables "Text Flows Around Frame" feature for object "name". 
Called with parameters string name and optional int "state" (0 &lt;= state 
&lt;= 3). Setting "state" to 0 will disable text flow. Setting "state" to 1 
will make text flow around object frame. Setting "state" to 2 will make text 
flow around bounding box. Setting "state" to 3 will make text flow around 
contour line. If "state" is not passed, text flow is toggled.</p></dd>
+<p>Enables/disables "Text Flows Around Frame" feature for object "name".</p>
+<p>Called with parameters string name and optional int "state" (0 &lt;= state 
&lt;= 3). Setting "state" to 0 will disable text flow. Setting "state" to 1 
will make text flow around object frame. Setting "state" to 2 will make text 
flow around bounding box. Setting "state" to 3 will make text flow around 
contour line. If "state" is not passed, text flow is toggled.</p></dd>
 
 </dl>
 </body>

Modified: trunk/Scribus/doc/ru/scripterapi-manobj.html
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=23689&path=/trunk/Scribus/doc/ru/scripterapi-manobj.html
==============================================================================
--- trunk/Scribus/doc/ru/scripterapi-manobj.html        (original)
+++ trunk/Scribus/doc/ru/scripterapi-manobj.html        Tue May  5 15:09:57 2020
@@ -11,7 +11,7 @@
 <dt><a name="-combinePolygons"><strong>combinePolygons()</strong></a></dt>
 <dd><code>combinePolygons()</code>
 <p>Combines two or more selected polygons.</p>
-<p>May raise WrongFrameTypeError.</p></dd>
+<p>May raise <a 
href="scripterapi.html#WrongFrameTypeError">WrongFrameTypeError</a>.</p></dd>
 
 <dt><a name="-copyObject"><strong>copyObject</strong>(...)</a></dt>
 <dd><code>copyObject(["name"]) -&gt; string</code>
@@ -23,15 +23,15 @@
 
 <dt><a 
name="-getCharacterStyle"><strong>getCharacterStyle</strong></a>(...)</dt>
 <dd><code>getCharacterStyle(["name"])</code>
-<p>Return name of character style applied to object named "name". If "name" is 
not given, the currently selected object is used.<p>
+<p>Return name of character style applied to object named "name". If "name" is 
not given, the currently selected object is used.</p>
 <p>If current object has a text selection, the name of style applied to start 
of selection is returned. Otherwise the name of the item default character 
style is returned.</p>
-<p>May raise WrongFrameTypeError.</p></dd>
+<p>May raise <a 
href="scripterapi.html#WrongFrameTypeError">WrongFrameTypeError</a> if target 
frame is not a text frame.</p></dd>
 
 <dt><a 
name="-getParagraphStyle"><strong>getParagraphStyle</strong></a>(...)</dt>
 <dd><code>getParagraphStyle(["name"])</code>
-<p>Return name of paragraph style applied to object named "name". If "name" is 
not given, the currently selected object is used.<p>
+<p>Return name of paragraph style applied to object named "name". If "name" is 
not given, the currently selected object is used.</p>
 <p>If current object has a text selection, the name of style applied to start 
of selection is returned. Otherwise the name of the item default style is 
returned.</p>
-<p>May raise WrongFrameTypeError.</p></dd>
+<p>May raise <a 
href="scripterapi.html#WrongFrameTypeError">WrongFrameTypeError</a> if target 
frame is not a text frame.</p></dd>
 
 <dt><a name="-getStyle"><strong>getStyle</strong></a>(...)</dt>
 <dd><code>getStyle(["name"])</code>
@@ -52,7 +52,7 @@
 <dt><a name="-moveObject"><strong>moveObject</strong></a>(...)</dt>
 <dd><code>moveObject(dx, dy [, "name"])</code>
 <p>Moves the object "name" by dx and dy relative to its current position. The 
distances are expressed in the current measurement unit of the document (see 
UNIT constants). If "name" is not given the currently selected item is used. If 
the object "name" belongs to a group, the whole group is moved.</p>
-<p>If what you wish to do is to move an object to a different page or layer, 
it may be more efficient to do the sequence <em>copyObject(...)</em>, followed 
by <em>pasteObject(...)</em>, and then finally <em>deleteObject(...)</em> to 
delete the original.</dd>
+<p>If what you wish to do is to move an object to a different page or layer, 
it may be more efficient to do the sequence <em>copyObject(...)</em>, followed 
by <em>pasteObject(...)</em>, and then finally <em>deleteObject(...)</em> to 
delete the original.</p></dd>
 
 <dt><a name="-moveObjectAbs"><strong>moveObjectAbs</strong></a>(...)</dt>
 <dd><code>moveObjectAbs(x, y [, "name"])</code>
@@ -60,7 +60,7 @@
 
 <dt><a name="-pasteObject"><strong>pasteObject</strong>(...)</a></dt>
 <dd><code>pasteObject(["name"]) -&gt; string</code>
-<p>pastes an Object from the clipboard. This will be used only or most 
sensibly following <em>copyObject(...)</em>, since otherwise there will likely 
be nothing in the clipboard to paste.</p></dd>
+<p>Pastes an Object from the clipboard. This will be used only or most 
sensibly following <em>copyObject(...)</em>, since otherwise there will likely 
be nothing in the clipboard to paste.</p></dd>
 
 <dt><a name="-rotateObject"><strong>rotateObject</strong></a>(...)</dt>
 <dd><code>rotateObject(rot [, "name"])</code>
@@ -77,21 +77,29 @@
 
 <dt><a 
name="-setCharacterStyle"><strong>setCharacterStyle</strong></a>(...)</dt>
 <dd><code>setCharacterStyle("style" [, "name"])</code>
-<p>Apply the named character "style" to the object named "name". If object 
name is given, style is applied to the current text selection in object "name". 
If no object name is given, style is applied on selected object.</p></dd>
+<p>Apply the named character "style" to the object named "name".</p>
+<p>If object name is not provided, style is applied on current object 
selection.</p>
+<p>If multiple objects are selected or if selected object has no text 
selection, style is applied on selected object(s). Otherwise style is applied 
to the current text selection.</p>
+<p>May raise <a 
href="scripterapi.html#WrongFrameTypeError">WrongFrameTypeError</a> if the 
target frame is not a text frame.</p>
+<p>May raise <a href="scripterapi.html#NotFoundError">NotFoundError</a> if 
specified style name does not exist in current document.</p></dd>
 
 <dt><a 
name="-setParagraphStyle"><strong>setParagraphStyle</strong></a>(...)</dt>
 <dd><code>setParagraphStyle("style" [, "name"])</code>
-<p>Apply the named paragraph "style" to the object named "name". If object 
name is given, style is applied to the current text selection in object "name". 
If no object name is given, style is applied on selected object.</p></dd>
+<p>Apply the named paragraph "style" to the object named "name".</p>
+<p>If object name is not provided, style is applied on current object 
selection.</p>
+<p>If multiple objects are selected or if selected object has no text 
selection, style is applied on selected object(s). Otherwise style is applied 
to the current text selection.</p>
+<p>May raise <a 
href="scripterapi.html#WrongFrameTypeError">WrongFrameTypeError</a> if the 
target frame is not a text frame.</p>
+<p>May raise <a href="scripterapi.html#NotFoundError">NotFoundError</a> if 
specified style name does not exist in current document.</p></dd>
 
 <dt><a 
name="-setScaleFrameToImage"><strong>setScaleFrameToImage</strong></a>(...)</dt>
 <dd><code>setScaleFrameToImage([name])</code>
 <p>Set frame size on the selected or specified image frame to image size.</p>
-<p>May raise WrongFrameTypeError.</p></dd>
+<p>May raise <a 
href="scripterapi.html#WrongFrameTypeError">WrongFrameTypeError</a>.</p></dd>
 
 <dt><a 
name="-setScaleImageToFrame"><strong>setScaleImageToFrame</strong></a>(...)</dt>
 <dd><code>setScaleImageToFrame(scaletoframe, proportional=None, 
name=&lt;selection&gt;)</code>
 <p>Sets the scale to frame on the selected or specified image frame to 
`scaletoframe'. If `proportional' is specified, set fixed aspect ratio scaling 
to `proportional'. Both `scaletoframe' and `proportional' are boolean.</p>
-<p>May raise WrongFrameTypeError.</p></dd>
+<p>May raise <a 
href="scripterapi.html#WrongFrameTypeError">WrongFrameTypeError</a>.</p></dd>
 
 <dt><a name="-setStyle"><strong>setStyle</strong></a>(...)</dt>
 <dd><code>setStyle("style" [, "name"])</code>
@@ -103,11 +111,12 @@
 
 <dt><a name="-unGroupObjects"><strong>unGroupObjects</strong></a>(...)</dt>
 <dd><code>unGroupObjects("name")</code>
-<p>Destructs the group the object "name" belongs to.If "name" is not given the 
currently selected item is used.</p></dd>
+<p>Destructs the group the object "name" belongs to. If "name" is not given 
the currently selected item is used.</p></dd>
 
 <dt><a name="-textFlowMode"><strong>textFlowMode</strong>(...)</a></dt>
 <dd><code>textFlowMode("name" [, state])</code>
-<p>Enables/disables "Text Flows Around Frame" feature for object "name". 
Called with parameters string name and optional int "state" (0 &lt;= state 
&lt;= 3). Setting "state" to 0 will disable text flow. Setting "state" to 1 
will make text flow around object frame. Setting "state" to 2 will make text 
flow around bounding box. Setting "state" to 3 will make text flow around 
contour line. If "state" is not passed, text flow is toggled.</p></dd>
+<p>Enables/disables "Text Flows Around Frame" feature for object "name".</p>
+<p>Called with parameters string name and optional int "state" (0 &lt;= state 
&lt;= 3). Setting "state" to 0 will disable text flow. Setting "state" to 1 
will make text flow around object frame. Setting "state" to 2 will make text 
flow around bounding box. Setting "state" to 3 will make text flow around 
contour line. If "state" is not passed, text flow is toggled.</p></dd>
 
 </dl>
 </body>

Modified: trunk/Scribus/scribus/plugins/scriptplugin/cmdobj.cpp
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=23689&path=/trunk/Scribus/scribus/plugins/scriptplugin/cmdobj.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/cmdobj.cpp       (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/cmdobj.cpp       Tue May  5 
15:09:57 2020
@@ -678,64 +678,52 @@
                PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set 
style on a non-text frame.", "python error").toLocal8Bit().constData());
                return nullptr;
        }
-
-       // First, find the style number associated with the requested style
-       // by scanning through the styles looking for the name. If
-       // we can't find it, raise PyExc_Exception.
-       // FIXME: Should use a more specific exception.
-       bool found = false;
-       QString paraStyleName = QString::fromUtf8(style);
-       // We start at zero here because it's OK to match an internal name
+       
        ScribusDoc*  currentDoc = ScCore->primaryMainWindow()->doc;
        ScribusView* currentView = ScCore->primaryMainWindow()->view;
        ScribusMainWindow* currentWin = ScCore->primaryMainWindow();
-       const StyleSet<ParagraphStyle> &docParagraphStyles = 
currentDoc->paragraphStyles();
-       int docParagraphStylesCount = docParagraphStyles.count();
-       for (int i=0; i < docParagraphStylesCount; ++i)
-       {
-               if (docParagraphStyles[i].name() == paraStyleName) {
-                       found = true;
-                       break;
-               }
-       }
-       if (!found) {
+
+       // First, check if style name provided by user is available in document
+       QString paraStyleName = QString::fromUtf8(style);
+       if (!currentDoc->paragraphStyles().contains(paraStyleName))
+       {
                // whoops, the user specified an invalid style, complain loudly.
+               // FIXME: Should use a more specific exception.
                PyErr_SetString(NotFoundError, QObject::tr("Style not 
found.","python error").toLocal8Bit().constData());
                return nullptr;
        }
-       // for current item only
-       if (currentDoc->m_Selection->isEmpty() || (strlen(name) > 0))
-       {
-               // Store text selection as clearing object selection
-               // will also clear text selection
-               int selectionStart = -1;
-               int selectionLength = item->itemText.selectionLength();
-               if (selectionLength > 0)
-                       selectionStart = item->itemText.startOfSelection();
-               // quick hack to always apply on the right frame - pv
-               currentView->deselectItems(true);
-               //CB I dont think we need to draw here. Its faster if we dont.
-               currentView->selectItem(item, false);
-               // Restore text selection if necessary
-               if (selectionStart >= 0)
-               {
-                       item->itemText.deselectAll();
-                       item->itemText.select(selectionStart, selectionLength);
-                       item->HasSel = true;
-               }
-               // Now apply the style.
-               int mode = currentDoc->appMode;
-               currentDoc->appMode = modeEdit;
-               currentWin->setNewParStyle(paraStyleName);
-               currentDoc->appMode = mode;
-       }
-       else // for multiple selection
+
+       // For multiple selections or if current item has no text selected, we 
apply style in normal mode
+       if (currentDoc->m_Selection->isMultipleSelection() || 
(item->itemText.selectionLength() <= 0))
        {
                int mode = currentDoc->appMode;
                currentDoc->appMode = modeNormal;
                currentDoc->itemSelection_SetNamedParagraphStyle(paraStyleName);
                currentDoc->appMode = mode;
-       }
+               Py_RETURN_NONE;
+       }
+
+       // For single items which have a text selection, we apply style in edit 
mode
+       // Store text selection as clearing object selection
+       // will also clear text selection
+       int selectionStart =  item->itemText.startOfSelection();
+       int selectionLength = item->itemText.selectionLength();
+       // Quick hack to always apply on the right frame - pv
+       currentView->deselectItems(true);
+       //CB I dont think we need to draw here. Its faster if we dont.
+       currentView->selectItem(item, false);
+       // Restore text selection if necessary
+       if (selectionStart >= 0)
+       {
+               item->itemText.deselectAll();
+               item->itemText.select(selectionStart, selectionLength);
+               item->HasSel = true;
+       }
+       // Now apply the style.
+       int mode = currentDoc->appMode;
+       currentDoc->appMode = modeEdit;
+       currentWin->setNewParStyle(paraStyleName);
+       currentDoc->appMode = mode;
 
        Py_RETURN_NONE;
 }
@@ -761,64 +749,53 @@
                PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set 
character style on a non-text frame.", "python 
error").toLocal8Bit().constData());
                return nullptr;
        }
-
-       // First, find the style number associated with the requested style
-       // by scanning through the styles looking for the name. If
-       // we can't find it, raise PyExc_Exception.
-       // FIXME: Should use a more specific exception.
-       bool found = false;
-       QString charStyleName = QString::fromUtf8(style);
-       // We start at zero here because it's OK to match an internal name
+       
        ScribusDoc*  currentDoc = ScCore->primaryMainWindow()->doc;
        ScribusView* currentView = ScCore->primaryMainWindow()->view;
        ScribusMainWindow* currentWin = ScCore->primaryMainWindow();
-       const StyleSet<CharStyle> &docCharStyles = currentDoc->charStyles();
-       int docCharacterStylesCount = docCharStyles.count();
-       for (int i = 0; i < docCharacterStylesCount; ++i)
-       {
-               if (docCharStyles[i].name() == charStyleName) {
-                       found = true;
-                       break;
-               }
-       }
-       if (!found) {
+
+       // First, check if style name provided by user is available in document
+       QString charStyleName = QString::fromUtf8(style);
+       if (!currentDoc->charStyles().contains(charStyleName))
+       {
                // whoops, the user specified an invalid style, complain loudly.
+               // FIXME: Should use a more specific exception.
                PyErr_SetString(NotFoundError, QObject::tr("Character style not 
found.", "python error").toLocal8Bit().constData());
                return nullptr;
        }
-       // for current item only
-       if (currentDoc->m_Selection->isEmpty() || (strlen(name) > 0))
-       {
-               // Store text selection as clearing object selection
-               // will also clear text selection
-               int selectionStart = -1;
-               int selectionLength = item->itemText.selectionLength();
-               if (selectionLength > 0)
-                       selectionStart = item->itemText.startOfSelection();
-               // quick hack to always apply on the right frame - pv
-               currentView->deselectItems(true);
-               //CB I dont think we need to draw here. Its faster if we dont.
-               currentView->selectItem(item, false);
-               // Restore text selection if necessary
-               if (selectionStart >= 0)
-               {
-                       item->itemText.deselectAll();
-                       item->itemText.select(selectionStart, selectionLength);
-                       item->HasSel = true;
-               }       
-               // Now apply the style.
-               int mode = ScCore->primaryMainWindow()->doc->appMode;
-               currentDoc->appMode = modeEdit;
-               currentWin->setNewCharStyle(charStyleName);
-               currentDoc->appMode = mode;
-       }
-       else // for multiple selection
+
+       // For multiple selections or if current item has no text selected, we 
apply style in normal mode
+       if (currentDoc->m_Selection->isMultipleSelection() || 
(item->itemText.selectionLength() <= 0))
        {
                int mode = currentDoc->appMode;
                currentDoc->appMode = modeNormal;
                currentDoc->itemSelection_SetNamedCharStyle(charStyleName);
                currentDoc->appMode = mode;
-       }
+               Py_RETURN_NONE;
+       }
+
+       // For single items which have a text selection, we apply style in edit 
mode
+       // Store text selection as clearing object selection
+       // will also clear text selection
+       int selectionStart =  item->itemText.startOfSelection();
+       int selectionLength = item->itemText.selectionLength();
+
+       // Quick hack to always apply on the right frame - pv
+       currentView->deselectItems(true);
+       //CB I dont think we need to draw here. Its faster if we dont.
+       currentView->selectItem(item, false);
+       // Restore text selection if necessary
+       if (selectionStart >= 0)
+       {
+               item->itemText.deselectAll();
+               item->itemText.select(selectionStart, selectionLength);
+               item->HasSel = true;
+       }       
+       // Now apply the style.
+       int mode = ScCore->primaryMainWindow()->doc->appMode;
+       currentDoc->appMode = modeEdit;
+       currentWin->setNewCharStyle(charStyleName);
+       currentDoc->appMode = mode;
 
        Py_RETURN_NONE;
 }

Modified: trunk/Scribus/scribus/plugins/scriptplugin/cmdobj.h
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=23689&path=/trunk/Scribus/scribus/plugins/scriptplugin/cmdobj.h
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/cmdobj.h (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/cmdobj.h Tue May  5 15:09:57 2020
@@ -271,9 +271,11 @@
 PyDoc_STRVAR(scribus_setparagraphstyle__doc__,
 QT_TR_NOOP("setParagraphStyle(\"style\" [, \"name\"])\n\
 \n\
-Apply the named paragraph \"style\" to the object named \"name\". If object 
name is\n\
-given, style is applied to the current text selection in object \"name\".\n\
-If no object name is given, style is applied on selected object.\n\
+Apply the named paragraph \"style\" to the object named \"name\".\n\
+If  object name is not provided, style is applied on current object 
selection.\n\
+If multiple objects are selected or if selected object has no text 
selection,\n\
+style is applied on selected objects. Otherwise style is applied to the 
current\n\
+text selection.\n\
 "));
 
 PyDoc_STRVAR(scribus_setstyle__doc__,
@@ -293,9 +295,11 @@
 PyDoc_STRVAR(scribus_setcharstyle__doc__,
 QT_TR_NOOP("setCharacterStyle(\"style\" [, \"name\"])\n\
 \n\
-Apply the named character \"style\" to the object named \"name\". If object 
name is\n\
-given, style is applied to the current text selection in object \"name\".\n\
-If no object name is given, style is applied on selected object.\n\
+Apply the named character \"style\" to the object named \"name\".\n\
+If  object name is not provided, style is applied on current object 
selection.\n\
+If multiple objects are selected or if selected object has no text 
selection,\n\
+style is applied on selected objects. Otherwise style is applied to the 
current\n\
+text selection.\n\
 "));
 /**
 Apply the named character style to the currently selected object.

Modified: trunk/Scribus/scribus/styles/styleset.h
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=23689&path=/trunk/Scribus/scribus/styles/styleset.h
==============================================================================
--- trunk/Scribus/scribus/styles/styleset.h     (original)
+++ trunk/Scribus/scribus/styles/styleset.h     Tue May  5 15:09:57 2020
@@ -127,19 +127,16 @@
 template<class STYLE>
 inline void StyleSet<STYLE>::remove(int index)
 {
-       assert(index >= 0 && index < styles.count()); 
-//     QList<STYLE*> it = styles.at(index);
+       assert(index >= 0 && index < styles.count());
        if (styles.at(index) == m_default)
                return;
-//     delete (*it);
-//     styles.erase(it);
        styles.removeAt(index);
 }
 
 template<class STYLE>
 inline bool StyleSet<STYLE>::contains(const QString& name) const
 {
-       for (int i=0; i < styles.count(); ++i)
+       for (int i = 0; i < styles.count(); ++i)
                if (styles[i]->name() == name)
                        return true;
        return false;
@@ -148,7 +145,7 @@
 template<class STYLE>
 inline int StyleSet<STYLE>::find(const QString& name) const
 {
-       for (int i=0; i < styles.count(); ++i)
+       for (int i = 0; i < styles.count(); ++i)
                if (styles[i]->name() == name)
                        return i;
        return -1;


_______________________________________________
scribus-commit mailing list
[email protected]
http://lists.scribus.net/mailman/listinfo/scribus-commit

Reply via email to