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

Free Support Forum - aspose.com

Call to Slide.changeMaster results in wrong Layout on slide

Hi,

after merging two presentations (adding slide from b.ppt to a.ppt) the call to changeMaster results in a wrong layout of slide b.

Presentation presentationA = new com.aspose.slides.Presentation(new FileInputStream(“d:/a.ppt”));
Presentation presentationB = new com.aspose.slides.Presentation(new FileInputStream(“d:/b.ppt”));
FileOutputStream fos = null;
try {
final SortedList sl = new SortedList();
final Slide slideB = presentationB.getSlideByPosition(1);
final Slide clonedSlide = slideB.getParent().cloneSlide(
slideB,
presentationA.getSlides().getCount() + 1,
presentationA,
sl);

clonedSlide.changeMaster(presentationA.getMainMaster());

// clonedSlide.changeMaster(presentationA.getMainMaster(), true, true);
fos = new FileOutputStream(new File(“d:/ab_with_changed_master.ppt”));
presentationA.write(fos);
} finally {
fos.close();
}

Please explain what exactly cloneSlide and changeMaster do in regards to its masters and layouts. How does “changeMaster” know which will be the new layout?

best regards,
D.Croe


Hi D.Croe,


I have worked over your requirements shared by you using our upcoming new merged API for Aspose.Slides for Java. With new version the things are cloned fine. We are scheduled to release the new release during first week of July 2014. I have used the following sample code that you will be needed to use on your end with new API. For your kind reference, the generated presentation is also attached.

public static void genClone() throws Exception
{
Presentation presentationA = new com.aspose.slides.Presentation(new FileInputStream(“c:/Presentations/a.ppt”));
Presentation presentationB = new com.aspose.slides.Presentation(new FileInputStream(“c:/Presentations/b.ppt”));
FileOutputStream fos = null;
try {
// final SortedList sl = new SortedList();
final ISlide slideB = presentationB.getSlides().get_Item(0);
presentationA.getSlides().addClone(slideB,presentationA.getMasters().get_Item(0));
// clonedSlide.changeMaster(presentationA.getMainMaster(), true, true);
fos = new FileOutputStream(new File(“c:/Presentations/ab_with_changed_master.ppt”));
presentationA.save(fos,SaveFormat.Ppt);
} finally {
fos.close();
}
}

Many Thanks,

Hi D.Croe,


I have worked over your requirements shared by you using our upcoming new merged API for Aspose.Slides for Java. With new version the things are cloned fine. We are scheduled to release the new release during first week of July 2014. I have used the following sample code that you will be needed to use on your end with new API. For your kind reference, the generated presentation is also attached.

public static void genClone() throws Exception
{
Presentation presentationA = new com.aspose.slides.Presentation(new FileInputStream(“c:/Presentations/a.ppt”));
Presentation presentationB = new com.aspose.slides.Presentation(new FileInputStream(“c:/Presentations/b.ppt”));
FileOutputStream fos = null;
try {
// final SortedList sl = new SortedList();
final ISlide slideB = presentationB.getSlides().get_Item(0);
presentationA.getSlides().addClone(slideB,presentationA.getMasters().get_Item(0));
// clonedSlide.changeMaster(presentationA.getMainMaster(), true, true);
fos = new FileOutputStream(new File(“c:/Presentations/ab_with_changed_master.ppt”));
presentationA.save(fos,SaveFormat.Ppt);
} finally {
fos.close();
}
}

Many Thanks,

Hi Mudassir,

thanks for the ppt file, but i do not understand the master(and layouts) in this result.

a.ppt and b.ppt only have 1 layout each and the result has 11 layouts!?

Slide b looks better now, but the corresponding layout doesn't have the title in green, thus where is the green color defined than?

Seems like Slide A and B uses layout at Position 6, how are the layouts chosen?

could you please explain how this "merging magic" works?

best regards,

D.Croe

Hi D.Core,

I have observed the presentation with upcoming merged API for Aspose.Slides for Java that provides single interface for both PPT and PPTX presentations. Actually, the PPT presentations have Slide Master where as the PPTX presentations have Master with Layout slides internally. The new upcoming API is based on PPTX format with support of PPT in it. This extra layouts generated for cloned presentation seems to be an issue. I have created an issue with ID SLIDESJAVA-34394 in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be automatically notified once the issue will be resolved.

We are sorry for your inconvenience,