This is a mandatory function to be able to load shapes from SVG, because the same shape may be instantiated from different places. We still need to discuss whether we need to really "share" the shape template, but for now I just deep-copy them (which is the easiest because of shape normalization problem we have). There are the following drawbacks/hacks in this patch: 1) Not all the shapes have KoShape::cloneShape() implemented! Basically, it is defined only for group shape and all the descendants of a path shape (which are the only shapes used in SVG). Other shapes use the default implementation which simply returns null. Ideally, there should be no default implementation and all the shapes should define it. But, given that we are going to deprecate quite a lot of stuff, I'll keep them just unimplemented for now. 2) The following shape properties are not yet copied during cloning: * toolDelegates * dependees * shadow * border * filterEffectStack All the properties, except of tool delegates will probably be deprecated soon. And for the tool delegates we need to invent something ingenious to handle the pointers to recover pointers to the *cloned* shapes. 3) I cannot guarantee TextShape's work anymore. I just blindly refactored it to use QScopedPointer to QTextDocument instead of the previous raw pointers trickery and never tested it. Hope it still works...
Showing with 1026 additions and 675 deletions