Modified: 
poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextShape.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextShape.java?rev=1782096&r1=1782095&r2=1782096&view=diff
==============================================================================
--- 
poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextShape.java
 (original)
+++ 
poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextShape.java
 Wed Feb  8 01:12:22 2017
@@ -714,7 +714,7 @@ public class TestXSLFTextShape {
 
         // level 5: text properties are defined in the text run
         CTTextParagraphProperties lv5PPr = 
paragraph.getXmlObject().addNewPPr();
-        CTTextCharacterProperties lv5CPr = textRun.getXmlObject().getRPr();
+        CTTextCharacterProperties lv5CPr = textRun.getRPr(false);
         lv5CPr.setSz(3600);
         assertEquals(36.0, textRun.getFontSize(), 0);
         lv5CPr.addNewLatin().setTypeface("Calibri");
@@ -899,11 +899,11 @@ public class TestXSLFTextShape {
 
         // level 5: text properties are defined in the text run
         lv1PPr = p1.getXmlObject().isSetPPr() ? p1.getXmlObject().getPPr() : 
p1.getXmlObject().addNewPPr();
-        lv1CPr = r1.getXmlObject().getRPr();
+        lv1CPr = r1.getRPr(false);
         lv2PPr = p2.getXmlObject().isSetPPr() ? p2.getXmlObject().getPPr() : 
p2.getXmlObject().addNewPPr();
-        lv2CPr = r2.getXmlObject().getRPr();
+        lv2CPr = r2.getRPr(false);
         lv3PPr = p3.getXmlObject().isSetPPr() ? p3.getXmlObject().getPPr() : 
p3.getXmlObject().addNewPPr();
-        lv3CPr = r3.getXmlObject().getRPr();
+        lv3CPr = r3.getRPr(false);
 
         lv1CPr.setSz(3600);
         assertEquals(36.0, r1.getFontSize(), 0);

Modified: 
poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTheme.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTheme.java?rev=1782096&r1=1782095&r2=1782096&view=diff
==============================================================================
--- 
poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTheme.java 
(original)
+++ 
poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTheme.java 
Wed Feb  8 01:12:22 2017
@@ -17,12 +17,15 @@
 package org.apache.poi.xslf.usermodel;
 
 import static org.apache.poi.sl.TestCommonSL.sameColor;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
 
 import java.awt.Color;
 import java.util.List;
 
-import org.apache.poi.sl.usermodel.*;
+import org.apache.poi.sl.usermodel.PaintStyle;
 import org.apache.poi.sl.usermodel.PaintStyle.GradientPaint;
 import org.apache.poi.sl.usermodel.PaintStyle.SolidPaint;
 import org.apache.poi.sl.usermodel.PaintStyle.TexturePaint;
@@ -54,7 +57,9 @@ public class TestXSLFTheme {
 
     private XSLFShape getShape(XSLFSheet sheet, String name){
         for(XSLFShape sh : sheet.getShapes()){
-            if(sh.getShapeName().equals(name)) return sh;
+            if(sh.getShapeName().equals(name)) {
+                return sh;
+            }
         }
         throw new IllegalArgumentException("Shape not found: " + name);
     }
@@ -99,7 +104,7 @@ public class TestXSLFTheme {
         assertTrue(sameColor(new Color(148, 198, 0), run2.getFontColor()));
         assertNull(sh2.getFillColor());  // no fill
 
-        assertFalse(slide.getSlideLayout().getFollowMasterGraphics());
+        assertTrue(slide.getSlideLayout().getFollowMasterGraphics());
     }
 
     void slide5(XSLFSlide slide){
@@ -113,7 +118,7 @@ public class TestXSLFTheme {
         // font size is 40pt and scale factor is 90%
         assertEquals(36.0, run2.getFontSize(), 0);
 
-        assertFalse(slide.getSlideLayout().getFollowMasterGraphics());
+        assertTrue(slide.getSlideLayout().getFollowMasterGraphics());
     }
 
     void slide6(XSLFSlide slide){

Modified: 
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/HeadersFooters.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/HeadersFooters.java?rev=1782096&r1=1782095&r2=1782096&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/HeadersFooters.java 
(original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/HeadersFooters.java 
Wed Feb  8 01:12:22 2017
@@ -21,13 +21,14 @@ import org.apache.poi.hslf.record.CStrin
 import org.apache.poi.hslf.record.Document;
 import org.apache.poi.hslf.record.HeadersFootersAtom;
 import org.apache.poi.hslf.record.HeadersFootersContainer;
-import org.apache.poi.hslf.record.OEPlaceholderAtom;
 import org.apache.poi.hslf.record.Record;
 import org.apache.poi.hslf.record.RecordTypes;
 import org.apache.poi.hslf.record.SheetContainer;
 import org.apache.poi.hslf.usermodel.HSLFSheet;
+import org.apache.poi.hslf.usermodel.HSLFSimpleShape;
 import org.apache.poi.hslf.usermodel.HSLFSlideShow;
 import org.apache.poi.hslf.usermodel.HSLFTextShape;
+import org.apache.poi.sl.usermodel.Placeholder;
 
 /**
  * Header / Footer settings.
@@ -87,7 +88,7 @@ public final class HeadersFooters {
      */
     public String getHeaderText(){
         CString cs = _container == null ? null : _container.getHeaderAtom();
-        return getPlaceholderText(OEPlaceholderAtom.MasterHeader, cs);
+        return getPlaceholderText(Placeholder.HEADER, cs);
     }
 
     /**
@@ -112,7 +113,7 @@ public final class HeadersFooters {
      */
     public String getFooterText(){
         CString cs = _container == null ? null : _container.getFooterAtom();
-        return getPlaceholderText(OEPlaceholderAtom.MasterFooter, cs);
+        return getPlaceholderText(Placeholder.FOOTER, cs);
     }
 
     /**
@@ -137,7 +138,7 @@ public final class HeadersFooters {
      */
     public String getDateTimeText(){
         CString cs = _container == null ? null : _container.getUserDateAtom();
-        return getPlaceholderText(OEPlaceholderAtom.MasterDate, cs);
+        return getPlaceholderText(Placeholder.DATETIME, cs);
     }
 
     /**
@@ -160,7 +161,7 @@ public final class HeadersFooters {
      * whether the footer text is displayed.
      */
     public boolean isFooterVisible(){
-        return isVisible(HeadersFootersAtom.fHasFooter, 
OEPlaceholderAtom.MasterFooter);
+        return isVisible(HeadersFootersAtom.fHasFooter, Placeholder.FOOTER);
     }
 
     /**
@@ -174,7 +175,7 @@ public final class HeadersFooters {
      * whether the header text is displayed.
      */
     public boolean isHeaderVisible(){
-        return isVisible(HeadersFootersAtom.fHasHeader, 
OEPlaceholderAtom.MasterHeader);
+        return isVisible(HeadersFootersAtom.fHasHeader, Placeholder.HEADER);
     }
 
     /**
@@ -188,7 +189,7 @@ public final class HeadersFooters {
      * whether the date is displayed in the footer.
      */
     public boolean isDateTimeVisible(){
-        return isVisible(HeadersFootersAtom.fHasDate, 
OEPlaceholderAtom.MasterDate);
+        return isVisible(HeadersFootersAtom.fHasDate, Placeholder.DATETIME);
     }
 
     /**
@@ -202,7 +203,7 @@ public final class HeadersFooters {
      * whether the custom user date is used instead of today's date.
      */
     public boolean isUserDateVisible(){
-        return isVisible(HeadersFootersAtom.fHasUserDate, 
OEPlaceholderAtom.MasterDate);
+        return isVisible(HeadersFootersAtom.fHasUserDate, 
Placeholder.DATETIME);
     }
 
     /**
@@ -216,7 +217,7 @@ public final class HeadersFooters {
      * whether the slide number is displayed in the footer.
      */
     public boolean isSlideNumberVisible(){
-        return isVisible(HeadersFootersAtom.fHasSlideNumber, 
OEPlaceholderAtom.MasterSlideNumber);
+        return isVisible(HeadersFootersAtom.fHasSlideNumber, 
Placeholder.SLIDE_NUMBER);
     }
 
     /**
@@ -244,31 +245,29 @@ public final class HeadersFooters {
         _container.getHeadersFootersAtom().setFormatId(formatId);
     }
 
-    private boolean isVisible(int flag, int placeholderId){
+    private boolean isVisible(int flag, Placeholder placeholderId){
         boolean visible;
         if(_ppt2007){
-            HSLFTextShape placeholder = _sheet.getPlaceholder(placeholderId);
-            visible = placeholder != null && placeholder.getText() != null;
+            HSLFSimpleShape ss = _sheet.getPlaceholder(placeholderId);
+            visible = ss instanceof HSLFTextShape && 
((HSLFTextShape)ss).getText() != null;
         } else {
             visible = _container.getHeadersFootersAtom().getFlag(flag);
         }
         return visible;
     }
 
-    private String getPlaceholderText(int placeholderId, CString cs){
-        String text = null;
+    private String getPlaceholderText(Placeholder ph, CString cs) {
+        String text;
         if (_ppt2007) {
-            HSLFTextShape placeholder = _sheet.getPlaceholder(placeholderId);
-            if (placeholder != null) {
-                text = placeholder.getText();
-            }
+            HSLFSimpleShape ss = _sheet.getPlaceholder(ph);
+            text = (ss instanceof HSLFTextShape) ? 
((HSLFTextShape)ss).getText() : null;
 
             // default text in master placeholders is not visible
             if("*".equals(text)) {
                 text = null;
             }
         } else {
-            text = cs == null ? null : cs.getText();
+            text = (cs == null) ? null : cs.getText();
         }
         return text;
     }

Modified: 
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/OEPlaceholderAtom.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/OEPlaceholderAtom.java?rev=1782096&r1=1782095&r2=1782096&view=diff
==============================================================================
--- 
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/OEPlaceholderAtom.java 
(original)
+++ 
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/OEPlaceholderAtom.java 
Wed Feb  8 01:12:22 2017
@@ -17,17 +17,18 @@
 
 package org.apache.poi.hslf.record;
 
-import org.apache.poi.util.LittleEndian;
 import java.io.IOException;
 import java.io.OutputStream;
 
+import org.apache.poi.sl.usermodel.Placeholder;
+import org.apache.poi.util.LittleEndian;
+
 /**
- * OEPlaceholderAtom (3011).
- * <p>
- *  An atom record that specifies whether a shape is a placeholder shape.
- * </p>
+ * OEPlaceholderAtom (3011).<p>
+ * 
+ * An atom record that specifies whether a shape is a placeholder shape.
  *
- * @author Yegor Kozlov
+ * @see Placeholder
  */
 
 public final class OEPlaceholderAtom extends RecordAtom{
@@ -47,155 +48,6 @@ public final class OEPlaceholderAtom ext
      */
     public static final int PLACEHOLDER_QUARTSIZE = 2;
 
-    /**
-     * MUST NOT be used for this field.
-     */
-    public static final byte None = 0;
-
-    /**
-     * The corresponding shape contains the master title text.
-     * The corresponding slide MUST be a main master slide.
-     */
-    public static final byte MasterTitle = 1;
-
-    /**
-     * The corresponding shape contains the master body text.
-     * The corresponding slide MUST be a main master slide.
-     */
-    public static final byte MasterBody = 2;
-
-    /**
-     * The corresponding shape contains the master center title text.
-     * The corresponding slide MUST be a title master slide.
-     */
-    public static final byte MasterCenteredTitle = 3;
-
-    /**
-     * The corresponding shape contains the master sub-title text.
-     * The corresponding slide MUST be a title master slide.
-     */
-    public static final byte MasterSubTitle = 4;
-
-    /**
-     * The corresponding shape contains the shared properties for slide image 
shapes.
-     * The corresponding slide MUST be a notes master slide.
-     */
-    public static final byte MasterNotesSlideImage = 5;
-
-    /**
-     * The corresponding shape contains the master body text.
-     * The corresponding slide MUST be a notes master slide.
-     */
-    public static final byte MasterNotesBody = 6;
-
-    /**
-     * The corresponding shape contains the date text field.
-     * The corresponding slide MUST be a main master slide, title master 
slide, notes master slide, or handout master slide.
-     */
-    public static final byte MasterDate = 7;
-
-    /**
-     * The corresponding shape contains a slide number text field.
-     * The corresponding slide MUST be a main master slide, title master 
slide, notes master slide, or handout master slide.
-     */
-    public static final byte MasterSlideNumber = 8;
-
-    /**
-     * The corresponding shape contains a footer text field.
-     * The corresponding slide MUST be a main master slide, title master 
slide, notes master slide, or handout master slide.
-     */
-    public static final byte MasterFooter = 9;
-
-    /**
-     * The corresponding shape contains a header text field.
-     * The corresponding slide must be a notes master slide or handout master 
slide.
-     */
-    public static final byte MasterHeader = 10;
-
-    /**
-     * The corresponding shape contains a presentation slide image.
-     * The corresponding slide MUST be a notes slide.
-     */
-    public static final byte NotesSlideImage = 11;
-
-    /**
-     * The corresponding shape contains the notes text.
-     * The corresponding slide MUST be a notes slide.
-     */
-    public static final byte NotesBody = 12;
-
-    /**
-     *  The corresponding shape contains the title text.
-     *  The corresponding slide MUST be a presentation slide.
-     */
-    public static final byte Title = 13;
-
-    /**
-     * The corresponding shape contains the body text.
-     * The corresponding slide MUST be a presentation slide.
-     */
-    public static final byte Body = 14;
-
-    /**
-     * The corresponding shape contains the title text.
-     * The corresponding slide MUST be a presentation slide.
-     */
-    public static final byte CenteredTitle = 15;
-
-    /**
-     * The corresponding shape contains the sub-title text.
-     * The corresponding slide MUST be a presentation slide.
-     */
-    public static final byte Subtitle = 16;
-
-    /**
-     * The corresponding shape contains the title text with vertical text flow.
-     * The corresponding slide MUST be a presentation slide.
-     */
-    public static final byte VerticalTextTitle = 17;
-
-    /**
-     * The corresponding shape contains the body text with vertical text flow.
-     * The corresponding slide MUST be a presentation slide.
-     */
-    public static final byte VerticalTextBody = 18;
-
-    /**
-     *  The corresponding shape contains a generic object.
-     *  The corresponding slide MUST be a presentation slide.
-     */
-    public static final byte Object = 19;
-
-    /**
-     * The corresponding shape contains a chart object.
-     * The corresponding slide MUST be a presentation slide.
-     */
-    public static final byte Graph = 20;
-
-    /**
-     * The corresponding shape contains a table object.
-     * The corresponding slide MUST be a presentation slide.
-     */
-    public static final byte Table = 21;
-
-    /**
-     * The corresponding shape contains a clipart object.
-     * The corresponding slide MUST be a presentation slide.
-     */
-    public static final byte ClipArt = 22;
-
-    /**
-     * The corresponding shape contains an organization chart object.
-     * The corresponding slide MUST be a presentation slide.
-     */
-    public static final byte OrganizationChart = 23;
-
-    /**
-     * The corresponding shape contains a media object.
-     * The corresponding slide MUST be a presentation slide.
-     */
-    public static final byte MediaClip = 24;
-
        private byte[] _header;
 
     private int placementId;
@@ -205,7 +57,7 @@ public final class OEPlaceholderAtom ext
 
 
     /**
-     * Create a new instance of <code>OEPlaceholderAtom</code>
+     * Create a new instance of {@code OEPlaceholderAtom}
      */
     public OEPlaceholderAtom(){
         _header = new byte[8];
@@ -219,7 +71,7 @@ public final class OEPlaceholderAtom ext
     }
 
     /**
-     * Build an instance of <code>OEPlaceholderAtom</code> from on-disk data
+     * Build an instance of {@code OEPlaceholderAtom} from on-disk data
      */
        protected OEPlaceholderAtom(byte[] source, int start, int len) {
                _header = new byte[8];
@@ -236,15 +88,15 @@ public final class OEPlaceholderAtom ext
     /**
      * @return type of this record {@link RecordTypes#OEPlaceholderAtom}.
      */
-       public long getRecordType() { return 
RecordTypes.OEPlaceholderAtom.typeID; }
+       @Override
+    public long getRecordType() { return RecordTypes.OEPlaceholderAtom.typeID; 
}
 
     /**
-     * Returns the placement Id.
-     * <p>
+     * Returns the placement Id.<p>
+     * 
      * The placement Id is a number assigned to the placeholder. It goes from 
-1 to the number of placeholders.
      * It SHOULD be unique among all PlacholderAtom records contained in the 
corresponding slide.
      * The value 0xFFFFFFFF specifies that the corresponding shape is not a 
placeholder shape.
-     * </p>
      *
      * @return the placement Id.
      */
@@ -253,12 +105,11 @@ public final class OEPlaceholderAtom ext
     }
 
     /**
-     * Sets the placement Id.
-     * <p>
+     * Sets the placement Id.<p>
+     *
      * The placement Id is a number assigned to the placeholder. It goes from 
-1 to the number of placeholders.
      * It SHOULD be unique among all PlacholderAtom records contained in the 
corresponding slide.
      * The value 0xFFFFFFFF specifies that the corresponding shape is not a 
placeholder shape.
-     * </p>
      *
      * @param id the placement Id.
      */
@@ -267,12 +118,10 @@ public final class OEPlaceholderAtom ext
     }
 
     /**
-     * Returns the placeholder Id.
+     * Returns the placeholder Id.<p>
      *
-     * <p>
      * placeholder Id specifies the type of the placeholder shape.
      * The value MUST be one of the static constants defined in this class
-     * </p>
      *
      * @return the placeholder Id.
      */
@@ -281,12 +130,11 @@ public final class OEPlaceholderAtom ext
     }
 
     /**
-     * Sets the placeholder Id.
+     * Sets the placeholder Id.<p>
      *
-     * <p>
      * placeholder Id specifies the type of the placeholder shape.
      * The value MUST be one of the static constants defined in this class
-     * </p>
+     *
      * @param id the placeholder Id.
      */
     public void setPlaceholderId(byte id){
@@ -314,10 +162,10 @@ public final class OEPlaceholderAtom ext
     }
 
        /**
-        * Write the contents of the record back, so it can be written
-        *  to disk
+        * Write the contents of the record back, so it can be written to disk
         */
-       public void writeOut(OutputStream out) throws IOException {
+       @Override
+    public void writeOut(OutputStream out) throws IOException {
                out.write(_header);
 
         byte[] recdata = new byte[8];

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/SlideAtom.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/SlideAtom.java?rev=1782096&r1=1782095&r2=1782096&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/SlideAtom.java 
(original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/SlideAtom.java Wed 
Feb  8 01:12:22 2017
@@ -20,23 +20,21 @@ package org.apache.poi.hslf.record;
 import java.io.IOException;
 import java.io.OutputStream;
 
-import org.apache.poi.hslf.exceptions.HSLFException;
+import org.apache.poi.hslf.record.SlideAtomLayout.SlideLayoutType;
 import org.apache.poi.util.LittleEndian;
 
 /**
  * A Slide Atom (type 1007). Holds information on the parent Slide, what
- *  Master Slide it uses, what Notes is attached to it, that sort of thing.
- *  It also has a SSlideLayoutAtom embeded in it, but without the Atom header
- *
- * @author Nick Burch
+ * Master Slide it uses, what Notes is attached to it, that sort of thing.
+ * It also has a SSlideLayoutAtom embedded in it, but without the Atom header
  */
 
-public final class SlideAtom extends RecordAtom
-{
-       private byte[] _header;
+public final class SlideAtom extends RecordAtom {
+    public static final int USES_MASTER_SLIDE_ID  =  0x80000000;
+    // private static final int MASTER_SLIDE_ID      =  0x00000000;
+
+    private byte[] _header;
        private static long _type = 1007l;
-       public static final int MASTER_SLIDE_ID = 0;
-       public static final int USES_MASTER_SLIDE_ID = -2147483648;
 
        private int masterID;
        private int notesID;
@@ -44,7 +42,7 @@ public final class SlideAtom extends Rec
        private boolean followMasterObjects;
        private boolean followMasterScheme;
        private boolean followMasterBackground;
-       private SSlideLayoutAtom layoutAtom;
+       private SlideAtomLayout layoutAtom;
        private byte[] reserved;
 
 
@@ -54,8 +52,8 @@ public final class SlideAtom extends Rec
     public void setMasterID(int id) { masterID = id; }
        /** Get the ID of the notes for this slide. 0 if doesn't have one */
        public int getNotesID()  { return notesID; }
-       /** Get the embeded SSlideLayoutAtom */
-       public SSlideLayoutAtom getSSlideLayoutAtom() { return layoutAtom; }
+       /** Get the embedded SSlideLayoutAtom */
+       public SlideAtomLayout getSSlideLayoutAtom() { return layoutAtom; }
 
        /** Change the ID of the notes for this slide. 0 if it no longer has 
one */
        public void setNotesID(int id) { notesID = id; }
@@ -85,7 +83,7 @@ public final class SlideAtom extends Rec
                byte[] SSlideLayoutAtomData = new byte[12];
                System.arraycopy(source,start+8,SSlideLayoutAtomData,0,12);
                // Use them to build up the SSlideLayoutAtom
-               layoutAtom = new SSlideLayoutAtom(SSlideLayoutAtomData);
+               layoutAtom = new SlideAtomLayout(SSlideLayoutAtomData);
 
                // Get the IDs of the master and notes
                masterID = LittleEndian.getInt(source,start+12+8);
@@ -125,13 +123,13 @@ public final class SlideAtom extends Rec
                LittleEndian.putInt(_header, 4, 24);
 
                byte[] ssdate = new byte[12];
-               layoutAtom = new SSlideLayoutAtom(ssdate);
-               layoutAtom.setGeometryType(SSlideLayoutAtom.BLANK_SLIDE);
+               layoutAtom = new SlideAtomLayout(ssdate);
+               layoutAtom.setGeometryType(SlideLayoutType.BLANK_SLIDE);
 
                followMasterObjects = true;
                followMasterScheme = true;
                followMasterBackground = true;
-               masterID = -2147483648;
+               masterID = USES_MASTER_SLIDE_ID; // -2147483648;
                notesID = 0;
                reserved = new byte[2];
        }
@@ -168,70 +166,4 @@ public final class SlideAtom extends Rec
                // Reserved data
                out.write(reserved);
        }
-
-
-       /**
-        * Holds the geometry of the Slide, and the ID of the placeholders
-        *  on the slide.
-        * (Embeded inside SlideAtom is a SSlideLayoutAtom, without the
-        *  usual record header. Since it's a fixed size and tied to
-        *  the SlideAtom, we'll hold it here.)
-        */
-       public static class SSlideLayoutAtom {
-               // The different kinds of geometry
-               public static final int TITLE_SLIDE = 0;
-               public static final int TITLE_BODY_SLIDE = 1;
-               public static final int TITLE_MASTER_SLIDE = 2;
-               public static final int MASTER_SLIDE = 3;
-               public static final int MASTER_NOTES = 4;
-               public static final int NOTES_TITLE_BODY = 5;
-               public static final int HANDOUT = 6; // Only header, footer and 
date placeholders
-               public static final int TITLE_ONLY = 7;
-               public static final int TITLE_2_COLUMN_BODY = 8;
-               public static final int TITLE_2_ROW_BODY = 9;
-               public static final int TITLE_2_COLUNM_RIGHT_2_ROW_BODY = 10;
-               public static final int TITLE_2_COLUNM_LEFT_2_ROW_BODY = 11;
-               public static final int TITLE_2_ROW_BOTTOM_2_COLUMN_BODY = 12;
-               public static final int TITLE_2_ROW_TOP_2_COLUMN_BODY = 13;
-               public static final int FOUR_OBJECTS = 14;
-               public static final int BIG_OBJECT = 15;
-               public static final int BLANK_SLIDE = 16;
-               public static final int VERTICAL_TITLE_BODY_LEFT = 17;
-               public static final int VERTICAL_TITLE_2_ROW_BODY_LEFT = 17;
-
-               /** What geometry type we are */
-               private int geometry;
-               /** What placeholder IDs we have */
-               private byte[] placeholderIDs;
-
-               /** Retrieve the geometry type */
-               public int getGeometryType() { return geometry; }
-               /** Set the geometry type */
-               public void setGeometryType(int geom) { geometry = geom; }
-
-               /**
-                * Create a new Embeded SSlideLayoutAtom, from 12 bytes of data
-                */
-               public SSlideLayoutAtom(byte[] data) {
-                       if(data.length != 12) {
-                               throw new HSLFException("SSlideLayoutAtom 
created with byte array not 12 bytes long - was " + data.length + " bytes in 
size");
-                       }
-
-                       // Grab out our data
-                       geometry = LittleEndian.getInt(data,0);
-                       placeholderIDs = new byte[8];
-                       System.arraycopy(data,4,placeholderIDs,0,8);
-               }
-
-               /**
-                * Write the contents of the record back, so it can be written
-                *  to disk. Skips the record header
-                */
-               public void writeOut(OutputStream out) throws IOException {
-                       // Write the geometry
-                       writeLittleEndian(geometry,out);
-                       // Write the placeholder IDs
-                       out.write(placeholderIDs);
-               }
-       }
 }

Added: 
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/SlideAtomLayout.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/SlideAtomLayout.java?rev=1782096&view=auto
==============================================================================
--- 
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/SlideAtomLayout.java 
(added)
+++ 
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/SlideAtomLayout.java 
Wed Feb  8 01:12:22 2017
@@ -0,0 +1,133 @@
+/* ====================================================================
+   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.hslf.exceptions.HSLFException;
+import org.apache.poi.util.Internal;
+import org.apache.poi.util.LittleEndian;
+
+/**
+ * Holds the geometry of the Slide, and the ID of the placeholders on the 
slide.
+ * Embedded inside a SlideAtom is a SlideAtomLayout, without the usual record 
header.
+ * Since it's a fixed size and tied to the SlideAtom, we'll hold it here.<p>
+ * 
+ * This might eventually merged with the XSLF counterpart
+ */
+@Internal
+public class SlideAtomLayout {
+    // The different kinds of geometry
+    public enum SlideLayoutType {
+        /** One title and one subtitle placeholder shapes. */
+        TITLE_SLIDE(0x0000),
+        /** Presentation slide or main master slide layout with one title and 
one body placeholder shape. */
+        TITLE_BODY(0x0001),
+        /** Title master slide layout with one title and one subtitle 
placeholder shape. */
+        MASTER_TITLE(0x0002),
+        /** ??? (not documented in spec) */
+        MASTER_SLIDE(0x0003),
+        /** ??? (not documented in spec) */
+        MASTER_NOTES(0x0004),
+        /** ??? (not documented in spec) */
+        NOTES_TITLE_BODY(0x0005),
+        /** Only header, footer and date placeholders */
+        HANDOUT(0x0006),
+        /** Presentation slide layout with one title placeholder shape. */
+        TITLE_ONLY(0x0007),
+        /** Presentation slide layout with one title and two body placeholder 
shapes stacked horizontally. */
+        TWO_COLUMNS(0x0008),
+        /** Presentation slide layout with one title and two body placeholder 
shapes stacked vertically. */
+        TWO_ROWS(0x0009),
+        /** Presentation slide layout with one title and three body 
placeholder shapes split into two columns. The right column has two rows. */
+        COLUMN_TWO_ROWS(0x000A),
+        /** Presentation slide layout with one title and three body 
placeholder shapes split into two columns. The left column has two rows. */
+        TWO_ROWS_COLUMN(0x000B),
+        /** ??? (not documented in spec) */
+        TITLE_2_ROW_BOTTOM_2_COLUMN_BODY(0x000C),
+        /** Presentation slide layout with one title and three body 
placeholder shapes split into two rows. The top row has two columns. */
+        TWO_COLUMNS_ROW(0x000D),
+        /** Presentation slide layout with one title and four body placeholder 
shapes. */
+        FOUR_OBJECTS(0x000E),
+        /** Presentation slide layout with one body placeholder shape. */
+        BIG_OBJECT(0x000F),
+        /** Presentation slide layout with no placeholder shape. */
+        BLANK_SLIDE(0x0010),
+        /** Presentation slide layout with a vertical title placeholder shape 
on the right and a body placeholder shape on the left. */
+        VERTICAL_TITLE_BODY(0x0011),
+        /** Presentation slide layout with a vertical title placeholder shape 
on the right and two body placeholder shapes in two columns on the left. */
+        VERTICAL_TWO_ROWS(0x0012);
+
+        private int nativeId;
+        SlideLayoutType(int nativeId) {
+            this.nativeId = nativeId;
+        }
+        
+        public int getNativeId() {
+            return nativeId;
+        }
+
+        public static SlideLayoutType forNativeID(int nativeId) {
+            for (SlideLayoutType ans : values()) {
+                if (ans.nativeId == nativeId) {
+                    return ans;
+                }
+            }
+            return null;
+        }
+    }
+
+    /** What geometry type we are */
+    private SlideLayoutType geometry;
+    /** What placeholder IDs we have */
+    private byte[] placeholderIDs;
+
+    /** Retrieve the geometry type */
+    public SlideLayoutType getGeometryType() { return geometry; }
+    /** Set the geometry type */
+    public void setGeometryType(SlideLayoutType geom) { geometry = geom; }
+
+    /**
+     * Create a new Embedded SSlideLayoutAtom, from 12 bytes of data
+     */
+    public SlideAtomLayout(byte[] data) {
+        if(data.length != 12) {
+            throw new HSLFException("SSlideLayoutAtom created with byte array 
not 12 bytes long - was " + data.length + " bytes in size");
+        }
+
+        // Grab out our data
+        geometry = SlideLayoutType.forNativeID(LittleEndian.getInt(data,0));
+        placeholderIDs = new byte[8];
+        System.arraycopy(data,4,placeholderIDs,0,8);
+    }
+
+    /**
+     * Write the contents of the record back, so it can be written
+     *  to disk. Skips the record header
+     */
+    public void writeOut(OutputStream out) throws IOException {
+        // Write the geometry
+        byte[] buf = new byte[4];
+        LittleEndian.putInt(buf, 0, geometry.getNativeId());
+        out.write(buf);
+        // Write the placeholder IDs
+        out.write(placeholderIDs);
+    }
+
+}

Propchange: 
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/SlideAtomLayout.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java?rev=1782096&r1=1782095&r2=1782096&view=diff
==============================================================================
--- 
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java 
(original)
+++ 
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java 
Wed Feb  8 01:12:22 2017
@@ -42,15 +42,11 @@ import org.apache.poi.util.POILogger;
  *  the style applies to, and what style elements make up the style (another
  *  list, this time of TextProps). Each TextProp has a value, which somehow
  *  encapsulates a property of the style
- *
- * @author Nick Burch
- * @author Yegor Kozlov
  */
 
-public final class StyleTextPropAtom extends RecordAtom
-{
+public final class StyleTextPropAtom extends RecordAtom {
+    public static final long _type = RecordTypes.StyleTextPropAtom.typeID;
     private byte[] _header;
-    private static final long _type = RecordTypes.StyleTextPropAtom.typeID;
     private byte[] reserved;
 
     private byte[] rawContents; // Holds the contents between write-outs

Modified: 
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextBytesAtom.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextBytesAtom.java?rev=1782096&r1=1782095&r2=1782096&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextBytesAtom.java 
(original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextBytesAtom.java 
Wed Feb  8 01:12:22 2017
@@ -17,25 +17,23 @@
 
 package org.apache.poi.hslf.record;
 
+import java.io.IOException;
+import java.io.OutputStream;
+
 import org.apache.poi.util.HexDump;
 import org.apache.poi.util.LittleEndian;
 import org.apache.poi.util.StringUtil;
-import java.io.IOException;
-import java.io.OutputStream;
 
 /**
  * A TextBytesAtom (type 4008). Holds text in ascii form (unknown
  *  code page, for now assumed to be the default of
  *  org.apache.poi.util.StringUtil, which is the Excel default).
  * The trailing return character is always stripped from this
- *
- * @author Nick Burch
  */
 
-public final class TextBytesAtom extends RecordAtom
-{
+public final class TextBytesAtom extends RecordAtom {
+    public static final long _type = RecordTypes.TextBytesAtom.typeID;
        private byte[] _header;
-       private static long _type = RecordTypes.TextBytesAtom.typeID;
 
        /** The bytes that make up the text */
        private byte[] _text;
@@ -87,13 +85,15 @@ public final class TextBytesAtom extends
        /**
         * We are of type 4008
         */
-       public long getRecordType() { return _type; }
+       @Override
+    public long getRecordType() { return _type; }
 
        /**
         * Write the contents of the record back, so it can be written
         *  to disk
         */
-       public void writeOut(OutputStream out) throws IOException {
+       @Override
+    public void writeOut(OutputStream out) throws IOException {
                // Header - size or type unchanged
                out.write(_header);
 
@@ -105,7 +105,8 @@ public final class TextBytesAtom extends
         * dump debug info; use getText() to return a string
         * representation of the atom
         */
-       public String toString() {
+       @Override
+    public String toString() {
         StringBuffer out = new StringBuffer();
         out.append( "TextBytesAtom:\n");
                out.append( HexDump.dump(_text, 0, 0) );

Modified: 
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextCharsAtom.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextCharsAtom.java?rev=1782096&r1=1782095&r2=1782096&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextCharsAtom.java 
(original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextCharsAtom.java 
Wed Feb  8 01:12:22 2017
@@ -17,23 +17,21 @@
 
 package org.apache.poi.hslf.record;
 
+import java.io.IOException;
+import java.io.OutputStream;
+
 import org.apache.poi.util.HexDump;
 import org.apache.poi.util.LittleEndian;
 import org.apache.poi.util.StringUtil;
-import java.io.IOException;
-import java.io.OutputStream;
 
 /**
  * A TextCharsAtom (type 4000). Holds text in byte swapped unicode form.
  * The trailing return character is always stripped from this
- *
- * @author Nick Burch
  */
 
-public final class TextCharsAtom extends RecordAtom
-{
+public final class TextCharsAtom extends RecordAtom {
+    public static final long _type = RecordTypes.TextCharsAtom.typeID;
        private byte[] _header;
-       private static long _type = RecordTypes.TextCharsAtom.typeID;
 
        /** The bytes that make up the text */
        private byte[] _text;
@@ -83,13 +81,15 @@ public final class TextCharsAtom extends
        /**
         * We are of type 4000
         */
-       public long getRecordType() { return _type; }
+       @Override
+    public long getRecordType() { return _type; }
 
        /**
         * Write the contents of the record back, so it can be written
         *  to disk
         */
-       public void writeOut(OutputStream out) throws IOException {
+       @Override
+    public void writeOut(OutputStream out) throws IOException {
                // Header - size or type unchanged
                out.write(_header);
 
@@ -101,7 +101,8 @@ public final class TextCharsAtom extends
         * dump debug info; use getText() to return a string
         * representation of the atom
         */
-       public String toString() {
+       @Override
+    public String toString() {
         StringBuffer out = new StringBuffer();
         out.append( "TextCharsAtom:\n");
                out.append( HexDump.dump(_text, 0, 0) );

Modified: 
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextHeaderAtom.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextHeaderAtom.java?rev=1782096&r1=1782095&r2=1782096&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextHeaderAtom.java 
(original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextHeaderAtom.java 
Wed Feb  8 01:12:22 2017
@@ -27,14 +27,11 @@ import org.apache.poi.util.LittleEndian;
  * A TextHeaderAtom  (type 3999). Holds information on what kind of
  *  text is contained in the TextBytesAtom / TextCharsAtom that follows
  *  straight after
- *
- * @author Nick Burch
  */
 
-public final class TextHeaderAtom extends RecordAtom implements 
ParentAwareRecord
-{
+public final class TextHeaderAtom extends RecordAtom implements 
ParentAwareRecord {
+    public static final long _type = RecordTypes.TextHeaderAtom.typeID;
        private byte[] _header;
-       private static long _type = RecordTypes.TextHeaderAtom.typeID;
        private RecordContainer parentRecord;
 
        public static final int TITLE_TYPE = 0;

Modified: 
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSheet.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSheet.java?rev=1782096&r1=1782095&r2=1782096&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSheet.java 
(original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSheet.java 
Wed Feb  8 01:12:22 2017
@@ -30,15 +30,14 @@ import org.apache.poi.ddf.EscherRecord;
 import org.apache.poi.hslf.exceptions.HSLFException;
 import org.apache.poi.hslf.record.CString;
 import org.apache.poi.hslf.record.ColorSchemeAtom;
-import org.apache.poi.hslf.record.OEPlaceholderAtom;
 import org.apache.poi.hslf.record.PPDrawing;
 import org.apache.poi.hslf.record.RecordContainer;
 import org.apache.poi.hslf.record.RecordTypes;
-import org.apache.poi.hslf.record.RoundTripHFPlaceholder12;
 import org.apache.poi.hslf.record.SheetContainer;
 import org.apache.poi.sl.draw.DrawFactory;
 import org.apache.poi.sl.draw.Drawable;
 import org.apache.poi.sl.usermodel.PictureData;
+import org.apache.poi.sl.usermodel.Placeholder;
 import org.apache.poi.sl.usermodel.ShapeType;
 import org.apache.poi.sl.usermodel.Sheet;
 import org.apache.poi.util.Internal;
@@ -108,6 +107,7 @@ public abstract class HSLFSheet implemen
     /**
      * Fetch the SlideShow we're attached to
      */
+    @Override
     public HSLFSlideShow getSlideShow() {
         return _slideShow;
     }
@@ -131,7 +131,9 @@ public abstract class HSLFSheet implemen
         
         _slideShow = ss;
         List<List<HSLFTextParagraph>> trs = getTextParagraphs();
-        if (trs == null) return;
+        if (trs == null) {
+            return;
+        }
         for (List<HSLFTextParagraph> ltp : trs) {
             HSLFTextParagraph.supplySheet(ltp, this);
             HSLFTextParagraph.applyHyperlinks(ltp);
@@ -192,6 +194,7 @@ public abstract class HSLFSheet implemen
      *
      * @param shape - the Shape to add
      */
+    @Override
     public void addShape(HSLFShape shape) {
         PPDrawing ppdrawing = getPPDrawing();
 
@@ -226,8 +229,9 @@ public abstract class HSLFSheet implemen
                 c.incrementShapeId();
                 dg.setNumShapes( dg.getNumShapes() + 1 );
                 dg.setLastMSOSPID( result );
-                if (result >= dgg.getShapeIdMax())
+                if (result >= dgg.getShapeIdMax()) {
                     dgg.setShapeIdMax( result + 1 );
+                }
                 return result;
             }
         }
@@ -238,8 +242,9 @@ public abstract class HSLFSheet implemen
         dg.setNumShapes( dg.getNumShapes() + 1 );
         int result = (1024 * dgg.getFileIdClusters().length);
         dg.setLastMSOSPID( result );
-        if (result >= dgg.getShapeIdMax())
+        if (result >= dgg.getShapeIdMax()) {
             dgg.setShapeIdMax( result + 1 );
+        }
         return result;
     }
 
@@ -249,6 +254,7 @@ public abstract class HSLFSheet implemen
      * @param shape shape to be removed from this sheet, if present.
      * @return <tt>true</tt> if the shape was deleted.
      */
+    @Override
     public boolean removeShape(HSLFShape shape) {
         PPDrawing ppdrawing = getPPDrawing();
 
@@ -274,6 +280,7 @@ public abstract class HSLFSheet implemen
     /**
      * Return the master sheet .
      */
+    @Override
     public abstract HSLFMasterSheet getMasterSheet();
 
     /**
@@ -288,6 +295,7 @@ public abstract class HSLFSheet implemen
      *
      * @return the background shape for this sheet.
      */
+    @Override
     public HSLFBackground getBackground() {
         if (_background == null) {
             PPDrawing ppdrawing = getPPDrawing();
@@ -335,26 +343,17 @@ public abstract class HSLFSheet implemen
     }
 
     /**
-     * Search text placeholer by its type
+     * Search placeholder by its type
      *
      * @param type  type of placeholder to search. See {@link 
org.apache.poi.hslf.record.OEPlaceholderAtom}
-     * @return  <code>TextShape</code> or <code>null</code>
+     * @return  {@code SimpleShape} or {@code null}
      */
-    public HSLFTextShape getPlaceholder(int type){
+    public HSLFSimpleShape getPlaceholder(Placeholder type){
         for (HSLFShape shape : getShapes()) {
-            if(shape instanceof HSLFTextShape){
-                HSLFTextShape tx = (HSLFTextShape)shape;
-                int placeholderId = 0;
-                OEPlaceholderAtom oep = tx.getPlaceholderAtom();
-                if(oep != null) {
-                    placeholderId = oep.getPlaceholderId();
-                } else {
-                    //special case for files saved in Office 2007
-                    RoundTripHFPlaceholder12 hldr = 
tx.getClientDataRecord(RecordTypes.RoundTripHFPlaceholder12.typeID);
-                    if(hldr != null) placeholderId = hldr.getPlaceholderId();
-                }
-                if(placeholderId == type){
-                    return tx;
+            if (shape instanceof HSLFSimpleShape) {
+                HSLFSimpleShape ss = (HSLFSimpleShape)shape;
+                if (type == ss.getPlaceholder()) {
+                    return ss;
                 }
             }
         }
@@ -382,7 +381,9 @@ public abstract class HSLFSheet implemen
                     progBinaryTag.findFirstOfType(
                             RecordTypes.CString.typeID
                 );
-                if(binaryTag != null) tag = binaryTag.getText();
+                if(binaryTag != null) {
+                    tag = binaryTag.getText();
+                }
             }
         }
 
@@ -390,6 +391,7 @@ public abstract class HSLFSheet implemen
 
     }
 
+    @Override
     public Iterator<HSLFShape> iterator() {
         return getShapes().iterator();
     }
@@ -400,6 +402,7 @@ public abstract class HSLFSheet implemen
      * Sheets that support the notion of master (slide, slideLayout) should 
override it and
      * check this setting
      */
+    @Override
     public boolean getFollowMasterGraphics() {
         return false;
     }

Modified: 
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSimpleShape.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSimpleShape.java?rev=1782096&r1=1782095&r2=1782096&view=diff
==============================================================================
--- 
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSimpleShape.java 
(original)
+++ 
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSimpleShape.java 
Wed Feb  8 01:12:22 2017
@@ -42,6 +42,7 @@ import org.apache.poi.sl.draw.geom.Prese
 import org.apache.poi.sl.usermodel.LineDecoration;
 import org.apache.poi.sl.usermodel.LineDecoration.DecorationShape;
 import org.apache.poi.sl.usermodel.LineDecoration.DecorationSize;
+import org.apache.poi.sl.usermodel.MasterSheet;
 import org.apache.poi.sl.usermodel.PaintStyle;
 import org.apache.poi.sl.usermodel.PaintStyle.SolidPaint;
 import org.apache.poi.sl.usermodel.Placeholder;
@@ -546,13 +547,40 @@ public abstract class HSLFSimpleShape ex
         if (clRecords == null) {
             return null;
         }
+        int phSource;
+        HSLFSheet sheet = getSheet();
+        if (sheet instanceof HSLFSlideMaster) {
+            phSource = 1;
+        } else if (sheet instanceof HSLFNotes) {
+            phSource = 2;
+        } else if (sheet instanceof MasterSheet) {
+            // notes master aren't yet supported ...
+            phSource = 3;
+        } else {
+            phSource = 0;
+        }
+        
         for (Record r : clRecords) {
+            int phId;
             if (r instanceof OEPlaceholderAtom) {
-                OEPlaceholderAtom oep = (OEPlaceholderAtom)r;
-                return Placeholder.lookupNative(oep.getPlaceholderId());
+                phId = ((OEPlaceholderAtom)r).getPlaceholderId();
             } else if (r instanceof RoundTripHFPlaceholder12) {
-                RoundTripHFPlaceholder12 rtp = (RoundTripHFPlaceholder12)r;
-                return Placeholder.lookupNative(rtp.getPlaceholderId());
+                //special case for files saved in Office 2007
+                phId = ((RoundTripHFPlaceholder12)r).getPlaceholderId();
+            } else {
+                continue;
+            }
+
+            switch (phSource) {
+            case 0:
+                return Placeholder.lookupNativeSlide(phId);
+            default:
+            case 1:
+                return Placeholder.lookupNativeSlideMaster(phId);
+            case 2:
+                return Placeholder.lookupNativeNotes(phId);
+            case 3:
+                return Placeholder.lookupNativeNotesMaster(phId);
             }
         }
 

Modified: 
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlide.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlide.java?rev=1782096&r1=1782095&r2=1782096&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlide.java 
(original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlide.java 
Wed Feb  8 01:12:22 2017
@@ -36,6 +36,7 @@ import org.apache.poi.hslf.record.Record
 import org.apache.poi.hslf.record.RecordTypes;
 import org.apache.poi.hslf.record.SSSlideInfoAtom;
 import org.apache.poi.hslf.record.SlideAtom;
+import org.apache.poi.hslf.record.SlideAtomLayout.SlideLayoutType;
 import org.apache.poi.hslf.record.SlideListWithText.SlideAtomsSet;
 import org.apache.poi.hslf.record.StyleTextProp9Atom;
 import org.apache.poi.hslf.record.TextHeaderAtom;
@@ -501,4 +502,27 @@ public final class HSLFSlide extends HSL
     public boolean getFollowMasterGraphics() {
         return getFollowMasterObjects();
     }
+
+    @Override
+    public boolean getDisplayPlaceholder(Placeholder placeholder) {
+        HeadersFooters hf = getHeadersFooters();
+        SlideLayoutType slt =  
getSlideRecord().getSlideAtom().getSSlideLayoutAtom().getGeometryType();
+        boolean isTitle =
+            (slt == SlideLayoutType.TITLE_SLIDE || slt == 
SlideLayoutType.TITLE_ONLY || slt == SlideLayoutType.MASTER_TITLE);
+        if (hf != null) {
+            switch (placeholder) {
+            case DATETIME:
+                return hf.isDateTimeVisible() && !isTitle;
+            case SLIDE_NUMBER:
+                return hf.isSlideNumberVisible() && !isTitle;
+            case HEADER:
+                return hf.isHeaderVisible() && !isTitle;
+            case FOOTER:
+                return hf.isFooterVisible() && !isTitle;
+            default:
+                break;    
+            }
+        }
+        return false;
+    }
 }

Modified: 
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideMaster.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideMaster.java?rev=1782096&r1=1782095&r2=1782096&view=diff
==============================================================================
--- 
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideMaster.java 
(original)
+++ 
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideMaster.java 
Wed Feb  8 01:12:22 2017
@@ -23,7 +23,9 @@ import java.util.List;
 import org.apache.poi.hslf.exceptions.HSLFException;
 import org.apache.poi.hslf.model.textproperties.TextProp;
 import org.apache.poi.hslf.model.textproperties.TextPropCollection;
-import org.apache.poi.hslf.record.*;
+import org.apache.poi.hslf.record.MainMaster;
+import org.apache.poi.hslf.record.TextHeaderAtom;
+import org.apache.poi.hslf.record.TxMasterStyleAtom;
 import org.apache.poi.util.Internal;
 
 /**
@@ -49,13 +51,16 @@ public final class HSLFSlideMaster exten
         super(record, sheetNo);
 
         for (List<HSLFTextParagraph> l : 
HSLFTextParagraph.findTextParagraphs(getPPDrawing(), this)) {
-            if (!_paragraphs.contains(l)) _paragraphs.add(l);
+            if (!_paragraphs.contains(l)) {
+                _paragraphs.add(l);
+            }
         }
     }
 
     /**
      * Returns an array of all the TextRuns found
      */
+    @Override
     public List<List<HSLFTextParagraph>> getTextParagraphs() {
         return _paragraphs;
     }
@@ -63,6 +68,7 @@ public final class HSLFSlideMaster exten
     /**
      * Returns <code>null</code> since SlideMasters doen't have master sheet.
      */
+    @Override
     public HSLFMasterSheet getMasterSheet() {
         return null;
     }
@@ -71,8 +77,11 @@ public final class HSLFSlideMaster exten
      * Pickup a style attribute from the master.
      * This is the "workhorse" which returns the default style attributes.
      */
+    @Override
     public TextProp getStyleAttribute(int txtype, int level, String name, 
boolean isCharacter) {
-        if (_txmaster.length <= txtype) return null;
+        if (_txmaster.length <= txtype) {
+            return null;
+        }
         TxMasterStyleAtom t = _txmaster[txtype];
         List<TextPropCollection> styles = isCharacter ? t.getCharacterStyles() 
: t.getParagraphStyles();
         
@@ -81,7 +90,9 @@ public final class HSLFSlideMaster exten
             prop = styles.get(i).findByName(name);
         }
 
-        if (prop != null) return prop;
+        if (prop != null) {
+            return prop;
+        }
         
         switch (txtype) {
             case TextHeaderAtom.CENTRE_BODY_TYPE:
@@ -146,6 +157,7 @@ public final class HSLFSlideMaster exten
         }
     }
 
+    @Override
     protected void onAddTextShape(HSLFTextShape shape) {
         List<HSLFTextParagraph> runs = shape.getTextParagraphs();
         _paragraphs.add(runs);

Modified: 
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java?rev=1782096&r1=1782095&r2=1782096&view=diff
==============================================================================
--- 
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java
 (original)
+++ 
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java
 Wed Feb  8 01:12:22 2017
@@ -36,14 +36,35 @@ import org.apache.poi.hslf.model.textpro
 import org.apache.poi.hslf.model.textproperties.TextProp;
 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.ColorSchemeAtom;
+import org.apache.poi.hslf.record.EscherTextboxWrapper;
+import org.apache.poi.hslf.record.FontCollection;
+import org.apache.poi.hslf.record.InteractiveInfo;
+import org.apache.poi.hslf.record.MasterTextPropAtom;
+import org.apache.poi.hslf.record.OutlineTextRefAtom;
+import org.apache.poi.hslf.record.PPDrawing;
+import org.apache.poi.hslf.record.Record;
+import org.apache.poi.hslf.record.RecordContainer;
+import org.apache.poi.hslf.record.RecordTypes;
+import org.apache.poi.hslf.record.RoundTripHFPlaceholder12;
+import org.apache.poi.hslf.record.SlideListWithText;
+import org.apache.poi.hslf.record.SlidePersistAtom;
+import org.apache.poi.hslf.record.StyleTextProp9Atom;
+import org.apache.poi.hslf.record.StyleTextPropAtom;
+import org.apache.poi.hslf.record.TextBytesAtom;
+import org.apache.poi.hslf.record.TextCharsAtom;
+import org.apache.poi.hslf.record.TextHeaderAtom;
+import org.apache.poi.hslf.record.TextRulerAtom;
+import org.apache.poi.hslf.record.TextSpecInfoAtom;
+import org.apache.poi.hslf.record.TxInteractiveInfoAtom;
 import org.apache.poi.sl.draw.DrawPaint;
 import org.apache.poi.sl.usermodel.AutoNumberingScheme;
+import org.apache.poi.sl.usermodel.MasterSheet;
 import org.apache.poi.sl.usermodel.PaintStyle;
 import org.apache.poi.sl.usermodel.PaintStyle.SolidPaint;
+import org.apache.poi.sl.usermodel.Placeholder;
 import org.apache.poi.sl.usermodel.TextParagraph;
 import org.apache.poi.util.Internal;
-import org.apache.poi.util.LocaleUtil;
 import org.apache.poi.util.POILogFactory;
 import org.apache.poi.util.POILogger;
 import org.apache.poi.util.StringUtil;
@@ -53,8 +74,6 @@ import org.apache.poi.util.Units;
  * This class represents a run of text in a powerpoint document. That
  *  run could be text on a sheet, or text in a note.
  *  It is only a very basic class for now
- *
- * @author Nick Burch
  */
 
 public final class HSLFTextParagraph implements 
TextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun> {
@@ -74,6 +93,7 @@ public final class HSLFTextParagraph imp
     private TextBytesAtom _byteAtom;
     private TextCharsAtom _charAtom;
     private TextPropCollection _paragraphStyle = new TextPropCollection(1, 
TextPropType.paragraph);
+    private TextPropCollection _masterStyle;
 
     protected TextRulerAtom _ruler;
     protected final List<HSLFTextRun> _runs = new ArrayList<HSLFTextRun>();
@@ -139,7 +159,7 @@ public final class HSLFTextParagraph imp
     public void setParagraphStyle(TextPropCollection paragraphStyle) {
         _paragraphStyle.copy(paragraphStyle);
     }
-
+    
     /**
      * Setting a master style reference
      *
@@ -148,8 +168,8 @@ public final class HSLFTextParagraph imp
      * @since POI 3.14-Beta1
      */
     @Internal
-    /* package */ void setMasterStyleReference(TextPropCollection 
paragraphStyle) {
-        _paragraphStyle = paragraphStyle;
+    /* package */ void setMasterStyleReference(TextPropCollection masterStyle) 
{
+        _masterStyle = masterStyle;
     }
 
     /**
@@ -321,8 +341,8 @@ public final class HSLFTextParagraph imp
 
     @Override
     public Double getLeftMargin() {
-        TextProp val = getPropVal(_paragraphStyle, "text.offset", this);
-        return (val == null) ? null : Units.masterToPoints(val.getValue());
+        TextProp tp = getPropVal(_paragraphStyle, _masterStyle, "text.offset");
+        return (tp == null) ? null : Units.masterToPoints(tp.getValue());
     }
 
     @Override
@@ -344,8 +364,8 @@ public final class HSLFTextParagraph imp
 
     @Override
     public Double getIndent() {
-        TextProp val = getPropVal(_paragraphStyle, "bullet.offset", this);
-        return (val == null) ? null : Units.masterToPoints(val.getValue());
+        TextProp tp = getPropVal(_paragraphStyle, _masterStyle, 
"bullet.offset");
+        return (tp == null) ? null : Units.masterToPoints(tp.getValue());
     }
 
     @Override
@@ -393,7 +413,7 @@ public final class HSLFTextParagraph imp
 
     @Override
     public TextAlign getTextAlign() {
-        TextProp tp = getPropVal(_paragraphStyle, "alignment", this);
+        TextProp tp = getPropVal(_paragraphStyle, _masterStyle, "alignment");
         if (tp == null) {
             return null;
         }
@@ -411,7 +431,7 @@ public final class HSLFTextParagraph imp
 
     @Override
     public FontAlign getFontAlign() {
-        TextProp tp = getPropVal(_paragraphStyle, FontAlignmentProp.NAME, 
this);
+        TextProp tp = getPropVal(_paragraphStyle, _masterStyle, 
FontAlignmentProp.NAME);
         if (tp == null) {
             return null;
         }
@@ -577,7 +597,7 @@ public final class HSLFTextParagraph imp
      * Returns the bullet character
      */
     public Character getBulletChar() {
-        TextProp tp = getPropVal(_paragraphStyle, "bullet.char", this);
+        TextProp tp = getPropVal(_paragraphStyle, _masterStyle, "bullet.char");
         return (tp == null) ? null : (char)tp.getValue();
     }
 
@@ -608,7 +628,7 @@ public final class HSLFTextParagraph imp
      * Returns the bullet color
      */
     public Color getBulletColor() {
-        TextProp tp = getPropVal(_paragraphStyle, "bullet.color", this);
+        TextProp tp = getPropVal(_paragraphStyle, _masterStyle, 
"bullet.color");
         boolean hasColor = 
getFlag(ParagraphFlagsTextProp.BULLET_HARDCOLOR_IDX);
         if (tp == null || !hasColor) {
             // if bullet color is undefined, return color of first run
@@ -632,8 +652,9 @@ public final class HSLFTextParagraph imp
      */
     public void setBulletFont(String typeface) {
         if (typeface == null) {
-            setPropVal(_paragraphStyle, "bullet.font", null);
+            setPropVal(_paragraphStyle, _masterStyle, "bullet.font", null);
             setFlag(ParagraphFlagsTextProp.BULLET_HARDFONT_IDX, false);
+            return;
         }
 
         FontCollection fc = getSheet().getSlideShow().getFontCollection();
@@ -647,7 +668,7 @@ public final class HSLFTextParagraph imp
      * Returns the bullet font
      */
     public String getBulletFont() {
-        TextProp tp = getPropVal(_paragraphStyle, "bullet.font", this);
+        TextProp tp = getPropVal(_paragraphStyle, _masterStyle, "bullet.font");
         boolean hasFont = getFlag(ParagraphFlagsTextProp.BULLET_HARDFONT_IDX);
         if (tp == null || !hasFont) {
             return getDefaultFontFamily();
@@ -694,7 +715,7 @@ public final class HSLFTextParagraph imp
     }
 
     private Double getPctOrPoints(String propName) {
-        TextProp tp = getPropVal(_paragraphStyle, propName, this);
+        TextProp tp = getPropVal(_paragraphStyle, _masterStyle, propName);
         if (tp == null) {
             return null;
         }
@@ -711,7 +732,7 @@ public final class HSLFTextParagraph imp
     }
 
     private boolean getFlag(int index) {
-        BitMaskTextProp tp = (BitMaskTextProp)getPropVal(_paragraphStyle, 
ParagraphFlagsTextProp.NAME, this);
+        BitMaskTextProp tp = (BitMaskTextProp)getPropVal(_paragraphStyle, 
_masterStyle, ParagraphFlagsTextProp.NAME);
         return (tp == null) ? false : tp.getSubValue(index);
     }
 
@@ -729,7 +750,7 @@ public final class HSLFTextParagraph imp
      * The propName can be a comma-separated list, in case multiple equivalent 
values
      * are queried
      */
-    protected static TextProp getPropVal(TextPropCollection props, String 
propName, HSLFTextParagraph paragraph) {
+    protected TextProp getPropVal(TextPropCollection props, TextPropCollection 
masterProps, String propName) {
         String propNames[] = propName.split(",");
         for (String pn : propNames) {
             TextProp prop = props.findByName(pn);
@@ -740,41 +761,52 @@ public final class HSLFTextParagraph imp
             // Font properties (maybe other too???) can have an index of -1
             // so we check the master for this font index then
             if (pn.contains("font") && prop.getValue() == -1) {
-                return getMasterPropVal(props, pn, paragraph);
+                return getMasterPropVal(props, masterProps, pn);
             }
             
             return prop;
         }
         
-        return getMasterPropVal(props, propName, paragraph);
+        return getMasterPropVal(props, masterProps, propName);
     }
     
-    private static TextProp getMasterPropVal(TextPropCollection props, String 
propName, HSLFTextParagraph paragraph) {
-        String propNames[] = propName.split(",");
-        
-        BitMaskTextProp maskProp = (BitMaskTextProp) 
props.findByName(ParagraphFlagsTextProp.NAME);
-        boolean hardAttribute = (maskProp != null && maskProp.getValue() == 0);
-        if (hardAttribute) {
-            return null;
-        }
+    private TextProp getMasterPropVal(TextPropCollection props, 
TextPropCollection masterProps, String propName) {
+        boolean isChar = props.getTextPropType() == TextPropType.character;
 
-        HSLFSheet sheet = paragraph.getSheet();
-        int txtype = paragraph.getRunType();
-        HSLFMasterSheet master = sheet.getMasterSheet();
-        if (master == null) {
-            logger.log(POILogger.WARN, "MasterSheet is not available");
-            return null;
+        // check if we can delegate to master for the property
+        if (!isChar) {
+            BitMaskTextProp maskProp = (BitMaskTextProp) 
props.findByName(ParagraphFlagsTextProp.NAME);
+            boolean hardAttribute = (maskProp != null && maskProp.getValue() 
== 0);
+            if (hardAttribute) {
+                return null;
+            }
         }
 
-        boolean isChar = props.getTextPropType() == TextPropType.character;
+        String propNames[] = propName.split(",");
+        if (masterProps == null) { 
+            HSLFSheet sheet = getSheet();
+            int txtype = getRunType();
+            HSLFMasterSheet master = sheet.getMasterSheet();
+            if (master == null) {
+                logger.log(POILogger.WARN, "MasterSheet is not available");
+                return null;
+            }
 
-        for (String pn : propNames) {
-            TextProp prop = master.getStyleAttribute(txtype, 
paragraph.getIndentLevel(), pn, isChar);
-            if (prop != null) {
-                return prop;
+            for (String pn : propNames) {
+                TextProp prop = master.getStyleAttribute(txtype, 
getIndentLevel(), pn, isChar);
+                if (prop != null) {
+                    return prop;
+                }
+            }
+        } else {
+            for (String pn : propNames) {
+                TextProp prop = masterProps.findByName(pn);
+                if (prop != null) {
+                    return prop;
+                }
             }
         }
-
+        
         return null;
     }
 
@@ -786,14 +818,19 @@ public final class HSLFTextParagraph imp
      * @param name the name of the TextProp to fetch/add
      * @param val the value, null if unset
      */
-    protected static void setPropVal(TextPropCollection props, String name, 
Integer val) {
+    protected void setPropVal(TextPropCollection props, TextPropCollection 
masterProps, String name, Integer val) {
+        TextPropCollection pc = props;
+        if (getSheet() instanceof MasterSheet && masterProps != null) {
+            pc = masterProps;
+        }
+        
         if (val == null) {
-            props.removeByName(name);
+            pc.removeByName(name);
             return;
         }
 
         // Fetch / Add the TextProp
-        TextProp tp = props.addWithName(name);
+        TextProp tp = pc.addWithName(name);
         tp.setValue(val);
     }
 
@@ -1517,38 +1554,6 @@ public final class HSLFTextParagraph imp
         }
     }
 
-    protected static List<HSLFTextParagraph> createEmptyParagraph() {
-        EscherTextboxWrapper wrapper = new EscherTextboxWrapper();
-        return createEmptyParagraph(wrapper);
-    }
-
-    protected static List<HSLFTextParagraph> 
createEmptyParagraph(EscherTextboxWrapper wrapper) {
-        TextHeaderAtom tha = new TextHeaderAtom();
-        tha.setParentRecord(wrapper);
-        wrapper.appendChildRecord(tha);
-
-        TextBytesAtom tba = new TextBytesAtom();
-        tba.setText("".getBytes(LocaleUtil.CHARSET_1252));
-        wrapper.appendChildRecord(tba);
-
-        StyleTextPropAtom sta = new StyleTextPropAtom(1);
-        TextPropCollection paraStyle = sta.addParagraphTextPropCollection(1);
-        TextPropCollection charStyle = sta.addCharacterTextPropCollection(1);
-        wrapper.appendChildRecord(sta);
-
-        List<HSLFTextParagraph> paragraphs = new 
ArrayList<HSLFTextParagraph>(1);
-        HSLFTextParagraph htp = new HSLFTextParagraph(tha, tba, null, 
paragraphs);
-        htp.setParagraphStyle(paraStyle);
-        paragraphs.add(htp);
-
-        HSLFTextRun htr = new HSLFTextRun(htp);
-        htr.setCharacterStyle(charStyle);
-        htr.setText("");
-        htp.addTextRun(htr);
-
-        return paragraphs;
-    }
-
     public EscherTextboxWrapper getTextboxWrapper() {
         return (EscherTextboxWrapper) _headerAtom.getParentRecord();
     }
@@ -1583,7 +1588,7 @@ public final class HSLFTextParagraph imp
      * @param val The value to set for the TextProp
      */
     public void setParagraphTextPropVal(String propName, Integer val) {
-        setPropVal(_paragraphStyle, propName, val);
+        setPropVal(_paragraphStyle, _masterStyle, propName, val);
         setDirty();
     }
 
@@ -1624,21 +1629,19 @@ public final class HSLFTextParagraph imp
      */
     @Override
     public boolean isHeaderOrFooter() {
-        HSLFShape s = getParentShape();
+        HSLFTextShape s = getParentShape();
         if (s == null) {
             return false;
         }
-        RoundTripHFPlaceholder12 hfPl = 
s.getClientDataRecord(RecordTypes.RoundTripHFPlaceholder12.typeID);
-        if (hfPl == null) {
+        Placeholder ph = s.getPlaceholder();
+        if (ph == null) {
             return false;
         }
-
-        int plId = hfPl.getPlaceholderId();
-        switch (plId) {
-            case OEPlaceholderAtom.MasterDate:
-            case OEPlaceholderAtom.MasterSlideNumber:
-            case OEPlaceholderAtom.MasterFooter:
-            case OEPlaceholderAtom.MasterHeader:
+        switch (ph) {
+            case DATETIME:
+            case SLIDE_NUMBER:
+            case FOOTER:
+            case HEADER:
                 return true;
             default:
                 return false;

Modified: 
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextRun.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextRun.java?rev=1782096&r1=1782095&r2=1782096&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextRun.java 
(original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextRun.java 
Wed Feb  8 01:12:22 2017
@@ -17,8 +17,6 @@
 
 package org.apache.poi.hslf.usermodel;
 
-import static org.apache.poi.hslf.usermodel.HSLFTextParagraph.getPropVal;
-
 import java.awt.Color;
 
 import org.apache.poi.hslf.exceptions.HSLFException;
@@ -30,6 +28,7 @@ import org.apache.poi.hslf.model.textpro
 import org.apache.poi.sl.draw.DrawPaint;
 import org.apache.poi.sl.usermodel.PaintStyle;
 import org.apache.poi.sl.usermodel.PaintStyle.SolidPaint;
+import org.apache.poi.sl.usermodel.Placeholder;
 import org.apache.poi.sl.usermodel.TextRun;
 import org.apache.poi.util.Internal;
 import org.apache.poi.util.POILogFactory;
@@ -54,6 +53,8 @@ public final class HSLFTextRun implement
         * Note - we may share these styles with other RichTextRuns
         */
        private TextPropCollection characterStyle = new TextPropCollection(1, 
TextPropType.character);
+       
+       private TextPropCollection masterStyle;
 
        /**
         * Create a new wrapper around a rich text string
@@ -80,8 +81,8 @@ public final class HSLFTextRun implement
      * @since POI 3.14-Beta1
      */
        @Internal
-    /* package */ void setMasterStyleReference(TextPropCollection 
characterStyle) {
-        this.characterStyle = characterStyle;
+    /* package */ void setMasterStyleReference(TextPropCollection masterStyle) 
{
+        this.masterStyle = masterStyle;
     }
  
        
@@ -105,14 +106,16 @@ public final class HSLFTextRun implement
        /**
         * Fetch the text, in raw storage form
         */
-       public String getRawText() {
+       @Override
+    public String getRawText() {
                return _runText;
        }
 
        /**
         * Change the text
         */
-       public void setText(String text) {
+       @Override
+    public void setText(String text) {
            if (text == null) {
                throw new HSLFException("text must not be null");
            }
@@ -137,7 +140,9 @@ public final class HSLFTextRun implement
        }
 
        protected boolean getFlag(int index) {
-           if (characterStyle == null) return false;
+           if (characterStyle == null) {
+            return false;
+        }
 
                BitMaskTextProp prop = 
(BitMaskTextProp)characterStyle.findByName(CharFlagsTextProp.NAME);
 
@@ -175,8 +180,8 @@ public final class HSLFTextRun implement
         * @param val The value to set for the TextProp
         */
        public void setCharTextPropVal(String propName, Integer val) {
-           HSLFTextParagraph.setPropVal(characterStyle, propName, val);
-           parentParagraph.setDirty();
+           getTextParagraph().setPropVal(characterStyle, masterStyle, 
propName, val);
+           getTextParagraph().setDirty();
        }
 
 
@@ -256,7 +261,7 @@ public final class HSLFTextRun implement
         * @return the percentage of the font size. If the value is positive, 
it is superscript, otherwise it is subscript
         */
        public int getSuperscript() {
-               TextProp tp = getPropVal(characterStyle, "superscript", 
parentParagraph);
+               TextProp tp = getTextParagraph().getPropVal(characterStyle, 
masterStyle, "superscript");
                return tp == null ? 0 : tp.getValue();
        }
 
@@ -271,7 +276,7 @@ public final class HSLFTextRun implement
 
     @Override
        public Double getFontSize() {
-        TextProp tp = getPropVal(characterStyle, "font.size", parentParagraph);
+        TextProp tp = getTextParagraph().getPropVal(characterStyle, 
masterStyle, "font.size");
         return tp == null ? null : (double)tp.getValue();
        }
 
@@ -286,7 +291,7 @@ public final class HSLFTextRun implement
         * Gets the font index
         */
        public int getFontIndex() {
-        TextProp tp = getPropVal(characterStyle, "font.index", 
parentParagraph);
+        TextProp tp = getTextParagraph().getPropVal(characterStyle, 
masterStyle, "font.index");
         return tp == null ? -1 : tp.getValue();
        }
 
@@ -320,7 +325,7 @@ public final class HSLFTextRun implement
                if (sheet == null || slideShow == null) {
                        return _fontFamily;
                }
-        TextProp tp = getPropVal(characterStyle, 
"font.index,asian.font.index,ansi.font.index,symbol.font.index", 
parentParagraph);
+        TextProp tp = getTextParagraph().getPropVal(characterStyle, 
masterStyle, "font.index,asian.font.index,ansi.font.index,symbol.font.index");
         if (tp == null) { return null; }
                return 
slideShow.getFontCollection().getFontWithId(tp.getValue());
        }
@@ -330,8 +335,10 @@ public final class HSLFTextRun implement
         */
        @Override
        public SolidPaint getFontColor() {
-               TextProp tp = getPropVal(characterStyle, "font.color", 
parentParagraph);
-               if (tp == null) return null;
+               TextProp tp = getTextParagraph().getPropVal(characterStyle, 
masterStyle, "font.color");
+               if (tp == null) {
+            return null;
+        }
                Color color = 
HSLFTextParagraph.getColorFromColorIndexStruct(tp.getValue(), 
parentParagraph.getSheet());
                SolidPaint ps = DrawPaint.createSolidPaint(color);
                return ps;
@@ -374,6 +381,7 @@ public final class HSLFTextRun implement
         return parentParagraph;
     }
     
+    @Override
     public TextCap getTextCap() {
         return TextCap.NONE;
     }
@@ -388,6 +396,7 @@ public final class HSLFTextRun implement
         return getSuperscript() > 0;
     }
 
+    @Override
     public byte getPitchAndFamily() {
         return 0;
     }
@@ -414,4 +423,20 @@ public final class HSLFTextRun implement
         }
         return link;
     }
+    
+    @Override
+    public FieldType getFieldType() {
+        Placeholder ph = getTextParagraph().getParentShape().getPlaceholder();
+        if (ph != null) {
+            switch (ph) {
+            case SLIDE_NUMBER:
+                return FieldType.SLIDE_NUMBER;
+            case DATETIME:
+                return FieldType.DATE_TIME;
+            default:
+                break;
+            }
+        }
+        return null;
+    }
 }

Modified: 
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextShape.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextShape.java?rev=1782096&r1=1782095&r2=1782096&view=diff
==============================================================================
--- 
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextShape.java 
(original)
+++ 
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextShape.java 
Wed Feb  8 01:12:22 2017
@@ -20,7 +20,6 @@ package org.apache.poi.hslf.usermodel;
 import static org.apache.poi.hslf.record.RecordTypes.OEPlaceholderAtom;
 import static org.apache.poi.hslf.record.RecordTypes.RoundTripHFPlaceholder12;
 
-import java.awt.font.FontRenderContext;
 import java.awt.geom.Rectangle2D;
 import java.io.IOException;
 import java.util.ArrayList;
@@ -34,10 +33,14 @@ import org.apache.poi.ddf.EscherSimplePr
 import org.apache.poi.ddf.EscherTextboxRecord;
 import org.apache.poi.hslf.exceptions.HSLFException;
 import org.apache.poi.hslf.model.HSLFMetroShape;
+import org.apache.poi.hslf.model.textproperties.TextPropCollection;
 import org.apache.poi.hslf.record.EscherTextboxWrapper;
 import org.apache.poi.hslf.record.OEPlaceholderAtom;
 import org.apache.poi.hslf.record.PPDrawing;
 import org.apache.poi.hslf.record.RoundTripHFPlaceholder12;
+import org.apache.poi.hslf.record.StyleTextPropAtom;
+import org.apache.poi.hslf.record.TextBytesAtom;
+import org.apache.poi.hslf.record.TextCharsAtom;
 import org.apache.poi.hslf.record.TextHeaderAtom;
 import org.apache.poi.sl.draw.DrawFactory;
 import org.apache.poi.sl.draw.DrawTextShape;
@@ -71,12 +74,12 @@ implements TextShape<HSLFShape,HSLFTextP
         BOTTOM_BASELINE       (7, VerticalAlignment.BOTTOM, false, true),
         TOP_CENTER_BASELINE   (8, VerticalAlignment.TOP,    true,  true),
         BOTTOM_CENTER_BASELINE(9, VerticalAlignment.BOTTOM, true,  true);
-        
+
         public final int nativeId;
         public final VerticalAlignment vAlign;
         public final boolean centered;
         public final Boolean baseline;
-        
+
         HSLFTextAnchor(int nativeId, VerticalAlignment vAlign, boolean 
centered, Boolean baseline) {
             this.nativeId = nativeId;
             this.vAlign = vAlign;
@@ -86,7 +89,9 @@ implements TextShape<HSLFShape,HSLFTextP
 
         static HSLFTextAnchor fromNativeId(int nativeId) {
             for (HSLFTextAnchor ta : values()) {
-                if (ta.nativeId == nativeId) return ta;
+                if (ta.nativeId == nativeId) {
+                    return ta;
+                }
             }
             return null;
         }
@@ -125,13 +130,13 @@ implements TextShape<HSLFShape,HSLFTextP
     /**
      * TextRun object which holds actual text and format data
      */
-    protected List<HSLFTextParagraph> _paragraphs = new 
ArrayList<HSLFTextParagraph>();
+    private List<HSLFTextParagraph> _paragraphs = new 
ArrayList<HSLFTextParagraph>();
 
     /**
      * Escher container which holds text attributes such as
-     * TextHeaderAtom, TextBytesAtom ot TextCharsAtom, StyleTextPropAtom etc.
+     * TextHeaderAtom, TextBytesAtom or TextCharsAtom, StyleTextPropAtom etc.
      */
-    protected EscherTextboxWrapper _txtbox;
+    private EscherTextboxWrapper _txtbox;
 
     /**
      * This setting is used for supporting a deprecated alignment
@@ -141,11 +146,6 @@ implements TextShape<HSLFShape,HSLFTextP
 //    boolean alignToBaseline = false;
 
     /**
-     * Used to calculate text bounds
-     */
-    protected static final FontRenderContext _frc = new 
FontRenderContext(null, true, true);
-
-    /**
      * Create a TextBox object and initialize it from the supplied Record 
container.
      *
      * @param escherRecord       <code>EscherSpContainer</code> container 
which holds information about this shape
@@ -222,10 +222,14 @@ implements TextShape<HSLFShape,HSLFTextP
     }
 
     protected EscherTextboxWrapper getEscherTextboxWrapper(){
-        if(_txtbox != null) return _txtbox;
+        if(_txtbox != null) {
+            return _txtbox;
+        }
 
         EscherTextboxRecord textRecord = 
getEscherChild(EscherTextboxRecord.RECORD_ID);
-        if (textRecord == null) return null;
+        if (textRecord == null) {
+            return null;
+        }
 
         HSLFSheet sheet = getSheet();
         if (sheet != null) {
@@ -248,6 +252,66 @@ implements TextShape<HSLFShape,HSLFTextP
         return _txtbox;
     }
 
+    private void createEmptyParagraph() {
+        TextHeaderAtom tha = 
(TextHeaderAtom)_txtbox.findFirstOfType(TextHeaderAtom._type);
+        if (tha == null) {
+            tha = new TextHeaderAtom();
+            tha.setParentRecord(_txtbox);
+            _txtbox.appendChildRecord(tha);
+        }
+
+        TextBytesAtom tba = 
(TextBytesAtom)_txtbox.findFirstOfType(TextBytesAtom._type);
+        TextCharsAtom tca = 
(TextCharsAtom)_txtbox.findFirstOfType(TextCharsAtom._type);
+        if (tba == null && tca == null) {
+            tba = new TextBytesAtom();
+             tba.setText(new byte[0]);
+             _txtbox.appendChildRecord(tba);
+        }
+
+        final String text = ((tba != null) ? tba.getText() : tca.getText());
+        
+        StyleTextPropAtom sta = 
(StyleTextPropAtom)_txtbox.findFirstOfType(StyleTextPropAtom._type);
+        TextPropCollection paraStyle = null, charStyle = null;
+        if (sta == null) {
+            int parSiz = text.length();
+            sta = new StyleTextPropAtom(parSiz+1);
+            if (_paragraphs.isEmpty()) {
+                paraStyle = sta.addParagraphTextPropCollection(parSiz+1);
+                charStyle = sta.addCharacterTextPropCollection(parSiz+1);
+            } else {
+                for (HSLFTextParagraph htp : _paragraphs) {
+                    int runsLen = 0;
+                    for (HSLFTextRun htr : htp.getTextRuns()) {
+                        runsLen += htr.getLength();
+                        charStyle = 
sta.addCharacterTextPropCollection(htr.getLength());
+                        htr.setCharacterStyle(charStyle);
+                    }
+                    paraStyle = sta.addParagraphTextPropCollection(runsLen);
+                    htp.setParagraphStyle(paraStyle);
+                }
+                assert (paraStyle != null && charStyle != null);
+            }
+            _txtbox.appendChildRecord(sta);
+        } else {
+            paraStyle = sta.getParagraphStyles().get(0);
+            charStyle = sta.getCharacterStyles().get(0);
+        }
+
+        if (_paragraphs.isEmpty()) {
+            HSLFTextParagraph htp = new HSLFTextParagraph(tha, tba, tca, 
_paragraphs);
+            htp.setParagraphStyle(paraStyle);
+            htp.setParentShape(this);
+            _paragraphs.add(htp);
+    
+            HSLFTextRun htr = new HSLFTextRun(htp);
+            htr.setCharacterStyle(charStyle);
+            htr.setText(text);
+            htp.addTextRun(htr);
+        }
+    }
+
+
+    
     /**
      * Adjust the size of the shape so it encompasses the text inside it.
      *
@@ -276,7 +340,9 @@ implements TextShape<HSLFShape,HSLFTextP
     */
     public int getRunType() {
         getEscherTextboxWrapper();
-        if (_txtbox == null) return -1;
+        if (_txtbox == null) {
+            return -1;
+        }
         List<HSLFTextParagraph> paras = 
HSLFTextParagraph.findTextParagraphs(_txtbox, getSheet());
         return (paras.isEmpty()) ? -1 : paras.get(0).getRunType();
     }
@@ -289,7 +355,9 @@ implements TextShape<HSLFShape,HSLFTextP
     */
     public void setRunType(int type) {
         getEscherTextboxWrapper();
-        if (_txtbox == null) return;
+        if (_txtbox == null) {
+            return;
+        }
         List<HSLFTextParagraph> paras = 
HSLFTextParagraph.findTextParagraphs(_txtbox, getSheet());
         if (!paras.isEmpty()) {
             paras.get(0).setRunType(type);
@@ -562,19 +630,23 @@ implements TextShape<HSLFShape,HSLFTextP
 
     @Override
     public List<HSLFTextParagraph> getTextParagraphs(){
-        if (!_paragraphs.isEmpty()) return _paragraphs;
+        if (!_paragraphs.isEmpty()) {
+            return _paragraphs;
+        }
 
         _txtbox = getEscherTextboxWrapper();
         if (_txtbox == null) {
-            _paragraphs.addAll(HSLFTextParagraph.createEmptyParagraph());
-            _txtbox = _paragraphs.get(0).getTextboxWrapper();
+            _txtbox = new EscherTextboxWrapper();
+            createEmptyParagraph();
         } else {
-            _paragraphs = HSLFTextParagraph.findTextParagraphs(_txtbox, 
getSheet());
-            if (_paragraphs == null) {
+            List<HSLFTextParagraph> pList = 
HSLFTextParagraph.findTextParagraphs(_txtbox, getSheet());
+            if (pList == null) {
                 // there are actually TextBoxRecords without extra data - see 
#54722
-                _paragraphs = HSLFTextParagraph.createEmptyParagraph(_txtbox);
+                createEmptyParagraph();
+            } else {
+                _paragraphs = pList;
             }
-
+        
             if (_paragraphs.isEmpty()) {
                 LOG.log(POILogger.WARN, "TextRecord didn't contained any text 
lines");
             }
@@ -587,6 +659,7 @@ implements TextShape<HSLFShape,HSLFTextP
         return _paragraphs;
     }
 
+
     @Override
     public void setSheet(HSLFSheet sheet) {
         super.setSheet(sheet);
@@ -611,26 +684,30 @@ implements TextShape<HSLFShape,HSLFTextP
     /**
      * Return {@link RoundTripHFPlaceholder12}, the atom that describes a 
header/footer placeholder.
      * Compare the {@link RoundTripHFPlaceholder12#getPlaceholderId()} with
-     * {@link OEPlaceholderAtom#MasterHeader} or {@link 
OEPlaceholderAtom#MasterFooter}, to find out
+     * {@link Placeholder#HEADER} or {@link Placeholder#FOOTER}, to find out
      * what kind of placeholder this is.
      *
      * @return {@link RoundTripHFPlaceholder12} or {@code null} if not found
-     * 
+     *
      * @since POI 3.14-Beta2
      */
     public RoundTripHFPlaceholder12 getHFPlaceholderAtom() {
         // special case for files saved in Office 2007
         return getClientDataRecord(RoundTripHFPlaceholder12.typeID);
     }
-    
+
     @Override
     public boolean isPlaceholder() {
         OEPlaceholderAtom oep = getPlaceholderAtom();
-        if (oep != null) return true;
+        if (oep != null) {
+            return true;
+        }
 
         //special case for files saved in Office 2007
         RoundTripHFPlaceholder12 hldr = getHFPlaceholderAtom();
-        if (hldr != null) return true;
+        if (hldr != null) {
+            return true;
+        }
 
         return false;
     }
@@ -710,7 +787,7 @@ implements TextShape<HSLFShape,HSLFTextP
         }
         setEscherProperty(opt, EscherProperties.TEXT__TEXTFLOW, msotxfl);
     }
-    
+
     @Override
     public Double getTextRotation() {
         // see 2.4.6 MSOCDIR
@@ -718,7 +795,7 @@ implements TextShape<HSLFShape,HSLFTextP
         EscherSimpleProperty prop = getEscherProperty(opt, 
EscherProperties.TEXT__FONTROTATION);
         return (prop == null) ? null : (90. * prop.getPropertyValue());
     }
-    
+
     @Override
     public void setTextRotation(Double rotation) {
         AbstractEscherOptRecord opt = getEscherOptRecord();
@@ -729,7 +806,7 @@ implements TextShape<HSLFShape,HSLFTextP
             setEscherProperty(EscherProperties.TEXT__FONTROTATION, rot);
         }
     }
-    
+
     /**
      * Returns the raw text content of the shape. This hasn't had any
      * changes applied to it, and so is probably unlikely to print
@@ -751,7 +828,7 @@ implements TextShape<HSLFShape,HSLFTextP
         List<HSLFTextParagraph> paras = getTextParagraphs();
         HSLFTextRun htr = HSLFTextParagraph.appendText(paras, text, 
newParagraph);
         setTextId(getRawText().hashCode());
-        return htr; 
+        return htr;
     }
 
     @Override

Modified: 
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTitleMaster.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTitleMaster.java?rev=1782096&r1=1782095&r2=1782096&view=diff
==============================================================================
--- 
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTitleMaster.java 
(original)
+++ 
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTitleMaster.java 
Wed Feb  8 01:12:22 2017
@@ -25,8 +25,6 @@ import org.apache.poi.hslf.record.SlideA
 
 /**
  * Title masters define the design template for slides with a Title Slide 
layout.
- *
- * @author Yegor Kozlov
  */
 public final class HSLFTitleMaster extends HSLFMasterSheet {
     private final List<List<HSLFTextParagraph>> _paragraphs = new 
ArrayList<List<HSLFTextParagraph>>();
@@ -39,13 +37,16 @@ public final class HSLFTitleMaster exten
         super(record, sheetNo);
 
         for (List<HSLFTextParagraph> l : 
HSLFTextParagraph.findTextParagraphs(getPPDrawing(), this)) {
-            if (!_paragraphs.contains(l)) _paragraphs.add(l);
+            if (!_paragraphs.contains(l)) {
+                _paragraphs.add(l);
+            }
         }
     }
 
     /**
      * Returns an array of all the TextRuns found
      */
+    @Override
     public List<List<HSLFTextParagraph>> getTextParagraphs() {
         return _paragraphs;
     }
@@ -53,20 +54,23 @@ public final class HSLFTitleMaster exten
     /**
      * Delegate the call to the underlying slide master.
      */
+    @Override
     public TextProp getStyleAttribute(int txtype, int level, String name, 
boolean isCharacter) {
         HSLFMasterSheet master = getMasterSheet();
-        return master == null ? null : master.getStyleAttribute(txtype, level, 
name, isCharacter);
+        return (master == null) ? null : master.getStyleAttribute(txtype, 
level, name, isCharacter);
     }
 
     /**
      * Returns the slide master for this title master.
      */
+    @Override
     public HSLFMasterSheet getMasterSheet(){
-        List<HSLFSlideMaster> master = getSlideShow().getSlideMasters();
         SlideAtom sa = 
((org.apache.poi.hslf.record.Slide)getSheetContainer()).getSlideAtom();
         int masterId = sa.getMasterID();
-        for (HSLFSlideMaster sm : master) {
-            if (masterId == sm._getSheetNumber()) return sm;
+        for (HSLFSlideMaster sm : getSlideShow().getSlideMasters()) {
+            if (masterId == sm._getSheetNumber()) {
+                return sm;
+            }
         }
         return null;
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to