Hello,
Yes indeed another bug related to master cloning, and using the cloned layouts/masters for the slides.
Steps: This time we add all masters from “ThreeMasters.pptx” first to the “Presentation1.pptx”. Now we decide to replace all slides which are using - “Susan Master” master to the “Susan Office Theme” master in “Presentation1.pptx”. The code for doing the replacement or migration is shared as - migrateSlideMasters(Presentation ) method.
Issue: In slide 3 and 4, the charts are invisible.
Please look into this on why the charts are missing?
Probable workaround could be to reset the slide. If we reset the slide manually from MS office they become visible. How to reset slides using Aspose.Slides is our next follow up question?
Code:
public void rohitPdfBug() {
String dirUrl = “Bug - Susan Charts invisble\”;
String docxName = “ThreeMasters.pptx”;
String doclet = “Presentation1.pptx”;
Presentation sample = new Presentation(dirUrl + docxName);
Presentation dclt = new Presentation(dirUrl + doclet);
//formattingApplication(dclt, sample);
addMaster(dclt, sample);
migrateSlideMasters(dclt);
dclt.save(dirUrl + doclet + “_After_Application.pptx”, SaveFormat.Pptx);
}
static IMasterSlide getMasterByName(final IMasterSlideCollection presentationMasters, final String masterLookUp) {
final IMasterSlideCollection pptMasters = presentationMasters;
IMasterSlide desired = null;
for (IMasterSlide master : pptMasters) {
if (masterLookUp.equals(getMasterName(master))) {
desired = master;
break;
}
}
return desired;
}
static ILayoutSlide getLayoutByName(final IMasterSlide master, final String layoutName) {
ILayoutSlide layout = null;
for (final ILayoutSlide layoutAttached : master.getLayoutSlides()) {
if (layoutAttached.getName().equals(layoutName)) {
layout = layoutAttached;
break;
}
}
return layout;
}
private static void migrateSlideMasters(Presentation loadedPresentation) {
String fromMasterName = “Susan Master”;
String toMasterName = “Susan Office Theme”;
// from and to masters should be valid master names, checked all preconditions
// while creating MasterMigrationRules instance
final IMasterSlideCollection loadedMasters = loadedPresentation.getMasters();
// migrate Oracle2014 to Oracle2015
// from(Oracle2014) -> to(Oracle2015)
IMasterSlide fromMaster = getMasterByName(loadedMasters, fromMasterName);
IMasterSlide toMaster = getMasterByName(loadedMasters, toMasterName);
if (fromMaster == null || toMaster == null) {
throw new IllegalStateException(“Possible sample mismatch. The masters specified in map not found in Presentation!”);
}
if (fromMaster.hasDependingSlides()) {
IMasterLayoutSlideCollection masterLayoutCollection = fromMaster.getLayoutSlides();
Set masterLayoutCollectionList = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
for (ILayoutSlide layoutSLide : masterLayoutCollection) {
masterLayoutCollectionList.add(layoutSLide.getName());
}
for (String masterLayout : masterLayoutCollectionList) {
ILayoutSlide layout = getLayoutByName(fromMaster, masterLayout);
ILayoutSlide correspondingActualMasterLayout = getLayoutByName(toMaster, layout.getName());
if (correspondingActualMasterLayout == null) {
// New layout in toMaster, add the layout
correspondingActualMasterLayout = toMaster.getLayoutSlides().addClone(layout);
}
if (layout.hasDependingSlides()) {
final ISlide[] slides = layout.getDependingSlides();
Map<Integer, ISlide> slideMap = new TreeMap<>();
for (ISlide slide : slides) {
slideMap.put(slide.getSlideNumber(), slide);
}
for (Map.Entry<Integer, ISlide> slideIndex : slideMap.entrySet()) {
ISlide slide = slideIndex.getValue();
slide.setLayoutSlide(correspondingActualMasterLayout);
}
}
}
if (fromMaster.hasDependingSlides()) {
throw new IllegalStateException(“We just removed all dependencies”);
}
}
}
void addMaster(Presentation loadedPresentation, Presentation sampleTemplate) {
final IMasterSlideCollection loadedMasters = loadedPresentation.getMasters();
for (IMasterSlide master: sampleTemplate.getMasters()) {
loadedMasters.addClone(master);
}
}
static String getMasterName(final IMasterSlide master) {
return master.getThemeManager().getOverrideTheme().getName();
}
Hi,
I have worked with the presentation files shared by you and have been able to observe the issue specified. An issue with ID SLIDESJAVA-34939 has been created 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,
Hello,
Probable workaround could be to reset the slide. If we reset the slide manually from MS office they become visible. How to reset slides using Aspose.Slides is our next follow up question?
Do you have Slide.reset() sort of functionality?
Hi,
.
Hi Mudassir,
Do you think any workaround to charts/tables being invisible issue (SLIDESJAVA-34939)?
We can live even with some silly workaround like -
1. renaming the slide can put all charts visible again?
2. use getHidden(false), and this would solve the problem?
One promising one I could think of is - to set the coordinates again for nodes, after cloning the master from sample template but this is crappy as we need to scan before and after the document. Do you think this is better - do you know Aspose support the functionality to get/set the coordinates of tables and charts?
Do you think any better idea than this?
Hi,
First of all I have logged an issue with ID SLIDESJAVA-34952 in our issue tracking system to provide the support for reset slide as given in image shared by you. This will serve the purpose once the support will be available. Now coming to your question regarding get/set coordinates of tables and charts; I like to share that every shape has its X,Y, length and width. You can get or set these parameters by using the information given over this documentation link. Please share, if I may help you further in this regard.
Many Thanks,
The issues you have found earlier (filed as SLIDESJAVA-34939) have been fixed in this update.
This message was posted using Notification2Forum from Downloads module by Aspose Notifier.
The issues you have found earlier (filed as SLIDESJAVA-34952) have been fixed in this update.
This message was posted using Notification2Forum from Downloads module by Aspose Notifier.