We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Public Slide CloneSlide(Slide-int-Presentation-SortedList);

how do I clone a Slide WITHOUT master?
origPres.CloneSlide(mySlide,myPos,targetPres,new SortedList.add(0x8000000000,0x8000000000));

Is this correct?

FEZ

The code i posted does not compile.
So my question is: Does

SortedList soli = new SortedList();
soli.Add(80000000,80000000);
orig.CloneSlide(origSlide,target.Slides.Count,target,soli);

clone a slide without a master?

FEZ

Dear FEZ,

At first, please never change last SortedList parameter by yourself. It’s not a real slide ids. It’s internal information and if you change it I can’t guarantee correct work at all.

If you really must clone slide without master then copy it with master and after that change MasterId.

So just give if a “new SortedList()” as last parameter?
Or what?

Dear FEZ,

Yes.
SortedList soli = new SortedList();
orig.CloneSlide(origSlide,target.Slides.Count,target,soli);

Well, well, well…

It works…
BUT:
It creates an own master for EVERY slide…
so if I have a presentation with 5 slides and 1 master
and I create a new one
cloning those slides as said above
the new presentation has 5 slides and 5 masters…

FEZ

Dear FEZ,

Did you read examples and comments in the blog?

Clone all slides to another presentation and create only one copy of master slides:

Presentation part1 = new Presentation(args[0]);
Presentation part2 = new Presentation(args[1]);
SortedList temp = new SortedList();
for (int i = 0; i < part2.Slides.Count; i++)
{
part2.CloneSlide(part2.Slides[ i ], part1.Slides.Count, part1, temp);
}
part1.Write(args[2]);

Clone each slide with own master slide:

Presentation part1 = new Presentation(args[0]);
Presentation part2 = new Presentation(args[1]);
SortedList temp = new SortedList();
for (int i = 0; i < part2.Slides.Count; i++)
{
temp.Clear();
part2.CloneSlide(part2.Slides[ i ], part1.Slides.Count, part1, temp);
}
part1.Write(args[2]);

BANG
MY VERY VERY OWN FAULT!!!
BangBang

I should always check my loops twice…

SORRY FOR THE BUZZ

Hmm… This code seems wrong.

The problem is this line:

part2.CloneSlide(part2.Slides[ i ], part1.Slides.Count, part1, temp);

Unfortunately, this code isn’t easily fixed.

In messing with this, it seems that any function that inserts a slide at a specific position, will “bump” any slides that already exist at that position.

To illustrate, I have a presentation (part1) with 4 slides at the following positions:
1
2
3
4

If I Clone a slide from THE SAME presentation at part1.Slides.Count (4 in this case), then it will insert the new slide at position 4 and the old position 4 slide will be position 5.

I had thought the proper line should be:

part2.CloneSlide(part2.Slides[ i ], part1.Slides.Count + 1, part1, temp);

However, when I do this, the line doesn’t work AFTER the first new slide is cloned. On the second time through the loop, an additional “master” slide has been added at Position 0, making my slide Count 6 instead of the expected 5. So it tries to insert the second slide at position 7 (Count + 1), which is incorrect now.

Matt

Dear Matthew,

As you know, slides can have different values for Slide.Position and index of slide in the Slides collection. The main idea of the new slide cloning was to set correct value for Slide.Position (“position” parameter of CloneSlide function). In the Slides collection new slides always will be added at the end. I will check setting Slide.Position values and if it’s incorrect will fix it. Thank you.

alcrus:
Dear FEZ,

Did you read examples and comments in the blog?

Clone all slides to another presentation and create only one copy of master slides:

Presentation part1 = new Presentation(args[0]);
Presentation part2 = new Presentation(args[1]);
SortedList temp = new SortedList();
for (int i = 0; i < part2.Slides.Count; i++)
{
part2.CloneSlide(part2.Slides[ i ], part1.Slides.Count, part1, temp);
}
part1.Write(args[2]);

Clone each slide with own master slide:

Presentation part1 = new Presentation(args[0]);
Presentation part2 = new Presentation(args[1]);
SortedList temp = new SortedList();
for (int i = 0; i < part2.Slides.Count; i++)
{
temp.Clear();
part2.CloneSlide(part2.Slides[ i ], part1.Slides.Count, part1, temp);
}
part1.Write(args[2]);



Following example number two, I get a presentation with one master for all slide, even though the original had 3 different masters for 10 slides. Why is that?

Kind regards
Dennis Milandt

In example 1, you are not clearing the sortedlist, it contains the master slides which have already been exported to another presentation, so that Aspose.Slides don’t export another master slide. So, it actually keeps track of which of the master slides have been exported/cloned and which ones are new ones.

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

If you will clear the list, then Aspose.Slides will lose its track and export the master slide again even if it has been exported previously.

Suppose s1, s2 and s3 are slides each have one master m1, if you will clear the sorted list while cloning the slides, then final presentation will have 6 slides instead of 4 i.e s1 and its master m1, s2 and its master m1 again, s3 and its master m1 again

Or simply

s1, s2, s3, s1m1, s2m1, s3m1