| 1277 | } |
| 1278 | |
| 1279 | std::vector<std::pair<App::DocumentObject*, std::string>> |
| 1280 | DocumentObject::getParents(int depth) const |
| 1281 | { |
| 1282 | std::vector<std::pair<App::DocumentObject*, std::string>> ret; |
| 1283 | if (!isAttachedToDocument() || !GetApplication().checkLinkDepth(depth, MessageOption::Throw)) { |
| 1284 | return ret; |
| 1285 | } |
| 1286 | |
| 1287 | std::string name(getNameInDocument()); |
| 1288 | name += "."; |
| 1289 | for (auto parent : getInList()) { |
| 1290 | if (!parent || !parent->isAttachedToDocument()) { |
| 1291 | continue; |
| 1292 | } |
| 1293 | |
| 1294 | if (!parent->hasChildElement() |
| 1295 | && !parent->hasExtension(GeoFeatureGroupExtension::getExtensionClassTypeId())) { |
| 1296 | continue; |
| 1297 | } |
| 1298 | |
| 1299 | if (!parent->getSubObject(name.c_str())) { |
| 1300 | continue; |
| 1301 | } |
| 1302 | |
| 1303 | auto links = GetApplication().getLinksTo(parent, App::GetLinkRecursive); |
| 1304 | links.insert(parent); |
| 1305 | |
| 1306 | for (auto parent : links) { |
| 1307 | auto parents = parent->getParents(depth + 1); |
| 1308 | if (parents.empty()) { |
| 1309 | parents.emplace_back(parent, std::string()); |
| 1310 | } |
| 1311 | |
| 1312 | for (auto& v : parents) { |
| 1313 | ret.emplace_back(v.first, v.second + name); |
| 1314 | } |
| 1315 | } |
| 1316 | } |
| 1317 | |
| 1318 | return ret; |
| 1319 | } |
| 1320 | |
| 1321 | App::DocumentObject* DocumentObject::getFirstParent() const |
| 1322 | { |
no test coverage detected