r24018 by craig - #16240: Fix lack of returned item name string for scripter copyObject and pasteObject
scribus-commit
scribus-commit at lists.scribus.net
Tue Sep 15 21:21:00 UTC 2020
Author: craig
Date: Tue Sep 15 21:20:59 2020
New Revision: 24018
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=24018
Log:
#16240: Fix lack of returned item name string for scripter copyObject and pasteObject
Modified:
trunk/Scribus/scribus/plugins/scriptplugin/cmdobj.cpp
trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdobj.cpp
Modified: trunk/Scribus/scribus/plugins/scriptplugin/cmdobj.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24018&path=/trunk/Scribus/scribus/plugins/scriptplugin/cmdobj.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/cmdobj.cpp (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/cmdobj.cpp Tue Sep 15 21:20:59 2020
@@ -859,7 +859,7 @@
// do the copy
currentWin->slotEditCopy();
- Py_RETURN_NONE;
+ return PyUnicode_FromString(currentDoc->m_Selection->itemAt(0)->itemName().toUtf8());
}
PyObject *scribus_pasteobject(PyObject * /* self */, PyObject *args)
@@ -871,9 +871,21 @@
return nullptr;
// do the paste
- ScCore->primaryMainWindow()->slotEditPaste();
-
- Py_RETURN_NONE;
+ ScribusMainWindow* currentWin = ScCore->primaryMainWindow();
+ ScribusDoc* currentDoc = currentWin->doc;
+ currentWin->slotEditPaste();
+ if (!currentDoc->m_Selection->isMultipleSelection())
+ return PyUnicode_FromString(currentDoc->m_Selection->itemAt(0)->itemName().toUtf8());
+
+ QString nameList;
+ int docSelectionCount = currentDoc->m_Selection->count();
+ for (int i = 0; i < docSelectionCount; ++i)
+ {
+ nameList.append(currentDoc->m_Selection->itemAt(i)->itemName());
+ if (i < docSelectionCount)
+ nameList.append(",");
+ }
+ return PyUnicode_FromString(nameList.toUtf8());
}
/*! HACK: this removes "warning: 'blah' defined but not used" compiler warnings
Modified: trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdobj.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24018&path=/trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdobj.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdobj.cpp (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdobj.cpp Tue Sep 15 21:20:59 2020
@@ -859,7 +859,7 @@
// do the copy
currentWin->slotEditCopy();
- Py_RETURN_NONE;
+ return PyString_FromString(currentDoc->m_Selection->itemAt(0)->itemName().toUtf8());
}
PyObject *scribus_pasteobject(PyObject * /* self */, PyObject *args)
@@ -871,9 +871,21 @@
return nullptr;
// do the paste
- ScCore->primaryMainWindow()->slotEditPaste();
-
- Py_RETURN_NONE;
+ ScribusMainWindow* currentWin = ScCore->primaryMainWindow();
+ ScribusDoc* currentDoc = currentWin->doc;
+ currentWin->slotEditPaste();
+ if (!currentDoc->m_Selection->isMultipleSelection())
+ return PyString_FromString(currentDoc->m_Selection->itemAt(0)->itemName().toUtf8());
+
+ QString nameList;
+ int docSelectionCount = currentDoc->m_Selection->count();
+ for (int i = 0; i < docSelectionCount; ++i)
+ {
+ nameList.append(currentDoc->m_Selection->itemAt(i)->itemName());
+ if (i < docSelectionCount)
+ nameList.append(",");
+ }
+ return PyString_FromString(nameList.toUtf8());
}
/*! HACK: this removes "warning: 'blah' defined but not used" compiler warnings
More information about the scribus-commit
mailing list