You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ki...@apache.org on 2018/04/18 15:02:03 UTC

svn commit: r1829453 [2/3] - in /poi: site/src/documentation/content/xdocs/ trunk/src/java/org/apache/poi/sl/draw/ trunk/src/java/org/apache/poi/sl/extractor/ trunk/src/java/org/apache/poi/sl/usermodel/ trunk/src/ooxml/java/org/apache/poi/xslf/extracto...

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextParagraph.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextParagraph.java?rev=1829453&r1=1829452&r2=1829453&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextParagraph.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextParagraph.java Wed Apr 18 15:02:02 2018
@@ -20,6 +20,9 @@ import java.awt.Color;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Objects;
+import java.util.function.Function;
+import java.util.function.Supplier;
 
 import org.apache.poi.sl.draw.DrawPaint;
 import org.apache.poi.sl.usermodel.AutoNumberingScheme;
@@ -49,6 +52,12 @@ public class XSLFTextParagraph implement
     private final List<XSLFTextRun> _runs;
     private final XSLFTextShape _shape;
 
+    @FunctionalInterface
+    private interface Procedure {
+        void accept();
+    }
+
+
     XSLFTextParagraph(CTTextParagraph p, XSLFTextShape shape){
         _p = p;
         _runs = new ArrayList<>();
@@ -79,14 +88,6 @@ public class XSLFTextParagraph implement
         return out.toString();
     }
 
-    String getRenderableText(){
-        StringBuilder out = new StringBuilder();
-        for (XSLFTextRun r : _runs) {
-            out.append(r.getRenderableText());
-        }
-        return out.toString();
-    }
-
     @Internal
     public CTTextParagraph getXmlObject(){
         return _p;
@@ -125,6 +126,7 @@ public class XSLFTextParagraph implement
      *
      * @return text run representing this line break ('\n')
      */
+    @SuppressWarnings("WeakerAccess")
     public XSLFTextRun addLineBreak(){
         XSLFLineBreak run = new XSLFLineBreak(_p.addNewBr(), this);
         CTTextCharacterProperties brProps = run.getRPr(true);
@@ -200,6 +202,7 @@ public class XSLFTextParagraph implement
     /**
      * @return the font to be used on bullet characters within a given paragraph
      */
+    @SuppressWarnings("WeakerAccess")
     public String getBulletFont(){
         ParagraphPropertyFetcher<String> fetcher = new ParagraphPropertyFetcher<String>(getIndentLevel()){
             public boolean fetch(CTTextParagraphProperties props){
@@ -214,6 +217,7 @@ public class XSLFTextParagraph implement
         return fetcher.getValue();
     }
 
+    @SuppressWarnings("WeakerAccess")
     public void setBulletFont(String typeface){
         CTTextParagraphProperties pr = _p.isSetPPr() ? _p.getPPr() : _p.addNewPPr();
         CTTextFont font = pr.isSetBuFont() ? pr.getBuFont() : pr.addNewBuFont();
@@ -223,6 +227,7 @@ public class XSLFTextParagraph implement
     /**
      * @return the character to be used in place of the standard bullet point
      */
+    @SuppressWarnings("WeakerAccess")
     public String getBulletCharacter(){
         ParagraphPropertyFetcher<String> fetcher = new ParagraphPropertyFetcher<String>(getIndentLevel()){
             public boolean fetch(CTTextParagraphProperties props){
@@ -237,6 +242,7 @@ public class XSLFTextParagraph implement
         return fetcher.getValue();
     }
 
+    @SuppressWarnings("WeakerAccess")
     public void setBulletCharacter(String str){
         CTTextParagraphProperties pr = _p.isSetPPr() ? _p.getPPr() : _p.addNewPPr();
         CTTextCharBullet c = pr.isSetBuChar() ? pr.getBuChar() : pr.addNewBuChar();
@@ -248,6 +254,7 @@ public class XSLFTextParagraph implement
      * @return the color of bullet characters within a given paragraph.
      * A <code>null</code> value means to use the text font color.
      */
+    @SuppressWarnings("WeakerAccess")
     public PaintStyle getBulletFontColor(){
         final XSLFTheme theme = getParentShape().getSheet().getTheme();
         ParagraphPropertyFetcher<Color> fetcher = new ParagraphPropertyFetcher<Color>(getIndentLevel()){
@@ -265,6 +272,7 @@ public class XSLFTextParagraph implement
         return (col == null) ? null : DrawPaint.createSolidPaint(col);
     }
 
+    @SuppressWarnings("WeakerAccess")
     public void setBulletFontColor(Color color) {
         setBulletFontColor(DrawPaint.createSolidPaint(color));
     }
@@ -275,6 +283,7 @@ public class XSLFTextParagraph implement
      *
      * @param color the bullet color
      */
+    @SuppressWarnings("WeakerAccess")
     public void setBulletFontColor(PaintStyle color) {
         if (!(color instanceof SolidPaint)) {
             throw new IllegalArgumentException("Currently XSLF only supports SolidPaint");
@@ -300,6 +309,7 @@ public class XSLFTextParagraph implement
      *
      * @return the bullet size
      */
+    @SuppressWarnings("WeakerAccess")
     public Double getBulletFontSize(){
         ParagraphPropertyFetcher<Double> fetcher = new ParagraphPropertyFetcher<Double>(getIndentLevel()){
             public boolean fetch(CTTextParagraphProperties props){
@@ -326,6 +336,7 @@ public class XSLFTextParagraph implement
      * If bulletSize < 0, then it specifies the size in points
      * </p>
      */
+    @SuppressWarnings("WeakerAccess")
     public void setBulletFontSize(double bulletSize){
         CTTextParagraphProperties pr = _p.isSetPPr() ? _p.getPPr() : _p.addNewPPr();
 
@@ -343,6 +354,7 @@ public class XSLFTextParagraph implement
     /**
      * @return the auto numbering scheme, or null if not defined
      */
+    @SuppressWarnings("WeakerAccess")
     public AutoNumberingScheme getAutoNumberingScheme() {
         ParagraphPropertyFetcher<AutoNumberingScheme> fetcher = new ParagraphPropertyFetcher<AutoNumberingScheme>(getIndentLevel()) {
             public boolean fetch(CTTextParagraphProperties props) {
@@ -363,6 +375,7 @@ public class XSLFTextParagraph implement
     /**
      * @return the auto numbering starting number, or null if not defined
      */
+    @SuppressWarnings("WeakerAccess")
     public Integer getAutoNumberingStartAt() {
         ParagraphPropertyFetcher<Integer> fetcher = new ParagraphPropertyFetcher<Integer>(getIndentLevel()) {
             public boolean fetch(CTTextParagraphProperties props) {
@@ -487,10 +500,11 @@ public class XSLFTextParagraph implement
         return fetcher.getValue();
     }
 
-    public double getTabStop(final int idx){
+    @SuppressWarnings("WeakerAccess")
+    public double getTabStop(final int idx) {
         ParagraphPropertyFetcher<Double> fetcher = new ParagraphPropertyFetcher<Double>(getIndentLevel()){
             public boolean fetch(CTTextParagraphProperties props){
-                if(props.isSetTabLst()){
+                if (props.isSetTabLst()) {
                     CTTextTabStopList tabStops = props.getTabLst();
                     if(idx < tabStops.sizeOfTabArray() ) {
                         CTTextTabStop ts = tabStops.getTabArray(idx);
@@ -506,6 +520,7 @@ public class XSLFTextParagraph implement
         return fetcher.getValue() == null ? 0. : fetcher.getValue();
     }
 
+    @SuppressWarnings("WeakerAccess")
     public void addTabStop(double value){
         CTTextParagraphProperties pr = _p.isSetPPr() ? _p.getPPr() : _p.addNewPPr();
         CTTextTabStopList tabStops = pr.isSetTabLst() ? pr.getTabLst() : pr.addNewTabLst();
@@ -514,45 +529,18 @@ public class XSLFTextParagraph implement
 
     @Override
     public void setLineSpacing(Double lineSpacing){
-        if (lineSpacing == null && !_p.isSetPPr()) return;
-        CTTextParagraphProperties pr = _p.isSetPPr() ? _p.getPPr() : _p.addNewPPr();
-        if(lineSpacing == null) {
-            if (pr.isSetLnSpc()) pr.unsetLnSpc();
-        } else {
-            CTTextSpacing spc = (pr.isSetLnSpc()) ? pr.getLnSpc() : pr.addNewLnSpc();
-            if (lineSpacing >= 0) {
-                (spc.isSetSpcPct() ? spc.getSpcPct() : spc.addNewSpcPct()).setVal((int)(lineSpacing*1000));
-                if (spc.isSetSpcPts()) spc.unsetSpcPts();
-            } else {
-                (spc.isSetSpcPts() ? spc.getSpcPts() : spc.addNewSpcPts()).setVal((int)(-lineSpacing*100));
-                if (spc.isSetSpcPct()) spc.unsetSpcPct();
-            }
-        }
+        setSpacing(lineSpacing, props -> props::getLnSpc, props -> props::addNewLnSpc, props -> props::unsetLnSpc);
     }
 
     @Override
     public Double getLineSpacing(){
-        ParagraphPropertyFetcher<Double> fetcher = new ParagraphPropertyFetcher<Double>(getIndentLevel()){
-            public boolean fetch(CTTextParagraphProperties props){
-                if(props.isSetLnSpc()){
-                    CTTextSpacing spc = props.getLnSpc();
-
-                    if(spc.isSetSpcPct()) setValue( spc.getSpcPct().getVal()*0.001 );
-                    else if (spc.isSetSpcPts()) setValue( -spc.getSpcPts().getVal()*0.01 );
-                    return true;
-                }
-                return false;
-            }
-        };
-        fetchParagraphProperty(fetcher);
-
-        Double lnSpc = fetcher.getValue();
+        final Double lnSpc = getSpacing(props -> props::getLnSpc);
         if (lnSpc != null && lnSpc > 0) {
             // check if the percentage value is scaled
-            CTTextNormalAutofit normAutofit = getParentShape().getTextBodyPr().getNormAutofit();
-            if(normAutofit != null) {
-                double scale = 1 - (double)normAutofit.getLnSpcReduction() / 100000;
-                lnSpc *= scale;
+            final CTTextNormalAutofit normAutofit = getParentShape().getTextBodyPr().getNormAutofit();
+            if (normAutofit != null) {
+                final double scale = 1 - (double)normAutofit.getLnSpcReduction() / 100000;
+                return lnSpc * scale;
             }
         }
         
@@ -561,84 +549,82 @@ public class XSLFTextParagraph implement
 
     @Override
     public void setSpaceBefore(Double spaceBefore){
-        if (spaceBefore == null && !_p.isSetPPr()) {
-            return;
-        }
-
-        // unset the space before on null input
-        if (spaceBefore == null) {
-            if(_p.getPPr().isSetSpcBef()) {
-                _p.getPPr().unsetSpcBef();
-            }
-            return;
-        }
-
-        CTTextParagraphProperties pr = _p.isSetPPr() ? _p.getPPr() : _p.addNewPPr();
-        CTTextSpacing spc = CTTextSpacing.Factory.newInstance();
-
-        if(spaceBefore >= 0) {
-            spc.addNewSpcPct().setVal((int)(spaceBefore*1000));
-        } else {
-            spc.addNewSpcPts().setVal((int)(-spaceBefore*100));
-        }
-        pr.setSpcBef(spc);
+        setSpacing(spaceBefore, props -> props::getSpcBef, props -> props::addNewSpcBef, props -> props::unsetSpcBef);
     }
 
     @Override
     public Double getSpaceBefore(){
-        ParagraphPropertyFetcher<Double> fetcher = new ParagraphPropertyFetcher<Double>(getIndentLevel()){
-            public boolean fetch(CTTextParagraphProperties props){
-                if(props.isSetSpcBef()){
-                    CTTextSpacing spc = props.getSpcBef();
-
-                    if(spc.isSetSpcPct()) setValue( spc.getSpcPct().getVal()*0.001 );
-                    else if (spc.isSetSpcPts()) setValue( -spc.getSpcPts().getVal()*0.01 );
-                    return true;
-                }
-                return false;
-            }
-        };
-        fetchParagraphProperty(fetcher);
-
-        return fetcher.getValue();
+        return getSpacing(props -> props::getSpcBef);
     }
 
     @Override
     public void setSpaceAfter(Double spaceAfter){
-        if (spaceAfter == null && !_p.isSetPPr()) {
+        setSpacing(spaceAfter, props -> props::getSpcAft, props -> props::addNewSpcAft, props -> props::unsetSpcAft);
+    }
+
+    @Override
+    public Double getSpaceAfter() {
+        return getSpacing(props -> props::getSpcAft);
+    }
+
+    private void setSpacing(final Double space,
+        final Function<CTTextParagraphProperties,Supplier<CTTextSpacing>> getSpc,
+        final Function<CTTextParagraphProperties,Supplier<CTTextSpacing>> addSpc,
+        final Function<CTTextParagraphProperties,Procedure> unsetSpc
+    ) {
+        final CTTextParagraphProperties pPr = (space == null || _p.isSetPPr()) ?  _p.getPPr() : _p.addNewPPr();
+        if (pPr == null) {
             return;
         }
 
-        // unset the space before on null input
-        if (spaceAfter == null) {
-            if(_p.getPPr().isSetSpcAft()) {
-                _p.getPPr().unsetSpcAft();
+        CTTextSpacing spc = getSpc.apply(pPr).get();
+
+        if (space == null) {
+            if (spc != null) {
+                // unset the space before on null input
+                unsetSpc.apply(pPr).accept();
             }
             return;
         }
 
-        CTTextParagraphProperties pr = _p.isSetPPr() ? _p.getPPr() : _p.addNewPPr();
-        CTTextSpacing spc = CTTextSpacing.Factory.newInstance();
+        if (spc == null) {
+            spc = addSpc.apply(pPr).get();
+        }
 
-        if(spaceAfter >= 0) {
-            spc.addNewSpcPct().setVal((int)(spaceAfter*1000));
+        if (space >= 0) {
+            if (spc.isSetSpcPts()) {
+                spc.unsetSpcPts();
+            }
+            final CTTextSpacingPercent pct = spc.isSetSpcPct() ? spc.getSpcPct() : spc.addNewSpcPct();
+            pct.setVal((int)(space*1000));
         } else {
-            spc.addNewSpcPts().setVal((int)(-spaceAfter*100));
+            if (spc.isSetSpcPct()) {
+                spc.unsetSpcPct();
+            }
+            final CTTextSpacingPoint pts = spc.isSetSpcPts() ? spc.getSpcPts() : spc.addNewSpcPts();
+            pts.setVal((int)(-space*100));
         }
-        pr.setSpcAft(spc);
     }
 
-    @Override
-    public Double getSpaceAfter(){
-        ParagraphPropertyFetcher<Double> fetcher = new ParagraphPropertyFetcher<Double>(getIndentLevel()){
-            public boolean fetch(CTTextParagraphProperties props){
-                if(props.isSetSpcAft()){
-                    CTTextSpacing spc = props.getSpcAft();
+    private Double getSpacing(final Function<CTTextParagraphProperties,Supplier<CTTextSpacing>> getSpc) {
+        final ParagraphPropertyFetcher<Double> fetcher = new ParagraphPropertyFetcher<Double>(getIndentLevel()){
+            public boolean fetch(final CTTextParagraphProperties props){
+                final CTTextSpacing spc = getSpc.apply(props).get();
+
+                if (spc == null) {
+                    return false;
+                }
+
+                if (spc.isSetSpcPct()) {
+                    setValue( spc.getSpcPct().getVal()*0.001 );
+                    return true;
+                }
 
-                    if(spc.isSetSpcPct()) setValue( spc.getSpcPct().getVal()*0.001 );
-                    else if (spc.isSetSpcPts()) setValue( -spc.getSpcPts().getVal()*0.01 );
+                if (spc.isSetSpcPts()) {
+                    setValue( -spc.getSpcPts().getVal()*0.01 );
                     return true;
                 }
+
                 return false;
             }
         };
@@ -713,6 +699,7 @@ public class XSLFTextParagraph implement
      * @param startAt the number that will start number for a given sequence of automatically
     numbered bullets (1-based).
      */
+    @SuppressWarnings("WeakerAccess")
     public void setBulletAutoNumber(AutoNumberingScheme scheme, int startAt) {
         if(startAt < 1) throw new IllegalArgumentException("Start Number must be greater or equal that 1") ;
         CTTextParagraphProperties pr = _p.isSetPPr() ? _p.getPPr() : _p.addNewPPr();
@@ -732,7 +719,7 @@ public class XSLFTextParagraph implement
      * there are no master slides or the master slides do not contain a text paragraph
      */
     /* package */ CTTextParagraphProperties getDefaultMasterStyle(){
-        CTPlaceholder ph = _shape.getCTPlaceholder();
+        CTPlaceholder ph = _shape.getPlaceholderDetails().getCTPlaceholder(false);
         String defaultStyleSelector;  
         switch(ph == null ? -1 : ph.getType().intValue()) {
             case STPlaceholderType.INT_TITLE:
@@ -780,37 +767,46 @@ public class XSLFTextParagraph implement
         return null;
     }
 
-    private <T> boolean fetchParagraphProperty(ParagraphPropertyFetcher<T> visitor){
-        boolean ok = false;
+    private void fetchParagraphProperty(final ParagraphPropertyFetcher<?> visitor){
         final XSLFTextShape shape = getParentShape();
         final XSLFSheet sheet = shape.getSheet();
         
         if (!(sheet instanceof XSLFSlideMaster)) {
-            if(_p.isSetPPr()) ok = visitor.fetch(_p.getPPr());
-            if (ok) return true;
+            if (_p.isSetPPr() && visitor.fetch(_p.getPPr())) {
+                return;
+            }
     
-            ok = shape.fetchShapeProperty(visitor);
-            if (ok) return true;
-                    
-            
-            CTPlaceholder ph = shape.getCTPlaceholder();
-            if(ph == null){
-                // if it is a plain text box then take defaults from presentation.xml
-                @SuppressWarnings("resource")
-                XMLSlideShow ppt = sheet.getSlideShow();
-                CTTextParagraphProperties themeProps = ppt.getDefaultParagraphStyle(getIndentLevel());
-                if (themeProps != null) ok = visitor.fetch(themeProps);
+            if (shape.fetchShapeProperty(visitor)) {
+                return;
+            }
+
+            if (fetchThemeProperty(visitor)) {
+                return;
             }
-            if (ok) return true;
         }
 
+        fetchMasterProperty(visitor);
+    }
+
+    boolean fetchMasterProperty(final ParagraphPropertyFetcher<?> visitor) {
         // defaults for placeholders are defined in the slide master
-        CTTextParagraphProperties defaultProps = getDefaultMasterStyle();
+        final CTTextParagraphProperties defaultProps = getDefaultMasterStyle();
         // TODO: determine master shape
-        if(defaultProps != null) ok = visitor.fetch(defaultProps);
-        if (ok) return true;
+        return defaultProps != null && visitor.fetch(defaultProps);
+    }
+
+    boolean fetchThemeProperty(final ParagraphPropertyFetcher<?> visitor) {
+        final XSLFTextShape shape = getParentShape();
+
+        if (shape.isPlaceholder()) {
+            return false;
+        }
 
-        return false;
+        // if it is a plain text box then take defaults from presentation.xml
+        @SuppressWarnings("resource")
+        final XMLSlideShow ppt = shape.getSheet().getSlideShow();
+        final CTTextParagraphProperties themeProps = ppt.getDefaultParagraphStyle(getIndentLevel());
+        return themeProps != null && visitor.fetch(themeProps);
     }
 
     void copy(XSLFTextParagraph other){
@@ -873,40 +869,40 @@ public class XSLFTextParagraph implement
                     setBulletFontColor(buColor);
                 }
                 Double buSize = other.getBulletFontSize();
-                if(!doubleEquals(buSize, getBulletFontSize())){
+                if(doubleNotEquals(buSize, getBulletFontSize())){
                     setBulletFontSize(buSize);
                 }
             }
         }
 
         Double leftMargin = other.getLeftMargin();
-        if (!doubleEquals(leftMargin, getLeftMargin())){
+        if (doubleNotEquals(leftMargin, getLeftMargin())){
             setLeftMargin(leftMargin);
         }
 
         Double indent = other.getIndent();
-        if (!doubleEquals(indent, getIndent())) {
+        if (doubleNotEquals(indent, getIndent())) {
             setIndent(indent);
         }
 
         Double spaceAfter = other.getSpaceAfter();
-        if (!doubleEquals(spaceAfter, getSpaceAfter())) {
+        if (doubleNotEquals(spaceAfter, getSpaceAfter())) {
             setSpaceAfter(spaceAfter);
         }
         
         Double spaceBefore = other.getSpaceBefore();
-        if (!doubleEquals(spaceBefore, getSpaceBefore())) {
+        if (doubleNotEquals(spaceBefore, getSpaceBefore())) {
             setSpaceBefore(spaceBefore);
         }
         
         Double lineSpacing = other.getLineSpacing();
-        if (!doubleEquals(lineSpacing, getLineSpacing())) {
+        if (doubleNotEquals(lineSpacing, getLineSpacing())) {
             setLineSpacing(lineSpacing);
         }
     }
 
-    private static boolean doubleEquals(Double d1, Double d2) {
-        return (d1 == d2 || (d1 != null && d1.equals(d2)));
+    private static boolean doubleNotEquals(Double d1, Double d2) {
+        return !Objects.equals(d1, d2);
     }
     
     @Override
@@ -1072,7 +1068,7 @@ public class XSLFTextParagraph implement
 
     @Override
     public boolean isHeaderOrFooter() {
-        CTPlaceholder ph = _shape.getCTPlaceholder();
+        CTPlaceholder ph = _shape.getPlaceholderDetails().getCTPlaceholder(false);
         int phId = (ph == null ? -1 : ph.getType().intValue());
         switch (phId) {
             case STPlaceholderType.INT_SLD_NUM:

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextRun.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextRun.java?rev=1829453&r1=1829452&r2=1829453&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextRun.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextRun.java Wed Apr 18 15:02:02 2018
@@ -17,7 +17,6 @@
 package org.apache.poi.xslf.usermodel;
 
 import java.awt.Color;
-import java.util.Locale;
 
 import org.apache.poi.common.usermodel.fonts.FontCharset;
 import org.apache.poi.common.usermodel.fonts.FontFamily;
@@ -31,7 +30,6 @@ import org.apache.poi.sl.usermodel.Paint
 import org.apache.poi.sl.usermodel.PaintStyle.SolidPaint;
 import org.apache.poi.sl.usermodel.TextRun;
 import org.apache.poi.util.Beta;
-import org.apache.poi.util.LocaleUtil;
 import org.apache.poi.xslf.model.CharacterPropertyFetcher;
 import org.apache.poi.xslf.usermodel.XSLFPropertiesDelegate.XSLFFillProperties;
 import org.apache.xmlbeans.XmlObject;
@@ -47,10 +45,8 @@ import org.openxmlformats.schemas.drawin
 import org.openxmlformats.schemas.drawingml.x2006.main.CTTextFont;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTTextLineBreak;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTTextNormalAutofit;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraphProperties;
 import org.openxmlformats.schemas.drawingml.x2006.main.STTextStrikeType;
 import org.openxmlformats.schemas.drawingml.x2006.main.STTextUnderlineType;
-import org.openxmlformats.schemas.presentationml.x2006.main.CTPlaceholder;
 
 /**
  * Represents a run of text within the containing text body. The run element is the
@@ -83,36 +79,6 @@ public class XSLFTextRun implements Text
         return ((CTRegularTextRun)_r).getT();
     }
 
-    String getRenderableText(){
-        if (_r instanceof CTTextField) {
-            CTTextField tf = (CTTextField)_r;
-            XSLFSheet sheet = _p.getParentShape().getSheet();
-            if ("slidenum".equals(tf.getType()) && sheet instanceof XSLFSlide) {
-                return Integer.toString(((XSLFSlide)sheet).getSlideNumber());
-            }
-            return tf.getT();
-        } else if (_r instanceof CTTextLineBreak) {
-            return "\n";
-        }
-
-        return getRenderableText(((CTRegularTextRun)_r).getT());
-    }
-
-    /* package */ String getRenderableText(final String txt){
-        // TODO: finish support for tabs
-        final String txtSpace = txt.replace("\t", "  ");
-        final Locale loc = LocaleUtil.getUserLocale();
-
-        switch (getTextCap()) {
-            case ALL:
-                return txtSpace.toUpperCase(loc);
-            case SMALL:
-                return txtSpace.toLowerCase(loc);
-            default:
-                return txtSpace;
-        }
-    }
-
     @Override
     public void setText(String text){
         if (_r instanceof CTTextField) {
@@ -230,6 +196,7 @@ public class XSLFTextRun implements Text
      * @return the spacing between characters within a text run,
      * If this attribute is omitted than a value of 0 or no adjustment is assumed.
      */
+    @SuppressWarnings("WeakerAccess")
     public double getCharacterSpacing(){
 
         CharacterPropertyFetcher<Double> fetcher = new CharacterPropertyFetcher<Double>(_p.getIndentLevel()){
@@ -255,6 +222,7 @@ public class XSLFTextRun implements Text
      *
      * @param spc  character spacing in points.
      */
+    @SuppressWarnings("WeakerAccess")
     public void setCharacterSpacing(double spc){
         CTTextCharacterProperties rPr = getRPr(true);
         if(spc == 0.0) {
@@ -357,9 +325,8 @@ public class XSLFTextRun implements Text
      *     The size is specified using a percentage.
      *     Positive values indicate superscript, negative values indicate subscript.
      *  </p>
-     *
-     * @param baselineOffset
      */
+    @SuppressWarnings("WeakerAccess")
     public void setBaselineOffset(double baselineOffset){
        getRPr(true).setBaseline((int) baselineOffset * 1000);
     }
@@ -370,6 +337,7 @@ public class XSLFTextRun implements Text
      *
      * @see #setBaselineOffset(double)
      */
+    @SuppressWarnings("WeakerAccess")
     public void setSuperscript(boolean flag){
         setBaselineOffset(flag ? 30. : 0.);
     }
@@ -380,6 +348,7 @@ public class XSLFTextRun implements Text
      *
      * @see #setBaselineOffset(double)
      */
+    @SuppressWarnings("WeakerAccess")
     public void setSubscript(boolean flag){
         setBaselineOffset(flag ? -25.0 : 0.);
     }
@@ -544,38 +513,23 @@ public class XSLFTextRun implements Text
         return new XSLFHyperlink(hl, _p.getParentShape().getSheet());
     }
 
-    private boolean fetchCharacterProperty(CharacterPropertyFetcher<?> fetcher){
+    private void fetchCharacterProperty(final CharacterPropertyFetcher<?> visitor){
         XSLFTextShape shape = _p.getParentShape();
-        XSLFSheet sheet = shape.getSheet();
 
         CTTextCharacterProperties rPr = getRPr(false);
-        if (rPr != null && fetcher.fetch(rPr)) {
-            return true;
-        }
-
-        if (shape.fetchShapeProperty(fetcher)) {
-            return true;
+        if (rPr != null && visitor.fetch(rPr)) {
+            return;
         }
 
-        CTPlaceholder ph = shape.getCTPlaceholder();
-        if (ph == null){
-            // if it is a plain text box then take defaults from presentation.xml
-            @SuppressWarnings("resource")
-            XMLSlideShow ppt = sheet.getSlideShow();
-            // TODO: determine master shape
-            CTTextParagraphProperties themeProps = ppt.getDefaultParagraphStyle(_p.getIndentLevel());
-            if (themeProps != null && fetcher.fetch(themeProps)) {
-                return true;
-            }
+        if (shape.fetchShapeProperty(visitor)) {
+            return;
         }
 
-        // TODO: determine master shape
-        CTTextParagraphProperties defaultProps =  _p.getDefaultMasterStyle();
-        if(defaultProps != null && fetcher.fetch(defaultProps)) {
-            return true;
+        if (_p.fetchThemeProperty(visitor)) {
+            return;
         }
 
-        return false;
+        _p.fetchMasterProperty(visitor);
     }
 
     void copy(XSLFTextRun r){
@@ -630,14 +584,14 @@ public class XSLFTextRun implements Text
     }
 
 
-    private class XSLFFontInfo implements FontInfo {
+    private final class XSLFFontInfo implements FontInfo {
         private final FontGroup fontGroup;
 
         private XSLFFontInfo(FontGroup fontGroup) {
             this.fontGroup = (fontGroup != null) ? fontGroup : FontGroup.getFontGroupFirst(getRawText());
         }
 
-        public void copyFrom(FontInfo fontInfo) {
+        void copyFrom(FontInfo fontInfo) {
             CTTextFont tf = getXmlObject(true);
             setTypeface(fontInfo.getTypeface());
             setCharset(fontInfo.getCharset());

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextShape.java?rev=1829453&r1=1829452&r2=1829453&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextShape.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextShape.java Wed Apr 18 15:02:02 2018
@@ -590,13 +590,7 @@ public abstract class XSLFTextShape exte
     }
 
     public Placeholder getTextType(){
-        CTPlaceholder ph = getCTPlaceholder();
-        if (ph == null) {
-            return null;
-        }
-
-        int val = ph.getType().intValue();
-        return Placeholder.lookupOoxml(val);
+        return getPlaceholder();
     }
 
     @Override

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXMLSlideShow.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXMLSlideShow.java?rev=1829453&r1=1829452&r2=1829453&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXMLSlideShow.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXMLSlideShow.java Wed Apr 18 15:02:02 2018
@@ -19,6 +19,7 @@ package org.apache.poi.xslf.usermodel;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
@@ -51,7 +52,7 @@ public class TestXMLSlideShow extends Ba
    }
    
    @After
-   public void tearDown() throws IOException {
+   public void tearDown() {
        pack.revert();
    }
 
@@ -149,7 +150,7 @@ public class TestXMLSlideShow extends Ba
       assertEquals(null, xml.getCommentAuthors());
       
       for (XSLFSlide slide : xml.getSlides()) {
-         assertEquals(null, slide.getComments());
+         assertTrue(slide.getComments().isEmpty());
       }
       
       // Try another with comments
@@ -166,17 +167,18 @@ public class TestXMLSlideShow extends Ba
          i++;
          
          if(i == 0) {
-            assertNotNull(slide.getComments());
-            assertEquals(1, slide.getComments().getNumberOfComments());
-            assertEquals("testdoc", slide.getComments().getCommentAt(0).getText());
-            assertEquals(0, slide.getComments().getCommentAt(0).getAuthorId());
+            assertNotNull(slide.getCommentsPart());
+            assertEquals(1, slide.getCommentsPart().getNumberOfComments());
+            assertEquals("testdoc", slide.getCommentsPart().getCommentAt(0).getText());
+            assertEquals(0, slide.getCommentsPart().getCommentAt(0).getAuthorId());
          } else if (i == 1) {
             assertNotNull(slide.getComments());
-            assertEquals(1, slide.getComments().getNumberOfComments());
-            assertEquals("test phrase", slide.getComments().getCommentAt(0).getText());
-            assertEquals(0, slide.getComments().getCommentAt(0).getAuthorId());
+            assertEquals(1, slide.getCommentsPart().getNumberOfComments());
+            assertEquals("test phrase", slide.getCommentsPart().getCommentAt(0).getText());
+            assertEquals(0, slide.getCommentsPart().getCommentAt(0).getAuthorId());
          } else {
-            assertEquals(null, slide.getComments());
+            assertNull(slide.getCommentsPart());
+            assertTrue(slide.getComments().isEmpty());
          }
       }
       
@@ -188,7 +190,7 @@ public class TestXMLSlideShow extends Ba
        return reopen((XMLSlideShow)show);
    }
 
-   public static XMLSlideShow reopen(XMLSlideShow show) {
+   private static XMLSlideShow reopen(XMLSlideShow show) {
        try {
            BufAccessBAOS bos = new BufAccessBAOS();
            show.write(bos);
@@ -200,7 +202,7 @@ public class TestXMLSlideShow extends Ba
    }
 
    private static class BufAccessBAOS extends ByteArrayOutputStream {
-       public byte[] getBuf() {
+       byte[] getBuf() {
            return buf;
        }
    }

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextRun.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextRun.java?rev=1829453&r1=1829452&r2=1829453&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextRun.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextRun.java Wed Apr 18 15:02:02 2018
@@ -28,6 +28,7 @@ import static org.mockito.Mockito.when;
 import java.awt.Color;
 import java.io.IOException;
 
+import org.apache.poi.sl.draw.DrawTextParagraph;
 import org.junit.Test;
 
 /**
@@ -65,17 +66,17 @@ public class TestXSLFTextRun {
         r.setFontSize(13.0);
         assertEquals(13.0, r.getFontSize(), 0);
 
-        assertEquals(false, r.isSuperscript());
+        assertFalse(r.isSuperscript());
         r.setSuperscript(true);
-        assertEquals(true, r.isSuperscript());
+        assertTrue(r.isSuperscript());
         r.setSuperscript(false);
-        assertEquals(false, r.isSuperscript());
+        assertFalse(r.isSuperscript());
 
-        assertEquals(false, r.isSubscript());
+        assertFalse(r.isSubscript());
         r.setSubscript(true);
-        assertEquals(true, r.isSubscript());
+        assertTrue(r.isSubscript());
         r.setSubscript(false);
-        assertEquals(false, r.isSubscript());
+        assertFalse(r.isSubscript());
         
         ppt.close();
     }
@@ -94,8 +95,11 @@ public class TestXSLFTextRun {
         try (XMLSlideShow ppt = new XMLSlideShow()) {
             XSLFSlide slide = ppt.createSlide();
             XSLFTextShape sh = slide.createAutoShape();
-            XSLFTextRun r = sh.addNewTextParagraph().addNewTextRun();
-            assertEquals(unicodeSurrogates, r.getRenderableText(unicodeSurrogates));
+            XSLFTextParagraph p = sh.addNewTextParagraph();
+            XSLFTextRun r = p.addNewTextRun();
+            r.setText(unicodeSurrogates);
+
+            assertEquals(unicodeSurrogates, new DrawTextParagraph(p).getRenderableText(r));
         }
     }
 

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=1829453&r1=1829452&r2=1829453&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 Apr 18 15:02:02 2018
@@ -83,7 +83,7 @@ public class TestXSLFTextShape {
         assertEquals("Title Slide",layout.getName());
 
         XSLFTextShape shape1 = (XSLFTextShape)shapes.get(0);
-        CTPlaceholder ph1 = shape1.getCTPlaceholder();
+        CTPlaceholder ph1 = shape1.getPlaceholderDetails().getCTPlaceholder(false);
         assertEquals(STPlaceholderType.CTR_TITLE, ph1.getType());
         // anchor is not defined in the shape
         assertNull(getSpPr(shape1).getXfrm());
@@ -113,7 +113,7 @@ public class TestXSLFTextShape {
         assertTrue(sameColor(Color.black, r1.getFontColor()));
 
         XSLFTextShape shape2 = (XSLFTextShape)shapes.get(1);
-        CTPlaceholder ph2 = shape2.getCTPlaceholder();
+        CTPlaceholder ph2 = shape2.getPlaceholderDetails().getCTPlaceholder(false);
         assertEquals(STPlaceholderType.SUB_TITLE, ph2.getType());
         // anchor is not defined in the shape
         assertNull(getSpPr(shape2).getXfrm());
@@ -149,7 +149,7 @@ public class TestXSLFTextShape {
         assertEquals("Title and Content",layout.getName());
 
         XSLFTextShape shape1 = (XSLFTextShape)shapes.get(0);
-        CTPlaceholder ph1 = shape1.getCTPlaceholder();
+        CTPlaceholder ph1 = shape1.getPlaceholderDetails().getCTPlaceholder(false);
         assertEquals(STPlaceholderType.TITLE, ph1.getType());
         // anchor is not defined in the shape
         assertNull(getSpPr(shape1).getXfrm());
@@ -182,7 +182,7 @@ public class TestXSLFTextShape {
         assertTrue(sameColor(Color.black, r1.getFontColor()));
 
         XSLFTextShape shape2 = (XSLFTextShape)shapes.get(1);
-        CTPlaceholder ph2 = shape2.getCTPlaceholder();
+        CTPlaceholder ph2 = shape2.getPlaceholderDetails().getCTPlaceholder(false);
         assertFalse(ph2.isSetType()); // <p:ph idx="1"/>
         assertTrue(ph2.isSetIdx());
         assertEquals(1, ph2.getIdx());
@@ -262,7 +262,7 @@ public class TestXSLFTextShape {
         assertEquals("Section Header",layout.getName());
 
         XSLFTextShape shape1 = (XSLFTextShape)shapes.get(0);
-        CTPlaceholder ph1 = shape1.getCTPlaceholder();
+        CTPlaceholder ph1 = shape1.getPlaceholderDetails().getCTPlaceholder(false);
         assertEquals(STPlaceholderType.TITLE, ph1.getType());
         // anchor is not defined in the shape
         assertNull(getSpPr(shape1).getXfrm());
@@ -296,7 +296,7 @@ public class TestXSLFTextShape {
         assertFalse(r1.isUnderlined());
 
         XSLFTextShape shape2 = (XSLFTextShape)shapes.get(1);
-        CTPlaceholder ph2 = shape2.getCTPlaceholder();
+        CTPlaceholder ph2 = shape2.getPlaceholderDetails().getCTPlaceholder(false);
         assertEquals(STPlaceholderType.BODY, ph2.getType());
         // anchor is not defined in the shape
         assertNull(getSpPr(shape2).getXfrm());
@@ -333,7 +333,7 @@ public class TestXSLFTextShape {
         assertEquals("Two Content",layout.getName());
 
         XSLFTextShape shape1 = (XSLFTextShape)shapes.get(0);
-        CTPlaceholder ph1 = shape1.getCTPlaceholder();
+        CTPlaceholder ph1 = shape1.getPlaceholderDetails().getCTPlaceholder(false);
         assertEquals(STPlaceholderType.TITLE, ph1.getType());
         // anchor is not defined in the shape
         assertNull(getSpPr(shape1).getXfrm());
@@ -367,7 +367,7 @@ public class TestXSLFTextShape {
         assertTrue(sameColor(Color.black, r1.getFontColor()));
 
         XSLFTextShape shape2 = (XSLFTextShape)shapes.get(1);
-        CTPlaceholder ph2 = shape2.getCTPlaceholder();
+        CTPlaceholder ph2 = shape2.getPlaceholderDetails().getCTPlaceholder(false);
         assertFalse(ph2.isSetType());
         assertTrue(ph2.isSetIdx());
         assertEquals(1, ph2.getIdx());  //<p:ph sz="half" idx="1"/>
@@ -448,7 +448,7 @@ public class TestXSLFTextShape {
         assertEquals("Blank",layout.getName());
 
         XSLFTextShape shape1 = (XSLFTextShape)shapes.get(0);
-        CTPlaceholder ph1 = shape1.getCTPlaceholder();
+        CTPlaceholder ph1 = shape1.getPlaceholderDetails().getCTPlaceholder(false);
         assertEquals(STPlaceholderType.TITLE, ph1.getType());
         // anchor is not defined in the shape
         assertNull(getSpPr(shape1).getXfrm());
@@ -516,7 +516,7 @@ public class TestXSLFTextShape {
         assertEquals("Content with Caption",layout.getName());
 
         XSLFTextShape shape1 = (XSLFTextShape)shapes.get(0);
-        CTPlaceholder ph1 = shape1.getCTPlaceholder();
+        CTPlaceholder ph1 = shape1.getPlaceholderDetails().getCTPlaceholder(false);
         assertEquals(STPlaceholderType.TITLE, ph1.getType());
         // anchor is not defined in the shape
         assertNull(getSpPr(shape1).getXfrm());
@@ -549,7 +549,7 @@ public class TestXSLFTextShape {
         assertTrue(r1.isBold());
 
         XSLFTextShape shape2 = (XSLFTextShape)shapes.get(1);
-        CTPlaceholder ph2 = shape2.getCTPlaceholder();
+        CTPlaceholder ph2 = shape2.getPlaceholderDetails().getCTPlaceholder(false);
         assertFalse(ph2.isSetType());
         assertTrue(ph2.isSetIdx());
         assertEquals(1, ph2.getIdx());

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/extractor/PowerPointExtractor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/extractor/PowerPointExtractor.java?rev=1829453&r1=1829452&r2=1829453&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/extractor/PowerPointExtractor.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/extractor/PowerPointExtractor.java Wed Apr 18 15:02:02 2018
@@ -20,47 +20,36 @@ package org.apache.poi.hslf.extractor;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.HashSet;
 import java.util.List;
-import java.util.Set;
 
 import org.apache.poi.POIOLE2TextExtractor;
-import org.apache.poi.hslf.model.Comment;
-import org.apache.poi.hslf.model.HSLFMetroShape;
-import org.apache.poi.hslf.model.HeadersFooters;
-import org.apache.poi.hslf.usermodel.HSLFMasterSheet;
-import org.apache.poi.hslf.usermodel.HSLFNotes;
+import org.apache.poi.hslf.usermodel.HSLFObjectShape;
 import org.apache.poi.hslf.usermodel.HSLFShape;
-import org.apache.poi.hslf.usermodel.HSLFSlide;
-import org.apache.poi.hslf.usermodel.HSLFSlideMaster;
 import org.apache.poi.hslf.usermodel.HSLFSlideShow;
 import org.apache.poi.hslf.usermodel.HSLFSlideShowImpl;
-import org.apache.poi.hslf.usermodel.HSLFTable;
-import org.apache.poi.hslf.usermodel.HSLFTableCell;
 import org.apache.poi.hslf.usermodel.HSLFTextParagraph;
-import org.apache.poi.hslf.usermodel.HSLFTextShape;
-import org.apache.poi.hslf.usermodel.HSLFObjectShape;
+import org.apache.poi.hssf.record.crypto.Biff8EncryptionKey;
 import org.apache.poi.poifs.filesystem.DirectoryNode;
 import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
+import org.apache.poi.sl.extractor.SlideShowExtractor;
+import org.apache.poi.sl.usermodel.SlideShowFactory;
 
 /**
  * This class can be used to extract text from a PowerPoint file. Can optionally
  * also get the notes from one.
+ *
+ * @deprecated in POI 4.0.0, use {@link SlideShowExtractor} instead
  */
+@SuppressWarnings("WeakerAccess")
+@Deprecated
 public final class PowerPointExtractor extends POIOLE2TextExtractor {
-   private static final POILogger LOG = POILogFactory.getLogger(PowerPointExtractor.class);
-    
-   private final HSLFSlideShow _show;
-   private final List<HSLFSlide> _slides;
-
-   private boolean _slidesByDefault = true;
-   private boolean _notesByDefault;
-   private boolean _commentsByDefault;
-   private boolean _masterByDefault;
+   	private final SlideShowExtractor<HSLFShape,HSLFTextParagraph> delegate;
+
+	private boolean slidesByDefault = true;
+	private boolean notesByDefault;
+	private boolean commentsByDefault;
+	private boolean masterByDefault;
 
 	/**
 	 * Basic extractor. Returns all the text, and optionally all the notes
@@ -92,13 +81,19 @@ public final class PowerPointExtractor e
 		ppe.close();
 	}
 
+	public PowerPointExtractor(final HSLFSlideShow slideShow) {
+		super(slideShow.getSlideShowImpl());
+		setFilesystem(slideShow);
+		delegate = new SlideShowExtractor<>(slideShow);
+	}
+
 	/**
 	 * Creates a PowerPointExtractor, from a file
 	 *
 	 * @param fileName The name of the file to extract from
 	 */
 	public PowerPointExtractor(String fileName) throws IOException {
-		this(new NPOIFSFileSystem(new File(fileName)));
+		this((HSLFSlideShow)SlideShowFactory.create(new File(fileName), Biff8EncryptionKey.getCurrentUserPassword(), true));
 	}
 
 	/**
@@ -107,7 +102,7 @@ public final class PowerPointExtractor e
 	 * @param iStream The input stream containing the PowerPoint document
 	 */
 	public PowerPointExtractor(InputStream iStream) throws IOException {
-		this(new POIFSFileSystem(iStream));
+		this((HSLFSlideShow)SlideShowFactory.create(iStream, Biff8EncryptionKey.getCurrentUserPassword()));
 	}
 
 	/**
@@ -116,7 +111,7 @@ public final class PowerPointExtractor e
 	 * @param fs the POIFSFileSystem containing the PowerPoint document
 	 */
 	public PowerPointExtractor(POIFSFileSystem fs) throws IOException {
-		this(fs.getRoot());
+		this((HSLFSlideShow)SlideShowFactory.create(fs, Biff8EncryptionKey.getCurrentUserPassword()));
 	}
 
    /**
@@ -125,8 +120,7 @@ public final class PowerPointExtractor e
     * @param fs the NPOIFSFileSystem containing the PowerPoint document
     */
    public PowerPointExtractor(NPOIFSFileSystem fs) throws IOException {
-      this(fs.getRoot());
-      setFilesystem(fs);
+	   this((HSLFSlideShow)SlideShowFactory.create(fs, Biff8EncryptionKey.getCurrentUserPassword()));
    }
 
    /**
@@ -136,7 +130,7 @@ public final class PowerPointExtractor e
     * @param dir the POIFS Directory containing the PowerPoint document
     */
    public PowerPointExtractor(DirectoryNode dir) throws IOException {
-      this(new HSLFSlideShowImpl(dir));
+      this(new HSLFSlideShow(dir));
    }
 
 	/**
@@ -145,37 +139,39 @@ public final class PowerPointExtractor e
 	 * @param ss the HSLFSlideShow to extract text from
 	 */
 	public PowerPointExtractor(HSLFSlideShowImpl ss) {
-		super(ss);
-		_show = new HSLFSlideShow(ss);
-		_slides = _show.getSlides();
+		this(new HSLFSlideShow(ss));
 	}
 
 	/**
 	 * Should a call to getText() return slide text? Default is yes
 	 */
-	public void setSlidesByDefault(boolean slidesByDefault) {
-		this._slidesByDefault = slidesByDefault;
+	public void setSlidesByDefault(final boolean slidesByDefault) {
+		this.slidesByDefault = slidesByDefault;
+		delegate.setSlidesByDefault(slidesByDefault);
 	}
 
 	/**
 	 * Should a call to getText() return notes text? Default is no
 	 */
-	public void setNotesByDefault(boolean notesByDefault) {
-		this._notesByDefault = notesByDefault;
+	public void setNotesByDefault(final boolean notesByDefault) {
+		this.notesByDefault = notesByDefault;
+		delegate.setNotesByDefault(notesByDefault);
 	}
 
 	/**
 	 * Should a call to getText() return comments text? Default is no
 	 */
-	public void setCommentsByDefault(boolean commentsByDefault) {
-		this._commentsByDefault = commentsByDefault;
+	public void setCommentsByDefault(final boolean commentsByDefault) {
+		this.commentsByDefault = commentsByDefault;
+		delegate.setCommentsByDefault(commentsByDefault);
 	}
 
     /**
      * Should a call to getText() return text from master? Default is no
      */
-    public void setMasterByDefault(boolean masterByDefault) {
-        this._masterByDefault = masterByDefault;
+    public void setMasterByDefault(final boolean masterByDefault) {
+    	this.masterByDefault = masterByDefault;
+    	delegate.setMasterByDefault(masterByDefault);
     }
 
 	/**
@@ -184,28 +180,7 @@ public final class PowerPointExtractor e
 	 */
 	@Override
     public String getText() {
-		return getText(_slidesByDefault, _notesByDefault, _commentsByDefault, _masterByDefault);
-	}
-
-	/**
-	 * Fetches all the notes text from the slideshow, but not the slide text
-	 */
-	public String getNotes() {
-		return getText(false, true);
-	}
-
-	public List<HSLFObjectShape> getOLEShapes() {
-		List<HSLFObjectShape> list = new ArrayList<>();
-
-		for (HSLFSlide slide : _slides) {
-			for (HSLFShape shape : slide.getShapes()) {
-				if (shape instanceof HSLFObjectShape) {
-					list.add((HSLFObjectShape) shape);
-				}
-			}
-		}
-
-		return list;
+		return delegate.getText();
 	}
 
 	/**
@@ -217,159 +192,33 @@ public final class PowerPointExtractor e
 	 * @param getNoteText fetch note text
 	 */
 	public String getText(boolean getSlideText, boolean getNoteText) {
-		return getText(getSlideText, getNoteText, _commentsByDefault, _masterByDefault);
+		return getText(getSlideText,getNoteText,commentsByDefault,masterByDefault);
 	}
 
 	public String getText(boolean getSlideText, boolean getNoteText, boolean getCommentText, boolean getMasterText) {
-		StringBuffer ret = new StringBuffer();
-
-		if (getSlideText) {
-            if (getMasterText) {
-                for (HSLFSlideMaster master : _show.getSlideMasters()) {
-                    for(HSLFShape sh : master.getShapes()){
-                        if(sh instanceof HSLFTextShape){
-                            HSLFTextShape hsh = (HSLFTextShape)sh;
-                            final String text = hsh.getText();
-                            if (text == null || text.isEmpty() || "*".equals(text)) {
-                                continue;
-                            }
-                            
-                            if (HSLFMasterSheet.isPlaceholder(sh)) {
-                                // check for metro shape of complex placeholder
-                                boolean isMetro = new HSLFMetroShape<HSLFShape>(sh).hasMetroBlob();
-                                
-                                if (!isMetro) {
-                                    // don't bother about boiler plate text on master sheets
-                                    LOG.log(POILogger.INFO, "Ignoring boiler plate (placeholder) text on slide master:", text);
-                                    continue;
-                                }
-                            }
-                            
-                            ret.append(text);
-                            if (!text.endsWith("\n")) {
-                                ret.append("\n");
-                            }
-                        }
-                    }
-                }
-            }
-
-            for (HSLFSlide slide : _slides) {
-                String headerText = "";
-                String footerText = "";
-                HeadersFooters hf = slide.getHeadersFooters();
-                if (hf != null) {
-                    if (hf.isHeaderVisible()) {
-                        headerText = safeLine(hf.getHeaderText());
-                    }
-                    if (hf.isFooterVisible()) {
-                        footerText = safeLine(hf.getFooterText());
-                    }
-                }
-                
-                // Slide header, if set
-                ret.append(headerText);
-
-                // Slide text
-                textRunsToText(ret, slide.getTextParagraphs());
-
-                // Table text
-                for (HSLFShape shape : slide.getShapes()){
-                    if (shape instanceof HSLFTable){
-                        extractTableText(ret, (HSLFTable)shape);
-                    }
-                }
-                // Slide footer, if set
-                ret.append(footerText);
-
-				// Comments, if requested and present
-				if (getCommentText) {
-					for (Comment comment : slide.getComments()) {
-						ret.append(comment.getAuthor() + " - " + comment.getText() + "\n");
-					}
-				}
-			}
-			if (getNoteText) {
-				ret.append('\n');
-			}
+		delegate.setSlidesByDefault(getSlideText);
+		delegate.setNotesByDefault(getNoteText);
+		delegate.setCommentsByDefault(getCommentText);
+		delegate.setMasterByDefault(getMasterText);
+		try {
+			return delegate.getText();
+		} finally {
+			delegate.setSlidesByDefault(slidesByDefault);
+			delegate.setNotesByDefault(notesByDefault);
+			delegate.setCommentsByDefault(commentsByDefault);
+			delegate.setMasterByDefault(masterByDefault);
 		}
+	}
 
-		if (getNoteText) {
-			// Not currently using _notes, as that can have the notes of
-			// master sheets in. Grab Slide list, then work from there,
-			// but ensure no duplicates
-			Set<Integer> seenNotes = new HashSet<>();
-            String headerText = "";
-            String footerText = "";
-			HeadersFooters hf = _show.getNotesHeadersFooters();
-			if (hf != null) {
-			    if (hf.isHeaderVisible()) {
-			        headerText = safeLine(hf.getHeaderText());
-			    }
-			    if (hf.isFooterVisible()) {
-                    footerText = safeLine(hf.getFooterText());
-			    }
-			}
-			
-
-			for (HSLFSlide slide : _slides) {
-				HSLFNotes notes = slide.getNotes();
-				if (notes == null) {
-					continue;
-				}
-				Integer id = Integer.valueOf(notes._getSheetNumber());
-				if (seenNotes.contains(id)) {
-					continue;
-				}
-				seenNotes.add(id);
-
-				// Repeat the Notes header, if set
-				ret.append(headerText);
-
-				// Notes text
-				textRunsToText(ret, notes.getTextParagraphs());
-
-				// Repeat the notes footer, if set
-				ret.append(footerText);
-			}
-		}
+	/**
+	 * Fetches all the notes text from the slideshow, but not the slide text
+	 */
+	public String getNotes() {
+		return getText(false, true, false, false);
+	}
 
-		return ret.toString();
+	@SuppressWarnings("unchecked")
+	public List<HSLFObjectShape> getOLEShapes() {
+		return (List<HSLFObjectShape>)delegate.getOLEShapes();
 	}
-	
-	private static String safeLine(String text) {
-	    return (text == null) ? "" : (text+'\n');
-	}
-
-    private void extractTableText(StringBuffer ret, HSLFTable table) {
-        final int nrows = table.getNumberOfRows();
-        final int ncols = table.getNumberOfColumns();
-        for (int row = 0; row < nrows; row++){
-            for (int col = 0; col < ncols; col++){
-                HSLFTableCell cell = table.getCell(row, col);
-                //defensive null checks; don't know if they're necessary
-                if (cell != null){
-                    String txt = cell.getText();
-                    txt = (txt == null) ? "" : txt;
-                    ret.append(txt);
-                    if (col < ncols-1){
-                        ret.append('\t');
-                    }
-                }
-            }
-            ret.append('\n');
-        }
-    }
-    private void textRunsToText(StringBuffer ret, List<List<HSLFTextParagraph>> paragraphs) {
-        if (paragraphs==null) {
-            return;
-        }
-
-        for (List<HSLFTextParagraph> lp : paragraphs) {
-            ret.append(HSLFTextParagraph.getText(lp));
-            if (ret.length() > 0 && ret.charAt(ret.length()-1) != '\n') {
-                ret.append('\n');
-            }
-        }
-    }
 }

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=1829453&r1=1829452&r2=1829453&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 Apr 18 15:02:02 2018
@@ -275,4 +275,11 @@ public final class HeadersFooters {
     private void setFlag(int type, boolean flag) {
         _container.getHeadersFootersAtom().setFlag(type, flag);
     }
+
+    /**
+     * @return true, if this is a ppt 2007 document and header/footer are stored as placeholder shapes
+     */
+    public boolean isPpt2007() {
+        return _ppt2007;
+    }
 }

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/DocumentEncryptionAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/DocumentEncryptionAtom.java?rev=1829453&r1=1829452&r2=1829453&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/DocumentEncryptionAtom.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/DocumentEncryptionAtom.java Wed Apr 18 15:02:02 2018
@@ -22,6 +22,7 @@ import java.io.IOException;
 import java.io.OutputStream;
 import java.util.Map;
 
+import org.apache.poi.EncryptedDocumentException;
 import org.apache.poi.poifs.crypt.CipherAlgorithm;
 import org.apache.poi.poifs.crypt.EncryptionInfo;
 import org.apache.poi.poifs.crypt.EncryptionMode;
@@ -46,15 +47,17 @@ public final class DocumentEncryptionAto
 	/**
 	 * For the Document Encryption Atom
 	 */
-	protected DocumentEncryptionAtom(byte[] source, int start, int len) throws IOException {
+	protected DocumentEncryptionAtom(byte[] source, int start, int len) {
 		// Get the header
 		_header = new byte[8];
 		System.arraycopy(source,start,_header,0,8);
 
 		ByteArrayInputStream bis = new ByteArrayInputStream(source, start+8, len-8);
-		LittleEndianInputStream leis = new LittleEndianInputStream(bis);
-		ei = new EncryptionInfo(leis, EncryptionMode.cryptoAPI);
-		leis.close();
+		try (LittleEndianInputStream leis = new LittleEndianInputStream(bis)) {
+			ei = new EncryptionInfo(leis, EncryptionMode.cryptoAPI);
+		} catch (IOException e) {
+			throw new EncryptedDocumentException(e);
+		}
 	}
 
 	public DocumentEncryptionAtom() {

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/HSLFEscherClientDataRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/HSLFEscherClientDataRecord.java?rev=1829453&r1=1829452&r2=1829453&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/HSLFEscherClientDataRecord.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/HSLFEscherClientDataRecord.java Wed Apr 18 15:02:02 2018
@@ -20,7 +20,6 @@ package org.apache.poi.hslf.record;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 
 import org.apache.poi.ddf.EscherClientDataRecord;
@@ -49,12 +48,7 @@ public class HSLFEscherClientDataRecord
     }
     
     public void removeChild(Class<? extends Record> childClass) {
-        Iterator<Record> iter = _childRecords.iterator();
-        while (iter.hasNext()) {
-            if (childClass.isInstance(iter.next())) {
-                iter.remove();
-            }
-        }
+        _childRecords.removeIf(childClass::isInstance);
     }
     
     public void addChild(Record childRecord) {
@@ -109,8 +103,10 @@ public class HSLFEscherClientDataRecord
         _childRecords.clear();
         int offset = 0;
         while (offset < remainingData.length) {
-            Record r = Record.buildRecordAtOffset(remainingData, offset);
-            _childRecords.add(r);
+            final Record r = Record.buildRecordAtOffset(remainingData, offset);
+            if (r != null) {
+                _childRecords.add(r);
+            }
             long rlen = LittleEndian.getUInt(remainingData,offset+4);
             offset += 8 + rlen;
         }

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/Record.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/Record.java?rev=1829453&r1=1829452&r2=1829453&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/Record.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/Record.java Wed Apr 18 15:02:02 2018
@@ -24,6 +24,7 @@ import java.util.List;
 
 import org.apache.poi.hslf.exceptions.CorruptPowerPointFileException;
 import org.apache.poi.hslf.exceptions.HSLFException;
+import org.apache.poi.hslf.record.RecordTypes.RecordConstructor;
 import org.apache.poi.util.LittleEndian;
 import org.apache.poi.util.POILogFactory;
 import org.apache.poi.util.POILogger;
@@ -122,15 +123,13 @@ public abstract class Record
 
 			// Abort if first record is of type 0000 and length FFFF,
 			//  as that's a sign of a screwed up record
-			if(pos == 0 && type == 0l && rleni == 0xffff) {
+			if(pos == 0 && type == 0L && rleni == 0xffff) {
 				throw new CorruptPowerPointFileException("Corrupt document - starts with record of type 0000 and length 0xFFFF");
 			}
 
 			Record r = createRecordForType(type,b,pos,8+rleni);
 			if(r != null) {
 				children.add(r);
-			} else {
-				// Record was horribly corrupt
 			}
 			pos += 8;
 			pos += rleni;
@@ -150,43 +149,32 @@ public abstract class Record
 	 *  passing in corrected lengths
 	 */
 	public static Record createRecordForType(long type, byte[] b, int start, int len) {
-		Record toReturn = null;
-
-		// Handle case of a corrupt last record, whose claimed length
-		//  would take us passed the end of the file
-		if(start + len > b.length) {
-			logger.log(POILogger.WARN, "Warning: Skipping record of type " + type + " at position " + start + " which claims to be longer than the file! (" + len + " vs " + (b.length-start) + ")");
-			return null;
-		}
-
 		// We use the RecordTypes class to provide us with the right
 		//  class to use for a given type
 		// A spot of reflection gets us the (byte[],int,int) constructor
 		// From there, we instanciate the class
 		// Any special record handling occurs once we have the class
-		Class<? extends Record> c = null;
+		RecordConstructor c = RecordTypes.forTypeID((short)type).recordConstructor;
+		if (c == null) {
+			// How odd. RecordTypes normally substitutes in
+			//  a default handler class if it has heard of the record
+			//  type but there's no support for it. Explicitly request
+			//  that now
+			c = RecordTypes.UnknownRecordPlaceholder.recordConstructor;
+		}
+
+		final Record toReturn;
 		try {
-			c = RecordTypes.forTypeID((short)type).handlingClass;
-			if(c == null) {
-				// How odd. RecordTypes normally substitutes in
-				//  a default handler class if it has heard of the record
-				//  type but there's no support for it. Explicitly request
-				//  that now
-				c = RecordTypes.UnknownRecordPlaceholder.handlingClass;
+			toReturn = c.apply(b, start, len);
+		} catch(RuntimeException e) {
+			// Handle case of a corrupt last record, whose claimed length
+			//  would take us passed the end of the file
+			if(start + len > b.length ) {
+				logger.log(POILogger.WARN, "Warning: Skipping record of type " + type + " at position " + start + " which claims to be longer than the file! (" + len + " vs " + (b.length-start) + ")");
+				return null;
 			}
 
-			// Grab the right constructor
-			java.lang.reflect.Constructor<? extends Record> con = c.getDeclaredConstructor(new Class[] { byte[].class, Integer.TYPE, Integer.TYPE });
-			// Instantiate
-			toReturn = con.newInstance(new Object[] { b, start, len });
-		} catch(InstantiationException ie) {
-			throw new HSLFException("Couldn't instantiate the class for type with id " + type + " on class " + c + " : " + ie, ie);
-		} catch(java.lang.reflect.InvocationTargetException ite) {
-			throw new HSLFException("Couldn't instantiate the class for type with id " + type + " on class " + c + " : " + ite + "\nCause was : " + ite.getCause(), ite);
-		} catch(IllegalAccessException iae) {
-			throw new HSLFException("Couldn't access the constructor for type with id " + type + " on class " + c + " : " + iae, iae);
-		} catch(NoSuchMethodException nsme) {
-			throw new HSLFException("Couldn't access the constructor for type with id " + type + " on class " + c + " : " + nsme, nsme);
+			throw new HSLFException("Couldn't instantiate the class for type with id " + type + " on class " + c + " : " + e, e);
 		}
 
 		// Handling for special kinds of records follow

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/RecordTypes.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/RecordTypes.java?rev=1829453&r1=1829452&r2=1829453&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/RecordTypes.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/RecordTypes.java Wed Apr 18 15:02:02 2018
@@ -29,141 +29,141 @@ import java.util.Map;
  */
 public enum RecordTypes {
     Unknown(0,null),
-    UnknownRecordPlaceholder(-1, UnknownRecordPlaceholder.class),
-    Document(1000,Document.class),
-    DocumentAtom(1001,DocumentAtom.class),
+    UnknownRecordPlaceholder(-1, UnknownRecordPlaceholder::new),
+    Document(1000,Document::new),
+    DocumentAtom(1001,DocumentAtom::new),
     EndDocument(1002,null),
-    Slide(1006,Slide.class),
-    SlideAtom(1007,SlideAtom.class),
-    Notes(1008,Notes.class),
-    NotesAtom(1009,NotesAtom.class),
-    Environment(1010,Environment.class),
-    SlidePersistAtom(1011,SlidePersistAtom.class),
+    Slide(1006,Slide::new),
+    SlideAtom(1007,SlideAtom::new),
+    Notes(1008,Notes::new),
+    NotesAtom(1009,NotesAtom::new),
+    Environment(1010,Environment::new),
+    SlidePersistAtom(1011,SlidePersistAtom::new),
     SSlideLayoutAtom(1015,null),
-    MainMaster(1016,MainMaster.class),
-    SSSlideInfoAtom(1017,SSSlideInfoAtom.class),
+    MainMaster(1016,MainMaster::new),
+    SSSlideInfoAtom(1017,SSSlideInfoAtom::new),
     SlideViewInfo(1018,null),
     GuideAtom(1019,null),
     ViewInfo(1020,null),
     ViewInfoAtom(1021,null),
     SlideViewInfoAtom(1022,null),
-    VBAInfo(1023,VBAInfoContainer.class),
-    VBAInfoAtom(1024,VBAInfoAtom.class),
+    VBAInfo(1023,VBAInfoContainer::new),
+    VBAInfoAtom(1024,VBAInfoAtom::new),
     SSDocInfoAtom(1025,null),
     Summary(1026,null),
     DocRoutingSlip(1030,null),
     OutlineViewInfo(1031,null),
     SorterViewInfo(1032,null),
-    ExObjList(1033,ExObjList.class),
-    ExObjListAtom(1034,ExObjListAtom.class),
-    PPDrawingGroup(1035,PPDrawingGroup.class),
-    PPDrawing(1036,PPDrawing.class),
+    ExObjList(1033,ExObjList::new),
+    ExObjListAtom(1034,ExObjListAtom::new),
+    PPDrawingGroup(1035,PPDrawingGroup::new),
+    PPDrawing(1036,PPDrawing::new),
     NamedShows(1040,null),
     NamedShow(1041,null),
     NamedShowSlides(1042,null),
     SheetProperties(1044,null),
     RoundTripCustomTableStyles12Atom(1064,null),
-    List(2000,DocInfoListContainer.class),
-    FontCollection(2005,FontCollection.class),
+    List(2000,DocInfoListContainer::new),
+    FontCollection(2005,FontCollection::new),
     BookmarkCollection(2019,null),
-    SoundCollection(2020,SoundCollection.class),
+    SoundCollection(2020,SoundCollection::new),
     SoundCollAtom(2021,null),
-    Sound(2022,Sound.class),
-    SoundData(2023,SoundData.class),
+    Sound(2022,Sound::new),
+    SoundData(2023,SoundData::new),
     BookmarkSeedAtom(2025,null),
-    ColorSchemeAtom(2032,ColorSchemeAtom.class),
-    ExObjRefAtom(3009,ExObjRefAtom.class),
-    OEPlaceholderAtom(3011,OEPlaceholderAtom.class),
+    ColorSchemeAtom(2032,ColorSchemeAtom::new),
+    ExObjRefAtom(3009,ExObjRefAtom::new),
+    OEPlaceholderAtom(3011,OEPlaceholderAtom::new),
     GPopublicintAtom(3024,null),
     GRatioAtom(3031,null),
-    OutlineTextRefAtom(3998,OutlineTextRefAtom.class),
-    TextHeaderAtom(3999,TextHeaderAtom.class),
-    TextCharsAtom(4000,TextCharsAtom.class),
-    StyleTextPropAtom(4001, StyleTextPropAtom.class),//0x0fa1 RT_StyleTextPropAtom
-    MasterTextPropAtom(4002, MasterTextPropAtom.class),
-    TxMasterStyleAtom(4003,TxMasterStyleAtom.class),
+    OutlineTextRefAtom(3998,OutlineTextRefAtom::new),
+    TextHeaderAtom(3999,TextHeaderAtom::new),
+    TextCharsAtom(4000,TextCharsAtom::new),
+    StyleTextPropAtom(4001, StyleTextPropAtom::new),//0x0fa1 RT_StyleTextPropAtom
+    MasterTextPropAtom(4002, MasterTextPropAtom::new),
+    TxMasterStyleAtom(4003,TxMasterStyleAtom::new),
     TxCFStyleAtom(4004,null),
     TxPFStyleAtom(4005,null),
-    TextRulerAtom(4006,TextRulerAtom.class),
+    TextRulerAtom(4006,TextRulerAtom::new),
     TextBookmarkAtom(4007,null),
-    TextBytesAtom(4008,TextBytesAtom.class),
+    TextBytesAtom(4008,TextBytesAtom::new),
     TxSIStyleAtom(4009,null),
-    TextSpecInfoAtom(4010, TextSpecInfoAtom.class),
+    TextSpecInfoAtom(4010, TextSpecInfoAtom::new),
     DefaultRulerAtom(4011,null),
-    StyleTextProp9Atom(4012, StyleTextProp9Atom.class), //0x0FAC RT_StyleTextProp9Atom
-    FontEntityAtom(4023,FontEntityAtom.class),
+    StyleTextProp9Atom(4012, StyleTextProp9Atom::new), //0x0FAC RT_StyleTextProp9Atom
+    FontEntityAtom(4023,FontEntityAtom::new),
     FontEmbeddedData(4024,null),
-    CString(4026,CString.class),
+    CString(4026,CString::new),
     MetaFile(4033,null),
-    ExOleObjAtom(4035,ExOleObjAtom.class),
+    ExOleObjAtom(4035,ExOleObjAtom::new),
     SrKinsoku(4040,null),
-    HandOut(4041,DummyPositionSensitiveRecordWithChildren.class),
-    ExEmbed(4044,ExEmbed.class),
-    ExEmbedAtom(4045,ExEmbedAtom.class),
+    HandOut(4041,DummyPositionSensitiveRecordWithChildren::new),
+    ExEmbed(4044,ExEmbed::new),
+    ExEmbedAtom(4045,ExEmbedAtom::new),
     ExLink(4046,null),
     BookmarkEntityAtom(4048,null),
     ExLinkAtom(4049,null),
     SrKinsokuAtom(4050,null),
-    ExHyperlinkAtom(4051,ExHyperlinkAtom.class),
-    ExHyperlink(4055,ExHyperlink.class),
+    ExHyperlinkAtom(4051,ExHyperlinkAtom::new),
+    ExHyperlink(4055,ExHyperlink::new),
     SlideNumberMCAtom(4056,null),
-    HeadersFooters(4057,HeadersFootersContainer.class),
-    HeadersFootersAtom(4058,HeadersFootersAtom.class),
-    TxInteractiveInfoAtom(4063,TxInteractiveInfoAtom.class),
+    HeadersFooters(4057,HeadersFootersContainer::new),
+    HeadersFootersAtom(4058,HeadersFootersAtom::new),
+    TxInteractiveInfoAtom(4063,TxInteractiveInfoAtom::new),
     CharFormatAtom(4066,null),
     ParaFormatAtom(4067,null),
     RecolorInfoAtom(4071,null),
     ExQuickTimeMovie(4074,null),
     ExQuickTimeMovieData(4075,null),
-    ExControl(4078,ExControl.class),
-    SlideListWithText(4080,SlideListWithText.class),
-    InteractiveInfo(4082,InteractiveInfo.class),
-    InteractiveInfoAtom(4083,InteractiveInfoAtom.class),
-    UserEditAtom(4085,UserEditAtom.class),
+    ExControl(4078,ExControl::new),
+    SlideListWithText(4080,SlideListWithText::new),
+    InteractiveInfo(4082,InteractiveInfo::new),
+    InteractiveInfoAtom(4083,InteractiveInfoAtom::new),
+    UserEditAtom(4085,UserEditAtom::new),
     CurrentUserAtom(4086,null),
     DateTimeMCAtom(4087,null),
     GenericDateMCAtom(4088,null),
     FooterMCAtom(4090,null),
-    ExControlAtom(4091,ExControlAtom.class),
-    ExMediaAtom(4100,ExMediaAtom.class),
-    ExVideoContainer(4101,ExVideoContainer.class),
-    ExAviMovie(4102,ExAviMovie.class),
-    ExMCIMovie(4103,ExMCIMovie.class),
+    ExControlAtom(4091,ExControlAtom::new),
+    ExMediaAtom(4100,ExMediaAtom::new),
+    ExVideoContainer(4101,ExVideoContainer::new),
+    ExAviMovie(4102,ExAviMovie::new),
+    ExMCIMovie(4103,ExMCIMovie::new),
     ExMIDIAudio(4109,null),
     ExCDAudio(4110,null),
     ExWAVAudioEmbedded(4111,null),
     ExWAVAudioLink(4112,null),
-    ExOleObjStg(4113,ExOleObjStg.class),
+    ExOleObjStg(4113,ExOleObjStg::new),
     ExCDAudioAtom(4114,null),
     ExWAVAudioEmbeddedAtom(4115,null),
-    AnimationInfo(4116,AnimationInfo.class),
-    AnimationInfoAtom(4081,AnimationInfoAtom.class),
+    AnimationInfo(4116,AnimationInfo::new),
+    AnimationInfoAtom(4081,AnimationInfoAtom::new),
     RTFDateTimeMCAtom(4117,null),
-    ProgTags(5000,DummyPositionSensitiveRecordWithChildren.class),
+    ProgTags(5000,DummyPositionSensitiveRecordWithChildren::new),
     ProgStringTag(5001,null),
-    ProgBinaryTag(5002,DummyPositionSensitiveRecordWithChildren.class),
-    BinaryTagData(5003, BinaryTagDataBlob.class),//0x138b RT_BinaryTagDataBlob
+    ProgBinaryTag(5002,DummyPositionSensitiveRecordWithChildren::new),
+    BinaryTagData(5003, BinaryTagDataBlob::new),//0x138b RT_BinaryTagDataBlob
     PrpublicintOptions(6000,null),
-    PersistPtrFullBlock(6001,PersistPtrHolder.class),
-    PersistPtrIncrementalBlock(6002,PersistPtrHolder.class),
+    PersistPtrFullBlock(6001,PersistPtrHolder::new),
+    PersistPtrIncrementalBlock(6002,PersistPtrHolder::new),
     GScalingAtom(10001,null),
     GRColorAtom(10002,null),
 
     // Records ~12000 seem to be related to the Comments used in PPT 2000/XP
     // (Comments in PPT97 are normal Escher text boxes)
-    Comment2000(12000,Comment2000.class),
-    Comment2000Atom(12001,Comment2000Atom.class),
+    Comment2000(12000,Comment2000::new),
+    Comment2000Atom(12001,Comment2000Atom::new),
     Comment2000Summary(12004,null),
     Comment2000SummaryAtom(12005,null),
 
     // Records ~12050 seem to be related to Document Encryption
-    DocumentEncryptionAtom(12052,DocumentEncryptionAtom.class),
+    DocumentEncryptionAtom(12052,DocumentEncryptionAtom::new),
 
     OriginalMainMasterId(1052,null),
     CompositeMasterId(1052,null),
     RoundTripContentMasterInfo12(1054,null),
     RoundTripShapeId12(1055,null),
-    RoundTripHFPlaceholder12(1056,RoundTripHFPlaceholder12.class),
+    RoundTripHFPlaceholder12(1056,RoundTripHFPlaceholder12::new),
     RoundTripContentMasterId(1058,null),
     RoundTripOArtTextStyles12(1059,null),
     RoundTripShapeCheckSumForCustomLayouts12(1062,null),
@@ -207,6 +207,11 @@ public enum RecordTypes {
     // same as EscherTertiaryOptRecord.RECORD_ID
     EscherUserDefined(0xf122,null);
 
+    @FunctionalInterface
+    public interface RecordConstructor<T extends Record> {
+         T apply(byte[] source, int start, int len);
+    }
+
     private static final Map<Short,RecordTypes> LOOKUP;
 
     static {
@@ -217,85 +222,15 @@ public enum RecordTypes {
     }    
     
     public final short typeID;
-    public final Class<? extends Record> handlingClass;
+    public final RecordConstructor recordConstructor;
 
-    private RecordTypes(int typeID, Class<? extends Record> handlingClass) {
+    RecordTypes(int typeID, RecordConstructor recordConstructor) {
         this.typeID = (short)typeID;
-        this.handlingClass = handlingClass;
+        this.recordConstructor = recordConstructor;
     }
 
     public static RecordTypes forTypeID(int typeID) {
         RecordTypes rt = LOOKUP.get((short)typeID);
         return (rt != null) ? rt : UnknownRecordPlaceholder;
     }
-
-
-
-    /**
-     * Returns name of the record by its type
-     *
-     * @param type section of the record header
-     * @return name of the record
-     */
-//    public static String recordName(int type) {
-//        String name = typeToName.get(Integer.valueOf(type));
-//        return (name == null) ? ("Unknown" + type) : name;
-//    }
-
-    /**
-     * Returns the class handling a record by its type.
-	 * If given an un-handled PowerPoint record, will return a dummy
-	 *  placeholder class. If given an unknown PowerPoint record, or
-	 *  and Escher record, will return null.
-     *
-     * @param type section of the record header
-     * @return class to handle the record, or null if an unknown (eg Escher) record
-     */
-//	public static Class<? extends Record> recordHandlingClass(int type) {
-//		Class<? extends Record> c = typeToClass.get(Integer.valueOf(type));
-//		return c;
-//	}
-//
-//    static {
-//		typeToName = new HashMap<Integer,String>();
-//		typeToClass = new HashMap<Integer,Class<? extends Record>>();
-//        try {
-//            Field[] f = RecordTypes.class.getFields();
-//            for (int i = 0; i < f.length; i++){
-//               Object val = f[i].get(null);
-//
-//               // Escher record, only store ID -> Name
-//               if (val instanceof Integer) {
-//                  typeToName.put((Integer)val, f[i].getName());
-//               }
-//               // PowerPoint record, store ID -> Name and ID -> Class
-//               if (val instanceof Type) {
-//                  Type t = (Type)val;
-//                  Class<? extends Record> c = t.handlingClass;
-//                  Integer id = Integer.valueOf(t.typeID);
-//                  if(c == null) { c = UnknownRecordPlaceholder.class; }
-//
-//                  typeToName.put(id, f[i].getName());
-//                  typeToClass.put(id, c);
-//               }
-//            }
-//        } catch (IllegalAccessException e){
-//            throw new HSLFException("Failed to initialize records types");
-//        }
-//    }
-
-
-	/**
-	 * Wrapper for the details of a PowerPoint or Escher record type.
-	 * Contains both the type, and the handling class (if any), and
-	 *  offers methods to get either back out.
-	 */
-//	public static class Type {
-//		public final int typeID;
-//		public final Class<? extends Record> handlingClass;
-//		public Type(int typeID, Class<? extends Record> handlingClass) {
-//			this.typeID = typeID;
-//			this.handlingClass = handlingClass;
-//		}
-//	}
 }

Copied: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFComment.java (from r1829452, poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Comment.java)
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFComment.java?p2=poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFComment.java&p1=poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Comment.java&r1=1829452&r2=1829453&rev=1829453&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Comment.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFComment.java Wed Apr 18 15:02:02 2018
@@ -15,61 +15,90 @@
    limitations under the License.
 ==================================================================== */
 
-package org.apache.poi.hslf.model;
+package org.apache.poi.hslf.usermodel;
 
 import org.apache.poi.hslf.record.Comment2000;
+import org.apache.poi.sl.usermodel.Comment;
+import org.apache.poi.util.Units;
 
-/**
- *
- * @author Nick Burch
- */
-public final class Comment {
-	private Comment2000 _comment2000;
-
-	public Comment(Comment2000 comment2000) {
-		_comment2000 = comment2000;
-	}
-
-	protected Comment2000 getComment2000() {
-		return _comment2000;
-	}
-
-	/**
-	 * Get the Author of this comment
-	 */
-	public String getAuthor() {
-		return _comment2000.getAuthor();
-	}
-	/**
-	 * Set the Author of this comment
-	 */
-	public void setAuthor(String author) {
-		_comment2000.setAuthor(author);
-	}
-
-	/**
-	 * Get the Author's Initials of this comment
-	 */
-	public String getAuthorInitials() {
-		return _comment2000.getAuthorInitials();
-	}
-	/**
-	 * Set the Author's Initials of this comment
-	 */
-	public void setAuthorInitials(String initials) {
-		_comment2000.setAuthorInitials(initials);
-	}
-
-	/**
-	 * Get the text of this comment
-	 */
-	public String getText() {
-		return _comment2000.getText();
-	}
-	/**
-	 * Set the text of this comment
-	 */
-	public void setText(String text) {
-		_comment2000.setText(text);
-	}
+import java.awt.geom.Point2D;
+import java.util.Date;
+
+public final class HSLFComment implements Comment {
+    private Comment2000 _comment2000;
+
+    public HSLFComment(Comment2000 comment2000) {
+        _comment2000 = comment2000;
+    }
+
+    protected Comment2000 getComment2000() {
+        return _comment2000;
+    }
+
+    /**
+     * Get the Author of this comment
+     */
+    public String getAuthor() {
+        return _comment2000.getAuthor();
+    }
+
+    /**
+     * Set the Author of this comment
+     */
+    public void setAuthor(String author) {
+        _comment2000.setAuthor(author);
+    }
+
+    /**
+     * Get the Author's Initials of this comment
+     */
+    public String getAuthorInitials() {
+        return _comment2000.getAuthorInitials();
+    }
+
+    /**
+     * Set the Author's Initials of this comment
+     */
+    public void setAuthorInitials(String initials) {
+        _comment2000.setAuthorInitials(initials);
+    }
+
+    /**
+     * Get the text of this comment
+     */
+    public String getText() {
+        return _comment2000.getText();
+    }
+
+    /**
+     * Set the text of this comment
+     */
+    public void setText(String text) {
+        _comment2000.setText(text);
+    }
+
+    @Override
+    public Date getDate() {
+        return _comment2000.getComment2000Atom().getDate();
+    }
+
+    @Override
+    public void setDate(Date date) {
+        _comment2000.getComment2000Atom().setDate(date);
+    }
+
+    @Override
+    public Point2D getOffset() {
+        final double x = Units.masterToPoints(_comment2000.getComment2000Atom().getXOffset());
+        final double y = Units.masterToPoints(_comment2000.getComment2000Atom().getYOffset());
+        return new Point2D.Double(x, y);
+    }
+
+    @Override
+    public void setOffset(Point2D offset) {
+        final int x = Units.pointsToMaster(offset.getX());
+        final int y = Units.pointsToMaster(offset.getY());
+        _comment2000.getComment2000Atom().setXOffset(x);
+        _comment2000.getComment2000Atom().setYOffset(y);
+    }
 }

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFMasterSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFMasterSheet.java?rev=1829453&r1=1829452&r2=1829453&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFMasterSheet.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFMasterSheet.java Wed Apr 18 15:02:02 2018
@@ -21,6 +21,8 @@ import org.apache.poi.hslf.model.textpro
 import org.apache.poi.hslf.record.SheetContainer;
 import org.apache.poi.hslf.record.TextHeaderAtom;
 import org.apache.poi.sl.usermodel.MasterSheet;
+import org.apache.poi.sl.usermodel.SimpleShape;
+import org.apache.poi.util.Removal;
 
 /**
  * The superclass of all master sheets - Slide masters, Notes masters, etc.
@@ -52,11 +54,13 @@ public abstract class HSLFMasterSheet ex
      *
      *
      * @return true if the shape is a placeholder
+     * 
+     * @deprecated use {@link SimpleShape#isPlaceholder()}
      */
+    @Deprecated
+    @Removal(version="4.1.0")
     public static boolean isPlaceholder(HSLFShape shape){
-        if(!(shape instanceof HSLFTextShape)) return false;
-
-        HSLFTextShape tx = (HSLFTextShape)shape;
-        return tx.getPlaceholderAtom() != null;
+        return shape instanceof SimpleShape 
+            && ((SimpleShape<?,?>)shape).isPlaceholder();
     }
 }

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFNotes.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFNotes.java?rev=1829453&r1=1829452&r2=1829453&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFNotes.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFNotes.java Wed Apr 18 15:02:02 2018
@@ -20,7 +20,10 @@ package org.apache.poi.hslf.usermodel;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.poi.hslf.model.HeadersFooters;
+import org.apache.poi.hslf.record.HeadersFootersContainer;
 import org.apache.poi.sl.usermodel.Notes;
+import org.apache.poi.sl.usermodel.Placeholder;
 import org.apache.poi.util.POILogFactory;
 import org.apache.poi.util.POILogger;
 
@@ -72,4 +75,28 @@ public final class HSLFNotes extends HSL
     public HSLFMasterSheet getMasterSheet() {
         return null;
     }
+
+    /**
+     * Header / Footer settings for this slide.
+     *
+     * @return Header / Footer settings for this slide
+     */
+    @Override
+    public HeadersFooters getHeadersFooters() {
+        return new HeadersFooters(this, HeadersFootersContainer.NotesHeadersFootersContainer);
+    }
+
+
+    @Override
+    public HSLFPlaceholderDetails getPlaceholderDetails(Placeholder placeholder) {
+        if (placeholder == null) {
+            return null;
+        }
+
+        if (placeholder == Placeholder.HEADER || placeholder == Placeholder.FOOTER) {
+            return new HSLFPlaceholderDetails(this, placeholder);
+        } else {
+            return super.getPlaceholderDetails(placeholder);
+        }
+    }
 }

Added: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPlaceholderDetails.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPlaceholderDetails.java?rev=1829453&view=auto
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPlaceholderDetails.java (added)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPlaceholderDetails.java Wed Apr 18 15:02:02 2018
@@ -0,0 +1,157 @@
+/* ====================================================================
+   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.usermodel;
+
+import org.apache.poi.hslf.model.HeadersFooters;
+import org.apache.poi.sl.usermodel.Placeholder;
+import org.apache.poi.sl.usermodel.PlaceholderDetails;
+
+/**
+ * Extended placeholder details for HSLF sheets - mainly for headers and footers
+ *
+ * @since POI 4.0.0
+ */
+public class HSLFPlaceholderDetails implements PlaceholderDetails {
+    private final HSLFSheet sheet;
+    private final Placeholder placeholder;
+
+    HSLFPlaceholderDetails(final HSLFSheet sheet, final Placeholder placeholder) {
+        this.sheet = sheet;
+        this.placeholder = placeholder;
+    }
+
+
+    public boolean isVisible() {
+        final Placeholder ph = getPlaceholder();
+        if (ph == null) {
+            return false;
+        }
+
+        final HeadersFooters headersFooters = sheet.getHeadersFooters();
+
+        switch (ph) {
+            case HEADER:
+                return headersFooters.isHeaderVisible();
+            case FOOTER:
+                return headersFooters.isFooterVisible();
+            case DATETIME:
+                return headersFooters.isDateTimeVisible();
+            case TITLE:
+                return headersFooters.isHeaderVisible();
+            case SLIDE_NUMBER:
+                return headersFooters.isSlideNumberVisible();
+            default:
+                return false;
+        }
+    }
+
+    public void setVisible(final boolean isVisible) {
+        final Placeholder ph = getPlaceholder();
+        if (ph == null) {
+            return;
+        }
+
+        final HeadersFooters headersFooters = sheet.getHeadersFooters();
+
+        switch (ph) {
+            case TITLE:
+            case HEADER:
+                headersFooters.setHeaderVisible(isVisible);
+                break;
+            case FOOTER:
+                headersFooters.setFooterVisible(isVisible);
+                break;
+            case DATETIME:
+                headersFooters.setDateTimeVisible(isVisible);
+                break;
+            case SLIDE_NUMBER:
+                headersFooters.setSlideNumberVisible(isVisible);
+                break;
+        }
+    }
+
+    @Override
+    public Placeholder getPlaceholder() {
+        return placeholder;
+    }
+
+    @Override
+    public void setPlaceholder(Placeholder placeholder) {
+        throw new UnsupportedOperationException("Only sub class(es) of HSLFPlaceholderDetails allow setting the placeholder");
+    }
+
+    @Override
+    public PlaceholderSize getSize() {
+        return PlaceholderSize.full;
+    }
+
+    @Override
+    public void setSize(PlaceholderSize size) {
+        throw new UnsupportedOperationException("Only sub class(es) of HSLFPlaceholderDetails allow setting the size");
+    }
+
+    @Override
+    public String getText() {
+        final Placeholder ph = getPlaceholder();
+        if (ph == null) {
+            return null;
+        }
+
+        final HeadersFooters headersFooters = sheet.getHeadersFooters();
+
+        switch (ph) {
+            case TITLE:
+            case HEADER:
+                return headersFooters.getHeaderText();
+            case FOOTER:
+                return headersFooters.getFooterText();
+            case DATETIME:
+                return headersFooters.getDateTimeText();
+            case SLIDE_NUMBER:
+            default:
+                return null;
+        }
+    }
+
+    @Override
+    public void setText(final String text) {
+        final Placeholder ph = getPlaceholder();
+        if (ph == null) {
+            return;
+        }
+
+        final HeadersFooters headersFooters = sheet.getHeadersFooters();
+
+        switch (ph) {
+            case TITLE:
+            case HEADER:
+                headersFooters.setHeaderText(text);
+                break;
+            case FOOTER:
+                headersFooters.setFootersText(text);
+                break;
+            case DATETIME:
+                headersFooters.setDateTimeText(text);
+                break;
+            case SLIDE_NUMBER:
+            default:
+                break;
+        }
+
+    }
+}
\ No newline at end of file

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



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