I'm having a weird issue with the Aspose.Slides (.Net): Shapes.Remove(Shape) is not removing the shape from the presentation. I'm passing the shapes between function calls so I can resize and move them around, as I see fit.
The shape in question are rectangles and textframes. It's troublesome that Shapes.Remove() is a void function and no excetion is thrown so I have no way to know what happened or if something ever happened... I'm driven by good faith alone.
I initially had an extension similar to: public static bool remove( this Shape shape ) { Slide slide = shape.Parent; slide.Shapes.Remove(shape); return true; // no real way to know when to return "false", right? }
When I noticed some shapes not being removed, I then used the basic code, meaning: shape.Parent.Shapes.Remove(shape);
But it still doesn't work. Can you shed some light on what should I be looking for? Is there any method I can use to ensure the shape is destroyed?
I think you have this problem with removing TextFrame only. TextFrame inherited from Shape by historical reasons but really that is part of another shape. For example Rectangle, Ellipse, AutoShape and etc. So you should delete these shapes instead of TextFrame.
Another possible reason is the shapes are inside GroupShape. In this case you should delete it from group but not from slide. There is example:
I want to tell you how mad I am because your damn "editor" removed all my text when I added a tag to see if it worked (I wanted to format the damn text for clarity!). You should really correct this dump behavior.
I first had problems with textframes, they couldn't be serialized neither removed. The workaround was to move them out of sight and recreate them at the destiny slide (they're all cloned from serialized shapes from the same template). It didn't impact much because it was 1 per slide (if any).
Question: How do I get the shape from the textframe?
I now have issues with some rectangles. As I mentioned before, I add them as streams (of serialized shapes). It turns out in some cases I need to undo those additions (removing specifically two rectangles), but it just doesn't do anything. Also, those base shapes I serialize are found via FindShape() by looking for the AltText —so it should return Shapes not TextFrames, right?
Questions: How do I know if removing a shape worked or not? How can I ensure a shape has been removed?
Note: This happened in v3.1 and now in 4.0 as well. I'm working with VS2008.
Thank you for considering a return value. On the same line, would it be possible to make Shapes class implement IList? That would also be really helpful.
The delete key wasn't working on QuickReply, it did nothing (either with text selected or not). I'm using IE 7 —not because I want to, though.
The delete problem was reduced to textframes only again. So I'm still wondering... 1. How can I get TextFrames from FindShape() if it's an 'internal' shape? 2. How can I retrieve the Shape that owns that TextFrame?
Unfortunately it’s not possible to use generics because we have to support .NET 1.1. There are many customers who still use it.
1. Shape object has TextFrame property (can be null in case shape doesn’t have a TextFrame). So you use FindShape() which returns Shape and get TextFrame object after that.
2. Vice versa is not possible. The right way is store references to Shape objects only but not to a TextFrame directly.
I finally got time to check on this, and it turns out you were right. A Shape is returned, but a reference to its TextFrame was stored instead of the Shape (not Aspose related).