You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Yegor Kozlov <ye...@dinom.ru> on 2008/01/04 12:46:30 UTC

Re[2]: Cloning of slides

It's hard to tell what's wrong without a code snippet.  Lines in ppt format are separated by the carriage return character.
Looks like you are using '\n' instead of '\r'.

See an example at http://poi.apache.org/hslf/how-to-shapes.html#Bullets

Regards,
Yegor


>     
>   
>   
> Hello Yegor
>   
>  
>   
> As you advised I tried To recognize bullets by
> RichTextRun.isBullet()and To set bullets
> RichTextRun.setBullet(boolean flag).
>   
>  
>   
> But if a textbox has more than one line of bullet for eg:
>   
>  
>   
> ·         A
>   
> ·         B
>   
> ·         C
>   
> The texts A,B,C will come in one RichTextRun (Which in turn is set
> as bullet) so the output if I use RichTextRun.setBullet(boolean flag) will be
>   
>  
>   
>   
>  
>   
> -----Original Message-----
>  From: Yegor Kozlov [mailto:yegor@dinom.ru] 
>  Sent: Friday, December 28, 2007 2:52 PM
>  To: POI Users List
>  Subject: Re: Cloning of slides
>   
>  
>   
> Cloning slides is  not yet supported. You have to iterate over the
>   
> shapes and re-create them in the target slide.
>   
>  
>   
> To recognize bullets use RichTextRun.isBullet(). To set bullets use
>   
> RichTextRun.setBullet(boolean flag)
>   
>  
>   
> Support for ppt tables is in progress. I'm going to include it in
>   
> 3.0.2 FINAL. For now there is no way to clone ppt tables.
>   
>  
>   
> Regards,
>   
> Yegor
>   
>>  
>   
>  
>   
>> Hello 
>   
>  
>   
>>  
>   
>  
>   
>>             I am Ritwik currently working on presentation module for a
>   
>> product which needs creating a new presentation from two different
>   
>> presentations.
>   
>  
>   
>> What I am currently doing is:
>   
>  
>   
>>  
>   
>  
>   
>> 1.      Creating two slide shows for both the PPTs. (here we will add
>   
>> desired slide of 2nd PPT at the end of 1st)
>   
>> 2.      for each slide in the 2nd PPT
>   
>  
>   
>> *         Extract text out of textboxes, format it as its was in the
>   
>> previous slide
>   
>  
>   
>> *         Extract auto shapes
>   
>  
>   
>> *         Extract lines
>   
>  
>   
>> *         Extract pictures
>   
>  
>   
>>  
>   
>  
>   
>> 3.      Add the extracts by creating new slide at end of PPT1.
>   
>  
>   
>>  
>   
>  
>   
>>  
>   
>  
>   
>>  
>   
>  
>   
>> SlideShow ppt1 = new SlideShow(input stream of 1st ppt);
>   
>  
>   
>> SlideShow ppt2 = new SlideShow(nput stream of 2nd ppt);
>   
>  
>   
>>  
>   
>  
>   
>> Slide slide[] = ppt2.getSlides();
>   
>  
>   
>>  
>   
>  
>   
>> for(int i=0; i< slide.length; i++)
>   
>  
>   
>>         {
>   
>  
>   
>>             Slide newSlide = ppt1.createSlide();
>   
>  
>   
>>             newSlide.setFollowMasterBackground(true);
>   
>  
>   
>>             TextRun textRun[] = slide[i].getTextRuns();
>   
>  
>   
>>             Shape sh[] = slide[i].getShapes();
>   
>  
>   
>>             for (int j = 0; j < sh.length; j++)
>   
>  
>   
>>             {
>   
>  
>   
>>                 //shapes's anchor which defines the position of this shape
>   
>> in the slide
>   
>  
>   
>>                 java.awt.Rectangle anchor = sh[j].getAnchor();
>   
>  
>   
>>  
>   
>  
>   
>>                 if (sh[j] instanceof Line)
>   
>  
>   
>>                 {
>   
>  
>   
>>                     Line line = (Line)sh[j];
>   
>  
>   
>>                     Line newLine = new Line();
>   
>  
>   
>>                     newLine.setAnchor(anchor);
>   
>  
>   
>>                     newLine.setLineColor(line.getLineColor());
>   
>  
>   
>>                     newLine.setLineStyle(line.getLineStyle());
>   
>  
>   
>>                     newSlide.addShape(newLine);
>   
>  
>   
>>                 }
>   
>  
>   
>>                 else if (sh[j] instanceof AutoShape)
>   
>  
>   
>>                 {
>   
>  
>   
>>                     AutoShape shape = (AutoShape)sh[j];
>   
>  
>   
>>                     shape.setAnchor(anchor);
>   
>  
>   
>>                     newSlide.addShape(shape);
>   
>  
>   
>>                 }
>   
>  
>   
>>                 else if (sh[j] instanceof TextBox)
>   
>  
>   
>>                 {
>   
>  
>   
>>                     TextBox shape = (TextBox)sh[j];
>   
>  
>   
>>  
>   
>  
>   
>>                     TextBox txt = new TextBox();
>   
>  
>   
>>                     txt.setText(textRun[j].getText());
>   
>  
>   
>>                     txt.setAnchor(anchor);
>   
>  
>   
>>                     RichTextRun rt =
>   
>> shape.getTextRun().getRichTextRuns()[0];
>   
>  
>   
>>                     RichTextRun newRt =
>   
>> txt.getTextRun().getRichTextRuns()[0];
>   
>  
>   
>>                     newRt.setFontSize(rt.getFontSize());
>   
>  
>   
>>                     newRt.setFontName(rt.getFontName());
>   
>  
>   
>>                     newRt.setBold(rt.isBold());
>   
>  
>   
>>                     newRt.setItalic(rt.isItalic());
>   
>  
>   
>>                     newRt.setUnderlined(rt.isUnderlined());
>   
>  
>   
>>                     newRt.setFontColor(rt.getFontColor());
>   
>  
>   
>>                     newRt.setAlignment(rt.getAlignment());
>   
>  
>   
>>                     newSlide.addShape(txt);
>   
>  
>   
>>                 }
>   
>  
>   
>>                 else if (sh[j] instanceof Picture)
>   
>  
>   
>>                  {
>   
>  
>   
>>  
>   
>  
>   
>>                     Picture pict = (Picture)sh[j];
>   
>  
>   
>>                     PictureData pictData = pict.getPictureData();
>   
>  
>   
>>                     byte[] data = pictData.getData();
>   
>  
>   
>>                     int type = pictData.getType();
>   
>  
>   
>>                     int id =ppt1.addPicture(data,type);
>   
>  
>   
>>                     Picture pict1 = new Picture(id);
>   
>  
>   
>>                     //set image position in the slide
>   
>  
>   
>>                     pict1.setAnchor(anchor);
>   
>  
>   
>>                     newSlide.addShape(pict1);
>   
>  
>   
>>  
>   
>  
>   
>>                 }
>   
>  
>   
>>             }
>   
>  
>   
>>  
>   
>  
>   
>>         }
>   
>  
>   
>>  
>   
>  
>   
>>  
>   
>  
>   
>>  
>   
>  
>   
>>  
>   
>  
>   
>> In short we need to clone the slides of 2nd PPT, so is there any easier and
>   
>> efficient method to clone required slides of a PPT ???
>   
>  
>   
>>  
>   
>  
>   
>> Because currently I am facing following issues:
>   
>  
>   
>> *       Copy the TABLE from one PPT to another
>   
>> *       To recognize BULLET LIST and NUMBERED LIST and reproduce it as such
>   
>  
>   
>>  
>   
>  
>   
>>  
>   
>  
>   
>>  
>   
>  
>   
>> Thanking you,
>   
>  
>   
>> Ritwik Kumar
>   
>  
>   
>  
>   
>  
>   
> ---------------------------------------------------------------------
>   
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
>   
> For additional commands, e-mail: user-help@poi.apache.org
>   
>   
>     


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org