Spreadsheet: change alias handling
No longer add dynamic property for alias, simply rely on get(Dynamic)PropertyByName() to check for aliases. Add new API PropertyContainer::getPropertyNamedList() so that ExpressionCompleter can discover properties with aliases.
This commit is contained in:
@@ -120,6 +120,17 @@ const Cell * PropertySheet::getValueFromAlias(const std::string &alias) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
Cell * PropertySheet::getValueFromAlias(const std::string &alias)
|
||||
{
|
||||
std::map<std::string, CellAddress>::const_iterator it = revAliasProp.find(alias);
|
||||
|
||||
if (it != revAliasProp.end())
|
||||
return getValue(it->second);
|
||||
else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
bool PropertySheet::isValidAlias(const std::string &candidate)
|
||||
{
|
||||
static const boost::regex gen("^[A-Za-z][_A-Za-z0-9]*$");
|
||||
@@ -615,9 +626,14 @@ void PropertySheet::setAlias(CellAddress address, const std::string &alias)
|
||||
Cell * cell = nonNullCellAt(address);
|
||||
assert(cell != 0);
|
||||
|
||||
if (aliasedCell != 0 && cell != aliasedCell)
|
||||
if(aliasedCell == cell)
|
||||
return;
|
||||
|
||||
if (aliasedCell)
|
||||
throw Base::ValueError("Alias already defined.");
|
||||
|
||||
AtomicPropertyChange signaller(*this);
|
||||
|
||||
/* Mark cells depending on this cell dirty; they need to be resolved when an alias changes or disappears */
|
||||
std::string fullName = owner->getFullName() + "." + address.toString();
|
||||
|
||||
@@ -632,23 +648,21 @@ void PropertySheet::setAlias(CellAddress address, const std::string &alias)
|
||||
}
|
||||
|
||||
std::string oldAlias;
|
||||
|
||||
if (cell->getAlias(oldAlias))
|
||||
owner->aliasRemoved(address, oldAlias);
|
||||
|
||||
cell->getAlias(oldAlias);
|
||||
cell->setAlias(alias);
|
||||
|
||||
if (oldAlias.size() > 0 && alias.size() > 0) {
|
||||
if (oldAlias.size() > 0) {
|
||||
std::map<App::ObjectIdentifier, App::ObjectIdentifier> m;
|
||||
|
||||
App::ObjectIdentifier key(owner, oldAlias);
|
||||
App::ObjectIdentifier value(owner, alias);
|
||||
App::ObjectIdentifier value(owner, alias.empty()?address.toString():alias);
|
||||
|
||||
m[key] = value;
|
||||
|
||||
owner->getDocument()->renameObjectIdentifiers(m);
|
||||
}
|
||||
|
||||
signaller.tryInvoke();
|
||||
}
|
||||
|
||||
void PropertySheet::setComputedUnit(CellAddress address, const Base::Unit &unit)
|
||||
|
||||
Reference in New Issue
Block a user