poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kiwiwi...@apache.org
Subject svn commit: r1684773 [2/3] - in /poi/branches/common_sl: src/examples/src/org/apache/poi/hslf/examples/ src/java/org/apache/poi/ddf/ src/java/org/apache/poi/hssf/usermodel/ src/ooxml/java/org/apache/poi/xslf/usermodel/ src/scratchpad/src/org/apache/poi...
Date Wed, 10 Jun 2015 22:23:48 GMT
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=1684773&r1=1684772&r2=1684773&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 Wed Jun 10 22:23:47 2015
@@ -17,7 +17,10 @@
 
 package org.apache.poi.hslf.usermodel;
 
+import static org.apache.poi.hslf.record.RecordTypes.OutlineTextRefAtom;
+
 import java.awt.Color;
+import java.io.IOException;
 import java.util.*;
 
 import org.apache.poi.hslf.model.PPFont;
@@ -52,8 +55,7 @@ public final class HSLFTextParagraph imp
 	private final TextHeaderAtom _headerAtom;
 	private TextBytesAtom  _byteAtom;
 	private TextCharsAtom  _charAtom;
-	private StyleTextPropAtom _styleAtom;
-	private TextPropCollection _paragraphStyle = new TextPropCollection(1, TextPropType.paragraph);
+	private final TextPropCollection _paragraphStyle = new TextPropCollection(1, TextPropType.paragraph);
 
     protected TextRulerAtom _ruler;
 	protected List<HSLFTextRun> _runs = new ArrayList<HSLFTextRun>();
@@ -61,11 +63,6 @@ public final class HSLFTextParagraph imp
     private HSLFSheet _sheet;
     private int shapeId;
 
-    /**
-     * all text run records that follow TextHeaderAtom.
-     * (there can be misc InteractiveInfo, TxInteractiveInfo and other records)
-     */
-    private Record[] _records;
 	// private StyleTextPropAtom styleTextPropAtom;
 	private StyleTextProp9Atom styleTextProp9Atom;
 
@@ -76,32 +73,30 @@ public final class HSLFTextParagraph imp
     * @param tha the TextHeaderAtom that defines what's what
     * @param tba the TextBytesAtom containing the text or null if {@link TextCharsAtom} is provided
     * @param tca the TextCharsAtom containing the text or null if {@link TextBytesAtom} is provided
-    * @param sta the StyleTextPropAtom which defines the character stylings
 	 */
 	/* package */ HSLFTextParagraph(
         TextHeaderAtom tha,
         TextBytesAtom tba,
-        TextCharsAtom tca,
-        StyleTextPropAtom sta
+        TextCharsAtom tca
     ) {
+	    if (tha == null)  {
+	        throw new IllegalArgumentException("TextHeaderAtom must be set.");
+	    }
 		_headerAtom = tha;
-		_styleAtom = sta;
         _byteAtom = tba;
         _charAtom = tca;
 	}
 
     /* package */ HSLFTextParagraph(HSLFTextParagraph other) {
-            _headerAtom = other._headerAtom;
-            _styleAtom = other._styleAtom;
-            _byteAtom = other._byteAtom;
-            _charAtom = other._charAtom;
-            _paragraphStyle = other._paragraphStyle;
-            _parentShape = other._parentShape;
-            _sheet = other._sheet;
-            _ruler = other._ruler; // ????
-            shapeId = other.shapeId;
-            _records = other._records;
-        }
+        _headerAtom = other._headerAtom;
+        _byteAtom = other._byteAtom;
+        _charAtom = other._charAtom;
+        _parentShape = other._parentShape;
+        _sheet = other._sheet;
+        _ruler = other._ruler;
+        shapeId = other.shapeId;
+        _paragraphStyle.copy(other._paragraphStyle);
+    }
 
 	public void addTextRun(HSLFTextRun run) {
 	    _runs.add(run);
@@ -120,7 +115,7 @@ public final class HSLFTextParagraph imp
 	}
 
 	public void setParagraphStyle(TextPropCollection paragraphStyle) {
-	    _paragraphStyle = paragraphStyle;
+	    _paragraphStyle.copy(paragraphStyle);
 	}
 
 	/**
@@ -196,20 +191,52 @@ public final class HSLFTextParagraph imp
         _ruler = getTextRuler();
         if (_ruler == null) {
             _ruler = TextRulerAtom.getParagraphInstance();
-            _headerAtom.getParentRecord().appendChildRecord(_ruler);
+            Record childAfter = _byteAtom;
+            if (childAfter == null) childAfter = _charAtom;
+            if (childAfter == null) childAfter = _headerAtom;
+            _headerAtom.getParentRecord().addChildAfter(_ruler, childAfter);
         }
         return _ruler;
     }
 
     /**
-     * Returns records that make up this text run
+     * Returns records that make up the list of text paragraphs
+     * (there can be misc InteractiveInfo, TxInteractiveInfo and other records)
      *
      * @return text run records
      */
     public Record[] getRecords(){
-        return _records;
+        Record r[] = _headerAtom.getParentRecord().getChildRecords();
+        return getRecords(r, new int[]{0}, _headerAtom);
     }
 
+    private static Record[] getRecords(Record[] records, int[] startIdx, TextHeaderAtom headerAtom) {
+        if (records == null) {
+            throw new NullPointerException("records need to be set.");
+        }
+        
+        for (; startIdx[0] < records.length; startIdx[0]++) {
+            Record r = records[startIdx[0]];
+            if (r instanceof TextHeaderAtom && (headerAtom == null || r == headerAtom)) break;
+        }
+
+        if (startIdx[0] >= records.length) {
+            logger.log(POILogger.INFO, "header atom wasn't found - container might contain only an OutlineTextRefAtom");
+            return new Record[0];
+        }
+        
+        int length;
+        for (length = 1; startIdx[0]+length < records.length; length++) {
+            if (records[startIdx[0]+length] instanceof TextHeaderAtom) break;
+        }
+        
+        Record result[] = new Record[length];
+        System.arraycopy(records, startIdx[0], result, 0, length);
+        startIdx[0] += length;
+        
+        return result;
+    }
+    
     /** Numbered List info */
 	public void setStyleTextProp9Atom(final StyleTextProp9Atom styleTextProp9Atom) {
 		this.styleTextProp9Atom = styleTextProp9Atom;
@@ -220,11 +247,6 @@ public final class HSLFTextParagraph imp
 		return this.styleTextProp9Atom;
 	}
 
-    /** Characters covered */
-	public StyleTextPropAtom getStyleTextPropAtom() {
-		return this._styleAtom;
-	}
-
 	/**
      * Fetch the value of the given Paragraph related TextProp.
      * Returns -1 if that TextProp isn't present.
@@ -232,14 +254,9 @@ public final class HSLFTextParagraph imp
      *  Master Sheet will apply.
      */
     private int getParaTextPropVal(String propName) {
-        TextProp prop = null;
-        boolean hardAttribute = false;
-        if (_paragraphStyle != null){
-            prop = _paragraphStyle.findByName(propName);
-
-            BitMaskTextProp maskProp = (BitMaskTextProp)_paragraphStyle.findByName(ParagraphFlagsTextProp.NAME);
-            hardAttribute = maskProp != null && maskProp.getValue() == 0;
-        }
+        TextProp prop = _paragraphStyle.findByName(propName);
+        BitMaskTextProp maskProp = (BitMaskTextProp)_paragraphStyle.findByName(ParagraphFlagsTextProp.NAME);
+        boolean hardAttribute = (maskProp != null && maskProp.getValue() == 0);
         if (prop == null && !hardAttribute){
             HSLFSheet sheet = getSheet();
             int txtype = getRunType();
@@ -258,11 +275,6 @@ public final class HSLFTextParagraph imp
      */
     public void setParaTextPropVal(String propName, int val) {
         // Ensure we have the StyleTextProp atom we're going to need
-        if(_paragraphStyle == null) {
-            _styleAtom = findStyleAtomPresent(_headerAtom, -1);
-            _paragraphStyle = _styleAtom.getParagraphStyles().get(0);
-        }
-
         assert(_paragraphStyle!=null);
         TextProp tp = fetchOrAddTextProp(_paragraphStyle, propName);
         tp.setValue(val);
@@ -615,10 +627,7 @@ public final class HSLFTextParagraph imp
 
    protected void setFlag(int index, boolean value) {
        // Ensure we have the StyleTextProp atom we're going to need
-       if(_paragraphStyle == null) {
-           _paragraphStyle = new TextPropCollection(1, TextPropType.paragraph);
-       }
-
+       assert(_paragraphStyle!=null);
        BitMaskTextProp prop = (BitMaskTextProp) fetchOrAddTextProp(_paragraphStyle, ParagraphFlagsTextProp.NAME);
        prop.setSubValue(value,index);
    }
@@ -653,12 +662,13 @@ public final class HSLFTextParagraph imp
        boolean afterHeader = false;
        StyleTextPropAtom style = null;
        for (Record record : header.getParentRecord().getChildRecords()) {
-           if (afterHeader && record.getRecordType() == RecordTypes.TextHeaderAtom.typeID) {
+           long rt = record.getRecordType();
+           if (afterHeader && rt == RecordTypes.TextHeaderAtom.typeID) {
                // already on the next header, quit searching
                break;
            }
            afterHeader |= (header == record);
-           if (afterHeader && record.getRecordType() == RecordTypes.StyleTextPropAtom.typeID) {
+           if (afterHeader && rt == RecordTypes.StyleTextPropAtom.typeID) {
                // found it
                style = (StyleTextPropAtom)record;
            }
@@ -789,12 +799,20 @@ public final class HSLFTextParagraph imp
         * If TextSpecInfoAtom is present, we must update the text size in it,
         * otherwise the ppt will be corrupted
         */
-       for (Record r : paragraphs.get(0)._records) {
+       for (Record r : paragraphs.get(0).getRecords()) {
            if (r instanceof TextSpecInfoAtom) {
                ((TextSpecInfoAtom)r).setParentSize(rawText.length()+1);
                break;
            }
        }
+       
+       if (_txtbox instanceof EscherTextboxWrapper) {
+           try {
+               ((EscherTextboxWrapper)_txtbox).writeOut(null);
+           } catch (IOException e) {
+               throw new RuntimeException("failed dummy write", e);
+           }
+       }
    }
 
    /**
@@ -817,7 +835,7 @@ public final class HSLFTextParagraph imp
            if (!isFirst) {
                TextPropCollection tpc = htp.getParagraphStyle();
                HSLFTextParagraph prevHtp = htp;
-               htp = new HSLFTextParagraph(htp._headerAtom, htp._byteAtom, htp._charAtom, htp._styleAtom);
+               htp = new HSLFTextParagraph(htp._headerAtom, htp._byteAtom, htp._charAtom);
                htp.getParagraphStyle().copy(tpc);
                htp.setParentShape(prevHtp.getParentShape());
                htp.setShapeId(prevHtp.getShapeId());
@@ -930,24 +948,14 @@ public final class HSLFTextParagraph imp
    /**
     * For a given PPDrawing, grab all the TextRuns
     */
-   public static List<List<HSLFTextParagraph>> findTextParagraphs(PPDrawing ppdrawing) {
+   public static List<List<HSLFTextParagraph>> findTextParagraphs(PPDrawing ppdrawing, HSLFSheet sheet) {
        List<List<HSLFTextParagraph>> runsV = new ArrayList<List<HSLFTextParagraph>>();
        for (EscherTextboxWrapper wrapper : ppdrawing.getTextboxWrappers()) {
-           runsV.addAll(findTextParagraphs(wrapper));
+           runsV.add(findTextParagraphs(wrapper, sheet));
        }
        return runsV;
    }
-   /**
-    * Scans through the supplied record array, looking for
-    * a TextHeaderAtom followed by one of a TextBytesAtom or
-    * a TextCharsAtom. Builds up TextRuns from these
-    *
-    * @param records the records to build from
-    * @param found   vector to add any found to
-    */
-   protected static List<List<HSLFTextParagraph>> findTextParagraphs(final Record[] records) {
-       return findTextParagraphs(records, null);
-   }
+
    /**
     * Scans through the supplied record array, looking for
     * a TextHeaderAtom followed by one of a TextBytesAtom or
@@ -955,14 +963,73 @@ public final class HSLFTextParagraph imp
     *
     * @param wrapper an EscherTextboxWrapper
     */
-   protected static List<List<HSLFTextParagraph>> findTextParagraphs(EscherTextboxWrapper wrapper) {
+   protected static List<HSLFTextParagraph> findTextParagraphs(EscherTextboxWrapper wrapper, HSLFSheet sheet) {
        // propagate parents to parent-aware records
        RecordContainer.handleParentAwareRecords(wrapper);
        int shapeId = wrapper.getShapeId();
-       List<List<HSLFTextParagraph>> rv = findTextParagraphs(wrapper.getChildRecords(), wrapper.getStyleTextProp9Atom());
-       for (List<HSLFTextParagraph> htpList : rv) {
-           for (HSLFTextParagraph htp : htpList) {
+       List<HSLFTextParagraph> rv = null;
+       
+       OutlineTextRefAtom ota = (OutlineTextRefAtom)wrapper.findFirstOfType(OutlineTextRefAtom.typeID);
+       if (ota != null) {
+           // if we are based on an outline, there are no further records to be parsed from the wrapper
+           if (sheet == null) {
+               throw new RuntimeException("Outline atom reference can't be solved without a sheet record");
+           }
+           
+           List<List<HSLFTextParagraph>> sheetRuns = sheet.getTextParagraphs();
+           assert(sheetRuns != null);
+           
+           int idx = ota.getTextIndex();
+           for (List<HSLFTextParagraph> r : sheetRuns) {
+               if (r.isEmpty()) continue;
+               int ridx = r.get(0).getIndex();
+               if (ridx > idx) break;
+               if (ridx == idx) {
+                   if (rv == null) {
+                       rv = r;
+                   } else {
+                       // create a new container
+                       // TODO: ... is this case really happening?
+                       rv = new ArrayList<HSLFTextParagraph>(rv);
+                       rv.addAll(r);
+                   }
+               }
+           }
+           if(rv == null || rv.isEmpty()) {
+               logger.log(POILogger.WARN, "text run not found for OutlineTextRefAtom.TextIndex=" + idx);
+           }
+       } else {
+           if (sheet != null) {
+               // check sheet runs first, so we get exactly the same paragraph list
+               List<List<HSLFTextParagraph>> sheetRuns = sheet.getTextParagraphs();
+               assert(sheetRuns != null);
+
+               for (List<HSLFTextParagraph> paras : sheetRuns) {
+                   if (!paras.isEmpty() && paras.get(0)._headerAtom.getParentRecord() == wrapper) {
+                       rv = paras;
+                       break;
+                   }
+               }
+           }
+           
+           if (rv == null) {
+               // if we haven't found the wrapper in the sheet runs, create a new paragraph list from its record
+               List<List<HSLFTextParagraph>> rvl = findTextParagraphs(wrapper.getChildRecords());
+               switch (rvl.size()) {
+               case 0: break; // nothing found
+               case 1: rv = rvl.get(0); break; // normal case
+               default:
+                   throw new RuntimeException("TextBox contains more than one list of paragraphs.");
+               }
+           }
+       }
+       
+       if (rv !=  null) {
+           StyleTextProp9Atom styleTextProp9Atom = wrapper.getStyleTextProp9Atom();
+           
+           for (HSLFTextParagraph htp : rv) {
                htp.setShapeId(shapeId);
+               htp.setStyleTextProp9Atom(styleTextProp9Atom);
            }
        }
        return rv;
@@ -974,77 +1041,59 @@ public final class HSLFTextParagraph imp
     * a TextCharsAtom. Builds up TextRuns from these
     *
     * @param records the records to build from
-    * @param styleTextProp9Atom an optional StyleTextProp9Atom with numbered lists info
     */
-    protected static List<List<HSLFTextParagraph>> findTextParagraphs(Record[] records, StyleTextProp9Atom styleTextProp9Atom) {
+    protected static List<List<HSLFTextParagraph>> findTextParagraphs(Record[] records) {
         List<List<HSLFTextParagraph>> paragraphCollection = new ArrayList<List<HSLFTextParagraph>>();
 
-        if (records == null) {
-            throw new NullPointerException("records need to be filled.");
-        }
-
-        int recordIdx;
-        for (recordIdx = 0; recordIdx < records.length; recordIdx++) {
-            if (records[recordIdx] instanceof TextHeaderAtom) break;
-        }
-
-        if (recordIdx == records.length) {
-            logger.log(POILogger.INFO, "No text records found.");
-            return paragraphCollection;
-        }
-
-        for (int slwtIndex = 0; recordIdx < records.length; slwtIndex++) {
-            List<HSLFTextParagraph> paragraphs = new ArrayList<HSLFTextParagraph>();
-            paragraphCollection.add(paragraphs);
-
-            TextHeaderAtom    header = (TextHeaderAtom)records[recordIdx++];
+        int[] recordIdx = {0};
+        
+        for (int slwtIndex = 0; recordIdx[0] < records.length; slwtIndex++) {
+            TextHeaderAtom    header = null;
             TextBytesAtom     tbytes = null;
             TextCharsAtom     tchars = null;
             TextRulerAtom     ruler  = null;
             MasterTextPropAtom indents = null;
 
-            List<Record> otherRecordList = new ArrayList<Record>();
-
-            for (; recordIdx < records.length; recordIdx++) {
-                Record r = records[recordIdx];
+            for (Record r : getRecords(records, recordIdx, null)) {
                 long rt = r.getRecordType();
-                if (RecordTypes.TextHeaderAtom.typeID == rt) break;
-                else if (RecordTypes.TextBytesAtom.typeID == rt) tbytes = (TextBytesAtom)r;
-                else if (RecordTypes.TextCharsAtom.typeID == rt) tchars = (TextCharsAtom)r;
-                // don't search for RecordTypes.StyleTextPropAtom.typeID here ... see findStyleAtomPresent below
-                else if (RecordTypes.TextRulerAtom.typeID == rt) ruler = (TextRulerAtom)r;
-                else if (RecordTypes.MasterTextPropAtom.typeID == rt) {
+                if (RecordTypes.TextHeaderAtom.typeID == rt) {
+                    header = (TextHeaderAtom)r;
+                } else if (RecordTypes.TextBytesAtom.typeID == rt) {
+                    tbytes = (TextBytesAtom)r;
+                } else if (RecordTypes.TextCharsAtom.typeID == rt) {
+                    tchars = (TextCharsAtom)r;
+                } else if (RecordTypes.TextRulerAtom.typeID == rt) {
+                    ruler = (TextRulerAtom)r;
+                } else if (RecordTypes.MasterTextPropAtom.typeID == rt) {
                     indents = (MasterTextPropAtom)r;
-                    otherRecordList.add(indents);
-                } else {
-                    otherRecordList.add(r);
                 }
+                // don't search for RecordTypes.StyleTextPropAtom.typeID here ... see findStyleAtomPresent below
             }
 
-            assert(header != null);
+            if (header == null) break;
+            
             if (header.getParentRecord() instanceof SlideListWithText) {
                 // runs found in PPDrawing are not linked with SlideListWithTexts
                 header.setIndex(slwtIndex);
             }
 
-            Record otherRecords[] = otherRecordList.toArray(new Record[otherRecordList.size()]);
-
             if (tbytes == null && tchars == null) {
                 tbytes = new TextBytesAtom();
-                // header.getParentRecord().addChildAfter(tbytes, header);
+                // don't add record yet - set it in storeText
                 logger.log(POILogger.INFO, "bytes nor chars atom doesn't exist. Creating dummy record for later saving.");
             }
 
             String rawText = (tchars != null) ? tchars.getText() : tbytes.getText();
             StyleTextPropAtom styles = findStyleAtomPresent(header, rawText.length());
 
+            List<HSLFTextParagraph> paragraphs = new ArrayList<HSLFTextParagraph>();
+            paragraphCollection.add(paragraphs);
+            
             // split, but keep delimiter
             for (String para : rawText.split("(?<=\r)")) {
-                HSLFTextParagraph tpara = new HSLFTextParagraph(header, tbytes, tchars, styles);
+                HSLFTextParagraph tpara = new HSLFTextParagraph(header, tbytes, tchars);
                 paragraphs.add(tpara);
-                tpara.setStyleTextProp9Atom(styleTextProp9Atom);
                 tpara._ruler = ruler;
-                tpara._records = otherRecords;
                 tpara.getParagraphStyle().updateTextSize(para.length());
 
                 HSLFTextRun trun = new HSLFTextRun(tpara);
@@ -1059,6 +1108,10 @@ public final class HSLFTextParagraph imp
             }
         }
 
+        if (paragraphCollection.isEmpty()) {
+            logger.log(POILogger.DEBUG, "No text records found.");
+        }
+        
         return paragraphCollection;
     }
 
@@ -1166,9 +1219,8 @@ public final class HSLFTextParagraph imp
         TextPropCollection charStyle = sta.addCharacterTextPropCollection(1);
         wrapper.appendChildRecord(sta);
 
-        HSLFTextParagraph htp = new HSLFTextParagraph(tha, tba, null, sta);
+        HSLFTextParagraph htp = new HSLFTextParagraph(tha, tba, null);
         htp.setParagraphStyle(paraStyle);
-        htp._records = new Record[0];
 
         HSLFTextRun htr = new HSLFTextRun(htp);
         htr.setCharacterStyle(charStyle);

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=1684773&r1=1684772&r2=1684773&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 Wed Jun 10 22:23:47 2015
@@ -92,7 +92,7 @@ public final class HSLFTextRun implement
 	 * Change the text
 	 */
 	public void setText(String text) {
-	    _runText = text;
+	    _runText = HSLFTextParagraph.toInternalString(text);
 	}
 
 	// --------------- Internal helpers on rich text properties -------

Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextShape.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextShape.java?rev=1684773&r1=1684772&r2=1684773&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextShape.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextShape.java Wed Jun 10 22:23:47 2015
@@ -159,10 +159,29 @@ public abstract class HSLFTextShape exte
     }
 
     protected EscherTextboxWrapper getEscherTextboxWrapper(){
-        if(_txtbox == null){
-            EscherTextboxRecord textRecord = getEscherChild(EscherTextboxRecord.RECORD_ID);
-            if(textRecord != null) _txtbox = new EscherTextboxWrapper(textRecord);
+        if(_txtbox != null) return _txtbox;
+        
+        EscherTextboxRecord textRecord = getEscherChild(EscherTextboxRecord.RECORD_ID);
+        if (textRecord == null) return null;
+        
+        HSLFSheet sheet = getSheet();
+        if (sheet != null) {
+            PPDrawing drawing = sheet.getPPDrawing();
+            if (drawing != null) {
+                EscherTextboxWrapper wrappers[] = drawing.getTextboxWrappers();
+                if (wrappers != null) {
+                    for (EscherTextboxWrapper w : wrappers) {
+                        // check for object identity
+                        if (textRecord == w.getEscherRecord()) {
+                            _txtbox = w;
+                            return _txtbox;
+                        }
+                    }
+                }
+            }
         }
+        
+        _txtbox = new EscherTextboxWrapper(textRecord);
         return _txtbox;
     }
 
@@ -507,13 +526,17 @@ public abstract class HSLFTextShape exte
             _paragraphs.addAll(HSLFTextParagraph.createEmptyParagraph());
             _txtbox = _paragraphs.get(0).getTextboxWrapper();
         } else {
-            initParagraphsFromSheetRecords();
-            if (_paragraphs.isEmpty()) {
-                List<List<HSLFTextParagraph>> llhtp = HSLFTextParagraph.findTextParagraphs(_txtbox);
-                if (!llhtp.isEmpty()) {
-                    _paragraphs.addAll(llhtp.get(0));
-                }
+            _paragraphs = HSLFTextParagraph.findTextParagraphs(_txtbox, getSheet());
+            if (_paragraphs == null || _paragraphs.isEmpty()) {
+                throw new RuntimeException("TextRecord didn't contained any text lines");
             }
+//            initParagraphsFromSheetRecords();
+//            if (_paragraphs.isEmpty()) {
+//                List<List<HSLFTextParagraph>> llhtp = HSLFTextParagraph.findTextParagraphs(_txtbox);
+//                if (!llhtp.isEmpty()) {
+//                    _paragraphs.addAll(llhtp.get(0));
+//                }
+//            }
         }
 
         for (HSLFTextParagraph p : _paragraphs) {
@@ -536,57 +559,47 @@ public abstract class HSLFTextShape exte
         }
     }
 
-    protected void initParagraphsFromSheetRecords(){
-        EscherTextboxWrapper txtbox = getEscherTextboxWrapper();
-        HSLFSheet sheet = getSheet();
-
-        if(sheet == null || txtbox == null) return;
-
-        OutlineTextRefAtom ota = null;
-
-        Record[] child = txtbox.getChildRecords();
-        for (int i = 0; i < child.length; i++) {
-            if (child[i] instanceof OutlineTextRefAtom) {
-                ota = (OutlineTextRefAtom)child[i];
-                break;
-            }
-        }
-
-        List<List<HSLFTextParagraph>> sheetRuns = _sheet.getTextParagraphs();
-        _paragraphs.clear();
-        if (sheetRuns != null) {
-            if (ota != null) {
-                int idx = ota.getTextIndex();
-                for (List<HSLFTextParagraph> r : sheetRuns) {
-                    if (r.isEmpty()) continue;
-                    int ridx = r.get(0).getIndex();
-                    if (ridx > idx) break;
-                    if (ridx == idx) _paragraphs.addAll(r);
-                }
-                if(_paragraphs.isEmpty()) {
-                    logger.log(POILogger.WARN, "text run not found for OutlineTextRefAtom.TextIndex=" + idx);
-                }
-            } else {
-                int shapeId = getShapeId();
-                for (List<HSLFTextParagraph> r : sheetRuns) {
-                    if (r.isEmpty()) continue;
-                    if (r.get(0).getShapeId() == shapeId) _paragraphs.addAll(r);
-                }
-            }
-        }
-
-        // ensure the same references child records of TextRun
-        // TODO: check the purpose of this ...
-//        if(_txtrun != null) {
-//            for (int i = 0; i < child.length; i++) {
-//                for (Record r : _txtrun.getRecords()) {
-//                    if (child[i].getRecordType() == r.getRecordType()) {
-//                        child[i] = r;
-//                    }
-//                }
+//    protected void initParagraphsFromSheetRecords(){
+//        EscherTextboxWrapper txtbox = getEscherTextboxWrapper();
+//        HSLFSheet sheet = getSheet();
+//
+//        if (sheet == null || txtbox == null) return;
+//        List<List<HSLFTextParagraph>> sheetRuns = _sheet.getTextParagraphs();
+//        if (sheetRuns == null) return;
+//
+//        _paragraphs.clear();
+//        OutlineTextRefAtom ota = (OutlineTextRefAtom)txtbox.findFirstOfType(OutlineTextRefAtom.typeID);
+//
+//        if (ota != null) {
+//            int idx = ota.getTextIndex();
+//            for (List<HSLFTextParagraph> r : sheetRuns) {
+//                if (r.isEmpty()) continue;
+//                int ridx = r.get(0).getIndex();
+//                if (ridx > idx) break;
+//                if (ridx == idx) _paragraphs.addAll(r);
+//            }
+//            if(_paragraphs.isEmpty()) {
+//                logger.log(POILogger.WARN, "text run not found for OutlineTextRefAtom.TextIndex=" + idx);
+//            }
+//        } else {
+//            int shapeId = getShapeId();
+//            for (List<HSLFTextParagraph> r : sheetRuns) {
+//                if (r.isEmpty()) continue;
+//                if (r.get(0).getShapeId() == shapeId) _paragraphs.addAll(r);
 //            }
 //        }
-    }
+//
+//        // ensure the same references child records of TextRun - see #48916
+////        if(_txtrun != null) {
+////            for (int i = 0; i < child.length; i++) {
+////                for (Record r : _txtrun.getRecords()) {
+////                    if (child[i].getRecordType() == r.getRecordType()) {
+////                        child[i] = r;
+////                    }
+////                }
+////            }
+////        }
+//    }
 
     /*
         // 0xB acts like cariage return in page titles and like blank in the others
@@ -740,7 +753,8 @@ public abstract class HSLFTextShape exte
        * Also updates the styles to the correct text length.
        */
       protected void storeText() {
-          HSLFTextParagraph.storeText(_paragraphs);
+          List<HSLFTextParagraph> paras = getTextParagraphs();
+          HSLFTextParagraph.storeText(paras);
       }
       // Accesser methods follow
 

Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTitleMaster.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTitleMaster.java?rev=1684773&r1=1684772&r2=1684773&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTitleMaster.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTitleMaster.java Wed Jun 10 22:23:47 2015
@@ -29,7 +29,7 @@ import org.apache.poi.hslf.record.SlideA
  * @author Yegor Kozlov
  */
 public final class HSLFTitleMaster extends HSLFMasterSheet {
-    private final List<List<HSLFTextParagraph>> _runs = new ArrayList<List<HSLFTextParagraph>>();
+    private final List<List<HSLFTextParagraph>> _paragraphs = new ArrayList<List<HSLFTextParagraph>>();
 
     /**
      * Constructs a TitleMaster
@@ -38,14 +38,16 @@ public final class HSLFTitleMaster exten
     public HSLFTitleMaster(org.apache.poi.hslf.record.Slide record, int sheetNo) {
         super(record, sheetNo);
 
-        _runs.addAll(HSLFTextParagraph.findTextParagraphs(getPPDrawing()));
+        for (List<HSLFTextParagraph> l : HSLFTextParagraph.findTextParagraphs(getPPDrawing(), this)) {
+            if (!_paragraphs.contains(l)) _paragraphs.add(l);
+        }
     }
 
     /**
      * Returns an array of all the TextRuns found
      */
     public List<List<HSLFTextParagraph>> getTextParagraphs() {
-        return _runs;
+        return _paragraphs;
     }
 
     /**

Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawFactory.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawFactory.java?rev=1684773&r1=1684772&r2=1684773&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawFactory.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawFactory.java Wed Jun 10 22:23:47 2015
@@ -69,8 +69,8 @@ public class DrawFactory {
             return getDrawable((FreeformShape<? extends TextParagraph<? extends TextRun>>)shape);
         } else if (shape instanceof TextShape) {
             return getDrawable((TextShape<? extends TextParagraph<? extends TextRun>>)shape);
-        } else if (shape instanceof ShapeGroup) {
-            return getDrawable((ShapeGroup<? extends Shape>)shape);
+        } else if (shape instanceof GroupShape) {
+            return getDrawable((GroupShape<? extends Shape>)shape);
         } else if (shape instanceof PictureShape) {
             return getDrawable((PictureShape)shape);
         } else if (shape instanceof Background) {
@@ -110,8 +110,8 @@ public class DrawFactory {
         return new DrawTextShape<T>(shape);
     }
 
-    public <T extends ShapeGroup<? extends Shape>> DrawShapeGroup<T> getDrawable(T shape) {
-        return new DrawShapeGroup<T>(shape);
+    public <T extends GroupShape<? extends Shape>> DrawGroupShape<T> getDrawable(T shape) {
+        return new DrawGroupShape<T>(shape);
     }
     
     public <T extends PictureShape> DrawPictureShape<T> getDrawable(T shape) {

Copied: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawGroupShape.java (from r1678838, poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawShapeGroup.java)
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawGroupShape.java?p2=poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawGroupShape.java&p1=poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawShapeGroup.java&r1=1678838&r2=1684773&rev=1684773&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawShapeGroup.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawGroupShape.java Wed Jun 10 22:23:47 2015
@@ -7,9 +7,9 @@ import java.awt.geom.Rectangle2D;
 import org.apache.poi.sl.usermodel.*;
 
 
-public class DrawShapeGroup<T extends ShapeGroup<? extends Shape>> extends DrawShape<T> implements Drawable {
+public class DrawGroupShape<T extends GroupShape<? extends Shape>> extends DrawShape<T> implements Drawable {
 
-    public DrawShapeGroup(T shape) {
+    public DrawGroupShape(T shape) {
         super(shape);
     }
     
@@ -31,6 +31,7 @@ public class DrawShapeGroup<T extends Sh
         tx.translate(-interior.getX(), -interior.getY());
 
         DrawFactory drawFact = DrawFactory.getInstance(graphics);
+        AffineTransform at2 = graphics.getTransform();
         
         for (Shape child : shape) {
             // remember the initial transform and restore it after we are done with the drawing
@@ -46,7 +47,7 @@ public class DrawShapeGroup<T extends Sh
             graphics.setRenderingHint(Drawable.GRESTORE, true);
         }
 
+        graphics.setTransform(at2);
         graphics.setRenderingHint(Drawable.GROUP_TRANSFORM, tx0);
-        
     }
 }

Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawShape.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawShape.java?rev=1684773&r1=1684772&r2=1684773&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawShape.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawShape.java Wed Jun 10 22:23:47 2015
@@ -25,11 +25,10 @@ public class DrawShape<T extends Shape>
         if (!(shape instanceof PlaceableShape)) return;
         
         PlaceableShape ps = (PlaceableShape)shape;
-        Rectangle2D anchor = ps.getAnchor();
         AffineTransform tx = (AffineTransform)graphics.getRenderingHint(Drawable.GROUP_TRANSFORM);
-        if(tx != null) {
-            anchor = tx.createTransformedShape(anchor).getBounds2D();
-        }
+        final Rectangle2D anchor = (tx != null)
+            ? tx.createTransformedShape(ps.getAnchor()).getBounds2D()
+            : ps.getAnchor();
 
         // rotation
         double rotation = ps.getRotation();
@@ -39,7 +38,8 @@ public class DrawShape<T extends Shape>
             double centerY = anchor.getCenterY();
 
             // normalize rotation
-            rotation = (360.+(rotation%360.))%360.;
+            rotation %= 360.;
+            if (rotation < 0) rotation += 360.;
             int quadrant = (((int)rotation+45)/90)%4;
             double scaleX = 1.0, scaleY = 1.0;
 
@@ -53,26 +53,43 @@ public class DrawShape<T extends Shape>
                 // think of it, as if you paint the shape on a canvas. First you rotate the canvas, which might
                 // be already (differently) scaled, so you can paint the shape in its default orientation
                 // and later on, turn it around again to compare it with its original size ...
-                AffineTransform txg = new AffineTransform(); // graphics coordinate space
-                AffineTransform txs = new AffineTransform(tx); // shape coordinate space
+
+                // graphics coordinate space
+                AffineTransform txg = new AffineTransform();
                 txg.translate(centerX, centerY);
-                txg.rotate(Math.toRadians(quadrant*90));
+                txg.rotate(Math.toRadians(90));
                 txg.translate(-centerX, -centerY);
-                txs.translate(centerX, centerY);
-                txs.rotate(Math.toRadians(-quadrant*90));
-                txs.translate(-centerX, -centerY);
-                txg.concatenate(txs);
-                Rectangle2D anchor2 = txg.createTransformedShape(ps.getAnchor()).getBounds2D();
+
+                boolean oldVariant = true;
+                Rectangle2D anchor2;
+                
+                if (oldVariant) {
+                    // shape coordinate space
+                    AffineTransform txs = new AffineTransform(tx);
+                    txs.translate(centerX, centerY);
+                    txs.rotate(Math.toRadians(90));
+                    txs.translate(-centerX, -centerY);
+                    txg.concatenate(txs);
+                    anchor2 = txg.createTransformedShape(ps.getAnchor()).getBounds2D();
+                } else {
+                    anchor2 = txg.createTransformedShape(anchor).getBounds2D();
+                }
+
                 scaleX = anchor.getWidth() == 0. ? 1.0 : anchor.getWidth() / anchor2.getWidth();
                 scaleY = anchor.getHeight() == 0. ? 1.0 : anchor.getHeight() / anchor2.getHeight();
+                
+                graphics.translate(centerX, centerY);
+                graphics.rotate(Math.toRadians(rotation-quadrant*90.));
+                graphics.scale(scaleX, scaleY);
+                graphics.rotate(Math.toRadians(quadrant*90));
+                graphics.translate(-centerX, -centerY);
+            } else {
+                graphics.translate(centerX, centerY);
+                graphics.rotate(Math.toRadians(rotation));
+                graphics.scale(scaleX, scaleY);
+                graphics.translate(-centerX, -centerY);
             }
-
             // transformation is applied reversed ...
-            graphics.translate(centerX, centerY);
-            graphics.rotate(Math.toRadians(rotation-quadrant*90.));
-            graphics.scale(scaleX, scaleY);
-            graphics.rotate(Math.toRadians(quadrant*90));
-            graphics.translate(-centerX, -centerY);
         }
 
         //flip horizontal

Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/Drawable.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/Drawable.java?rev=1684773&r1=1684772&r2=1684773&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/Drawable.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/Drawable.java Wed Jun 10 22:23:47 2015
@@ -32,6 +32,23 @@ public interface Drawable {
         public boolean isCompatibleValue(Object val) {
             return true;
         }
+        
+        public String toString() {
+            switch (intKey()) {
+            case 1: return "DRAW_FACTORY";
+            case 2: return "GROUP_TRANSFORM";
+            case 3: return "IMAGE_RENDERER";
+            case 4: return "TEXT_RENDERING_MODE";
+            case 5: return "GRADIENT_SHAPE";
+            case 6: return "PRESET_GEOMETRY_CACHE";
+            case 7: return "FONT_HANDLER";
+            case 8: return "FONT_FALLBACK";
+            case 9: return "FONT_MAP";
+            case 10: return "GSAVE";
+            case 11: return "GRESTORE";
+            default: return "UNKNOWN_ID "+intKey();
+            }
+        }
     }
     
     /**

Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/ImageRenderer.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/ImageRenderer.java?rev=1684773&r1=1684772&r2=1684773&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/ImageRenderer.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/ImageRenderer.java Wed Jun 10 22:23:47 2015
@@ -30,18 +30,35 @@ import javax.imageio.ImageIO;
 /**
  * For now this class renders only images supported by the javax.imageio.ImageIO
  * framework. Subclasses can override this class to support other formats, for
- * example, Use Apache batik to render WMF:
+ * example, use Apache Batik to render WMF, PICT can be rendered using Apple QuickTime API for Java:
  *
  * <pre>
  * <code>
  * public class MyImageRendener extends ImageRendener {
+ *     InputStream data;
  *
  *     public boolean drawImage(Graphics2D graphics,Rectangle2D anchor,Insets clip) {
  *         // draw image
+ *       DataInputStream is = new DataInputStream(data);
+ *       org.apache.batik.transcoder.wmf.tosvg.WMFRecordStore wmfStore =
+ *               new org.apache.batik.transcoder.wmf.tosvg.WMFRecordStore();
+ *       try {
+ *           wmfStore.read(is);
+ *       } catch (IOException e){
+ *           return;
+ *       }
+ *
+ *       float scale = (float)anchor.width/wmfStore.getWidthPixels();
+ *
+ *       org.apache.batik.transcoder.wmf.tosvg.WMFPainter painter =
+ *               new org.apache.batik.transcoder.wmf.tosvg.WMFPainter(wmfStore, 0, 0, scale);
+ *       graphics.translate(anchor.x, anchor.y);
+ *       painter.paint(graphics);
  *     }
  *
  *     public void loadImage(InputStream data, String contentType) throws IOException {
  *         if ("image/wmf".equals(contentType)) {
+ *             this.data = data;
  *             // use Apache Batik to handle WMF
  *         } else {
  *             super.loadImage(data,contentType);
@@ -147,12 +164,14 @@ public class ImageRenderer {
         int iw = img.getWidth();
         int ih = img.getHeight();
 
+        
         double cw = (100000-clip.left-clip.right) / 100000.0;
         double ch = (100000-clip.top-clip.bottom) / 100000.0;
         double sx = anchor.getWidth()/(iw*cw);
         double sy = anchor.getHeight()/(ih*ch);
         double tx = anchor.getX()-(iw*sx*clip.left/100000.0);
         double ty = anchor.getY()-(ih*sy*clip.top/100000.0);
+
         AffineTransform at = new AffineTransform(sx, 0, 0, sy, tx, ty) ;
 
         Shape clipOld = graphics.getClip();

Copied: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/usermodel/GroupShape.java (from r1678838, poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/usermodel/ShapeGroup.java)
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/usermodel/GroupShape.java?p2=poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/usermodel/GroupShape.java&p1=poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/usermodel/ShapeGroup.java&r1=1678838&r2=1684773&rev=1684773&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/usermodel/ShapeGroup.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/usermodel/GroupShape.java Wed Jun 10 22:23:47 2015
@@ -19,6 +19,21 @@ package org.apache.poi.sl.usermodel;
 
 import java.awt.geom.Rectangle2D;
 
-public interface ShapeGroup<T extends Shape> extends Shape, ShapeContainer<T>, PlaceableShape {
+public interface GroupShape<T extends Shape> extends Shape, ShapeContainer<T>, PlaceableShape {
+
+    /**
+     * Gets the coordinate space of this group.  All children are constrained
+     * to these coordinates.
+     *
+     * @param anchor the coordinate space of this group
+     */
     Rectangle2D getInteriorAnchor();
+    
+    /**
+     * Sets the coordinate space of this group.  All children are constrained
+     * to these coordinates.
+     *
+     * @param anchor the coordinate space of this group
+     */
+    void setInteriorAnchor(Rectangle2D anchor);
 }

Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/usermodel/PictureShape.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/usermodel/PictureShape.java?rev=1684773&r1=1684772&r2=1684773&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/usermodel/PictureShape.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/usermodel/PictureShape.java Wed Jun 10 22:23:47 2015
@@ -20,9 +20,17 @@ package org.apache.poi.sl.usermodel;
 import java.awt.Insets;
 
 public interface PictureShape extends SimpleShape {
-	PictureData getPictureData();
+    /**
+     * Returns the picture data for this picture.
+     *
+     * @return the picture data for this picture.
+     */
+    PictureData getPictureData();
 
 	/**
+	 * Returns the clipping values as percent ratio relatively to the image size.
+	 * The clipping are returned as insets converted/scaled to 100000 (=100%).
+	 * 
 	 * @return the clipping rectangle, which is given in percent in relation to the image width/height
 	 */
 	Insets getClipping();

Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/usermodel/Sheet.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/usermodel/Sheet.java?rev=1684773&r1=1684772&r2=1684773&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/usermodel/Sheet.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/usermodel/Sheet.java Wed Jun 10 22:23:47 2015
@@ -17,6 +17,8 @@
 
 package org.apache.poi.sl.usermodel;
 
+import java.awt.Graphics2D;
+
 
 /**
  * Common parent of Slides, Notes and Masters
@@ -34,4 +36,11 @@ public interface Sheet<T extends Shape,
 	MasterSheet<T,SS> getMasterSheet();
 
 	Background getBackground();
+	
+	/**
+	 * Convenience method to draw a sheet to a graphics context
+	 *
+	 * @param graphics
+	 */
+	void draw(Graphics2D graphics);
 }

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=1684773&r1=1684772&r2=1684773&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 Wed Jun 10 22:23:47 2015
@@ -29,7 +29,6 @@ import org.junit.runners.Suite;
     TestFreeform.class,
     TestHeadersFooters.class,
     TestHyperlink.class,
-    TestImagePainter.class,
     TestLine.class,
     TestMovieShape.class,
     TestOleEmbedding.class,

Modified: poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTable.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTable.java?rev=1684773&r1=1684772&r2=1684773&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTable.java (original)
+++ poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTable.java Wed Jun 10 22:23:47 2015
@@ -43,15 +43,15 @@ public final class TestTable {
 
         HSLFSlide slide = ppt.createSlide();
 
-        Table tbl = new Table(2, 5);
+        HSLFTable tbl = new HSLFTable(2, 5);
         slide.addShape(tbl);
 
-        TableCell cell = tbl.getCell(0, 0);
+        HSLFTableCell cell = tbl.getCell(0, 0);
         //table cells have type=TextHeaderAtom.OTHER_TYPE, see bug #46033
         assertEquals(TextHeaderAtom.OTHER_TYPE, cell.getTextParagraphs().get(0).getRunType());
 
-        assertTrue(slide.getShapes().get(0) instanceof Table);
-        Table tbl2 = (Table)slide.getShapes().get(0);
+        assertTrue(slide.getShapes().get(0) instanceof HSLFTable);
+        HSLFTable tbl2 = (HSLFTable)slide.getShapes().get(0);
         assertEquals(tbl.getNumberOfColumns(), tbl2.getNumberOfColumns());
         assertEquals(tbl.getNumberOfRows(), tbl2.getNumberOfRows());
 
@@ -61,8 +61,8 @@ public final class TestTable {
 
         ppt = new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray()));
         slide = ppt.getSlides().get(0);
-        assertTrue(slide.getShapes().get(0) instanceof Table);
-        Table tbl3 = (Table)slide.getShapes().get(0);
+        assertTrue(slide.getShapes().get(0) instanceof HSLFTable);
+        HSLFTable tbl3 = (HSLFTable)slide.getShapes().get(0);
         assertEquals(tbl.getNumberOfColumns(), tbl3.getNumberOfColumns());
         assertEquals(tbl.getNumberOfRows(), tbl3.getNumberOfRows());
     }
@@ -75,7 +75,7 @@ public final class TestTable {
         HSLFSlideShow ppt = new HSLFSlideShow();
         HSLFSlide slide = ppt.createSlide();
         List<HSLFShape> shapes;
-        Table tbl1 = new Table(1, 5);
+        HSLFTable tbl1 = new HSLFTable(1, 5);
         assertEquals(5, tbl1.getNumberOfColumns());
         assertEquals(1, tbl1.getNumberOfRows());
         slide.addShape(tbl1);
@@ -83,7 +83,7 @@ public final class TestTable {
         shapes = slide.getShapes();
         assertEquals(1, shapes.size());
 
-        Table tbl2 = (Table)shapes.get(0);
+        HSLFTable tbl2 = (HSLFTable)shapes.get(0);
         assertSame(tbl1.getSpContainer(), tbl2.getSpContainer());
 
         assertEquals(tbl1.getNumberOfColumns(), tbl2.getNumberOfColumns());
@@ -93,13 +93,13 @@ public final class TestTable {
     @Test
     public void testIllegalCOnstruction(){
         try {
-            new Table(0, 5);
+            new HSLFTable(0, 5);
             fail("Table(rownum, colnum) must throw IllegalArgumentException if any of tghe arguments is less than 1");
         } catch (IllegalArgumentException e){
 
         }
         try {
-            new Table(5, 0);
+            new HSLFTable(5, 0);
             fail("Table(rownum, colnum) must throw IllegalArgumentException if any of tghe arguments is less than 1");
         } catch (IllegalArgumentException e){
 

Modified: poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestAddingSlides.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestAddingSlides.java?rev=1684773&r1=1684772&r2=1684773&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestAddingSlides.java (original)
+++ poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestAddingSlides.java Wed Jun 10 22:23:47 2015
@@ -281,7 +281,7 @@ public final class TestAddingSlides exte
         assertEquals(14, doc.getNotesSlideListWithText().getSlideAtomsSets().length);
 
         //remove all slides, corresponding notes should be removed too
-        for (int i = 0; i < slides.size(); i++) {
+        for (int i = slides.size(); i > 0; i--) {
             ppt.removeSlide(0);
         }
         assertEquals(0, ppt.getSlides().size());

Modified: poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java?rev=1684773&r1=1684772&r2=1684773&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java (original)
+++ poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java Wed Jun 10 22:23:47 2015
@@ -18,14 +18,10 @@
 package org.apache.poi.hslf.usermodel;
 
 import static org.junit.Assert.*;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
 
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
+import java.awt.Color;
+import java.awt.Rectangle;
+import java.io.*;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
@@ -44,14 +40,14 @@ import org.apache.poi.ddf.EscherProperti
 import org.apache.poi.hslf.HSLFTestDataSamples;
 import org.apache.poi.hslf.exceptions.OldPowerPointFormatException;
 import org.apache.poi.hslf.model.*;
-import org.apache.poi.hslf.record.Document;
-import org.apache.poi.hslf.record.Record;
-import org.apache.poi.hslf.record.SlideListWithText;
+import org.apache.poi.hslf.model.textproperties.TextPropCollection;
+import org.apache.poi.hslf.model.textproperties.TextPropCollection.TextPropType;
+import org.apache.poi.hslf.record.*;
 import org.apache.poi.hslf.record.SlideListWithText.SlideAtomsSet;
-import org.apache.poi.hslf.record.TextHeaderAtom;
-import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.StringUtil;
-import org.apache.poi.util.Units;
+import org.apache.poi.poifs.filesystem.DocumentEntry;
+import org.apache.poi.poifs.filesystem.POIFSFileSystem;
+import org.apache.poi.util.*;
+import org.junit.Ignore;
 import org.junit.Test;
 
 /**
@@ -527,7 +523,7 @@ public final class TestBugs {
         for (List<HSLFTextParagraph> tr : _slides.get(0).getTextParagraphs()) {
             if (! tr.get(0).isDrawingBased()) str++;
         }
-        assertEquals(1, str);
+        assertEquals(2, str);
     }
     
     @Test

Modified: poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestFontRendering.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestFontRendering.java?rev=1684773&r1=1684772&r2=1684773&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestFontRendering.java (original)
+++ poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestFontRendering.java Wed Jun 10 22:23:47 2015
@@ -17,29 +17,22 @@
 
 package org.apache.poi.hslf.usermodel;
 
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
 import static org.junit.Assume.assumeTrue;
 
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.Font;
-import java.awt.Graphics2D;
-import java.awt.GraphicsEnvironment;
-import java.awt.RenderingHints;
+import java.awt.*;
 import java.awt.geom.AffineTransform;
 import java.awt.geom.Rectangle2D;
 import java.awt.image.BufferedImage;
 import java.awt.image.DataBufferByte;
 import java.io.File;
 import java.io.InputStream;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.*;
 
 import javax.imageio.ImageIO;
 
 import org.apache.poi.POIDataSamples;
-import org.apache.poi.hslf.model.TextPainter;
+import org.apache.poi.sl.draw.Drawable;
 import org.apache.poi.util.TempFile;
 import org.junit.Ignore;
 import org.junit.Test;
@@ -50,7 +43,7 @@ import org.junit.Test;
 public class TestFontRendering {
     private static POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
 
-    @Ignore("This fails on some systems because fonts are rendered slightly different")
+    // @Ignore2("This fails on some systems because fonts are rendered slightly different")
     @Test
     public void bug55902mixedFontWithChineseCharacters() throws Exception {
         // font files need to be downloaded first via
@@ -86,7 +79,7 @@ public class TestFontRendering {
         
         Dimension pgsize = ss.getPageSize();
         
-        HSLFSlide slide = ss.getSlides()[0];
+        HSLFSlide slide = ss.getSlides().get(0);
         
         // render it
         double zoom = 1;
@@ -95,8 +88,8 @@ public class TestFontRendering {
         
         BufferedImage imgActual = new BufferedImage((int)Math.ceil(pgsize.width*zoom), (int)Math.ceil(pgsize.height*zoom), BufferedImage.TYPE_3BYTE_BGR);
         Graphics2D graphics = imgActual.createGraphics();
-        graphics.setRenderingHint(TextPainter.KEY_FONTFALLBACK, fallbackMap);
-        graphics.setRenderingHint(TextPainter.KEY_FONTMAP, fontMap);
+        graphics.setRenderingHint(Drawable.FONT_FALLBACK, fallbackMap);
+        graphics.setRenderingHint(Drawable.FONT_MAP, fontMap);
         graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
         graphics.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
         graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
@@ -116,7 +109,7 @@ public class TestFontRendering {
         if(!Arrays.equals(expectedData, actualData)) {
             ImageIO.write(imgActual, "PNG", TempFile.createTempFile("TestFontRendering", ".png"));
         }
-        assertTrue("Expected to have matching raster-arrays, but found differences, size " + expectedData.length + " and " + actualData.length, 
-                Arrays.equals(expectedData, actualData));
+        
+        assertArrayEquals("Expected to have matching raster-arrays, but found differences", expectedData, actualData);
     }
 }

Modified: poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNumberedList3.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNumberedList3.java?rev=1684773&r1=1684772&r2=1684773&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNumberedList3.java (original)
+++ poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNumberedList3.java Wed Jun 10 22:23:47 2015
@@ -79,10 +79,14 @@ public final class TestNumberedList3 {
 		assertEquals(Short.valueOf((short)1), autoNumbers[0].getAutoNumberStartNumber());//Default value = 1 will be used 
 		assertTrue(TextAutoNumberSchemeEnum.ANM_ArabicPeriod == autoNumbersOfTextBox0[0].getAutoNumberScheme());
 		
-		final List<TextPropCollection> textProps = textParass.get(1).get(0).getStyleTextPropAtom().getCharacterStyles();
-		assertEquals(1, textProps.size());
-		final TextPropCollection textProp = textProps.get(0);
-		assertEquals(67, textProp.getCharactersCovered());
+		int chCovered = 0;
+		for (HSLFTextParagraph htp : textParass.get(1)) {
+    		for (HSLFTextRun htr : htp.getTextRuns()) {
+    		    TextPropCollection textProp = htr.getCharacterStyle();
+    		    chCovered += textProp.getCharactersCovered();
+    		}
+		}
+		assertEquals(67, chCovered);
 		
 		assertTrue(textParass.get(0).get(0).isBullet());
 		

Modified: poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestPicture.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestPicture.java?rev=1684773&r1=1684772&r2=1684773&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestPicture.java (original)
+++ poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestPicture.java Wed Jun 10 22:23:47 2015
@@ -17,18 +17,11 @@
 
 package org.apache.poi.hslf.usermodel;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-
-import java.awt.Dimension;
-import java.awt.Graphics2D;
-import java.awt.Rectangle;
+import static org.junit.Assert.*;
+
+import java.awt.*;
 import java.awt.image.BufferedImage;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.InputStream;
+import java.io.*;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -36,8 +29,12 @@ import javax.imageio.ImageIO;
 
 import org.apache.poi.POIDataSamples;
 import org.apache.poi.ddf.EscherBSERecord;
-import org.apache.poi.hslf.usermodel.*;
+import org.apache.poi.hssf.usermodel.DummyGraphics2d;
+import org.apache.poi.sl.draw.Drawable;
+import org.apache.poi.sl.usermodel.Slide;
+import org.apache.poi.sl.usermodel.SlideShow;
 import org.apache.poi.util.JvmBugs;
+import org.apache.poi.xslf.usermodel.XMLSlideShow;
 import org.junit.Ignore;
 import org.junit.Test;
 
@@ -143,45 +140,42 @@ public final class TestPicture {
     }
 
     @Test
-    @Ignore("Just for visual validation - antialiasing is different on various systems")
+    // @Ignore("Just for visual validation - antialiasing is different on various systems")
     public void bug54541() throws Exception {
-//        InputStream xis = _slTests.openResourceAsStream("54542_cropped_bitmap.pptx");
-//        XMLSlideShow xss = new XMLSlideShow(xis);
-//        xis.close();
-//        
-//        Dimension xpg = xss.getPageSize();
-//        for(XSLFSlide slide : xss.getSlides()) {
-//            BufferedImage img = new BufferedImage(xpg.width, xpg.height, BufferedImage.TYPE_INT_RGB);
-//            Graphics2D graphics = img.createGraphics();
-//            fixFonts(graphics);
-//            slide.draw(graphics);
-//            ImageIO.write(img, "PNG", new File("testx.png"));
-//        }
-//
-//        System.out.println("########################");
-        
-        InputStream is = _slTests.openResourceAsStream("54541_cropped_bitmap.ppt");
-        HSLFSlideShow ss = new HSLFSlideShow(is);
+        String file = new String[]{
+            "54542_cropped_bitmap.pptx",
+            "54541_cropped_bitmap.ppt",
+            "54541_cropped_bitmap2.ppt",
+            "sample_pptx_grouping_issues.pptx"
+        }[3];
+        InputStream is = _slTests.openResourceAsStream(file);
+        SlideShow ss = file.endsWith("pptx") ? new XMLSlideShow(is) : new HSLFSlideShow(is);
         is.close();
         
+        boolean debugOut = false;
         Dimension pg = ss.getPageSize();
         int i=1;
-        for(HSLFSlide slide : ss.getSlides()) {
-            BufferedImage img = new BufferedImage(pg.width, pg.height, BufferedImage.TYPE_INT_RGB);
-            Graphics2D graphics = img.createGraphics();
-            fixFonts(graphics);
-            slide.draw(graphics);
-            ImageIO.write(img, "PNG", new File("test"+(i++)+".png"));
+        for(Slide<?,?,?> slide : ss.getSlides()) {
+            if (debugOut) {
+                DummyGraphics2d graphics = new DummyGraphics2d();
+                slide.draw(graphics);
+            } else {
+                BufferedImage img = new BufferedImage(pg.width, pg.height, BufferedImage.TYPE_INT_RGB);
+                Graphics2D graphics = img.createGraphics();
+                fixFonts(graphics);
+                slide.draw(graphics);
+                ImageIO.write(img, "PNG", new File("test"+(i++)+"hslf.png"));
+            }
         }
     }
     
     @SuppressWarnings("unchecked")
     private void fixFonts(Graphics2D graphics) {
         if (!JvmBugs.hasLineBreakMeasurerBug()) return;
-        Map<String,String> fontMap = (Map<String,String>)graphics.getRenderingHint(TextPainter.KEY_FONTMAP);
+        Map<String,String> fontMap = (Map<String,String>)graphics.getRenderingHint(Drawable.FONT_MAP);
         if (fontMap == null) fontMap = new HashMap<String,String>();
         fontMap.put("Calibri", "Lucida Sans");
         fontMap.put("Cambria", "Lucida Bright");
-        graphics.setRenderingHint(TextPainter.KEY_FONTMAP, fontMap);        
+        graphics.setRenderingHint(Drawable.FONT_MAP, fontMap);        
     }
 }

Modified: poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestPictures.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestPictures.java?rev=1684773&r1=1684772&r2=1684773&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestPictures.java (original)
+++ poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestPictures.java Wed Jun 10 22:23:47 2015
@@ -22,17 +22,12 @@ import static org.junit.Assert.assertArr
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.net.URL;
+import java.util.List;
 
 import junit.framework.TestCase;
 
 import org.apache.poi.POIDataSamples;
-import org.apache.poi.hslf.blip.DIB;
-import org.apache.poi.hslf.blip.EMF;
-import org.apache.poi.hslf.blip.JPEG;
-import org.apache.poi.hslf.blip.PICT;
-import org.apache.poi.hslf.blip.PNG;
-import org.apache.poi.hslf.blip.WMF;
-import org.apache.poi.hslf.model.*;
+import org.apache.poi.hslf.blip.*;
 
 /**
  * Test adding/reading pictures
@@ -65,9 +60,9 @@ public final class TestPictures extends
         ppt = new HSLFSlideShow(new HSLFSlideShowImpl(new ByteArrayInputStream(out.toByteArray())));
 
         //make sure we can read this picture shape and it refers to the correct picture data
-        HSLFShape[] sh = ppt.getSlides()[0].getShapes();
-        assertEquals(1, sh.length);
-        pict = (HSLFPictureShape)sh[0];
+        List<HSLFShape> sh = ppt.getSlides().get(0).getShapes();
+        assertEquals(1, sh.size());
+        pict = (HSLFPictureShape)sh.get(0);
         assertEquals(idx, pict.getPictureIndex());
 
         //check picture data
@@ -110,9 +105,9 @@ public final class TestPictures extends
         ppt = new HSLFSlideShow(new HSLFSlideShowImpl(new ByteArrayInputStream(out.toByteArray())));
 
         //make sure we can read this picture shape and it refers to the correct picture data
-        HSLFShape[] sh = ppt.getSlides()[0].getShapes();
-        assertEquals(1, sh.length);
-        pict = (HSLFPictureShape)sh[0];
+        List<HSLFShape> sh = ppt.getSlides().get(0).getShapes();
+        assertEquals(1, sh.size());
+        pict = (HSLFPictureShape)sh.get(0);
         assertEquals(idx, pict.getPictureIndex());
 
         //check picture data
@@ -156,9 +151,9 @@ public final class TestPictures extends
         ppt = new HSLFSlideShow(new HSLFSlideShowImpl(new ByteArrayInputStream(out.toByteArray())));
 
         //make sure we can get this picture shape and it refers to the correct picture data
-        HSLFShape[] sh = ppt.getSlides()[0].getShapes();
-        assertEquals(1, sh.length);
-        pict = (HSLFPictureShape)sh[0];
+        List<HSLFShape> sh = ppt.getSlides().get(0).getShapes();
+        assertEquals(1, sh.size());
+        pict = (HSLFPictureShape)sh.get(0);
         assertEquals(idx, pict.getPictureIndex());
 
         //check picture data
@@ -195,9 +190,9 @@ public final class TestPictures extends
         ppt = new HSLFSlideShow(new HSLFSlideShowImpl(new ByteArrayInputStream(out.toByteArray())));
 
         //make sure we can read this picture shape and it refers to the correct picture data
-        HSLFShape[] sh = ppt.getSlides()[0].getShapes();
-        assertEquals(1, sh.length);
-        pict = (HSLFPictureShape)sh[0];
+        List<HSLFShape> sh = ppt.getSlides().get(0).getShapes();
+        assertEquals(1, sh.size());
+        pict = (HSLFPictureShape)sh.get(0);
         assertEquals(idx, pict.getPictureIndex());
 
         //check picture data
@@ -235,9 +230,9 @@ public final class TestPictures extends
         ppt = new HSLFSlideShow(new HSLFSlideShowImpl(new ByteArrayInputStream(out.toByteArray())));
 
         //make sure we can read this picture shape and it refers to the correct picture data
-        HSLFShape[] sh = ppt.getSlides()[0].getShapes();
-        assertEquals(1, sh.length);
-        pict = (HSLFPictureShape)sh[0];
+        List<HSLFShape> sh = ppt.getSlides().get(0).getShapes();
+        assertEquals(1, sh.size());
+        pict = (HSLFPictureShape)sh.get(0);
         assertEquals(idx, pict.getPictureIndex());
 
         //check picture data
@@ -274,9 +269,9 @@ public final class TestPictures extends
         ppt = new HSLFSlideShow(new HSLFSlideShowImpl(new ByteArrayInputStream(out.toByteArray())));
 
         //make sure we can read this picture shape and it refers to the correct picture data
-        HSLFShape[] sh = ppt.getSlides()[0].getShapes();
-        assertEquals(1, sh.length);
-        pict = (HSLFPictureShape)sh[0];
+        List<HSLFShape> sh = ppt.getSlides().get(0).getShapes();
+        assertEquals(1, sh.size());
+        pict = (HSLFPictureShape)sh.get(0);
         assertEquals(idx, pict.getPictureIndex());
 
         //check picture data
@@ -302,11 +297,11 @@ public final class TestPictures extends
         HSLFPictureData pdata;
 
         HSLFSlideShow ppt = new HSLFSlideShow(slTests.openResourceAsStream("pictures.ppt"));
-        HSLFSlide[] slides = ppt.getSlides();
+        List<HSLFSlide> slides = ppt.getSlides();
         HSLFPictureData[] pictures = ppt.getPictureData();
         assertEquals(5, pictures.length);
 
-        pict = (HSLFPictureShape)slides[0].getShapes()[0]; //the first slide contains JPEG
+        pict = (HSLFPictureShape)slides.get(0).getShapes().get(0); //the first slide contains JPEG
         pdata = pict.getPictureData();
         assertTrue(pdata instanceof JPEG);
         assertEquals(HSLFPictureShape.JPEG, pdata.getType());
@@ -314,7 +309,7 @@ public final class TestPictures extends
         ppt_bytes = slTests.readFile("clock.jpg");
         assertArrayEquals(src_bytes, ppt_bytes);
 
-        pict = (HSLFPictureShape)slides[1].getShapes()[0]; //the second slide contains PNG
+        pict = (HSLFPictureShape)slides.get(1).getShapes().get(0); //the second slide contains PNG
         pdata = pict.getPictureData();
         assertTrue(pdata instanceof PNG);
         assertEquals(HSLFPictureShape.PNG, pdata.getType());
@@ -322,7 +317,7 @@ public final class TestPictures extends
         ppt_bytes = slTests.readFile("tomcat.png");
         assertArrayEquals(src_bytes, ppt_bytes);
 
-        pict = (HSLFPictureShape)slides[2].getShapes()[0]; //the third slide contains WMF
+        pict = (HSLFPictureShape)slides.get(2).getShapes().get(0); //the third slide contains WMF
         pdata = pict.getPictureData();
         assertTrue(pdata instanceof WMF);
         assertEquals(HSLFPictureShape.WMF, pdata.getType());
@@ -336,7 +331,7 @@ public final class TestPictures extends
         System.arraycopy(ppt_bytes, 22, b2, 0, b2.length);
         assertArrayEquals(b1, b2);
 
-        pict = (HSLFPictureShape)slides[3].getShapes()[0]; //the forth slide contains PICT
+        pict = (HSLFPictureShape)slides.get(3).getShapes().get(0); //the forth slide contains PICT
         pdata = pict.getPictureData();
         assertTrue(pdata instanceof PICT);
         assertEquals(HSLFPictureShape.PICT, pdata.getType());
@@ -350,7 +345,7 @@ public final class TestPictures extends
         System.arraycopy(ppt_bytes, 512, b2, 0, b2.length);
         assertArrayEquals(b1, b2);
 
-        pict = (HSLFPictureShape)slides[4].getShapes()[0]; //the fifth slide contains EMF
+        pict = (HSLFPictureShape)slides.get(4).getShapes().get(0); //the fifth slide contains EMF
         pdata = pict.getPictureData();
         assertTrue(pdata instanceof EMF);
         assertEquals(HSLFPictureShape.EMF, pdata.getType());
@@ -375,20 +370,20 @@ public final class TestPictures extends
 
 		// Now test what happens when we use the SlideShow interface
 		HSLFSlideShow ppt = new HSLFSlideShow(hslf);
-        HSLFSlide[] slides = ppt.getSlides();
+        List<HSLFSlide> slides = ppt.getSlides();
         HSLFPictureData[] pictures = ppt.getPictureData();
-        assertEquals(12, slides.length);
+        assertEquals(12, slides.size());
         assertEquals(2, pictures.length);
 
 		HSLFPictureShape pict;
 		HSLFPictureData pdata;
 
-        pict = (HSLFPictureShape)slides[0].getShapes()[1]; // 2nd object on 1st slide
+        pict = (HSLFPictureShape)slides.get(0).getShapes().get(1); // 2nd object on 1st slide
         pdata = pict.getPictureData();
         assertTrue(pdata instanceof WMF);
         assertEquals(HSLFPictureShape.WMF, pdata.getType());
 
-        pict = (HSLFPictureShape)slides[0].getShapes()[2]; // 3rd object on 1st slide
+        pict = (HSLFPictureShape)slides.get(0).getShapes().get(2); // 3rd object on 1st slide
         pdata = pict.getPictureData();
         assertTrue(pdata instanceof WMF);
         assertEquals(HSLFPictureShape.WMF, pdata.getType());
@@ -411,20 +406,20 @@ public final class TestPictures extends
 
 		// Now test what happens when we use the SlideShow interface
 		HSLFSlideShow ppt = new HSLFSlideShow(hslf);
-        HSLFSlide[] slides = ppt.getSlides();
+        List<HSLFSlide> slides = ppt.getSlides();
         HSLFPictureData[] pictures = ppt.getPictureData();
-        assertEquals(27, slides.length);
+        assertEquals(27, slides.size());
         assertEquals(2, pictures.length);
 
 		HSLFPictureShape pict;
 		HSLFPictureData pdata;
 
-        pict = (HSLFPictureShape)slides[6].getShapes()[13];
+        pict = (HSLFPictureShape)slides.get(6).getShapes().get(13);
         pdata = pict.getPictureData();
         assertTrue(pdata instanceof WMF);
         assertEquals(HSLFPictureShape.WMF, pdata.getType());
 
-        pict = (HSLFPictureShape)slides[7].getShapes()[13];
+        pict = (HSLFPictureShape)slides.get(7).getShapes().get(13);
         pdata = pict.getPictureData();
         assertTrue(pdata instanceof WMF);
         assertEquals(HSLFPictureShape.WMF, pdata.getType());
@@ -446,9 +441,9 @@ public final class TestPictures extends
 
     public void testGetPictureName() throws Exception {
         HSLFSlideShow ppt = new HSLFSlideShow(slTests.openResourceAsStream("ppt_with_png.ppt"));
-        HSLFSlide slide = ppt.getSlides()[0];
+        HSLFSlide slide = ppt.getSlides().get(0);
 
-        HSLFPictureShape p = (HSLFPictureShape)slide.getShapes()[0]; //the first slide contains JPEG
+        HSLFPictureShape p = (HSLFPictureShape)slide.getShapes().get(0); //the first slide contains JPEG
         assertEquals("test", p.getPictureName());
     }
 
@@ -469,7 +464,7 @@ public final class TestPictures extends
 
         ppt = new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray()));
 
-        HSLFPictureShape p = (HSLFPictureShape)ppt.getSlides()[0].getShapes()[0];
+        HSLFPictureShape p = (HSLFPictureShape)ppt.getSlides().get(0).getShapes().get(0);
         assertEquals("tomcat.png", p.getPictureName());
     }
 }

Modified: poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestTable.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestTable.java?rev=1684773&r1=1684772&r2=1684773&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestTable.java (original)
+++ poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestTable.java Wed Jun 10 22:23:47 2015
@@ -19,10 +19,12 @@
 
 package org.apache.poi.hslf.usermodel;
 
-import junit.framework.TestCase;
+import static org.junit.Assert.*;
+
+import java.util.List;
 
-import org.apache.poi.hslf.model.Table;
 import org.apache.poi.POIDataSamples;
+import org.junit.Test;
 
 
 /**
@@ -30,40 +32,39 @@ import org.apache.poi.POIDataSamples;
  * 
  * @author Alex Nikiforov [mailto:anikif@gmail.com]
  */
-public final class TestTable extends TestCase {
+public class TestTable {
     private static POIDataSamples _slTests = POIDataSamples.getSlideShowInstance();
 
-	protected void setUp() throws Exception {
-	}
-
-	public void testTable() throws Exception {
+    @Test
+    public void testTable() throws Exception {
 		HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("54111.ppt"));
 		assertTrue("No Exceptions while reading file", true);
 
-		final HSLFSlide[] slides = ppt.getSlides();
-		assertEquals(1, slides.length);
-		checkSlide(slides[0]);
+		List<HSLFSlide> slides = ppt.getSlides();
+		assertEquals(1, slides.size());
+		checkSlide(slides.get(0));
 	}
+	
 	private void checkSlide(final HSLFSlide s) {
-		HSLFTextParagraph[] textRuns = s.getTextParagraphs();
-		assertEquals(2, textRuns.length);
+		List<List<HSLFTextParagraph>> textRuns = s.getTextParagraphs();
+		assertEquals(2, textRuns.size());
 
-		HSLFTextRun textRun = textRuns[0].getTextRuns()[0];
+		HSLFTextRun textRun = textRuns.get(0).get(0).getTextRuns().get(0);
 		assertEquals("Table sample", textRun.getRawText().trim());
-		assertEquals(1, textRuns[0].getTextRuns().length);
-		assertFalse(textRun.isBullet());
+		assertEquals(1, textRuns.get(0).get(0).getTextRuns().size());
+		assertFalse(textRun.getTextParagraph().isBullet());
 
-		assertEquals("Dummy text", textRuns[1].getRawText());
+		assertEquals("Dummy text", HSLFTextParagraph.getRawText(textRuns.get(1)));
 		
-		final HSLFShape[] shapes = s.getShapes();
+		List<HSLFShape> shapes = s.getShapes();
 		assertNotNull(shapes);
-		assertEquals(3, shapes.length);
-		assertTrue(shapes[2] instanceof Table);
-		final Table table = (Table) shapes[2];
+		assertEquals(3, shapes.size());
+		assertTrue(shapes.get(2) instanceof HSLFTable);
+		final HSLFTable table = (HSLFTable) shapes.get(2);
 		assertEquals(4, table.getNumberOfColumns());
 		assertEquals(6, table.getNumberOfRows());
 		for (int x = 0; x < 4; x ++) {
-			assertEquals("TH Cell " + (x + 1), table.getCell(0, x).getTextParagraphs().getRawText());
+			assertEquals("TH Cell " + (x + 1), HSLFTextParagraph.getRawText(table.getCell(0, x).getTextParagraphs()));
 			for (int y = 1; y < 6; y++) {
 				assertEquals("Row " + y + ", Cell " + (x + 1), table.getCell(y, x).getText());
 			}



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


Mime
View raw message