Spreadsheet: modernize C++11
* use nullptr
This commit is contained in:
@@ -64,7 +64,7 @@ PyObject* SheetPy::set(PyObject *args)
|
||||
|
||||
|
||||
if (!PyArg_ParseTuple(args, "ss:set", &address, &contents))
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
try {
|
||||
Sheet * sheet = getSheetPtr();
|
||||
@@ -83,7 +83,7 @@ PyObject* SheetPy::set(PyObject *args)
|
||||
}
|
||||
catch (const Base::Exception & e) {
|
||||
PyErr_SetString(PyExc_ValueError, e.what());
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Py_Return;
|
||||
@@ -92,10 +92,10 @@ PyObject* SheetPy::set(PyObject *args)
|
||||
PyObject* SheetPy::get(PyObject *args)
|
||||
{
|
||||
const char *address;
|
||||
const char *address2=0;
|
||||
const char *address2=nullptr;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "s|s:get", &address, &address2))
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
PY_TRY {
|
||||
if(address2) {
|
||||
@@ -113,7 +113,7 @@ PyObject* SheetPy::get(PyObject *args)
|
||||
if(!prop) {
|
||||
PyErr_Format(PyExc_ValueError, "Invalid address '%s' in range %s:%s",
|
||||
range.address().c_str(), address, address2);
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
tuple.setItem(i++,Py::Object(prop->getPyObject(),true));
|
||||
}while(range.next());
|
||||
@@ -123,10 +123,10 @@ PyObject* SheetPy::get(PyObject *args)
|
||||
|
||||
App::Property * prop = this->getSheetPtr()->getPropertyByName(address);
|
||||
|
||||
if (prop == 0) {
|
||||
if (prop == nullptr) {
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"Invalid cell address or property: %s",address);
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
return prop->getPyObject();
|
||||
}
|
||||
@@ -137,7 +137,7 @@ PyObject* SheetPy::getContents(PyObject *args)
|
||||
CellAddress address;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "s:getContents", &strAddress))
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
PY_TRY {
|
||||
try {
|
||||
@@ -151,7 +151,7 @@ PyObject* SheetPy::getContents(PyObject *args)
|
||||
}
|
||||
catch (const Base::Exception & e) {
|
||||
PyErr_SetString(PyExc_ValueError, e.what());
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::string contents;
|
||||
@@ -170,7 +170,7 @@ PyObject* SheetPy::clear(PyObject *args)
|
||||
int all = 1;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "s|p:clear", &strAddress, &all))
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
try {
|
||||
Range rangeIter(strAddress);
|
||||
@@ -180,7 +180,7 @@ PyObject* SheetPy::clear(PyObject *args)
|
||||
}
|
||||
catch (const Base::Exception & e) {
|
||||
PyErr_SetString(PyExc_ValueError, e.what());
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Py_Return;
|
||||
@@ -189,7 +189,7 @@ PyObject* SheetPy::clear(PyObject *args)
|
||||
PyObject* SheetPy::clearAll(PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
this->getSheetPtr()->clearAll();
|
||||
Py_Return;
|
||||
@@ -203,7 +203,7 @@ PyObject* SheetPy::importFile(PyObject *args)
|
||||
const char * escapeChar = "\\";
|
||||
|
||||
if (!PyArg_ParseTuple(args, "s|sss:importFile", &filename, &delimiter, "eChar, &escapeChar))
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
if (getSheetPtr()->importFromFile(filename, delimiter[0], quoteChar[0], escapeChar[0]))
|
||||
return Py::new_reference_to( Py::Boolean(true) );
|
||||
@@ -219,7 +219,7 @@ PyObject* SheetPy::exportFile(PyObject *args)
|
||||
const char * escapeChar = "\\";
|
||||
|
||||
if (!PyArg_ParseTuple(args, "s|sss:exportFile", &filename, &delimiter, "eChar, &escapeChar))
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
if (getSheetPtr()->exportToFile(filename, delimiter[0], quoteChar[0], escapeChar[0]))
|
||||
return Py::new_reference_to( Py::Boolean(true) );
|
||||
@@ -232,7 +232,7 @@ PyObject* SheetPy::mergeCells(PyObject *args)
|
||||
const char * range;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "s:mergeCells", &range))
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
getSheetPtr()->mergeCells(Range(range));
|
||||
Py_Return;
|
||||
@@ -243,7 +243,7 @@ PyObject* SheetPy::splitCell(PyObject *args)
|
||||
const char * strAddress;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "s:splitCell", &strAddress))
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
CellAddress address;
|
||||
try {
|
||||
@@ -251,7 +251,7 @@ PyObject* SheetPy::splitCell(PyObject *args)
|
||||
}
|
||||
catch (const Base::Exception & e) {
|
||||
PyErr_SetString(PyExc_ValueError, e.what());
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
getSheetPtr()->splitCell(address);
|
||||
@@ -264,7 +264,7 @@ PyObject* SheetPy::insertColumns(PyObject *args)
|
||||
int count;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "si:insertColumns", &column, &count))
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
getSheetPtr()->insertColumns(decodeColumn(column), count);
|
||||
Py_Return;
|
||||
@@ -276,7 +276,7 @@ PyObject* SheetPy::removeColumns(PyObject *args)
|
||||
int count;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "si:removeColumns", &column, &count))
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
getSheetPtr()->removeColumns(decodeColumn(column), count);
|
||||
Py_Return;
|
||||
@@ -288,7 +288,7 @@ PyObject* SheetPy::insertRows(PyObject *args)
|
||||
int count;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "si:insertRows", &row, &count))
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
getSheetPtr()->insertRows(decodeRow(std::string(row)), count);
|
||||
Py_Return;
|
||||
@@ -300,7 +300,7 @@ PyObject* SheetPy::removeRows(PyObject *args)
|
||||
int count;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "si:removeRows", &row, &count))
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
getSheetPtr()->removeRows(decodeRow(std::string(row)), count);
|
||||
Py_Return;
|
||||
@@ -314,7 +314,7 @@ PyObject* SheetPy::setStyle(PyObject *args)
|
||||
const char * options = "replace";
|
||||
|
||||
if (!PyArg_ParseTuple(args, "sO|s:setStyle", &cell, &value, &options))
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
if (PySet_Check(value)) {
|
||||
PyObject * copy = PySet_New(value);
|
||||
@@ -329,7 +329,7 @@ PyObject* SheetPy::setStyle(PyObject *args)
|
||||
std::string error = std::string("type of the set need to be a string, not ") + item->ob_type->tp_name;
|
||||
PyErr_SetString(PyExc_TypeError, error.c_str());
|
||||
Py_DECREF(copy);
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
Py_DECREF(copy);
|
||||
@@ -347,7 +347,7 @@ PyObject* SheetPy::setStyle(PyObject *args)
|
||||
else {
|
||||
std::string error = std::string("style must be either set or string, not ") + value->ob_type->tp_name;
|
||||
PyErr_SetString(PyExc_TypeError, error.c_str());
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (strcmp(options, "replace") == 0) {
|
||||
@@ -421,7 +421,7 @@ PyObject* SheetPy::setStyle(PyObject *args)
|
||||
}
|
||||
else {
|
||||
PyErr_SetString(PyExc_ValueError, "Optional parameter must be either 'replace', 'add', 'remove', or 'invert'");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Py_Return;
|
||||
@@ -433,21 +433,21 @@ PyObject* SheetPy::getStyle(PyObject *args)
|
||||
CellAddress address;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "s:getStyle", &strAddress))
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
try {
|
||||
address = stringToAddress(strAddress);
|
||||
}
|
||||
catch (const Base::Exception & e) {
|
||||
PyErr_SetString(PyExc_ValueError, e.what());
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::set<std::string> style;
|
||||
const Cell * cell = getSheetPtr()->getCell(address);
|
||||
|
||||
if (cell && cell->getStyle(style)) {
|
||||
PyObject * s = PySet_New(NULL);
|
||||
PyObject * s = PySet_New(nullptr);
|
||||
|
||||
for (std::set<std::string>::const_iterator i = style.begin(); i != style.end(); ++i)
|
||||
PySet_Add(s, PyUnicode_FromString((*i).c_str()));
|
||||
@@ -466,7 +466,7 @@ PyObject* SheetPy::setDisplayUnit(PyObject *args)
|
||||
const char * value;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "ss:setDisplayUnit", &cell, &value))
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
try {
|
||||
Range rangeIter(cell);
|
||||
@@ -477,7 +477,7 @@ PyObject* SheetPy::setDisplayUnit(PyObject *args)
|
||||
}
|
||||
catch (const Base::Exception & e) {
|
||||
PyErr_SetString(PyExc_ValueError, e.what());
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Py_Return;
|
||||
@@ -490,7 +490,7 @@ PyObject* SheetPy::setAlias(PyObject *args)
|
||||
PyObject * value;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "sO:setAlias", &strAddress, &value))
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
try {
|
||||
address = stringToAddress(strAddress);
|
||||
@@ -505,7 +505,7 @@ PyObject* SheetPy::setAlias(PyObject *args)
|
||||
}
|
||||
catch (const Base::Exception & e) {
|
||||
PyErr_SetString(PyExc_ValueError, e.what());
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -514,7 +514,7 @@ PyObject* SheetPy::getAlias(PyObject *args)
|
||||
const char * strAddress;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "s:getAlias", &strAddress))
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
try {
|
||||
CellAddress address(strAddress);
|
||||
@@ -530,7 +530,7 @@ PyObject* SheetPy::getAlias(PyObject *args)
|
||||
}
|
||||
catch (const Base::Exception & e) {
|
||||
PyErr_SetString(PyExc_ValueError, e.what());
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -539,7 +539,7 @@ PyObject* SheetPy::getCellFromAlias(PyObject *args)
|
||||
const char * alias;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "s:getAlias", &alias))
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
try {
|
||||
std::string address = getSheetPtr()->getAddressFromAlias(alias);
|
||||
@@ -553,7 +553,7 @@ PyObject* SheetPy::getCellFromAlias(PyObject *args)
|
||||
}
|
||||
catch (const Base::Exception & e) {
|
||||
PyErr_SetString(PyExc_ValueError, e.what());
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -563,7 +563,7 @@ PyObject* SheetPy::getDisplayUnit(PyObject *args)
|
||||
CellAddress address;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "s:getDisplayUnit", &strAddress))
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
try {
|
||||
address = stringToAddress(strAddress);
|
||||
@@ -579,7 +579,7 @@ PyObject* SheetPy::getDisplayUnit(PyObject *args)
|
||||
}
|
||||
catch (const Base::Exception & e) {
|
||||
PyErr_SetString(PyExc_ValueError, e.what());
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -591,7 +591,7 @@ PyObject* SheetPy::setAlignment(PyObject *args)
|
||||
const char * options = "replace";
|
||||
|
||||
if (!PyArg_ParseTuple(args, "sO|s:setAlignment", &cell, &value, &options))
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
if (PySet_Check(value)) {
|
||||
// Argument is a set of strings
|
||||
@@ -607,7 +607,7 @@ PyObject* SheetPy::setAlignment(PyObject *args)
|
||||
std::string error = std::string("type of the key need to be a string, not") + item->ob_type->tp_name;
|
||||
PyErr_SetString(PyExc_TypeError, error.c_str());
|
||||
Py_DECREF(copy);
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -629,7 +629,7 @@ PyObject* SheetPy::setAlignment(PyObject *args)
|
||||
else {
|
||||
std::string error = std::string("style must be either set or string, not ") + value->ob_type->tp_name;
|
||||
PyErr_SetString(PyExc_TypeError, error.c_str());
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Set alignment depending on 'options' variable
|
||||
@@ -660,7 +660,7 @@ PyObject* SheetPy::setAlignment(PyObject *args)
|
||||
}
|
||||
else {
|
||||
PyErr_SetString(PyExc_ValueError, "Optional parameter must be either 'replace' or 'keep'");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
Py_Return;
|
||||
}
|
||||
@@ -671,21 +671,21 @@ PyObject* SheetPy::getAlignment(PyObject *args)
|
||||
CellAddress address;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "s:getAlignment", &strAddress))
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
try {
|
||||
address = stringToAddress(strAddress);
|
||||
}
|
||||
catch (const Base::Exception & e) {
|
||||
PyErr_SetString(PyExc_ValueError, e.what());
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
int alignment;
|
||||
const Cell * cell = getSheetPtr()->getCell(address);
|
||||
if (cell && cell->getAlignment(alignment)) {
|
||||
PyObject * s = PySet_New(NULL);
|
||||
PyObject * s = PySet_New(nullptr);
|
||||
|
||||
if (alignment & Cell::ALIGNMENT_LEFT)
|
||||
PySet_Add(s, PyUnicode_FromString("left"));
|
||||
@@ -745,7 +745,7 @@ PyObject* SheetPy::setForeground(PyObject *args)
|
||||
Color c;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "sO:setForeground", &range, &value))
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
decodeColor(value, c);
|
||||
|
||||
@@ -757,11 +757,11 @@ PyObject* SheetPy::setForeground(PyObject *args)
|
||||
}
|
||||
catch (const Base::TypeError & e) {
|
||||
PyErr_SetString(PyExc_TypeError, e.what());
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
catch (const Base::Exception & e) {
|
||||
PyErr_SetString(PyExc_ValueError, e.what());
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -771,14 +771,14 @@ PyObject* SheetPy::getForeground(PyObject *args)
|
||||
CellAddress address;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "s:getForeground", &strAddress))
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
try {
|
||||
address = stringToAddress(strAddress);
|
||||
}
|
||||
catch (const Base::Exception & e) {
|
||||
PyErr_SetString(PyExc_ValueError, e.what());
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Color c;
|
||||
@@ -807,7 +807,7 @@ PyObject* SheetPy::setBackground(PyObject *args)
|
||||
Color c;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "sO:setBackground", &strAddress, &value))
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
decodeColor(value, c);
|
||||
Range rangeIter(strAddress);
|
||||
@@ -819,11 +819,11 @@ PyObject* SheetPy::setBackground(PyObject *args)
|
||||
}
|
||||
catch (const Base::TypeError & e) {
|
||||
PyErr_SetString(PyExc_TypeError, e.what());
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
catch (const Base::Exception & e) {
|
||||
PyErr_SetString(PyExc_ValueError, e.what());
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -833,14 +833,14 @@ PyObject* SheetPy::getBackground(PyObject *args)
|
||||
CellAddress address;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "s:setStyle", &strAddress))
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
try {
|
||||
address = stringToAddress(strAddress);
|
||||
}
|
||||
catch (const Base::Exception & e) {
|
||||
PyErr_SetString(PyExc_ValueError, e.what());
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Color c;
|
||||
@@ -868,7 +868,7 @@ PyObject* SheetPy::setColumnWidth(PyObject *args)
|
||||
CellAddress address;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "si:setColumnWidth", &columnStr, &width))
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
try {
|
||||
std::string cellAddr = std::string(columnStr) + "1";
|
||||
@@ -879,7 +879,7 @@ PyObject* SheetPy::setColumnWidth(PyObject *args)
|
||||
}
|
||||
catch (const Base::Exception & e) {
|
||||
PyErr_SetString(PyExc_ValueError, e.what());
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -888,7 +888,7 @@ PyObject* SheetPy::getColumnWidth(PyObject *args)
|
||||
const char * columnStr;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "s:getColumnWidth", &columnStr))
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
try {
|
||||
CellAddress address(std::string(columnStr) + "1");
|
||||
@@ -897,7 +897,7 @@ PyObject* SheetPy::getColumnWidth(PyObject *args)
|
||||
}
|
||||
catch (const Base::Exception & e) {
|
||||
PyErr_SetString(PyExc_ValueError, e.what());
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -907,7 +907,7 @@ PyObject* SheetPy::setRowHeight(PyObject *args)
|
||||
int height;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "si:setRowHeight", &rowStr, &height))
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
try {
|
||||
CellAddress address("A" + std::string(rowStr));
|
||||
@@ -917,7 +917,7 @@ PyObject* SheetPy::setRowHeight(PyObject *args)
|
||||
}
|
||||
catch (const Base::Exception & e) {
|
||||
PyErr_SetString(PyExc_ValueError, e.what());
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -926,7 +926,7 @@ PyObject* SheetPy::getRowHeight(PyObject *args)
|
||||
const char * rowStr;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "s:getRowHeight", &rowStr))
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
try {
|
||||
CellAddress address("A" + std::string(rowStr));
|
||||
@@ -935,16 +935,16 @@ PyObject* SheetPy::getRowHeight(PyObject *args)
|
||||
}
|
||||
catch (const Base::Exception & e) {
|
||||
PyErr_SetString(PyExc_ValueError, e.what());
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
PyObject *SheetPy::touchCells(PyObject *args) {
|
||||
const char *address;
|
||||
const char *address2=0;
|
||||
const char *address2=nullptr;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "s|s:touchCells", &address, &address2))
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
PY_TRY {
|
||||
std::string a1 = getSheetPtr()->getAddressFromAlias(address);
|
||||
@@ -966,10 +966,10 @@ PyObject *SheetPy::touchCells(PyObject *args) {
|
||||
|
||||
PyObject *SheetPy::recomputeCells(PyObject *args) {
|
||||
const char *address;
|
||||
const char *address2=0;
|
||||
const char *address2=nullptr;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "s|s:touchCells", &address, &address2))
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
PY_TRY {
|
||||
std::string a1 = getSheetPtr()->getAddressFromAlias(address);
|
||||
@@ -993,7 +993,7 @@ PyObject *SheetPy::recomputeCells(PyObject *args) {
|
||||
|
||||
PyObject *SheetPy::getCustomAttributes(const char*) const
|
||||
{
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int SheetPy::setCustomAttributes(const char* , PyObject* )
|
||||
|
||||
Reference in New Issue
Block a user