Free Support Forum - aspose.com

Another cloneSlides problem

Attached are two powerpoint files. The following code should copy slide 1 from from.ppt into to.ppt at position 4, but the cloneSlide method never returns.

Why does this not work, and why does Aspose not return an error condition if something is wrong?

Cheers,
Ralf.

try {
Presentation into = new Presentation(new FileInputStream(new File(“d:\temp\into.ppt”)));
Presentation from = new Presentation(new FileInputStream(new File(“d:\temp\from.ppt”)));

Slide slide = from.getSlideById(256);
Slide newSlide = from.cloneSlide(slide, 3, into, new TreeMap());

log.error(“Done”);

} catch (PptException e) {
log.error(“Caught exception”, e);
} catch (FileNotFoundException e) {
log.error(“Caught exception”, e);
}


Oh, I should also add that I downloaded the lastest version 1.6.5.0 from the web and this exhibits the same behviour. Previously I was using version 1.6.6.9 (not sure why the version number is higher!) which wa sent by e-mail about 6 weeks ago.

Found something similar I think.

was iterating though each slide in the selected ppt doc and adding them to my new document

Cloneslide died unless you fist check you are not adding a master slide !!!e.g.

if (!presentation.Slides[ i ].IsMasterSlide)

.....

Thanks for the suggestion, but that’s not it in this case.

The slide in question isn’t a master slide, as it’s ID is 256 and position is 1.

On further experimenting, it seems it’s something to do with the master layout on that powerpoint, but given that the point of this project is inserting arbitrary powerpoints into the middle of the master document, it shouldn’t matter what the layout is like on the source, it should just work…

The strange thing I found was that the the masterslide is not always the first.

(In my case all of my PPT documents contain just 1 slide)

however the slide count property tells me there are 2, so had to ignore the master one when thumbnailing/cloning etc

Yes, I know that. The master slide can appear anywhere, as they appear in the slides in the order they were created. However, getSlidePosition() returns 0 for any master slide, and positive for a real slide.

As I said before, the fact that the ID is 256 also indicates that this is a normal slide, as master slides always have one of the high bits set.

Also, the point of passing in the TreeMap is that Apsose is actually cloning the master associated with a normal slide, and uses the map to ensure that masters are only copied once. There actually should be no problem cloning a master slide, and in fact that does work fine usually. (I have done that in the past and then used deleteUnusedMasters() to remove anything that’s no longer useful.)

I am actually checking so that I only copy non-master slides in my code, but this example was a minimum complete sample that demonstrates the problem.

The problem is that certain types of slides cause Aspose to hang when cloning. This appears (from what I can tell) to be related in some way to the master slide that the slide refers to, but even so, Aspose should not hang when cloning the slide.If there’s a feature it doesn’t understand, it should return an error.

Please wait, I’m working with this problem.

Dear Ralf,

New hot fix 1.6.6.0 is available.
Please write if you have any other problems with slide cloning.

That’s fixed the problem perfectly. Thanks a lot!