Author: jghali
Date: Wed Nov  6 11:48:44 2019
New Revision: 23339

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=23339
Log:
#15911: Add layoutTextChain() function to scripter for updating text layout for 
a whole text chain

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

Modified: trunk/Scribus/doc/de/scripterapi-textframes.html
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=23339&path=/trunk/Scribus/doc/de/scripterapi-textframes.html
==============================================================================
--- trunk/Scribus/doc/de/scripterapi-textframes.html    (original)
+++ trunk/Scribus/doc/de/scripterapi-textframes.html    Wed Nov  6 11:48:44 2019
@@ -100,6 +100,10 @@
 <dd><code>layoutText(["name"])</code>
 <p>Relayout text in the text frame "name". If "name" is not given the 
currently selected item is used.</p></dd>
 
+<dt><a name="-layoutTextChain"><strong>layoutTextChain</strong></a>(...)</dt>
+<dd><code>layoutTextChain(["name"])</code>
+<p>Relayout the whole text chain whom the text frame "name" belongs. If "name" 
is not given the currently selected item is used.</p></dd>
+
 <dt><a name="-selectText"><strong>selectText</strong></a>(...)</dt>
 <dd><code>selectText(start, count, ["name"])</code>
 <p>Selects "count" characters of text in the text frame "name" starting from 
the character "start". Character counting starts at 0. If "count" is zero, any 
text selection will be cleared.  If "name" is not given the currently selected 
item is used.</p>

Modified: trunk/Scribus/doc/en/scripterapi-textframes.html
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=23339&path=/trunk/Scribus/doc/en/scripterapi-textframes.html
==============================================================================
--- trunk/Scribus/doc/en/scripterapi-textframes.html    (original)
+++ trunk/Scribus/doc/en/scripterapi-textframes.html    Wed Nov  6 11:48:44 2019
@@ -100,6 +100,10 @@
 <dd><code>layoutText(["name"])</code>
 <p>Relayout text in the text frame "name". If "name" is not given the 
currently selected item is used.</p></dd>
 
+<dt><a name="-layoutTextChain"><strong>layoutTextChain</strong></a>(...)</dt>
+<dd><code>layoutTextChain(["name"])</code>
+<p>Relayout the whole text chain whom the text frame "name" belongs. If "name" 
is not given the currently selected item is used.</p></dd>
+
 <dt><a name="-selectText"><strong>selectText</strong></a>(...)</dt>
 <dd><code>selectText(start, count, ["name"])</code>
 <p>Selects "count" characters of text in the text frame "name" starting from 
the character "start". Character counting starts at 0. If "count" is zero, any 
text selection will be cleared.  If "name" is not given the currently selected 
item is used.</p>

Modified: trunk/Scribus/doc/fr/scripterapi-textframes.html
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=23339&path=/trunk/Scribus/doc/fr/scripterapi-textframes.html
==============================================================================
--- trunk/Scribus/doc/fr/scripterapi-textframes.html    (original)
+++ trunk/Scribus/doc/fr/scripterapi-textframes.html    Wed Nov  6 11:48:44 2019
@@ -74,6 +74,10 @@
 <dd><code>layoutText(["nom"])</code>
 <p>Actualise la mise en page du texte dans le cadre de texte "nom". Si "nom" 
n'est pas fourni, l'élément sélectionné est utilisé. </p></dd>
 
+<dt><a name="-layoutText"><strong>layoutTextChain</strong></a>(...)</dt>
+<dd><code>layoutTextChain(["nom"])</code>
+<p>Actualise la mise en page du texte pour l'intégralité de la chaîne de 
texte à laquelle le cadre de texte "nom" appartient. Si "nom" n'est pas 
fourni, l'élément sélectionné est utilisé. </p></dd>
+
 <dt><a name="-selectText"><strong>selectText</strong></a>(...)</dt>
 <dd><code>selectText(depart, compte, ["nom"])</code>
 <p>Sélectionne le nombre ("compte") de caractères de texte dans le cadre de 
texte "nom" en partant du caractère "départ". Le décompte des caractères 
commence &agrave; 0. Si "compte" est &agrave; zéro, tout le texte sera 
effacé. Si "nom" n'est pas fourni, l'élément sélectionné est utilisé. </p>

Modified: trunk/Scribus/doc/it/scripterapi-textframes.html
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=23339&path=/trunk/Scribus/doc/it/scripterapi-textframes.html
==============================================================================
--- trunk/Scribus/doc/it/scripterapi-textframes.html    (original)
+++ trunk/Scribus/doc/it/scripterapi-textframes.html    Wed Nov  6 11:48:44 2019
@@ -100,6 +100,10 @@
 <dd><code>layoutText(["name"])</code>
 <p>Relayout text in the text frame "name". If "name" is not given the 
currently selected item is used.</p></dd>
 
+<dt><a name="-layoutTextChain"><strong>layoutTextChain</strong></a>(...)</dt>
+<dd><code>layoutTextChain(["name"])</code>
+<p>Relayout the whole text chain whom the text frame "name" belongs. If "name" 
is not given the currently selected item is used.</p></dd>
+
 <dt><a name="-selectText"><strong>selectText</strong></a>(...)</dt>
 <dd><code>selectText(start, count, ["name"])</code>
 <p>Selects "count" characters of text in the text frame "name" starting from 
the character "start". Character counting starts at 0. If "count" is zero, any 
text selection will be cleared.  If "name" is not given the currently selected 
item is used.</p>

Modified: trunk/Scribus/doc/ru/scripterapi-textframes.html
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=23339&path=/trunk/Scribus/doc/ru/scripterapi-textframes.html
==============================================================================
--- trunk/Scribus/doc/ru/scripterapi-textframes.html    (original)
+++ trunk/Scribus/doc/ru/scripterapi-textframes.html    Wed Nov  6 11:48:44 2019
@@ -100,6 +100,10 @@
 <dd><code>layoutText(["name"])</code>
 <p>Relayout text in the text frame "name". If "name" is not given the 
currently selected item is used.</p></dd>
 
+<dt><a name="-layoutTextChain"><strong>layoutTextChain</strong></a>(...)</dt>
+<dd><code>layoutTextChain(["name"])</code>
+<p>Relayout the whole text chain whom the text frame "name" belongs. If "name" 
is not given the currently selected item is used.</p></dd>
+
 <dt><a name="-selectText"><strong>selectText</strong></a>(...)</dt>
 <dd><code>selectText(start, count, ["name"])</code>
 <p>Selects "count" characters of text in the text frame "name" starting from 
the character "start". Character counting starts at 0. If "count" is zero, any 
text selection will be cleared.  If "name" is not given the currently selected 
item is used.</p>

Modified: trunk/Scribus/scribus/plugins/scriptplugin/cmdtext.cpp
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=23339&path=/trunk/Scribus/scribus/plugins/scriptplugin/cmdtext.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/cmdtext.cpp      (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/cmdtext.cpp      Wed Nov  6 
11:48:44 2019
@@ -478,10 +478,43 @@
                return nullptr;
        if (!item->isTextFrame() && !item->isPathText())
        {
-               PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot delete 
text from a non-text frame.","python error").toLocal8Bit().constData());
+               PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot layout 
text for a non-text frame.", "python error").toLocal8Bit().constData());
                return nullptr;
        }
        item->layout();
+
+       Py_RETURN_NONE;
+}
+
+PyObject *scribus_layouttextchain(PyObject* /* self */, PyObject* args)
+{
+       char *Name = const_cast<char*>("");
+       if (!PyArg_ParseTuple(args, "|es", "utf-8", &Name))
+               return nullptr;
+       if (!checkHaveDocument())
+               return nullptr;
+       PageItem *item = GetUniqueItem(QString::fromUtf8(Name));
+       if (item == nullptr)
+               return nullptr;
+       if (!item->isTextFrame() && !item->isPathText())
+       {
+               PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot layout 
text chain for a non-text frame.", "python error").toLocal8Bit().constData());
+               return nullptr;
+       }
+
+       if (item->isPathText())
+       {
+               item->layout();
+               Py_RETURN_NONE;
+       }
+       
+       PageItem* firstFrame = item->firstInChain();
+       PageItem* nextFrame = firstFrame;
+       while (nextFrame)
+       {
+               nextFrame->layout();
+               nextFrame = nextFrame->nextInChain();
+       }
 
        Py_RETURN_NONE;
 }

Modified: trunk/Scribus/scribus/plugins/scriptplugin/cmdtext.h
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=23339&path=/trunk/Scribus/scribus/plugins/scriptplugin/cmdtext.h
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/cmdtext.h        (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/cmdtext.h        Wed Nov  6 
11:48:44 2019
@@ -215,6 +215,16 @@
 PyObject *scribus_layouttext(PyObject * /*self*/, PyObject* args);
 
 /*! docstring */
+PyDoc_STRVAR(scribus_layouttextchain__doc__,
+QT_TR_NOOP("layoutTextChain([\"name\"])\n\
+\n\
+Relayout the whole text chain whom the text frame \"name\" belongs.\n\
+If \"name\" is not given the currently selected item is used.\n\
+"));
+/*! Delete text */
+PyObject *scribus_layouttextchain(PyObject * /*self*/, PyObject* args);
+
+/*! docstring */
 PyDoc_STRVAR(scribus_setfont__doc__,
 QT_TR_NOOP("setFont(\"font\", [\"name\"])\n\
 \n\

Modified: trunk/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=23339&path=/trunk/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp Wed Nov  6 
11:48:44 2019
@@ -421,6 +421,7 @@
        {const_cast<char*>("isLayerFlow"), scribus_glayerflow, METH_VARARGS, 
tr(scribus_glayerflow__doc__)},
        {const_cast<char*>("isLocked"), scribus_islocked, METH_VARARGS, 
tr(scribus_islocked__doc__)},
        {const_cast<char*>("layoutText"), scribus_layouttext, METH_VARARGS, 
tr(scribus_layouttext__doc__)},
+       {const_cast<char*>("layoutTextChain"), scribus_layouttextchain, 
METH_VARARGS, tr(scribus_layouttextchain__doc__)},
        {const_cast<char*>("linkTextFrames"), scribus_linktextframes, 
METH_VARARGS, tr(scribus_linktextframes__doc__)},
        {const_cast<char*>("loadImage"), scribus_loadimage, METH_VARARGS, 
tr(scribus_loadimage__doc__)},
        {const_cast<char*>("loadStylesFromFile"), scribus_loadstylesfromfile, 
METH_VARARGS, tr(scribus_loadstylesfromfile__doc__)},


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

Reply via email to