Free Support Forum - aspose.com

Shapes.Remove() not working(?)

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?

Thank you in advance.

Hello,

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:

GroupShape gShape = …;
gShape.Shapes.Remove(shape);

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.

OK, to hell with formatting...

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.

So... Where is the fast reply you guarantee? Is it that it only applies once, and it doesn't even need to actually be related to the problem?

P.S. About your editor: "Delete" key is also used to delete, you know?

Hello,

We are already working on your request and Shapes.Remove will return result in the next version.

What is the problem with Delete key? Everything work fine for me in Firefox and IE.

For problems with removing rectangles please provide code example how you do it and example of presentation so we could reproduce the problem.

You're still there... great!

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?

Hello,

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.

1. That's the point, I'm not doing ".FindShape(...).TextFrame", I'm just doing ".FindShape(...)", so why do I get a TextFrame?

2. Why not? I get the point you state, but given the case above that's something required.

About the first point, I think it is absolutely impossible. If you can provide any example where FindShape returns TextFrame we will fix it.

I see… I’ll check if I can send you a sample —people here don’t want to make anything public— and build you one.

Theoretically this shouldn’t happen so you can’t help me anymore, right? I’ll see what I can do.

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).

The issues you have found earlier (filed as 11083) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.