r22537 by craig - More nullptr and other conversions
scribus-commit
scribus-commit at lists.scribus.net
Sat May 12 20:34:43 UTC 2018
Author: craig
Date: Sat May 12 20:34:43 2018
New Revision: 22537
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=22537
Log:
More nullptr and other conversions
Modified:
trunk/Scribus/scribus/plugins/scriptplugin/cmdgetsetprop.cpp
trunk/Scribus/scribus/plugins/scriptplugin/cmdmani.cpp
trunk/Scribus/scribus/plugins/scriptplugin/cmdmisc.cpp
trunk/Scribus/scribus/plugins/scriptplugin/cmdobj.cpp
trunk/Scribus/scribus/plugins/scriptplugin/cmdpage.cpp
trunk/Scribus/scribus/plugins/scriptplugin/cmdsetprop.cpp
trunk/Scribus/scribus/plugins/scriptplugin/cmdtable.cpp
trunk/Scribus/scribus/plugins/scriptplugin/cmdtext.cpp
trunk/Scribus/scribus/plugins/scriptplugin/cmdutil.cpp
trunk/Scribus/scribus/plugins/scriptplugin/objimageexport.cpp
trunk/Scribus/scribus/plugins/scriptplugin/objpdffile.cpp
trunk/Scribus/scribus/plugins/scriptplugin/objprinter.cpp
trunk/Scribus/scribus/plugins/scriptplugin/scriptercore.cpp
Modified: trunk/Scribus/scribus/plugins/scriptplugin/cmdgetsetprop.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22537&path=/trunk/Scribus/scribus/plugins/scriptplugin/cmdgetsetprop.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/cmdgetsetprop.cpp (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/cmdgetsetprop.cpp Sat May 12 20:34:43 2018
@@ -21,14 +21,14 @@
return getPageItemByName(QString::fromUtf8(PyString_AsString(arg)));
else if (PyCObject_Check(arg))
{
- // It's a PyCObject, ie a wrapped pointer. Check it's not NULL
+ // It's a PyCObject, ie a wrapped pointer. Check it's not nullptr
// and return it.
// FIXME: Try to check that its a pointer to a QObject instance
QObject* tempObject = (QObject*)PyCObject_AsVoidPtr(arg);
if (!tempObject)
{
- PyErr_SetString(PyExc_TypeError, "INTERNAL: Passed NULL PyCObject");
- return NULL;
+ PyErr_SetString(PyExc_TypeError, "INTERNAL: Passed nullptr PyCObject");
+ return nullptr;
}
else
return tempObject;
@@ -37,14 +37,14 @@
{
// It's not a type we know what to do with
PyErr_SetString(PyExc_TypeError, QObject::tr("Argument must be page item name, or PyCObject instance").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
}
PyObject* wrapQObject(QObject* obj)
{
- return PyCObject_FromVoidPtr((void*)obj, NULL);
+ return PyCObject_FromVoidPtr((void*)obj, nullptr);
}
@@ -53,10 +53,10 @@
const QMetaObject* objmeta = obj->metaObject();
int i = objmeta->indexOfProperty(propname);
if (i == -1)
- return NULL;
+ return nullptr;
QMetaProperty propmeta = objmeta->property(i);
if (!propmeta.isValid())
- return NULL;
+ return nullptr;
const char* type = propmeta.typeName();
return type;
}
@@ -64,29 +64,29 @@
PyObject* scribus_propertyctype(PyObject* /*self*/, PyObject* args, PyObject* kw)
{
- PyObject* objArg = NULL;
- char* propertyname = NULL;
+ PyObject* objArg = nullptr;
+ char* propertyname = nullptr;
int includesuper = 1;
char* kwargs[] = {const_cast<char*>("object"),
const_cast<char*>("property"),
const_cast<char*>("includesuper"),
- NULL};
+ nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kw, "Oes|i", kwargs,
&objArg, "ascii", &propertyname, &includesuper))
- return NULL;
-
- // Get the QObject* the object argument refers to
- QObject* obj = getQObjectFromPyArg(objArg);
- if (!obj)
- return NULL;
- objArg = NULL; // no need to decref, it's borrowed
+ return nullptr;
+
+ // Get the QObject* the object argument refers to
+ QObject* obj = getQObjectFromPyArg(objArg);
+ if (!obj)
+ return nullptr;
+ objArg = nullptr; // no need to decref, it's borrowed
// Look up the property and retrive its type information
const char* type = getpropertytype( (QObject*)obj, propertyname, includesuper);
- if (type == NULL)
+ if (type == nullptr)
{
PyErr_SetString(PyExc_KeyError, QObject::tr("Property not found").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
return PyString_FromString(type);
}
@@ -95,11 +95,11 @@
{
PyObject* resultList = PyList_New(0);
if (!resultList)
- return NULL;
+ return nullptr;
for ( QStringList::Iterator it = origlist.begin(); it != origlist.end(); ++it )
if (PyList_Append(resultList, PyString_FromString((*it).toUtf8().data())) == -1)
- return NULL;
+ return nullptr;
return resultList;
}
@@ -109,9 +109,9 @@
{
PyObject* resultList = PyList_New(0);
if (!resultList)
- return NULL;
-
- PyObject* objPtr = NULL;
+ return nullptr;
+
+ PyObject* objPtr = nullptr;
// Loop over the objects in the list and add them to the python
// list wrapped in PyCObjects .
for (int i = 0; i < origlist->count(); ++i)
@@ -122,11 +122,11 @@
{
// Failed to wrap the object. An exception is already set.
Py_DECREF(resultList);
- return NULL;
+ return nullptr;
}
// and add it to the list
if (PyList_Append(resultList, (PyObject*)objPtr) == -1)
- return NULL;
+ return nullptr;
}
return resultList;
}
@@ -135,9 +135,9 @@
PyObject* scribus_getchildren(PyObject* , PyObject* args, PyObject* kw)
{
- PyObject* objArg = NULL;
- char* ofclass = NULL;
- char* ofname = NULL;
+ PyObject* objArg = nullptr;
+ char* ofclass = nullptr;
+ char* ofname = nullptr;
int recursive = 0;
int regexpmatch = 0;
char* kwnames[] = {const_cast<char*>("object"),
@@ -145,16 +145,16 @@
const_cast<char*>("ofname"),
const_cast<char*>("regexpmatch"),
const_cast<char*>("recursive"),
- NULL};
+ nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kw, "O|esesii", kwnames,
&objArg, "ascii", &ofclass, "ascii", &ofname, ®expmatch, &recursive))
- return NULL;
-
- // Get the QObject* the object argument refers to
- QObject* obj = getQObjectFromPyArg(objArg);
- if (!obj)
- return NULL;
- objArg = NULL; // no need to decref, it's borrowed
+ return nullptr;
+
+ // Get the QObject* the object argument refers to
+ QObject* obj = getQObjectFromPyArg(objArg);
+ if (!obj)
+ return nullptr;
+ objArg = nullptr; // no need to decref, it's borrowed
// Our job is to return a Python list containing the children of this
// widget (as PyCObjects).
@@ -171,33 +171,33 @@
// select class.
PyObject* scribus_getchild(PyObject* , PyObject* args, PyObject* kw)
{
- PyObject* objArg = NULL;
- char* childname = NULL;
- char* ofclass = NULL;
+ PyObject* objArg = nullptr;
+ char* childname = nullptr;
+ char* ofclass = nullptr;
bool recursive = true;
char* kwnames[] = {const_cast<char*>("object"),
const_cast<char*>("childname"),
const_cast<char*>("ofclass"),
const_cast<char*>("recursive"),
- NULL};
+ nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kw, "Oes|esi", kwnames,
&objArg, "ascii", &childname, "ascii", &ofclass, &recursive))
- return NULL;
-
- // Get the QObject* the object argument refers to
- QObject* obj = getQObjectFromPyArg(objArg);
- if (!obj)
- return NULL;
- objArg = NULL; // no need to decref, it's borrowed
+ return nullptr;
+
+ // Get the QObject* the object argument refers to
+ QObject* obj = getQObjectFromPyArg(objArg);
+ if (!obj)
+ return nullptr;
+ objArg = nullptr; // no need to decref, it's borrowed
// Search for the child, possibly restricting the search to children
// of a particular type, and possibly recursively searching through
// grandchildren etc.
QObject* child = obj->child(childname, ofclass, recursive);
- if (child == NULL)
+ if (child == nullptr)
{
PyErr_SetString(PyExc_KeyError, QObject::tr("Child not found").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
return wrapQObject(child);
@@ -206,25 +206,25 @@
PyObject* scribus_getpropertynames(PyObject* /*self*/, PyObject* args, PyObject* kw)
{
- PyObject* objArg = NULL;
+ PyObject* objArg = nullptr;
int includesuper = 1;
char* kwargs[] = {const_cast<char*>("object"),
const_cast<char*>("includesuper"),
- NULL};
+ nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kw, "O|i", kwargs,
&objArg, &includesuper))
- return NULL;
-
- // Get the QObject* the object argument refers to
- QObject* obj = getQObjectFromPyArg(objArg);
- if (!obj)
- return NULL;
- objArg = NULL; // no need to decref, it's borrowed
+ return nullptr;
+
+ // Get the QObject* the object argument refers to
+ QObject* obj = getQObjectFromPyArg(objArg);
+ if (!obj)
+ return nullptr;
+ objArg = nullptr; // no need to decref, it's borrowed
// Retrive the object's meta object so we can query it
const QMetaObject* objmeta = obj->metaObject();
if (!objmeta)
- return NULL;
+ return nullptr;
// Return the list of properties
QStringList propertyNames;
@@ -240,20 +240,20 @@
PyObject* scribus_getproperty(PyObject* /*self*/, PyObject* args, PyObject* kw)
{
- PyObject* objArg = NULL;
- char* propertyName = NULL;
+ PyObject* objArg = nullptr;
+ char* propertyName = nullptr;
char* kwargs[] = {const_cast<char*>("object"),
const_cast<char*>("property"),
- NULL};
+ nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kw, "Oes", kwargs,
&objArg, "ascii", &propertyName))
- return NULL;
-
- // Get the QObject* the object argument refers to
- QObject* obj = getQObjectFromPyArg(objArg);
- if (!obj)
- return NULL;
- objArg = NULL; // no need to decref, it's borrowed
+ return nullptr;
+
+ // Get the QObject* the object argument refers to
+ QObject* obj = getQObjectFromPyArg(objArg);
+ if (!obj)
+ return nullptr;
+ objArg = nullptr; // no need to decref, it's borrowed
// Get the QMetaProperty for the property, so we can check
// if it's a set/enum and do name/value translation.
@@ -263,7 +263,7 @@
{
PyErr_SetString(PyExc_ValueError,
QObject::tr("Property not found").toLocal8Bit().data());
- return NULL;
+ return nullptr;
}
QMetaProperty propmeta = objmeta->property(i);
@@ -271,14 +271,14 @@
{
PyErr_SetString(PyExc_ValueError,
QObject::tr("Invalid property").toLocal8Bit().data());
- return NULL;
+ return nullptr;
}
// Get the property value as a variant type
QVariant prop = obj->property(propertyName);
// Convert the property to an instance of the closest matching Python type.
- PyObject* resultobj = NULL;
+ PyObject* resultobj = nullptr;
// NUMERIC TYPES
if (prop.type() == QVariant::Int)
resultobj = PyLong_FromLong(prop.toInt());
@@ -321,11 +321,11 @@
}
// Return the resulting Python object
- if (resultobj == NULL)
+ if (resultobj == nullptr)
{
// An exception was set while assigning to resultobj
assert(PyErr_Occurred());
- return NULL;
+ return nullptr;
}
else
return resultobj;
@@ -335,16 +335,16 @@
PyObject* scribus_setproperty(PyObject* /*self*/, PyObject* args, PyObject* kw)
{
- PyObject* objArg = NULL;
- char* propertyName = NULL;
- PyObject* objValue = NULL;
+ PyObject* objArg = nullptr;
+ char* propertyName = nullptr;
+ PyObject* objValue = nullptr;
char* kwargs[] = {const_cast<char*>("object"),
const_cast<char*>("property"),
const_cast<char*>("value"),
- NULL};
+ nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kw, "OesO", kwargs,
&objArg, "ascii", &propertyName, &objValue))
- return NULL;
+ return nullptr;
// We're going to hang on to the value object for a while, so
// claim a reference to it.
@@ -353,12 +353,12 @@
// Get the QObject* the object argument refers to
QObject* obj = getQObjectFromPyArg(objArg);
if (!obj)
- return NULL;
- objArg = NULL; // no need to decref, it's borrowed
+ return nullptr;
+ objArg = nullptr; // no need to decref, it's borrowed
const char* propertyTypeName = getpropertytype(obj, propertyName, true);
- if (propertyTypeName == NULL)
- return NULL;
+ if (propertyTypeName == nullptr)
+ return nullptr;
QString propertyType = QString::fromLatin1(propertyTypeName);
// Did we know how to convert the value argument to the right type?
@@ -452,7 +452,7 @@
Py_DECREF(objValue);
PyErr_SetString(PyExc_TypeError,
QObject::tr("Property type '%1' not supported").arg(propertyType).toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
// If `matched' is false, we recognised the C type but weren't able to
@@ -463,7 +463,7 @@
PyObject* objRepr = PyObject_Repr(objValue);
Py_DECREF(objValue); // We're done with it now
if (!objRepr)
- return NULL;
+ return nullptr;
// Extract the repr() string
QString reprString = QString::fromUtf8(PyString_AsString(objRepr));
Py_DECREF(objRepr);
@@ -471,7 +471,7 @@
// And return an error
PyErr_SetString(PyExc_TypeError,
QObject::tr("Couldn't convert '%1' to property type '%2'").arg(reprString).arg(propertyType).toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
// `success' is the return value of the setProperty() call
@@ -479,7 +479,7 @@
{
Py_DECREF(objValue);
PyErr_SetString(PyExc_ValueError, QObject::tr("Types matched, but setting property failed.").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
Py_DECREF(objValue);
Modified: trunk/Scribus/scribus/plugins/scriptplugin/cmdmani.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22537&path=/trunk/Scribus/scribus/plugins/scriptplugin/cmdmani.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/cmdmani.cpp (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/cmdmani.cpp Sat May 12 20:34:43 2018
@@ -21,16 +21,16 @@
char *Name = const_cast<char*>("");
char *Image;
if (!PyArg_ParseTuple(args, "es|es", "utf-8", &Image, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
- PageItem *item = GetUniqueItem(QString::fromUtf8(Name));
- if (item == NULL)
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
+ PageItem *item = GetUniqueItem(QString::fromUtf8(Name));
+ if (item == nullptr)
+ return nullptr;
if (!item->asImageFrame())
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Target is not an image frame.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
ScCore->primaryMainWindow()->doc->loadPict(QString::fromUtf8(Image), item);
// Py_INCREF(Py_None);
@@ -43,16 +43,16 @@
char *Name = const_cast<char*>("");
double x, y;
if (!PyArg_ParseTuple(args, "dd|es", &x, &y, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
- PageItem *item = GetUniqueItem(QString::fromUtf8(Name));
- if (item == NULL)
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
+ PageItem *item = GetUniqueItem(QString::fromUtf8(Name));
+ if (item == nullptr)
+ return nullptr;
if (! item->asImageFrame())
{
PyErr_SetString(ScribusException, QObject::tr("Specified item not an image frame.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
// Grab the old selection - but use it only where is there any
@@ -85,16 +85,16 @@
char *Name = const_cast<char*>("");
double x, y;
if (!PyArg_ParseTuple(args, "dd|es", &x, &y, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
- PageItem *item = GetUniqueItem(QString::fromUtf8(Name));
- if (item == NULL)
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
+ PageItem *item = GetUniqueItem(QString::fromUtf8(Name));
+ if (item == nullptr)
+ return nullptr;
if (! item->asImageFrame())
{
PyErr_SetString(ScribusException, QObject::tr("Specified item not an image frame.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
// Grab the old selection - but use it only where is there any
@@ -128,16 +128,16 @@
char *Name = const_cast<char*>("");
double x, y;
if (!PyArg_ParseTuple(args, "dd|es", &x, &y, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
- PageItem *item = GetUniqueItem(QString::fromUtf8(Name));
- if (item == NULL)
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
+ PageItem *item = GetUniqueItem(QString::fromUtf8(Name));
+ if (item == nullptr)
+ return nullptr;
if (! item->asImageFrame())
{
PyErr_SetString(ScribusException, QObject::tr("Specified item not an image frame.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
// Grab the old selection - but use it only where is there any
@@ -172,16 +172,16 @@
char *Name = const_cast<char*>("");
double n;
if (!PyArg_ParseTuple(args, "d|es", &n, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
- PageItem *item = GetUniqueItem(QString::fromUtf8(Name));
- if (item == NULL)
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
+ PageItem *item = GetUniqueItem(QString::fromUtf8(Name));
+ if (item == nullptr)
+ return nullptr;
if (! item->asImageFrame())
{
PyErr_SetString(ScribusException, QObject::tr("Specified item not an image frame.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
ImageEffect ef;
@@ -202,16 +202,16 @@
{
char *Name = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "|es", "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
- PageItem *item = GetUniqueItem(QString::fromUtf8(Name));
- if (item == NULL)
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
+ PageItem *item = GetUniqueItem(QString::fromUtf8(Name));
+ if (item == nullptr)
+ return nullptr;
if (! item->asImageFrame())
{
PyErr_SetString(ScribusException, QObject::tr("Specified item not an image frame.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
ImageEffect ef;
@@ -231,12 +231,12 @@
char *Name = const_cast<char*>("");
double x, y;
if (!PyArg_ParseTuple(args, "dd|es", &x, &y, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
- PageItem *item = GetUniqueItem(QString::fromUtf8(Name));
- if (item==NULL)
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
+ PageItem *item = GetUniqueItem(QString::fromUtf8(Name));
+ if (item==nullptr)
+ return nullptr;
// Grab the old selection - but use it only where is there any
Selection tempSelection(*ScCore->primaryMainWindow()->doc->m_Selection);
bool hadOrigSelection = (tempSelection.count() != 0);
@@ -269,12 +269,12 @@
char *Name = const_cast<char*>("");
double x, y;
if (!PyArg_ParseTuple(args, "dd|es", &x, &y, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
- PageItem *item = GetUniqueItem(QString::fromUtf8(Name));
- if (item == NULL)
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
+ PageItem *item = GetUniqueItem(QString::fromUtf8(Name));
+ if (item == nullptr)
+ return nullptr;
// Grab the old selection - but use it only where is there any
Selection tempSelection(*ScCore->primaryMainWindow()->doc->m_Selection);
bool hadOrigSelection = (tempSelection.count() != 0);
@@ -308,12 +308,12 @@
char *Name = const_cast<char*>("");
double x;
if (!PyArg_ParseTuple(args, "d|es", &x, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
- PageItem *item = GetUniqueItem(QString::fromUtf8(Name));
- if (item == NULL)
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
+ PageItem *item = GetUniqueItem(QString::fromUtf8(Name));
+ if (item == nullptr)
+ return nullptr;
ScCore->primaryMainWindow()->doc->rotateItem(item->rotation() - x, item);
// Py_INCREF(Py_None);
// return Py_None;
@@ -325,12 +325,12 @@
char *Name = const_cast<char*>("");
double x;
if (!PyArg_ParseTuple(args, "d|es", &x, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
- PageItem *item = GetUniqueItem(QString::fromUtf8(Name));
- if (item == NULL)
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
+ PageItem *item = GetUniqueItem(QString::fromUtf8(Name));
+ if (item == nullptr)
+ return nullptr;
ScCore->primaryMainWindow()->doc->rotateItem(x * -1.0, item);
// Py_INCREF(Py_None);
// return Py_None;
@@ -342,12 +342,12 @@
char *Name = const_cast<char*>("");
double x, y;
if (!PyArg_ParseTuple(args, "dd|es", &x, &y, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
- PageItem *item = GetUniqueItem(QString::fromUtf8(Name));
- if (item == NULL)
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
+ PageItem *item = GetUniqueItem(QString::fromUtf8(Name));
+ if (item == nullptr)
+ return nullptr;
ScCore->primaryMainWindow()->doc->sizeItem(ValueToPoint(x), ValueToPoint(y), item);
// Py_INCREF(Py_None);
// return Py_None;
@@ -359,13 +359,13 @@
char *Name = const_cast<char*>("");
PyObject *il = 0;
if (!PyArg_ParseTuple(args, "|O", &il))
- return NULL;
+ return nullptr;
if (!checkHaveDocument())
- return NULL;
+ return nullptr;
if (il == 0 && ScCore->primaryMainWindow()->doc->m_Selection->count() < 2)
{
PyErr_SetString(PyExc_TypeError, QObject::tr("Need selection or argument list of items to group", "python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
Selection *tempSelection=0;
Selection *finalSelection=0;
@@ -382,10 +382,10 @@
// so anyway.
Name = PyString_AsString(PyList_GetItem(il, i));
PageItem *ic = GetUniqueItem(QString::fromUtf8(Name));
- if (ic == NULL)
+ if (ic == nullptr)
{
delete tempSelection;
- return NULL;
+ return nullptr;
}
tempSelection->addItem (ic, true);
}
@@ -399,26 +399,26 @@
PyErr_SetString(NoValidObjectError, QObject::tr("Cannot group less than two items", "python error").toLocal8Bit().constData());
finalSelection=0;
delete tempSelection;
- return NULL;
+ return nullptr;
}
const PageItem* group = ScCore->primaryMainWindow()->doc->itemSelection_GroupObjects(false, false, finalSelection);
finalSelection=0;
delete tempSelection;
- return (group ? PyString_FromString(group->itemName().toUtf8()) : NULL);
+ return (group ? PyString_FromString(group->itemName().toUtf8()) : nullptr);
}
PyObject *scribus_ungroupobj(PyObject* /* self */, PyObject* args)
{
char *Name = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "|es", "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
- if (i == NULL)
- return NULL;
+ if (i == nullptr)
+ return nullptr;
ScCore->primaryMainWindow()->view->Deselect();
ScCore->primaryMainWindow()->view->SelectItem(i);
ScCore->primaryMainWindow()->UnGroupObj();
@@ -432,17 +432,17 @@
char *Name = const_cast<char*>("");
double sc;
if (!PyArg_ParseTuple(args, "d|es", &sc, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
if (sc == 0.0)
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot scale by 0%.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
- if (i == NULL)
- return NULL;
+ if (i == nullptr)
+ return nullptr;
ScCore->primaryMainWindow()->view->Deselect();
ScCore->primaryMainWindow()->view->SelectItem(i);
// int h = ScCore->primaryMainWindow()->view->frameResizeHandle;
@@ -460,9 +460,9 @@
{
int i = 0;
if (!PyArg_ParseTuple(args, "|i", &i))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
if ((i < static_cast<int>(ScCore->primaryMainWindow()->doc->m_Selection->count())) && (i > -1))
return PyString_FromString(ScCore->primaryMainWindow()->doc->m_Selection->itemAt(i)->itemName().toUtf8());
else
@@ -473,7 +473,7 @@
PyObject *scribus_selcount(PyObject* /* self */)
{
if(!checkHaveDocument())
- return NULL;
+ return nullptr;
return PyInt_FromLong(static_cast<long>(ScCore->primaryMainWindow()->doc->m_Selection->count()));
}
@@ -481,12 +481,12 @@
{
char *Name = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "es", "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
- if (i == NULL)
- return NULL;
+ if (i == nullptr)
+ return nullptr;
ScCore->primaryMainWindow()->view->SelectItem(i);
// Py_INCREF(Py_None);
// return Py_None;
@@ -496,7 +496,7 @@
PyObject *scribus_deselect(PyObject* /* self */)
{
if(!checkHaveDocument())
- return NULL;
+ return nullptr;
ScCore->primaryMainWindow()->view->Deselect();
// Py_INCREF(Py_None);
// return Py_None;
@@ -507,12 +507,12 @@
{
char *name = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "|es", "utf-8", &name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
PageItem *item = GetUniqueItem(QString::fromUtf8(name));
- if (item == NULL)
- return NULL;
+ if (item == nullptr)
+ return nullptr;
item->toggleLock();
if (item->locked())
return PyInt_FromLong(1);
@@ -523,14 +523,14 @@
{
char *name = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "|es", "utf-8", &name))
- return NULL;
+ return nullptr;
// FIXME: Rather than toggling the lock, we should probably let the user set the lock state
// and instead provide a different function like toggleLock()
if(!checkHaveDocument())
- return NULL;
+ return nullptr;
PageItem *item = GetUniqueItem(QString::fromUtf8(name));
- if (item == NULL)
- return NULL;
+ if (item == nullptr)
+ return nullptr;
if (item->locked())
return PyBool_FromLong(1);
return PyBool_FromLong(0);
@@ -542,18 +542,18 @@
long int scaleToFrame = 0;
long int proportional = 1;
char* kwargs[] = {const_cast<char*>("scaletoframe"),
- const_cast<char*>("proportional"), const_cast<char*>("name"), NULL};
+ const_cast<char*>("proportional"), const_cast<char*>("name"), nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kw, "i|ies", kwargs, &scaleToFrame, &proportional, "utf-8", &name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
PageItem *item = GetUniqueItem(QString::fromUtf8(name));
- if (item == NULL)
- return NULL;
+ if (item == nullptr)
+ return nullptr;
if (! item->asImageFrame())
{
PyErr_SetString(ScribusException, QObject::tr("Specified item not an image frame.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
// Set the item to scale if appropriate. ScaleType 1 is free
// scale, 0 is scale to frame.
@@ -579,12 +579,12 @@
char *Name = const_cast<char*>("");
double h, v;
if (!PyArg_ParseTuple(args, "dd|es", &h, &v, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
- PageItem *item = GetUniqueItem(QString::fromUtf8(Name));
- if (item == NULL)
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
+ PageItem *item = GetUniqueItem(QString::fromUtf8(Name));
+ if (item == nullptr)
+ return nullptr;
// Grab the old selection - but use it only where is there any
Selection tempSelection(*ScCore->primaryMainWindow()->doc->m_Selection);
Modified: trunk/Scribus/scribus/plugins/scriptplugin/cmdmisc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22537&path=/trunk/Scribus/scribus/plugins/scriptplugin/cmdmisc.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/cmdmisc.cpp (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/cmdmisc.cpp Sat May 12 20:34:43 2018
@@ -24,9 +24,9 @@
{
int e;
if (!PyArg_ParseTuple(args, "i", &e))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
ScCore->primaryMainWindow()->doc->DoDrawing = static_cast<bool>(e);
// Py_INCREF(Py_None);
// return Py_None;
@@ -85,7 +85,7 @@
char *Name = const_cast<char*>("");
char *FileName = const_cast<char*>("");
char *Sample = const_cast<char*>("");
- char *format = NULL;
+ char *format = nullptr;
int Size;
bool ret = false;
char *kwargs[] = {const_cast<char*>("fontname"),
@@ -93,20 +93,20 @@
const_cast<char*>("sample"),
const_cast<char*>("size"),
const_cast<char*>("format"),
- NULL};
+ nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kw, "esesesi|es", kwargs,
"utf-8", &Name, "utf-8", &FileName, "utf-8", &Sample, &Size, "ascii", &format))
- return NULL;
+ return nullptr;
if (!PrefsManager::instance()->appPrefs.fontPrefs.AvailFonts.contains(QString::fromUtf8(Name)))
{
PyErr_SetString(NotFoundError, QObject::tr("Font not found.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
QVector<uint> ts = QString::fromUtf8(Sample).toUcs4();
if (ts.isEmpty())
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot render an empty sample.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
if (!format)
// User specified no format, so use the historical default of PPM format.
@@ -123,13 +123,13 @@
if (!ret)
{
PyErr_SetString(ScribusException, QObject::tr("Unable to save pixmap","scripter error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
int bufferSize = buffer.size();
buffer.close();
// Now make a Python string from the data we generated
PyObject* stringPython = PyString_FromStringAndSize(buffer_string,bufferSize);
- // Return even if the result is NULL (error) since an exception will have been
+ // Return even if the result is nullptr (error) since an exception will have been
// set in that case.
return stringPython;
}
@@ -140,7 +140,7 @@
if (!ret)
{
PyErr_SetString(PyExc_Exception, QObject::tr("Unable to save pixmap","scripter error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
// For historical reasons, we need to return true on success.
// Py_INCREF(Py_True);
@@ -153,7 +153,7 @@
PyObject *scribus_getlayers(PyObject* /* self */)
{
if(!checkHaveDocument())
- return NULL;
+ return nullptr;
PyObject *l;
l = PyList_New(ScCore->primaryMainWindow()->doc->Layers.count());
for (int lam=0; lam < ScCore->primaryMainWindow()->doc->Layers.count(); lam++)
@@ -165,13 +165,13 @@
{
char *Name = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "es", "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
if (Name == 0)
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot have an empty layer name.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
bool found = ScCore->primaryMainWindow()->doc->setActiveLayer(QString::fromUtf8(Name));
if (found)
@@ -179,7 +179,7 @@
else
{
PyErr_SetString(NotFoundError, QObject::tr("Layer not found.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
// Py_INCREF(Py_None);
// return Py_None;
@@ -189,7 +189,7 @@
PyObject *scribus_getactlayer(PyObject* /* self */)
{
if(!checkHaveDocument())
- return NULL;
+ return nullptr;
return PyString_FromString(ScCore->primaryMainWindow()->doc->activeLayerName().toUtf8());
}
@@ -198,24 +198,24 @@
char *Name = const_cast<char*>("");
char *Layer = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "es|es", "utf-8", &Layer, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
if (strlen(Layer) == 0)
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot have an empty layer name.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
PageItem *item = GetUniqueItem(QString::fromUtf8(Name));
- if (item == NULL)
- return NULL;
+ if (item == nullptr)
+ return nullptr;
ScribusDoc* currentDoc = ScCore->primaryMainWindow()->doc;
ScribusView* currentView = ScCore->primaryMainWindow()->view;
const ScLayer *scLayer = currentDoc->Layers.layerByName( QString::fromUtf8(Layer) );
if (!scLayer)
{
PyErr_SetString(ScribusException, QString("Layer not found").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
// If no name have been specified in args, process whole selection
currentView->SelectItem(item);
@@ -242,13 +242,13 @@
char *Name = const_cast<char*>("");
int vis = 1;
if (!PyArg_ParseTuple(args, "esi", "utf-8", &Name, &vis))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
if (strlen(Name) == 0)
{
PyErr_SetString(PyExc_ValueError, QString("Cannot have an empty layer name").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
bool found = false;
for (int lam=0; lam < ScCore->primaryMainWindow()->doc->Layers.count(); ++lam)
@@ -263,7 +263,7 @@
if (!found)
{
PyErr_SetString(NotFoundError, QObject::tr("Layer not found.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
// Py_INCREF(Py_None);
// return Py_None;
@@ -275,13 +275,13 @@
char *Name = const_cast<char*>("");
int vis = 1;
if (!PyArg_ParseTuple(args, "esi", "utf-8", &Name, &vis))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
- if (strlen(Name) == 0)
- {
- PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot have an empty layer name.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
+ if (strlen(Name) == 0)
+ {
+ PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot have an empty layer name.","python error").toLocal8Bit().constData());
+ return nullptr;
}
bool found = false;
for (int lam=0; lam < ScCore->primaryMainWindow()->doc->Layers.count(); ++lam)
@@ -296,7 +296,7 @@
if (!found)
{
PyErr_SetString(NotFoundError, QObject::tr("Layer not found.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
// Py_INCREF(Py_None);
// return Py_None;
@@ -308,13 +308,13 @@
char *Name = const_cast<char*>("");
int vis = 1;
if (!PyArg_ParseTuple(args, "esi", "utf-8", &Name, &vis))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
- if (strlen(Name) == 0)
- {
- PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot have an empty layer name.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
+ if (strlen(Name) == 0)
+ {
+ PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot have an empty layer name.","python error").toLocal8Bit().constData());
+ return nullptr;
}
bool found = false;
for (int lam=0; lam < ScCore->primaryMainWindow()->doc->Layers.count(); ++lam)
@@ -329,7 +329,7 @@
if (!found)
{
PyErr_SetString(NotFoundError, QObject::tr("Layer not found.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
// Py_INCREF(Py_None);
// return Py_None;
@@ -341,13 +341,13 @@
char *Name = const_cast<char*>("");
int vis = 1;
if (!PyArg_ParseTuple(args, "esi", "utf-8", &Name, &vis))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
- if (strlen(Name) == 0)
- {
- PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot have an empty layer name.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
+ if (strlen(Name) == 0)
+ {
+ PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot have an empty layer name.","python error").toLocal8Bit().constData());
+ return nullptr;
}
bool found = false;
for (int lam=0; lam < ScCore->primaryMainWindow()->doc->Layers.count(); ++lam)
@@ -362,7 +362,7 @@
if (!found)
{
PyErr_SetString(NotFoundError, QObject::tr("Layer not found.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
// Py_INCREF(Py_None);
// return Py_None;
@@ -374,13 +374,13 @@
char *Name = const_cast<char*>("");
int vis = 1;
if (!PyArg_ParseTuple(args, "esi", "utf-8", &Name, &vis))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
- if (strlen(Name) == 0)
- {
- PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot have an empty layer name.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
+ if (strlen(Name) == 0)
+ {
+ PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot have an empty layer name.","python error").toLocal8Bit().constData());
+ return nullptr;
}
bool found = false;
for (int lam=0; lam < ScCore->primaryMainWindow()->doc->Layers.count(); ++lam)
@@ -395,7 +395,7 @@
if (!found)
{
PyErr_SetString(NotFoundError, QObject::tr("Layer not found.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
// Py_INCREF(Py_None);
// return Py_None;
@@ -407,13 +407,13 @@
char *Name = const_cast<char*>("");
int vis = 0;
if (!PyArg_ParseTuple(args, "esi", "utf-8", &Name, &vis))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
if (strlen(Name) == 0)
{
PyErr_SetString(PyExc_ValueError, QString("Cannot have an empty layer name").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
bool found = false;
for (int lam=0; lam < ScCore->primaryMainWindow()->doc->Layers.count(); ++lam)
@@ -428,7 +428,7 @@
if (!found)
{
PyErr_SetString(NotFoundError, QObject::tr("Layer not found.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
// Py_INCREF(Py_None);
// return Py_None;
@@ -440,13 +440,13 @@
char *Name = const_cast<char*>("");
double vis = 1.0;
if (!PyArg_ParseTuple(args, "esd", "utf-8", &Name, &vis))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
if (strlen(Name) == 0)
{
PyErr_SetString(PyExc_ValueError, QString("Cannot have an empty layer name").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
bool found = false;
for (int lam=0; lam < ScCore->primaryMainWindow()->doc->Layers.count(); ++lam)
@@ -461,7 +461,7 @@
if (!found)
{
PyErr_SetString(NotFoundError, QObject::tr("Layer not found.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
// Py_INCREF(Py_None);
// return Py_None;
@@ -472,13 +472,13 @@
{
char *Name = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "es", "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
- if (strlen(Name) == 0)
- {
- PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot have an empty layer name.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
+ if (strlen(Name) == 0)
+ {
+ PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot have an empty layer name.","python error").toLocal8Bit().constData());
+ return nullptr;
}
int i = 0;
bool found = false;
@@ -494,7 +494,7 @@
if (!found)
{
PyErr_SetString(NotFoundError, QObject::tr("Layer not found.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
return PyInt_FromLong(static_cast<long>(i));
}
@@ -503,13 +503,13 @@
{
char *Name = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "es", "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
- if (strlen(Name) == 0)
- {
- PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot have an empty layer name.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
+ if (strlen(Name) == 0)
+ {
+ PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot have an empty layer name.","python error").toLocal8Bit().constData());
+ return nullptr;
}
int i = 0;
bool found = false;
@@ -525,7 +525,7 @@
if (!found)
{
PyErr_SetString(NotFoundError, QObject::tr("Layer not found.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
return PyInt_FromLong(static_cast<long>(i));
}
@@ -534,13 +534,13 @@
{
char *Name = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "es", "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
- if (strlen(Name) == 0)
- {
- PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot have an empty layer name.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
+ if (strlen(Name) == 0)
+ {
+ PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot have an empty layer name.","python error").toLocal8Bit().constData());
+ return nullptr;
}
int i = 0;
bool found = false;
@@ -556,7 +556,7 @@
if (!found)
{
PyErr_SetString(NotFoundError, QObject::tr("Layer not found.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
return PyInt_FromLong(static_cast<long>(i));
}
@@ -565,13 +565,13 @@
{
char *Name = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "es", "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
- if (strlen(Name) == 0)
- {
- PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot have an empty layer name.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
+ if (strlen(Name) == 0)
+ {
+ PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot have an empty layer name.","python error").toLocal8Bit().constData());
+ return nullptr;
}
int i = 0;
bool found = false;
@@ -587,7 +587,7 @@
if (!found)
{
PyErr_SetString(NotFoundError, QObject::tr("Layer not found.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
return PyInt_FromLong(static_cast<long>(i));
}
@@ -596,13 +596,13 @@
{
char *Name = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "es", "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
- if (strlen(Name) == 0)
- {
- PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot have an empty layer name.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
+ if (strlen(Name) == 0)
+ {
+ PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot have an empty layer name.","python error").toLocal8Bit().constData());
+ return nullptr;
}
int i = 0;
bool found = false;
@@ -618,7 +618,7 @@
if (!found)
{
PyErr_SetString(NotFoundError, QObject::tr("Layer not found.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
return PyInt_FromLong(static_cast<long>(i));
}
@@ -627,13 +627,13 @@
{
char *Name = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "es", "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
- if (strlen(Name) == 0)
- {
- PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot have an empty layer name.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
+ if (strlen(Name) == 0)
+ {
+ PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot have an empty layer name.","python error").toLocal8Bit().constData());
+ return nullptr;
}
int i = 0;
bool found = false;
@@ -649,7 +649,7 @@
if (!found)
{
PyErr_SetString(NotFoundError, QObject::tr("Layer not found.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
return PyInt_FromLong(static_cast<long>(i));
}
@@ -658,13 +658,13 @@
{
char *Name = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "es", "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
- if (strlen(Name) == 0)
- {
- PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot have an empty layer name.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
+ if (strlen(Name) == 0)
+ {
+ PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot have an empty layer name.","python error").toLocal8Bit().constData());
+ return nullptr;
}
double i = 1.0;
bool found = false;
@@ -680,7 +680,7 @@
if (!found)
{
PyErr_SetString(NotFoundError, QObject::tr("Layer not found.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
return PyFloat_FromDouble(i);
}
@@ -690,18 +690,18 @@
//FIXME: Use the docs remove layer code
char *Name = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "es", "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
- if (strlen(Name) == 0)
- {
- PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot have an empty layer name.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
+ if (strlen(Name) == 0)
+ {
+ PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot have an empty layer name.","python error").toLocal8Bit().constData());
+ return nullptr;
}
if (ScCore->primaryMainWindow()->doc->Layers.count() == 1)
{
PyErr_SetString(ScribusException, QObject::tr("Cannot remove the last layer.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
bool found = false;
for (int lam=0; lam < ScCore->primaryMainWindow()->doc->Layers.count(); ++lam)
@@ -727,7 +727,7 @@
if (!found)
{
PyErr_SetString(NotFoundError, QObject::tr("Layer not found.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
// Py_INCREF(Py_None);
// return Py_None;
@@ -738,13 +738,13 @@
{
char *Name = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "es", "utf-8", &Name))
- return NULL;
+ return nullptr;
if (!checkHaveDocument())
- return NULL;
+ return nullptr;
if (strlen(Name) == 0)
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot create layer without a name.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
ScCore->primaryMainWindow()->doc->addLayer(QString::fromUtf8(Name), true);
ScCore->primaryMainWindow()->changeLayer(ScCore->primaryMainWindow()->doc->activeLayer());
@@ -782,15 +782,15 @@
{
char* file;
if(!checkHaveDocument())
- return NULL;
+ return nullptr;
if (!PyArg_ParseTuple(args, const_cast<char*>("es"), "utf-8", &file))
- return NULL;
+ return nullptr;
PDFOptionsIO io(ScCore->primaryMainWindow()->doc->pdfOptions());
if (!io.writeTo(file))
{
PyErr_SetString(ScribusException, io.lastError().toUtf8());
- return NULL;
+ return nullptr;
}
Py_RETURN_NONE;
}
@@ -799,15 +799,15 @@
{
char* file;
if(!checkHaveDocument())
- return NULL;
+ return nullptr;
if (!PyArg_ParseTuple(args, const_cast<char*>("es"), "utf-8", &file))
- return NULL;
+ return nullptr;
PDFOptionsIO io(ScCore->primaryMainWindow()->doc->pdfOptions());
if (!io.readFrom(file))
{
PyErr_SetString(ScribusException, io.lastError().toUtf8());
- return NULL;
+ return nullptr;
}
Py_RETURN_NONE;
}
Modified: trunk/Scribus/scribus/plugins/scriptplugin/cmdobj.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22537&path=/trunk/Scribus/scribus/plugins/scriptplugin/cmdobj.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/cmdobj.cpp (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/cmdobj.cpp Sat May 12 20:34:43 2018
@@ -23,13 +23,13 @@
char *Name = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "dddd|es", &x, &y, &w, &h, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
// if (ItemExists(QString::fromUtf8(Name)))
// {
// PyErr_SetString(NameExistsError, QObject::tr("An object with the requested name already exists.","python error"));
-// return NULL;
+// return nullptr;
// }
int i = ScCore->primaryMainWindow()->doc->itemAdd(PageItem::Polygon, PageItem::Rectangle,
pageUnitXToDocX(x), pageUnitYToDocY(y),
@@ -52,9 +52,9 @@
double x, y, w, h;
char *Name = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "dddd|es", &x, &y, &w, &h, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
int i = ScCore->primaryMainWindow()->doc->itemAdd(PageItem::Polygon, PageItem::Ellipse,
pageUnitXToDocX(x),
pageUnitYToDocY(y),
@@ -78,9 +78,9 @@
double x, y, w, h;
char *Name = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "dddd|es", &x, &y, &w, &h, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
int i = ScCore->primaryMainWindow()->doc->itemAdd(PageItem::ImageFrame, PageItem::Unspecified,
pageUnitXToDocX(x),
pageUnitYToDocY(y),
@@ -103,9 +103,9 @@
double x, y, w, h;
char *Name = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "dddd|es", &x, &y, &w, &h, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
int i = ScCore->primaryMainWindow()->doc->itemAdd(PageItem::TextFrame, PageItem::Unspecified,
pageUnitXToDocX(x),
pageUnitYToDocY(y),
@@ -128,13 +128,13 @@
int numRows, numColumns;
char *Name = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "ddddii|es", &x, &y, &w, &h, &numRows, &numColumns, "utf-8", &Name))
- return NULL;
+ return nullptr;
if (!checkHaveDocument())
- return NULL;
+ return nullptr;
if (numRows < 1 || numColumns < 1)
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Both numRows and numColumns must be greater than 0.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
int i = ScCore->primaryMainWindow()->doc->itemAdd(PageItem::Table, PageItem::Unspecified,
pageUnitXToDocX(x),
@@ -163,9 +163,9 @@
double x, y, w, h;
char *Name = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "dddd|es", &x, &y, &w, &h, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
x = pageUnitXToDocX(x);
y = pageUnitYToDocY(y);
w = pageUnitXToDocX(w);
@@ -175,7 +175,7 @@
// PyErr_SetString(NameExistsError,
// QObject::tr("An object with the requested name already exists.",
// "python error"));
-// return NULL;
+// return nullptr;
// }
int i = ScCore->primaryMainWindow()->doc->itemAdd(PageItem::Line, PageItem::Unspecified,
x, y, w, h,
@@ -223,26 +223,26 @@
{
char *Name = const_cast<char*>("");
PyObject *il;
- // FIXME: PyList_Check failing will cause the function to return NULL w/o an exception. Separarate out the check.
+ // FIXME: PyList_Check failing will cause the function to return nullptr w/o an exception. Separarate out the check.
if ((!PyArg_ParseTuple(args, "O|es", &il, "utf-8", &Name)) || (!PyList_Check(il)))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
int len = PyList_Size(il);
if (len < 4)
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Point list must contain at least two points (four values).","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
if ((len % 2) != 0)
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Point list must contain an even number of values.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
// if (ItemExists(QString::fromUtf8(Name)))
// {
// PyErr_SetString(NameExistsError, QObject::tr("An object with the requested name already exists.","python error").toLocal8Bit().constData());
-// return NULL;
+// return nullptr;
// }
double x, y, w, h;
int i = 0;
@@ -300,26 +300,26 @@
{
char *Name = const_cast<char*>("");
PyObject *il;
- // FIXME: PyList_Check failing will cause the function to return NULL w/o an exception. Separarate out the check.
+ // FIXME: PyList_Check failing will cause the function to return nullptr w/o an exception. Separarate out the check.
if ((!PyArg_ParseTuple(args, "O|es", &il, "utf-8", &Name)) || (!PyList_Check(il)))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
int len = PyList_Size(il);
if (len < 6)
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Point list must contain at least three points (six values).","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
if ((len % 2) != 0)
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Point list must contain an even number of values.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
// if (ItemExists(QString::fromUtf8(Name)))
// {
// PyErr_SetString(NameExistsError, QObject::tr("An object with the requested name already exists.","python error").toLocal8Bit().constData());
-// return NULL;
+// return nullptr;
// }
double x, y, w, h;
int i = 0;
@@ -381,26 +381,26 @@
{
char *Name = const_cast<char*>("");
PyObject *il;
- // FIXME: PyList_Check failing will cause the function to return NULL w/o an exception. Separarate out the check.
+ // FIXME: PyList_Check failing will cause the function to return nullptr w/o an exception. Separarate out the check.
if ((!PyArg_ParseTuple(args, "O|es", &il, "utf-8", &Name)) || (!PyList_Check(il)))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
int len = PyList_Size(il);
if (len < 8)
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Point list must contain at least four points (eight values).","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
if ((len % 6) != 0)
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Point list must have a multiple of six values.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
// if (ItemExists(QString::fromUtf8(Name)))
// {
// PyErr_SetString(NameExistsError, QObject::tr("An object with the requested name already exists.","python error").toLocal8Bit().constData());
-// return NULL;
+// return nullptr;
// }
double x, y, w, h, kx, ky, kx2, ky2;
int i = 0;
@@ -478,22 +478,22 @@
char *TextB = const_cast<char*>("");
char *PolyB = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "ddeses|es", &x, &y, "utf-8", &TextB, "utf-8", &PolyB, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
// if (ItemExists(QString::fromUtf8(Name)))
// {
// PyErr_SetString(NameExistsError, QObject::tr("An object with the requested name already exists.","python error"));
-// return NULL;
+// return nullptr;
// }
//FIXME: Why use GetItem not GetUniqueItem? Maybe use GetUniqueItem and use the exceptions
// its sets for us?
PageItem *i = GetItem(QString::fromUtf8(TextB));
PageItem *ii = GetItem(QString::fromUtf8(PolyB));
- if ((i == NULL) || (ii == NULL))
+ if ((i == nullptr) || (ii == nullptr))
{
PyErr_SetString(NotFoundError, QObject::tr("Object not found.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
ScCore->primaryMainWindow()->doc->m_Selection->clear();
ScCore->primaryMainWindow()->doc->m_Selection->addItem(i);
@@ -516,12 +516,12 @@
{
char *Name = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "|es", "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
- if (i == NULL)
- return NULL;
+ if (i == nullptr)
+ return nullptr;
ScCore->primaryMainWindow()->doc->m_Selection->clear();
ScCore->primaryMainWindow()->doc->m_Selection->addItem(i);
ScCore->primaryMainWindow()->doc->itemSelection_DeleteItem();
@@ -539,12 +539,12 @@
int state = -1;
if (!PyArg_ParseTuple(args, "es|i", "utf-8", &name, &state))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
PageItem *i = GetUniqueItem(QString::fromUtf8(name));
- if (i == NULL)
- return NULL;
+ if (i == nullptr)
+ return nullptr;
if (state == -1)
{
if (i->textFlowAroundObject())
@@ -572,9 +572,9 @@
{
char* name = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "|es", "utf-8", &name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
if (ItemExists(QString::fromUtf8(name)))
return PyBool_FromLong(static_cast<long>(true));
return PyBool_FromLong(static_cast<long>(false));
@@ -590,16 +590,16 @@
char *style = const_cast<char*>("");
char *name = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "es|es", "utf-8", &style, "utf-8", &name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
PageItem *item = GetUniqueItem(QString::fromUtf8(name));
- if (item == NULL)
- return NULL;
+ if (item == nullptr)
+ return nullptr;
if ((item->itemType() != PageItem::TextFrame) && (item->itemType() != PageItem::PathText))
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set style on a non-text frame.", "python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
// First, find the style number associated with the requested style
@@ -624,7 +624,7 @@
if (!found) {
// whoops, the user specified an invalid style, complain loudly.
PyErr_SetString(NotFoundError, QObject::tr("Style not found.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
// for current item only
if (currentDoc->m_Selection->count() == 0 || (strlen(name) > 0))
@@ -674,16 +674,16 @@
char *style = const_cast<char*>("");
char *name = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "es|es", "utf-8", &style, "utf-8", &name))
- return NULL;
+ return nullptr;
if (!checkHaveDocument())
- return NULL;
+ return nullptr;
PageItem *item = GetUniqueItem(QString::fromUtf8(name));
- if (item == NULL)
- return NULL;
+ if (item == nullptr)
+ return nullptr;
if ((item->itemType() != PageItem::TextFrame) && (item->itemType() != PageItem::PathText))
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set character style on a non-text frame.", "python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
// First, find the style number associated with the requested style
@@ -708,7 +708,7 @@
if (!found) {
// whoops, the user specified an invalid style, complain loudly.
PyErr_SetString(NotFoundError, QObject::tr("Character style not found.", "python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
// for current item only
if (currentDoc->m_Selection->count() == 0 || (strlen(name) > 0))
@@ -756,14 +756,14 @@
{
PyObject *styleList;
if(!checkHaveDocument())
- return NULL;
+ return nullptr;
styleList = PyList_New(0);
for (int i=0; i < ScCore->primaryMainWindow()->doc->paragraphStyles().count(); ++i)
{
if (PyList_Append(styleList, PyString_FromString(ScCore->primaryMainWindow()->doc->paragraphStyles()[i].name().toUtf8())))
{
// An exception will have already been set by PyList_Append apparently.
- return NULL;
+ return nullptr;
}
}
return styleList;
@@ -773,14 +773,14 @@
{
PyObject *charStyleList;
if(!checkHaveDocument())
- return NULL;
+ return nullptr;
charStyleList = PyList_New(0);
for (int i=0; i < ScCore->primaryMainWindow()->doc->charStyles().count(); ++i)
{
if (PyList_Append(charStyleList, PyString_FromString(ScCore->primaryMainWindow()->doc->charStyles()[i].name().toUtf8())))
{
// An exception will have already been set by PyList_Append apparently.
- return NULL;
+ return nullptr;
}
}
return charStyleList;
@@ -790,19 +790,19 @@
{
char* name = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "|es", "utf-8", &name)) {
- return NULL;
+ return nullptr;
}
if(!checkHaveDocument()) {
- return NULL;
+ return nullptr;
}
// Is there a special name given? Yes -> add this to selection
PageItem *i = GetUniqueItem(QString::fromUtf8(name));
- if (i != NULL) {
+ if (i != nullptr) {
ScCore->primaryMainWindow()->doc->m_Selection->clear();
ScCore->primaryMainWindow()->doc->m_Selection->addItem(i);
}
else
- return NULL;
+ return nullptr;
// do the duplicate
ScCore->primaryMainWindow()->slotEditCopy();
ScCore->primaryMainWindow()->slotEditPaste();
@@ -815,19 +815,19 @@
{
char* name = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "|es", "utf-8", &name)) {
- return NULL;
+ return nullptr;
}
if(!checkHaveDocument()) {
- return NULL;
+ return nullptr;
}
// Is there a special name given? Yes -> add this to selection
PageItem *i = GetUniqueItem(QString::fromUtf8(name));
- if (i != NULL) {
+ if (i != nullptr) {
ScCore->primaryMainWindow()->doc->m_Selection->clear();
ScCore->primaryMainWindow()->doc->m_Selection->addItem(i);
}
else
- return NULL;
+ return nullptr;
// do the copy
ScCore->primaryMainWindow()->slotEditCopy();
// Py_INCREF(Py_None);
@@ -839,10 +839,10 @@
{
char* name = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "|es", "utf-8", &name)) {
- return NULL;
+ return nullptr;
}
if(!checkHaveDocument()) {
- return NULL;
+ return nullptr;
}
// do the paste
Modified: trunk/Scribus/scribus/plugins/scriptplugin/cmdpage.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22537&path=/trunk/Scribus/scribus/plugins/scriptplugin/cmdpage.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/cmdpage.cpp (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/cmdpage.cpp Sat May 12 20:34:43 2018
@@ -17,14 +17,14 @@
PyObject *scribus_actualpage(PyObject* /* self */)
{
if(!checkHaveDocument())
- return NULL;
+ return nullptr;
return PyInt_FromLong(static_cast<long>(ScCore->primaryMainWindow()->doc->currentPageNumber() + 1));
}
PyObject *scribus_redraw(PyObject* /* self */)
{
if(!checkHaveDocument())
- return NULL;
+ return nullptr;
ScCore->primaryMainWindow()->view->DrawNew();
qApp->processEvents();
// Py_INCREF(Py_None);
@@ -36,14 +36,14 @@
{
int e;
if (!PyArg_ParseTuple(args, "i", &e))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
e--;
if ((e < 0) || (e > static_cast<int>(ScCore->primaryMainWindow()->doc->Pages->count())-1))
{
PyErr_SetString(PyExc_IndexError, QObject::tr("Page number out of range.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
return PyInt_FromLong(static_cast<long>(ScCore->primaryMainWindow()->doc->locationOfPage(e)));
}
@@ -52,9 +52,9 @@
{
char *Name;
if (!PyArg_ParseTuple(args, "es", "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
QString epsError;
bool ret = ScCore->primaryMainWindow()->DoSaveAsEps(QString::fromUtf8(Name), epsError);
if (!ret)
@@ -63,7 +63,7 @@
if (!epsError.isEmpty())
message += QString("\n%1").arg(epsError);
PyErr_SetString(ScribusException, message.toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
// Py_INCREF(Py_True); // return True not None for backward compat
// return Py_True;
@@ -75,14 +75,14 @@
{
int e;
if (!PyArg_ParseTuple(args, "i", &e))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
e--;
if ((e < 0) || (e > static_cast<int>(ScCore->primaryMainWindow()->doc->Pages->count())-1))
{
PyErr_SetString(PyExc_IndexError, QObject::tr("Page number out of range.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
ScCore->primaryMainWindow()->deletePage2(e);
// Py_INCREF(Py_None);
@@ -94,14 +94,14 @@
{
int e;
if (!PyArg_ParseTuple(args, "i", &e))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
e--;
if ((e < 0) || (e > static_cast<int>(ScCore->primaryMainWindow()->doc->Pages->count())-1))
{
PyErr_SetString(PyExc_IndexError, QObject::tr("Page number out of range.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
ScCore->primaryMainWindow()->view->GotoPage(e);
// Py_INCREF(Py_None);
@@ -115,9 +115,9 @@
char *name = const_cast<char*>("");
QString qName(CommonStrings::trMasterPageNormal);
if (!PyArg_ParseTuple(args, "i|es", &e, "utf-8", &name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
int loc = (e > -1) ? e : ScCore->primaryMainWindow()->doc->Pages->count();
if (ScCore->primaryMainWindow()->doc->pageSets()[ScCore->primaryMainWindow()->doc->pagePositioning()].Columns != 1)
@@ -141,7 +141,7 @@
if (!ScCore->primaryMainWindow()->doc->MasterNames.contains(qName))
{
PyErr_SetString(PyExc_IndexError, QObject::tr("Given master page name does not match any existing.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
if (e < 0)
ScCore->primaryMainWindow()->slotNewPageP(loc, qName);
@@ -151,7 +151,7 @@
if ((e < 0) || (e > static_cast<int>(loc - 1)))
{
PyErr_SetString(PyExc_IndexError, QObject::tr("Page number out of range.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
ScCore->primaryMainWindow()->slotNewPageP(e, qName);
}
@@ -163,14 +163,14 @@
PyObject *scribus_pagecount(PyObject* /* self */)
{
if(!checkHaveDocument())
- return NULL;
+ return nullptr;
return PyInt_FromLong(static_cast<long>(ScCore->primaryMainWindow()->doc->Pages->count()));
}
PyObject *scribus_pagedimension(PyObject* /* self */)
{
if(!checkHaveDocument())
- return NULL;
+ return nullptr;
PyObject *t;
t = Py_BuildValue(
"(dd)",
@@ -184,14 +184,14 @@
{
int e;
if (!PyArg_ParseTuple(args, "i", &e))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
e--;
if ((e < 0) || (e > static_cast<int>(ScCore->primaryMainWindow()->doc->Pages->count())-1))
{
PyErr_SetString(PyExc_IndexError, QObject::tr("Page number out of range.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
PyObject *t;
t = Py_BuildValue(
@@ -206,16 +206,16 @@
{
int e;
if (!PyArg_ParseTuple(args, "i", &e))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
e--;
if ((e < 0) || (e > static_cast<int>(ScCore->primaryMainWindow()->doc->Pages->count())-1))
{
PyErr_SetString(PyExc_IndexError, QObject::tr("Page number out of range.","python error").toLocal8Bit().constData());
- return NULL;
- }
- PyObject *margins = NULL;
+ return nullptr;
+ }
+ PyObject *margins = nullptr;
margins = Py_BuildValue("ffff", PointToValue(ScCore->primaryMainWindow()->doc->Pages->at(e)->Margins.top()),
PointToValue(ScCore->primaryMainWindow()->doc->Pages->at(e)->Margins.left()),
PointToValue(ScCore->primaryMainWindow()->doc->Pages->at(e)->Margins.right()),
@@ -226,7 +226,7 @@
PyObject *scribus_getpageitems(PyObject* /* self */)
{
if(!checkHaveDocument())
- return NULL;
+ return nullptr;
if (ScCore->primaryMainWindow()->doc->Items->count() == 0)
return Py_BuildValue((char*)"[]");
uint counter = 0;
@@ -258,7 +258,7 @@
PyObject *scribus_getHguides(PyObject* /* self */)
{
if(!checkHaveDocument())
- return NULL;
+ return nullptr;
Guides g = ScCore->primaryMainWindow()->doc->currentPage()->guides.horizontals(GuideManagerCore::Standard);
int n = g.count();//ScCore->primaryMainWindow()->doc->currentPage->YGuides.count();
if (n == 0)
@@ -280,13 +280,13 @@
{
PyObject *l;
if (!PyArg_ParseTuple(args, "O", &l))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
if (!PyList_Check(l))
{
PyErr_SetString(PyExc_TypeError, QObject::tr("argument is not list: must be list of float values.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
int i, n;
n = PyList_Size(l);
@@ -297,7 +297,7 @@
if (!PyArg_Parse(PyList_GetItem(l, i), "d", &guide))
{
PyErr_SetString(PyExc_TypeError, QObject::tr("argument contains non-numeric values: must be list of float values.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
ScCore->primaryMainWindow()->doc->currentPage()->guides.addHorizontal(ValueToPoint(guide), GuideManagerCore::Standard);
}
@@ -309,7 +309,7 @@
PyObject *scribus_getVguides(PyObject* /* self */)
{
if(!checkHaveDocument())
- return NULL;
+ return nullptr;
Guides g = ScCore->primaryMainWindow()->doc->currentPage()->guides.verticals(GuideManagerCore::Standard);
int n = g.count();//ScCore->primaryMainWindow()->doc->currentPage->XGuides.count();
if (n == 0)
@@ -331,13 +331,13 @@
{
PyObject *l;
if (!PyArg_ParseTuple(args, "O", &l))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
if (!PyList_Check(l))
{
PyErr_SetString(PyExc_TypeError, QObject::tr("argument is not list: must be list of float values.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
int i, n;
n = PyList_Size(l);
@@ -348,7 +348,7 @@
if (!PyArg_Parse(PyList_GetItem(l, i), "d", &guide))
{
PyErr_SetString(PyExc_TypeError, QObject::tr("argument contains no-numeric values: must be list of float values.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
ScCore->primaryMainWindow()->doc->currentPage()->guides.addVertical(ValueToPoint(guide), GuideManagerCore::Standard);
}
@@ -359,9 +359,9 @@
PyObject *scribus_getpagemargins(PyObject* /* self */)
{
- PyObject *margins = NULL;
- if(!checkHaveDocument())
- return NULL;
+ PyObject *margins = nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
margins = Py_BuildValue("ffff", PointToValue(ScCore->primaryMainWindow()->doc->margins()->top()),
PointToValue(ScCore->primaryMainWindow()->doc->margins()->left()),
PointToValue(ScCore->primaryMainWindow()->doc->margins()->right()),
@@ -418,21 +418,21 @@
*/
PyObject *scribus_importpage(PyObject* /* self */, PyObject* args)
{
- char *doc = NULL;
- PyObject *pages = NULL;
+ char *doc = nullptr;
+ PyObject *pages = nullptr;
int createPageI = 1;
int importWhere = 2;
int importWherePage = 0;
if (!PyArg_ParseTuple(args, "sO|iii", &doc, &pages, &createPageI, &importWhere, &importWherePage))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
if (!PyTuple_Check(pages))
{
PyErr_SetString(PyExc_TypeError, QObject::tr("second argument is not tuple: must be tuple of integer values.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
Py_INCREF(pages);
@@ -445,7 +445,7 @@
{
PyErr_SetString(PyExc_TypeError, QObject::tr("second argument contains non-numeric values: must be list of integer values.","python error").toLocal8Bit().constData());
Py_DECREF(pages);
- return NULL;
+ return nullptr;
}
pageNs.push_back(p);
}
Modified: trunk/Scribus/scribus/plugins/scriptplugin/cmdsetprop.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22537&path=/trunk/Scribus/scribus/plugins/scriptplugin/cmdsetprop.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/cmdsetprop.cpp (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/cmdsetprop.cpp Sat May 12 20:34:43 2018
@@ -16,17 +16,17 @@
char *Color2;
int typ, shade1, shade2;
if (!PyArg_ParseTuple(args, "iesiesi|es", &typ, "utf-8", &Color1, &shade1, "utf-8", &Color2, &shade2, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
if ((shade1 < 0) || (shade1 > 100) || (shade2 < 0) || (shade2 > 100))
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Stop shade out of bounds, must be 0 <= shade <= 100.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
PageItem *currItem = GetUniqueItem(QString::fromUtf8(Name));
- if (currItem == NULL)
- return NULL;
+ if (currItem == nullptr)
+ return nullptr;
QColor tmp;
currItem->fill_gradient.clearStops();
QString c1 = QString::fromUtf8(Color1);
@@ -93,27 +93,27 @@
int shade1;
double rampPoint, opacity;
if (!PyArg_ParseTuple(args, "esidd|es", "utf-8", &Color1, &shade1, &opacity, &rampPoint, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
if ((shade1 < 0) || (shade1 > 100))
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Stop shade out of bounds, must be 0 <= shade <= 100.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
if ((rampPoint < 0.0) || (rampPoint > 1.0))
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Ramp point out of bounds, must be 0 <= rampPoint <= 1.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
if ((opacity < 0.0) || (opacity > 1.0))
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Opacity out of bounds, must be 0 <= transparency <= 1.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
PageItem *currItem = GetUniqueItem(QString::fromUtf8(Name));
- if (currItem == NULL)
- return NULL;
+ if (currItem == nullptr)
+ return nullptr;
QColor tmp;
QString c1 = QString::fromUtf8(Color1);
currItem->SetQColor(&tmp, c1, shade1);
@@ -128,12 +128,12 @@
char *Name = const_cast<char*>("");
char *Color;
if (!PyArg_ParseTuple(args, "es|es", "utf-8", &Color, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
- if (i == NULL)
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
+ PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
+ if (i == nullptr)
+ return nullptr;
i->setFillColor(QString::fromUtf8(Color));
Py_RETURN_NONE;
}
@@ -143,17 +143,17 @@
char *Name = const_cast<char*>("");
double w;
if (!PyArg_ParseTuple(args, "d|es", &w, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
if ((w < 0.0) || (w > 1.0))
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Transparency out of bounds, must be 0 <= transparency <= 1.","python error").toLocal8Bit().constData());
- return NULL;
- }
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
- if (i == NULL)
- return NULL;
+ return nullptr;
+ }
+ PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
+ if (i == nullptr)
+ return nullptr;
i->setFillTransparency(1.0 - w);
Py_RETURN_NONE;
}
@@ -163,17 +163,17 @@
char *Name = const_cast<char*>("");
int w;
if (!PyArg_ParseTuple(args, "i|es", &w, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
if ((w < 0) || (w > 15))
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Blendmode out of bounds, must be 0 <= blendmode <= 15.","python error").toLocal8Bit().constData());
- return NULL;
- }
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
- if (i == NULL)
- return NULL;
+ return nullptr;
+ }
+ PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
+ if (i == nullptr)
+ return nullptr;
i->setFillBlendmode(w);
Py_RETURN_NONE;
}
@@ -183,17 +183,17 @@
char *Name = const_cast<char*>("");
char *Style;
if (!PyArg_ParseTuple(args, "es|es", "utf-8", &Style, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
PageItem *it = GetUniqueItem(QString::fromUtf8(Name));
- if (it == NULL)
- return NULL;
+ if (it == nullptr)
+ return nullptr;
QString qStyle = QString::fromUtf8(Style);
if (! ScCore->primaryMainWindow()->doc->MLineStyles.contains(qStyle))
{
PyErr_SetString(NotFoundError, QObject::tr("Line Style not found.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
it->setCustomLineStyle(qStyle);
@@ -205,12 +205,12 @@
char *Name = const_cast<char*>("");
char *Color;
if (!PyArg_ParseTuple(args, "es|es", "utf-8", &Color, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
PageItem *it = GetUniqueItem(QString::fromUtf8(Name));
- if (it == NULL)
- return NULL;
+ if (it == nullptr)
+ return nullptr;
it->setLineColor(QString::fromUtf8(Color));
Py_RETURN_NONE;
}
@@ -220,17 +220,17 @@
char *Name = const_cast<char*>("");
double w;
if (!PyArg_ParseTuple(args, "d|es", &w, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
if ((w < 0.0) || (w > 1.0))
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Transparency out of bounds, must be 0 <= transparency <= 1.","python error").toLocal8Bit().constData());
- return NULL;
- }
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
- if (i == NULL)
- return NULL;
+ return nullptr;
+ }
+ PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
+ if (i == nullptr)
+ return nullptr;
i->setLineTransparency(1.0 - w);
Py_RETURN_NONE;
}
@@ -240,17 +240,17 @@
char *Name = const_cast<char*>("");
int w;
if (!PyArg_ParseTuple(args, "i|es", &w, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
if ((w < 0) || (w > 15))
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Blendmode out of bounds, must be 0 <= blendmode <= 15.","python error").toLocal8Bit().constData());
- return NULL;
- }
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
- if (i == NULL)
- return NULL;
+ return nullptr;
+ }
+ PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
+ if (i == nullptr)
+ return nullptr;
i->setLineBlendmode(w);
Py_RETURN_NONE;
}
@@ -260,17 +260,17 @@
char *Name = const_cast<char*>("");
double w;
if (!PyArg_ParseTuple(args, "d|es", &w, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
if ((w < 0.0) || (w > 300.0))
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Line width out of bounds, must be 0 <= line_width <= 300.","python error").toLocal8Bit().constData());
- return NULL;
- }
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
- if (i == NULL)
- return NULL;
+ return nullptr;
+ }
+ PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
+ if (i == nullptr)
+ return nullptr;
i->setLineWidth(w);
Py_RETURN_NONE;
}
@@ -280,17 +280,17 @@
char *Name = const_cast<char*>("");
int w;
if (!PyArg_ParseTuple(args, "i|es", &w, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
if ((w < 0) || (w > 100))
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Line shade out of bounds, must be 0 <= shade <= 100.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
PageItem *it = GetUniqueItem(QString::fromUtf8(Name));
- if (it == NULL)
- return NULL;
+ if (it == nullptr)
+ return nullptr;
it->setLineShade(w);
Py_RETURN_NONE;
}
@@ -300,17 +300,17 @@
char *Name = const_cast<char*>("");
int w;
if (!PyArg_ParseTuple(args, "i|es", &w, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
if ((w < 0) || (w > 100))
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Fill shade out of bounds, must be 0 <= shade <= 100.","python error").toLocal8Bit().constData());
- return NULL;
- }
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
- if (i == NULL)
- return NULL;
+ return nullptr;
+ }
+ PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
+ if (i == nullptr)
+ return nullptr;
i->setFillShade(w);
Py_RETURN_NONE;
}
@@ -320,12 +320,12 @@
char *Name = const_cast<char*>("");
int w;
if (!PyArg_ParseTuple(args, "i|es", &w, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
- if (i == NULL)
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
+ PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
+ if (i == nullptr)
+ return nullptr;
i->PLineJoin = Qt::PenJoinStyle(w);
Py_RETURN_NONE;
}
@@ -335,12 +335,12 @@
char *Name = const_cast<char*>("");
int w;
if (!PyArg_ParseTuple(args, "i|es", &w, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
- if (i == NULL)
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
+ PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
+ if (i == nullptr)
+ return nullptr;
i->PLineEnd = Qt::PenCapStyle(w);
Py_RETURN_NONE;
}
@@ -350,12 +350,12 @@
char *Name = const_cast<char*>("");
int w;
if (!PyArg_ParseTuple(args, "i|es", &w, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
- if (i == NULL)
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
+ PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
+ if (i == nullptr)
+ return nullptr;
i->PLineArt = Qt::PenStyle(w);
Py_RETURN_NONE;
}
@@ -365,17 +365,17 @@
char *Name = const_cast<char*>("");
int w;
if (!PyArg_ParseTuple(args, "i|es", &w, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
if (w < 0)
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Corner radius must be a positive number.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
PageItem *currItem = GetUniqueItem(QString::fromUtf8(Name));
- if (currItem == NULL)
- return NULL;
+ if (currItem == nullptr)
+ return nullptr;
// apply rounding
currItem->setCornerRadius(w);
currItem->SetFrameRound();
@@ -387,18 +387,18 @@
PyObject *scribus_setmultiline(PyObject* /* self */, PyObject* args)
{
char *Name = const_cast<char*>("");
- char *Style = NULL;
+ char *Style = nullptr;
if (!PyArg_ParseTuple(args, "es|es", "utf-8", &Style, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
PageItem *currItem = GetUniqueItem(QString::fromUtf8(Name));
- if (currItem == NULL)
- return NULL;
+ if (currItem == nullptr)
+ return nullptr;
if (!ScCore->primaryMainWindow()->doc->MLineStyles.contains(QString::fromUtf8(Style)))
{
PyErr_SetString(NotFoundError, QObject::tr("Line style not found.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
currItem->NamedLStyle = QString::fromUtf8(Style);
Py_RETURN_NONE;
@@ -409,12 +409,12 @@
char *Name = const_cast<char*>("");
char *newName = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "es|es", "utf-8", &newName, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
PageItem *currItem = GetUniqueItem(QString::fromUtf8(Name));
- if (currItem == NULL)
- return NULL;
+ if (currItem == nullptr)
+ return nullptr;
currItem->setItemName(newName);
Py_RETURN_NONE;
}
@@ -422,18 +422,18 @@
PyObject *scribus_setobjectattributes(PyObject* /* self */, PyObject* args)
{
if(!checkHaveDocument())
- return NULL;
+ return nullptr;
char *Name = const_cast<char*>("");
PyObject *attr;
if (!PyArg_ParseTuple(args, "O|es", &attr, "utf-8", &Name))
- return NULL;
+ return nullptr;
PageItem *item = GetUniqueItem(QString::fromUtf8(Name));
- if (item == NULL)
- return NULL;
+ if (item == nullptr)
+ return nullptr;
if (!PyList_Check(attr)) {
PyErr_SetString(PyExc_TypeError, "argument must be list.");
- return NULL;
+ return nullptr;
}
ObjAttrVector attributes;
@@ -442,7 +442,7 @@
PyObject *tmp = PyList_GetItem(attr, i);
if (!PyDict_Check(tmp)) {
PyErr_SetString(PyExc_TypeError, "elemets of 'attr' must be dictionary.");
- return NULL;
+ return nullptr;
}
ObjectAttribute blank;
PyObject *val;
@@ -451,71 +451,71 @@
val = PyDict_GetItemString(tmp, "Name");
if (!val) {
PyErr_SetString(PyExc_TypeError, "attribute does not have 'Name' key.");
- return NULL;
- }
- data = PyString_AsString(val);
- if (!data)
- return NULL;
+ return nullptr;
+ }
+ data = PyString_AsString(val);
+ if (!data)
+ return nullptr;
blank.name = QString(data);
val = PyDict_GetItemString(tmp, "Type");
if (!val) {
PyErr_SetString(PyExc_TypeError, "attribute does not have 'Type' key.");
- return NULL;
- }
- data = PyString_AsString(val);
- if (!data)
- return NULL;
+ return nullptr;
+ }
+ data = PyString_AsString(val);
+ if (!data)
+ return nullptr;
blank.type = QString(data);
val = PyDict_GetItemString(tmp, "Value");
if (!val) {
PyErr_SetString(PyExc_TypeError, "attribute does not have 'Value' key.");
- return NULL;
- }
- data = PyString_AsString(val);
- if (!data)
- return NULL;
+ return nullptr;
+ }
+ data = PyString_AsString(val);
+ if (!data)
+ return nullptr;
blank.value = QString(data);
val = PyDict_GetItemString(tmp, "Parameter");
if (!val) {
PyErr_SetString(PyExc_TypeError, "attribute does not have 'Parameter' key.");
- return NULL;
- }
- data = PyString_AsString(val);
- if (!data)
- return NULL;
+ return nullptr;
+ }
+ data = PyString_AsString(val);
+ if (!data)
+ return nullptr;
blank.parameter = QString(data);
val = PyDict_GetItemString(tmp, "Relationship");
if (!val) {
PyErr_SetString(PyExc_TypeError, "attribute does not have 'Relationship' key.");
- return NULL;
- }
- data = PyString_AsString(val);
- if (!data)
- return NULL;
+ return nullptr;
+ }
+ data = PyString_AsString(val);
+ if (!data)
+ return nullptr;
blank.relationship = QString(data);
val = PyDict_GetItemString(tmp, "RelationshipTo");
if (!val) {
PyErr_SetString(PyExc_TypeError, "attribute does not have 'RelationshipTo' key.");
- return NULL;
- }
- data = PyString_AsString(val);
- if (!data)
- return NULL;
+ return nullptr;
+ }
+ data = PyString_AsString(val);
+ if (!data)
+ return nullptr;
blank.relationshipto = QString(data);
val = PyDict_GetItemString(tmp, "AutoAddTo");
if (!val) {
PyErr_SetString(PyExc_TypeError, "attribute does not have 'AutoAddTo' key.");
- return NULL;
- }
- data = PyString_AsString(val);
- if (!data)
- return NULL;
+ return nullptr;
+ }
+ data = PyString_AsString(val);
+ if (!data)
+ return nullptr;
blank.autoaddto = QString(data);
attributes.append(blank);
Modified: trunk/Scribus/scribus/plugins/scriptplugin/cmdtable.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22537&path=/trunk/Scribus/scribus/plugins/scriptplugin/cmdtable.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/cmdtable.cpp (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/cmdtable.cpp Sat May 12 20:34:43 2018
@@ -15,18 +15,18 @@
{
char *Name = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "|es", "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
- if (i == NULL)
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
+ PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
+ if (i == nullptr)
+ return nullptr;
PageItem_Table *table = i->asTable();
if (!table)
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot get table row count of non-table item.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
return PyInt_FromLong(static_cast<long>(table->rows()));
}
@@ -35,18 +35,18 @@
{
char *Name = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "|es", "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
- if (i == NULL)
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
+ PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
+ if (i == nullptr)
+ return nullptr;
PageItem_Table *table = i->asTable();
if (!table)
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot get table column count of non-table item.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
return PyInt_FromLong(static_cast<long>(table->columns()));
}
@@ -56,27 +56,27 @@
char *Name = const_cast<char*>("");
int index, numRows;
if (!PyArg_ParseTuple(args, "ii|es", &index, &numRows, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
- if (i == NULL)
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
+ PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
+ if (i == nullptr)
+ return nullptr;
PageItem_Table *table = i->asTable();
if (!table)
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot insert rows on a non-table item.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
if (index < 0 || index > table->rows())
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Table row index out of bounds, must be >= 0 and < %1", "python error").arg(table->rows()).toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
if (numRows < 1)
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Table row count out of bounds, must be >= 1", "python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
table->insertRows(index, numRows);
Py_RETURN_NONE;
@@ -87,32 +87,32 @@
char *Name = const_cast<char*>("");
int index, numRows;
if (!PyArg_ParseTuple(args, "ii|es", &index, &numRows, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
- if (i == NULL)
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
+ PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
+ if (i == nullptr)
+ return nullptr;
PageItem_Table *table = i->asTable();
if (!table)
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot remove rows from a non-table item.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
if (index < 0 || index >= table->rows())
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Table row index out of bounds, must be >= 0 and < %1", "python error").arg(table->rows()).toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
if (numRows < 1 || numRows >= table->rows())
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Table row count out of bounds, must be >= 1 and < %1", "python error").arg(table->rows()).toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
if (index + numRows > table->rows())
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Row deletion range out of bounds, index + numRows must be <= %1", "python error").arg(table->rows()).toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
table->removeRows(index, numRows);
Py_RETURN_NONE;
@@ -123,17 +123,17 @@
char *Name = const_cast<char*>("");
int row;
if (!PyArg_ParseTuple(args, "i|es", &row, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
- if (i == NULL)
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
+ PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
+ if (i == nullptr)
+ return nullptr;
PageItem_Table *table = i->asTable();
if (!table)
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot get row height from non-table item.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
return PyFloat_FromDouble(static_cast<double>(table->rowHeight(row)));
}
@@ -144,27 +144,27 @@
int row;
double height;
if (!PyArg_ParseTuple(args, "id|es", &row, &height, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
- if (i == NULL)
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
+ PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
+ if (i == nullptr)
+ return nullptr;
PageItem_Table *table = i->asTable();
if (!table)
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot resize row on a non-table item.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
if (row < 0 || row >= table->rows())
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Table row index out of bounds, must be >= 0 and < %1", "python error").arg(table->rows()).toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
if (height <= 0.0)
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Table row height must be > 0.0", "python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
table->resizeRow(row, height);
Py_RETURN_NONE;
@@ -175,27 +175,27 @@
char *Name = const_cast<char*>("");
int index, numColumns;
if (!PyArg_ParseTuple(args, "ii|es", &index, &numColumns, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
- if (i == NULL)
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
+ PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
+ if (i == nullptr)
+ return nullptr;
PageItem_Table *table = i->asTable();
if (!table)
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot insert columns on a non-table item.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
if (index < 0 || index > table->columns())
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Table column index out of bounds, must be >= 0 and < %1", "python error").arg(table->columns()).toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
if (numColumns < 1)
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Table column count out of bounds, must be >= 1", "python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
table->insertColumns(index, numColumns);
Py_RETURN_NONE;
@@ -206,32 +206,32 @@
char *Name = const_cast<char*>("");
int index, numColumns;
if (!PyArg_ParseTuple(args, "ii|es", &index, &numColumns, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
- if (i == NULL)
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
+ PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
+ if (i == nullptr)
+ return nullptr;
PageItem_Table *table = i->asTable();
if (!table)
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot remove columns from a non-table item.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
if (index < 0 || index >= table->columns())
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Table column index out of bounds, must be >= 0 and < %1", "python error").arg(table->columns()).toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
if (numColumns < 1 || numColumns >= table->columns())
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Table column count out of bounds, must be >= 1 and < %1", "python error").arg(table->columns()).toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
if (index + numColumns > table->columns())
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Column deletion range out of bounds, index + numColumns must be <= %1", "python error").arg(table->columns()).toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
table->removeColumns(index, numColumns);
Py_RETURN_NONE;
@@ -242,17 +242,17 @@
char *Name = const_cast<char*>("");
int column;
if (!PyArg_ParseTuple(args, "i|es", &column, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
- if (i == NULL)
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
+ PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
+ if (i == nullptr)
+ return nullptr;
PageItem_Table *table = i->asTable();
if (!table)
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot get column width from non-table item.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
return PyFloat_FromDouble(static_cast<double>(table->columnWidth(column)));
}
@@ -263,27 +263,27 @@
int column;
double width;
if (!PyArg_ParseTuple(args, "id|es", &column, &width, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
- if (i == NULL)
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
+ PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
+ if (i == nullptr)
+ return nullptr;
PageItem_Table *table = i->asTable();
if (!table)
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot resize column on a non-table item.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
if (column < 0 || column >= table->columns())
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Table column index out of bounds, must be >= 0 and < %1", "python error").arg(table->columns()).toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
if (width <= 0.0)
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Table column width must be > 0.0", "python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
table->resizeColumn(column, width);
Py_RETURN_NONE;
@@ -294,29 +294,29 @@
char *Name = const_cast<char*>("");
int row, column, numRows, numColumns;
if (!PyArg_ParseTuple(args, "iiii|es", &row, &column, &numRows, &numColumns, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
- if (i == NULL)
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
+ PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
+ if (i == nullptr)
+ return nullptr;
PageItem_Table *table = i->asTable();
if (!table)
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot merge cells on a non-table item.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
if (numRows < 1 || numColumns < 1)
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Number of rows and columns must both be > 0.", "python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
if (row < 0 || row >= table->rows() || column < 0 || column >= table->columns() ||
row + numRows - 1 < 0 || row + numRows - 1 >= table->rows() ||
column + numColumns - 1 < 0 || column + numColumns - 1 >= table->columns())
{
PyErr_SetString(PyExc_ValueError, QObject::tr("The area %1,%2 %3x%4 is not inside the table.", "python error").arg(row).arg(column).arg(numColumns).arg(numRows).toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
table->mergeCells(row, column, numRows, numColumns);
Py_RETURN_NONE;
@@ -326,17 +326,17 @@
{
char *Name = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "|es", "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
- if (i == NULL)
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
+ PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
+ if (i == nullptr)
+ return nullptr;
PageItem_Table *table = i->asTable();
if (!table)
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot get table style on a non-table item.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
return PyString_FromString(table->styleName().toUtf8());
}
@@ -346,17 +346,17 @@
char *Name = const_cast<char*>("");
char *style;
if (!PyArg_ParseTuple(args, "es|es", "utf-8", &style, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
- if (i == NULL)
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
+ PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
+ if (i == nullptr)
+ return nullptr;
PageItem_Table *table = i->asTable();
if (!table)
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set table style on a non-table item.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
table->setStyle(QString::fromUtf8(style));
Py_RETURN_NONE;
@@ -366,17 +366,17 @@
{
char *Name = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "|es", "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
- if (i == NULL)
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
+ PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
+ if (i == nullptr)
+ return nullptr;
PageItem_Table *table = i->asTable();
if (!table)
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot get table fill color on a non-table item.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
return PyString_FromString(table->fillColor().toUtf8());
}
@@ -386,17 +386,17 @@
char *Name = const_cast<char*>("");
char *color;
if (!PyArg_ParseTuple(args, "es|es", "utf-8", &color, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
- if (i == NULL)
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
+ PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
+ if (i == nullptr)
+ return nullptr;
PageItem_Table *table = i->asTable();
if (!table)
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set table fill color on a non-table item.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
table->setFillColor(QString::fromUtf8(color));
Py_RETURN_NONE;
@@ -407,17 +407,17 @@
char *Name = const_cast<char*>("");
PyObject* borderLines;
if (!PyArg_ParseTuple(args, "O|es", &borderLines, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
- if (i == NULL)
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
+ PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
+ if (i == nullptr)
+ return nullptr;
PageItem_Table *table = i->asTable();
if (!table)
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set table left border on a non-table item.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
bool ok = false;
@@ -425,7 +425,7 @@
if (ok)
table->setLeftBorder(border);
else
- return NULL;
+ return nullptr;
Py_RETURN_NONE;
}
@@ -435,17 +435,17 @@
char *Name = const_cast<char*>("");
PyObject* borderLines;
if (!PyArg_ParseTuple(args, "O|es", &borderLines, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
- if (i == NULL)
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
+ PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
+ if (i == nullptr)
+ return nullptr;
PageItem_Table *table = i->asTable();
if (!table)
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set table right border on a non-table item.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
bool ok = false;
@@ -453,7 +453,7 @@
if (ok)
table->setRightBorder(border);
else
- return NULL;
+ return nullptr;
Py_RETURN_NONE;
}
@@ -463,17 +463,17 @@
char *Name = const_cast<char*>("");
PyObject* borderLines;
if (!PyArg_ParseTuple(args, "O|es", &borderLines, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
- if (i == NULL)
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
+ PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
+ if (i == nullptr)
+ return nullptr;
PageItem_Table *table = i->asTable();
if (!table)
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set table top border on a non-table item.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
bool ok = false;
@@ -481,7 +481,7 @@
if (ok)
table->setTopBorder(border);
else
- return NULL;
+ return nullptr;
Py_RETURN_NONE;
}
@@ -491,17 +491,17 @@
char *Name = const_cast<char*>("");
PyObject* borderLines;
if (!PyArg_ParseTuple(args, "O|es", &borderLines, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
- if (i == NULL)
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
+ PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
+ if (i == nullptr)
+ return nullptr;
PageItem_Table *table = i->asTable();
if (!table)
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set table bottom border on a non-table item.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
bool ok = false;
@@ -509,7 +509,7 @@
if (ok)
table->setBottomBorder(border);
else
- return NULL;
+ return nullptr;
Py_RETURN_NONE;
}
Modified: trunk/Scribus/scribus/plugins/scriptplugin/cmdtext.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22537&path=/trunk/Scribus/scribus/plugins/scriptplugin/cmdtext.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/cmdtext.cpp (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/cmdtext.cpp Sat May 12 20:34:43 2018
@@ -50,23 +50,23 @@
{
char *Name = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "|es", "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
PageItem *it = GetUniqueItem(QString::fromUtf8(Name));
- if (it == NULL)
- return NULL;
+ if (it == nullptr)
+ return nullptr;
if (!(it->isTextFrame()) && !(it->isPathText()))
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot get font size of non-text frame.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
if (it->HasSel)
{
for (int b = 0; b < it->itemText.length(); b++)
if (it->itemText.selected(b))
return PyFloat_FromDouble(static_cast<double>(it->itemText.charStyle(b).fontSize() / 10.0));
- return NULL;
+ return nullptr;
}
else
return PyFloat_FromDouble(static_cast<double>(it->currentCharStyle().fontSize() / 10.0));
@@ -76,23 +76,23 @@
{
char *Name = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "|es", "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
PageItem *it = GetUniqueItem(QString::fromUtf8(Name));
- if (it == NULL)
- return NULL;
+ if (it == nullptr)
+ return nullptr;
if (!(it->isTextFrame()) && !(it->isPathText()))
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot get font of non-text frame.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
if (it->HasSel)
{
for (int b = 0; b < it->itemText.length(); b++)
if (it->itemText.selected(b))
return PyString_FromString(it->itemText.charStyle(b).font().scName().toUtf8());
- return NULL;
+ return nullptr;
}
else
return PyString_FromString(it->currentCharStyle().font().scName().toUtf8());
@@ -102,16 +102,16 @@
{
char *Name = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "|es", "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
- if (i == NULL)
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
+ PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
+ if (i == nullptr)
+ return nullptr;
if (!(i->isTextFrame()) && !(i->isPathText()))
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot get text size of non-text frame.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
return PyInt_FromLong(static_cast<long>(i->itemText.length()));
}
@@ -120,16 +120,16 @@
{
char *Name = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "|es", "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
- if (i == NULL)
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
+ PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
+ if (i == nullptr)
+ return nullptr;
if (!(i->isTextFrame()) && !(i->isPathText()))
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot get number of lines of non-text frame.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
return PyInt_FromLong(static_cast<long>(i->textLayout.lines()));
}
@@ -138,16 +138,16 @@
{
char *Name = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "|es", "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
- if (i == NULL)
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
+ PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
+ if (i == nullptr)
+ return nullptr;
if (!i->isTextFrame())
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot get column count of non-text frame.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
return PyInt_FromLong(static_cast<long>(i->Cols));
}
@@ -156,23 +156,23 @@
{
char *Name = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "|es", "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
PageItem *it = GetUniqueItem(QString::fromUtf8(Name));
- if (it == NULL)
- return NULL;
+ if (it == nullptr)
+ return nullptr;
if (!(it->isTextFrame()) && !(it->isPathText()))
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot get fontfeatures of non-text frame.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
if (it->HasSel)
{
for (int b = 0; b < it->itemText.length(); b++)
if (it->itemText.selected(b))
return PyString_FromString(it->itemText.charStyle(b).fontFeatures().toUtf8());
- return NULL;
+ return nullptr;
}
else
return PyString_FromString(it->currentCharStyle().fontFeatures().toUtf8());
@@ -182,16 +182,16 @@
{
char *Name = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "|es", "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
- if (i == NULL)
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
+ PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
+ if (i == nullptr)
+ return nullptr;
if (!i->asTextFrame())
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot get line space of non-text frame.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
return PyFloat_FromDouble(static_cast<double>(i->currentStyle().lineSpacing()));
}
@@ -200,16 +200,16 @@
{
char *Name = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "|es", "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
- if (i == NULL)
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
+ PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
+ if (i == nullptr)
+ return nullptr;
if (!i->isTextFrame())
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot get text distances of non-text frame.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
return Py_BuildValue("(dddd)",
PointToValue(i->textToFrameDistLeft()),
@@ -222,16 +222,16 @@
{
char *Name = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "|es", "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
- if (i == NULL)
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
+ PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
+ if (i == nullptr)
+ return nullptr;
if (!i->isTextFrame())
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot get column gap of non-text frame.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
return PyFloat_FromDouble(PointToValue(static_cast<double>(i->ColGap)));
}
@@ -240,17 +240,17 @@
{
char *Name = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "|es", "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
QString text = "";
PageItem *it = GetUniqueItem(QString::fromUtf8(Name));
- if (it == NULL)
- return NULL;
+ if (it == nullptr)
+ return nullptr;
if (!(it->isTextFrame()) && !(it->isPathText()))
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot get text of non-text frame.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
for (int a = it->firstInFrame(); a <= it->lastInFrame(); ++a)
{
@@ -271,17 +271,17 @@
{
char *Name = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "|es", "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
QString text = "";
PageItem *it = GetUniqueItem(QString::fromUtf8(Name));
- if (it == NULL)
- return NULL;
+ if (it == nullptr)
+ return nullptr;
if (!(it->isTextFrame()) && !(it->isPathText()))
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot get text of non-text frame.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
// collect all chars from a storytext
@@ -305,16 +305,16 @@
char *Name = const_cast<char*>("");
char *Text;
if (!PyArg_ParseTuple(args, "es|es", "utf-8", &Text, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
PageItem *currItem = GetUniqueItem(QString::fromUtf8(Name));
- if (currItem == NULL)
- return NULL;
+ if (currItem == nullptr)
+ return nullptr;
if (!(currItem->isTextFrame()) && !(currItem->isPathText()))
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set text of non-text frame.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
QString Daten = QString::fromUtf8(Text);
Daten.replace("\r\n", SpecialChars::PARSEP);
@@ -335,16 +335,16 @@
char *Text;
int pos;
if (!PyArg_ParseTuple(args, "esi|es", "utf-8", &Text, &pos, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
PageItem *it = GetUniqueItem(QString::fromUtf8(Name));
- if (it == NULL)
- return NULL;
+ if (it == nullptr)
+ return nullptr;
if (!(it->isTextFrame()) && !(it->isPathText()))
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot insert text into non-text frame.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
QString textData = QString::fromUtf8(Text);
textData.replace("\r\n", SpecialChars::PARSEP);
@@ -353,7 +353,7 @@
if ((pos < -1) || (pos > static_cast<int>(it->itemText.length())))
{
PyErr_SetString(PyExc_IndexError, QObject::tr("Insert index out of bounds.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
if (pos == -1)
pos = it->itemText.length();
@@ -373,23 +373,23 @@
char *file;
if (!PyArg_ParseTuple(args, "es|es", "utf-8", &file, "utf-8", &name)) {
- return NULL;
+ return nullptr;
}
if(!checkHaveDocument()) {
- return NULL;
+ return nullptr;
}
PageItem *it = GetUniqueItem(QString::fromUtf8(name));
- if (it == NULL) {
- return NULL;
+ if (it == nullptr) {
+ return nullptr;
}
if (!(it->isTextFrame()) && !(it->isPathText())) {
PyErr_SetString(WrongFrameTypeError,
QObject::tr("Cannot insert text into non-text frame.",
"python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
QString fileName = QString::fromUtf8(file);
@@ -406,21 +406,21 @@
char *Name = const_cast<char*>("");
int alignment;
if (!PyArg_ParseTuple(args, "i|es", &alignment, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
if ((alignment > 4) || (alignment < 0))
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Alignment out of range. Use one of the scribus.ALIGN* constants.","python error").toLocal8Bit().constData());
- return NULL;
- }
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
- if (i == NULL)
- return NULL;
+ return nullptr;
+ }
+ PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
+ if (i == nullptr)
+ return nullptr;
if (!i->asTextFrame())
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set text alignment on a non-text frame.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
int Apm = ScCore->primaryMainWindow()->doc->appMode;
ScCore->primaryMainWindow()->doc->m_Selection->clear();
@@ -440,21 +440,21 @@
char *Name = const_cast<char*>("");
int direction;
if (!PyArg_ParseTuple(args, "i|es", &direction, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
if ((direction > 1) || (direction < 0))
{
PyErr_SetString(PyExc_ValueError, QObject::tr("direction out of range. Use one of the scribus.DIRECTION* constants.","python error").toLocal8Bit().constData());
- return NULL;
- }
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
- if (i == NULL)
- return NULL;
+ return nullptr;
+ }
+ PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
+ if (i == nullptr)
+ return nullptr;
if (!i->asTextFrame())
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set text direction on a non-text frame.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
int Apm = ScCore->primaryMainWindow()->doc->appMode;
ScCore->primaryMainWindow()->doc->m_Selection->clear();
@@ -473,22 +473,22 @@
char *Name = const_cast<char*>("");
double size;
if (!PyArg_ParseTuple(args, "d|es", &size, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
if ((size > 512) || (size < 1))
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Font size out of bounds - must be 1 <= size <= 512.","python error").toLocal8Bit().constData());
- return NULL;
- }
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
- if (i == NULL)
- return NULL;
+ return nullptr;
+ }
+ PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
+ if (i == nullptr)
+ return nullptr;
if (!i->isTextFrame())
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set font size on a non-text frame.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
int Apm = ScCore->primaryMainWindow()->doc->appMode;
ScCore->primaryMainWindow()->doc->m_Selection->clear();
@@ -508,18 +508,18 @@
char *Name = const_cast<char*>("");
char *fontfeature = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "es|es", "utf-8", &fontfeature, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
-
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
- if (i == NULL)
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
+
+ PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
+ if (i == nullptr)
+ return nullptr;
if (!i->isTextFrame())
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set font feature on a non-text frame.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
int Apm = ScCore->primaryMainWindow()->doc->appMode;
ScCore->primaryMainWindow()->doc->m_Selection->clear();
@@ -539,16 +539,16 @@
char *Name = const_cast<char*>("");
char *Font = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "es|es", "utf-8", &Font, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
- if (i == NULL)
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
+ PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
+ if (i == nullptr)
+ return nullptr;
if (!(i->isTextFrame()) && !(i->isPathText()))
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set font on a non-text frame.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
if (PrefsManager::instance()->appPrefs.fontPrefs.AvailFonts.contains(QString::fromUtf8(Font)))
{
@@ -564,7 +564,7 @@
else
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Font not found.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
// Py_INCREF(Py_None);
// return Py_None;
@@ -576,21 +576,21 @@
char *Name = const_cast<char*>("");
double w;
if (!PyArg_ParseTuple(args, "d|es", &w, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
if (w < 0.1)
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Line space out of bounds, must be >= 0.1.","python error").toLocal8Bit().constData());
- return NULL;
- }
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
- if (i == NULL)
- return NULL;
+ return nullptr;
+ }
+ PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
+ if (i == nullptr)
+ return nullptr;
if (!i->isTextFrame())
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set line spacing on a non-text frame.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
int Apm = ScCore->primaryMainWindow()->doc->appMode;
@@ -613,21 +613,21 @@
char *Name = const_cast<char*>("");
int w;
if (!PyArg_ParseTuple(args, "i|es", &w, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
if (w < 0 || w > 3) // Use constants?
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Line space mode invalid, must be 0, 1 or 2","python error").toLocal8Bit().constData());
- return NULL;
- }
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
- if (i == NULL)
- return NULL;
+ return nullptr;
+ }
+ PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
+ if (i == nullptr)
+ return nullptr;
if (!i->isTextFrame())
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set line spacing mode on a non-text frame.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
int Apm = ScCore->primaryMainWindow()->doc->appMode;
@@ -647,21 +647,21 @@
char *Name = const_cast<char*>("");
double l,r,t,b;
if (!PyArg_ParseTuple(args, "dddd|es", &l, &r, &t, &b, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
if (l < 0.0 || r < 0.0 || t < 0.0 || b < 0.0)
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Text distances out of bounds, must be positive.","python error").toLocal8Bit().constData());
- return NULL;
- }
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
- if (i == NULL)
- return NULL;
+ return nullptr;
+ }
+ PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
+ if (i == nullptr)
+ return nullptr;
if (!i->isTextFrame())
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set text distances on a non-text frame.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
i->setTextToFrameDist(ValueToPoint(l), ValueToPoint(r), ValueToPoint(t), ValueToPoint(b));
Py_INCREF(Py_None);
@@ -673,21 +673,21 @@
char *Name = const_cast<char*>("");
double w;
if (!PyArg_ParseTuple(args, "d|es", &w, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
if (w < 0.0)
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Column gap out of bounds, must be positive.","python error").toLocal8Bit().constData());
- return NULL;
- }
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
- if (i == NULL)
- return NULL;
+ return nullptr;
+ }
+ PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
+ if (i == nullptr)
+ return nullptr;
if (!i->isTextFrame())
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set column gap on a non-text frame.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
i->ColGap = ValueToPoint(w);
// Py_INCREF(Py_None);
@@ -700,21 +700,21 @@
char *Name = const_cast<char*>("");
int w;
if (!PyArg_ParseTuple(args, "i|es", &w, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
if (w < 1)
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Column count out of bounds, must be > 1.","python error").toLocal8Bit().constData());
- return NULL;
- }
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
- if (i == NULL)
- return NULL;
+ return nullptr;
+ }
+ PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
+ if (i == nullptr)
+ return nullptr;
if (!i->isTextFrame())
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set number of columns on a non-text frame.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
i->Cols = w;
// Py_INCREF(Py_None);
@@ -727,12 +727,12 @@
char *Name = const_cast<char*>("");
int start, selcount;
if (!PyArg_ParseTuple(args, "ii|es", &start, &selcount, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
PageItem *it = GetUniqueItem(QString::fromUtf8(Name));
- if (it == NULL)
- return NULL;
+ if (it == nullptr)
+ return nullptr;
if (selcount == -1)
{
// user wants to select all after the start point -- CR
@@ -745,18 +745,18 @@
if ((start < 0) || ((start + selcount) > static_cast<int>(it->itemText.length())))
{
PyErr_SetString(PyExc_IndexError, QObject::tr("Selection index out of bounds", "python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
if (!(it->isTextFrame()) && !(it->isPathText()))
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot select text in a non-text frame", "python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
/* FIXME: not sure if we should make this check or not
if (start > ende)
{
PyErr_SetString(PyExc_ValueError, QString("Selection start > selection end").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
*/
it->itemText.deselectAll();
@@ -778,16 +778,16 @@
{
char *Name = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "|es", "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
PageItem *it = GetUniqueItem(QString::fromUtf8(Name));
- if (it == NULL)
- return NULL;
+ if (it == nullptr)
+ return nullptr;
if (!it->isTextFrame() && !it->isPathText())
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot delete text from a non-text frame.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
PageItem_TextFrame* tf_item = it->asTextFrame();
if (tf_item)
@@ -811,16 +811,16 @@
char *Name = const_cast<char*>("");
char *Color;
if (!PyArg_ParseTuple(args, "es|es", "utf-8", &Color, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
PageItem *it = GetUniqueItem(QString::fromUtf8(Name));
- if (it == NULL)
- return NULL;
+ if (it == nullptr)
+ return nullptr;
if (!it->isTextFrame() && !it->isPathText())
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set text fill on a non-text frame.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
else
{
@@ -848,16 +848,16 @@
char *Name = const_cast<char*>("");
char *Color;
if (!PyArg_ParseTuple(args, "es|es", "utf-8", &Color, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
PageItem *it = GetUniqueItem(QString::fromUtf8(Name));
- if (it == NULL)
- return NULL;
+ if (it == nullptr)
+ return nullptr;
if (!it->isTextFrame() && !it->isPathText())
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set text stroke on a non-text frame.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
else
{
@@ -886,21 +886,21 @@
char *Name = const_cast<char*>("");
double sc;
if (!PyArg_ParseTuple(args, "d|es", &sc, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
if (sc < 10)
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Character scaling out of bounds, must be >= 10","python error").toLocal8Bit().constData());
- return NULL;
- }
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
- if (i == NULL)
- return NULL;
+ return nullptr;
+ }
+ PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
+ if (i == nullptr)
+ return nullptr;
if (!i->isTextFrame())
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set character scaling on a non-text frame.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
int Apm = ScCore->primaryMainWindow()->doc->appMode;
@@ -921,21 +921,21 @@
char *Name = const_cast<char*>("");
double sc;
if (!PyArg_ParseTuple(args, "d|es", &sc, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
if (sc < 10)
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Character scaling out of bounds, must be >= 10","python error").toLocal8Bit().constData());
- return NULL;
- }
- PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
- if (i == NULL)
- return NULL;
+ return nullptr;
+ }
+ PageItem *i = GetUniqueItem(QString::fromUtf8(Name));
+ if (i == nullptr)
+ return nullptr;
if (!i->isTextFrame())
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set character scaling on a non-text frame.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
int Apm = ScCore->primaryMainWindow()->doc->appMode;
@@ -956,9 +956,9 @@
char *Name = const_cast<char*>("");
int w;
if (!PyArg_ParseTuple(args, "i|es", &w, "utf-8", &Name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
if ((w < 0) || (w > 100))
{
// Py_INCREF(Py_None);
@@ -966,12 +966,12 @@
Py_RETURN_NONE;
}
PageItem *it = GetUniqueItem(QString::fromUtf8(Name));
- if (it == NULL)
- return NULL;
+ if (it == nullptr)
+ return nullptr;
if (!it->isTextFrame() && !it->isPathText())
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set text shade on a non-text frame.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
else
{
@@ -1000,39 +1000,39 @@
char *name2;
if (!PyArg_ParseTuple(args, "eses", "utf-8", &name1, "utf-8", &name2))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
PageItem *fromitem = GetUniqueItem(QString::fromUtf8(name1));
- if (fromitem == NULL)
- return NULL;
+ if (fromitem == nullptr)
+ return nullptr;
PageItem *toitem = GetUniqueItem(QString::fromUtf8(name2));
- if (toitem == NULL)
- return NULL;
+ if (toitem == nullptr)
+ return nullptr;
if (!(fromitem->isTextFrame()) || !(toitem->isTextFrame()))
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Can only link text frames.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
/* if (toitem->itemText.length() > 0)
{
PyErr_SetString(ScribusException, QObject::tr("Target frame must be empty.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}*/
if (toitem->nextInChain() != 0)
{
PyErr_SetString(ScribusException, QObject::tr("Target frame links to another frame.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
if (toitem->prevInChain() != 0)
{
PyErr_SetString(ScribusException, QObject::tr("Target frame is linked to by another frame.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
if (toitem == fromitem)
{
PyErr_SetString(ScribusException, QObject::tr("Source and target are the same object.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
// references to the others boxes
fromitem->link(toitem);
@@ -1048,27 +1048,27 @@
{
char *name;
if (!PyArg_ParseTuple(args, "es", "utf-8", &name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
PageItem *item = GetUniqueItem(QString::fromUtf8(name));
- if (item == NULL)
- return NULL;
+ if (item == nullptr)
+ return nullptr;
if (!item->asTextFrame())
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot unlink a non-text frame.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
// only linked
if (item->prevInChain() == 0)
{
PyErr_SetString(ScribusException, QObject::tr("Object is not a linked text frame, can't unlink.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
/* if (item->NextBox == 0)
{
PyErr_SetString(ScribusException, QObject::tr("Object the last frame in a series, can't unlink. Unlink the previous frame instead.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
*/
/* PageItem* nextbox = item->NextBox;
@@ -1103,16 +1103,16 @@
{
char *name = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "|es", "utf-8", &name))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
PageItem *item = GetUniqueItem(QString::fromUtf8(name));
- if (item == NULL)
- return NULL;
+ if (item == nullptr)
+ return nullptr;
if (!item->isTextFrame())
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot convert a non-text frame to outlines.","python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
if (item->invalid)
item->layout();
@@ -1128,18 +1128,18 @@
{
int nolinks = 0;
char *name = const_cast<char*>("");
- char *kwargs[] = {const_cast<char*>("name"), const_cast<char*>("nolinks"), NULL};
+ char *kwargs[] = {const_cast<char*>("name"), const_cast<char*>("nolinks"), nullptr};
if (!PyArg_ParseTupleAndKeywords(args, kw, "|esi", kwargs, "utf-8", &name, &nolinks))
- return NULL;
- if(!checkHaveDocument())
- return NULL;
+ return nullptr;
+ if(!checkHaveDocument())
+ return nullptr;
PageItem *item = GetUniqueItem(QString::fromUtf8(name));
- if (item == NULL)
- return NULL;
+ if (item == nullptr)
+ return nullptr;
if (!item->isTextFrame())
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Only text frames can be checked for overflowing", "python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
/* original solution
if (item->itemText.count() > item->MaxChars)
@@ -1179,16 +1179,16 @@
{
char *name = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "|es", "utf-8", &name))
- return NULL;
+ return nullptr;
if (!checkHaveDocument())
- return NULL;
+ return nullptr;
PageItem *i = GetUniqueItem(QString::fromUtf8(name));
- if (i == NULL)
- return NULL;
+ if (i == nullptr)
+ return nullptr;
if (!i->isTextFrame())
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Can only hyphenate text frame", "python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
ScCore->primaryMainWindow()->doc->docHyphenator->slotHyphenate(i);
return PyBool_FromLong(1);
@@ -1202,16 +1202,16 @@
{
char *name = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "|es", "utf-8", &name))
- return NULL;
+ return nullptr;
if (!checkHaveDocument())
- return NULL;
+ return nullptr;
PageItem *i = GetUniqueItem(QString::fromUtf8(name));
- if (i == NULL)
- return NULL;
+ if (i == nullptr)
+ return nullptr;
if (!i->isTextFrame())
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Can only dehyphenate text frame", "python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
ScCore->primaryMainWindow()->doc->docHyphenator->slotDeHyphenate(i);
return PyBool_FromLong(1);
@@ -1222,16 +1222,16 @@
char *name = const_cast<char*>("");
bool toggle;
if (!PyArg_ParseTuple(args, "b|es", &toggle, "utf-8", &name))
- return NULL;
+ return nullptr;
if (!checkHaveDocument())
- return NULL;
+ return nullptr;
PageItem *i = GetUniqueItem(QString::fromUtf8(name));
- if (i == NULL)
- return NULL;
+ if (i == nullptr)
+ return nullptr;
if (!i->isTextFrame())
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Can't set bookmark on a non-text frame", "python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
if (i->isBookmark == toggle)
{
@@ -1256,16 +1256,16 @@
{
char *name = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "|es", "utf-8", &name))
- return NULL;
+ return nullptr;
if (!checkHaveDocument())
- return NULL;
+ return nullptr;
PageItem *i = GetUniqueItem(QString::fromUtf8(name));
- if (i == NULL)
- return NULL;
+ if (i == nullptr)
+ return nullptr;
if (!i->isTextFrame())
{
PyErr_SetString(WrongFrameTypeError, QObject::tr("Can't get info from a non-text frame", "python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
if (i->isBookmark)
return PyBool_FromLong(1);
Modified: trunk/Scribus/scribus/plugins/scriptplugin/cmdutil.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22537&path=/trunk/Scribus/scribus/plugins/scriptplugin/cmdutil.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/cmdutil.cpp (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/cmdutil.cpp Sat May 12 20:34:43 2018
@@ -75,7 +75,7 @@
if (ScCore->primaryMainWindow()->doc->m_Selection->count() != 0)
return ScCore->primaryMainWindow()->doc->m_Selection->itemAt(0);
}
- return NULL;
+ return nullptr;
}
void ReplaceColor(QString col, QString rep)
@@ -107,7 +107,7 @@
else
{
PyErr_SetString(NoValidObjectError, QString("Cannot use empty string for object name when there is no selection").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
else
return getPageItemByName(name);
@@ -118,7 +118,7 @@
if (name.length() == 0)
{
PyErr_SetString(PyExc_ValueError, QString("Cannot accept empty name for pageitem").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
for (int j = 0; j<ScCore->primaryMainWindow()->doc->Items->count(); j++)
{
@@ -126,7 +126,7 @@
return ScCore->primaryMainWindow()->doc->Items->at(j);
} // for items
PyErr_SetString(NoValidObjectError, QString("Object not found").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
@@ -159,7 +159,7 @@
if (ScCore->primaryMainWindow()->HaveDoc)
return true;
// Caller is required to check for false return from this function
- // and return NULL.
+ // and return nullptr.
PyErr_SetString(NoDocOpenError, QString("Command does not make sense without an open document").toLocal8Bit().constData());
return false;
}
@@ -208,7 +208,7 @@
// Get the sequence of border lines.
PyObject* borderLinesList = PySequence_List(borderLines);
- if (borderLinesList == NULL)
+ if (borderLinesList == nullptr)
{
PyErr_SetString(PyExc_ValueError, QObject::tr("Expected a list of border lines", "python error").toLocal8Bit().constData());
*ok = false;
Modified: trunk/Scribus/scribus/plugins/scriptplugin/objimageexport.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22537&path=/trunk/Scribus/scribus/plugins/scriptplugin/objimageexport.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/objimageexport.cpp (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/objimageexport.cpp Sat May 12 20:34:43 2018
@@ -39,11 +39,11 @@
static PyObject * ImageExport_new(PyTypeObject *type, PyObject * /*args*/, PyObject * /*kwds*/)
{
if(!checkHaveDocument())
- return NULL;
+ return nullptr;
ImageExport *self;
self = (ImageExport *)type->tp_alloc(type, 0);
- if (self != NULL) {
+ if (self != nullptr) {
self->name = PyString_FromString("ImageExport.png");
self->type = PyString_FromString("PNG");
self->allTypes = PyList_New(0);
@@ -63,7 +63,7 @@
{const_cast<char*>("dpi"), T_INT, offsetof(ImageExport, dpi), 0, imgexp_dpi__doc__},
{const_cast<char*>("scale"), T_INT, offsetof(ImageExport, scale), 0, imgexp_scale__doc__},
{const_cast<char*>("quality"), T_INT, offsetof(ImageExport, quality), 0, imgexp_quality__doc__},
- {NULL, 0, 0, 0, NULL} // sentinel
+ {nullptr, 0, 0, 0, nullptr} // sentinel
};
static PyObject *ImageExport_getName(ImageExport *self, void * /*closure*/)
@@ -97,7 +97,7 @@
static int ImageExport_setType(ImageExport *self, PyObject *value, void * /*closure*/)
{
- if (value == NULL) {
+ if (value == nullptr) {
PyErr_SetString(PyExc_TypeError, QObject::tr("Cannot delete image type settings.", "python error").toLocal8Bit().constData());
return -1;
}
@@ -132,16 +132,16 @@
}
static PyGetSetDef ImageExport_getseters [] = {
- {const_cast<char*>("name"), (getter)ImageExport_getName, (setter)ImageExport_setName, imgexp_filename__doc__, NULL},
- {const_cast<char*>("type"), (getter)ImageExport_getType, (setter)ImageExport_setType, imgexp_type__doc__, NULL},
- {const_cast<char*>("allTypes"), (getter)ImageExport_getAllTypes, (setter)ImageExport_setAllTypes, imgexp_alltypes__doc__, NULL},
- {NULL, NULL, NULL, NULL, NULL} // sentinel
+ {const_cast<char*>("name"), (getter)ImageExport_getName, (setter)ImageExport_setName, imgexp_filename__doc__, nullptr},
+ {const_cast<char*>("type"), (getter)ImageExport_getType, (setter)ImageExport_setType, imgexp_type__doc__, nullptr},
+ {const_cast<char*>("allTypes"), (getter)ImageExport_getAllTypes, (setter)ImageExport_setAllTypes, imgexp_alltypes__doc__, nullptr},
+ {nullptr, nullptr, nullptr, nullptr, nullptr} // sentinel
};
static PyObject *ImageExport_save(ImageExport *self)
{
if(!checkHaveDocument())
- return NULL;
+ return nullptr;
ScribusDoc* doc = ScCore->primaryMainWindow()->doc;
ScribusView*view = ScCore->primaryMainWindow()->view;
@@ -157,7 +157,7 @@
if (!im.save(PyString_AsString(self->name), PyString_AsString(self->type)))
{
PyErr_SetString(ScribusException, QObject::tr("Failed to export image", "python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
// Py_INCREF(Py_True); // return True not None for backward compat
// return Py_True;
@@ -169,9 +169,9 @@
{
char* value;
if(!checkHaveDocument())
- return NULL;
+ return nullptr;
if (!PyArg_ParseTuple(args, const_cast<char*>("es"), "utf-8", &value))
- return NULL;
+ return nullptr;
ScribusDoc* doc = ScCore->primaryMainWindow()->doc;
ScribusView*view = ScCore->primaryMainWindow()->view;
@@ -188,7 +188,7 @@
if (!im.save(value, PyString_AsString(self->type)))
{
PyErr_SetString(ScribusException, QObject::tr("Failed to export image", "python error").toLocal8Bit().constData());
- return NULL;
+ return nullptr;
}
// Py_INCREF(Py_True); // return True not None for backward compat
// return Py_True;
@@ -199,11 +199,11 @@
static PyMethodDef ImageExport_methods[] = {
{const_cast<char*>("save"), (PyCFunction)ImageExport_save, METH_NOARGS, imgexp_save__doc__},
{const_cast<char*>("saveAs"), (PyCFunction)ImageExport_saveAs, METH_VARARGS, imgexp_saveas__doc__},
- {NULL, (PyCFunction)(0), 0, NULL} // sentinel
+ {nullptr, (PyCFunction)(0), 0, nullptr} // sentinel
};
PyTypeObject ImageExport_Type = {
- PyObject_HEAD_INIT(NULL) // PyObject_VAR_HEAD
+ PyObject_HEAD_INIT(nullptr) // PyObject_VAR_HEAD
0,
const_cast<char*>("scribus.ImageExport"), // char *tp_name; /* For printing, in format "<module>.<name>" */
sizeof(ImageExport), // int tp_basicsize, /* For allocation */
Modified: trunk/Scribus/scribus/plugins/scriptplugin/objpdffile.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22537&path=/trunk/Scribus/scribus/plugins/scriptplugin/objpdffile.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/objpdffile.cpp (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/objpdffile.cpp Sat May 12 20:34:43 2018
@@ -142,7 +142,7 @@
{
// do not create new object if there is no opened document
if (!checkHaveDocument()) {
- return NULL;
+ return nullptr;
}
PDFfile *self;
@@ -153,30 +153,30 @@
self->file = PyString_FromString("");
if (!self->file) {
Py_DECREF(self);
- return NULL;
+ return nullptr;
}
// set font embedding mode attribute
self->fontEmbedding = PyInt_FromLong(0);
if (!self->fontEmbedding) {
Py_DECREF(self);
- return NULL;
+ return nullptr;
}
// set fonts attribute
self->fonts = PyList_New(0);
if (!self->fonts){
Py_DECREF(self);
- return NULL;
+ return nullptr;
}
self->subsetList = PyList_New(0);
if (!self->subsetList){
Py_DECREF(self);
- return NULL;
+ return nullptr;
}
// set pages attribute
self->pages = PyList_New(0);
- if (self->pages == NULL){
+ if (self->pages == nullptr){
Py_DECREF(self);
- return NULL;
+ return nullptr;
}
// set thumbnails attribute
self->thumbnails = 0;
@@ -204,13 +204,13 @@
self->resolution = PyInt_FromLong(300);
if (!self->resolution){
Py_DECREF(self);
- return NULL;
+ return nullptr;
}
// set downsample attribute
self->downsample = PyInt_FromLong(0);
if (!self->downsample){
Py_DECREF(self);
- return NULL;
+ return nullptr;
}
// set bookmarks attribute
self->bookmarks = 0;
@@ -222,7 +222,7 @@
self->effval = PyList_New(0);
if (!self->effval){
Py_DECREF(self);
- return NULL;
+ return nullptr;
}
// set article attribute
self->article = 0;
@@ -236,19 +236,19 @@
self->lpival = PyList_New(0);
if (!self->lpival){
Py_DECREF(self);
- return NULL;
+ return nullptr;
}
// set owner attribute
self->owner = PyString_FromString("");
if (!self->owner){
Py_DECREF(self);
- return NULL;
+ return nullptr;
}
// set user attribute
self->user = PyString_FromString("");
if (!self->user){
Py_DECREF(self);
- return NULL;
+ return nullptr;
}
// set allowPrinting attribute
self->allowPrinting = 1;
@@ -272,22 +272,22 @@
self->solidpr = PyString_FromString("");
if (!self->solidpr){
Py_DECREF(self);
- return NULL;
+ return nullptr;
}
self->imagepr = PyString_FromString("");
if (!self->imagepr){
Py_DECREF(self);
- return NULL;
+ return nullptr;
}
self->printprofc = PyString_FromString("");
if (!self->printprofc){
Py_DECREF(self);
- return NULL;
+ return nullptr;
}
self->info = PyString_FromString("");
if (!self->info){
Py_DECREF(self);
- return NULL;
+ return nullptr;
}
self->bleedt = 0; // double -
self->bleedl = 0; // double -
@@ -302,7 +302,7 @@
self->rotateDeg = PyInt_FromLong(0);
if (!self->rotateDeg){
Py_DECREF(self);
- return NULL;
+ return nullptr;
}
self->isGrayscale = 0;
self->pageLayout = 0;
@@ -316,7 +316,7 @@
self->openAction = PyString_FromString("");
if (!self->openAction){
Py_DECREF(self);
- return NULL;
+ return nullptr;
}
}
return (PyObject *) self;
@@ -338,7 +338,7 @@
QFileInfo fi = QFileInfo(currentDoc->DocName);
tf = fi.path()+"/"+fi.baseName()+".pdf";
}
- PyObject *file = NULL;
+ PyObject *file = nullptr;
file = PyString_FromString(tf.toLatin1());
if (file){
Py_DECREF(self->file);
@@ -348,7 +348,7 @@
return -1;
}
// font embedding mode
- PyObject *embeddingMode = NULL;
+ PyObject *embeddingMode = nullptr;
embeddingMode = PyInt_FromLong(pdfOptions.FontEmbedding);
if (embeddingMode){
Py_DECREF(self->fontEmbedding);
@@ -358,7 +358,7 @@
return -1;
}
// embed all used fonts
- PyObject *fonts = NULL;
+ PyObject *fonts = nullptr;
fonts = PyList_New(0);
if (fonts){
Py_DECREF(self->fonts);
@@ -374,7 +374,7 @@
for (int i = 0; i < tmpEm.count(); ++i)
{
QString fontName = tmpEm.at(i);
- PyObject *tmp= NULL;
+ PyObject *tmp= nullptr;
tmp = PyString_FromString(fontName.toLatin1());
if (tmp) {
PyList_Append(self->fonts, tmp);
@@ -400,7 +400,7 @@
// copied from TabPDFOptions::restoreDefaults()
for (int fe = 0; fe < pdfOptions.SubsetList.count(); ++fe)
{
- PyObject *tmp= NULL;
+ PyObject *tmp= nullptr;
tmp = PyString_FromString(pdfOptions.SubsetList[fe].toLatin1().data());
if (tmp) {
PyList_Append(self->subsetList, tmp);
@@ -413,7 +413,7 @@
}
// set to print all pages
- PyObject *pages = NULL;
+ PyObject *pages = nullptr;
int num = 0;
// which one should I use ???
// new = ScCore->primaryMainWindow()->view->Pages.count()
@@ -457,7 +457,7 @@
// use maximum image quality
self->quality = pdfOptions.Quality;
// default resolution
- PyObject *resolution = NULL;
+ PyObject *resolution = nullptr;
resolution = PyInt_FromLong(300);
if (resolution){
Py_DECREF(self->resolution);
@@ -468,7 +468,7 @@
}
// do not downsample images
int down = pdfOptions.RecalcPic ? pdfOptions.PicRes : 0;
- PyObject *downsample = NULL;
+ PyObject *downsample = nullptr;
downsample = PyInt_FromLong(down);
if (downsample){
Py_DECREF(self->downsample);
@@ -484,7 +484,7 @@
// do not enable presentation effects
self->presentation = pdfOptions.PresentMode;
// set effects values for all pages
- PyObject *effval = NULL;
+ PyObject *effval = nullptr;
num = 0;
// which one should I use ???
// new = ScCore->primaryMainWindow()->view->Pages.count();
@@ -548,7 +548,7 @@
Py_DECREF(self->lpival);
self->lpival = lpival;
// set owner's password
- PyObject *owner = NULL;
+ PyObject *owner = nullptr;
owner = PyString_FromString(pdfOptions.PassOwner.toLatin1());
if (owner){
Py_DECREF(self->owner);
@@ -558,7 +558,7 @@
return -1;
}
// set user'a password
- PyObject *user = NULL;
+ PyObject *user = nullptr;
user = PyString_FromString(pdfOptions.PassUser.toLatin1());
if (user){
Py_DECREF(self->user);
@@ -588,7 +588,7 @@
QString tp = pdfOptions.SolidProf;
if (!ScCore->InputProfiles.contains(tp))
tp = currentDoc->cmsSettings().DefaultSolidColorRGBProfile;
- PyObject *solidpr = NULL;
+ PyObject *solidpr = nullptr;
solidpr = PyString_FromString(tp.toLatin1());
if (solidpr){
Py_DECREF(self->solidpr);
@@ -600,7 +600,7 @@
QString tp2 = pdfOptions.ImageProf;
if (!ScCore->InputProfiles.contains(tp2))
tp2 = currentDoc->cmsSettings().DefaultSolidColorRGBProfile;
- PyObject *imagepr = NULL;
+ PyObject *imagepr = nullptr;
imagepr = PyString_FromString(tp2.toLatin1());
if (imagepr){
Py_DECREF(self->imagepr);
@@ -612,7 +612,7 @@
QString tp3 = pdfOptions.PrintProf;
if (!ScCore->PDFXProfiles.contains(tp3))
tp3 = currentDoc->cmsSettings().DefaultPrinterProfile;
- PyObject *printprofc = NULL;
+ PyObject *printprofc = nullptr;
printprofc = PyString_FromString(tp3.toLatin1());
if (printprofc){
Py_DECREF(self->printprofc);
@@ -622,7 +622,7 @@
return -1;
}
QString tinfo = pdfOptions.Info;
- PyObject *info = NULL;
+ PyObject *info = nullptr;
info = PyString_FromString(tinfo.toLatin1());
if (info){
Py_DECREF(self->info);
@@ -641,7 +641,7 @@
self->mirrorH = pdfOptions.MirrorH; // bool
self->mirrorV = pdfOptions.MirrorV; // bool
self->doClip = pdfOptions.doClip; // bool
- PyObject *rotateDeg = NULL;
+ PyObject *rotateDeg = nullptr;
rotateDeg = PyInt_FromLong(0);
if (rotateDeg){
Py_DECREF(self->rotateDeg);
@@ -660,7 +660,7 @@
self->hideMenuBar = pdfOptions.hideMenuBar; // bool
self->fitWindow = pdfOptions.fitWindow; // bool
- PyObject *openAction = NULL;
+ PyObject *openAction = nullptr;
openAction = PyString_FromString(pdfOptions.openAction.toLatin1().data());
if (openAction){
Py_DECREF(self->openAction);
@@ -733,7 +733,7 @@
{const_cast<char*>("achange"), T_INT, offsetof(PDFfile, allowChange), 0, const_cast<char*>("Deprecated. Use 'allowChange' instead.")},
{const_cast<char*>("acopy"), T_INT, offsetof(PDFfile, allowCopy), 0, const_cast<char*>("Deprecated. Use 'allowCopy' instead.")},
{const_cast<char*>("aanot"), T_INT, offsetof(PDFfile, allowAnnots), 0, const_cast<char*>("Deprecated. Use 'allowAnnots' instead.")},
- {NULL, 0, 0, 0, NULL} // sentinel
+ {nullptr, 0, 0, 0, nullptr} // sentinel
};
@@ -747,7 +747,7 @@
static int PDFfile_setfile(PDFfile *self, PyObject *value, void * /*closure*/)
{
- if (value == NULL) {
+ if (value == nullptr) {
PyErr_SetString(PyExc_TypeError, "Cannot delete 'file' attribute.");
return -1;
}
@@ -769,7 +769,7 @@
static int PDFfile_setFontEmbeddingMode(PDFfile *self, PyObject *value, void * /*closure*/)
{
- if (value == NULL) {
+ if (value == nullptr) {
PyErr_SetString(PyExc_TypeError, "Cannot delete 'fontEmbedding' attribute.");
return -1;
}
@@ -796,7 +796,7 @@
static int PDFfile_setfonts(PDFfile *self, PyObject *value, void * /*closure*/)
{
- if (value == NULL) {
+ if (value == nullptr) {
PyErr_SetString(PyExc_TypeError, "Cannot delete 'fonts' attribute.");
return -1;
}
@@ -829,7 +829,7 @@
static int PDFfile_setSubsetList(PDFfile *self, PyObject *value, void * /*closure*/)
{
- if (value == NULL) {
+ if (value == nullptr) {
PyErr_SetString(PyExc_TypeError, "Cannot delete 'subsetList' attribute.");
return -1;
}
@@ -859,7 +859,7 @@
static int PDFfile_setpages(PDFfile *self, PyObject *value, void * /*closure*/)
{
- if (value == NULL) {
+ if (value == nullptr) {
PyErr_SetString(PyExc_TypeError, "Cannot delete 'pages' attribute.");
return -1;
}
@@ -870,7 +870,7 @@
int len = PyList_Size(value);
for (int i = 0; i<len; i++){
PyObject *tmp = PyList_GetItem(value, i);
- // I did not check if tmp is NULL
+ // I did not check if tmp is nullptr
// how can PyList_GetItem fail in this case (my guess: short of available memory?)
// Also do I need Py_INCREF or Py_DECREF here?
if (!PyInt_Check(tmp)){
@@ -897,7 +897,7 @@
static int PDFfile_setresolution(PDFfile *self, PyObject *value, void * /*closure*/)
{
- if (value == NULL) {
+ if (value == nullptr) {
PyErr_SetString(PyExc_TypeError, "Cannot delete 'resolution' attribute.");
return -1;
}
@@ -924,7 +924,7 @@
static int PDFfile_setdownsample(PDFfile *self, PyObject *value, void * /*closure*/)
{
- if (value == NULL) {
+ if (value == nullptr) {
PyErr_SetString(PyExc_TypeError, "Cannot delete 'downsample' attribute.");
return -1;
}
@@ -951,7 +951,7 @@
static int PDFfile_seteffval(PDFfile *self, PyObject *value, void * /*closure*/)
{
- if (value == NULL) {
+ if (value == nullptr) {
PyErr_SetString(PyExc_TypeError, "Cannot delete 'effval' attribute.");
return -1;
}
@@ -992,7 +992,7 @@
static int PDFfile_setlpival(PDFfile *self, PyObject *value, void * /*closure*/)
{
- if (value == NULL) {
+ if (value == nullptr) {
PyErr_SetString(PyExc_TypeError, "Cannot delete 'lpival' attribute.");
return -1;
}
@@ -1038,7 +1038,7 @@
static int PDFfile_setowner(PDFfile *self, PyObject *value, void * /*closure*/)
{
- if (value == NULL) {
+ if (value == nullptr) {
PyErr_SetString(PyExc_TypeError, "Cannot delete 'owner' attribute.");
return -1;
}
@@ -1060,7 +1060,7 @@
static int PDFfile_setuser(PDFfile *self, PyObject *value, void * /*closure*/)
{
- if (value == NULL) {
+ if (value == nullptr) {
PyErr_SetString(PyExc_TypeError, "Cannot delete 'user' attribute.");
return -1;
}
@@ -1082,7 +1082,7 @@
static int PDFfile_setsolidpr(PDFfile *self, PyObject *value, void * /*closure*/)
{
- if (value == NULL) {
+ if (value == nullptr) {
PyErr_SetString(PyExc_TypeError, "Cannot delete 'solidpr' attribute.");
return -1;
}
@@ -1104,7 +1104,7 @@
static int PDFfile_setimagepr(PDFfile *self, PyObject *value, void * /*closure*/)
{
- if (value == NULL) {
+ if (value == nullptr) {
PyErr_SetString(PyExc_TypeError, "Cannot delete 'imagepr' attribute.");
return -1;
}
@@ -1126,7 +1126,7 @@
static int PDFfile_setprintprofc(PDFfile *self, PyObject *value, void * /*closure*/)
{
- if (value == NULL) {
+ if (value == nullptr) {
PyErr_SetString(PyExc_TypeError, "Cannot delete 'printprofc' attribute.");
return -1;
}
@@ -1148,7 +1148,7 @@
static int PDFfile_setinfo(PDFfile *self, PyObject *value, void * /*closure*/)
{
- if (value == NULL) {
+ if (value == nullptr) {
PyErr_SetString(PyExc_TypeError, "Cannot delete 'info' attribute.");
return -1;
}
@@ -1170,7 +1170,7 @@
static int PDFfile_setRotateDeg(PDFfile *self, PyObject *value, void * /*closure*/)
{
- if (value == NULL) {
+ if (value == nullptr) {
PyErr_SetString(PyExc_TypeError, "Cannot delete 'rotateDeg' attribute.");
return -1;
}
@@ -1197,7 +1197,7 @@
static int PDFfile_setopenAction(PDFfile *self, PyObject *value, void * /*closure*/)
{
- if (value == NULL) {
+ if (value == nullptr) {
PyErr_SetString(PyExc_TypeError, "Cannot delete 'openAction' attribute.");
return -1;
}
@@ -1232,30 +1232,30 @@
"Be careful when supplying these values as they\nare not checked for validity.");
static PyGetSetDef PDFfile_getseters [] = {
- {const_cast<char*>("file"), (getter)PDFfile_getfile, (setter)PDFfile_setfile, const_cast<char*>("Name of file to save into"), NULL},
- {const_cast<char*>("fontEmbedding"), (getter)PDFfile_getFontEmbeddingMode, (setter)PDFfile_setFontEmbeddingMode, const_cast<char*>("Font embedding mode.\n\tValue must be one of integers: 0 (Embed), 1 (Outline), 2 (No embedding)."), NULL},
- {const_cast<char*>("fonts"), (getter)PDFfile_getfonts, (setter)PDFfile_setfonts, const_cast<char*>("List of fonts to embed."), NULL},
- {const_cast<char*>("subsetList"), (getter)PDFfile_getSubsetList, (setter)PDFfile_setSubsetList, const_cast<char*>("List of fonts to subsetted."), NULL},
- {const_cast<char*>("pages"), (getter)PDFfile_getpages, (setter)PDFfile_setpages, const_cast<char*>("List of pages to print"), NULL},
- {const_cast<char*>("resolution"), (getter)PDFfile_getresolution, (setter)PDFfile_setresolution, const_cast<char*>("Resolution of output file. Values from 35 to 4000."), NULL},
- {const_cast<char*>("downsample"), (getter)PDFfile_getdownsample, (setter)PDFfile_setdownsample, const_cast<char*>("Downsample image resolusion to this value. Values from 35 to 4000\nSet 0 for not to downsample"), NULL},
- {const_cast<char*>("effval"), (getter)PDFfile_geteffval, (setter)PDFfile_seteffval, effval_doc, NULL},
- {const_cast<char*>("lpival"), (getter)PDFfile_getlpival, (setter)PDFfile_setlpival, lpival_doc, NULL},
- {const_cast<char*>("owner"), (getter)PDFfile_getowner, (setter)PDFfile_setowner, const_cast<char*>("Owner's password"), NULL},
- {const_cast<char*>("user"), (getter)PDFfile_getuser, (setter)PDFfile_setuser, const_cast<char*>("User's password"), NULL},
- {const_cast<char*>("solidpr"), (getter)PDFfile_getsolidpr, (setter)PDFfile_setsolidpr, const_cast<char*>("Color profile for solid colors"), NULL},
- {const_cast<char*>("imagepr"), (getter)PDFfile_getimagepr, (setter)PDFfile_setimagepr, const_cast<char*>("Color profile for images"), NULL},
- {const_cast<char*>("printprofc"), (getter)PDFfile_getprintprofc, (setter)PDFfile_setprintprofc, const_cast<char*>("Output profile for printing. If possible, get some guidance from your printer on profile selection."), NULL},
- {const_cast<char*>("info"), (getter)PDFfile_getinfo, (setter)PDFfile_setinfo, const_cast<char*>("Mandatory string for PDF/X or the PDF will fail\nPDF/X conformance. We recommend you use the title of the document."), NULL},
- {const_cast<char*>("rotateDeg"), (getter)PDFfile_getRotateDeg, (setter)PDFfile_setRotateDeg, const_cast<char*>("Automatically rotate the exported pages\n\tValue must be one of integers: 0, 90, 180 or 270"), NULL},
- {const_cast<char*>("openAction"), (getter)PDFfile_getopenAction, (setter)PDFfile_setopenAction, const_cast<char*>("Javascript to be executed when PDF document is opened."), NULL},
- {NULL, NULL, NULL, NULL, NULL} // sentinel
+ {const_cast<char*>("file"), (getter)PDFfile_getfile, (setter)PDFfile_setfile, const_cast<char*>("Name of file to save into"), nullptr},
+ {const_cast<char*>("fontEmbedding"), (getter)PDFfile_getFontEmbeddingMode, (setter)PDFfile_setFontEmbeddingMode, const_cast<char*>("Font embedding mode.\n\tValue must be one of integers: 0 (Embed), 1 (Outline), 2 (No embedding)."), nullptr},
+ {const_cast<char*>("fonts"), (getter)PDFfile_getfonts, (setter)PDFfile_setfonts, const_cast<char*>("List of fonts to embed."), nullptr},
+ {const_cast<char*>("subsetList"), (getter)PDFfile_getSubsetList, (setter)PDFfile_setSubsetList, const_cast<char*>("List of fonts to subsetted."), nullptr},
+ {const_cast<char*>("pages"), (getter)PDFfile_getpages, (setter)PDFfile_setpages, const_cast<char*>("List of pages to print"), nullptr},
+ {const_cast<char*>("resolution"), (getter)PDFfile_getresolution, (setter)PDFfile_setresolution, const_cast<char*>("Resolution of output file. Values from 35 to 4000."), nullptr},
+ {const_cast<char*>("downsample"), (getter)PDFfile_getdownsample, (setter)PDFfile_setdownsample, const_cast<char*>("Downsample image resolusion to this value. Values from 35 to 4000\nSet 0 for not to downsample"), nullptr},
+ {const_cast<char*>("effval"), (getter)PDFfile_geteffval, (setter)PDFfile_seteffval, effval_doc, nullptr},
+ {const_cast<char*>("lpival"), (getter)PDFfile_getlpival, (setter)PDFfile_setlpival, lpival_doc, nullptr},
+ {const_cast<char*>("owner"), (getter)PDFfile_getowner, (setter)PDFfile_setowner, const_cast<char*>("Owner's password"), nullptr},
+ {const_cast<char*>("user"), (getter)PDFfile_getuser, (setter)PDFfile_setuser, const_cast<char*>("User's password"), nullptr},
+ {const_cast<char*>("solidpr"), (getter)PDFfile_getsolidpr, (setter)PDFfile_setsolidpr, const_cast<char*>("Color profile for solid colors"), nullptr},
+ {const_cast<char*>("imagepr"), (getter)PDFfile_getimagepr, (setter)PDFfile_setimagepr, const_cast<char*>("Color profile for images"), nullptr},
+ {const_cast<char*>("printprofc"), (getter)PDFfile_getprintprofc, (setter)PDFfile_setprintprofc, const_cast<char*>("Output profile for printing. If possible, get some guidance from your printer on profile selection."), nullptr},
+ {const_cast<char*>("info"), (getter)PDFfile_getinfo, (setter)PDFfile_setinfo, const_cast<char*>("Mandatory string for PDF/X or the PDF will fail\nPDF/X conformance. We recommend you use the title of the document."), nullptr},
+ {const_cast<char*>("rotateDeg"), (getter)PDFfile_getRotateDeg, (setter)PDFfile_setRotateDeg, const_cast<char*>("Automatically rotate the exported pages\n\tValue must be one of integers: 0, 90, 180 or 270"), nullptr},
+ {const_cast<char*>("openAction"), (getter)PDFfile_getopenAction, (setter)PDFfile_setopenAction, const_cast<char*>("Javascript to be executed when PDF document is opened."), nullptr},
+ {nullptr, nullptr, nullptr, nullptr, nullptr} // sentinel
};
static PyObject *PDFfile_save(PDFfile *self)
{
if (!checkHaveDocument()) {
- return NULL;
+ return nullptr;
}
ScribusDoc* currentDoc = ScCore->primaryMainWindow()->doc;
@@ -1401,7 +1401,7 @@
// if (!PyArg_ParseTuple(t, "[siii]", &s, &lpi.Frequency,
// &lpi.Angle, &lpi.SpotFunc)) {
// PyErr_SetString(PyExc_SystemError, "while parsing 'lpival'. WHY THIS HAPPENED????");
-// return NULL;
+// return nullptr;
// }
// pdfOptions.LPISettings[QString(s)]=lpi;
QString st;
@@ -1539,16 +1539,16 @@
if (success)
Py_RETURN_NONE;
- return NULL;
+ return nullptr;
}
static PyMethodDef PDFfile_methods[] = {
{const_cast<char*>("save"), (PyCFunction)PDFfile_save, METH_NOARGS, const_cast<char*>("Save selected pages to pdf file")},
- {NULL, (PyCFunction)(0), 0, NULL} // sentinel
+ {nullptr, (PyCFunction)(0), 0, nullptr} // sentinel
};
PyTypeObject PDFfile_Type = {
- PyObject_HEAD_INIT(NULL) // PyObject_VAR_HEAD
+ PyObject_HEAD_INIT(nullptr) // PyObject_VAR_HEAD
0, //
const_cast<char*>("scribus.PDFfile"), // char *tp_name; /* For printing, in format "<module>.<name>" */
sizeof(PDFfile), // int tp_basicsize, /* For allocation */
Modified: trunk/Scribus/scribus/plugins/scriptplugin/objprinter.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22537&path=/trunk/Scribus/scribus/plugins/scriptplugin/objprinter.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/objprinter.cpp (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/objprinter.cpp Sat May 12 20:34:43 2018
@@ -66,47 +66,46 @@
{
// do not create new object if there is no opened document
if (!checkHaveDocument()) {
- return NULL;
- }
-
- Printer *self;
- self = (Printer *)type->tp_alloc(type, 0);
- if (self != NULL) {
+ return nullptr;
+ }
+
+ Printer *self = (Printer *)type->tp_alloc(type, 0);
+ if (self != nullptr) {
// set allPrinters attribute
self->allPrinters = PyList_New(0);
- if (self->allPrinters == NULL){
+ if (self->allPrinters == nullptr){
Py_DECREF(self);
- return NULL;
+ return nullptr;
}
// set printer attribute
self->printer = PyString_FromString("");
- if (self->printer == NULL){
+ if (self->printer == nullptr){
Py_DECREF(self);
- return NULL;
+ return nullptr;
}
// set file attribute
self->file = PyString_FromString("");
- if (self->file == NULL){
+ if (self->file == nullptr){
Py_DECREF(self);
- return NULL;
+ return nullptr;
}
// set cmd attribute
self->cmd = PyString_FromString("");
- if (self->cmd == NULL){
+ if (self->cmd == nullptr){
Py_DECREF(self);
- return NULL;
+ return nullptr;
}
// set pages attribute
self->pages = PyList_New(0);
- if (self->pages == NULL){
+ if (self->pages == nullptr){
Py_DECREF(self);
- return NULL;
+ return nullptr;
}
// set separation attribute
self->separation = PyString_FromString("No");
- if (self->separation == NULL){
+ if (self->separation == nullptr){
Py_DECREF(self);
- return NULL;
+ return nullptr;
}
// set color attribute
self->color = 1;
@@ -154,7 +153,7 @@
PyList_Append(self->allPrinters, tmp2);
Py_DECREF(tmp2);
// as defaut set to print into file
- PyObject *printer = NULL;
+ PyObject *printer = nullptr;
printer = PyString_FromString("File");
if (printer){
Py_DECREF(self->printer);
@@ -166,7 +165,7 @@
QFileInfo fi = QFileInfo(ScCore->primaryMainWindow()->doc->DocName);
tf = fi.path()+"/"+fi.baseName()+".pdf";
}
- PyObject *file = NULL;
+ PyObject *file = nullptr;
file = PyString_FromString(tf.toLatin1());
if (file){
Py_DECREF(self->file);
@@ -176,7 +175,7 @@
return -1;
}
// alternative printer commands default to ""
- PyObject *cmd = NULL;
+ PyObject *cmd = nullptr;
cmd = PyString_FromString("");
if (cmd){
Py_DECREF(self->cmd);
@@ -184,7 +183,7 @@
}
// if document exist when created Printer instance
// set to print all pages
- PyObject *pages = NULL;
+ PyObject *pages = nullptr;
int num = ScCore->primaryMainWindow()->doc->Pages->count();
pages = PyList_New(num);
if (pages){
@@ -192,13 +191,13 @@
self->pages = pages;
}
for (int i = 0; i<num; i++) {
- PyObject *tmp=NULL;
+ PyObject *tmp=nullptr;
tmp = PyInt_FromLong((long)i+1L); // instead of 1 put here first page number
if (tmp)
PyList_SetItem(self->pages, i, tmp);
}
// do not print separation
- PyObject *separation = NULL;
+ PyObject *separation = nullptr;
separation = PyString_FromString("No");
if (separation){
Py_DECREF(self->separation);
@@ -229,7 +228,7 @@
{const_cast<char*>("mph"), T_INT, offsetof(Printer, mph), 0, const_cast<char*>("Mirror Pages Horizontal\n\tTrue\n\tFalse -- Default")},
{const_cast<char*>("mpv"), T_INT, offsetof(Printer, mpv), 0, const_cast<char*>("Mirror Pages Vertical\n\t True\n\tFalse -- Default")},
{const_cast<char*>("ucr"), T_INT, offsetof(Printer, ucr), 0, const_cast<char*>("Apply Under Color Removal\n\tTrue -- Default\n\tFalse")},
- {NULL, 0, 0, 0, NULL} // sentinel
+ {nullptr, 0, 0, 0, nullptr} // sentinel
};
/* Here begins Getter & Setter functions */
@@ -254,7 +253,7 @@
static int Printer_setprinter(Printer *self, PyObject *value, void * /*closure*/)
{
- if (value == NULL) {
+ if (value == nullptr) {
PyErr_SetString(PyExc_TypeError, "Cannot delete 'printer' attribute.");
return -1;
}
@@ -285,7 +284,7 @@
static int Printer_setfile(Printer *self, PyObject *value, void * /*closure*/)
{
- if (value == NULL) {
+ if (value == nullptr) {
PyErr_SetString(PyExc_TypeError, "Cannot delete 'file' attribute.");
return -1;
}
@@ -307,7 +306,7 @@
static int Printer_setcmd(Printer *self, PyObject *value, void * /*closure*/)
{
- if (value == NULL) {
+ if (value == nullptr) {
PyErr_SetString(PyExc_TypeError, "Cannot delete 'cmd' attribute.");
return -1;
}
@@ -329,7 +328,7 @@
static int Printer_setpages(Printer *self, PyObject *value, void * /*closure*/)
{
- if (value == NULL) {
+ if (value == nullptr) {
PyErr_SetString(PyExc_TypeError, "Cannot delete 'pages' attribute.");
return -1;
}
@@ -363,7 +362,7 @@
static int Printer_setseparation(Printer *self, PyObject *value, void * /*closure*/)
{
- if (value == NULL) {
+ if (value == nullptr) {
PyErr_SetString(PyExc_TypeError, "Cannot delete 'separation' attribute.");
return -1;
}
@@ -379,20 +378,20 @@
static PyGetSetDef Printer_getseters [] = {
- {const_cast<char*>("allPrinters"), (getter)Printer_getallPrinters, (setter)Printer_setallPrinters, const_cast<char*>("List of installed printers -- read only"), NULL},
- {const_cast<char*>("printer"), (getter)Printer_getprinter, (setter)Printer_setprinter, const_cast<char*>("Name of printer to use.\nDefault is 'File' for printing into file"), NULL},
- {const_cast<char*>("file"), (getter)Printer_getfile, (setter)Printer_setfile, const_cast<char*>("Name of file to print into"), NULL},
- {const_cast<char*>("cmd"), (getter)Printer_getcmd, (setter)Printer_setcmd, const_cast<char*>("Alternative Printer Command"), NULL},
- {const_cast<char*>("pages"), (getter)Printer_getpages, (setter)Printer_setpages, const_cast<char*>("List of pages to be printed"), NULL},
- {const_cast<char*>("separation"), (getter)Printer_getseparation, (setter)Printer_setseparation, const_cast<char*>("Print separationl\n\t 'No' -- Default\n\t 'All'\n\t 'Cyan'\n\t 'Magenta'\n\t 'Yellow'\n\t 'Black'\nBeware of misspelling because check is not performed"), NULL},
- {NULL, NULL, NULL, NULL, NULL} // sentinel
+ {const_cast<char*>("allPrinters"), (getter)Printer_getallPrinters, (setter)Printer_setallPrinters, const_cast<char*>("List of installed printers -- read only"), nullptr},
+ {const_cast<char*>("printer"), (getter)Printer_getprinter, (setter)Printer_setprinter, const_cast<char*>("Name of printer to use.\nDefault is 'File' for printing into file"), nullptr},
+ {const_cast<char*>("file"), (getter)Printer_getfile, (setter)Printer_setfile, const_cast<char*>("Name of file to print into"), nullptr},
+ {const_cast<char*>("cmd"), (getter)Printer_getcmd, (setter)Printer_setcmd, const_cast<char*>("Alternative Printer Command"), nullptr},
+ {const_cast<char*>("pages"), (getter)Printer_getpages, (setter)Printer_setpages, const_cast<char*>("List of pages to be printed"), nullptr},
+ {const_cast<char*>("separation"), (getter)Printer_getseparation, (setter)Printer_setseparation, const_cast<char*>("Print separationl\n\t 'No' -- Default\n\t 'All'\n\t 'Cyan'\n\t 'Magenta'\n\t 'Yellow'\n\t 'Black'\nBeware of misspelling because check is not performed"), nullptr},
+ {nullptr, nullptr, nullptr, nullptr, nullptr} // sentinel
};
// Here we actually print
static PyObject *Printer_print(Printer *self)
{
if (!checkHaveDocument()) {
- return NULL;
+ return nullptr;
}
// copied from void ScribusMainWindow::slotFilePrint() in file scribus.cpp
QString fna, prn, cmd, cc, SepName;
@@ -451,7 +450,7 @@
#endif
PSLib *dd = new PSLib(options, true, prefsManager->appPrefs.fontPrefs.AvailFonts, ReallyUsed, ScCore->primaryMainWindow()->doc->PageColors, false, true);
- if (dd != NULL)
+ if (dd != nullptr)
{
if (!fil)
fna = QDir::toNativeSeparators(ScPaths::tempFileDir()+"/tmp.ps");
@@ -498,7 +497,7 @@
else {
delete dd;
PyErr_SetString(PyExc_SystemError, "Printing failed");
- return NULL;
+ return nullptr;
}
delete dd;
}
@@ -509,11 +508,11 @@
static PyMethodDef Printer_methods[] = {
{const_cast<char*>("printNow"), (PyCFunction)Printer_print, METH_NOARGS, const_cast<char*>("Prints selected pages.")},
- {NULL, (PyCFunction)(0), 0, NULL} // sentinel
+ {nullptr, (PyCFunction)(0), 0, nullptr} // sentinel
};
PyTypeObject Printer_Type = {
- PyObject_HEAD_INIT(NULL) // PyObject_VAR_HEAD
+ PyObject_HEAD_INIT(nullptr) // PyObject_VAR_HEAD
0, //
const_cast<char*>("scribus.Printer"), // char *tp_name; /* For printing, in format "<module>.<name>" */
sizeof(Printer), // int tp_basicsize, /* For allocation */
Modified: trunk/Scribus/scribus/plugins/scriptplugin/scriptercore.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22537&path=/trunk/Scribus/scribus/plugins/scriptplugin/scriptercore.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/scriptercore.cpp (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/scriptercore.cpp Sat May 12 20:34:43 2018
@@ -43,7 +43,7 @@
ScripterCore::ScripterCore(QWidget* parent)
{
- menuMgr = NULL;
+ menuMgr = nullptr;
pcon = new PythonConsole(parent);
scrScripterActions.clear();
@@ -241,16 +241,16 @@
return;
disableMainWindowMenu();
- PyThreadState *state = NULL;
+ PyThreadState *state = nullptr;
QFileInfo fi(fileName);
QByteArray na = fi.fileName().toLocal8Bit();
// Set up a sub-interpreter if needed:
- PyThreadState* global_state = NULL;
+ PyThreadState* global_state = nullptr;
if (!inMainInterpreter)
{
ScCore->primaryMainWindow()->propertiesPalette->unsetDoc();
ScCore->primaryMainWindow()->textPalette->unsetDoc();
- ScCore->primaryMainWindow()->pagePalette->setView(NULL);
+ ScCore->primaryMainWindow()->pagePalette->setView(nullptr);
ScCore->primaryMainWindow()->setScriptRunning(true);
qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
// Create the sub-interpreter
@@ -282,7 +282,7 @@
// call python script
PyObject* m = PyImport_AddModule((char*)"__main__");
- if (m == NULL)
+ if (m == nullptr)
qDebug("Failed to get __main__ - aborting script");
else
{
@@ -329,12 +329,12 @@
// sub-interpreter if we created and switched to one earlier, otherwise
// it'll run in the main interpreter.
PyObject* result = PyRun_String(cmd.data(), Py_file_input, globals, globals);
- // NULL is returned if an exception is set. We don't care about any
+ // nullptr is returned if an exception is set. We don't care about any
// other return value (most likely None anyway) and can ignore it.
- if (result == NULL)
+ if (result == nullptr)
{
PyObject* errorMsgPyStr = PyMapping_GetItemString(globals, (char*)"_errorMsg");
- if (errorMsgPyStr == NULL)
+ if (errorMsgPyStr == nullptr)
{
// It's rather unlikely that this will ever be reached - to get here
// we'd have to fail to retrive the string we just created.
@@ -360,10 +360,10 @@
}
// We've already processed the exception text, so clear the exception
PyErr_Clear();
- } // end if result == NULL
- // Because 'result' may be NULL, not a PyObject*, we must call PyXDECREF not Py_DECREF
+ } // end if result == nullptr
+ // Because 'result' may be nullptr, not a PyObject*, we must call PyXDECREF not Py_DECREF
Py_XDECREF(result);
- } // end if m == NULL
+ } // end if m == nullptr
if (!inMainInterpreter)
{
Py_EndInterpreter(state);
@@ -395,12 +395,12 @@
ScCore->primaryMainWindow()->propertiesPalette->unsetDoc();
ScCore->primaryMainWindow()->textPalette->unsetDoc();
- ScCore->primaryMainWindow()->pagePalette->setView(NULL);
+ ScCore->primaryMainWindow()->pagePalette->setView(nullptr);
ScCore->primaryMainWindow()->setScriptRunning(true);
inValue = Script;
QString cm;
cm = "# -*- coding: utf8 -*- \n";
- if (PyThreadState_Get() != NULL)
+ if (PyThreadState_Get() != nullptr)
{
initscribus(ScCore->primaryMainWindow());
/* HACK: following loop handles all input line by line.
@@ -439,13 +439,13 @@
PySys_SetArgv(1, comm); */
// then run the code
PyObject* m = PyImport_AddModule((char*)"__main__");
- if (m == NULL)
+ if (m == nullptr)
qDebug("Failed to get __main__ - aborting script");
else
{
PyObject* globals = PyModule_GetDict(m);
PyObject* result = PyRun_String(cm.toUtf8().data(), Py_file_input, globals, globals);
- if (result == NULL)
+ if (result == nullptr)
{
PyErr_Print();
ScMessageBox::warning(ScCore->primaryMainWindow(), tr("Script error"),
@@ -454,7 +454,7 @@
"stderr. ") + "</qt>");
}
else
- // Because 'result' may be NULL, not a PyObject*, we must call PyXDECREF not Py_DECREF
+ // Because 'result' may be nullptr, not a PyObject*, we must call PyXDECREF not Py_DECREF
Py_XDECREF(result);
}
ScCore->primaryMainWindow()->setScriptRunning(false);
More information about the scribus-commit
mailing list