You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ki...@apache.org on 2015/07/26 01:27:46 UTC

svn commit: r1692671 - in /poi/site/publish/slideshow: how-to-shapes.html quick-guide.html xslf-cookbook.html

Author: kiwiwings
Date: Sat Jul 25 23:27:46 2015
New Revision: 1692671

URL: http://svn.apache.org/r1692671
Log:
Adapt docu to common_sl changes

Modified:
    poi/site/publish/slideshow/how-to-shapes.html
    poi/site/publish/slideshow/quick-guide.html
    poi/site/publish/slideshow/xslf-cookbook.html

Modified: poi/site/publish/slideshow/how-to-shapes.html
URL: http://svn.apache.org/viewvc/poi/site/publish/slideshow/how-to-shapes.html?rev=1692671&r1=1692670&r2=1692671&view=diff
==============================================================================
--- poi/site/publish/slideshow/how-to-shapes.html (original)
+++ poi/site/publish/slideshow/how-to-shapes.html Sat Jul 25 23:27:46 2015
@@ -231,13 +231,13 @@ if (VERSION > 3) {
                   
 <pre class="code">
     //create a new empty slide show
-    SlideShow ppt = new SlideShow();
-
+    HSLFSlideShow ppt = new HSLFSlideShow();
+    
     //add first slide
-    Slide s1 = ppt.createSlide();
-
+    HSLFSlide s1 = ppt.createSlide();
+    
     //add second slide
-    Slide s2 = ppt.createSlide();
+    HSLFSlide s2 = ppt.createSlide();
     
     //save changes in a file
     FileOutputStream out = new FileOutputStream("slideshow.ppt");
@@ -253,7 +253,7 @@ if (VERSION > 3) {
 </div>
                     
 <pre class="code">
-    SlideShow ppt = new SlideShow(new HSLFSlideShow("slideshow.ppt"));
+    HSLFSlideShow ppt = new HSLFSlideShow(new HSLFSlideShowImpl("slideshow.ppt"));
     //retrieve page size. Coordinates are expressed in points (72 dpi)
     java.awt.Dimension pgsize = ppt.getPageSize();
     int pgx = pgsize.width; //slide width
@@ -279,33 +279,31 @@ if (VERSION > 3) {
                   </p>
                     
 <pre class="code">
-  SlideShow ppt = new SlideShow(new HSLFSlideShow("slideshow.ppt"));
-  //get slides 
-  Slide[] slide = ppt.getSlides();
-  for (int i = 0; i &lt; slide.length; i++){
-    Shape[] sh = slide[i].getShapes();
-    for (int j = 0; j &lt; sh.length; j++){
-      //name of the shape
-      String name = sh[j].getShapeName();
-
-      //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];
-        //work with Line
-      } else if (sh[j] instanceof AutoShape){
-        AutoShape shape = (AutoShape)sh[j];
-        //work with AutoShape
-      } else if (sh[j] instanceof TextBox){
-        TextBox shape = (TextBox)sh[j];
-        //work with TextBox
-      } else if (sh[j] instanceof Picture){
-        Picture shape = (Picture)sh[j];
-        //work with Picture
-      }
+    HSLFSlideShow ppt = new HSLFSlideShow(new HSLFSlideShowImpl("slideshow.ppt"));
+    // get slides
+    for (HSLFSlide slide : ppt.getSlides()) {
+        for (HSLFShape sh : slide.getShapes()) {
+            // name of the shape
+            String name = sh.getShapeName();
+
+            // shapes's anchor which defines the position of this shape in the slide
+            java.awt.Rectangle anchor = sh.getAnchor();
+
+            if (sh instanceof Line) {
+                Line line = (Line) sh;
+                // work with Line
+            } else if (sh instanceof HSLFAutoShape) {
+                HSLFAutoShape shape = (HSLFAutoShape) sh;
+                // work with AutoShape
+            } else if (sh instanceof HSLFTextBox) {
+                HSLFTextBox shape = (HSLFTextBox) sh;
+                // work with TextBox
+            } else if (sh instanceof HSLFPictureShape) {
+                HSLFPictureShape shape = (HSLFPictureShape) sh;
+                // work with Picture
+            }
+        }
     }
-  }
                   </pre>
                 
                 
@@ -333,51 +331,51 @@ if (VERSION > 3) {
                    </p>
                    
 <pre class="code">
-  SlideShow ppt = new SlideShow();
-
-  Slide slide = ppt.createSlide();
-
-  //Line shape
-  Line line = new Line();
-  line.setAnchor(new java.awt.Rectangle(50, 50, 100, 20));
-  line.setLineColor(new Color(0, 128, 0));
-  line.setLineStyle(Line.LINE_DOUBLE);
-  slide.addShape(line);
-
-  //TextBox
-  TextBox txt = new TextBox();
-  txt.setText("Hello, World!");
-  txt.setAnchor(new java.awt.Rectangle(300, 100, 300, 50));
-
-  //use RichTextRun to work with the text format
-  RichTextRun rt = txt.getTextRun().getRichTextRuns()[0];
-  rt.setFontSize(32);
-  rt.setFontName("Arial");
-  rt.setBold(true);
-  rt.setItalic(true);
-  rt.setUnderlined(true);
-  rt.setFontColor(Color.red);
-  rt.setAlignment(TextBox.AlignRight);
-
-  slide.addShape(txt);
-
-  //Autoshape
-  //32-point star
-  AutoShape sh1 = new AutoShape(ShapeTypes.Star32);
-  sh1.setAnchor(new java.awt.Rectangle(50, 50, 100, 200));
-  sh1.setFillColor(Color.red);
-  slide.addShape(sh1);
-
-  //Trapezoid
-  AutoShape sh2 = new AutoShape(ShapeTypes.Trapezoid);
-  sh2.setAnchor(new java.awt.Rectangle(150, 150, 100, 200));
-  sh2.setFillColor(Color.blue);
-  slide.addShape(sh2);
-
-  FileOutputStream out = new FileOutputStream("slideshow.ppt");
-  ppt.write(out);
-  out.close();
-                    
+    HSLFSlideShow ppt = new HSLFSlideShow();
+    
+    HSLFSlide slide = ppt.createSlide();
+    
+    //Line shape
+    Line line = new Line();
+    line.setAnchor(new java.awt.Rectangle(50, 50, 100, 20));
+    line.setLineColor(new Color(0, 128, 0));
+    line.setLineCompound(LineCompound.DOUBLE);
+    slide.addShape(line);
+    
+    //TextBox
+    HSLFTextBox txt = new HSLFTextBox();
+    txt.setText("Hello, World!");
+    txt.setAnchor(new java.awt.Rectangle(300, 100, 300, 50));
+    
+    // use TextRun to work with the text format
+    HSLFTextParagraph tp = txt.getTextParagraphs().get(0);
+    tp.setAlignment(TextAlign.RIGHT);
+    HSLFTextRun rt = tp.getTextRuns().get(0);
+    rt.setFontSize(32.);
+    rt.setFontFamily("Arial");
+    rt.setBold(true);
+    rt.setItalic(true);
+    rt.setUnderlined(true);
+    rt.setFontColor(Color.red);
+    
+    slide.addShape(txt);
+    
+    // Autoshape
+    // 32-point star
+    HSLFAutoShape sh1 = new HSLFAutoShape(ShapeType.STAR_32);
+    sh1.setAnchor(new java.awt.Rectangle(50, 50, 100, 200));
+    sh1.setFillColor(Color.red);
+    slide.addShape(sh1);
+    
+    //Trapezoid
+    HSLFAutoShape sh2 = new HSLFAutoShape(ShapeType.TRAPEZOID);
+    sh2.setAnchor(new java.awt.Rectangle(150, 150, 100, 200));
+    sh2.setFillColor(Color.blue);
+    slide.addShape(sh2);
+    
+    FileOutputStream out = new FileOutputStream("slideshow.ppt");
+    ppt.write(out);
+    out.close();
                   </pre>
                 
                 
@@ -408,68 +406,66 @@ if (VERSION > 3) {
 
                     
 <pre class="code">
-  SlideShow ppt = new SlideShow(new HSLFSlideShow("slideshow.ppt"));
+    HSLFSlideShow ppt = new HSLFSlideShow(new HSLFSlideShowImpl("slideshow.ppt"));
 
-  //extract all pictures contained in the presentation
-  PictureData[] pdata = ppt.getPictureData();
-  for (int i = 0; i &lt; pdata.length; i++){
-    PictureData pict = pdata[i];
-
-    // picture data
-    byte[] data = pict.getData();
-
-    int type = pict.getType();
-    String ext;
-    switch (type){
-      case Picture.JPEG: ext=".jpg"; break;
-      case Picture.PNG: ext=".png"; break;
-      case Picture.WMF: ext=".wmf"; break;
-      case Picture.EMF: ext=".emf"; break;
-      case Picture.PICT: ext=".pict"; break;
-      default: continue;
-    }
-    FileOutputStream out = new FileOutputStream("pict_"+i + ext);
-      out.write(data);
-      out.close();
-
-  }
-
-  // add a new picture to this slideshow and insert it in a  new slide
-  int idx = ppt.addPicture(new File("clock.jpg"), Picture.JPEG);
-
-  Picture pict = new Picture(idx);
-
-  //set image position in the slide
-  pict.setAnchor(new java.awt.Rectangle(100, 100, 300, 200));
-
-  Slide slide = ppt.createSlide();
-  slide.addShape(pict);
-
-  //now retrieve pictures containes in the first slide and save them on disk
-  slide = ppt.getSlides()[0];
-  Shape[] sh = slide.getShapes();
-  for (int i = 0; i &lt; sh.length; i++){
-    if (sh[i] instanceof Picture){
-      Picture pict = (Picture)sh[i];
-      PictureData pictData = pict.getPictureData();
-      byte[] data = pictData.getData();
-      int type = pictData.getType();
-      if (type == Picture.JPEG){
-        FileOutputStream out = new FileOutputStream("slide0_"+i+".jpg");
-        out.write(data);
-        out.close();
-      } else if (type == Picture.PNG){
-        FileOutputStream out = new FileOutputStream("slide0_"+i+".png");
+    // extract all pictures contained in the presentation
+    int idx = 1;
+    for (HSLFPictureData pict : ppt.getPictureData()) {
+        // picture data
+        byte[] data = pict.getData();
+
+        int type = pict.getType();
+        String ext;
+        switch (type) {
+            case HSLFPictureShape.JPEG: ext = ".jpg"; break;
+            case HSLFPictureShape.PNG: ext = ".png"; break;
+            case HSLFPictureShape.WMF: ext = ".wmf"; break;
+            case HSLFPictureShape.EMF: ext = ".emf"; break;
+            case HSLFPictureShape.PICT: ext = ".pict"; break;
+            default: continue;
+        }
+        FileOutputStream out = new FileOutputStream("pict_" + idx + ext);
         out.write(data);
         out.close();
-      }
+        idx++;
     }
-  }
 
-  FileOutputStream out = new FileOutputStream("slideshow.ppt");
-  ppt.write(out);
-  out.close();
+    // add a new picture to this slideshow and insert it in a new slide
+    idx = ppt.addPicture(new File("clock.jpg"), HSLFPictureShape.JPEG);
 
+    HSLFPictureShape pictNew = new HSLFPictureShape(idx);
+
+    // set image position in the slide
+    pictNew.setAnchor(new java.awt.Rectangle(100, 100, 300, 200));
+
+    HSLFSlide slide = ppt.createSlide();
+    slide.addShape(pictNew);
+
+    // now retrieve pictures containes in the first slide and save them on disk
+    idx = 1;
+    slide = ppt.getSlides().get(0);
+    for (HSLFShape sh : slide.getShapes()) {
+        if (sh instanceof HSLFPictureShape) {
+            HSLFPictureShape pict = (HSLFPictureShape) sh;
+            HSLFPictureData pictData = pict.getPictureData();
+            byte[] data = pictData.getData();
+            int type = pictData.getType();
+            if (type == HSLFPictureShape.JPEG) {
+                FileOutputStream out = new FileOutputStream("slide0_" + idx + ".jpg");
+                out.write(data);
+                out.close();
+            } else if (type == HSLFPictureShape.PNG) {
+                FileOutputStream out = new FileOutputStream("slide0_" + idx + ".png");
+                out.write(data);
+                out.close();
+            }
+            idx++;
+        }
+    }
+
+    FileOutputStream out = new FileOutputStream("slideshow.ppt");
+    ppt.write(out);
+    out.close();
                     </pre>
                 
                 
@@ -480,12 +476,12 @@ if (VERSION > 3) {
 </div>
                     
 <pre class="code">
-    SlideShow ppt = new SlideShow();
-    Slide slide = ppt.createSlide();
-    TextBox title = slide.addTitle();
+    HSLFSlideShow ppt = new HSLFSlideShow();
+    HSLFSlide slide = ppt.createSlide();
+    HSLFTextBox title = slide.addTitle();
     title.setText("Hello, World!");
-    
-    //save changes 
+
+    // save changes
     FileOutputStream out = new FileOutputStream("slideshow.ppt");
     ppt.write(out);
     out.close();
@@ -508,13 +504,13 @@ if (VERSION > 3) {
 </div>
                     
 <pre class="code">
-        SlideShow ppt = new SlideShow();
-        SlideMaster master = ppt.getSlidesMasters()[0];
+    HSLFSlideShow ppt = new HSLFSlideShow();
+    HSLFSlideMaster master = ppt.getSlideMasters().get(0);
 
-        Fill fill = master.getBackground().getFill();
-        int idx = ppt.addPicture(new File("background.png"), Picture.PNG);
-        fill.setFillType(Fill.FILL_PICTURE);
-        fill.setPictureData(idx);
+    HSLFFill fill = master.getBackground().getFill();
+    int idx = ppt.addPicture(new File("background.png"), HSLFPictureShape.PNG);
+    fill.setFillType(HSLFFill.FILL_PICTURE);
+    fill.setPictureData(idx);
                   </pre>
                 
                 
@@ -524,16 +520,16 @@ if (VERSION > 3) {
 </div>
                     
 <pre class="code">
-        SlideShow ppt = new SlideShow();
-        Slide slide = ppt.createSlide();
-        
-        //This slide has its own background. 
-        //Without this line it will use master's background.
-        slide.setFollowMasterBackground(false);
-        Fill fill = slide.getBackground().getFill();
-        int idx = ppt.addPicture(new File("background.png"), Picture.PNG);
-        fill.setFillType(Fill.FILL_PATTERN);
-        fill.setPictureData(idx);
+    HSLFSlideShow ppt = new HSLFSlideShow();
+    HSLFSlide slide = ppt.createSlide();
+
+    // This slide has its own background.
+    // Without this line it will use master's background.
+    slide.setFollowMasterBackground(false);
+    HSLFFill fill = slide.getBackground().getFill();
+    int idx = ppt.addPicture(new File("background.png"), HSLFPictureShape.PNG);
+    fill.setFillType(HSLFFill.FILL_PATTERN);
+    fill.setPictureData(idx);
                   </pre>
                 
                 
@@ -543,17 +539,17 @@ if (VERSION > 3) {
 </div>
                     
 <pre class="code">
-        SlideShow ppt = new SlideShow();
-        Slide slide = ppt.createSlide();
-        
-        Shape shape = new AutoShape(ShapeTypes.Rectangle);
-        shape.setAnchor(new java.awt.Rectangle(100, 100, 200, 200));
-        Fill fill = shape.getFill();
-        fill.setFillType(Fill.FILL_SHADE);
-        fill.setBackgroundColor(Color.red);
-        fill.setForegroundColor(Color.green);
-        
-        slide.addShape(shape);
+    HSLFSlideShow ppt = new HSLFSlideShow();
+    HSLFSlide slide = ppt.createSlide();
+    
+    HSLFShape shape = new HSLFAutoShape(ShapeType.RECT);
+    shape.setAnchor(new java.awt.Rectangle(100, 100, 200, 200));
+    HSLFFill fill = shape.getFill();
+    fill.setFillType(HSLFFill.FILL_SHADE);
+    fill.setBackgroundColor(Color.red);
+    fill.setForegroundColor(Color.green);
+    
+    slide.addShape(shape);
                   </pre>
                 
                 
@@ -564,30 +560,31 @@ if (VERSION > 3) {
 </div>
                     
 <pre class="code">
-  SlideShow ppt = new SlideShow();
+    HSLFSlideShow ppt = new HSLFSlideShow();
+
+    HSLFSlide slide = ppt.createSlide();
 
-  Slide slide = ppt.createSlide();
+    HSLFTextBox shape = new HSLFTextBox();
+    HSLFTextParagraph tp = shape.getTextParagraphs().get(0);
+    tp.setBullet(true);
+    tp.setBulletChar('\u263A'); //bullet character
+    tp.setIndent(0.);  //bullet offset
+    tp.setLeftMargin(50.);   //text offset (should be greater than bullet offset)
+    HSLFTextRun rt = tp.getTextRuns().get(0);
+    shape.setText(
+        "January\r" +
+        "February\r" +
+        "March\r" +
+        "April");
+    rt.setFontSize(42.);
+    slide.addShape(shape);
 
-  TextBox shape = new TextBox();
-  RichTextRun rt = shape.getTextRun().getRichTextRuns()[0];
-  shape.setText(
-          "January\r" +
-          "February\r" +
-          "March\r" +
-          "April");
-  rt.setFontSize(42);
-  rt.setBullet(true);
-  rt.setBulletOffset(0);  //bullet offset
-  rt.setTextOffset(50);   //text offset (should be greater than bullet offset)
-  rt.setBulletChar('\u263A'); //bullet character
-  slide.addShape(shape);
-
-  shape.setAnchor(new java.awt.Rectangle(50, 50, 500, 300));  //position of the text box in the slide
-  slide.addShape(shape);
-
-  FileOutputStream out = new FileOutputStream("bullets.ppt");
-  ppt.write(out);
-  out.close();
+    shape.setAnchor(new java.awt.Rectangle(50, 50, 500, 300));  //position of the text box in the slide
+    slide.addShape(shape);
+
+    FileOutputStream out = new FileOutputStream("bullets.ppt");
+    ppt.write(out);
+    out.close();
                 </pre>
                 
                 
@@ -599,19 +596,14 @@ if (VERSION > 3) {
                     
 <pre class="code">
     FileInputStream is = new FileInputStream("slideshow.ppt");
-    SlideShow ppt = new SlideShow(is);
+    HSLFSlideShow ppt = new HSLFSlideShow(is);
     is.close();
 
-    Slide[] slide = ppt.getSlides();
-    for (int j = 0; j &lt; slide.length; j++) {
-
+    for (HSLFSlide slide : ppt.getSlides()) {
         //read hyperlinks from the text runs
-        TextRun[] txt = slide[j].getTextRuns();
-        for (int k = 0; k &lt; txt.length; k++) {
-            String text = txt[k].getText();
-            Hyperlink[] links = txt[k].getHyperlinks();
-            if(links != null) for (int l = 0; l &lt; links.length; l++) {
-                Hyperlink link = links[l];
+        for (List&lt;HSLFTextParagraph&gt; txt : slide.getTextParagraphs()) {
+            String text = HSLFTextParagraph.getText(txt);
+            for (HSLFHyperlink link : HSLFHyperlink.find(txt)) {
                 String title = link.getTitle();
                 String address = link.getAddress();
                 String substring = text.substring(link.getStartIndex(), link.getEndIndex()-1); //in ppt end index is inclusive
@@ -621,9 +613,8 @@ if (VERSION > 3) {
         //in PowerPoint you can assign a hyperlink to a shape without text,
         //for example to a Line object. The code below demonstrates how to
         //read such hyperlinks
-        Shape[] sh = slide[j].getShapes();
-        for (int k = 0; k &lt; sh.length; k++) {
-            Hyperlink link = sh[k].getHyperlink();
+        for (HSLFShape sh : slide.getShapes()) {
+            HSLFHyperlink link = sh.getHyperlink();
             if(link != null)  {
                 String title = link.getTitle();
                 String address = link.getAddress();
@@ -640,52 +631,51 @@ if (VERSION > 3) {
 </div>
                   
 <pre class="code">
-      //table data              
-      String[][] data = {
-          {"INPUT FILE", "NUMBER OF RECORDS"},
-          {"Item File", "11,559"},
-          {"Vendor File", "300"},
-          {"Purchase History File", "10,000"},
-          {"Total # of requisitions", "10,200,038"}
-      };
-
-      SlideShow ppt = new SlideShow();
-
-      Slide slide = ppt.createSlide();
-      //create a table of 5 rows and 2 columns
-      Table table = new Table(5, 2);
-      for (int i = 0; i &lt; data.length; i++) {
-          for (int j = 0; j &lt; data[i].length; j++) {
-              TableCell cell = table.getCell(i, j);
-              cell.setText(data[i][j]);
-
-              RichTextRun rt = cell.getTextRun().getRichTextRuns()[0];
-              rt.setFontName("Arial");
-              rt.setFontSize(10);
-
-              cell.setVerticalAlignment(TextBox.AnchorMiddle);
-              cell.setHorizontalAlignment(TextBox.AlignCenter);
-          }
-      }
-
-      //set table borders
-      Line border = table.createBorder();
-      border.setLineColor(Color.black);
-      border.setLineWidth(1.0);
-      table.setAllBorders(border);
-
-      //set width of the 1st column
-      table.setColumnWidth(0, 300);
-      //set width of the 2nd column
-      table.setColumnWidth(1, 150);
-
-      slide.addShape(table);
-      table.moveTo(100, 100);
-
-      FileOutputStream out = new FileOutputStream("hslf-table.ppt");
-      ppt.write(out);
-      out.close();
-    
+    //table data              
+    String[][] data = {
+        {"INPUT FILE", "NUMBER OF RECORDS"},
+        {"Item File", "11,559"},
+        {"Vendor File", "300"},
+        {"Purchase History File", "10,000"},
+        {"Total # of requisitions", "10,200,038"}
+    };
+
+    HSLFSlideShow ppt = new HSLFSlideShow();
+
+    HSLFSlide slide = ppt.createSlide();
+    //create a table of 5 rows and 2 columns
+    HSLFTable table = new HSLFTable(5, 2);
+    for (int i = 0; i &lt; data.length; i++) {
+        for (int j = 0; j &lt; data[i].length; j++) {
+            HSLFTableCell cell = table.getCell(i, j);
+            cell.setText(data[i][j]);
+
+            HSLFTextRun rt = cell.getTextParagraphs().get(0).getTextRuns().get(0);
+            rt.setFontFamily("Arial");
+            rt.setFontSize(10.);
+
+            cell.setVerticalAlignment(VerticalAlignment.MIDDLE);
+            cell.setHorizontalCentered(true);
+        }
+    }
+
+    //set table borders
+    Line border = table.createBorder();
+    border.setLineColor(Color.black);
+    border.setLineWidth(1.0);
+    table.setAllBorders(border);
+
+    //set width of the 1st column
+    table.setColumnWidth(0, 300);
+    //set width of the 2nd column
+    table.setColumnWidth(1, 150);
+
+    slide.addShape(table);
+    table.moveTo(100, 100);
+
+    FileOutputStream out = new FileOutputStream("hslf-table.ppt");
+    ppt.write(out);
+    out.close();
                     </pre>
                 
                   
@@ -697,16 +687,13 @@ if (VERSION > 3) {
 </div>
                   
 <pre class="code">
-
-        Shape[] shape = slide.getShapes();
-        for (int i = 0; i &lt; shape.length; i++) {
-    
-            //remove the shape
-            boolean ok = slide.removeShape(shape[i]);
-            if(ok){
-              //the shape was removed. Do something.
-            }
+    for (HSLFShape shape : slide.getShapes()) {
+        // remove the shape
+        boolean ok = slide.removeShape(shape);
+        if (ok) {
+            // the shape was removed. Do something.
         }
+    }
                     </pre>
                   
                 
@@ -717,20 +704,18 @@ if (VERSION > 3) {
 </div>
                   
 <pre class="code">
-
-        Shape[] shape = slide.getShapes();
-        for (int i = 0; i &lt; shape.length; i++) {
-            if (shape[i] instanceof OLEShape) {
-                OLEShape ole = (OLEShape) shape[i];
-                ObjectData data = ole.getObjectData();
-                String name = ole.getInstanceName();
-                if ("Worksheet".equals(name)) {
-                    HSSFWorkbook wb = new HSSFWorkbook(data.getData());
-                } else if ("Document".equals(name)) {
-                    HWPFDocument doc = new HWPFDocument(data.getData());
-                }
+    for (HSLFShape shape : slide.getShapes()) {
+        if (shape instanceof OLEShape) {
+            OLEShape ole = (OLEShape) shape;
+            HSLFObjectData data = ole.getObjectData();
+            String name = ole.getInstanceName();
+            if ("Worksheet".equals(name)) {
+                HSSFWorkbook wb = new HSSFWorkbook(data.getData());
+            } else if ("Document".equals(name)) {
+                HWPFDocument doc = new HWPFDocument(data.getData());
             }
         }
+    }
                     </pre>
                   
 
@@ -742,20 +727,18 @@ if (VERSION > 3) {
 </div>
                   
 <pre class="code">
+    FileInputStream is = new FileInputStream(args[0]);
+    HSLFSlideShow ppt = new HSLFSlideShow(is);
+    is.close();
 
-        FileInputStream is = new FileInputStream(args[0]);
-        SlideShow ppt = new SlideShow(is);
-        is.close();
-
-        SoundData[] sound = ppt.getSoundData();
-        for (int i = 0; i &lt; sound.length; i++) {
-            //save *WAV sounds on disk
-            if(sound[i].getSoundType().equals(".WAV")){
-                FileOutputStream out = new FileOutputStream(sound[i].getSoundName());
-                out.write(sound[i].getData());
-                out.close();
-            }
+    for (HSLFSoundData sound : ppt.getSoundData()) {
+        // save *WAV sounds on disk
+        if (sound.getSoundType().equals(".WAV")) {
+            FileOutputStream out = new FileOutputStream(sound.getSoundName());
+            out.write(sound.getData());
+            out.close();
         }
+    }
                     </pre>
                   
                   
@@ -767,21 +750,20 @@ if (VERSION > 3) {
 </div>
                   
 <pre class="code">
+    HSLFSlideShow ppt = new HSLFSlideShow();
+    HSLFSlide slide = ppt.createSlide();
 
-        SlideShow ppt = new SlideShow();
-        Slide slide = ppt.createSlide();
-
-        java.awt.geom.GeneralPath path = new java.awt.geom.GeneralPath();
-        path.moveTo(100, 100);
-        path.lineTo(200, 100);
-        path.curveTo(50, 45, 134, 22, 78, 133);
-        path.curveTo(10, 45, 134, 56, 78, 100);
-        path.lineTo(100, 200);
-        path.closePath();
-        
-        Freeform shape = new Freeform();
-        shape.setPath(path);
-        slide.addShape(shape);
+    java.awt.geom.GeneralPath path = new java.awt.geom.GeneralPath();
+    path.moveTo(100, 100);
+    path.lineTo(200, 100);
+    path.curveTo(50, 45, 134, 22, 78, 133);
+    path.curveTo(10, 45, 134, 56, 78, 100);
+    path.lineTo(100, 200);
+    path.closePath();
+
+    HSLFFreeformShape shape = new HSLFFreeformShape();
+    shape.setPath(path);
+    slide.addShape(shape);
                     </pre>
                   
 
@@ -801,52 +783,55 @@ if (VERSION > 3) {
 </div>
                   
 <pre class="code">
-        SlideShow ppt = new SlideShow();
-        Slide slide = ppt.createSlide();
+    HSLFSlideShow ppt = new HSLFSlideShow();
+    HSLFSlide slide = ppt.createSlide();
 
-        //draw a simple bar graph
-        //bar chart data. The first value is the bar color, the second is the width
-        Object[] def = new Object[]{
-            Color.yellow, new Integer(100),
-            Color.green, new Integer(150),
-            Color.gray, new Integer(75),
-            Color.red, new Integer(200),
-        };
-
-        //all objects are drawn into a shape group so we need to create one
-
-        ShapeGroup group = new ShapeGroup();
-        //define position of the drawing in the slide
-        Rectangle bounds = new java.awt.Rectangle(200, 100, 350, 300);
-        //if you want to draw in the entire slide area then define the anchor as follows:
-        //Dimension pgsize = ppt.getPageSize();
-        //java.awt.Rectangle bounds = new java.awt.Rectangle(0, 0, pgsize.width, pgsize.height);
-
-        group.setAnchor(bounds);
-        slide.addShape(group);
-
-        //draw a simple bar chart
-        Graphics2D graphics = new PPGraphics2D(group);
-        int x = bounds.x + 50, y = bounds.y + 50;
-        graphics.setFont(new Font("Arial", Font.BOLD, 10));
-        for (int i = 0, idx = 1; i &lt; def.length; i+=2, idx++) {
-            graphics.setColor(Color.black);
-            int width = ((Integer)def[i+1]).intValue();
-            graphics.drawString("Q" + idx, x-20, y+20);
-            graphics.drawString(width + "%", x + width + 10, y + 20);
-            graphics.setColor((Color)def[i]);
-            graphics.fill(new Rectangle(x, y, width, 30));
-            y += 40;
-        }
+    // draw a simple bar graph
+    // bar chart data.
+    // The first value is the bar color,
+    // the second is the width
+    Object[] def = new Object[]{
+        Color.yellow, new Integer(100),
+        Color.green, new Integer(150),
+        Color.gray, new Integer(75),
+        Color.red, new Integer(200),
+    };
+
+    // all objects are drawn into a shape group so we need to create one
+
+    HSLFGroupShape group = new HSLFGroupShape();
+    // define position of the drawing in the slide
+    Rectangle bounds = new java.awt.Rectangle(200, 100, 350, 300);
+    // if you want to draw in the entire slide area then define the anchor
+    // as follows:
+    // Dimension pgsize = ppt.getPageSize();
+    // java.awt.Rectangle bounds = new java.awt.Rectangle(0, 0,
+    // pgsize.width, pgsize.height);
+
+    group.setAnchor(bounds);
+    slide.addShape(group);
+
+    // draw a simple bar chart
+    Graphics2D graphics = new PPGraphics2D(group);
+    int x = bounds.x + 50, y = bounds.y + 50;
+    graphics.setFont(new Font("Arial", Font.BOLD, 10));
+    for (int i = 0, idx = 1; i &lt; def.length; i += 2, idx++) {
         graphics.setColor(Color.black);
-        graphics.setFont(new Font("Arial", Font.BOLD, 14));
-        graphics.draw(bounds);
-        graphics.drawString("Performance", x + 70, y + 40);
-
-        FileOutputStream out = new FileOutputStream("hslf-graphics2d.ppt");
-        ppt.write(out);
-        out.close();
+        int width = ((Integer) def[i + 1]).intValue();
+        graphics.drawString("Q" + idx, x - 20, y + 20);
+        graphics.drawString(width + "%", x + width + 10, y + 20);
+        graphics.setColor((Color) def[i]);
+        graphics.fill(new Rectangle(x, y, width, 30));
+        y += 40;
+    }
+    graphics.setColor(Color.black);
+    graphics.setFont(new Font("Arial", Font.BOLD, 14));
+    graphics.draw(bounds);
+    graphics.drawString("Performance", x + 70, y + 40);
 
+    FileOutputStream out = new FileOutputStream("hslf-graphics2d.ppt");
+    ppt.write(out);
+    out.close();
                    </pre>
                   
 
@@ -886,30 +871,31 @@ if (VERSION > 3) {
 </ul>
                   
 <pre class="code">
-        FileInputStream is = new FileInputStream("slideshow.ppt");
-        SlideShow ppt = new SlideShow(is);
-        is.close();
-        
-        Dimension pgsize = ppt.getPageSize();
+    FileInputStream is = new FileInputStream("slideshow.ppt");
+    HSLFSlideShow ppt = new HSLFSlideShow(is);
+    is.close();
 
-        Slide[] slide = ppt.getSlides();
-        for (int i = 0; i &lt; slide.length; i++) {
+    Dimension pgsize = ppt.getPageSize();
 
-            BufferedImage img = new BufferedImage(pgsize.width, pgsize.height, BufferedImage.TYPE_INT_RGB);
-            Graphics2D graphics = img.createGraphics();
-            //clear the drawing area
-            graphics.setPaint(Color.white);
-            graphics.fill(new Rectangle2D.Float(0, 0, pgsize.width, pgsize.height));
-
-            //render
-            slide[i].draw(graphics);
-
-            //save the output
-            FileOutputStream out = new FileOutputStream("slide-"  + (i+1) + ".png");
-            javax.imageio.ImageIO.write(img, "png", out);
-            out.close();
-        }
+    int idx = 1;
+    for (HSLFSlide slide : ppt.getSlides()) {
 
+        BufferedImage img = new BufferedImage(pgsize.width, pgsize.height, BufferedImage.TYPE_INT_RGB);
+        Graphics2D graphics = img.createGraphics();
+        // clear the drawing area
+        graphics.setPaint(Color.white);
+        graphics.fill(new Rectangle2D.Float(0, 0, pgsize.width, pgsize.height));
+
+        // render
+        slide.draw(graphics);
+
+        // save the output
+        FileOutputStream out = new FileOutputStream("slide-" + idx + ".png");
+        javax.imageio.ImageIO.write(img, "png", out);
+        out.close();
+
+        idx++;
+    }
                   </pre>
                   
                   
@@ -922,32 +908,29 @@ if (VERSION > 3) {
 </div>
               
 <pre class="code">
+    FileInputStream is = new FileInputStream("slideshow.ppt");
+    HSLFSlideShow ppt = new HSLFSlideShow(is);
+    is.close();
 
-          FileInputStream is = new FileInputStream("slideshow.ppt");
-          SlideShow ppt = new SlideShow(is);
-          is.close();
-          Slide[] slides = ppt.getSlides();
-
-          //presentation-scope headers / footers
-          HeadersFooters hdd = ppt.getSlideHeadersFooters();
-          if(hdd.isFooterVisible()) {
-              String footerText = hdd.getFooterText();
-          }
-
-          //per-slide headers / footers
-          for (int i=0; i &lt; slides.length; i++){
-              HeadersFooters hdd2 = slides[i].getHeadersFooters();
-              if(hdd2.isFooterVisible()) {
-                  String footerText = hdd2.getFooterText();
-              }
-              if(hdd2.isUserDateVisible()) {
-                 String customDate = hdd2.getDateTimeText();
-              }
-              if(hdd2.isSlideNumberVisible()){
-                  int slideNUm = slides[i].getSlideNumber();
-              }
+    // presentation-scope headers / footers
+    HeadersFooters hdd = ppt.getSlideHeadersFooters();
+    if (hdd.isFooterVisible()) {
+        String footerText = hdd.getFooterText();
+    }
 
-          }
+    // per-slide headers / footers
+    for (HSLFSlide slide : ppt.getSlides()) {
+        HeadersFooters hdd2 = slide.getHeadersFooters();
+        if (hdd2.isFooterVisible()) {
+            String footerText = hdd2.getFooterText();
+        }
+        if (hdd2.isUserDateVisible()) {
+            String customDate = hdd2.getDateTimeText();
+        }
+        if (hdd2.isSlideNumberVisible()) {
+            int slideNUm = slide.getSlideNumber();
+        }
+    }
                 </pre>
               
             
@@ -957,13 +940,12 @@ if (VERSION > 3) {
 </div>
               
 <pre class="code">
+    HSLFSlideShow ppt = new HSLFSlideShow();
 
-          SlideShow ppt = new SlideShow();
-
-          //presentation-scope headers / footers
-          HeadersFooters hdd = ppt.getSlideHeadersFooters();
-          hdd.setSlideNumberVisible(true);
-          hdd.setFootersText("Created by POI-HSLF");
+    // presentation-scope headers / footers
+    HeadersFooters hdd = ppt.getSlideHeadersFooters();
+    hdd.setSlideNumberVisible(true);
+    hdd.setFootersText("Created by POI-HSLF");
                 </pre>
               
         

Modified: poi/site/publish/slideshow/quick-guide.html
URL: http://svn.apache.org/viewvc/poi/site/publish/slideshow/quick-guide.html?rev=1692671&r1=1692670&r2=1692671&view=diff
==============================================================================
--- poi/site/publish/slideshow/quick-guide.html (original)
+++ poi/site/publish/slideshow/quick-guide.html Sat Jul 25 23:27:46 2015
@@ -155,21 +155,21 @@ from both.
 <h3>Specific Text Extraction</h3>
 </div>
 		
-<p>To get specific bits of text, first create a <span class="codefrag">org.apache.poi.hslf.usermodel.SlideShow</span>
-(from a <span class="codefrag">org.apache.poi.hslf.HSLFSlideShow</span>, which accepts a file or an input
+<p>To get specific bits of text, first create a <span class="codefrag">org.apache.poi.hslf.usermodel.HSLFSlideShow</span>
+(from a <span class="codefrag">org.apache.poi.hslf.usermodel.HSLFSlideShowImpl</span>, which accepts a file or an input
 stream). Use <span class="codefrag">getSlides()</span> and <span class="codefrag">getNotes()</span> to get the slides and notes.
 These can be queried to get their page ID (though they should be returned
 in the right order).</p>
 		
-<p>You can then call <span class="codefrag">getTextRuns()</span> on these, to get 
-their blocks of text. (One TextRun normally holds all the text in a 
+<p>You can then call <span class="codefrag">getTextParagraphs()</span> on these, to get 
+their blocks of text. (A list of <span class="codefrag">HSLFTextParagraph</span> normally holds all the text in a 
 given area of the page, eg in the title bar, or in a box).
-From the <span class="codefrag">TextRun</span>, you can extract the text, and check
-what type of text it is (eg Body, Title). You can allso call
-<span class="codefrag">getRichTextRuns()</span>, which will return the 
-<span class="codefrag">RichTextRun</span>s that make up the <span class="codefrag">TextRun</span>. A 
-<span class="codefrag">RichTextRun</span> is made up of a sequence of text, all having the
-same character and paragraph formatting.
+From the <span class="codefrag">HSLFTextParagraph</span>, you can extract the text, and check
+what type of text it is (eg Body, Title). You can also call
+<span class="codefrag">getTextRuns()</span>, which will return the 
+<span class="codefrag">HSLFTextRun</span>s that make up the <span class="codefrag">TextParagraph</span>. A 
+<span class="codefrag">HSLFTextRun</span> is a text fragment, having the same character formatting.
+The paragraph formatting is defined in the parent <span class="codefrag">HSLFTextParagraph</span>.
 		</p>
 		
 		
@@ -206,14 +206,16 @@ same character and paragraph formatting.
 </div>
 		
 <p>It is possible to change the text via 
-		<span class="codefrag">TextRun.setText(String)</span> or
-		<span class="codefrag">RichTextRun.setText(String)</span>. It is not yet possible
-		to add additional TextRuns or RichTextRuns.</p>
+		<span class="codefrag">HSLFTextParagraph.setText(List&lt;HSLFTextParagraph&gt;,String)</span> or
+		<span class="codefrag">HSLFTextRun.setText(String)</span>. It is possible to add additional TextRuns
+        with <span class="codefrag">HSLFTextParagraph.appendText(List&lt;HSLFTextParagraph&gt;,String,boolean)</span>
+         or <span class="codefrag">HSLFTextParagraph.addTextRun(HSLFTextRun)</span>
+</p>
 		
-<p>When calling <span class="codefrag">TextRun.setText(String)</span>, all
+<p>When calling <span class="codefrag">HSLFTextParagraph.setText(List&lt;HSLFTextParagraph&gt;,String)</span>, all
 		the text will end up with the same formatting. When calling
-		<span class="codefrag">RichTextRun.setText(String)</span>, the text will retain
-		the old formatting of that <span class="codefrag">RichTextRun</span>.
+		<span class="codefrag">HSLFTextRun.setText(String)</span>, the text will retain
+		the old formatting of that <span class="codefrag">HSLFTextRun</span>.
 		</p>
 		
 
@@ -224,10 +226,8 @@ same character and paragraph formatting.
 </div>
 		
 <p>You may add new slides by calling
-		<span class="codefrag">SlideShow.createSlide()</span>, which will add a new slide
-		to the end of the SlideShow. It is not currently possible to
-		re-order slides, nor to add new text to slides (currently only
-		adding Escher objects to new slides is supported).
+		<span class="codefrag">HSLFSlideShow.createSlide()</span>, which will add a new slide
+		to the end of the SlideShow. It is possible to re-order slides with <span class="codefrag">HSLFSlideShow.reorderSlide(...)</span>.
 		</p>
 		
 		
@@ -240,40 +240,39 @@ same character and paragraph formatting.
 <ul>
 		
 <li>
-<span class="codefrag">org.apache.poi.hslf.HSLFSlideShow</span>
+<span class="codefrag">org.apache.poi.hslf.usermodel.HSLFSlideShowImpl</span>
 		Handles reading in and writing out files. Calls 
 		<span class="codefrag">org.apache.poi.hslf.record.record</span> to build a tree
 		of all the records in the file, which it allows access to.
   		</li>
 		
 <li>
-<span class="codefrag">org.apache.poi.hslf.record.record</span>
+<span class="codefrag">org.apache.poi.hslf.record.Record</span>
 		Base class of all records. Also provides the main record generation
 		code, which will build up a tree of records for a file.
   		</li>
   		
 <li>
-<span class="codefrag">org.apache.poi.hslf.usermodel.SlideShow</span>
+<span class="codefrag">org.apache.poi.hslf.usermodel.HSLFSlideShow</span>
   Builds up model entries from the records, and presents a user facing
   view of the file
   		</li>
   		
 <li>
-<span class="codefrag">org.apache.poi.hslf.model.Slide</span>
+<span class="codefrag">org.apache.poi.hslf.usermodel.HSLFSlide</span>
   A user facing view of a Slide in a slidesow. Allows you to get at the 
   Text of the slide, and at any drawing objects on it.
   		</li>
   		
 <li>
-<span class="codefrag">org.apache.poi.hslf.model.TextRun</span>
-  Holds all the Text in a given area of the Slide, and will
-  contain one or more <span class="codefrag">RichTextRun</span>s.
+<span class="codefrag">org.apache.poi.hslf.usermodel.HSLFTextParagraph</span>
+  A list of <span class="codefrag">HSLFTextParagraph</span>s holds all the text in a given area of the Slide, and will
+  contain one or more <span class="codefrag">HSLFTextRun</span>s.
   		</li>
   		
 <li>
-<span class="codefrag">org.apache.poi.hslf.usermodel.RichTextRun</span>
-  Holds a run of text, all having the same character and
-  paragraph stylings. It is possible to modify text, and/or text stylings.
+<span class="codefrag">org.apache.poi.hslf.usermodel.HSLFTextRun</span>
+  Holds a run of text, all having the same character stylings. It is possible to modify text, and/or text stylings.
   		</li>
   		
 <li>

Modified: poi/site/publish/slideshow/xslf-cookbook.html
URL: http://svn.apache.org/viewvc/poi/site/publish/slideshow/xslf-cookbook.html?rev=1692671&r1=1692670&r2=1692671&view=diff
==============================================================================
--- poi/site/publish/slideshow/xslf-cookbook.html (original)
+++ poi/site/publish/slideshow/xslf-cookbook.html Sat Jul 25 23:27:46 2015
@@ -276,7 +276,7 @@ if (VERSION > 3) {
 
     // there can be multiple masters each referencing a number of layouts
     // for demonstration purposes we use the first (default) slide master
-    XSLFSlideMaster defaultMaster = ppt.getSlideMasters()[0];
+    XSLFSlideMaster defaultMaster = ppt.getSlideMasters().get(0);
 
     // title slide
     XSLFSlideLayout titleLayout = defaultMaster.getLayout(SlideLayout.TITLE);
@@ -323,9 +323,9 @@ if (VERSION > 3) {
                   
 <pre class="code">
     XMLSlideShow ppt = new XMLSlideShow(new FileInputStream("slideshow.pptx"));
-    XSLFSlide[] slides = ppt.getSlides();
+    List&lt;XSLFSlide&gt; slides = ppt.getSlides();
 
-    XSLFSlide thirdSlide = slides[2];
+    XSLFSlide thirdSlide = slides.get(2);
     ppt.setSlideOrder(thirdSlide, 0); // move the third slide to the beginning
                 </pre>
                 
@@ -360,30 +360,30 @@ if (VERSION > 3) {
                   </p>
                     
 <pre class="code">
-  XMLSlideShow ppt = new XMLSlideShow(new FileInputStream("slideshow.pptx"));
-  //get slides 
-  XSLFSlide[] slide = ppt.getSlides();
-  for (int i = 0; i &lt; slide.length; i++){
-    XSLFShape[] sh = slide[i].getShapes();
-    for (int j = 0; j &lt; sh.length; j++){
-      //name of the shape
-      String name = sh[j].getShapeName();
-
-      //shapes's anchor which defines the position of this shape in the slide
-      java.awt.geom.Rectangle2D anchor = sh[j].getAnchor();
-
-      if (sh[j] instanceof XSLFConnectorShape){
-        XSLFConnectorShape line = (XSLFConnectorShape)sh[j];
-        //work with Line
-      } else if (sh[j] instanceof XSLFTextShape){
-        XSLFTextShape shape = (XSLFTextShape)sh[j];
-        //work with a shape that can hold text
-      } else if (sh[j] instanceof XSLFPictureShape){
-        XSLFPictureShape shape = (XSLFPictureShape)sh[j];
-        //work with Picture
-      }
+    XMLSlideShow ppt = new XMLSlideShow(new FileInputStream("slideshow.pptx"));
+    // get slides
+    for (XSLFSlide slide : ppt.getSlides()) {
+        for (XSLFShape sh : slide.getShapes()) {
+            // name of the shape
+            String name = sh.getShapeName();
+
+            // shapes's anchor which defines the position of this shape in the slide
+            if (sh instanceof PlaceableShape) {
+                java.awt.geom.Rectangle2D anchor = ((PlaceableShape)sh).getAnchor();
+            }
+
+            if (sh instanceof XSLFConnectorShape) {
+                XSLFConnectorShape line = (XSLFConnectorShape) sh;
+                // work with Line
+            } else if (sh instanceof XSLFTextShape) {
+                XSLFTextShape shape = (XSLFTextShape) sh;
+                // work with a shape that can hold text
+            } else if (sh instanceof XSLFPictureShape) {
+                XSLFPictureShape shape = (XSLFPictureShape) sh;
+                // work with Picture
+            }
+        }
     }
-  }
                   </pre>
                 
                 
@@ -438,7 +438,7 @@ if (VERSION > 3) {
     XSLFTextRun r1 = p.addNewTextRun();
     r1.setText("The");
     r1.setFontColor(Color.blue);
-    r1.setFontSize(24);
+    r1.setFontSize(24.);
 
     XSLFTextRun r2 = p.addNewTextRun();
     r2.setText(" quick");
@@ -447,7 +447,7 @@ if (VERSION > 3) {
 
     XSLFTextRun r3 = p.addNewTextRun();
     r3.setText(" brown");
-    r3.setFontSize(12);
+    r3.setFontSize(12.);
     r3.setItalic(true);
     r3.setStrikethrough(true);
     



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