| 1218 | } // namespace |
| 1219 | |
| 1220 | std::vector<DocumentObject*> DocumentObject::getSubObjectList(const char* subname, |
| 1221 | std::vector<int>* const subsizes, |
| 1222 | bool flatten) const |
| 1223 | { |
| 1224 | std::vector<DocumentObject*> res; |
| 1225 | res.push_back(const_cast<DocumentObject*>(this)); |
| 1226 | if (subsizes) { |
| 1227 | subsizes->push_back(0); |
| 1228 | } |
| 1229 | if (!subname || (subname[0] == '\0')) { |
| 1230 | return res; |
| 1231 | } |
| 1232 | auto element = Data::findElementName(subname); |
| 1233 | std::string sub(subname, element - subname); |
| 1234 | App::DocumentObject* container = nullptr; |
| 1235 | |
| 1236 | bool lastChild = false; |
| 1237 | if (flatten) { |
| 1238 | auto linked = getLinkedObject(); |
| 1239 | if (linked->getExtensionByType<App::GeoFeatureGroupExtension>(true)) { |
| 1240 | container = const_cast<DocumentObject*>(this); |
| 1241 | } |
| 1242 | else if (auto grp = App::GeoFeatureGroupExtension::getGroupOfObject(linked)) { |
| 1243 | container = grp; |
| 1244 | lastChild = true; |
| 1245 | } |
| 1246 | } |
| 1247 | for (auto pos = sub.find('.'); pos != std::string::npos; pos = sub.find('.', pos + 1)) { |
| 1248 | char subTail = sub[pos + 1]; |
| 1249 | sub[pos + 1] = '\0'; |
| 1250 | auto sobj = getSubObject(sub.c_str()); |
| 1251 | if (!sobj || !sobj->isAttachedToDocument()) { |
| 1252 | continue; |
| 1253 | } |
| 1254 | |
| 1255 | if (flatten) { |
| 1256 | res = getSubObjectListFlatten(res, subsizes, sobj, &container, lastChild); |
| 1257 | } |
| 1258 | res.push_back(sobj); |
| 1259 | if (subsizes) { |
| 1260 | subsizes->push_back((int)pos + 1); |
| 1261 | } |
| 1262 | sub[pos + 1] = subTail; |
| 1263 | } |
| 1264 | return res; |
| 1265 | } |
| 1266 | |
| 1267 | std::vector<std::string> DocumentObject::getSubObjects(int reason) const |
| 1268 | { |
no test coverage detected