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/05/29 01:32:27 UTC

svn commit: r1682356 [1/2] - in /poi/branches/common_sl/src: examples/src/org/apache/poi/hslf/examples/ java/org/apache/poi/util/ scratchpad/src/org/apache/poi/hslf/model/ scratchpad/src/org/apache/poi/hslf/record/ scratchpad/src/org/apache/poi/hslf/us...

Author: kiwiwings
Date: Thu May 28 23:32:26 2015
New Revision: 1682356

URL: http://svn.apache.org/r1682356
Log:
Fixed several test drivers or the implementation
renamed font functions in HSLFTextRun

Added:
    poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/record/TextSpecInfoRun.java
    poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestPicture.java
      - copied, changed from r1678838, poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPicture.java
    poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestTextShape.java
      - copied, changed from r1678838, poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextShape.java
Removed:
    poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPicture.java
    poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextShape.java
    poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/TextPainterTest.java
Modified:
    poi/branches/common_sl/src/examples/src/org/apache/poi/hslf/examples/ApacheconEU08.java
    poi/branches/common_sl/src/examples/src/org/apache/poi/hslf/examples/TableDemo.java
    poi/branches/common_sl/src/java/org/apache/poi/util/HexDump.java
    poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/PPGraphics2D.java
    poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/record/PPDrawing.java
    poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/record/TextSpecInfoAtom.java
    poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSheet.java
    poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java
    poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java
    poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextRun.java
    poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/AllHSLFModelTests.java
    poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPPGraphics2D.java
    poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java
    poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSheet.java
    poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlideMaster.java
    poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextRunReWrite.java
    poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/record/TestTextSpecInfoAtom.java
    poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/record/TestTxMasterStyleAtom.java
    poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/AllHSLFUserModelTests.java
    poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNumberedList.java
    poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNumberedList2.java
    poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNumberedList3.java
    poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestReOrderingSlides.java
    poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRecordSetup.java
    poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRichTextRun.java
    poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestSheetText.java
    poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestSlideOrdering.java
    poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestTextRun.java

Modified: poi/branches/common_sl/src/examples/src/org/apache/poi/hslf/examples/ApacheconEU08.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/examples/src/org/apache/poi/hslf/examples/ApacheconEU08.java?rev=1682356&r1=1682355&r2=1682356&view=diff
==============================================================================
--- poi/branches/common_sl/src/examples/src/org/apache/poi/hslf/examples/ApacheconEU08.java (original)
+++ poi/branches/common_sl/src/examples/src/org/apache/poi/hslf/examples/ApacheconEU08.java Thu May 28 23:32:26 2015
@@ -153,7 +153,7 @@ public final class ApacheconEU08 {
                 cell.setText(txt1[i][j]);
                 HSLFTextRun rt = cell.getTextParagraphs().get(0).getTextRuns().get(0);
                 rt.setFontSize(10);
-                rt.setFontName("Arial");
+                rt.setFontFamily("Arial");
                 rt.setBold(true);
                 if(i == 0){
                     rt.setFontSize(32);
@@ -232,7 +232,7 @@ public final class ApacheconEU08 {
 
         HSLFTextBox box3 = new HSLFTextBox();
         HSLFTextRun rt3 = box3.getTextParagraphs().get(0).getTextRuns().get(0);
-        rt3.setFontName("Courier New");
+        rt3.setFontFamily("Courier New");
         rt3.setFontSize(8);
         box3.setText(
                 "SlideShow ppt = new SlideShow();\u000b" +
@@ -341,7 +341,7 @@ public final class ApacheconEU08 {
 
         HSLFTextBox box3 = new HSLFTextBox();
         HSLFTextRun rt3 = box3.getTextParagraphs().get(0).getTextRuns().get(0);
-        rt3.setFontName("Courier New");
+        rt3.setFontFamily("Courier New");
         rt3.setFontSize(8);
         box3.setText(
                 "//bar chart data. The first value is the bar color, the second is the width\u000b" +

Modified: poi/branches/common_sl/src/examples/src/org/apache/poi/hslf/examples/TableDemo.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/examples/src/org/apache/poi/hslf/examples/TableDemo.java?rev=1682356&r1=1682355&r2=1682356&view=diff
==============================================================================
--- poi/branches/common_sl/src/examples/src/org/apache/poi/hslf/examples/TableDemo.java (original)
+++ poi/branches/common_sl/src/examples/src/org/apache/poi/hslf/examples/TableDemo.java Thu May 28 23:32:26 2015
@@ -54,7 +54,7 @@ public final class TableDemo {
             for (int j = 0; j < txt1[i].length; j++) {
                 TableCell cell = table1.getCell(i, j);
                 HSLFTextRun rt = cell.getTextParagraphs().get(0).getTextRuns().get(0);
-                rt.setFontName("Arial");
+                rt.setFontFamily("Arial");
                 rt.setFontSize(10);
                 if(i == 0){
                     cell.getFill().setForegroundColor(new Color(227, 227, 227));
@@ -94,7 +94,7 @@ public final class TableDemo {
                 TableCell cell = table2.getCell(i, j);
                 HSLFTextRun rt = cell.getTextParagraphs().get(0).getTextRuns().get(0);
                 rt.setFontSize(10);
-                rt.setFontName("Arial");
+                rt.setFontFamily("Arial");
                 if(i == 0){
                     cell.getFill().setForegroundColor(new Color(0, 51, 102));
                     rt.setFontColor(Color.white);

Modified: poi/branches/common_sl/src/java/org/apache/poi/util/HexDump.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/java/org/apache/poi/util/HexDump.java?rev=1682356&r1=1682355&r2=1682356&view=diff
==============================================================================
--- poi/branches/common_sl/src/java/org/apache/poi/util/HexDump.java (original)
+++ poi/branches/common_sl/src/java/org/apache/poi/util/HexDump.java Thu May 28 23:32:26 2015
@@ -170,49 +170,41 @@ public class HexDump {
      * @return output string
      */
 
-    public static String dump(final byte [] data, final long offset,
-                            final int index) {
-        StringBuffer buffer;
-        if ((index < 0) || (index >= data.length))
+    public static String dump(final byte [] data, final long offset, final int index) {
+        if ((index < 0) || (index > data.length))
         {
             throw new ArrayIndexOutOfBoundsException(
                 "illegal index: " + index + " into array of length "
                 + data.length);
         }
-        long         display_offset = offset + index;
-        buffer         = new StringBuffer(74);
+        long  display_offset = offset + index;
+        StringBuilder buffer = new StringBuilder(74);
 
-        for (int j = index; j < data.length; j += 16)
-        {
+        for (int j = index; j <= data.length; j += 16) {
             int chars_read = data.length - j;
 
-            if (chars_read > 16)
-            {
+            if (chars_read > 16) {
                 chars_read = 16;
             }
+            
             buffer.append(dump(display_offset)).append(' ');
-            for (int k = 0; k < 16; k++)
-            {
-                if (k < chars_read)
-                {
-                    buffer.append(dump(data[ k + j ]));
-                }
-                else
-                {
-                    buffer.append("  ");
-                }
+            for (int k = 0; k < 16; k++) {
+                String hexDmp = (k < chars_read) ? dump(data[ k + j ]) : "  ";
+                buffer.append(hexDmp);
                 buffer.append(' ');
             }
-            for (int k = 0; k < chars_read; k++)
-            {
-                if ((data[ k + j ] >= ' ') && (data[ k + j ] < 127))
-                {
-                    buffer.append(( char ) data[ k + j ]);
-                }
-                else
-                {
-                    buffer.append('.');
+            for (int k = 0; k < chars_read; k++) {
+                byte dataB = data[ k + j ];
+                char charB = (char)(dataB & 0xFF);
+                switch (charB) {
+                case 127: case 128: case 129: case 141: case 142: case 143: case 144: case 157: case 158:
+                    charB = '.';
+                    break;
+                default:
+                    if (charB < ' ') charB = '.';
+                    break;
                 }
+                buffer.append(charB);
             }
             buffer.append(EOL);
             display_offset += chars_read;

Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/PPGraphics2D.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/PPGraphics2D.java?rev=1682356&r1=1682355&r2=1682356&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/PPGraphics2D.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/model/PPGraphics2D.java Thu May 28 23:32:26 2015
@@ -257,7 +257,7 @@ public final class PPGraphics2D extends
 
         HSLFTextRun rt = txt.getTextParagraphs().get(0).getTextRuns().get(0);
         rt.setFontSize(_font.getSize());
-        rt.setFontName(_font.getFamily());
+        rt.setFontFamily(_font.getFamily());
 
         if (getColor() != null) rt.setFontColor(getColor());
         if (_font.isBold()) rt.setBold(true);

Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/record/PPDrawing.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/record/PPDrawing.java?rev=1682356&r1=1682355&r2=1682356&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/record/PPDrawing.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/record/PPDrawing.java Thu May 28 23:32:26 2015
@@ -247,14 +247,14 @@ public final class PPDrawing extends Rec
 	 */
 	public void writeOut(OutputStream out) throws IOException {
 		// Ensure the escher layer reflects the text changes
-		for(int i=0; i<textboxWrappers.length; i++) {
-			textboxWrappers[i].writeOut(null);
+		for (EscherTextboxWrapper w : textboxWrappers) {
+			w.writeOut(null);
 		}
 
 		// Find the new size of the escher children;
 		int newSize = 0;
-		for(int i=0; i<childRecords.length; i++) {
-			newSize += childRecords[i].getRecordSize();
+		for(EscherRecord er : childRecords) {
+			newSize += er.getRecordSize();
 		}
 
 		// Update the size (header bytes 5-8)

Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/record/TextSpecInfoAtom.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/record/TextSpecInfoAtom.java?rev=1682356&r1=1682355&r2=1682356&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/record/TextSpecInfoAtom.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/record/TextSpecInfoAtom.java Thu May 28 23:32:26 2015
@@ -17,11 +17,12 @@
 
 package org.apache.poi.hslf.record;
 
-import org.apache.poi.util.LittleEndian;
-
-import java.io.OutputStream;
-import java.io.IOException;
+import java.io.*;
 import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.poi.util.LittleEndian;
+import org.apache.poi.util.LittleEndianByteArrayInputStream;
 
 /**
  * The special info runs contained in this text.
@@ -43,6 +44,15 @@ public final class TextSpecInfoAtom exte
     private byte[] _data;
 
     /**
+     * Constructs an empty atom, with a default run of size 1 
+     */
+    public TextSpecInfoAtom() {
+        _header = new byte[8];
+        LittleEndian.putUInt(_header, 4, _type);
+        reset(1);
+    }
+    
+    /**
      * Constructs the link related atom record from its
      *  source data.
      *
@@ -50,7 +60,7 @@ public final class TextSpecInfoAtom exte
      * @param start the start offset into the byte array.
      * @param len the length of the slice in the byte array.
      */
-    protected TextSpecInfoAtom(byte[] source, int start, int len) {
+    public TextSpecInfoAtom(byte[] source, int start, int len) {
         // Get the header.
         _header = new byte[8];
         System.arraycopy(source,start,_header,0,8);
@@ -92,111 +102,67 @@ public final class TextSpecInfoAtom exte
      * @param size  the site of parent text
      */
     public void reset(int size){
-        _data = new byte[10];
-        // 01 00 00 00
-        LittleEndian.putInt(_data, 0, size);
-        // 01 00 00 00
-        LittleEndian.putInt(_data, 4, 1); //mask
-        // 00 00
-        LittleEndian.putShort(_data, 8, (short)0); //langId
+        TextSpecInfoRun sir = new TextSpecInfoRun(size);
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        try {
+            sir.writeOut(bos);
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+        _data = bos.toByteArray();
 
         // Update the size (header bytes 5-8)
         LittleEndian.putInt(_header, 4, _data.length);
     }
 
     /**
+     * Adapts the size by enlarging the last {@link TextSpecInfoRun}
+     * or chopping the runs to the given length
+     *
+     * @param size
+     */
+    public void setParentSize(int size) {
+        assert(size > 0);
+        int covered = 0;
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        TextSpecInfoRun runs[] = getTextSpecInfoRuns();
+        assert(runs.length > 0);
+        for (int i=0; i<runs.length && covered < size; i++) {
+            TextSpecInfoRun run = runs[i];
+            if (covered + run.getLength() > size || i == runs.length-1) {
+                run.setLength(size-covered);
+            }
+            covered += run.getLength();
+            try {
+                run.writeOut(bos);
+            } catch (IOException e) {
+                throw new RuntimeException(e);
+            }
+        }
+        _data = bos.toByteArray();
+
+        // Update the size (header bytes 5-8)
+        LittleEndian.putInt(_header, 4, _data.length);
+    }
+    
+    /**
      * Get the number of characters covered by this records
      *
      * @return the number of characters covered by this records
      */
     public int getCharactersCovered(){
         int covered = 0;
-        TextSpecInfoRun[] runs = getTextSpecInfoRuns();
-        for (int i = 0; i < runs.length; i++) covered += runs[i].len;
+        for (TextSpecInfoRun r : getTextSpecInfoRuns()) covered += r.length;
         return covered;
     }
 
     public TextSpecInfoRun[] getTextSpecInfoRuns(){
-        ArrayList<TextSpecInfoRun> lst = new ArrayList<TextSpecInfoRun>();
-        int pos = 0;
-        int[] bits = {1, 0, 2};
-        while(pos < _data.length) {
-            TextSpecInfoRun run = new TextSpecInfoRun();
-            run.len = LittleEndian.getInt(_data, pos); pos += 4;
-            run.mask = LittleEndian.getInt(_data, pos); pos += 4;
-            for (int i = 0; i < bits.length; i++) {
-                if((run.mask & 1 << bits[i]) != 0){
-                    switch (bits[i]){
-                        case 0:
-                            run.spellInfo = LittleEndian.getShort(_data, pos); pos += 2;
-                            break;
-                        case 1:
-                            run.langId = LittleEndian.getShort(_data, pos); pos += 2;
-                            break;
-                        case 2:
-                            run.altLangId = LittleEndian.getShort(_data, pos); pos += 2;
-                            break;
-                    }
-                }
-            }
-            lst.add(run);
+        LittleEndianByteArrayInputStream bis = new LittleEndianByteArrayInputStream(_data);
+        List<TextSpecInfoRun> lst = new ArrayList<TextSpecInfoRun>();
+        while (bis.available() > 0) {
+            lst.add(new TextSpecInfoRun(bis));
         }
         return lst.toArray(new TextSpecInfoRun[lst.size()]);
     }
 
-    public static class TextSpecInfoRun {
-        //Length of special info run.
-        protected int len;
-
-        //Special info mask of this run;
-        protected int mask;
-
-        // info fields as indicated by the mask.
-        // -1 means the bit is not set
-        protected short spellInfo = -1;
-        protected short langId = -1;
-        protected short altLangId = -1;
-
-        /**
-         * Spelling status of this text. See Spell Info table below.
-         *
-         * <p>Spell Info Types:</p>
-         * <li>0    Unchecked
-         * <li>1    Previously incorrect, needs rechecking
-         * <li>2    Correct
-         * <li>3    Incorrect
-         *
-         * @return Spelling status of this text
-         */
-        public short getSpellInfo(){
-            return spellInfo;
-        }
-
-        /**
-         * Windows LANGID for this text.
-         *
-         * @return Windows LANGID for this text.
-         */
-        public short getLangId(){
-            return spellInfo;
-        }
-
-        /**
-         * Alternate Windows LANGID of this text;
-         * must be a valid non-East Asian LANGID if the text has an East Asian language,
-         * otherwise may be an East Asian LANGID or language neutral (zero).
-         *
-         * @return  Alternate Windows LANGID of this text
-         */
-        public short getAltLangId(){
-            return altLangId;
-        }
-
-        /**
-         * @return Length of special info run.
-         */
-        public int length(){
-            return len;
-        }
-    }
 }

Added: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/record/TextSpecInfoRun.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/record/TextSpecInfoRun.java?rev=1682356&view=auto
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/record/TextSpecInfoRun.java (added)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/record/TextSpecInfoRun.java Thu May 28 23:32:26 2015
@@ -0,0 +1,346 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hslf.record;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.apache.poi.util.*;
+
+public class TextSpecInfoRun {
+    /**
+     * A enum that specifies the spelling status of a run of text.
+     */
+    public enum SpellInfoEnum {
+        /** the text is spelled incorrectly. */
+        error(new BitField(1)),
+        /** the text needs rechecking. */
+        clean(new BitField(2)),
+        /** the text has a grammar error. */
+        grammar(new BitField(4)),
+        /** the text is spelled correct */
+        correct(new BitField(0));
+        
+        final BitField bitField;
+        
+        SpellInfoEnum(BitField bitField) {
+            this.bitField = bitField;
+        }
+    }
+    
+    /** A bit that specifies whether the spellInfo field exists. */
+    private static final BitField spellFld    = new BitField(0X00000001);
+    /** A bit that specifies whether the lid field exists. */
+    private static final BitField langFld     = new BitField(0X00000002);
+    /** A bit that specifies whether the altLid field exists. */
+    private static final BitField altLangFld  = new BitField(0X00000004);
+    // unused1, unused2 - Undefined and MUST be ignored.
+    /** A bit that specifies whether the pp10runid, reserved3, and grammarError fields exist. */
+    private static final BitField pp10extFld  = new BitField(0X00000020);
+    /** A bit that specifies whether the bidi field exists. */
+    private static final BitField bidiFld     = new BitField(0X00000040);
+    // unused3 - Undefined and MUST be ignored.
+    // reserved1 - MUST be zero and MUST be ignored.
+    /** A bit that specifies whether the smartTags field exists. */
+    private static final BitField smartTagFld = new BitField(0X00000200);
+    // reserved2 - MUST be zero and MUST be ignored. 
+
+    /**
+     * An optional unsigned integer that specifies an identifier for a character
+     * run that contains StyleTextProp11 data. It MUST exist if and only if pp10ext is TRUE.
+     **/
+    private static final BitField pp10runidFld = new BitField(0X0000000F);
+    // reserved3 - An optional unsigned integer that MUST be zero, and MUST be ignored. It
+    // MUST exist if and only if fPp10ext is TRUE.
+    /**
+     * An optional bit that specifies a grammar error. It MUST exist if and
+     * only if fPp10ext is TRUE.
+     **/
+    private static final BitField grammarErrorFld = new BitField(0X80000000);
+    
+    //Length of special info run.
+    protected int length;
+
+    //Special info mask of this run;
+    protected int mask;
+
+    // info fields as indicated by the mask.
+    // -1 means the bit is not set
+
+    /**
+     * An optional SpellingFlags structure that specifies the spelling status of this
+     * text. It MUST exist if and only if spell is TRUE.
+     * The spellInfo.grammar sub-field MUST be zero.
+     * <br>
+     * error (1 bit): A bit that specifies whether the text is spelled incorrectly.<br>
+     * clean (1 bit): A bit that specifies whether the text needs rechecking.<br>
+     * grammar (1 bit): A bit that specifies whether the text has a grammar error.<br>
+     * reserved (13 bits): MUST be zero and MUST be ignored.
+     */
+    protected short spellInfo = -1;
+    
+    /**
+     * An optional TxLCID that specifies the language identifier of this text.
+     * It MUST exist if and only if lang is TRUE.
+     * <br>
+     * 0x0000 = No language.<br>
+     * 0x0013 = Any Dutch language is preferred over non-Dutch languages when proofing the text.<br>
+     * 0x0400 = No proofing is performed on the text.<br>
+     * &gt; 0x0400 = A valid LCID as specified by [MS-LCID].
+     */
+    protected short langId = -1;
+    
+    /**
+     * An optional TxLCID that specifies the alternate language identifier of this text.
+     * It MUST exist if and only if altLang is TRUE.
+     */
+    protected short altLangId = -1;
+    
+    /**
+     * An optional signed integer that specifies whether the text contains bidirectional
+     * characters. It MUST exist if and only if fBidi is TRUE.
+     * 0x0000 = Contains no bidirectional characters,
+     * 0x0001 = Contains bidirectional characters.
+     */
+    protected short bidi = -1;
+    
+    protected int pp10extMask = -1;
+    protected byte[] smartTagsBytes = null;
+
+    /**
+     * Inits a TextSpecInfoRun with default values
+     *
+     * @param len the length of the one and only run
+     */
+    public TextSpecInfoRun(int len) {
+        setLength(len);
+        setLangId((short)0);
+    }
+    
+    public TextSpecInfoRun(LittleEndianByteArrayInputStream source) {
+        length = source.readInt();
+        mask = source.readInt();
+        if (spellFld.isSet(mask)) {
+            spellInfo = source.readShort();
+        }
+        if (langFld.isSet(mask)) {
+            langId = source.readShort();
+        }
+        if (altLangFld.isSet(mask)) {
+            altLangId = source.readShort();
+        }
+        if (bidiFld.isSet(mask)) {
+            bidi = source.readShort();
+        }
+        if (pp10extFld.isSet(mask)) {
+            pp10extMask = source.readInt();
+        }
+        if (smartTagFld.isSet(mask)) {
+            // An unsigned integer specifies the count of items in rgSmartTagIndex.
+            int count = source.readInt();
+            smartTagsBytes = new byte[4+count*4];
+            LittleEndian.putInt(smartTagsBytes, 0, count);
+            // An array of SmartTagIndex that specifies the indices.
+            // The count of items in the array is specified by count.
+            source.readFully(smartTagsBytes, 4, count*4);
+        }
+    }
+
+    /**
+     * Write the contents of the record back, so it can be written
+     * to disk
+     *
+     * @param out the output stream to write to.
+     * @throws java.io.IOException if an error occurs.
+     */
+    public void writeOut(OutputStream out) throws IOException {
+        final byte buf[] = new byte[4];
+        LittleEndian.putInt(buf, 0, length);
+        out.write(buf);
+        LittleEndian.putInt(buf, 0, mask);
+        out.write(buf);
+        Object flds[] = {
+            spellFld, spellInfo, "spell info",
+            langFld, langId, "lang id",
+            altLangFld, altLangId, "alt lang id",
+            bidiFld, bidi, "bidi",
+            pp10extFld, pp10extMask, "pp10 extension field",
+            smartTagFld, smartTagsBytes, "smart tags"
+        };
+        
+        for (int i=0; i<flds.length; i+=3) {
+            BitField fld = (BitField)flds[i+0];
+            Object valO = flds[i+1];
+            if (!fld.isSet(mask)) continue;
+            boolean valid;
+            if (valO instanceof byte[]) {
+                byte bufB[] = (byte[])valO;
+                valid = bufB.length > 0;
+                out.write(bufB);
+            } else if (valO instanceof Integer) {
+                int valI = ((Integer)valO);
+                valid = (valI != -1);
+                LittleEndian.putInt(buf, 0, valI);
+                out.write(buf);
+            } else if (valO instanceof Short) {
+                short valS = ((Short)valO);
+                valid = (valS != -1);
+                LittleEndian.putShort(buf, 0, valS);
+                out.write(buf, 0, 2);
+            } else {
+                valid = false;
+            }
+            if (!valid) {
+                throw new IOException(flds[i+2]+" is activated, but its value is invalid");
+            }
+        }
+    }        
+    
+    /**
+     * @return Spelling status of this text. null if not defined.
+     */
+    public SpellInfoEnum getSpellInfo(){
+        if (spellInfo == -1) return null;
+        for (SpellInfoEnum si : new SpellInfoEnum[]{SpellInfoEnum.clean,SpellInfoEnum.error,SpellInfoEnum.grammar}) {
+            if (si.bitField.isSet(spellInfo)) return si;
+        }
+        return SpellInfoEnum.correct;
+    }
+
+    /**
+     * @param spellInfo Spelling status of this text. null if not defined.
+     */
+    public void setSpellInfo(SpellInfoEnum spellInfo) {
+        this.spellInfo = (spellInfo == null)
+            ? -1
+            : (short)spellInfo.bitField.set(0);
+        mask = spellFld.setBoolean(mask, spellInfo != null);
+    }
+    
+    /**
+     * Windows LANGID for this text.
+     *
+     * @return Windows LANGID for this text, -1 if it's not set
+     */
+    public short getLangId(){
+        return langId;
+    }
+
+    /**
+     * @param langId Windows LANGID for this text, -1 to unset
+     */
+    public void setLangId(short langId) {
+        this.langId = langId;
+        mask = langFld.setBoolean(mask, langId != -1);
+    }
+    
+    /**
+     * Alternate Windows LANGID of this text;
+     * must be a valid non-East Asian LANGID if the text has an East Asian language,
+     * otherwise may be an East Asian LANGID or language neutral (zero).
+     *
+     * @return  Alternate Windows LANGID of this text, -1 if it's not set
+     */
+    public short getAltLangId(){
+        return altLangId;
+    }
+
+    public void setAltLangId(short altLangId) {
+        this.altLangId = altLangId;
+        mask = altLangFld.setBoolean(mask, altLangId != -1);
+    }
+
+    /**
+     * @return Length of special info run.
+     */
+    public int getLength() {
+        return length;
+    }
+
+    /**
+     * @param length Length of special info run.
+     */
+    public void setLength(int length) {
+        this.length = length;
+    }
+
+    /**
+     * @return the bidirectional characters flag. false = not bidi, true = is bidi, null = not set
+     */
+    public Boolean getBidi() {
+        return (bidi == -1 ? null : bidi != 0);
+    }
+
+    /**
+     * @param bidi the bidirectional characters flag. false = not bidi, true = is bidi, null = not set
+     */
+    public void setBidi(Boolean bidi) {
+        this.bidi = (bidi == null) ? -1 : (short)(bidi ? 1 : 0);
+        mask = bidiFld.setBoolean(mask, bidi != null);
+    }
+
+    /**
+     * @return the unparsed smart tags
+     */
+    public byte[] getSmartTagsBytes() {
+        return smartTagsBytes;
+    }
+
+    /**
+     * @param smartTagsBytes the unparsed smart tags, null to unset
+     */
+    public void setSmartTagsBytes(byte[] smartTagsBytes) {
+        this.smartTagsBytes = smartTagsBytes;
+        mask = smartTagFld.setBoolean(mask, smartTagsBytes != null);
+    }
+    
+    /**
+     * @return an identifier for a character run that contains StyleTextProp11 data.
+     */
+    public int getPP10RunId() {
+        return (pp10extMask == -1 || !pp10extFld.isSet(mask)) ? -1 : pp10runidFld.getValue(pp10extMask);
+        
+    }
+    
+    /**
+     * @param pp10RunId an identifier for a character run that contains StyleTextProp11 data, -1 to unset
+     */
+    public void setPP10RunId(int pp10RunId) {
+        if (pp10RunId == -1) {
+            pp10extMask = (getGrammarError() == null) ? -1 : pp10runidFld.clear(pp10extMask);
+        } else {
+            pp10extMask = pp10runidFld.setValue(pp10extMask, pp10RunId);
+        }
+        // if both parameters are invalid, remove the extension mask
+        mask = pp10extFld.setBoolean(mask, pp10extMask != -1);
+    }
+    
+    public Boolean getGrammarError() {
+        return (pp10extMask == -1 || !pp10extFld.isSet(mask)) ? null : grammarErrorFld.isSet(pp10extMask);
+    }
+    
+    public void getGrammarError(Boolean grammarError) {
+        if (grammarError == null) {
+            pp10extMask = (getPP10RunId() == -1) ? -1 : grammarErrorFld.clear(pp10extMask);
+        } else {
+            pp10extMask = grammarErrorFld.set(pp10extMask);
+        }
+        // if both parameters are invalid, remove the extension mask
+        mask = pp10extFld.setBoolean(mask, pp10extMask != -1);
+    }
+}

Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSheet.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSheet.java?rev=1682356&r1=1682355&r2=1682356&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSheet.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSheet.java Thu May 28 23:32:26 2015
@@ -127,7 +127,36 @@ public abstract class HSLFSheet implemen
      */
     @Override
     public List<HSLFShape> getShapes() {
-        return getShapeList();
+        PPDrawing ppdrawing = getPPDrawing();
+
+        EscherContainerRecord dg = (EscherContainerRecord) ppdrawing.getEscherRecords()[0];
+        EscherContainerRecord spgr = null;
+
+        for (Iterator<EscherRecord> it = dg.getChildIterator(); it.hasNext();) {
+            EscherRecord rec = it.next();
+            if (rec.getRecordId() == EscherContainerRecord.SPGR_CONTAINER) {
+                spgr = (EscherContainerRecord) rec;
+                break;
+            }
+        }
+        if (spgr == null) {
+            throw new IllegalStateException("spgr not found");
+        }
+
+        List<HSLFShape> shapeList = new ArrayList<HSLFShape>();
+        Iterator<EscherRecord> it = spgr.getChildIterator();
+        if (it.hasNext()) {
+            // skip first item
+            it.next();
+        }
+        for (; it.hasNext();) {
+            EscherContainerRecord sp = (EscherContainerRecord) it.next();
+            HSLFShape sh = HSLFShapeFactory.createShape(sp, null);
+            sh.setSheet(this);
+            shapeList.add(sh);
+        }
+
+        return shapeList;
     }
 
     /**
@@ -347,49 +376,11 @@ public abstract class HSLFSheet implemen
     }
 
     public Iterator<HSLFShape> iterator() {
-        return getShapeList().iterator();
+        return getShapes().iterator();
     }
 
 
     /**
-     * Returns all shapes contained in this Sheet
-     *
-     * @return all shapes contained in this Sheet (Slide or Notes)
-     */
-    protected List<HSLFShape> getShapeList() {
-        PPDrawing ppdrawing = getPPDrawing();
-
-        EscherContainerRecord dg = (EscherContainerRecord) ppdrawing.getEscherRecords()[0];
-        EscherContainerRecord spgr = null;
-
-        for (Iterator<EscherRecord> it = dg.getChildIterator(); it.hasNext();) {
-            EscherRecord rec = it.next();
-            if (rec.getRecordId() == EscherContainerRecord.SPGR_CONTAINER) {
-                spgr = (EscherContainerRecord) rec;
-                break;
-            }
-        }
-        if (spgr == null) {
-            throw new IllegalStateException("spgr not found");
-        }
-
-        List<HSLFShape> shapeList = new ArrayList<HSLFShape>();
-        Iterator<EscherRecord> it = spgr.getChildIterator();
-        if (it.hasNext()) {
-            // skip first item
-            it.next();
-        }
-        for (; it.hasNext();) {
-            EscherContainerRecord sp = (EscherContainerRecord) it.next();
-            HSLFShape sh = HSLFShapeFactory.createShape(sp, null);
-            sh.setSheet(this);
-            shapeList.add(sh);
-        }
-
-        return shapeList;
-    }
-
-    /**
      * @return whether shapes on the master sheet should be shown. By default master graphics is turned off.
      * Sheets that support the notion of master (slide, slideLayout) should override it and
      * check this setting

Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java?rev=1682356&r1=1682355&r2=1682356&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java Thu May 28 23:32:26 2015
@@ -571,10 +571,6 @@ public final class HSLFSlideShow impleme
 							+ _slides.size() + ")");
 		}
 
-		_slides.get(newSlideNumber).setSlideNumber(oldSlideNumber);
-		_slides.get(oldSlideNumber).setSlideNumber(newSlideNumber);
-		Collections.swap(_slides, oldSlideNumber-1, newSlideNumber-1);
-		
 		// The order of slides is defined by the order of slide atom sets in the
 		// SlideListWithText container.
 		SlideListWithText slwt = _documentRecord.getSlideSlideListWithText();
@@ -584,11 +580,16 @@ public final class HSLFSlideShow impleme
 		sas[oldSlideNumber - 1] = sas[newSlideNumber - 1];
 		sas[newSlideNumber - 1] = tmp;
 
+		Collections.swap(_slides, oldSlideNumber - 1, newSlideNumber - 1);
+		_slides.get(newSlideNumber - 1).setSlideNumber(newSlideNumber);
+		_slides.get(oldSlideNumber - 1).setSlideNumber(oldSlideNumber);
+		
 		ArrayList<Record> lst = new ArrayList<Record>();
 		for (SlideAtomsSet s : sas) {
 			lst.add(s.getSlidePersistAtom());
 			lst.addAll(Arrays.asList(s.getSlideRecords()));
 		}
+		
 		Record[] r = lst.toArray(new Record[lst.size()]);
 		slwt.setChildRecord(r);
 	}
@@ -628,7 +629,7 @@ public final class HSLFSlideShow impleme
             records.add(s.getSlidePersistAtom());
             records.addAll(Arrays.asList(s.getSlideRecords()));
 		}
-		if (sa.size() == 0) {
+		if (sa.isEmpty()) {
 			_documentRecord.removeSlideListWithText(slwt);
 		} else {
 			slwt.setSlideAtomsSets(sa.toArray(new SlideAtomsSet[sa.size()]));

Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java?rev=1682356&r1=1682355&r2=1682356&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java Thu May 28 23:32:26 2015
@@ -241,8 +241,8 @@ public final class HSLFTextParagraph imp
             hardAttribute = maskProp != null && maskProp.getValue() == 0;
         }
         if (prop == null && !hardAttribute){
-            HSLFSheet sheet = _parentShape.getSheet();
-            int txtype = _parentShape.getRunType();
+            HSLFSheet sheet = getSheet();
+            int txtype = getRunType();
             HSLFMasterSheet master = sheet.getMasterSheet();
             if (master != null)
                 prop = master.getStyleAttribute(txtype, getIndentLevel(), propName, false);
@@ -600,7 +600,7 @@ public final class HSLFTextParagraph imp
 
         if (prop == null) {
             if (_sheet != null) {
-                int txtype = getParentShape().getRunType();
+                int txtype = getRunType();
                 HSLFMasterSheet master = _sheet.getMasterSheet();
                 if (master != null) {
                     prop = (BitMaskTextProp) master.getStyleAttribute(txtype, getIndentLevel(), ParagraphFlagsTextProp.NAME, false);
@@ -789,10 +789,11 @@ public final class HSLFTextParagraph imp
         * If TextSpecInfoAtom is present, we must update the text size in it,
         * otherwise the ppt will be corrupted
         */
-       TextSpecInfoAtom specAtom = (TextSpecInfoAtom)_txtbox.findFirstOfType(RecordTypes.TextSpecInfoAtom.typeID);
-       int len = rawText.length() + 1;
-       if(specAtom != null && len != specAtom.getCharactersCovered()) {
-           specAtom.reset(len);
+       for (Record r : paragraphs.get(0)._records) {
+           if (r instanceof TextSpecInfoAtom) {
+               ((TextSpecInfoAtom)r).setParentSize(rawText.length()+1);
+               break;
+           }
        }
    }
 
@@ -870,6 +871,12 @@ public final class HSLFTextParagraph imp
        return appendText(paragraphs, text, false);
    }
 
+   public static String getText(List<HSLFTextParagraph> paragraphs) {
+       assert(!paragraphs.isEmpty());
+       String rawText = getRawText(paragraphs);
+       return toExternalString(rawText, paragraphs.get(0).getRunType());
+   }
+   
    public static String getRawText(List<HSLFTextParagraph> paragraphs) {
        StringBuilder sb = new StringBuilder();
        for (HSLFTextParagraph p : paragraphs) {
@@ -1151,7 +1158,7 @@ public final class HSLFTextParagraph imp
         wrapper.appendChildRecord(tha);
 
         TextBytesAtom tba = new TextBytesAtom();
-        tba.setText("\r".getBytes());
+        tba.setText("".getBytes());
         wrapper.appendChildRecord(tba);
 
         StyleTextPropAtom sta = new StyleTextPropAtom(1);
@@ -1162,16 +1169,10 @@ public final class HSLFTextParagraph imp
         HSLFTextParagraph htp = new HSLFTextParagraph(tha, tba, null, sta);
         htp.setParagraphStyle(paraStyle);
         htp._records = new Record[0];
-//        htp.setBullet(false);
-//        htp.setLineSpacing(100);
-//        htp.setLeftMargin(0);
-//        htp.setIndent(0);
-        // set wrap flags
 
         HSLFTextRun htr = new HSLFTextRun(htp);
         htr.setCharacterStyle(charStyle);
-        htr.setText("\r");
-//        htr.setFontColor(Color.black);
+        htr.setText("");
         htp.addTextRun(htr);
 
         return Arrays.asList(htp);

Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextRun.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextRun.java?rev=1682356&r1=1682355&r2=1682356&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextRun.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextRun.java Thu May 28 23:32:26 2015
@@ -39,7 +39,7 @@ public final class HSLFTextRun implement
 	/** The TextRun we belong to */
 	private HSLFTextParagraph parentParagraph;
 	private String _runText = "";
-	private String _fontname;
+	private String _fontFamily;
 	
 	/**
 	 * Our paragraph and character style.
@@ -68,9 +68,9 @@ public final class HSLFTextRun implement
 	 * Supply the SlideShow we belong to
 	 */
 	public void updateSheet() {
-		if (_fontname != null) {
-			setFontName(_fontname);
-			_fontname = null;
+		if (_fontFamily != null) {
+			setFontFamily(_fontFamily);
+			_fontFamily = null;
 		}
 	}
 
@@ -149,7 +149,7 @@ public final class HSLFTextRun implement
 
 		if (prop == null){
 			HSLFSheet sheet = parentParagraph.getSheet();
-			int txtype = parentParagraph.getParentShape().getRunType();
+			int txtype = parentParagraph.getRunType();
 			HSLFMasterSheet master = sheet.getMasterSheet();
 			if (master != null)
 				prop = master.getStyleAttribute(txtype, parentParagraph.getIndentLevel(), propName, true);
@@ -306,16 +306,16 @@ public final class HSLFTextRun implement
 	/**
 	 * Sets the font name to use
 	 */
-	public void setFontName(String fontName) {
+	public void setFontFamily(String fontFamily) {
 	    HSLFSheet sheet = parentParagraph.getSheet();
 	    HSLFSlideShow slideShow = (sheet == null) ? null : sheet.getSlideShow();
 		if (sheet == null || slideShow == null) {
 			//we can't set font since slideshow is not assigned yet
-			_fontname = fontName;
+			_fontFamily = fontFamily;
 			return;
 		}
 		// Get the index for this font (adding if needed)
-		int fontIdx = slideShow.getFontCollection().addFont(fontName);
+		int fontIdx = slideShow.getFontCollection().addFont(fontFamily);
 		setCharTextPropVal("font.index", fontIdx);
 	}
 
@@ -327,7 +327,7 @@ public final class HSLFTextRun implement
         HSLFSheet sheet = parentParagraph.getSheet();
         HSLFSlideShow slideShow = (sheet == null) ? null : sheet.getSlideShow();
 		if (sheet == null || slideShow == null) {
-			return _fontname;
+			return _fontFamily;
 		}
 		int fontIdx = getCharTextPropVal("font.index");
 		if(fontIdx == -1) { return null; }

Modified: poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/AllHSLFModelTests.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/AllHSLFModelTests.java?rev=1682356&r1=1682355&r2=1682356&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/AllHSLFModelTests.java (original)
+++ poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/AllHSLFModelTests.java Thu May 28 23:32:26 2015
@@ -17,7 +17,6 @@
 
 package org.apache.poi.hslf.model;
 
-import org.apache.poi.hslf.usermodel.TestTextRun;
 import org.junit.runner.RunWith;
 import org.junit.runners.Suite;
 
@@ -36,7 +35,6 @@ import org.junit.runners.Suite;
     TestOleEmbedding.class,
     TestPPFont.class,
     TestPPGraphics2D.class,
-    TestPicture.class,
     TestSetBoldItalic.class,
     TestShapes.class,
     TestSheet.class,
@@ -44,9 +42,7 @@ import org.junit.runners.Suite;
     TestSlideMaster.class,
     TestSlides.class,
     TestTable.class,
-    TestTextRun.class,
-    TestTextRunReWrite.class,
-    TestTextShape.class
+    TestTextRunReWrite.class
 })
 public class AllHSLFModelTests {
 }

Modified: poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPPGraphics2D.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPPGraphics2D.java?rev=1682356&r1=1682355&r2=1682356&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPPGraphics2D.java (original)
+++ poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPPGraphics2D.java Thu May 28 23:32:26 2015
@@ -40,7 +40,7 @@ public final class TestPPGraphics2D {
     private HSLFSlideShow ppt;
 
     @Before
-    protected void setUp() throws Exception {
+    public void setUp() throws Exception {
 		ppt = new HSLFSlideShow(_slTests.openResourceAsStream("empty.ppt"));
     }
 

Modified: poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java?rev=1682356&r1=1682355&r2=1682356&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java (original)
+++ poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java Thu May 28 23:32:26 2015
@@ -21,7 +21,6 @@ import static org.junit.Assert.*;
 
 import java.awt.*;
 import java.awt.geom.Rectangle2D;
-import java.awt.geom.Rectangle2D.Double;
 import java.io.*;
 import java.util.ArrayList;
 import java.util.List;
@@ -29,11 +28,8 @@ import java.util.List;
 import org.apache.poi.POIDataSamples;
 import org.apache.poi.ddf.*;
 import org.apache.poi.hslf.usermodel.*;
-import org.apache.poi.sl.usermodel.*;
+import org.apache.poi.sl.usermodel.ShapeType;
 import org.apache.poi.sl.usermodel.StrokeStyle.LineDash;
-import org.apache.poi.sl.usermodel.TextParagraph.BulletStyle;
-import org.apache.poi.sl.usermodel.TextParagraph.FontAlign;
-import org.apache.poi.sl.usermodel.TextParagraph.TextAlign;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -138,6 +134,7 @@ public final class TestShapes {
         }
     }
 
+    @SuppressWarnings("unused")
     @Test
     public void testParagraphs() throws Exception {
         HSLFSlideShow ppt = new HSLFSlideShow();
@@ -196,7 +193,7 @@ public final class TestShapes {
         HSLFTextBox txtbox = new HSLFTextBox();
         rt = txtbox.getTextParagraphs().get(0).getTextRuns().get(0);
         txtbox.setText(val);
-        rt.setFontName("Arial");
+        rt.setFontFamily("Arial");
         rt.setFontSize(42);
         rt.setBold(true);
         rt.setItalic(true);

Modified: poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSheet.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSheet.java?rev=1682356&r1=1682355&r2=1682356&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSheet.java (original)
+++ poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSheet.java Thu May 28 23:32:26 2015
@@ -82,10 +82,13 @@ public final class TestSheet {
         assertTrue(sheet._getSheetNumber() != 0);
         assertTrue(sheet._getSheetRefId() != 0);
 
-        List<HSLFTextParagraph> txt = sheet.getTextParagraphs();
-        assertTrue("no text runs", txt != null && !txt.isEmpty());
-        for (HSLFTextParagraph t : txt) {
-            assertNotNull(t.getSheet());
+        List<List<HSLFTextParagraph>> txt = sheet.getTextParagraphs();
+        // assertTrue("no text runs", txt != null && !txt.isEmpty());
+        // backgrounds.ppt has no texts
+        for (List<HSLFTextParagraph> t : txt) {
+            for (HSLFTextParagraph tp : t) {
+                assertNotNull(tp.getSheet());
+            }
         }
 
         List<HSLFShape> shape = sheet.getShapes();

Modified: poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlideMaster.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlideMaster.java?rev=1682356&r1=1682355&r2=1682356&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlideMaster.java (original)
+++ poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlideMaster.java Thu May 28 23:32:26 2015
@@ -113,10 +113,9 @@ public final class TestSlideMaster {
         HSLFMasterSheet masterSheet = slide.getMasterSheet();
         assertTrue(masterSheet instanceof HSLFTitleMaster);
 
-        List<HSLFTextParagraph> txt = slide.getTextParagraphs();
-        for (int i = 0; i < txt.size(); i++) {
-            HSLFTextRun rt = txt.get(i).getTextRuns().get(0);
-            switch(txt.get(i).getRunType()){
+        for (List<HSLFTextParagraph> txt : slide.getTextParagraphs()) {
+            HSLFTextRun rt = txt.get(0).getTextRuns().get(0);
+            switch(txt.get(0).getRunType()){
                 case TextHeaderAtom.CENTER_TITLE_TYPE:
                     assertEquals("Arial", rt.getFontFamily());
                     assertEquals(32, rt.getFontSize(), 0);
@@ -141,20 +140,22 @@ public final class TestSlideMaster {
         HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("slide_master.ppt"));
         List<HSLFSlide> slide = ppt.getSlides();
         assertEquals(3, slide.size());
-        for (HSLFTextParagraph trun : slide.get(0).getTextParagraphs()) {
-            if (trun.getRunType() == TextHeaderAtom.TITLE_TYPE){
-                HSLFTextRun rt = trun.getTextRuns().get(0);
+        for (List<HSLFTextParagraph> tparas : slide.get(0).getTextParagraphs()) {
+            HSLFTextParagraph tpara = tparas.get(0);
+            if (tpara.getRunType() == TextHeaderAtom.TITLE_TYPE){
+                HSLFTextRun rt = tpara.getTextRuns().get(0);
                 assertEquals(40, rt.getFontSize(), 0);
                 assertEquals(true, rt.isUnderlined());
                 assertEquals("Arial", rt.getFontFamily());
-            } else if (trun.getRunType() == TextHeaderAtom.BODY_TYPE){
-                HSLFTextRun rt = trun.getTextRuns().get(0);
-                assertEquals(0, trun.getIndentLevel());
+            } else if (tpara.getRunType() == TextHeaderAtom.BODY_TYPE){
+                HSLFTextRun rt = tpara.getTextRuns().get(0);
+                assertEquals(0, tpara.getIndentLevel());
                 assertEquals(32, rt.getFontSize(), 0);
                 assertEquals("Arial", rt.getFontFamily());
 
-                rt = trun.getTextRuns().get(1);
-                assertEquals(1, trun.getIndentLevel());
+                tpara = tparas.get(1);
+                rt = tpara.getTextRuns().get(0);
+                assertEquals(1, tpara.getIndentLevel());
                 assertEquals(28, rt.getFontSize(), 0);
                 assertEquals("Arial", rt.getFontFamily());
 
@@ -162,16 +163,17 @@ public final class TestSlideMaster {
         }
 
         ;
-        for (HSLFTextParagraph trun : slide.get(1).getTextParagraphs()) {
-            if (trun.getRunType() == TextHeaderAtom.TITLE_TYPE){
-                HSLFTextRun rt = trun.getTextRuns().get(0);
+        for (List<HSLFTextParagraph> tparas : slide.get(1).getTextParagraphs()) {
+            HSLFTextParagraph tpara = tparas.get(0);
+            if (tpara.getRunType() == TextHeaderAtom.TITLE_TYPE){
+                HSLFTextRun rt = tpara.getTextRuns().get(0);
                 assertEquals(48, rt.getFontSize(), 0);
                 assertEquals(true, rt.isItalic());
                 assertEquals("Georgia", rt.getFontFamily());
-            } else if (trun.getRunType() == TextHeaderAtom.BODY_TYPE){
+            } else if (tpara.getRunType() == TextHeaderAtom.BODY_TYPE){
                 HSLFTextRun rt;
-                rt = trun.getTextRuns().get(0);
-                assertEquals(0, trun.getIndentLevel());
+                rt = tpara.getTextRuns().get(0);
+                assertEquals(0, tpara.getIndentLevel());
                 assertEquals(32, rt.getFontSize(), 0);
                 assertEquals("Courier New", rt.getFontFamily());
             }
@@ -222,16 +224,17 @@ public final class TestSlideMaster {
         HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("slide_master.ppt"));
         HSLFSlide slide = ppt.getSlides().get(0);
         
-        for (HSLFTextParagraph trun : slide.getTextParagraphs()) {
-            if (trun.getRunType() == TextHeaderAtom.TITLE_TYPE){
-                HSLFTextRun rt = trun.getTextRuns().get(0);
+        for (List<HSLFTextParagraph> tparas : slide.getTextParagraphs()) {
+            HSLFTextParagraph tpara = tparas.get(0);
+            if (tpara.getRunType() == TextHeaderAtom.TITLE_TYPE){
+                HSLFTextRun rt = tpara.getTextRuns().get(0);
                 assertEquals(40, rt.getFontSize(), 0);
                 assertEquals(true, rt.isUnderlined());
                 assertEquals("Arial", rt.getFontFamily());
-            } else if (trun.getRunType() == TextHeaderAtom.BODY_TYPE){
+            } else if (tpara.getRunType() == TextHeaderAtom.BODY_TYPE){
                 int indents[] = { 32, 28, 24 };
-                for (HSLFTextRun rt : trun.getTextRuns()) {
-                    int indent = trun.getIndentLevel();
+                for (HSLFTextRun rt : tpara.getTextRuns()) {
+                    int indent = tpara.getIndentLevel();
                     assertEquals(indents[indent], rt.getFontSize(), 0);
                 }
             }

Modified: poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextRunReWrite.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextRunReWrite.java?rev=1682356&r1=1682355&r2=1682356&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextRunReWrite.java (original)
+++ poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextRunReWrite.java Thu May 28 23:32:26 2015
@@ -21,6 +21,7 @@ import static org.junit.Assert.assertEqu
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
+import java.util.List;
 
 import org.apache.poi.POIDataSamples;
 import org.apache.poi.hslf.usermodel.*;
@@ -58,34 +59,37 @@ public final class TestTextRunReWrite {
 
     @Test
 	public void testWritesOutTheSameNonRich() throws Exception {
-    	// Grab the first text run on the first sheet
-    	HSLFTextParagraph tr1 = ss.getSlides().get(0).getTextParagraphs().get(0);
-    	HSLFTextParagraph tr2 = ss.getSlides().get(0).getTextParagraphs().get(1);
-
     	// Ensure the text lengths are as we'd expect to start with
-    	assertEquals(1, ss.getSlides().length);
-    	assertEquals(2, ss.getSlides().get(0).getTextParagraphs().length);
-    	assertEquals(30, tr1.getRawText().length());
-    	assertEquals(179, tr2.getRawText().length());
-
-    	assertEquals(1, tr1.getTextRuns().length);
-    	assertEquals(30, tr1.getTextRuns().get(0).getLength());
-    	assertEquals(30, tr1.getTextRuns().get(0).getRawText().length());
-    	assertEquals(31, tr1.getTextRuns().get(0)._getRawCharacterStyle().getCharactersCovered());
-    	assertEquals(31, tr1.getTextRuns().get(0)._getRawParagraphStyle().getCharactersCovered());
+    	assertEquals(1, ss.getSlides().size());
+    	assertEquals(2, ss.getSlides().get(0).getTextParagraphs().size());
+
+        // Grab the first text run on the first sheet
+        List<HSLFTextParagraph> tr1 = ss.getSlides().get(0).getTextParagraphs().get(0);
+        List<HSLFTextParagraph> tr2 = ss.getSlides().get(0).getTextParagraphs().get(1);
+    	
+    	
+    	assertEquals(30, HSLFTextParagraph.getRawText(tr1).length());
+    	assertEquals(179, HSLFTextParagraph.getRawText(tr2).length());
+
+    	assertEquals(1, tr1.size());
+    	assertEquals(30, HSLFTextParagraph.getText(tr1).length());
+    	assertEquals(30, HSLFTextParagraph.getRawText(tr1).length());
+    	assertEquals(31, tr1.get(0).getTextRuns().get(0).getCharacterStyle().getCharactersCovered());
+    	assertEquals(31, tr1.get(0).getParagraphStyle().getCharactersCovered());
 
     	// Set the text to be as it is now
-    	tr1.setText( tr1.getRawText() );
+    	HSLFTextParagraph.setText(tr1, HSLFTextParagraph.getRawText(tr1));
+    	tr1 = ss.getSlides().get(0).getTextParagraphs().get(0);
 
     	// Check the text lengths are still right
-    	assertEquals(30, tr1.getRawText().length());
-    	assertEquals(179, tr2.getRawText().length());
+    	assertEquals(30, HSLFTextParagraph.getRawText(tr1).length());
+    	assertEquals(179, HSLFTextParagraph.getRawText(tr2).length());
 
-    	assertEquals(1, tr1.getTextRuns().length);
-    	assertEquals(30, tr1.getTextRuns().get(0).getLength());
-    	assertEquals(30, tr1.getTextRuns().get(0).getRawText().length());
-    	assertEquals(31, tr1.getTextRuns().get(0)._getRawCharacterStyle().getCharactersCovered());
-    	assertEquals(31, tr1.getTextRuns().get(0)._getRawParagraphStyle().getCharactersCovered());
+        assertEquals(1, tr1.size());
+        assertEquals(30, HSLFTextParagraph.getText(tr1).length());
+        assertEquals(30, HSLFTextParagraph.getRawText(tr1).length());
+        assertEquals(31, tr1.get(0).getTextRuns().get(0).getCharacterStyle().getCharactersCovered());
+        assertEquals(31, tr1.get(0).getParagraphStyle().getCharactersCovered());
 
 
 		// Write the slideshow out to a byte array
@@ -117,33 +121,32 @@ public final class TestTextRunReWrite {
     @Test
     public void testWritesOutTheSameRich() throws Exception {
     	// Grab the first text run on the first sheet
-    	HSLFTextParagraph tr1 = ss.getSlides().get(0).getTextParagraphs().get(0);
+    	List<HSLFTextParagraph> tr1 = ss.getSlides().get(0).getTextParagraphs().get(0);
 
     	// Get the first rich text run
-    	HSLFTextRun rtr1 = tr1.getTextRuns().get(0);
+    	HSLFTextRun rtr1 = tr1.get(0).getTextRuns().get(0);
 
 
     	// Check that the text sizes are as expected
-    	assertEquals(1, tr1.getTextRuns().length);
-    	assertEquals(30, tr1.getRawText().length());
-    	assertEquals(30, tr1.getTextRuns().get(0).getRawText().length());
+    	assertEquals(1, tr1.get(0).getTextRuns().size());
+        assertEquals(30, HSLFTextParagraph.getRawText(tr1).length());
     	assertEquals(30, rtr1.getLength());
     	assertEquals(30, rtr1.getRawText().length());
-    	assertEquals(31, rtr1._getRawCharacterStyle().getCharactersCovered());
-    	assertEquals(31, rtr1._getRawParagraphStyle().getCharactersCovered());
+    	assertEquals(31, rtr1.getCharacterStyle().getCharactersCovered());
+    	assertEquals(31, tr1.get(0).getParagraphStyle().getCharactersCovered());
 
     	// Set the text to be as it is now
     	rtr1.setText( rtr1.getRawText() );
-    	rtr1 = tr1.getTextRuns().get(0);
+    	rtr1 = tr1.get(0).getTextRuns().get(0);
 
     	// Check that the text sizes are still as expected
-    	assertEquals(1, tr1.getTextRuns().length);
-    	assertEquals(30, tr1.getRawText().length());
-    	assertEquals(30, tr1.getTextRuns().get(0).getRawText().length());
+    	assertEquals(1, tr1.get(0).getTextRuns().size());
+    	assertEquals(30, HSLFTextParagraph.getRawText(tr1).length());
+    	assertEquals(30, tr1.get(0).getTextRuns().get(0).getRawText().length());
     	assertEquals(30, rtr1.getLength());
     	assertEquals(30, rtr1.getRawText().length());
-    	assertEquals(31, rtr1._getRawCharacterStyle().getCharactersCovered());
-    	assertEquals(31, rtr1._getRawParagraphStyle().getCharactersCovered());
+    	assertEquals(31, rtr1.getCharacterStyle().getCharactersCovered());
+    	assertEquals(31, tr1.get(0).getParagraphStyle().getCharactersCovered());
 
 
 		// Write the slideshow out to a byte array

Modified: poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/record/TestTextSpecInfoAtom.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/record/TestTextSpecInfoAtom.java?rev=1682356&r1=1682355&r2=1682356&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/record/TestTextSpecInfoAtom.java (original)
+++ poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/record/TestTextSpecInfoAtom.java Thu May 28 23:32:26 2015
@@ -42,14 +42,14 @@ public final class TestTextSpecInfoAtom
 
     public void testRead() {
         TextSpecInfoAtom spec = new TextSpecInfoAtom(data_1, 0, data_1.length);
-        TextSpecInfoAtom.TextSpecInfoRun[] run = spec.getTextSpecInfoRuns();
+        TextSpecInfoRun[] run = spec.getTextSpecInfoRuns();
         assertEquals(5, run.length);
 
-        assertEquals(10, run[0].length());
-        assertEquals(1, run[1].length());
-        assertEquals(70, run[2].length());
-        assertEquals(9, run[3].length());
-        assertEquals(32, run[4].length());
+        assertEquals(10, run[0].getLength());
+        assertEquals(1, run[1].getLength());
+        assertEquals(70, run[2].getLength());
+        assertEquals(9, run[3].getLength());
+        assertEquals(32, run[4].getLength());
 
     }
 
@@ -66,10 +66,10 @@ public final class TestTextSpecInfoAtom
         TextSpecInfoAtom spec = new TextSpecInfoAtom(data_1, 0, data_1.length);
         spec.reset(32);  //length of the parent text
 
-        TextSpecInfoAtom.TextSpecInfoRun[] run = spec.getTextSpecInfoRuns();
+        TextSpecInfoRun[] run = spec.getTextSpecInfoRuns();
         assertEquals(1, run.length);
 
-        assertEquals(32, run[0].length());
+        assertEquals(32, run[0].getLength());
 
         //serialize and read again
         ByteArrayOutputStream out = new ByteArrayOutputStream();
@@ -77,9 +77,9 @@ public final class TestTextSpecInfoAtom
 
         byte[] result = out.toByteArray();
         TextSpecInfoAtom spec2 = new TextSpecInfoAtom(result, 0, result.length);
-        TextSpecInfoAtom.TextSpecInfoRun[] run2 = spec2.getTextSpecInfoRuns();
+        TextSpecInfoRun[] run2 = spec2.getTextSpecInfoRuns();
         assertEquals(1, run2.length);
 
-        assertEquals(32, run2[0].length());
+        assertEquals(32, run2[0].getLength());
     }
 }

Modified: poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/record/TestTxMasterStyleAtom.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/record/TestTxMasterStyleAtom.java?rev=1682356&r1=1682355&r2=1682356&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/record/TestTxMasterStyleAtom.java (original)
+++ poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/record/TestTxMasterStyleAtom.java Thu May 28 23:32:26 2015
@@ -84,13 +84,13 @@ public final class TestTxMasterStyleAtom
         TextProp prop;
 
         //paragraph styles
-        props = txmaster.getParagraphStyles()[0];
+        props = txmaster.getParagraphStyles().get(0);
 
         prop = props.findByName("alignment");
         assertEquals(1, prop.getValue()); //title has center alignment
 
         //character styles
-        props = txmaster.getCharacterStyles()[0];
+        props = txmaster.getCharacterStyles().get(0);
 
         prop = props.findByName("font.color");
         assertEquals(0x3000000, prop.getValue());
@@ -110,27 +110,27 @@ public final class TestTxMasterStyleAtom
         TextPropCollection props;
         TextProp prop;
 
-        TextPropCollection[] prstyles = txmaster.getParagraphStyles();
-        TextPropCollection[] chstyles = txmaster.getCharacterStyles();
+        List<TextPropCollection> prstyles = txmaster.getParagraphStyles();
+        List<TextPropCollection> chstyles = txmaster.getCharacterStyles();
         assertEquals("TxMasterStyleAtom for TextHeaderAtom.BODY_TYPE " +
-                "must contain styles for 5 indentation levels", 5, prstyles.length);
+                "must contain styles for 5 indentation levels", 5, prstyles.size());
         assertEquals("TxMasterStyleAtom for TextHeaderAtom.BODY_TYPE " +
-                "must contain styles for 5 indentation levels", 5, chstyles.length);
+                "must contain styles for 5 indentation levels", 5, chstyles.size());
 
         //paragraph styles
-        props = prstyles[0];
+        props = prstyles.get(0);
 
         prop = props.findByName("alignment");
         assertEquals(0, prop.getValue());
 
 
-        for (int i = 0; i < prstyles.length; i++) {
-            assertNotNull("text.offset is null for indentation level " + i, prstyles[i].findByName("text.offset"));
-            assertNotNull("bullet.offset is null for indentation level " + i, prstyles[i].findByName("bullet.offset"));
+        for (int i = 0; i < prstyles.size(); i++) {
+            assertNotNull("text.offset is null for indentation level " + i, prstyles.get(i).findByName("text.offset"));
+            assertNotNull("bullet.offset is null for indentation level " + i, prstyles.get(i).findByName("bullet.offset"));
         }
 
         //character styles
-        props = chstyles[0];
+        props = chstyles.get(0);
 
         prop = props.findByName("font.color");
         assertEquals(0x1000000, prop.getValue());
@@ -150,13 +150,13 @@ public final class TestTxMasterStyleAtom
         TextProp prop;
 
         //paragraph styles
-        props = txmaster.getParagraphStyles()[0];
+        props = txmaster.getParagraphStyles().get(0);
 
         prop = props.findByName("alignment");
         assertEquals(0, prop.getValue());
 
         //character styles
-        props = txmaster.getCharacterStyles()[0];
+        props = txmaster.getCharacterStyles().get(0);
 
         prop = props.findByName("font.color");
         assertEquals(0x1000000, prop.getValue());
@@ -176,13 +176,13 @@ public final class TestTxMasterStyleAtom
         TextProp prop;
 
         //paragraph styles
-        props = txmaster.getParagraphStyles()[0];
+        props = txmaster.getParagraphStyles().get(0);
 
         prop = props.findByName("alignment");
         assertEquals(0, prop.getValue()); //title has center alignment
 
         //character styles
-        props = txmaster.getCharacterStyles()[0];
+        props = txmaster.getCharacterStyles().get(0);
 
         prop = props.findByName("font.color");
         assertEquals(0x1000000, prop.getValue());

Modified: poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/AllHSLFUserModelTests.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/AllHSLFUserModelTests.java?rev=1682356&r1=1682355&r2=1682356&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/AllHSLFUserModelTests.java (original)
+++ poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/AllHSLFUserModelTests.java Thu May 28 23:32:26 2015
@@ -37,7 +37,10 @@ import org.junit.runners.Suite;
     TestSheetText.class,
     TestSlideOrdering.class,
     TestSoundData.class,
-    TestFontRendering.class
+    TestFontRendering.class,
+    TestPicture.class,
+    TestTextRun.class,
+    TestTextShape.class
 })
 public class AllHSLFUserModelTests {
 }

Modified: poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNumberedList.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNumberedList.java?rev=1682356&r1=1682355&r2=1682356&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNumberedList.java (original)
+++ poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNumberedList.java Thu May 28 23:32:26 2015
@@ -19,17 +19,15 @@
 
 package org.apache.poi.hslf.usermodel;
 
-import java.util.List;
+import static org.junit.Assert.*;
 
-import junit.framework.TestCase;
+import java.util.List;
 
+import org.apache.poi.POIDataSamples;
 import org.apache.poi.hslf.model.textproperties.TextPFException9;
 import org.apache.poi.hslf.model.textproperties.TextPropCollection;
-import org.apache.poi.hslf.record.EscherTextboxWrapper;
-import org.apache.poi.hslf.record.StyleTextProp9Atom;
-import org.apache.poi.hslf.record.StyleTextPropAtom;
-import org.apache.poi.hslf.record.TextAutoNumberSchemeEnum;
-import org.apache.poi.POIDataSamples;
+import org.apache.poi.hslf.record.*;
+import org.junit.Test;
 
 
 /**
@@ -37,22 +35,21 @@ import org.apache.poi.POIDataSamples;
  * 
  * @author Alex Nikiforov [mailto:anikif@gmail.com]
  */
-public final class TestNumberedList extends TestCase {
+public final class TestNumberedList {
     private static POIDataSamples _slTests = POIDataSamples.getSlideShowInstance();
 
-	protected void setUp() throws Exception {
-	}
-
-	public void testNumberedList() throws Exception {
+    @Test
+    public void testNumberedList() throws Exception {
 		HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("numbers.ppt"));
 		assertTrue("No Exceptions while reading file", true);
 
-		final HSLFSlide[] slides = ppt.getSlides();
-		assertEquals(2, slides.length);
-		checkSlide0(slides[0]);
-		checkSlide1(slides[1]);
+		final List<HSLFSlide> slides = ppt.getSlides();
+		assertEquals(2, slides.size());
+		checkSlide0(slides.get(0));
+		checkSlide1(slides.get(1));
 	}
-	private void checkSlide0(final HSLFSlide s) {
+
+    private void checkSlide0(final HSLFSlide s) {
 		final StyleTextProp9Atom[] numberedListArray = s.getNumberedListInfo();
 		assertNotNull(numberedListArray);
 		assertEquals(1, numberedListArray.length);//Just one text box here
@@ -68,27 +65,33 @@ public final class TestNumberedList exte
 		assertNull(autoNumbers[1].getAutoNumberScheme());
 		assertTrue(TextAutoNumberSchemeEnum.ANM_AlphaLcParenRight == autoNumbers[2].getAutoNumberScheme());
 			
-		HSLFTextParagraph[] textRuns = s.getTextParagraphs();
-		assertEquals(2, textRuns.length);
-
-		HSLFTextRun textRun = textRuns[0].getTextRuns()[0];
-		assertEquals("titTe", textRun.getRawText());
-		assertEquals(1, textRuns[0].getTextRuns().length);
-		assertFalse(textRun.isBullet());
+		List<List<HSLFTextParagraph>> textParass = s.getTextParagraphs();
+		assertEquals(2, textParass.size());
 
-		assertEquals("This is a text placeholder that \rfollows the design pattern\rJust a test\rWithout any paragraph\rSecond paragraph first line c) ;\rSecond paragraph second line d) . \r", textRuns[1].getRawText());
+		List<HSLFTextParagraph> textParas = textParass.get(0);
+		assertEquals("titTe", HSLFTextParagraph.getRawText(textParas));
+		assertEquals(1, textParas.size());
+		assertFalse(textParas.get(0).isBullet());
+
+		String expected =
+	        "This is a text placeholder that \r" +
+	        "follows the design pattern\r" +
+	        "Just a test\rWithout any paragraph\r" +
+	        "Second paragraph first line c) ;\r" +
+	        "Second paragraph second line d) . \r";
+		assertEquals(expected, HSLFTextParagraph.getRawText(textParass.get(1)));
 		
 		final EscherTextboxWrapper[] styleAtoms = s.getTextboxWrappers();
-		assertEquals(textRuns.length, styleAtoms.length);
+		assertEquals(textParass.size(), styleAtoms.length);
 		final EscherTextboxWrapper wrapper =  styleAtoms[1];
 		final StyleTextPropAtom styleTextPropAtom = wrapper.getStyleTextPropAtom();
 		final List<TextPropCollection> textProps = styleTextPropAtom.getCharacterStyles();
-		final TextPropCollection[] props = (TextPropCollection[]) textProps.toArray(new TextPropCollection[textProps.size()]);
-		assertEquals(60, props[0].getCharactersCovered());
-		assertEquals(34, props[1].getCharactersCovered());
-		assertEquals(68, props[2].getCharactersCovered());
+		assertEquals(60, textProps.get(0).getCharactersCovered());
+		assertEquals(34, textProps.get(1).getCharactersCovered());
+		assertEquals(68, textProps.get(2).getCharactersCovered());
 	}
-	private void checkSlide1(final HSLFSlide s) {
+
+    private void checkSlide1(final HSLFSlide s) {
 		final StyleTextProp9Atom[] numberedListArray = s.getNumberedListInfo();
 		assertNotNull(numberedListArray);
 		assertEquals(1, numberedListArray.length);//Just one text box here
@@ -104,25 +107,30 @@ public final class TestNumberedList exte
 		assertNull(autoNumbers[1].getAutoNumberScheme());
 		assertTrue(TextAutoNumberSchemeEnum.ANM_AlphaUcPeriod == autoNumbers[2].getAutoNumberScheme());
 
-		final HSLFTextParagraph[] textRuns = s.getTextParagraphs();
-		assertEquals(2, textRuns.length);
-
-		HSLFTextRun textRun = textRuns[0].getTextRuns()[0];
-		assertEquals("Second Slide Title", textRun.getRawText());
-		assertEquals(1, textRuns[0].getTextRuns().length);
-		assertFalse(textRun.isBullet());
+		final List<List<HSLFTextParagraph>> textParass = s.getTextParagraphs();
+		assertEquals(2, textParass.size());
 
-		assertEquals("This is a text placeholder that \rfollows the design pattern\rJust a test\rWithout any paragraph\rSecond paragraph first line c) ;\rSecond paragraph second line d) . \r", textRuns[1].getRawText());
+		List<HSLFTextParagraph> textParas = textParass.get(0);
+		assertEquals("Second Slide Title", HSLFTextParagraph.getRawText(textParas));
+		assertEquals(1, textParas.size());
+		assertFalse(textParas.get(0).isBullet());
+
+		String expected =
+	        "This is a text placeholder that \r" +
+	        "follows the design pattern\r" +
+	        "Just a test\rWithout any paragraph\r" +
+	        "Second paragraph first line c) ;\r" +
+	        "Second paragraph second line d) . \r";		        
+		assertEquals(expected, HSLFTextParagraph.getRawText(textParass.get(1)));
 		
 		final EscherTextboxWrapper[] styleAtoms = s.getTextboxWrappers();
-		assertEquals(textRuns.length, styleAtoms.length);
+		assertEquals(textParass.size(), styleAtoms.length);
 		final EscherTextboxWrapper wrapper =  styleAtoms[1];
 		final StyleTextPropAtom styleTextPropAtom = wrapper.getStyleTextPropAtom();
 		final List<TextPropCollection> textProps = styleTextPropAtom.getCharacterStyles();
 		
-		final TextPropCollection[] props = (TextPropCollection[]) textProps.toArray(new TextPropCollection[textProps.size()]);
-		assertEquals(33, props[0].getCharactersCovered());
-		assertEquals(61, props[1].getCharactersCovered());
-		assertEquals(68, props[2].getCharactersCovered());
+		assertEquals(33, textProps.get(0).getCharactersCovered());
+		assertEquals(61, textProps.get(1).getCharactersCovered());
+		assertEquals(68, textProps.get(2).getCharactersCovered());
 	}
 }

Modified: poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNumberedList2.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNumberedList2.java?rev=1682356&r1=1682355&r2=1682356&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNumberedList2.java (original)
+++ poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNumberedList2.java Thu May 28 23:32:26 2015
@@ -19,17 +19,15 @@
 
 package org.apache.poi.hslf.usermodel;
 
-import java.util.List;
+import static org.junit.Assert.*;
 
-import junit.framework.TestCase;
+import java.util.List;
 
+import org.apache.poi.POIDataSamples;
 import org.apache.poi.hslf.model.textproperties.TextPFException9;
 import org.apache.poi.hslf.model.textproperties.TextPropCollection;
-import org.apache.poi.hslf.record.EscherTextboxWrapper;
-import org.apache.poi.hslf.record.StyleTextProp9Atom;
-import org.apache.poi.hslf.record.StyleTextPropAtom;
-import org.apache.poi.hslf.record.TextAutoNumberSchemeEnum;
-import org.apache.poi.POIDataSamples;
+import org.apache.poi.hslf.record.*;
+import org.junit.Test;
 
 
 /**
@@ -40,20 +38,18 @@ import org.apache.poi.POIDataSamples;
  * 
  * @author Alex Nikiforov [mailto:anikif@gmail.com]
  */
-public final class TestNumberedList2 extends TestCase {
+public final class TestNumberedList2 {
     private static POIDataSamples _slTests = POIDataSamples.getSlideShowInstance();
 
-	protected void setUp() throws Exception {
-	}
-
+    @Test
 	public void testNumberedList() throws Exception {
 		HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("numbers2.ppt"));
 		assertTrue("No Exceptions while reading file", true);
 
-		final HSLFSlide[] slides = ppt.getSlides();
-		assertEquals(2, slides.length);
-		checkSlide0(slides[0]);
-		checkSlide1(slides[1]);
+		final List<HSLFSlide> slides = ppt.getSlides();
+		assertEquals(2, slides.size());
+		checkSlide0(slides.get(0));
+		checkSlide1(slides.get(1));
 	}
 	private void checkSlide0(final HSLFSlide s) {
 		final StyleTextProp9Atom[] numberedListArray = s.getNumberedListInfo();
@@ -73,18 +69,22 @@ public final class TestNumberedList2 ext
 		assertTrue(TextAutoNumberSchemeEnum.ANM_ArabicPeriod == autoNumbersOfTextBox1[0].getAutoNumberScheme());
 
 		
-		HSLFTextParagraph[] textRuns = s.getTextParagraphs();
-		assertEquals(2, textRuns.length);
+		List<List<HSLFTextParagraph>> textParass = s.getTextParagraphs();
+		assertEquals(2, textParass.size());
 
-		HSLFTextRun textRun = textRuns[0].getTextRuns()[0];
-		assertEquals("List Item One\rList Item Two\rList Item Three", textRun.getRawText());
-		assertEquals(1, textRuns[0].getTextRuns().length);
-		assertTrue(textRun.isBullet());
-
-		assertEquals("A numbered list may start at any number \rThis would be used as a continuation list on another page\rThis list should start with #6", textRuns[1].getRawText());
+		List<HSLFTextParagraph> textParas = textParass.get(0);
+		assertEquals("List Item One\rList Item Two\rList Item Three", HSLFTextParagraph.getRawText(textParas));
+		assertEquals(3, textParas.size());
+		assertTrue(textParas.get(0).isBullet());
+
+		String expected =
+	        "A numbered list may start at any number \r" +
+	        "This would be used as a continuation list on another page\r" +
+            "This list should start with #6";
+		assertEquals(expected, HSLFTextParagraph.getRawText(textParass.get(1)));
 		
 		final EscherTextboxWrapper[] styleAtoms = s.getTextboxWrappers();
-		assertEquals(textRuns.length, styleAtoms.length);
+		assertEquals(textParass.size(), styleAtoms.length);
 		checkSingleRunWrapper(44, styleAtoms[0]);
 		checkSingleRunWrapper(130, styleAtoms[1]);
 	}
@@ -99,19 +99,21 @@ public final class TestNumberedList2 ext
 		assertEquals(Short.valueOf((short)1), autoNumbersOfTextBox[0].getAutoNumberStartNumber());//Default value = 1 will be used 
 		assertTrue(TextAutoNumberSchemeEnum.ANM_ArabicPeriod == autoNumbersOfTextBox[0].getAutoNumberScheme());
 			
-		HSLFTextParagraph[] textRuns = s.getTextParagraphs();
-		assertEquals(3, textRuns.length);
-
-		HSLFTextRun textRun = textRuns[0].getTextRuns()[0];
-		assertEquals("Bulleted list\rMore bullets", textRun.getRawText());
-		assertEquals(1, textRuns[0].getTextRuns().length);
-		assertTrue(textRun.isBullet());
+		List<List<HSLFTextParagraph>> textParass = s.getTextParagraphs();
+		assertEquals(3, textParass.size());
 
-		assertEquals("Numbered list between two bulleted lists\rSecond numbered list item", textRuns[1].getRawText());
-		assertEquals("Second bulleted list \u2013 should appear after numbered list\rMore bullets", textRuns[2].getRawText());
+		List<HSLFTextParagraph> textParas = textParass.get(0);
+		assertEquals("Bulleted list\rMore bullets", HSLFTextParagraph.getRawText(textParas));
+		assertEquals(2, textParas.size());
+		assertTrue(textParas.get(0).isBullet());
+
+		String expected = "Numbered list between two bulleted lists\rSecond numbered list item";
+		assertEquals(expected, HSLFTextParagraph.getRawText(textParass.get(1)));
+		expected = "Second bulleted list \u2013 should appear after numbered list\rMore bullets";
+		assertEquals(expected, HSLFTextParagraph.getRawText(textParass.get(2)));
 		
 		final EscherTextboxWrapper[] styleAtoms = s.getTextboxWrappers();
-		assertEquals(textRuns.length, styleAtoms.length);
+		assertEquals(textParass.size(), styleAtoms.length);
 		checkSingleRunWrapper(27, styleAtoms[0]);
 		checkSingleRunWrapper(67, styleAtoms[1]);
 		checkSingleRunWrapper(70, styleAtoms[2]);
@@ -120,7 +122,6 @@ public final class TestNumberedList2 ext
 		final StyleTextPropAtom styleTextPropAtom = wrapper.getStyleTextPropAtom();
 		final List<TextPropCollection> textProps = styleTextPropAtom.getCharacterStyles();
 		assertEquals(1, textProps.size());
-		final TextPropCollection[] props = (TextPropCollection[]) textProps.toArray(new TextPropCollection[textProps.size()]);
-		assertEquals(exceptedLength, props[0].getCharactersCovered());
+		assertEquals(exceptedLength, textProps.get(0).getCharactersCovered());
 	}
 }



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