Free Support Forum - aspose.com

Cloned Placeholder moves and has border added

Hello,

I have a presentation that I am inserting into another presentation with the four parameter cloneSlide method. There are two placeholders on the source slide. One of the placeholders on the source slide doesn't get copied to the same position on the destination slide. It is moved almost completely off the slide to the lower right hand corner. The other placeholder originally does not have a border, but after the slide is cloned, it does have a solid line border.

I have attached the two presentations and the Java code that clones the slides. "second.ppt" is cloned into "first.ppt" and written as "output.ppt". The problematic placeholders are in "second.ppt".

I am using the latest version of Aspose.Powerpoint for Java 1.4.6.0.

Thank you,
Randy Stegbauer

Dear Randy,



Are you sure you need this line?

slide.changeMaster(pres1.getMainMaster());

Hello,

Yes, I need the slide.changeMaster(), so that the Master Slide from "first.ppt" gets applied to the newly cloned slide.

I commented out the call to changeMaster and noticed that both of the problems disappeared, however I must have the Master Slide information on all the inserted slides.

Am I using changMaster() incorrectly?

Thank you,
Randy Stegbauer

Everything is ok with your code but changeMaster() function is not intended to work with such master slides.

Normal master slide should have some template placeholders.

You know “Click to edit Master title style”, “Click to edit master text styles…” and etc.



changeMaster() search text holders on a cloned slide and move it and resize to position

of template frame on a master slide.

But your master doesn’t have holders and changeMaster can’t work with it correctly.

Alexey,

I didn’t know that Master Slides are required to have Text Holders.

If Aspose.Powerpoint notices that a Master Slide doesn’t have a Text Holder, could it add a blank one to satisfy the requirement. Or at least raise an exception to notify the user that there is a potential problem.

Otherwise, would my problem be solved if I added an empty Text Holder to my Master Slide?

In other words, I’m not sure what I have to do to prevent this from happening again. I’m confused because I have been using changeMaster() on many other cloned slides without seeing this problem.

Thank you for your time and patience,
Randy Stegbauer

There are 3 possible solutions:

  1. Don’t use changeMaster() function. But that is not appropriate for you.
  2. Create normal default master slide with placeholders and after that add your own special graphics and text.
  3. Slides without Placeholders can be cloned with any Master Slide.

Alexey,

Thank you for the information.

I may be being thick here, but I don't understand what you mean by #2 above. Could you please give me more details?

During my investigation of this problem, I created two Place Holders on the Master Slide and then ran my test program that I sent you earlier in this thread.

It successfully inserted the Text Holders into the presentation in the desired position. However, the font style and size were changed to match the style and size from the Place Holders on the Master Slide. Is there a way to force the font style and size to remain the same as the style and size specified on the source slide?

Thank you for your help,
Randy Stegbauer

The main idea of changeMaster() was change position, size and style of placeholders.

I can try to rewrite it on weekends.

Alexey,

Thank you for spending so much time on this.

I assumed that the purpose of changeMaster was to overlay a new Master Slide to a cloned slide. I use the Master Slide to add headers, titles, page numbers, and copyright notices to slides that are inserted into a presentation. The Master Slide has no placeholders. I never expected changeMaster() to change anything on the original slide.

There is something I don't understand. If there are two (or more) place holders on the Master Slide and two place holders on the slide, then how does changeMaster() know which place holders to match up?

The slides that are inserted come from random users and so I cannot prevent them from using any Powerpoint feature...like Place Holders on a slide. This is going to be difficult for us because we will have to teach our users never to use Place Holders on their slides that are inserted.

Perhaps a new method should be created since this is a major change in functionality. There could be clients that depend on the current behaviour. Unless, of course, you believe the current behaviour is wrong.

Thank you,
Randy Stegbauer

Placeholders on master slide have special structure so we can identify it.



Current behavour is not wrong but your suggestion is useful too.

So I will add boolean parameter which shows should we change style of placeholders or not.

Alexey,

Excellent!!! That sounds like the perfect solution!

I have dealt with many different software vendors, and Aspose, by FAR, is the most responsive. I don't know of any other company that can match your level of support.

Thank you,
Randy Stegbauer.

Alexey,

I just downloaded the newest version of Aspose.Powerpoint for Java (1.4.7.0) and reran the testcase that I attached at the very beginning of this thread. I must be going crazy, because now it throws an exception on the cloneSlide. I was going to test the new changeMaster method, but I didn't get that far yet.

Here is the relevant code that is attempting to insert a slide from "second.ppt" into "first.ppt".

Presentation pres1 = new Presentation(new FileInputStream("first.ppt"));
Presentation pres2 = new Presentation(new FileInputStream("second.ppt"));
Slide sourceSlide = pres2.getSlideByPosition(1);
Slide slide = pres2.cloneSlide(sourceSlide, 2, pres1, new TreeMap());
slide.changeMaster(pres1.getMainMaster());
pres1.write(new FileOutputStream(new File("output.ppt")));

It throws this exception on the cloneSlide:

com.aspose.powerpoint.PptEditException: Slide cloning error.
at com.aspose.powerpoint.Presentation.cloneSlide(SourceFile:1267)
at InsertTest.main(InsertTest.java:26)
Caused by: java.lang.IndexOutOfBoundsException: Index: 2, Size: 1
at java.util.ArrayList.RangeCheck(ArrayList.java:507)
at java.util.ArrayList.get(ArrayList.java:324)
at com.aspose.powerpoint.Paragraphs.get(SourceFile:36)
at com.aspose.powerpoint.Presentation.do(SourceFile:1497)
at com.aspose.powerpoint.Presentation.do(SourceFile:1186)
at com.aspose.powerpoint.Presentation.cloneSlide(SourceFile:1255)
... 1 more

What's happening now?

Thank you,
Randy Stegbauer

Sorry, I run testcases before obfuscation and everything worked.

Please check 1.4.8 hot fix.

Alexey,

I'm sorry that I am bugging you about this so much....

I downloaded the latest version of Aspose.Powerpoint for Java 1.4.8.0, added "false" to changeMaster's parameter list and reran my testcase. It doesn't look like the placeholders on the cloned slide are getting all their properties set correctly. One placeholder has a border added and the text is left justified instead of centered. The other placeholder does not have word wrap set.

Attached is a testcase consisting of the Java source and three PPT files.

Thank you,
Randy Stegbauer

Test case from the beginning of this thread works right.

By the way, your new “first.ppt” file is wrong. I couldn’t open it by PowerPoint 2003.



As I wrote you should create master slide with template placeholders.

Each placeholder in a presentation (on normal slide) always has master shape.

That is requirement of ppt’s structure. If master slide doesn’t have any master shapes

then normal placeholders can’t be read correctly and have random errors like

black border, wrong text formatting and etc.



Another possible reason. In current version I disabled updating of text formatting

but if text has some properties by default they will be inherited from master.

Really this new feature is experimental yet and we can change it if you don’t like something.