Toponaming: Transfer in getLinksTo
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
|
||||
#include <App/Document.h>
|
||||
#include <App/DocumentObject.h>
|
||||
#include <App/DocumentObserver.h>
|
||||
#include <App/Expression.h>
|
||||
#include <App/ExpressionParser.h>
|
||||
#include <App/ExpressionVisitors.h>
|
||||
@@ -2267,3 +2268,50 @@ bool PropertySheet::hasSpan() const
|
||||
{
|
||||
return !mergedCells.empty();
|
||||
}
|
||||
|
||||
void PropertySheet::getLinksTo(std::vector<App::ObjectIdentifier>& identifiers,
|
||||
App::DocumentObject* obj,
|
||||
const char* subname,
|
||||
bool all) const
|
||||
{
|
||||
Expression::DepOption option =
|
||||
all ? Expression::DepOption::DepAll : Expression::DepOption::DepNormal;
|
||||
|
||||
App::SubObjectT objT(obj, subname);
|
||||
auto sobj = objT.getSubObject();
|
||||
auto subElement = objT.getOldElementName();
|
||||
|
||||
auto owner = Base::freecad_dynamic_cast<App::DocumentObject>(getContainer());
|
||||
for (const auto& v : data) {
|
||||
if (auto expr = v.second->getExpression()) {
|
||||
const auto& deps = expr->getDeps(option);
|
||||
auto it = deps.find(obj);
|
||||
if (it == deps.end()) {
|
||||
continue;
|
||||
}
|
||||
for (auto& dep : it->second) {
|
||||
if (!subname) {
|
||||
identifiers.emplace_back(owner, v.first.toString().c_str());
|
||||
break;
|
||||
}
|
||||
bool found = false;
|
||||
for (const auto& path : dep.second) {
|
||||
if (path.getSubObjectName() == subname) {
|
||||
identifiers.emplace_back(owner, v.first.toString().c_str());
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
App::SubObjectT sobjT(obj, path.getSubObjectName().c_str());
|
||||
if (sobjT.getSubObject() == sobj && sobjT.getOldElementName() == subElement) {
|
||||
identifiers.emplace_back(owner, v.first.toString().c_str());
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,6 +78,11 @@ public:
|
||||
|
||||
void Restore(Base::XMLReader& reader) override;
|
||||
|
||||
virtual void getLinksTo(std::vector<App::ObjectIdentifier>& identifiers,
|
||||
App::DocumentObject* obj,
|
||||
const char* subname = nullptr,
|
||||
bool all = false) const override;
|
||||
|
||||
void copyCells(Base::Writer& writer, const std::vector<App::Range>& ranges) const;
|
||||
|
||||
void pasteCells(Base::XMLReader& reader, App::Range dstRange);
|
||||
|
||||
Reference in New Issue
Block a user