]> source.dussan.org Git - poi.git/commitdiff
Commit changes in common_sl - need to update trunk ...
authorAndreas Beeker <kiwiwings@apache.org>
Mon, 11 May 2015 22:07:40 +0000 (22:07 +0000)
committerAndreas Beeker <kiwiwings@apache.org>
Mon, 11 May 2015 22:07:40 +0000 (22:07 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/branches/common_sl@1678832 13f79535-47bb-0310-9956-ffa450edef68

19 files changed:
src/examples/src/org/apache/poi/hslf/examples/Hyperlinks.java
src/examples/src/org/apache/poi/hslf/examples/PPT2PNG.java
src/examples/src/org/apache/poi/hslf/examples/SoundFinder.java
src/examples/src/org/apache/poi/hslf/examples/TableDemo.java
src/examples/src/org/apache/poi/xslf/usermodel/PieChartDemo.java
src/examples/src/org/apache/poi/xslf/usermodel/Tutorial1.java
src/examples/src/org/apache/poi/xslf/usermodel/tutorial/Step2.java
src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFHyperlink.java
src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlide.java
src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java
src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java
src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextRun.java
src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextShape.java
src/scratchpad/testcases/org/apache/poi/hslf/model/TestHyperlink.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestDocumentEncryption.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestSlideAtom.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestStyleTextPropAtom.java
src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestAddingSlides.java
src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java

index b9af6d2d56cafd273e392d8ae60315770ec90b8e..9e880825084fec21a79274cc1aab1a6ced6d24a7 100644 (file)
 
 package org.apache.poi.hslf.examples;
 
-import org.apache.poi.hslf.usermodel.*;
-
 import java.io.FileInputStream;
+import java.util.List;
+
+import org.apache.poi.hslf.usermodel.*;
 
 /**
  * Demonstrates how to read hyperlinks from  a presentation
@@ -34,44 +35,37 @@ public final class Hyperlinks {
             HSLFSlideShow ppt = new HSLFSlideShow(is);
             is.close();
 
-            HSLFSlide[] slide = ppt.getSlides();
-            for (int j = 0; j < slide.length; j++) {
-                System.out.println("slide " + slide[j].getSlideNumber());
+            for (HSLFSlide slide : ppt.getSlides()) {
+                System.out.println("\nslide " + slide.getSlideNumber());
+
+                // read hyperlinks from the slide's text runs
+                System.out.println("- reading hyperlinks from the text runs");
+                for (List<HSLFTextParagraph> txtParas : slide.getTextParagraphs()) {
+                    List<HSLFHyperlink> links = HSLFHyperlink.find(txtParas);
+                    String text = HSLFTextParagraph.getRawText(txtParas);
 
-                //read hyperlinks from the slide's text runs
-                System.out.println("reading hyperlinks from the text runs");
-                HSLFTextParagraph[] txt = slide[j].getTextParagraphs();
-                for (int k = 0; k < txt.length; k++) {
-                    String text = txt[k].getRawText();
-                    HSLFHyperlink[] links = txt[k].getHyperlinks();
-                    if(links != null) for (int l = 0; l < links.length; l++) {
-                        HSLFHyperlink link = links[l];
-                        String title = link.getTitle();
-                        String address = link.getAddress();
-                        System.out.println("  " + title);
-                        System.out.println("  " + address);
-                        String substring = text.substring(link.getStartIndex(), link.getEndIndex()-1);//in ppt end index is inclusive
-                        System.out.println("  " + substring);
+                    for (HSLFHyperlink link : links) {
+                        System.out.println(toStr(link, text));
                     }
                 }
 
-                //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
-                System.out.println("  reading hyperlinks from the slide's shapes");
-                HSLFShape[] sh = slide[j].getShapes();
-                for (int k = 0; k < sh.length; k++) {
-                    HSLFHyperlink link = sh[k].getHyperlink();
-                    if(link != null)  {
-                        String title = link.getTitle();
-                        String address = link.getAddress();
-                        System.out.println("  " + title);
-                        System.out.println("  " + address);
-                    }
+                // 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
+                System.out.println("- reading hyperlinks from the slide's shapes");
+                for (HSLFShape sh : slide.getShapes()) {
+                    HSLFHyperlink link = HSLFHyperlink.find(sh);
+                    if (link == null) continue;
+                    System.out.println(toStr(link, null));
                 }
             }
-
         }
-
    }
+
+    static String toStr(HSLFHyperlink link, String rawText) {
+        //in ppt end index is inclusive
+        String formatStr = "title: %1$s, address: %2$s" + (rawText == null ? "" : ", start: %3$s, end: %4$s, substring: %5$s");
+        String substring = (rawText == null) ? "" : rawText.substring(link.getStartIndex(), link.getEndIndex()-1);
+        return String.format(formatStr, link.getTitle(), link.getAddress(), link.getStartIndex(), link.getEndIndex(), substring);
+    }
 }
index 784d912c0ef760fcd830568949100ebbdf188874..8981c64c3c1930992bfb81e125f609c6b6ea29bd 100644 (file)
 
 package org.apache.poi.hslf.examples;
 
-import org.apache.poi.hslf.usermodel.*;
-import org.apache.poi.hslf.model.*;
+import java.awt.*;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.BufferedImage;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
 
 import javax.imageio.ImageIO;
 
-import java.io.FileOutputStream;
-import java.io.FileInputStream;
-import java.awt.*;
-import java.awt.image.BufferedImage;
-import java.awt.geom.Rectangle2D;
+import org.apache.poi.hslf.usermodel.HSLFSlide;
+import org.apache.poi.hslf.usermodel.HSLFSlideShow;
 
 /**
  * Demonstrates how you can use HSLF to convert each slide into a PNG image
@@ -70,12 +70,11 @@ public final class PPT2PNG {
         int width = (int)(pgsize.width*scale);
         int height = (int)(pgsize.height*scale);
 
-        HSLFSlide[] slide = ppt.getSlides();
-        for (int i = 0; i < slide.length; i++) {
-            if (slidenum != -1 && slidenum != (i+1)) continue;
+        for (HSLFSlide slide : ppt.getSlides()) {
+            if (slidenum != -1 && slidenum != slide.getSlideNumber()) continue;
 
-            String title = slide[i].getTitle();
-            System.out.println("Rendering slide "+slide[i].getSlideNumber() + (title == null ? "" : ": " + title));
+            String title = slide.getTitle();
+            System.out.println("Rendering slide "+slide.getSlideNumber() + (title == null ? "" : ": " + title));
 
             BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
             Graphics2D graphics = img.createGraphics();
@@ -89,9 +88,9 @@ public final class PPT2PNG {
 
             graphics.scale((double)width/pgsize.width, (double)height/pgsize.height);
 
-            slide[i].draw(graphics);
+            slide.draw(graphics);
 
-            String fname = file.replaceAll("\\.ppt", "-" + (i+1) + ".png");
+            String fname = file.replaceAll("\\.ppt", "-" + slide.getSlideNumber() + ".png");
             FileOutputStream out = new FileOutputStream(fname);
             ImageIO.write(img, "png", out);
             out.close();
index 7ebbea9f17fa659e17a2b6a95cc610fd01929be5..3cdb101be55ee4f8946725635be9670a5aa4beec 100644 (file)
    limitations under the License.
 ==================================================================== */
 package org.apache.poi.hslf.examples;
-import org.apache.poi.ddf.*;
-import org.apache.poi.hslf.model.*;
-import org.apache.poi.hslf.record.InteractiveInfo;
-import org.apache.poi.hslf.record.InteractiveInfoAtom;
-import org.apache.poi.hslf.record.Record;
-import org.apache.poi.hslf.usermodel.*;
-
 import java.io.FileInputStream;
 import java.util.Iterator;
 import java.util.List;
 
+import org.apache.poi.ddf.*;
+import org.apache.poi.hslf.record.*;
+import org.apache.poi.hslf.usermodel.*;
+
 /**
  * For each slide iterate over shapes and found associated sound data.
  *
@@ -36,16 +33,15 @@ public class SoundFinder {
         HSLFSlideShow ppt = new HSLFSlideShow(new FileInputStream(args[0]));
         HSLFSoundData[] sounds = ppt.getSoundData();
 
-        HSLFSlide[] slide = ppt.getSlides();
-        for (int i = 0; i < slide.length; i++) {
-            HSLFShape[] shape = slide[i].getShapes();
-            for (int j = 0; j < shape.length; j++) {
-                int soundRef = getSoundReference(shape[j]);
-                if(soundRef != -1) {
-                    System.out.println("Slide["+i+"], shape["+j+"], soundRef: "+soundRef);
-                    System.out.println("  " + sounds[soundRef].getSoundName());
-                    System.out.println("  " + sounds[soundRef].getSoundType());
-                }
+        for (HSLFSlide slide : ppt.getSlides()) {
+            for (HSLFShape shape : slide.getShapes()) {
+                int soundRef = getSoundReference(shape);
+                if(soundRef == -1) continue;
+
+                
+                System.out.println("Slide["+slide.getSlideNumber()+"], shape["+shape.getShapeId()+"], soundRef: "+soundRef);
+                System.out.println("  " + sounds[soundRef].getSoundName());
+                System.out.println("  " + sounds[soundRef].getSoundType());
             }
         }
     }
index 1d03e1b6f12d148710c0de9ee9b7e3eccf9f128b..bb2e813865c949af0bd1e01ef2e0a50d291e3aa2 100644 (file)
@@ -19,6 +19,8 @@ package org.apache.poi.hslf.examples;
 
 import org.apache.poi.hslf.usermodel.*;
 import org.apache.poi.hslf.model.*;
+import org.apache.poi.sl.usermodel.TextParagraph.TextAlign;
+import org.apache.poi.sl.usermodel.VerticalAlignment;
 
 import java.awt.*;
 import java.io.FileOutputStream;
@@ -51,8 +53,7 @@ public final class TableDemo {
         for (int i = 0; i < txt1.length; i++) {
             for (int j = 0; j < txt1[i].length; j++) {
                 TableCell cell = table1.getCell(i, j);
-                cell.setText(txt1[i][j]);
-                HSLFTextRun rt = cell.getTextParagraphs().getTextRuns()[0];
+                HSLFTextRun rt = cell.getTextParagraphs().get(0).getTextRuns().get(0);
                 rt.setFontName("Arial");
                 rt.setFontSize(10);
                 if(i == 0){
@@ -60,8 +61,9 @@ public final class TableDemo {
                 } else {
                     rt.setBold(true);
                 }
-                cell.setVerticalAlignment(HSLFTextBox.AnchorMiddle);
-                cell.setHorizontalAlignment(HSLFTextBox.AlignCenter);
+                cell.setVerticalAlignment(VerticalAlignment.MIDDLE);
+                cell.setHorizontalCentered(true);
+                cell.setText(txt1[i][j]);
             }
         }
 
@@ -90,8 +92,7 @@ public final class TableDemo {
         for (int i = 0; i < txt2.length; i++) {
             for (int j = 0; j < txt2[i].length; j++) {
                 TableCell cell = table2.getCell(i, j);
-                cell.setText(txt2[i][j]);
-                HSLFTextRun rt = cell.getTextParagraphs().getTextRuns()[0];
+                HSLFTextRun rt = cell.getTextParagraphs().get(0).getTextRuns().get(0);
                 rt.setFontSize(10);
                 rt.setFontName("Arial");
                 if(i == 0){
@@ -99,13 +100,15 @@ public final class TableDemo {
                     rt.setFontColor(Color.white);
                     rt.setBold(true);
                     rt.setFontSize(14);
-                    cell.setHorizontalAlignment(HSLFTextBox.AlignCenter);
+                    cell.setHorizontalCentered(true);
                 } else {
-                    rt.setBullet(true);
+                    rt.getTextParagraph().setBullet(true);
                     rt.setFontSize(12);
-                    cell.setHorizontalAlignment(HSLFTextBox.AlignLeft);
+                    rt.getTextParagraph().setAlignment(TextAlign.LEFT);
+                    cell.setHorizontalCentered(false);
                 }
-                cell.setVerticalAlignment(HSLFTextBox.AnchorMiddle);
+                cell.setVerticalAlignment(VerticalAlignment.MIDDLE);
+                cell.setText(txt2[i][j]);
             }
         }
         table2.setColumnWidth(0, 300);
index de90c52d20716241ee0ee4cb23236fdb2485e893..e399d3d0ed42919932c1f2a76874a504bbfe446a 100644 (file)
@@ -67,7 +67,7 @@ public class PieChartDemo {
             String chartTitle = modelReader.readLine();  // first line is chart title\r
     \r
             XMLSlideShow pptx = new XMLSlideShow(new FileInputStream(args[0]));\r
-            XSLFSlide slide = pptx.getSlides()[0];\r
+            XSLFSlide slide = pptx.getSlides().get(0);\r
     \r
             // find chart in the slide\r
             XSLFChart chart = null;\r
index 93d437b913513d5f12b1cc7081e25340d7bccd2b..458b987320c0f3b8168720b046ab69eaace8d8d6 100644 (file)
@@ -37,7 +37,7 @@ public class Tutorial1 {
         /*XSLFSlide blankSlide =*/ ppt.createSlide();\r
 \r
         \r
-        XSLFSlideMaster master = ppt.getSlideMasters()[0];\r
+        XSLFSlideMaster master = ppt.getSlideMasters().get(0);\r
 \r
         XSLFSlideLayout layout1 = master.getLayout(SlideLayout.TITLE);\r
         XSLFSlide slide1 = ppt.createSlide(layout1) ;\r
index b006eb86a121df8e839d469a4f82796cb211fac1..cd01d60c8ca9a7a790377d009e16b2650e5da61d 100644 (file)
@@ -49,7 +49,7 @@ public class Step2 {
         // blank slide
         /*XSLFSlide blankSlide =*/ ppt.createSlide();
 
-        XSLFSlideMaster defaultMaster = ppt.getSlideMasters()[0];
+        XSLFSlideMaster defaultMaster = ppt.getSlideMasters().get(0);
 
         // title slide
         XSLFSlideLayout titleLayout = defaultMaster.getLayout(SlideLayout.TITLE);
index baead9e31c198d058a1412a56eb8b099289e4982..02608b74a3b0b25fa412ae7c919f564a31b7c733 100644 (file)
@@ -146,50 +146,31 @@ public final class HSLFHyperlink {
      * @param shape  <code>TextRun</code> to lookup hyperlinks in
      * @return found hyperlinks or <code>null</code> if not found
      */
-    public static HSLFHyperlink[] find(HSLFTextShape shape){
-        List<HSLFHyperlink> lst = new ArrayList<HSLFHyperlink>();
-        HSLFSlideShow ppt = shape.getSheet().getSlideShow();
-        //document-level container which stores info about all links in a presentation
-        ExObjList exobj = ppt.getDocumentRecord().getExObjList();
-        if (exobj == null) {
-            return null;
-        }
-        
-        Record[] records = shape.getClientRecords();
-        find(records, exobj, lst);
-
-        HSLFHyperlink[] links = null;
-        if (lst.size() > 0){
-            links = new HSLFHyperlink[lst.size()];
-            lst.toArray(links);
-        }
-        return links;
+    public static List<HSLFHyperlink> find(HSLFTextShape shape){
+        return find(shape.getTextParagraphs());
     }
 
     /**
      * Find hyperlinks in a text paragraph
      *
-     * @param paragraph  <code>TextParagraph</code> to lookup hyperlinks in
-     * @return found hyperlinks or <code>null</code> if not found
+     * @param paragraphs  List of <code>TextParagraph</code> to lookup hyperlinks
+     * @return found hyperlinks
      */
-    public static HSLFHyperlink[] find(HSLFTextParagraph paragraph){
+    public static List<HSLFHyperlink> find(List<HSLFTextParagraph> paragraphs){
         List<HSLFHyperlink> lst = new ArrayList<HSLFHyperlink>();
-        HSLFSlideShow ppt = paragraph.getSheet().getSlideShow();
+        if (paragraphs == null || paragraphs.isEmpty()) return lst;
+
+        HSLFTextParagraph firstPara = paragraphs.get(0);
+        
+        HSLFSlideShow ppt = firstPara.getSheet().getSlideShow();
         //document-level container which stores info about all links in a presentation
         ExObjList exobj = ppt.getDocumentRecord().getExObjList();
-        if (exobj == null) {
-            return null;
-        }
+        if (exobj == null) return lst;
         
-        Record[] records = paragraph.getRecords();
+        Record[] records = firstPara.getRecords();
         find(records, exobj, lst);
 
-        HSLFHyperlink[] links = null;
-        if (lst.size() > 0){
-            links = new HSLFHyperlink[lst.size()];
-            lst.toArray(links);
-        }
-        return links;
+        return lst;
     }
 
     /**
@@ -224,24 +205,24 @@ public final class HSLFHyperlink {
         if (records == null) return;
         for (int i = 0; i < records.length; i++) {
             //see if we have InteractiveInfo in the textrun's records
-            if( records[i] instanceof InteractiveInfo){
-                InteractiveInfo hldr = (InteractiveInfo)records[i];
-                InteractiveInfoAtom info = hldr.getInteractiveInfoAtom();
-                int id = info.getHyperlinkID();
-                ExHyperlink linkRecord = exobj.get(id);
-                if (linkRecord != null){
-                    HSLFHyperlink link = new HSLFHyperlink();
-                    link.title = linkRecord.getLinkTitle();
-                    link.address = linkRecord.getLinkURL();
-                    link.type = info.getAction();
-
-                    if (++i < records.length && records[i] instanceof TxInteractiveInfoAtom){
-                        TxInteractiveInfoAtom txinfo = (TxInteractiveInfoAtom)records[i];
-                        link.startIndex = txinfo.getStartIndex();
-                        link.endIndex = txinfo.getEndIndex();
-                    }
-                    out.add(link);
-                }
+            if(!(records[i] instanceof InteractiveInfo)) continue;
+            
+            InteractiveInfo hldr = (InteractiveInfo)records[i];
+            InteractiveInfoAtom info = hldr.getInteractiveInfoAtom();
+            int id = info.getHyperlinkID();
+            ExHyperlink linkRecord = exobj.get(id);
+            if (linkRecord == null) continue;
+            
+            HSLFHyperlink link = new HSLFHyperlink();
+            link.title = linkRecord.getLinkTitle();
+            link.address = linkRecord.getLinkURL();
+            link.type = info.getAction();
+            out.add(link);
+
+            if (i+1 < records.length && records[i+1] instanceof TxInteractiveInfoAtom){
+                TxInteractiveInfoAtom txinfo = (TxInteractiveInfoAtom)records[++i];
+                link.startIndex = txinfo.getStartIndex();
+                link.endIndex = txinfo.getEndIndex();
             }
         }
     }
index 2fbd5c201f083ffe9b1e2e9ef88c911e82b53a54..048655fa6407b721fa122d80298c83aeced90e5b 100644 (file)
@@ -62,8 +62,8 @@ public final class HSLFSlide extends HSLFSheet implements Slide<HSLFShape,HSLFSl
                // Build up TextRuns from pairs of TextHeaderAtom and
                //  one of TextBytesAtom or TextCharsAtom
                if (_atomSet != null && _atomSet.getSlideRecords().length > 0) {
-                   List<List<HSLFTextParagraph>> llhtp = HSLFTextParagraph.findTextParagraphs(_atomSet.getSlideRecords());
-                   _paragraphs.addAll(llhtp);
+                   // Grab text from SlideListWithTexts entries
+                   _paragraphs.addAll(HSLFTextParagraph.findTextParagraphs(_atomSet.getSlideRecords()));
                if (_paragraphs.isEmpty()) {
                    throw new RuntimeException("No text records found for slide");
                }
@@ -71,23 +71,14 @@ public final class HSLFSlide extends HSLFSheet implements Slide<HSLFShape,HSLFSl
                        // No text on the slide, must just be pictures
                }
 
-               // Grab text from SlideListWithTexts entries
-               for(List<HSLFTextParagraph> ltp : _paragraphs) {
-                   for (HSLFTextParagraph tp : ltp) {
-                       tp.supplySheet(this);
-                   }
-               }
+               // Grab text from slide's PPDrawing
+               _paragraphs.addAll(HSLFTextParagraph.findTextParagraphs(getPPDrawing()));
 
-        // Grab the TextRuns from the PPDrawing
-               List<List<HSLFTextParagraph>> llOtherRuns = HSLFTextParagraph.findTextParagraphs(getPPDrawing());
-               for (List<HSLFTextParagraph> otherRuns : llOtherRuns) {
-               // Grab text from slide's PPDrawing
-               for(HSLFTextParagraph tp : otherRuns) {
-                   tp.supplySheet(this);
-                   tp.setIndex(-1); // runs found in PPDrawing are not linked with SlideListWithTexts
-               }
-               }
-        _paragraphs.addAll(llOtherRuns);
+        for(List<HSLFTextParagraph> ltp : _paragraphs) {
+            for (HSLFTextParagraph tp : ltp) {
+                tp.supplySheet(this);
+            }
+        }
        }
 
        /**
@@ -449,19 +440,19 @@ public final class HSLFSlide extends HSLFSheet implements Slide<HSLFShape,HSLFSl
 
        public void setHidden(boolean hidden) {
                org.apache.poi.hslf.record.Slide cont = getSlideRecord();
-               
-               SSSlideInfoAtom slideInfo = 
+
+               SSSlideInfoAtom slideInfo =
                        (SSSlideInfoAtom)cont.findFirstOfType(RecordTypes.SSSlideInfoAtom.typeID);
                if (slideInfo == null) {
                        slideInfo = new SSSlideInfoAtom();
                        cont.addChildAfter(slideInfo, cont.findFirstOfType(RecordTypes.SlideAtom.typeID));
                }
-               
+
                slideInfo.setEffectTransitionFlagByBit(SSSlideInfoAtom.HIDDEN_BIT, hidden);
        }
-       
+
        public boolean getHidden() {
-               SSSlideInfoAtom slideInfo = 
+               SSSlideInfoAtom slideInfo =
                        (SSSlideInfoAtom)getSlideRecord().findFirstOfType(RecordTypes.SSSlideInfoAtom.typeID);
                return (slideInfo == null)
                        ? false
@@ -475,6 +466,6 @@ public final class HSLFSlide extends HSLFSheet implements Slide<HSLFShape,HSLFSl
 
     public void setFollowMasterColourScheme(boolean follow) {
         // TODO Auto-generated method stub
-        
+
     }
 }
index cf91e5695394e18a9fe17a9571f9c5283cc3c593..62784f533b5febaf740df33a750c45e76c768b28 100644 (file)
@@ -613,7 +613,7 @@ public final class HSLFSlideShow implements SlideShow {
                SlideAtomsSet[] sas = slwt.getSlideAtomsSets();
 
                List<Record> records = new ArrayList<Record>();
-               List<SlideAtomsSet> sa = Arrays.asList(sas);
+               List<SlideAtomsSet> sa = new ArrayList<SlideAtomsSet>(Arrays.asList(sas));
 
                HSLFSlide removedSlide = _slides.remove(index);
                _notes.remove(removedSlide.getNotes());
index 7d76efe8daa4a89ef8c8b3cdcec2b8b3132deac5..b9c02dc7f34c6f4e2f0d6a2b32d4e0933065efa1 100644 (file)
@@ -668,11 +668,33 @@ public final class HSLFTextParagraph implements TextParagraph<HSLFTextRun> {
        prop.setSubValue(value,index);\r
    }\r
 \r
+   /**\r
+    * Check and add linebreaks to text runs leading other paragraphs\r
+    *\r
+    * @param paragraphs\r
+    */\r
+   protected static void fixLineEndings(List<HSLFTextParagraph> paragraphs) {\r
+       HSLFTextRun lastRun = null;\r
+       for (HSLFTextParagraph p : paragraphs) {\r
+           if (lastRun != null && !lastRun.getRawText().endsWith("\r")) {\r
+               lastRun.setText(lastRun.getRawText()+"\r");\r
+           }\r
+           List<HSLFTextRun> ltr = p.getTextRuns();\r
+           if (ltr.isEmpty()) {\r
+               throw new RuntimeException("paragraph without textruns found");\r
+           }\r
+           lastRun = ltr.get(ltr.size()-1);\r
+           assert(lastRun.getRawText() != null);\r
+       }       \r
+   }\r
+   \r
    /**\r
     * Saves the modified paragraphs/textrun to the records.\r
     * Also updates the styles to the correct text length.\r
     */\r
    protected static void storeText(List<HSLFTextParagraph> paragraphs) {\r
+       fixLineEndings(paragraphs);\r
+       \r
        String rawText = toInternalString(getRawText(paragraphs));\r
 \r
        // Will it fit in a 8 bit atom?\r
@@ -738,16 +760,16 @@ public final class HSLFTextParagraph implements TextParagraph<HSLFTextRun> {
        \r
        styleAtom.clearStyles();\r
        \r
-       TextPropCollection lastPTPC = null, lastRTPC = null;\r
+       TextPropCollection lastPTPC = null, lastRTPC = null, ptpc = null, rtpc = null;\r
        for (HSLFTextParagraph para : paragraphs) {\r
-           TextPropCollection ptpc = para.getParagraphStyle();\r
+           ptpc = para.getParagraphStyle();\r
            ptpc.updateTextSize(0);\r
            if (!ptpc.equals(lastPTPC)) {\r
                lastPTPC = styleAtom.addParagraphTextPropCollection(0);\r
                lastPTPC.copy(ptpc);\r
            }\r
            for (HSLFTextRun tr : para.getTextRuns()) {\r
-               TextPropCollection rtpc = tr.getCharacterStyle();\r
+               rtpc = tr.getCharacterStyle();\r
                rtpc.updateTextSize(0);\r
                if (!rtpc.equals(lastRTPC)) {\r
                    lastRTPC = styleAtom.addCharacterTextPropCollection(0);\r
@@ -761,7 +783,9 @@ public final class HSLFTextParagraph implements TextParagraph<HSLFTextRun> {
            }\r
        }\r
        \r
-       assert(lastPTPC != null && lastRTPC != null);\r
+       assert(lastPTPC != null && lastRTPC != null && ptpc != null && rtpc != null);\r
+       ptpc.updateTextSize(ptpc.getCharactersCovered()+1);\r
+       rtpc.updateTextSize(rtpc.getCharactersCovered()+1);\r
        lastPTPC.updateTextSize(lastPTPC.getCharactersCovered()+1);\r
        lastRTPC.updateTextSize(lastRTPC.getCharactersCovered()+1);\r
        \r
@@ -817,6 +841,8 @@ public final class HSLFTextParagraph implements TextParagraph<HSLFTextRun> {
            }\r
            htr.setText(rawText);\r
        }\r
+\r
+       storeText(paragraphs);\r
        \r
        return htr;\r
    }\r
@@ -909,16 +935,7 @@ public final class HSLFTextParagraph implements TextParagraph<HSLFTextRun> {
    public static List<List<HSLFTextParagraph>> findTextParagraphs(PPDrawing ppdrawing) {\r
        List<List<HSLFTextParagraph>> runsV = new ArrayList<List<HSLFTextParagraph>>();\r
        for (EscherTextboxWrapper wrapper : ppdrawing.getTextboxWrappers()) {\r
-           // propagate parents to parent-aware records\r
-           RecordContainer.handleParentAwareRecords(wrapper);\r
-           int shapeId = wrapper.getShapeId();\r
-           List<List<HSLFTextParagraph>> rv = findTextParagraphs(wrapper);\r
-           for (List<HSLFTextParagraph> htpList : rv) {\r
-               for (HSLFTextParagraph htp : htpList) {\r
-                   htp.setShapeId(shapeId);\r
-               }\r
-           }\r
-           runsV.addAll(rv);\r
+           runsV.addAll(findTextParagraphs(wrapper));\r
        }\r
        return runsV;\r
    }\r
@@ -940,8 +957,17 @@ public final class HSLFTextParagraph implements TextParagraph<HSLFTextRun> {
     *\r
     * @param wrapper an EscherTextboxWrapper\r
     */\r
-   protected static List<List<HSLFTextParagraph>> findTextParagraphs(final EscherTextboxWrapper wrapper) {\r
-       return findTextParagraphs(wrapper.getChildRecords(), wrapper.getStyleTextProp9Atom());\r
+   protected static List<List<HSLFTextParagraph>> findTextParagraphs(EscherTextboxWrapper wrapper) {\r
+       // propagate parents to parent-aware records\r
+       RecordContainer.handleParentAwareRecords(wrapper);\r
+       int shapeId = wrapper.getShapeId();\r
+       List<List<HSLFTextParagraph>> rv = findTextParagraphs(wrapper.getChildRecords(), wrapper.getStyleTextProp9Atom());\r
+       for (List<HSLFTextParagraph> htpList : rv) {\r
+           for (HSLFTextParagraph htp : htpList) {\r
+               htp.setShapeId(shapeId);\r
+           }\r
+       }\r
+       return rv;\r
    }\r
 \r
    /**\r
@@ -999,7 +1025,8 @@ public final class HSLFTextParagraph implements TextParagraph<HSLFTextRun> {
             }\r
         \r
             assert(header != null);\r
-            if (header.getIndex() == -1) {\r
+            if (header.getParentRecord() instanceof SlideListWithText) {\r
+                // runs found in PPDrawing are not linked with SlideListWithTexts\r
                 header.setIndex(slwtIndex);\r
             }\r
             \r
index e94c8446491263fabc55cdaad3c3195370d3a991..d06715b173f43b7364cf9be8207cb458c247bfeb 100644 (file)
@@ -383,6 +383,10 @@ public final class HSLFTextRun implements TextRun {
         prop.setSubValue(value, index);
     }
 
+    public HSLFTextParagraph getTextParagraph() {
+        return parentParagraph;
+    }
+    
     public TextCap getTextCap() {
         return TextCap.NONE;
     }
index d431f0bac4f67d03fd1937f099c6a5f96d232148..e05ae79a60a4815c8663d74a35f5d0584c0a5808 100644 (file)
@@ -750,7 +750,7 @@ public abstract class HSLFTextShape extends HSLFSimpleShape implements TextShape
      * @return the array of all hyperlinks in this text run or <code>null</code>
      *         if not found.
      */
-    public HSLFHyperlink[] getHyperlinks() {
+    public List<HSLFHyperlink> getHyperlinks() {
         return HSLFHyperlink.find(this);
     }
 
index 5438ac8af94b4a7128cd293c3876b8a985c0d7b4..5429b96fbc718660e3acafd2ea32a8454d72e8a9 100644 (file)
@@ -53,17 +53,17 @@ public final class TestHyperlink {
             "In addition, its notes has one link";
         assertEquals(expected, rawText);
         
-        HSLFHyperlink[] links = HSLFHyperlink.find(para.get(1));
+        List<HSLFHyperlink> links = HSLFHyperlink.find(para);
         assertNotNull(links);
-        assertEquals(2, links.length);
+        assertEquals(2, links.size());
 
-        assertEquals("http://jakarta.apache.org/poi/", links[0].getTitle());
-        assertEquals("http://jakarta.apache.org/poi/", links[0].getAddress());
-        assertEquals("http://jakarta.apache.org/poi/", rawText.substring(links[0].getStartIndex(), links[0].getEndIndex()-1));
+        assertEquals("http://jakarta.apache.org/poi/", links.get(0).getTitle());
+        assertEquals("http://jakarta.apache.org/poi/", links.get(0).getAddress());
+        assertEquals("http://jakarta.apache.org/poi/", rawText.substring(links.get(0).getStartIndex(), links.get(0).getEndIndex()-1));
 
-        assertEquals("http://slashdot.org/", links[1].getTitle());
-        assertEquals("http://slashdot.org/", links[1].getAddress());
-        assertEquals("http://slashdot.org/", rawText.substring(links[1].getStartIndex(), links[1].getEndIndex()-1));
+        assertEquals("http://slashdot.org/", links.get(1).getTitle());
+        assertEquals("http://slashdot.org/", links.get(1).getAddress());
+        assertEquals("http://slashdot.org/", rawText.substring(links.get(1).getStartIndex(), links.get(1).getEndIndex()-1));
 
         slide = ppt.getSlides().get(1);
         para = slide.getTextParagraphs().get(1);
@@ -73,12 +73,12 @@ public final class TestHyperlink {
             "Jakarta HSSF";
         assertEquals(expected, rawText);
 
-        links = HSLFHyperlink.find(para.get(1));
+        links = HSLFHyperlink.find(para);
         assertNotNull(links);
-        assertEquals(1, links.length);
+        assertEquals(1, links.size());
 
-        assertEquals("http://jakarta.apache.org/poi/hssf/", links[0].getTitle());
-        assertEquals("http://jakarta.apache.org/poi/hssf/", links[0].getAddress());
-        assertEquals("Jakarta HSSF", rawText.substring(links[0].getStartIndex(), links[0].getEndIndex()-1));
+        assertEquals("http://jakarta.apache.org/poi/hssf/", links.get(0).getTitle());
+        assertEquals("http://jakarta.apache.org/poi/hssf/", links.get(0).getAddress());
+        assertEquals("Jakarta HSSF", rawText.substring(links.get(0).getStartIndex(), links.get(0).getEndIndex()-1));
     }
 }
index 4f23e4998bccd3c5b9f01118be04ae02e5fd0ef6..7176c504e786de62ff9c3c7b1015dfde577ad450 100644 (file)
@@ -143,8 +143,9 @@ public class TestDocumentEncryption {
         HSLFSlideShowImpl hss = new HSLFSlideShowImpl(fs);\r
         HSLFSlideShow ss = new HSLFSlideShow(hss);\r
         \r
-        HSLFSlide slide = ss.getSlides()[0];\r
-        assertEquals("Dominic Salemno", slide.getTextParagraphs()[0].getRawText());\r
+        HSLFSlide slide = ss.getSlides().get(0);\r
+        String rawText = HSLFTextParagraph.getRawText(slide.getTextParagraphs().get(0));\r
+        assertEquals("Dominic Salemno", rawText);\r
 \r
         String picCmp[][] = {\r
             {"0","nKsDTKqxTCR8LFkVVWlP9GSTvZ0="},\r
index 4dad61a6cb7cd2ac5d51f952839fecdd15e926d9..447a7646b1a96ad5931a1a1e21015ec639697710 100644 (file)
@@ -85,8 +85,8 @@ public final class TestSlideAtom extends TestCase {
                ss.write(bos);
                ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
                ss = new HSLFSlideShow(bis);
-               slide1 = ss.getSlides()[0];
-               slide2 = ss.getSlides()[1];
+               slide1 = ss.getSlides().get(0);
+               slide2 = ss.getSlides().get(1);
                assertFalse(slide1.getHidden());
                assertTrue(slide2.getHidden());
        }
index 665c86e691d1bf343768aad21508b07f84a87559..e0e2de515a796e4549a3c405f7c1d158f1ef95f1 100644 (file)
@@ -21,13 +21,11 @@ import static org.junit.Assert.assertArrayEquals;
 
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
-import java.util.LinkedList;
+import java.util.List;
 
 import junit.framework.TestCase;
 
-import org.apache.poi.hslf.model.textproperties.CharFlagsTextProp;
-import org.apache.poi.hslf.model.textproperties.TextProp;
-import org.apache.poi.hslf.model.textproperties.TextPropCollection;
+import org.apache.poi.hslf.model.textproperties.*;
 import org.apache.poi.util.HexDump;
 
 /**
@@ -188,7 +186,7 @@ public final class TestStyleTextPropAtom extends TestCase {
         stpb.setParentTextSize(data_b_text_len);
 
         // 54 chars, 21 + 17 + 16
-        LinkedList<TextPropCollection> a_ch_l = stpa.getCharacterStyles();
+        List<TextPropCollection> a_ch_l = stpa.getCharacterStyles();
         TextPropCollection a_ch_1 = a_ch_l.get(0);
         TextPropCollection a_ch_2 = a_ch_l.get(1);
         TextPropCollection a_ch_3 = a_ch_l.get(2);
@@ -197,7 +195,7 @@ public final class TestStyleTextPropAtom extends TestCase {
         assertEquals(16, a_ch_3.getCharactersCovered());
 
         // 179 chars, 30 + 28 + 25
-        LinkedList<TextPropCollection> b_ch_l = stpb.getCharacterStyles();
+        List<TextPropCollection> b_ch_l = stpb.getCharacterStyles();
         TextPropCollection b_ch_1 = b_ch_l.get(0);
         TextPropCollection b_ch_2 = b_ch_l.get(1);
         TextPropCollection b_ch_3 = b_ch_l.get(2);
@@ -213,7 +211,7 @@ public final class TestStyleTextPropAtom extends TestCase {
         StyleTextPropAtom stpb = new StyleTextPropAtom(data_b,0,data_b.length);
         stpb.setParentTextSize(data_b_text_len);
 
-        LinkedList<TextPropCollection> b_ch_l = stpb.getCharacterStyles();
+        List<TextPropCollection> b_ch_l = stpb.getCharacterStyles();
         TextPropCollection b_ch_1 = b_ch_l.get(0);
         TextPropCollection b_ch_2 = b_ch_l.get(1);
         TextPropCollection b_ch_3 = b_ch_l.get(2);
@@ -260,7 +258,7 @@ public final class TestStyleTextPropAtom extends TestCase {
         StyleTextPropAtom stpb = new StyleTextPropAtom(data_b,0,data_b.length);
         stpb.setParentTextSize(data_b_text_len);
 
-        LinkedList<TextPropCollection> b_p_l = stpb.getParagraphStyles();
+        List<TextPropCollection> b_p_l = stpb.getParagraphStyles();
         TextPropCollection b_p_1 = b_p_l.get(0);
         TextPropCollection b_p_2 = b_p_l.get(1);
         TextPropCollection b_p_3 = b_p_l.get(2);
@@ -304,7 +302,7 @@ public final class TestStyleTextPropAtom extends TestCase {
         StyleTextPropAtom stpb = new StyleTextPropAtom(data_b,0,data_b.length);
         stpb.setParentTextSize(data_b_text_len);
 
-        LinkedList<TextPropCollection> b_ch_l = stpb.getCharacterStyles();
+        List<TextPropCollection> b_ch_l = stpb.getCharacterStyles();
         TextPropCollection b_ch_1 = b_ch_l.get(0);
         TextPropCollection b_ch_2 = b_ch_l.get(1);
         TextPropCollection b_ch_3 = b_ch_l.get(2);
@@ -375,13 +373,13 @@ public final class TestStyleTextPropAtom extends TestCase {
         StyleTextPropAtom stpb = new StyleTextPropAtom(data_b,0,data_b.length);
         stpb.setParentTextSize(data_b_text_len);
 
-        LinkedList<TextPropCollection> b_p_l = stpb.getParagraphStyles();
+        List<TextPropCollection> b_p_l = stpb.getParagraphStyles();
         TextPropCollection b_p_1 = b_p_l.get(0);
         TextPropCollection b_p_2 = b_p_l.get(1);
         TextPropCollection b_p_3 = b_p_l.get(2);
         TextPropCollection b_p_4 = b_p_l.get(3);
 
-        LinkedList<TextPropCollection> b_ch_l = stpb.getCharacterStyles();
+        List<TextPropCollection> b_ch_l = stpb.getCharacterStyles();
         TextPropCollection b_ch_1 = b_ch_l.get(0);
         TextPropCollection b_ch_2 = b_ch_l.get(1);
         TextPropCollection b_ch_3 = b_ch_l.get(2);
@@ -431,7 +429,7 @@ public final class TestStyleTextPropAtom extends TestCase {
 
         // Don't need to touch the paragraph styles
         // Add two more character styles
-        LinkedList<TextPropCollection> cs = stpa.getCharacterStyles();
+        List<TextPropCollection> cs = stpa.getCharacterStyles();
 
         // First char style is boring, and 21 long
         TextPropCollection tpca = cs.get(0);
@@ -468,7 +466,7 @@ public final class TestStyleTextPropAtom extends TestCase {
 
 
         // Need 4 paragraph styles
-        LinkedList<TextPropCollection> ps = stpa.getParagraphStyles();
+        List<TextPropCollection> ps = stpa.getParagraphStyles();
 
         // First is 30 long, left aligned, normal spacing
         TextPropCollection tppa = ps.get(0);
@@ -503,7 +501,7 @@ public final class TestStyleTextPropAtom extends TestCase {
 
 
         // Now do 4 character styles
-        LinkedList<TextPropCollection> cs = stpa.getCharacterStyles();
+        List<TextPropCollection> cs = stpa.getCharacterStyles();
 
         // First is 30 long, bold and font size
         TextPropCollection tpca = cs.get(0);
@@ -568,16 +566,16 @@ public final class TestStyleTextPropAtom extends TestCase {
         // Compare in detail to b
         StyleTextPropAtom stpb = new StyleTextPropAtom(data_b,0,data_b.length);
         stpb.setParentTextSize(data_b_text_len);
-        LinkedList<TextPropCollection> psb = stpb.getParagraphStyles();
-        LinkedList<TextPropCollection> csb = stpb.getCharacterStyles();
+        List<TextPropCollection> psb = stpb.getParagraphStyles();
+        List<TextPropCollection> csb = stpb.getCharacterStyles();
 
         assertEquals(psb.size(), ps.size());
         assertEquals(csb.size(), cs.size());
 
         // Ensure Paragraph Character styles match
         for(int z=0; z<2; z++) {
-            LinkedList<TextPropCollection> lla = cs;
-            LinkedList<TextPropCollection> llb = csb;
+            List<TextPropCollection> lla = cs;
+            List<TextPropCollection> llb = csb;
             int upto = 5;
             if(z == 1) {
                 lla = ps;
@@ -605,8 +603,8 @@ public final class TestStyleTextPropAtom extends TestCase {
                 ByteArrayOutputStream ba = new ByteArrayOutputStream();
                 ByteArrayOutputStream bb = new ByteArrayOutputStream();
 
-                ca.writeOut(ba);
-                cb.writeOut(bb);
+                ca.writeOut(ba, StyleTextPropAtom.characterTextPropTypes);
+                cb.writeOut(bb, StyleTextPropAtom.characterTextPropTypes);
                 byte[] cab = ba.toByteArray();
                 byte[] cbb = bb.toByteArray();
 
@@ -695,12 +693,12 @@ public final class TestStyleTextPropAtom extends TestCase {
         StyleTextPropAtom atom = new StyleTextPropAtom(data_d, 0, data_d.length);
         atom.setParentTextSize(data_d_text_len);
 
-        TextPropCollection prprops = atom.getParagraphStyles().getFirst();
+        TextPropCollection prprops = atom.getParagraphStyles().get(0);
         assertEquals(data_d_text_len+1, prprops.getCharactersCovered());
         assertEquals(1, prprops.getTextPropList().size()); //1 property found
         assertEquals(1, prprops.findByName("alignment").getValue());
 
-        TextPropCollection chprops = atom.getCharacterStyles().getFirst();
+        TextPropCollection chprops = atom.getCharacterStyles().get(0);
         assertEquals(data_d_text_len+1, chprops.getCharactersCovered());
         assertEquals(5, chprops.getTextPropList().size()); //5 properties found
         assertEquals(1, chprops.findByName("char_flags").getValue());
index 5778beac2c3dca6d8035e42a519c6600f82d349a..c0634f05fc57f84c141840b8cf33750f4814df11 100644 (file)
@@ -20,16 +20,12 @@ package org.apache.poi.hslf.usermodel;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
+import java.util.List;
 
 import junit.framework.TestCase;
 
-import org.apache.poi.hslf.*;
-import org.apache.poi.hslf.record.Record;
-import org.apache.poi.hslf.record.RecordTypes;
-import org.apache.poi.hslf.record.UserEditAtom;
-import org.apache.poi.hslf.record.Document;
-import org.apache.poi.hslf.model.*;
 import org.apache.poi.POIDataSamples;
+import org.apache.poi.hslf.record.*;
 
 /**
  * Tests that SlideShow adds additional sheets properly
@@ -70,7 +66,7 @@ public final class TestAddingSlides extends TestCase {
         */
        public void testAddSlideToEmpty() throws Exception {
                // Doesn't have any slides
-               assertEquals(0, ss_empty.getSlides().length);
+               assertEquals(0, ss_empty.getSlides().size());
 
                // Should only have a master SLWT
                assertEquals(1, ss_empty.getDocumentRecord().getSlideListWithTexts().length);
@@ -88,7 +84,7 @@ public final class TestAddingSlides extends TestCase {
 
                // Add one
                HSLFSlide slide = ss_empty.createSlide();
-               assertEquals(1, ss_empty.getSlides().length);
+               assertEquals(1, ss_empty.getSlides().size());
                assertEquals(256, slide._getSheetNumber());
                assertEquals(3, slide._getSheetRefId());
                assertEquals(1, slide.getSlideNumber());
@@ -103,13 +99,13 @@ public final class TestAddingSlides extends TestCase {
                HSLFSlideShow ss_read = new HSLFSlideShow(hss_read);
 
                // Check it now has a slide
-               assertEquals(1, ss_read.getSlides().length);
+               assertEquals(1, ss_read.getSlides().size());
 
                // Check it now has two SLWTs
                assertEquals(2, ss_empty.getDocumentRecord().getSlideListWithTexts().length);
 
                // And check it's as expected
-               slide = ss_read.getSlides()[0];
+               slide = ss_read.getSlides().get(0);
                assertEquals(256, slide._getSheetNumber());
                assertEquals(3, slide._getSheetRefId());
                assertEquals(1, slide.getSlideNumber());
@@ -120,8 +116,8 @@ public final class TestAddingSlides extends TestCase {
         */
        public void testAddSlideToExisting() throws Exception {
                // Has one slide
-               assertEquals(1, ss_one.getSlides().length);
-               HSLFSlide s1 = ss_one.getSlides()[0];
+               assertEquals(1, ss_one.getSlides().size());
+               HSLFSlide s1 = ss_one.getSlides().get(0);
 
                // Should have two SLTWs
                assertEquals(2, ss_one.getDocumentRecord().getSlideListWithTexts().length);
@@ -133,7 +129,7 @@ public final class TestAddingSlides extends TestCase {
 
                // Add a second one
                HSLFSlide s2 = ss_one.createSlide();
-               assertEquals(2, ss_one.getSlides().length);
+               assertEquals(2, ss_one.getSlides().size());
                assertEquals(257, s2._getSheetNumber());
                assertEquals(4, s2._getSheetRefId());
                assertEquals(2, s2.getSlideNumber());
@@ -147,14 +143,14 @@ public final class TestAddingSlides extends TestCase {
                HSLFSlideShow ss_read = new HSLFSlideShow(hss_read);
 
                // Check it now has two slides
-               assertEquals(2, ss_read.getSlides().length);
+               assertEquals(2, ss_read.getSlides().size());
 
                // Should still have two SLTWs
                assertEquals(2, ss_read.getDocumentRecord().getSlideListWithTexts().length);
 
                // And check it's as expected
-               s1 = ss_read.getSlides()[0];
-               s2 = ss_read.getSlides()[1];
+               s1 = ss_read.getSlides().get(0);
+               s2 = ss_read.getSlides().get(1);
                assertEquals(256, s1._getSheetNumber());
                assertEquals(3, s1._getSheetRefId());
                assertEquals(1, s1.getSlideNumber());
@@ -167,7 +163,8 @@ public final class TestAddingSlides extends TestCase {
         * Test adding a slide to an existing slideshow,
         *  with two slides already
         */
-       public void testAddSlideToExisting2() throws Exception {
+       @SuppressWarnings("unused")
+    public void testAddSlideToExisting2() throws Exception {
         //grab UserEditAtom
         UserEditAtom usredit = null;
         Record[] _records = hss_two.getRecords();
@@ -180,9 +177,9 @@ public final class TestAddingSlides extends TestCase {
        assertNotNull(usredit);
 
                // Has two slides
-               assertEquals(2, ss_two.getSlides().length);
-               HSLFSlide s1 = ss_two.getSlides()[0];
-               HSLFSlide s2 = ss_two.getSlides()[1];
+               assertEquals(2, ss_two.getSlides().size());
+               HSLFSlide s1 = ss_two.getSlides().get(0);
+               HSLFSlide s2 = ss_two.getSlides().get(1);
 
                // Check slide 1 is as expected
                assertEquals(256, s1._getSheetNumber());
@@ -195,7 +192,7 @@ public final class TestAddingSlides extends TestCase {
 
                // Add a third one
                HSLFSlide s3 = ss_two.createSlide();
-               assertEquals(3, ss_two.getSlides().length);
+               assertEquals(3, ss_two.getSlides().size());
                assertEquals(258, s3._getSheetNumber());
                assertEquals(8, s3._getSheetRefId()); // lots of notes before us
                assertEquals(3, s3.getSlideNumber());
@@ -210,12 +207,12 @@ public final class TestAddingSlides extends TestCase {
                HSLFSlideShow ss_read = new HSLFSlideShow(hss_read);
 
                // Check it now has three slides
-               assertEquals(3, ss_read.getSlides().length);
+               assertEquals(3, ss_read.getSlides().size());
 
                // And check it's as expected
-               s1 = ss_read.getSlides()[0];
-               s2 = ss_read.getSlides()[1];
-               s3 = ss_read.getSlides()[2];
+               s1 = ss_read.getSlides().get(0);
+               s2 = ss_read.getSlides().get(1);
+               s3 = ss_read.getSlides().get(2);
                assertEquals(256, s1._getSheetNumber());
                assertEquals(4, s1._getSheetRefId());
                assertEquals(1, s1.getSlideNumber());
@@ -235,8 +232,8 @@ public final class TestAddingSlides extends TestCase {
         HSLFSlide slide1 = ppt.createSlide();
         HSLFSlide slide2 = ppt.createSlide();
 
-        HSLFSlide[] s1 = ppt.getSlides();
-        assertEquals(2, s1.length);
+        List<HSLFSlide> s1 = ppt.getSlides();
+        assertEquals(2, s1.size());
         try {
             ppt.removeSlide(-1);
             fail("expected exception");
@@ -254,10 +251,10 @@ public final class TestAddingSlides extends TestCase {
         assertEquals(1, slide1.getSlideNumber());
 
         HSLFSlide removedSlide = ppt.removeSlide(0);
-        HSLFSlide[] s2 = ppt.getSlides();
-        assertEquals(1, s2.length);
+        List<HSLFSlide> s2 = ppt.getSlides();
+        assertEquals(1, s2.size());
         assertSame(slide1, removedSlide);
-        assertSame(slide2, s2[0]);
+        assertSame(slide2, s2.get(0));
 
         assertEquals(0, slide2.getSlideNumber());
 
@@ -266,29 +263,29 @@ public final class TestAddingSlides extends TestCase {
 
         ppt = new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray()));
 
-        HSLFSlide[] s3 = ppt.getSlides();
-        assertEquals(1, s3.length);
+        List<HSLFSlide> s3 = ppt.getSlides();
+        assertEquals(1, s3.size());
     }
 
 
     public void test47261() throws Exception {
         POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
         HSLFSlideShow ppt = new HSLFSlideShow(slTests.openResourceAsStream("47261.ppt"));
-        HSLFSlide[] slides = ppt.getSlides();
+        List<HSLFSlide> slides = ppt.getSlides();
         Document doc = ppt.getDocumentRecord();
         assertNotNull(doc.getSlideSlideListWithText());
-        assertEquals(14, ppt.getSlides().length);
-        int notesId = slides[0].getSlideRecord().getSlideAtom().getNotesID();
+        assertEquals(14, ppt.getSlides().size());
+        int notesId = slides.get(0).getSlideRecord().getSlideAtom().getNotesID();
         assertTrue(notesId > 0);
         assertNotNull(doc.getNotesSlideListWithText());
         assertEquals(14, doc.getNotesSlideListWithText().getSlideAtomsSets().length);
 
         //remove all slides, corresponding notes should be removed too
-        for (int i = 0; i < slides.length; i++) {
+        for (int i = 0; i < slides.size(); i++) {
             ppt.removeSlide(0);
         }
-        assertEquals(0, ppt.getSlides().length);
-        assertEquals(0, ppt.getNotes().length);
+        assertEquals(0, ppt.getSlides().size());
+        assertEquals(0, ppt.getNotes().size());
         assertNull(doc.getSlideSlideListWithText());
         assertNull(doc.getNotesSlideListWithText());
 
index 1dcd58ca374cf659fff1b53fca3d3fd06ea81afd..12e3ff6c304306600b38f342da1e9469186aa706 100644 (file)
@@ -17,7 +17,7 @@
 
 package org.apache.poi.hslf.usermodel;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.*;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
@@ -73,7 +73,7 @@ public final class TestBugs {
         HSLFSlideShow ppt = new HSLFSlideShow(hslf);
         assertTrue("No Exceptions while reading file", true);
 
-        assertEquals(1, ppt.getSlides().length);
+        assertEquals(1, ppt.getSlides().size());
 
         HSLFPictureData[] pict = ppt.getPictureData();
         assertEquals(2, pict.length);
@@ -91,23 +91,23 @@ public final class TestBugs {
 
         HSLFSlideShow ppt = new HSLFSlideShow(hslf);
         assertTrue("No Exceptions while reading file", true);
-        assertEquals(2, ppt.getSlides().length);
+        assertEquals(2, ppt.getSlides().size());
 
-        HSLFTextParagraph txrun;
+        List<HSLFTextParagraph> txrun;
         HSLFNotes notes;
 
-        notes = ppt.getSlides()[0].getNotesSheet();
+        notes = ppt.getSlides().get(0).getNotes();
         assertNotNull(notes);
-        txrun = notes.getTextParagraphs()[0];
-        assertEquals("Notes-1", txrun.getRawText());
-        assertEquals(false, txrun.getTextRuns()[0].isBold());
+        txrun = notes.getTextParagraphs().get(0);
+        assertEquals("Notes-1", HSLFTextParagraph.getRawText(txrun));
+        assertEquals(false, txrun.get(0).getTextRuns().get(0).isBold());
 
         //notes for the second slide are in bold
-        notes = ppt.getSlides()[1].getNotesSheet();
+        notes = ppt.getSlides().get(1).getNotes();
         assertNotNull(notes);
-        txrun = notes.getTextParagraphs()[0];
-        assertEquals("Notes-2", txrun.getRawText());
-        assertEquals(true, txrun.getTextRuns()[0].isBold());
+        txrun = notes.getTextParagraphs().get(0);
+        assertEquals("Notes-2", HSLFTextParagraph.getRawText(txrun));
+        assertEquals(true, txrun.get(0).getTextRuns().get(0).isBold());
 
     }
 
@@ -128,13 +128,12 @@ public final class TestBugs {
         notesMap.put(Integer.valueOf(7), "Although multiply and square root are easier");
         notesMap.put(Integer.valueOf(8), "The bus Z is split into Z_H and Z_L");
 
-        HSLFSlide[] slide = ppt.getSlides();
-        for (int i = 0; i < slide.length; i++) {
-            Integer slideNumber = Integer.valueOf(slide[i].getSlideNumber());
-            HSLFNotes notes = slide[i].getNotesSheet();
+        for (HSLFSlide slide : ppt.getSlides()) {
+            Integer slideNumber = Integer.valueOf(slide.getSlideNumber());
+            HSLFNotes notes = slide.getNotes();
             if (notesMap.containsKey(slideNumber)){
                 assertNotNull(notes);
-                String text = notes.getTextParagraphs()[0].getRawText();
+                String text = HSLFTextParagraph.getRawText(notes.getTextParagraphs().get(0));
                 String startingPhrase = notesMap.get(slideNumber);
                 assertTrue("Notes for slide " + slideNumber + " must start with " +
                         startingPhrase , text.startsWith(startingPhrase));
@@ -150,14 +149,12 @@ public final class TestBugs {
         HSLFSlideShowImpl hslf = new HSLFSlideShowImpl(_slTests.openResourceAsStream("42485.ppt"));
 
         HSLFSlideShow ppt = new HSLFSlideShow(hslf);
-        HSLFShape[] shape = ppt.getSlides()[0].getShapes();
-        for (int i = 0; i < shape.length; i++) {
-            if(shape[i] instanceof HSLFGroupShape){
-                HSLFGroupShape  group = (HSLFGroupShape)shape[i];
-                HSLFShape[] sh = group.getShapes();
-                for (int j = 0; j < sh.length; j++) {
-                    if( sh[j] instanceof HSLFTextBox){
-                        HSLFTextBox txt = (HSLFTextBox)sh[j];
+        for (HSLFShape shape : ppt.getSlides().get(0).getShapes()) {
+            if(shape instanceof HSLFGroupShape){
+                HSLFGroupShape group = (HSLFGroupShape)shape;
+                for (HSLFShape sh : group.getShapes()) {
+                    if(sh instanceof HSLFTextBox){
+                        HSLFTextBox txt = (HSLFTextBox)sh;
                         assertNotNull(txt.getTextParagraphs());
                     }
                 }
@@ -173,14 +170,12 @@ public final class TestBugs {
         HSLFSlideShowImpl hslf = new HSLFSlideShowImpl(_slTests.openResourceAsStream("42485.ppt"));
 
         HSLFSlideShow ppt = new HSLFSlideShow(hslf);
-        HSLFShape[] shape = ppt.getSlides()[0].getShapes();
-        for (int i = 0; i < shape.length; i++) {
-            if(shape[i] instanceof HSLFGroupShape){
-                HSLFGroupShape  group = (HSLFGroupShape)shape[i];
+        for (HSLFShape shape : ppt.getSlides().get(0).getShapes()) {
+            if(shape instanceof HSLFGroupShape){
+                HSLFGroupShape  group = (HSLFGroupShape)shape;
                 assertNotNull(group.getAnchor());
-                HSLFShape[] sh = group.getShapes();
-                for (int j = 0; j < sh.length; j++) {
-                    assertNotNull(sh[j].getAnchor());
+                for (HSLFShape sh : group.getShapes()) {
+                    assertNotNull(sh.getAnchor());
                 }
             }
         }
@@ -197,28 +192,28 @@ public final class TestBugs {
         HSLFSlideShow ppt = new HSLFSlideShow(hslf);
         assertTrue("No Exceptions while reading file", true);
 
-        assertEquals(1, ppt.getSlidesMasters().length);
-        assertEquals(1, ppt.getTitleMasters().length);
-        HSLFSlide[] slide = ppt.getSlides();
-        for (int i = 0; i < slide.length; i++) {
-            HSLFMasterSheet master = slide[i].getMasterSheet();
-            if (i == 0) assertTrue(master instanceof HSLFTitleMaster); //the first slide follows TitleMaster
-            else assertTrue(master instanceof HSLFSlideMaster);
+        assertEquals(1, ppt.getSlideMasters().size());
+        assertEquals(1, ppt.getTitleMasters().size());
+        boolean isFirst = true;
+        for (HSLFSlide slide : ppt.getSlides()) {
+            HSLFMasterSheet master = slide.getMasterSheet();
+            // the first slide follows TitleMaster
+            assertTrue(isFirst ? master instanceof HSLFTitleMaster : master instanceof HSLFSlideMaster);
+            isFirst = false;
         }
     }
 
     /**
      * Bug 42486:  Failure parsing a seemingly valid PPT
      */
+    @SuppressWarnings("unused")
     @Test
     public void bug42486 () throws Exception {
         HSLFSlideShowImpl hslf = new HSLFSlideShowImpl(_slTests.openResourceAsStream("42486.ppt"));
 
         HSLFSlideShow ppt = new HSLFSlideShow(hslf);
-        HSLFSlide[] slide = ppt.getSlides();
-        for (int i = 0; i < slide.length; i++) {
-            @SuppressWarnings("unused")
-            HSLFShape[] shape = slide[i].getShapes();
+        for (HSLFSlide slide : ppt.getSlides()) {
+            List<HSLFShape> shape = slide.getShapes();
         }
         assertTrue("No Exceptions while reading file", true);
 
@@ -233,16 +228,13 @@ public final class TestBugs {
 
         HSLFSlideShow ppt = new HSLFSlideShow(hslf);
         //walk down the tree and see if there were no errors while reading
-        HSLFSlide[] slide = ppt.getSlides();
-        for (int i = 0; i < slide.length; i++) {
-            HSLFShape[] shape = slide[i].getShapes();
-            for (int j = 0; j < shape.length; j++) {
-                assertNotNull(shape[j].getShapeName());
-                if (shape[j] instanceof HSLFGroupShape){
-                    HSLFGroupShape group = (HSLFGroupShape)shape[j];
-                    HSLFShape[] comps = group.getShapes();
-                    for (int k = 0; k < comps.length; k++) {
-                        assertNotNull(comps[k].getShapeName());
+        for (HSLFSlide slide : ppt.getSlides()) {
+            for (HSLFShape shape : slide.getShapes()) {
+                assertNotNull(shape.getShapeName());
+                if (shape instanceof HSLFGroupShape){
+                    HSLFGroupShape group = (HSLFGroupShape)shape;
+                    for (HSLFShape comps : group.getShapes()) {
+                        assertNotNull(comps.getShapeName());
                    }
                 }
             }
@@ -255,6 +247,7 @@ public final class TestBugs {
     /**
      * Bug 42520:  NPE in Picture.getPictureData()
      */
+    @SuppressWarnings("unused")
     @Test
     public void bug42520 () throws Exception {
         HSLFSlideShowImpl hslf = new HSLFSlideShowImpl(_slTests.openResourceAsStream("42520.ppt"));
@@ -262,22 +255,17 @@ public final class TestBugs {
         HSLFSlideShow ppt = new HSLFSlideShow(hslf);
 
         //test case from the bug report
-        HSLFGroupShape shapeGroup = (HSLFGroupShape)ppt.getSlides()[11].getShapes()[10];
-        HSLFPictureShape picture = (HSLFPictureShape)shapeGroup.getShapes()[0];
+        HSLFGroupShape shapeGroup = (HSLFGroupShape)ppt.getSlides().get(11).getShapes().get(10);
+        HSLFPictureShape picture = (HSLFPictureShape)shapeGroup.getShapes().get(0);
         picture.getPictureData();
 
         //walk down the tree and see if there were no errors while reading
-        HSLFSlide[] slide = ppt.getSlides();
-        for (int i = 0; i < slide.length; i++) {
-            HSLFShape[] shape = slide[i].getShapes();
-            for (int j = 0; j < shape.length; j++) {
-              if (shape[j] instanceof HSLFGroupShape){
-                    HSLFGroupShape group = (HSLFGroupShape)shape[j];
-                    HSLFShape[] comps = group.getShapes();
-                    for (int k = 0; k < comps.length; k++) {
-                        HSLFShape comp = comps[k];
+        for (HSLFSlide slide : ppt.getSlides()) {
+            for (HSLFShape shape : slide.getShapes()) {
+              if (shape instanceof HSLFGroupShape){
+                    HSLFGroupShape group = (HSLFGroupShape)shape;
+                    for (HSLFShape comp : group.getShapes()) {
                         if (comp instanceof HSLFPictureShape){
-                            @SuppressWarnings("unused")
                             HSLFPictureData pict = ((HSLFPictureShape)comp).getPictureData();
                         }
                     }
@@ -299,10 +287,10 @@ public final class TestBugs {
 
         assertTrue("No Exceptions while reading file", true);
 
-        HSLFSlide[] slide = ppt.getSlides();
-        assertEquals(1, slide.length);
-        HSLFTextParagraph[] runs = slide[0].getTextParagraphs();
-        assertEquals(4, runs.length);
+        List<HSLFSlide> slide = ppt.getSlides();
+        assertEquals(1, slide.size());
+        List<List<HSLFTextParagraph>> paras = slide.get(0).getTextParagraphs();
+        assertEquals(4, paras.size());
 
         Set<String> txt = new HashSet<String>();
         txt.add("\u201CHAPPY BIRTHDAY SCOTT\u201D");
@@ -310,8 +298,8 @@ public final class TestBugs {
         txt.add("PS Nobody is allowed to hassle Scott TODAY\u2026");
         txt.add("Drinks will be in the Boardroom at 5pm today to celebrate Scott\u2019s B\u2019Day\u2026  See you all there!");
 
-        for (int i = 0; i < runs.length; i++) {
-            String text = runs[i].getRawText();
+        for (List<HSLFTextParagraph> para : paras) {
+            String text = HSLFTextParagraph.getRawText(para);
             assertTrue(text, txt.contains(text));
         }
 
@@ -322,39 +310,37 @@ public final class TestBugs {
      * ( also fixed followup: getTextRuns() returns no text )
      */
     @Test
-    public void bug43781 () throws Exception {
+    public void bug43781() throws Exception {
         HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("43781.ppt"));
 
         assertTrue("No Exceptions while reading file", true);
 
         // Check the first slide
-        HSLFSlide slide = ppt.getSlides()[0];
-        HSLFTextParagraph[] slTr = slide.getTextParagraphs();
+        HSLFSlide slide = ppt.getSlides().get(0);
+        List<List<HSLFTextParagraph>> slTr = slide.getTextParagraphs();
         
-        // Has two text runs, one from slide text, one from drawing
-        assertEquals(2, slTr.length);
-        assertEquals(false, slTr[0].isDrawingBased());
-        assertEquals(true, slTr[1].isDrawingBased());
-        assertEquals("First run", slTr[0].getRawText());
-        assertEquals("Second run", slTr[1].getRawText());
+        // Has 3 text paragraphs, two from slide text (empty title / filled body), one from drawing
+        assertEquals(3, slTr.size());
+        assertFalse(slTr.get(0).get(0).isDrawingBased());
+        assertFalse(slTr.get(1).get(0).isDrawingBased());
+        assertTrue(slTr.get(2).get(0).isDrawingBased());
+        assertEquals("", HSLFTextParagraph.getRawText(slTr.get(0)));
+        assertEquals("First run", HSLFTextParagraph.getRawText(slTr.get(1)));
+        assertEquals("Second run", HSLFTextParagraph.getRawText(slTr.get(2)));
 
         // Check the shape based text runs
         List<HSLFTextParagraph> lst = new ArrayList<HSLFTextParagraph>();
-        HSLFShape[] shape = slide.getShapes();
-        for (int i = 0; i < shape.length; i++) {
-            if( shape[i] instanceof HSLFTextShape){
-                HSLFTextParagraph textRun = ((HSLFTextShape)shape[i]).getTextParagraphs();
-                if(textRun != null) {
-                    lst.add(textRun);
-                }
+        for (HSLFShape shape : slide.getShapes()) {
+            if (shape instanceof HSLFTextShape){
+                List<HSLFTextParagraph> textRun = ((HSLFTextShape)shape).getTextParagraphs();
+                lst.addAll(textRun);
             }
 
         }
-        // There should be only one shape based one found
-        assertEquals(1, lst.size());
         
-        // And it should be the second one
-        assertEquals("Second run", lst.get(0).getRawText());
+        // There are two shapes in the ppt
+        assertEquals(2, lst.size());
+        assertEquals("First runSecond run", HSLFTextParagraph.getRawText(lst));
     }
 
     /**
@@ -364,7 +350,7 @@ public final class TestBugs {
     public void bug44296  () throws Exception {
         HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("44296.ppt"));
 
-        HSLFSlide slide = ppt.getSlides()[0];
+        HSLFSlide slide = ppt.getSlides().get(0);
 
         HSLFBackground b = slide.getBackground();
         HSLFFill f = b.getFill();
@@ -397,16 +383,16 @@ public final class TestBugs {
     public void bug41071() throws Exception {
         HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("41071.ppt"));
 
-        HSLFSlide slide = ppt.getSlides()[0];
-        HSLFShape[] sh = slide.getShapes();
-        assertEquals(1, sh.length);
-        assertTrue(sh[0] instanceof HSLFTextShape);
-        HSLFTextShape tx = (HSLFTextShape)sh[0];
-        assertEquals("Fundera, planera och involvera.", tx.getTextParagraphs().getRawText());
+        HSLFSlide slide = ppt.getSlides().get(0);
+        List<HSLFShape> sh = slide.getShapes();
+        assertEquals(1, sh.size());
+        assertTrue(sh.get(0) instanceof HSLFTextShape);
+        HSLFTextShape tx = (HSLFTextShape)sh.get(0);
+        assertEquals("Fundera, planera och involvera.", HSLFTextParagraph.getRawText(tx.getTextParagraphs()));
 
-        HSLFTextParagraph[] run = slide.getTextParagraphs();
-        assertEquals(1, run.length);
-        assertEquals("Fundera, planera och involvera.", run[0].getRawText());
+        List<List<HSLFTextParagraph>> run = slide.getTextParagraphs();
+        assertEquals(3, run.size());
+        assertEquals("Fundera, planera och involvera.", HSLFTextParagraph.getRawText(run.get(2)));
     }
 
     /**
@@ -429,10 +415,10 @@ public final class TestBugs {
     public void bug49648() throws Exception {
        HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("49648.ppt"));
        for(HSLFSlide slide : ppt.getSlides()) {
-          for(HSLFTextParagraph run : slide.getTextParagraphs()) {
-             String text = run.getRawText();
+          for(List<HSLFTextParagraph> run : slide.getTextParagraphs()) {
+             String text = HSLFTextParagraph.getRawText(run);
              text.replace("{txtTot}", "With \u0123\u1234\u5678 unicode");
-             run.setRawText(text);
+             HSLFTextParagraph.setText(run, text);
           }
        }
     }
@@ -487,9 +473,9 @@ public final class TestBugs {
                 str = str.replace("$$DATE$$", new Date().toString());
                 tb.setText(str);
                 
-                HSLFTextParagraph tr = tb.getTextParagraphs();
-                assertEquals(str.length()+1,tr.getStyleTextPropAtom().getParagraphStyles().getFirst().getCharactersCovered());
-                assertEquals(str.length()+1,tr.getStyleTextPropAtom().getCharacterStyles().getFirst().getCharactersCovered());
+                List<HSLFTextParagraph> tr = tb.getTextParagraphs();
+                assertEquals(str.length()+1,tr.get(0).getParagraphStyle().getCharactersCovered());
+                assertEquals(str.length()+1,tr.get(0).getTextRuns().get(0).getCharacterStyle().getCharactersCovered());
             }
         }
     }
@@ -500,7 +486,7 @@ public final class TestBugs {
         
         HSLFSlideShowImpl ss = new HSLFSlideShowImpl(file.getAbsolutePath());
         HSLFSlideShow _show = new HSLFSlideShow(ss);
-        HSLFSlide[] _slides = _show.getSlides();
+        List<HSLFSlide> _slides = _show.getSlides();
 
         /* Iterate over slides and extract text */
         for( HSLFSlide slide : _slides ) {
@@ -516,8 +502,8 @@ public final class TestBugs {
         
         HSLFSlideShowImpl ss = new HSLFSlideShowImpl(file.getAbsolutePath());
         HSLFSlideShow _show = new HSLFSlideShow(ss);
-        HSLFSlide[] _slides = _show.getSlides();
-        assertEquals(13, _slides.length);
+        List<HSLFSlide> _slides = _show.getSlides();
+        assertEquals(13, _slides.size());
         
         // Check the number of TextHeaderAtoms on Slide 1
         Document dr = _show.getDocumentRecord();
@@ -538,8 +524,8 @@ public final class TestBugs {
         // Check the number of text runs based on the slide (not textbox)
         // Will have skipped the empty one
         int str = 0;
-        for (HSLFTextParagraph tr : _slides[0].getTextParagraphs()) {
-            if (! tr.isDrawingBased()) str++;
+        for (List<HSLFTextParagraph> tr : _slides.get(0).getTextParagraphs()) {
+            if (! tr.get(0).isDrawingBased()) str++;
         }
         assertEquals(1, str);
     }
@@ -549,11 +535,11 @@ public final class TestBugs {
         InputStream inputStream = new FileInputStream(_slTests.getFile("37625.ppt"));
         try {
             HSLFSlideShow slideShow = new HSLFSlideShow(inputStream);
-            assertEquals(29, slideShow.getSlides().length);
+            assertEquals(29, slideShow.getSlides().size());
             
             HSLFSlideShow slideBack = HSLFTestDataSamples.writeOutAndReadBack(slideShow);
             assertNotNull(slideBack);
-            assertEquals(29, slideBack.getSlides().length);
+            assertEquals(29, slideBack.getSlides().size());
         } finally {
             inputStream.close();
         }
@@ -564,11 +550,11 @@ public final class TestBugs {
         InputStream inputStream = new FileInputStream(_slTests.getFile("57272_corrupted_usereditatom.ppt"));
         try {
             HSLFSlideShow slideShow = new HSLFSlideShow(inputStream);
-            assertEquals(6, slideShow.getSlides().length);
+            assertEquals(6, slideShow.getSlides().size());
 
             HSLFSlideShow slideBack = HSLFTestDataSamples.writeOutAndReadBack(slideShow);
             assertNotNull(slideBack);
-            assertEquals(6, slideBack.getSlides().length);
+            assertEquals(6, slideBack.getSlides().size());
         } finally {
             inputStream.close();
         }
@@ -579,9 +565,9 @@ public final class TestBugs {
         InputStream inputStream = new FileInputStream(_slTests.getFile("49541_symbol_map.ppt"));
         try {
             HSLFSlideShow slideShow = new HSLFSlideShow(inputStream);
-            HSLFSlide slide = slideShow.getSlides()[0];
-            HSLFGroupShape sg = (HSLFGroupShape)slide.getShapes()[0];
-            HSLFTextBox tb = (HSLFTextBox)sg.getShapes()[0];
+            HSLFSlide slide = slideShow.getSlides().get(0);
+            HSLFGroupShape sg = (HSLFGroupShape)slide.getShapes().get(0);
+            HSLFTextBox tb = (HSLFTextBox)sg.getShapes().get(0);
             String text = StringUtil.mapMsCodepointString(tb.getText());
             assertEquals("\u226575 years", text);
         } finally {
@@ -608,7 +594,7 @@ public final class TestBugs {
         InputStream inputStream = new FileInputStream(_slTests.getFile("bug56240.ppt"));
         try {
             HSLFSlideShow slideShow = new HSLFSlideShow(inputStream);
-            int slideCnt = slideShow.getSlides().length;
+            int slideCnt = slideShow.getSlides().size();
             assertEquals(105, slideCnt);
             ByteArrayOutputStream bos = new ByteArrayOutputStream();
             slideShow.write(bos);
@@ -623,7 +609,7 @@ public final class TestBugs {
         InputStream inputStream = new FileInputStream(_slTests.getFile("bug46441.ppt"));
         try {
             HSLFSlideShow slideShow = new HSLFSlideShow(inputStream);
-            HSLFAutoShape as = (HSLFAutoShape)slideShow.getSlides()[0].getShapes()[0];
+            HSLFAutoShape as = (HSLFAutoShape)slideShow.getSlides().get(0).getShapes().get(0);
             EscherOptRecord opt = as.getEscherOptRecord();
             EscherArrayProperty ep = HSLFShape.getEscherProperty(opt, EscherProperties.FILL__SHADECOLORS);
             double exp[][] = {