Releated OLE Object

Hi Team,
here my problem is I have two ppts named as test1.ppt and test2.ppt
In the test1.ppt the second slide contain ole Object(it is also one more ppt file with two slides).

but through my application ,i am trying to add slides randomly for thouse two ppts and i want to create new ppt.

Its workin fine using the following code

String destpath = propertyManager.getDestinationPPTPath() + ModuleConstants.FOLDER_SEPARATOR + form1.getSessionID() + ".ppt";
File destFile = new File(destpath);
destIOStream = new FileInputStream(destFile);

if (!destFile.exists())
{
flag = true;
common.createPPT(destFile);
}

source = new Presentation(sourceInputStream); //i am taking the source ppts means test1.ppt are ///test2.ppt
destination = new Presentation(destInputStream);// i am creating destination ppt intial its create

//a empty ppt after i am adding slides randomly

Slide slide = source.getSlideByPosition(index); // get the source ppt slide by position

TreeMap tMap = new TreeMap();

cloneSlide(slide,destination.getSlides().getLastSlidePosition()+1, destination,tMap);


fos = new FileOutputStream(DestFilePath);
destination.write(fos);

if(flag)
{
destination.getSlides().removeAt(0);

fos = new FileOutputStream(DestFilePath);
destination.write(fos);
flag = false;
}

bean.setImageName(ModuleConstants.EMPTY_STRING + (index));
bean.setImagePath(sourcePath);
bean.setImageIndex(destinationPPTList.size());

destinationPPTList.add(bean);


But My problem is when i am adding one more slide, after test1.ppt slide 2 i am not able to add any more slides to new generated ppt some null pointer exception is coming.

And

In which way i Know the particular slide contains any OLEObjects are not.

If i found the slide contains any OLEObject and which way i rename the OLEObject.

Thanks

Vjay


.


Hi Team

Pls provide the suggestions for the further step, i am stucked in the above page,its a very urgent kind of thing.

Thanks in Advance

Vjay

Hi Vijay,


I have tried to understand the requirements shared by you and unfortunately have not been able to completely understand them. I would request you to please share the source presentation and destination presentation for further investigation. Moreover, I have observed the following line in your code snippet.

destination = new Presentation(destInputStream);// i am creating destination ppt intial its create

I want to know whether you are opening an existing presentation in the above line or trying to create an empty presentation. If you are trying to clone the slides from presentation 1 to existing presentation 2? Please share the problem again along with the a working example that you are using on your end for further investigation on our end.

Many Thanks,

Hi Mudassir Fayyaz ,

Thanks for u r reply

Actually what i am implementing is ?

I am going to create a new ppt based on the different ppts.(what exactly i am doing here is i will take different slides from different presentations randomly and create new ppt file)

Steps

1) I read one slid from test1.ppt and add to destination ppt( if the accessed slide is first slide for destination ppt than we create one empty ppt and add the accessed slide to the destination ppt ,then after adding i remove the empty slide from the destination ppt.)

2) If i select one more slide from test2.ppt and add to destination ppt(Here destination ppt is already having one slide in step1 so this slide is going to add as a second slide to the destination ppt)

3) In the same way i will add different slides from different ppts and finally create a new ppt and save the new ppt.

we reach the above process using the above code.

When i am adding normal slides(not embedded slide) for different ppts it is working fine,Suppose if i am trying to add a new slide after adding Embedded slide(which slide contains one more ppt) i am unable to add any more slides .

String destpath = propertyManager.getDestinationPPTPath() + ModuleConstants.FOLDER_SEPARATOR + form1.getSessionID() + ".ppt";
File destFile = new File(destpath);
destIOStream = new FileInputStream(destFile);

if (!destFile.exists())
{
flag = true;
common.createPPT(destFile);
}

destination = new Presentation(destIOStream);

above code destIOStream contains

firs time --------empty slide

second time --------one slide

third time --------- two slides and so on until and unless we save the destination ppt.

Please give reply as soon as possible,because i am stopped in middle

Thanks in advance.

Regards

Vjay

Hi Vijay,


I have tried to understand the issue shared by you and the code logic that you have shared is fine. I have generated the following code based on your issue. If there is still issue then please share the source presentations with me as requested earlier. I also like to know that by Embedded slides, you mean slide with Ole frames?. Once presentations will be available, I will try reproducing the issue to help you out further.

public static void AddPPTClone() throws Exception
{
try {
//Load the source presentation
Presentation srcPres = new Presentation(“D:\Aspose Data\Source2.ppt”);

//Load the source presentation
Presentation srcPres2 = new Presentation(“D:\Aspose Data\Source2.ppt”);


//Instantiate the target presentation
Presentation targetPres = new Presentation();
//Clone the source presentation to the target
for (int i = 1; i <= srcPres.getSlides().getLastSlidePosition();i++)
srcPres.cloneSlide(srcPres.getSlideByPosition(i),targetPres.getSlides().getLastSlidePosition() + 1, targetPres, new java.util.TreeMap());

//Clone the source presentation to the target
for ( i = 1; i <= srcPres2.getSlides().getLastSlidePosition();i++)
srcPres2.cloneSlide(srcPres2.getSlideByPosition(i),targetPres.getSlides().getLastSlidePosition() + 1, targetPres, new java.util.TreeMap());

//Removing Default slide
targetPres.getSlides().removeAt(0);
//Write the target presentation
targetPres.write(“D:\Aspose Data\destNew.ppt”);
}
catch (PptException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

We are sorry for your inconvenience,