Skip to content

Commit

Permalink
Spreadsheet: Issue #2402: Added getAlias function.
Browse files Browse the repository at this point in the history
  • Loading branch information
eivindkv authored and wwmayer committed Jan 26, 2016
1 parent 6104662 commit e8eef1d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Mod/Spreadsheet/App/SheetPy.xml
Expand Up @@ -110,6 +110,11 @@
<UserDocu>Set alias for cell address</UserDocu>
</Documentation>
</Methode>
<Methode Name="getAlias">
<Documentation>
<UserDocu>Get alias for cell address</UserDocu>
</Documentation>
</Methode>
<Methode Name="getCellFromAlias">
<Documentation>
<UserDocu>Get cell address given an alias</UserDocu>
Expand Down
25 changes: 25 additions & 0 deletions src/Mod/Spreadsheet/App/SheetPyImp.cpp
Expand Up @@ -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;
Expand Down

0 comments on commit e8eef1d

Please sign in to comment.