Spreadsheet: Consistently use App::Document::Label as reference for document names when tracking dependencies.
This commit is contained in:
parent
1f94a15869
commit
1b43ca109b
|
@ -206,7 +206,7 @@ void Path::renameDocumentObject(const std::string &oldName, const std::string &n
|
|||
|
||||
void Path::renameDocument(const std::string &oldName, const std::string &newName)
|
||||
{
|
||||
if (documentNameSet && documentName == oldName) {
|
||||
if (documentName == oldName) {
|
||||
documentName = newName;
|
||||
resolve();
|
||||
}
|
||||
|
|
|
@ -800,9 +800,10 @@ void PropertySheet::addDependencies(CellAddress key)
|
|||
while (i != expressionDeps.end()) {
|
||||
const Property * prop = (*i).getProperty();
|
||||
DocumentObject * docObj = prop ? freecad_dynamic_cast<DocumentObject>(prop->getContainer()) : 0;
|
||||
Document * doc = docObj ? docObj->getDocument() : 0;
|
||||
|
||||
std::string docName = (*i).getDocumentName().getString();
|
||||
std::string docObjName = docName + "#" + (prop ? docObj->getNameInDocument() : (*i).getDocumentObjectName().getString());
|
||||
std::string docName = doc ? doc->Label.getValue() : (*i).getDocumentName().getString();
|
||||
std::string docObjName = docName + "#" + (docObj ? docObj->getNameInDocument() : (*i).getDocumentObjectName().getString());
|
||||
std::string propName = docObjName + "." + (*i).getPropertyName();
|
||||
|
||||
if (!prop)
|
||||
|
@ -820,7 +821,8 @@ void PropertySheet::addDependencies(CellAddress key)
|
|||
}
|
||||
|
||||
// Observe document to trach changes to the property
|
||||
owner->observeDocument(docName);
|
||||
if (doc)
|
||||
owner->observeDocument(doc);
|
||||
|
||||
// Insert into maps
|
||||
propertyNameToCellMap[propName].insert(key);
|
||||
|
@ -879,9 +881,12 @@ void PropertySheet::removeDependencies(CellAddress key)
|
|||
assert(k != documentObjectToCellMap.end());
|
||||
|
||||
k->second.erase(key);
|
||||
|
||||
++j;
|
||||
}
|
||||
|
||||
|
||||
|
||||
cellToDocumentObjectMap.erase(i2);
|
||||
}
|
||||
|
||||
|
@ -900,7 +905,7 @@ void PropertySheet::recomputeDependants(const Property *prop)
|
|||
assert(name != 0);
|
||||
|
||||
if (owner && name) {
|
||||
const char * docName = owner->getDocument()->getName();
|
||||
const char * docName = owner->getDocument()->Label.getValue();
|
||||
const char * nameInDoc = owner->getNameInDocument();
|
||||
|
||||
if (nameInDoc) {
|
||||
|
@ -924,7 +929,7 @@ void PropertySheet::recomputeDependants(const Property *prop)
|
|||
|
||||
void PropertySheet::invalidateDependants(const DocumentObject *docObj)
|
||||
{
|
||||
const char * docName = docObj->getDocument()->getName();
|
||||
const char * docName = docObj->getDocument()->Label.getValue();
|
||||
const char * docObjName = docObj->getNameInDocument();
|
||||
|
||||
// Touch to force recompute
|
||||
|
@ -995,7 +1000,7 @@ void PropertySheet::renamedDocument(const Document * doc)
|
|||
|
||||
void PropertySheet::recomputeDependants(const DocumentObject *docObj)
|
||||
{
|
||||
const char * docName = docObj->getDocument()->getName();
|
||||
const char * docName = docObj->getDocument()->Label.getValue();
|
||||
const char * docObjName = docObj->getNameInDocument();
|
||||
|
||||
// Touch to force recompute
|
||||
|
|
|
@ -659,7 +659,7 @@ const char *Sheet::getPropertyName(const Property *prop) const
|
|||
void Sheet::recomputeCell(CellAddress p)
|
||||
{
|
||||
Cell * cell = cells.getValue(p);
|
||||
std::string docName = getDocument()->getName();
|
||||
std::string docName = getDocument()->Label.getValue();
|
||||
std::string docObjName = std::string(getNameInDocument());
|
||||
std::string name = docName + "#" + docObjName + "." + toAddress(p);
|
||||
|
||||
|
@ -1036,7 +1036,7 @@ std::set<std::string> Sheet::dependsOn(CellAddress address) const
|
|||
|
||||
void Sheet::providesTo(CellAddress address, std::set<std::string> & result) const
|
||||
{
|
||||
const char * docName = getDocument()->getName();
|
||||
const char * docName = getDocument()->Label.getValue();
|
||||
const char * docObjName = getNameInDocument();
|
||||
std::string fullName = std::string(docName) + "#" + std::string(docObjName) + "." + toAddress(address);
|
||||
std::set<CellAddress> tmpResult = cells.getDeps(fullName);
|
||||
|
@ -1047,7 +1047,7 @@ void Sheet::providesTo(CellAddress address, std::set<std::string> & result) cons
|
|||
|
||||
void Sheet::providesTo(CellAddress address, std::set<CellAddress> & result) const
|
||||
{
|
||||
const char * docName = getDocument()->getName();
|
||||
const char * docName = getDocument()->Label.getValue();
|
||||
const char * docObjName = getNameInDocument();
|
||||
std::string fullName = std::string(docName) + "#" + std::string(docObjName) + "." + toAddress(address);
|
||||
result = cells.getDeps(fullName);
|
||||
|
@ -1062,23 +1062,25 @@ void Sheet::onDocumentRestored()
|
|||
void Sheet::onRelabledDocument(const Document &document)
|
||||
{
|
||||
cells.renamedDocument(&document);
|
||||
cells.purgeTouched();
|
||||
}
|
||||
|
||||
void Sheet::onRenamedDocument(const Document &document)
|
||||
{
|
||||
}
|
||||
|
||||
void Sheet::observeDocument(const std::string & docName)
|
||||
void Sheet::observeDocument(Document * document)
|
||||
{
|
||||
ObserverMap::const_iterator it = observers.find(docName);
|
||||
ObserverMap::const_iterator it = observers.find(document->getName());
|
||||
|
||||
if (it != observers.end()) {
|
||||
// An observer already exists, increase reference counter for it
|
||||
it->second->ref();
|
||||
}
|
||||
else {
|
||||
// Create a new observer
|
||||
SheetObserver * observer = new SheetObserver(GetApplication().getDocument(docName.c_str()), &cells);
|
||||
SheetObserver * observer = new SheetObserver(document, &cells);
|
||||
|
||||
observers[docName] = observer;
|
||||
observers[document->getName()] = observer;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -202,7 +202,7 @@ public:
|
|||
}
|
||||
//@}
|
||||
|
||||
void observeDocument(const std::string &docName);
|
||||
void observeDocument(App::Document *document);
|
||||
|
||||
protected:
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user