296 obj->setColor (parentcolor); |
296 obj->setColor (parentcolor); |
297 } |
297 } |
298 |
298 |
299 // ============================================================================= |
299 // ============================================================================= |
300 // ----------------------------------------------------------------------------- |
300 // ----------------------------------------------------------------------------- |
301 List<LDObject*> LDSubfileObject::inlineContents (bool deep, bool cache) { |
301 List<LDObject*> LDSubfileObject::inlineContents (int flags) { |
302 List<LDObject*> objs, objcache; |
302 List<LDObject*> objs = fileInfo()->inlineContents (flags); |
303 |
|
304 // If we have this cached, just clone that |
|
305 if (deep && fileInfo()->cache().size()) { |
|
306 for (LDObject* obj : fileInfo()->cache()) |
|
307 objs << obj->clone(); |
|
308 } else { |
|
309 if (!deep) |
|
310 cache = false; |
|
311 |
|
312 for (LDObject* obj : *fileInfo()) { |
|
313 // Skip those without scemantic meaning |
|
314 if (!obj->isScemantic()) |
|
315 continue; |
|
316 |
|
317 // Got another sub-file reference, inline it if we're deep-inlining. If not, |
|
318 // just add it into the objects normally. Also, we only cache immediate |
|
319 // subfiles and this is not one. Yay, recursion! |
|
320 if (deep && obj->getType() == LDObject::Subfile) { |
|
321 LDSubfileObject* ref = static_cast<LDSubfileObject*> (obj); |
|
322 |
|
323 List<LDObject*> otherobjs = ref->inlineContents (true, false); |
|
324 |
|
325 for (LDObject* otherobj : otherobjs) { |
|
326 // Cache this object, if desired |
|
327 if (cache) |
|
328 objcache << otherobj->clone(); |
|
329 |
|
330 objs << otherobj; |
|
331 } |
|
332 } else { |
|
333 if (cache) |
|
334 objcache << obj->clone(); |
|
335 |
|
336 objs << obj->clone(); |
|
337 } |
|
338 } |
|
339 |
|
340 if (cache) |
|
341 fileInfo()->setCache (objcache); |
|
342 } |
|
343 |
303 |
344 // Transform the objects |
304 // Transform the objects |
345 for (LDObject* obj : objs) { |
305 for (LDObject* obj : objs) { |
346 // Set the parent now so we know what inlined this. |
306 // Set the parent now so we know what inlined this. |
347 obj->setParent (this); |
307 obj->setParent (this); |