diff --git a/src/Mod/Spreadsheet/App/SheetPy.xml b/src/Mod/Spreadsheet/App/SheetPy.xml index e9bfaff9c7..56b6b38cb0 100644 --- a/src/Mod/Spreadsheet/App/SheetPy.xml +++ b/src/Mod/Spreadsheet/App/SheetPy.xml @@ -110,6 +110,11 @@ Set alias for cell address + + + Get alias for cell address + + Get cell address given an alias diff --git a/src/Mod/Spreadsheet/App/SheetPyImp.cpp b/src/Mod/Spreadsheet/App/SheetPyImp.cpp index 25b72a5c64..9b65085e6b 100644 --- a/src/Mod/Spreadsheet/App/SheetPyImp.cpp +++ b/src/Mod/Spreadsheet/App/SheetPyImp.cpp @@ -473,6 +473,31 @@ PyObject* SheetPy::setAlias(PyObject *args) } } +PyObject* SheetPy::getAlias(PyObject *args) +{ + const char * strAddress; + + if (!PyArg_ParseTuple(args, "s:getAlias", &strAddress)) + return 0; + + try { + CellAddress address(strAddress); + const Cell * cell = getSheetPtr()->getCell(address); + std::string alias; + + if (cell && cell->getAlias(alias)) + return Py::new_reference_to( Py::String( alias ) ); + else { + Py_INCREF(Py_None); + return Py_None; + } + } + catch (const Base::Exception & e) { + PyErr_SetString(PyExc_ValueError, e.what()); + return 0; + } +} + PyObject* SheetPy::getCellFromAlias(PyObject *args) { const char * alias;