View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0016784 | Scribus | Scripter | public | 2022-04-23 18:12 | 2022-04-24 14:42 |
Reporter | MattMiller | Assigned To | |||
Priority | normal | Severity | minor | Reproducibility | always |
Status | new | Resolution | open | ||
Product Version | 1.6.0.svn | ||||
Summary | 0016784: Support "Unlink Text Frames and Cut Text" | ||||
Description | Scripter should have some analog to the GUI option "Item | Text Frame Links | Unlink Text Frames and Cut Text." | ||||
Additional Information | Attached is a patch to add an optional "cut_text" boolean flag to the current unlinkTextFrames() function. If set the new flag mirrors "Item | Text Frame Links | Unlink Text Frames and Cut Text" the same way that the function without the flag mirrors "Item | Text Frame Links | Unlink Text Frames." I have some concerns, though: 1. api_textitem.cpp also contains a reference to unlinkTextFrames(), but I don't see how to add a boolean arg to that. Does this file need to be updated? 2. cmdtext.cpp currently has almost no functions with optional arguments other than the optional object name. The attached adds a function with an optional bool. This seems to be related to concern 1. above, since, for example, the current function isTextOverflowing() also uses a boolean, but that function is excluded from api_textitem.cpp. 3. The documentation for unlinkTextFrames() states, "If the frame was in the middle of a chain, the previous and next frames will be connected, eg 'a->b->c' becomes 'a->c' when you unlinkTextFrames(b)." However, I don't see that behavior. Whether I unlink via the GUI or via Scripter, and whether I cut text or not, it seems that breaking a link just separates the chain into two chains. In other words, it seems that the chain 'a->b->c->d' becomes the two chains 'a->b' and 'c->d' when you unlinkTextFrames(c). Thanks for helping me with my first contribution. | ||||
Tags | scripter | ||||
Patch | Yes | ||||
|
unlink_and_cut_text.txt (2,327 bytes)
$ svn diff Index: Scribus/scribus/plugins/scriptplugin/cmdtext.cpp =================================================================== --- Scribus/scribus/plugins/scriptplugin/cmdtext.cpp (revision 25083) +++ Scribus/scribus/plugins/scriptplugin/cmdtext.cpp (working copy) @@ -1329,7 +1329,8 @@ PyObject *scribus_unlinktextframes(PyObject* /* self */, PyObject* args) { char *name; - if (!PyArg_ParseTuple(args, "es", "utf-8", &name)) + bool cut_text; + if (!PyArg_ParseTuple(args, "es|b", "utf-8", &name, &cut_text)) return nullptr; if (!checkHaveDocument()) return nullptr; @@ -1366,7 +1367,14 @@ for (uint s = 0; s < a2; ++s) item->BackBox->itemText.append(item->itemText.take(0)); */ - item->prevInChain()->unlink(); + if (cut_text) + { + item->unlinkWithText(); + } + else + { + item->prevInChain()->unlink(); + } // enable 'save icon' stuff ScCore->primaryMainWindow()->slotDocCh(); ScCore->primaryMainWindow()->view->DrawNew(); Index: Scribus/scribus/plugins/scriptplugin_py2x/cmdtext.cpp =================================================================== --- Scribus/scribus/plugins/scriptplugin_py2x/cmdtext.cpp (revision 25083) +++ Scribus/scribus/plugins/scriptplugin_py2x/cmdtext.cpp (working copy) @@ -1330,7 +1330,8 @@ PyObject *scribus_unlinktextframes(PyObject* /* self */, PyObject* args) { char *name; - if (!PyArg_ParseTuple(args, "es", "utf-8", &name)) + bool cut_text; + if (!PyArg_ParseTuple(args, "es|b", "utf-8", &name, &cut_text)) return nullptr; if (!checkHaveDocument()) return nullptr; @@ -1367,7 +1368,14 @@ for (uint s = 0; s < a2; ++s) item->BackBox->itemText.append(item->itemText.take(0)); */ - item->prevInChain()->unlink(); + if (cut_text) + { + item->unlinkWithText(); + } + else + { + item->prevInChain()->unlink(); + } // enable 'save icon' stuff ScCore->primaryMainWindow()->slotDocCh(); ScCore->primaryMainWindow()->view->DrawNew(); |
|
Here's a matching patch for the doc, which also corrects the description of how the linkage looks after an unlink. Let me know if other files need to be updated. unlink_and_cut_text-doc.txt (1,378 bytes)
$ svn diff ./Scribus/doc/en/scripterapi-textframes.html Index: Scribus/doc/en/scripterapi-textframes.html =================================================================== --- Scribus/doc/en/scripterapi-textframes.html (revision 25083) +++ Scribus/doc/en/scripterapi-textframes.html (working copy) @@ -246,8 +246,8 @@ <p>May raise WrongFrameTypeError if the target frame is not an text frame</p></dd> <dt><a name="-unlinkTextFrames"><strong>unlinkTextFrames</strong></a>(...)</dt> -<dd><code>unlinkTextFrames("name")</code> -<p>Remove the specified (named) object from the text frame flow/linkage. If the frame was in the middle of a chain, the previous and next frames will be connected, eg 'a->b->c' becomes 'a->c' when you <a href="#-unlinkTextFrames">unlinkTextFrames</a>(b)'</p> +<dd><code>unlinkTextFrames("name", [cut_text])</code> +<p>Remove the specified (named) object from the text frame flow/linkage. For example, the chain 'a->b->c->d' becomes the two chains 'a->b' and 'c->d' when you <a href="#-unlinkTextFrames">unlinkTextFrames</a>(c). If "cut_text" is set to a non-zero value the text in the chain is cut to match the new frame linkage, otherwise the text flow ends just before the unlinked frame.</p> <p>May throw <a href="#ScribusException">ScribusException</a> if linking rules are violated.</p></dd> </dl> |
Date Modified | Username | Field | Change |
---|---|---|---|
2022-04-23 18:12 | MattMiller | New Issue | |
2022-04-23 18:12 | MattMiller | Tag Attached: scripter | |
2022-04-23 18:12 | MattMiller | File Added: unlink_and_cut_text.txt | |
2022-04-24 14:42 | MattMiller | Note Added: 0049630 | |
2022-04-24 14:42 | MattMiller | File Added: unlink_and_cut_text-doc.txt |