Author: kiwiwings
Date: Wed Feb  8 01:12:22 2017
New Revision: 1782096

URL: http://svn.apache.org/viewvc?rev=1782096&view=rev
Log:
#60625 - Rendering issue with background and shape overlayed by image

Added:
    
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/SlideAtomLayout.java   
(with props)
Modified:
    poi/trunk/src/java/org/apache/poi/sl/draw/DrawMasterSheet.java
    poi/trunk/src/java/org/apache/poi/sl/draw/DrawShape.java
    poi/trunk/src/java/org/apache/poi/sl/draw/DrawSheet.java
    poi/trunk/src/java/org/apache/poi/sl/draw/DrawSlide.java
    poi/trunk/src/java/org/apache/poi/sl/draw/DrawTextParagraph.java
    poi/trunk/src/java/org/apache/poi/sl/draw/DrawTextShape.java
    poi/trunk/src/java/org/apache/poi/sl/draw/Drawable.java
    poi/trunk/src/java/org/apache/poi/sl/usermodel/Placeholder.java
    poi/trunk/src/java/org/apache/poi/sl/usermodel/Slide.java
    poi/trunk/src/java/org/apache/poi/sl/usermodel/TextRun.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFLineBreak.java
    
poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPropertiesDelegate.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShape.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSimpleShape.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideLayout.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTableCell.java
    
poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextParagraph.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextRun.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTheme.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/TestXSLFSlideShow.java
    
poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXMLSlideShow.java
    
poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFAutoShape.java
    
poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFHyperlink.java
    
poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFShape.java
    
poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSlide.java
    
poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextShape.java
    
poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTheme.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/HeadersFooters.java
    
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/OEPlaceholderAtom.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/SlideAtom.java
    
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextBytesAtom.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextCharsAtom.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextHeaderAtom.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSheet.java
    
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSimpleShape.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlide.java
    
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideMaster.java
    
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextRun.java
    
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextShape.java
    
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTitleMaster.java
    
poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestSlideAtom.java
    
poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java
    
poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestCounts.java

Modified: poi/trunk/src/java/org/apache/poi/sl/draw/DrawMasterSheet.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/draw/DrawMasterSheet.java?rev=1782096&r1=1782095&r2=1782096&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/draw/DrawMasterSheet.java (original)
+++ poi/trunk/src/java/org/apache/poi/sl/draw/DrawMasterSheet.java Wed Feb  8 
01:12:22 2017
@@ -17,7 +17,13 @@
 
 package org.apache.poi.sl.draw;
 
-import org.apache.poi.sl.usermodel.*;
+import java.awt.Graphics2D;
+
+import org.apache.poi.sl.usermodel.MasterSheet;
+import org.apache.poi.sl.usermodel.Placeholder;
+import org.apache.poi.sl.usermodel.Shape;
+import org.apache.poi.sl.usermodel.SimpleShape;
+import org.apache.poi.sl.usermodel.Slide;
 
 
 public class DrawMasterSheet extends DrawSheet {
@@ -33,12 +39,15 @@ public class DrawMasterSheet extends Dra
      * for instance, slide masters and layouts don't display placeholders
      */
     @Override
-    protected boolean canDraw(Shape<?,?> shape) {
+    protected boolean canDraw(Graphics2D graphics, Shape<?,?> shape) {
         if (shape instanceof SimpleShape) {
+            // in XSLF, slidenumber and date shapes aren't marked as 
placeholders opposed to HSLF
             Placeholder ph = ((SimpleShape<?,?>)shape).getPlaceholder();
-            return ph == null;
-        } else {
-            return true;
+            if (ph != null) {
+                Slide<?,?> slide = 
(Slide<?,?>)graphics.getRenderingHint(Drawable.CURRENT_SLIDE);
+                return slide.getDisplayPlaceholder(ph);
+            }
         }
+        return true;
     }
 }

Modified: poi/trunk/src/java/org/apache/poi/sl/draw/DrawShape.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/draw/DrawShape.java?rev=1782096&r1=1782095&r2=1782096&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/draw/DrawShape.java (original)
+++ poi/trunk/src/java/org/apache/poi/sl/draw/DrawShape.java Wed Feb  8 
01:12:22 2017
@@ -39,17 +39,33 @@ public class DrawShape implements Drawab
     }
 
     /**
+     * Sometimes it's necessary to distinguish between XSLF/HSLF for the 
rendering.
+     * Use this method on the shape to determine, if we work on the BIFF 
implementation
+     *
+     * @param shape the shape to render
+     * @return {@code true} if HSLF implementation is used
+     */
+    protected static boolean isHSLF(Shape<?,?> shape) {
+        return 
shape.getClass().getCanonicalName().toLowerCase(Locale.ROOT).contains("hslf");
+    }
+    
+    /**
      * Apply 2-D transforms before drawing this shape. This includes rotation 
and flipping.
      *
      * @param graphics the graphics whos transform matrix will be modified
      */
+    @Override
     public void applyTransform(Graphics2D graphics) {
-        if (!(shape instanceof PlaceableShape)) return;
+        if (!(shape instanceof PlaceableShape)) {
+            return;
+        }
 
         PlaceableShape<?,?> ps = (PlaceableShape<?,?>)shape;
-        final boolean isHSLF = 
ps.getClass().getCanonicalName().toLowerCase(Locale.ROOT).contains("hslf");
+        final boolean isHSLF = isHSLF(shape);
         AffineTransform tx = 
(AffineTransform)graphics.getRenderingHint(Drawable.GROUP_TRANSFORM);
-        if (tx == null) tx = new AffineTransform();
+        if (tx == null) {
+            tx = new AffineTransform();
+        }
         final Rectangle2D anchor = 
tx.createTransformedShape(ps.getAnchor()).getBounds2D();
 
         char cmds[] = isHSLF ? new char[]{ 'h','v','r' } : new char[]{ 
'r','h','v' };
@@ -81,7 +97,9 @@ public class DrawShape implements Drawab
 
                     // normalize rotation
                     rotation %= 360.;
-                    if (rotation < 0) rotation += 360.;
+                    if (rotation < 0) {
+                        rotation += 360.;
+                    }
 
                     int quadrant = (((int)rotation+45)/90)%4;
                     double scaleX = 1.0, scaleY = 1.0;
@@ -148,9 +166,11 @@ public class DrawShape implements Drawab
         return (dim2 == 0.) ? 1 : dim1/dim2;
     }
 
+    @Override
     public void draw(Graphics2D graphics) {
     }
 
+    @Override
     public void drawContent(Graphics2D graphics) {
     }
 
@@ -176,7 +196,10 @@ public class DrawShape implements Drawab
     
     protected static BasicStroke getStroke(StrokeStyle strokeStyle) {
         float lineWidth = (float) strokeStyle.getLineWidth();
-        if (lineWidth == 0.0f) lineWidth = 0.25f; // Both PowerPoint and OOo 
draw zero-length lines as 0.25pt
+        if (lineWidth == 0.0f) {
+            // Both PowerPoint and OOo draw zero-length lines as 0.25pt
+            lineWidth = 0.25f;
+        }
 
         LineDash lineDash = strokeStyle.getLineDash();
         if (lineDash == null) {
@@ -194,7 +217,9 @@ public class DrawShape implements Drawab
         }
 
         LineCap lineCapE = strokeStyle.getLineCap();
-        if (lineCapE == null) lineCapE = LineCap.FLAT;
+        if (lineCapE == null) {
+            lineCapE = LineCap.FLAT;
+        }
         int lineCap;
         switch (lineCapE) {
             case ROUND:

Modified: poi/trunk/src/java/org/apache/poi/sl/draw/DrawSheet.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/draw/DrawSheet.java?rev=1782096&r1=1782095&r2=1782096&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/draw/DrawSheet.java (original)
+++ poi/trunk/src/java/org/apache/poi/sl/draw/DrawSheet.java Wed Feb  8 
01:12:22 2017
@@ -17,13 +17,14 @@
 
 package org.apache.poi.sl.draw;
 
-import java.awt.Dimension;
 import java.awt.Color;
+import java.awt.Dimension;
 import java.awt.Graphics2D;
-
 import java.awt.geom.AffineTransform;
 
-import org.apache.poi.sl.usermodel.*;
+import org.apache.poi.sl.usermodel.MasterSheet;
+import org.apache.poi.sl.usermodel.Shape;
+import org.apache.poi.sl.usermodel.Sheet;
 
 
 public class DrawSheet implements Drawable {
@@ -34,6 +35,7 @@ public class DrawSheet implements Drawab
         this.sheet = sheet;
     }
     
+    @Override
     public void draw(Graphics2D graphics) {
         Dimension dim = sheet.getSlideShow().getPageSize();
         Color whiteTrans = new Color(1f,1f,1f,0f);
@@ -51,7 +53,9 @@ public class DrawSheet implements Drawab
         graphics.setRenderingHint(Drawable.GROUP_TRANSFORM, new 
AffineTransform());
 
         for (Shape<?,?> shape : sheet.getShapes()) {
-            if(!canDraw(shape)) continue;
+            if(!canDraw(graphics, shape)) {
+                continue;
+            }
             
             // remember the initial transform and restore it after we are done 
with drawing
             AffineTransform at = graphics.getTransform();
@@ -73,9 +77,11 @@ public class DrawSheet implements Drawab
         }
     }
 
+    @Override
     public void applyTransform(Graphics2D context) {
     }
 
+    @Override
     public void drawContent(Graphics2D context) {
     }
 
@@ -85,7 +91,7 @@ public class DrawSheet implements Drawab
      * Subclasses can override it and skip certain shapes from drawings,
      * for instance, slide masters and layouts don't display placeholders
      */
-    protected boolean canDraw(Shape<?,?> shape){
+    protected boolean canDraw(Graphics2D graphics, Shape<?,?> shape){
         return true;
     }
 }

Modified: poi/trunk/src/java/org/apache/poi/sl/draw/DrawSlide.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/draw/DrawSlide.java?rev=1782096&r1=1782095&r2=1782096&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/draw/DrawSlide.java (original)
+++ poi/trunk/src/java/org/apache/poi/sl/draw/DrawSlide.java Wed Feb  8 
01:12:22 2017
@@ -29,6 +29,8 @@ public class DrawSlide extends DrawSheet
     }
     
     public void draw(Graphics2D graphics) {
+        graphics.setRenderingHint(Drawable.CURRENT_SLIDE, this.sheet);
+        
         Background<?,?> bg = sheet.getBackground();
         if(bg != null) {
             DrawFactory drawFact = DrawFactory.getInstance(graphics);
@@ -37,5 +39,6 @@ public class DrawSlide extends DrawSheet
         }
 
         super.draw(graphics);
+        graphics.setRenderingHint(Drawable.CURRENT_SLIDE, null);
     }
 }

Modified: poi/trunk/src/java/org/apache/poi/sl/draw/DrawTextParagraph.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/draw/DrawTextParagraph.java?rev=1782096&r1=1782095&r2=1782096&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/draw/DrawTextParagraph.java (original)
+++ poi/trunk/src/java/org/apache/poi/sl/draw/DrawTextParagraph.java Wed Feb  8 
01:12:22 2017
@@ -41,10 +41,12 @@ import org.apache.poi.sl.usermodel.Paint
 import org.apache.poi.sl.usermodel.PlaceableShape;
 import org.apache.poi.sl.usermodel.ShapeContainer;
 import org.apache.poi.sl.usermodel.Sheet;
+import org.apache.poi.sl.usermodel.Slide;
 import org.apache.poi.sl.usermodel.TextParagraph;
 import org.apache.poi.sl.usermodel.TextParagraph.BulletStyle;
 import org.apache.poi.sl.usermodel.TextParagraph.TextAlign;
 import org.apache.poi.sl.usermodel.TextRun;
+import org.apache.poi.sl.usermodel.TextRun.FieldType;
 import org.apache.poi.sl.usermodel.TextRun.TextCap;
 import org.apache.poi.sl.usermodel.TextShape;
 import org.apache.poi.sl.usermodel.TextShape.TextDirection;
@@ -82,6 +84,7 @@ public class DrawTextParagraph implement
         /**
          * Resolves instances being deserialized to the predefined constants.
          */
+        @Override
         protected Object readResolve() throws InvalidObjectException {
             if (HYPERLINK_HREF.getName().equals(getName())) {
                 return HYPERLINK_HREF;
@@ -116,8 +119,11 @@ public class DrawTextParagraph implement
         autoNbrIdx = index;
     }
 
+    @Override
     public void draw(Graphics2D graphics){
-        if (lines.isEmpty()) return;
+        if (lines.isEmpty()) {
+            return;
+        }
 
         double penY = y;
 
@@ -144,7 +150,9 @@ public class DrawTextParagraph implement
 
         //The vertical line spacing
         Double spacing = paragraph.getLineSpacing();
-        if (spacing == null) spacing = 100d;
+        if (spacing == null) {
+            spacing = 100d;
+        }
 
         for(DrawTextFragment line : lines){
             double penX;
@@ -176,7 +184,9 @@ public class DrawTextParagraph implement
             double rightInset = insets.right;
 
             TextAlign ta = paragraph.getTextAlign();
-            if (ta == null) ta = TextAlign.LEFT;
+            if (ta == null) {
+                ta = TextAlign.LEFT;
+            }
             switch (ta) {
                 case CENTER:
                     penX += (anchor.getWidth() - line.getWidth() - leftInset - 
rightInset - leftMargin) / 2;
@@ -217,9 +227,11 @@ public class DrawTextParagraph implement
         return (lines.isEmpty() || rawText.trim().isEmpty());
     }
 
+    @Override
     public void applyTransform(Graphics2D graphics) {
     }
 
+    @Override
     public void drawContent(Graphics2D graphics) {
     }
 
@@ -243,10 +255,14 @@ public class DrawTextParagraph implement
 
             double wrappingWidth = getWrappingWidth(lines.size() == 0, 
graphics) + 1; // add a pixel to compensate rounding errors
             // shape width can be smaller that the sum of insets (this was 
proved by a test file)
-            if(wrappingWidth < 0) wrappingWidth = 1;
+            if(wrappingWidth < 0) {
+                wrappingWidth = 1;
+            }
 
             int nextBreak = text.indexOf("\n", startIndex + 1);
-            if (nextBreak == -1) nextBreak = it.getEndIndex();
+            if (nextBreak == -1) {
+                nextBreak = it.getEndIndex();
+            }
 
             TextLayout layout = measurer.nextLayout((float)wrappingWidth, 
nextBreak, true);
             if (layout == null) {
@@ -279,7 +295,9 @@ public class DrawTextParagraph implement
 
             maxLineHeight = Math.max(maxLineHeight, line.getHeight());
 
-            if(endIndex == it.getEndIndex()) break;
+            if(endIndex == it.getEndIndex()) {
+                break;
+            }
         }
 
         rawText = text.toString();
@@ -287,7 +305,9 @@ public class DrawTextParagraph implement
 
     protected DrawTextFragment getBullet(Graphics2D graphics, 
AttributedCharacterIterator firstLineAttr) {
         BulletStyle bulletStyle = paragraph.getBulletStyle();
-        if (bulletStyle == null) return null;
+        if (bulletStyle == null) {
+            return null;
+        }
 
         String buCharacter;
         AutoNumberingScheme ans = bulletStyle.getAutoNumberingScheme();
@@ -296,10 +316,14 @@ public class DrawTextParagraph implement
         } else {
             buCharacter = bulletStyle.getBulletCharacter();
         }
-        if (buCharacter == null) return null;
+        if (buCharacter == null) {
+            return null;
+        }
 
         String buFont = bulletStyle.getBulletFont();
-        if (buFont == null) buFont = paragraph.getDefaultFontFamily();
+        if (buFont == null) {
+            buFont = paragraph.getDefaultFontFamily();
+        }
         assert(buFont != null);
 
         PlaceableShape<?,?> ps = getParagraphShape();
@@ -313,9 +337,14 @@ public class DrawTextParagraph implement
 
         float fontSize = (Float)firstLineAttr.getAttribute(TextAttribute.SIZE);
         Double buSz = bulletStyle.getBulletFontSize();
-        if (buSz == null) buSz = 100d;
-        if (buSz > 0) fontSize *= buSz* 0.01;
-        else fontSize = (float)-buSz;
+        if (buSz == null) {
+            buSz = 100d;
+        }
+        if (buSz > 0) {
+            fontSize *= buSz* 0.01;
+        } else {
+            fontSize = (float)-buSz;
+        }
 
 
         AttributedString str = new 
AttributedString(mapFontCharset(buCharacter,buFont));
@@ -328,7 +357,11 @@ public class DrawTextParagraph implement
         return fact.getTextFragment(layout, str);
     }
 
-    protected String getRenderableText(TextRun tr) {
+    protected String getRenderableText(Graphics2D graphics, TextRun tr) {
+        if (tr.getFieldType() == FieldType.SLIDE_NUMBER) {
+            Slide<?,?> slide = 
(Slide<?,?>)graphics.getRenderingHint(Drawable.CURRENT_SLIDE);
+            return (slide == null) ? "" : 
Integer.toString(slide.getSlideNumber()); 
+        }
         StringBuilder buf = new StringBuilder();
         TextCap cap = tr.getTextCap();
         String tabs = null;
@@ -364,18 +397,24 @@ public class DrawTextParagraph implement
     private String tab2space(TextRun tr) {
         AttributedString string = new AttributedString(" ");
         String fontFamily = tr.getFontFamily();
-        if (fontFamily == null) fontFamily = "Lucida Sans";
+        if (fontFamily == null) {
+            fontFamily = "Lucida Sans";
+        }
         string.addAttribute(TextAttribute.FAMILY, fontFamily);
 
         Double fs = tr.getFontSize();
-        if (fs == null) fs = 12d;
+        if (fs == null) {
+            fs = 12d;
+        }
         string.addAttribute(TextAttribute.SIZE, fs.floatValue());
 
         TextLayout l = new TextLayout(string.getIterator(), new 
FontRenderContext(null, true, true));
         double wspace = l.getAdvance();
 
         Double tabSz = paragraph.getDefaultTabSize();
-        if (tabSz == null) tabSz = wspace*4;
+        if (tabSz == null) {
+            tabSz = wspace*4;
+        }
 
         int numSpaces = (int)Math.ceil(tabSz / wspace);
         StringBuilder buf = new StringBuilder();
@@ -449,10 +488,13 @@ public class DrawTextParagraph implement
             }
             if (firstLine && !isHSLF()) {
                 if (bullet != null){
-                    if (indent > 0) width -= indent;
+                    if (indent > 0) {
+                        width -= indent;
+                    }
                 } else {
-                    if (indent > 0) width -= indent; // first line indentation
-                    else if (indent < 0) { // hanging indentation: the first 
line start at the left margin
+                    if (indent > 0) {
+                        width -= indent; // first line indentation
+                    } else if (indent < 0) { // hanging indentation: the first 
line start at the left margin
                         width += leftMargin;
                     }
                 }
@@ -480,25 +522,36 @@ public class DrawTextParagraph implement
     @SuppressWarnings("rawtypes")
     private PlaceableShape<?,?> getParagraphShape() {
         return new PlaceableShape(){
+            @Override
             public ShapeContainer<?,?> getParent() { return null; }
+            @Override
             public Rectangle2D getAnchor() { return 
paragraph.getParentShape().getAnchor(); }
+            @Override
             public void setAnchor(Rectangle2D anchor) {}
+            @Override
             public double getRotation() { return 0; }
+            @Override
             public void setRotation(double theta) {}
+            @Override
             public void setFlipHorizontal(boolean flip) {}
+            @Override
             public void setFlipVertical(boolean flip) {}
+            @Override
             public boolean getFlipHorizontal() { return false; }
+            @Override
             public boolean getFlipVertical() { return false; }
+            @Override
             public Sheet<?,?> getSheet() { return 
paragraph.getParentShape().getSheet(); }
         };
     }
 
     protected AttributedString getAttributedString(Graphics2D graphics, 
StringBuilder text){
         List<AttributedStringData> attList = new 
ArrayList<AttributedStringData>();
-        if (text == null) text = new StringBuilder();
+        if (text == null) {
+            text = new StringBuilder();
+        }
 
         PlaceableShape<?,?> ps = getParagraphShape();
-
         DrawFontManager fontHandler = 
(DrawFontManager)graphics.getRenderingHint(Drawable.FONT_HANDLER);
         @SuppressWarnings("unchecked")
         Map<String,String> fontMap = 
(Map<String,String>)graphics.getRenderingHint(Drawable.FONT_MAP);
@@ -506,9 +559,11 @@ public class DrawTextParagraph implement
         Map<String,String> fallbackMap = 
(Map<String,String>)graphics.getRenderingHint(Drawable.FONT_FALLBACK);
 
         for (TextRun run : paragraph){
-            String runText = getRenderableText(run);
+            String runText = getRenderableText(graphics, run);
             // skip empty runs
-            if (runText.isEmpty()) continue;
+            if (runText.isEmpty()) {
+                continue;
+            }
 
             // user can pass an custom object to convert fonts
             String mappedFont = run.getFontFamily();
@@ -633,8 +688,11 @@ public class DrawTextParagraph implement
         return string;
     }
 
+    /**
+     * @return {@code true} if the HSLF implementation is used
+     */
     protected boolean isHSLF() {
-        return paragraph.getClass().getName().contains("HSLF");
+        return DrawShape.isHSLF(paragraph.getParentShape());
     }
 
     /**

Modified: poi/trunk/src/java/org/apache/poi/sl/draw/DrawTextShape.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/draw/DrawTextShape.java?rev=1782096&r1=1782095&r2=1782096&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/draw/DrawTextShape.java (original)
+++ poi/trunk/src/java/org/apache/poi/sl/draw/DrawTextShape.java Wed Feb  8 
01:12:22 2017
@@ -138,6 +138,7 @@ public class DrawTextShape extends DrawS
 
         double y0 = y;
         //noinspection RedundantCast
+        @SuppressWarnings("cast")
         Iterator<? extends TextParagraph<?,?,? extends TextRun>> paragraphs =
             (Iterator<? extends TextParagraph<?,?,? extends TextRun>>) 
getShape().iterator();
         

Modified: poi/trunk/src/java/org/apache/poi/sl/draw/Drawable.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/draw/Drawable.java?rev=1782096&r1=1782095&r2=1782096&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/draw/Drawable.java (original)
+++ poi/trunk/src/java/org/apache/poi/sl/draw/Drawable.java Wed Feb  8 01:12:22 
2017
@@ -130,6 +130,12 @@ public interface Drawable {
     DrawableHint GSAVE = new DrawableHint(10);
     DrawableHint GRESTORE = new DrawableHint(11);
     
+    /**
+     * The Common SL Draw API works sometimes cascading, but there are places
+     * where the current slide context need to be evaluated, e.g. when slide 
numbers
+     * are printed. In this situation we need to have a way to access the 
current slide
+     */
+    DrawableHint CURRENT_SLIDE = new DrawableHint(12);
     
     
     /**

Modified: poi/trunk/src/java/org/apache/poi/sl/usermodel/Placeholder.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/usermodel/Placeholder.java?rev=1782096&r1=1782095&r2=1782096&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/usermodel/Placeholder.java (original)
+++ poi/trunk/src/java/org/apache/poi/sl/usermodel/Placeholder.java Wed Feb  8 
01:12:22 2017
@@ -114,12 +114,30 @@ public enum Placeholder {
         this.ooxmlId = ooxmlId;
     }
     
-    public static Placeholder lookupNative(int nativeId) {
+    public static Placeholder lookupNativeSlide(int nativeId) {
+        return lookupNative(nativeId, 0);
+    }
+
+    public static Placeholder lookupNativeSlideMaster(int nativeId) {
+        return lookupNative(nativeId, 1);
+    }
+
+    public static Placeholder lookupNativeNotes(int nativeId) {
+        return lookupNative(nativeId, 2);
+    }
+
+    public static Placeholder lookupNativeNotesMaster(int nativeId) {
+        return lookupNative(nativeId, 3);
+    }
+
+    
+    private static Placeholder lookupNative(int nativeId, int type) {
         for (Placeholder ph : values()) {
-            if (ph.nativeSlideId == nativeId ||
-                ph.nativeSlideMasterId == nativeId || 
-                ph.nativeNotesId == nativeId ||
-                ph.nativeNotesMasterId == nativeId
+            if (
+                type == 0 && ph.nativeSlideId == nativeId ||
+                type == 1 && ph.nativeSlideMasterId == nativeId || 
+                type == 2 && ph.nativeNotesId == nativeId ||
+                type == 3 && ph.nativeNotesMasterId == nativeId
             ) {
                 return ph;
             }

Modified: poi/trunk/src/java/org/apache/poi/sl/usermodel/Slide.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/usermodel/Slide.java?rev=1782096&r1=1782095&r2=1782096&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/usermodel/Slide.java (original)
+++ poi/trunk/src/java/org/apache/poi/sl/usermodel/Slide.java Wed Feb  8 
01:12:22 2017
@@ -43,4 +43,14 @@ public interface Slide<
      */
     String getTitle();
 
+    /**
+     * In XSLF, slidenumber and date shapes aren't marked as placeholders
+     * whereas in HSLF they are activated via a HeadersFooter configuration.
+     * This method is used to generalize that handling.
+     *
+     * @param placeholder
+     * @return {@code true} if the placeholder should be displayed/rendered
+     * @since POI 3.16-beta2
+     */
+    boolean getDisplayPlaceholder(Placeholder placeholder);
 }

Modified: poi/trunk/src/java/org/apache/poi/sl/usermodel/TextRun.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/usermodel/TextRun.java?rev=1782096&r1=1782095&r2=1782096&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/usermodel/TextRun.java (original)
+++ poi/trunk/src/java/org/apache/poi/sl/usermodel/TextRun.java Wed Feb  8 
01:12:22 2017
@@ -20,6 +20,7 @@ package org.apache.poi.sl.usermodel;
 import java.awt.Color;
 
 import org.apache.poi.sl.usermodel.PaintStyle.SolidPaint;
+import org.apache.poi.util.Internal;
 
 /**
  * Some text.
@@ -30,6 +31,10 @@ public interface TextRun {
         SMALL,
         ALL
     }
+    
+    enum FieldType {
+        SLIDE_NUMBER, DATE_TIME
+    }
 
     String getRawText();
     void setText(String text);
@@ -176,4 +181,12 @@ public interface TextRun {
      * @since POI 3.14-Beta2
      */
     Hyperlink<?,?> createHyperlink();
+    
+    /**
+     * Experimental method to determine the field type, e.g. slide number
+     *
+     * @return the field type or {@code null} if text run is not a field
+     */
+    @Internal
+    FieldType getFieldType();
 }

Modified: 
poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFLineBreak.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFLineBreak.java?rev=1782096&r1=1782095&r2=1782096&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFLineBreak.java 
(original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFLineBreak.java 
Wed Feb  8 01:12:22 2017
@@ -19,20 +19,11 @@
 
 package org.apache.poi.xslf.usermodel;
 
-import org.openxmlformats.schemas.drawingml.x2006.main.CTRegularTextRun;
-import 
org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTTextLineBreak;
 
 class XSLFLineBreak extends XSLFTextRun {
-    private final CTTextCharacterProperties _brProps;
-
-    XSLFLineBreak(CTRegularTextRun r, XSLFTextParagraph p, 
CTTextCharacterProperties brProps){
+    protected XSLFLineBreak(CTTextLineBreak r, XSLFTextParagraph p) {
         super(r, p);
-        _brProps = brProps;
-    }
-
-    @Override
-    protected CTTextCharacterProperties getRPr(boolean create){
-        return _brProps;
     }
 
     public void setText(String text){

Modified: 
poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPropertiesDelegate.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPropertiesDelegate.java?rev=1782096&r1=1782095&r2=1782096&view=diff
==============================================================================
--- 
poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPropertiesDelegate.java
 (original)
+++ 
poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPropertiesDelegate.java
 Wed Feb  8 01:12:22 2017
@@ -1341,106 +1341,138 @@ import org.openxmlformats.schemas.presen
             this.props = props;
         }
 
+        @Override
         public CTNoFillProperties getNoFill() {
             return isSetNoFill() ? (CTNoFillProperties)props : null;
         }
 
+        @Override
         public boolean isSetNoFill() {
             return (props instanceof CTNoFillProperties);
         }
 
+        @Override
         public void setNoFill(CTNoFillProperties noFill) {}
 
+        @Override
         public CTNoFillProperties addNewNoFill() {
             return null;
         }
 
+        @Override
         public void unsetNoFill() {}
 
+        @Override
         public CTSolidColorFillProperties getSolidFill() {
             return isSetSolidFill() ? (CTSolidColorFillProperties)props : null;
         }
 
+        @Override
         public boolean isSetSolidFill() {
             return (props instanceof CTSolidColorFillProperties);
         }
 
+        @Override
         public void setSolidFill(CTSolidColorFillProperties solidFill) {}
 
+        @Override
         public CTSolidColorFillProperties addNewSolidFill() {
             return null;
         }
 
+        @Override
         public void unsetSolidFill() {}
 
+        @Override
         public CTGradientFillProperties getGradFill() {
             return isSetGradFill() ? (CTGradientFillProperties)props : null;
         }
 
+        @Override
         public boolean isSetGradFill() {
             return (props instanceof CTGradientFillProperties);
         }
 
+        @Override
         public void setGradFill(CTGradientFillProperties gradFill) {}
 
+        @Override
         public CTGradientFillProperties addNewGradFill() {
             return null;
         }
 
+        @Override
         public void unsetGradFill() {}
 
+        @Override
         public CTBlipFillProperties getBlipFill() {
             return isSetBlipFill() ? (CTBlipFillProperties)props : null;
         }
 
+        @Override
         public boolean isSetBlipFill() {
             return (props instanceof CTBlipFillProperties);
         }
 
+        @Override
         public void setBlipFill(CTBlipFillProperties blipFill) {}
 
+        @Override
         public CTBlipFillProperties addNewBlipFill() {
             return null;
         }
 
+        @Override
         public void unsetBlipFill() {}
 
+        @Override
         public CTPatternFillProperties getPattFill() {
             return isSetPattFill() ? (CTPatternFillProperties)props : null;
         }
 
+        @Override
         public boolean isSetPattFill() {
             return (props instanceof CTPatternFillProperties);
         }
 
+        @Override
         public void setPattFill(CTPatternFillProperties pattFill) {}
 
+        @Override
         public CTPatternFillProperties addNewPattFill() {
             return null;
         }
 
+        @Override
         public void unsetPattFill() {}
 
+        @Override
         public CTGroupFillProperties getGrpFill() {
             return isSetGrpFill() ? (CTGroupFillProperties)props : null;
         }
 
+        @Override
         public boolean isSetGrpFill() {
             return (props instanceof CTGroupFillProperties);
         }
 
+        @Override
         public void setGrpFill(CTGroupFillProperties grpFill) {}
 
+        @Override
         public CTGroupFillProperties addNewGrpFill() {
             return null;
         }
 
+        @Override
         public void unsetGrpFill() {}
 
+        @Override
         public boolean isSetMatrixStyle() {
             return false;
         }
 
+        @Override
         public CTStyleMatrixReference getMatrixStyle() {
             return null;
         }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShape.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShape.java?rev=1782096&r1=1782095&r2=1782096&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShape.java 
(original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShape.java Wed 
Feb  8 01:12:22 2017
@@ -32,6 +32,7 @@ import org.apache.poi.openxml4j.opc.Pack
 import org.apache.poi.sl.draw.DrawFactory;
 import org.apache.poi.sl.draw.DrawPaint;
 import org.apache.poi.sl.usermodel.ColorStyle;
+import org.apache.poi.sl.usermodel.MasterSheet;
 import org.apache.poi.sl.usermodel.PaintStyle;
 import org.apache.poi.sl.usermodel.PaintStyle.GradientPaint;
 import org.apache.poi.sl.usermodel.PaintStyle.TexturePaint;
@@ -57,6 +58,7 @@ import org.openxmlformats.schemas.drawin
 import org.openxmlformats.schemas.drawingml.x2006.main.CTStyleMatrix;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTStyleMatrixReference;
 import org.openxmlformats.schemas.drawingml.x2006.main.STPathShadeType;
+import org.openxmlformats.schemas.drawingml.x2006.main.STSchemeColorVal;
 import 
org.openxmlformats.schemas.presentationml.x2006.main.CTApplicationNonVisualDrawingProps;
 import 
org.openxmlformats.schemas.presentationml.x2006.main.CTBackgroundProperties;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTPlaceholder;
@@ -150,6 +152,7 @@ public abstract class XSLFShape implemen
     
     protected PaintStyle getFillPaint() {
         final XSLFTheme theme = getSheet().getTheme();
+        final boolean hasPlaceholder = getPlaceholder() != null;
         PropertyFetcher<PaintStyle> fetcher = new 
PropertyFetcher<PaintStyle>() {
             public boolean fetch(XSLFShape shape) {
                 XSLFFillProperties fp = 
XSLFPropertiesDelegate.getFillDelegate(shape.getShapeProperties());
@@ -163,7 +166,7 @@ public abstract class XSLFShape implemen
                 }
                 
                 PackagePart pp = shape.getSheet().getPackagePart();
-                PaintStyle paint = selectPaint(fp, null, pp, theme);
+                PaintStyle paint = selectPaint(fp, null, pp, theme, 
hasPlaceholder);
                 if (paint != null) {
                     setValue(paint);
                     return true;
@@ -172,7 +175,7 @@ public abstract class XSLFShape implemen
                 CTShapeStyle style = shape.getSpStyle();
                 if (style != null) {
                     fp = 
XSLFPropertiesDelegate.getFillDelegate(style.getFillRef());
-                    paint = selectPaint(fp, null, pp, theme);
+                    paint = selectPaint(fp, null, pp, theme, hasPlaceholder);
                 }
                 if (paint != null) {
                     setValue(paint);
@@ -230,6 +233,9 @@ public abstract class XSLFShape implemen
         if (cur.toChild(namespace, nodename)) {
             child = (T)cur.getObject();
         }
+        if 
(cur.toChild("http://schemas.openxmlformats.org/drawingml/2006/main";, 
nodename)) {
+            child = (T)cur.getObject();
+        }
         cur.dispose();
         return child;
     }
@@ -290,61 +296,71 @@ public abstract class XSLFShape implemen
     }
 
     /**
-     * Walk up the inheritance tree and fetch shape properties.
+     * Walk up the inheritance tree and fetch shape properties.<p>
      *
-     * The following order of inheritance is assumed:
-     * <p>
-     * slide <-- slideLayout <-- slideMaster
-     * </p>
+     * The following order of inheritance is assumed:<p>
+     * <ol>
+     * <li>slide
+     * <li>slideLayout
+     * <li>slideMaster
+     * </ol>
+     * 
+     * Currently themes and their defaults aren't correctly handled
      *
      * @param visitor the object that collects the desired property
      * @return true if the property was fetched
      */
     protected boolean fetchShapeProperty(PropertyFetcher<?> visitor) {
-        boolean ok = visitor.fetch(this);
+        // try shape properties in slide
+        if (visitor.fetch(this)) {
+            return true;
+        }
 
-        XSLFSimpleShape masterShape;
-        XSLFSheet masterSheet = (XSLFSheet)getSheet().getMasterSheet();
         CTPlaceholder ph = getCTPlaceholder();
-
-        if (masterSheet != null && ph != null) {
-            if (!ok) {
-                masterShape = masterSheet.getPlaceholder(ph);
-                if (masterShape != null) {
-                    ok = visitor.fetch(masterShape);
-                }
+        if (ph == null) {
+            return false;
+        }
+        MasterSheet<XSLFShape,XSLFTextParagraph> sm = 
getSheet().getMasterSheet();
+        
+        // try slide layout
+        if (sm instanceof XSLFSlideLayout) {
+            XSLFSlideLayout slideLayout = (XSLFSlideLayout)sm;
+            XSLFSimpleShape placeholderShape = slideLayout.getPlaceholder(ph);
+            if (placeholderShape != null && visitor.fetch(placeholderShape)) {
+                return true;
             }
-
-            // try slide master
-            if (!ok ) {
-                int textType;
-                if ( !ph.isSetType()) textType = STPlaceholderType.INT_BODY;
-                else {
-                    switch (ph.getType().intValue()) {
-                        case STPlaceholderType.INT_TITLE:
-                        case STPlaceholderType.INT_CTR_TITLE:
-                            textType = STPlaceholderType.INT_TITLE;
-                            break;
-                        case STPlaceholderType.INT_FTR:
-                        case STPlaceholderType.INT_SLD_NUM:
-                        case STPlaceholderType.INT_DT:
-                            textType = ph.getType().intValue();
-                            break;
-                        default:
-                            textType = STPlaceholderType.INT_BODY;
-                            break;
-                    }
-                }
-                XSLFSheet master = (XSLFSheet)masterSheet.getMasterSheet();
-                if (master != null) {
-                    masterShape = master.getPlaceholderByType(textType);
-                    if (masterShape != null) {
-                        ok = visitor.fetch(masterShape);
-                    }
-                }
+            sm = slideLayout.getMasterSheet();
+        }
+        
+        // try slide master
+        if (sm instanceof XSLFSlideMaster) {
+            XSLFSlideMaster master = (XSLFSlideMaster)sm;
+            int textType = getPlaceholderType(ph);
+            XSLFSimpleShape masterShape = 
master.getPlaceholderByType(textType);
+            if (masterShape != null && visitor.fetch(masterShape)) {
+                return true;
             }
         }
-        return ok;
+        
+        return false;
+    }
+    
+    private static int getPlaceholderType(CTPlaceholder ph) {
+        if ( !ph.isSetType()) {
+            return STPlaceholderType.INT_BODY;
+        }
+        
+        switch (ph.getType().intValue()) {
+            case STPlaceholderType.INT_TITLE:
+            case STPlaceholderType.INT_CTR_TITLE:
+                return STPlaceholderType.INT_TITLE;
+            case STPlaceholderType.INT_FTR:
+            case STPlaceholderType.INT_SLD_NUM:
+            case STPlaceholderType.INT_DT:
+                return ph.getType().intValue();
+            default:
+                return STPlaceholderType.INT_BODY;
+        }
     }
 
     /**
@@ -358,7 +374,7 @@ public abstract class XSLFShape implemen
      *
      * @return  the applied Paint or null if none was applied
      */
-    protected static PaintStyle selectPaint(XSLFFillProperties fp, final 
CTSchemeColor phClr, final PackagePart parentPart, final XSLFTheme theme) {
+    protected static PaintStyle selectPaint(XSLFFillProperties fp, final 
CTSchemeColor phClr, final PackagePart parentPart, final XSLFTheme theme, 
boolean hasPlaceholder) {
         if (fp == null || fp.isSetNoFill()) {
             return null;
         } else if (fp.isSetSolidFill()) {
@@ -368,15 +384,23 @@ public abstract class XSLFShape implemen
         } else if (fp.isSetGradFill()) {
             return selectPaint(fp.getGradFill(), phClr, theme);
         } else if (fp.isSetMatrixStyle()) {
-            return selectPaint(fp.getMatrixStyle(), theme, fp.isLineStyle());
+            return selectPaint(fp.getMatrixStyle(), theme, fp.isLineStyle(), 
hasPlaceholder);
         } else {
             return null;
         }
     }
 
     protected static PaintStyle selectPaint(CTSolidColorFillProperties 
solidFill, CTSchemeColor phClr, final XSLFTheme theme) {
-        if (phClr == null && solidFill.isSetSchemeClr()) {
-            phClr = solidFill.getSchemeClr();
+        if (solidFill.isSetSchemeClr()) {
+               // if there's a reference to the placeholder color,
+               // stop evaluating further and let the caller select
+               // the next style inheritance level
+            if 
(STSchemeColorVal.PH_CLR.equals(solidFill.getSchemeClr().getVal())) {
+                return null;
+            }
+            if (phClr == null) {
+                phClr = solidFill.getSchemeClr();
+            }
         }
         final XSLFColor c = new XSLFColor(solidFill, theme, phClr);
         return DrawPaint.createSolidPaint(c.getColorStyle());
@@ -483,7 +507,7 @@ public abstract class XSLFShape implemen
         };        
     }
     
-    protected static PaintStyle selectPaint(CTStyleMatrixReference fillRef, 
final XSLFTheme theme, boolean isLineStyle) {
+    protected static PaintStyle selectPaint(CTStyleMatrixReference fillRef, 
final XSLFTheme theme, boolean isLineStyle, boolean hasPlaceholder) {
         if (fillRef == null) return null;
         
         // The idx attribute refers to the index of a fill style or
@@ -492,7 +516,6 @@ public abstract class XSLFShape implemen
         // values 1-999 refer to the index of a fill style within the 
fillStyleLst element
         // values 1001 and above refer to the index of a background fill style 
within the bgFillStyleLst element.
         int idx = (int)fillRef.getIdx();
-        CTSchemeColor phClr = fillRef.getSchemeClr();
         CTStyleMatrix matrix = 
theme.getXmlObject().getThemeElements().getFmtScheme();
         final XmlObject styleLst;
         int childIdx;
@@ -511,8 +534,16 @@ public abstract class XSLFShape implemen
             fp = XSLFPropertiesDelegate.getFillDelegate(cur.getObject());
         }
         cur.dispose();
-        
-        return selectPaint(fp, phClr, theme.getPackagePart(), theme);
+            
+        CTSchemeColor phClr = fillRef.getSchemeClr();
+        PaintStyle res =  selectPaint(fp, phClr, theme.getPackagePart(), 
theme, hasPlaceholder);
+        // check for empty placeholder value
+        // see http://officeopenxml.com/prSlide-color.php - "Color 
Placeholders within Themes"
+        if (res != null || hasPlaceholder) {
+            return res;
+        }
+        XSLFColor col = new XSLFColor(fillRef, theme, phClr);
+        return DrawPaint.createSolidPaint(col.getColorStyle());
     }
     
     @Override

Modified: 
poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSimpleShape.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSimpleShape.java?rev=1782096&r1=1782095&r2=1782096&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSimpleShape.java 
(original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSimpleShape.java 
Wed Feb  8 01:12:22 2017
@@ -121,6 +121,7 @@ public abstract class XSLFSimpleShape ex
 
     protected CTTransform2D getXfrm(boolean create) {
         PropertyFetcher<CTTransform2D> fetcher = new 
PropertyFetcher<CTTransform2D>() {
+            @Override
             public boolean fetch(XSLFShape shape) {
                 XmlObject xo = shape.getShapeProperties();
                 if (xo instanceof CTShapeProperties && 
((CTShapeProperties)xo).isSetXfrm()) {
@@ -234,20 +235,32 @@ public abstract class XSLFSimpleShape ex
      */
     CTLineProperties getDefaultLineProperties() {
         CTShapeStyle style = getSpStyle();
-        if (style == null) return null;
+        if (style == null) {
+            return null;
+        }
         CTStyleMatrixReference lnRef = style.getLnRef();
-        if (lnRef == null) return null;
+        if (lnRef == null) {
+            return null;
+        }
         // 1-based index of a line style within the style matrix
         int idx = (int)lnRef.getIdx();
 
         XSLFTheme theme = getSheet().getTheme();
-        if (theme == null) return null;
+        if (theme == null) {
+            return null;
+        }
         CTBaseStyles styles = theme.getXmlObject().getThemeElements();
-        if (styles == null) return null;
+        if (styles == null) {
+            return null;
+        }
         CTStyleMatrix styleMatrix = styles.getFmtScheme();
-        if (styleMatrix == null) return null;
+        if (styleMatrix == null) {
+            return null;
+        }
         CTLineStyleList lineStyles = styleMatrix.getLnStyleLst();
-        if (lineStyles == null || lineStyles.sizeOfLnArray() < idx) return 
null;
+        if (lineStyles == null || lineStyles.sizeOfLnArray() < idx) {
+            return null;
+        }
 
         return lineStyles.getLnArray(idx - 1);
     }
@@ -301,12 +314,14 @@ public abstract class XSLFSimpleShape ex
     protected PaintStyle getLinePaint() {
         XSLFSheet sheet = getSheet();
         final XSLFTheme theme = sheet.getTheme();
+        final boolean hasPlaceholder = getPlaceholder() != null;
         PropertyFetcher<PaintStyle> fetcher = new 
PropertyFetcher<PaintStyle>() {
+            @Override
             public boolean fetch(XSLFShape shape) {
                 CTLineProperties spPr = getLn(shape, false);
                 XSLFFillProperties fp = 
XSLFPropertiesDelegate.getFillDelegate(spPr);
                 PackagePart pp = shape.getSheet().getPackagePart();
-                PaintStyle paint = selectPaint(fp, null, pp, theme);
+                PaintStyle paint = selectPaint(fp, null, pp, theme, 
hasPlaceholder);
                 if (paint != null) {
                     setValue(paint);
                     return true;
@@ -315,7 +330,7 @@ public abstract class XSLFSimpleShape ex
                 CTShapeStyle style = shape.getSpStyle();
                 if (style != null) {
                     fp = 
XSLFPropertiesDelegate.getFillDelegate(style.getLnRef());
-                    paint = selectPaint(fp, null, pp, theme);
+                    paint = selectPaint(fp, null, pp, theme, hasPlaceholder);
                 }
                 if (paint != null) {
                     setValue(paint);
@@ -327,11 +342,15 @@ public abstract class XSLFSimpleShape ex
         fetchShapeProperty(fetcher);
 
         PaintStyle paint = fetcher.getValue();
-        if (paint != null) return paint;
+        if (paint != null) {
+            return paint;
+        }
 
         // line color was not found, check if it is defined in the theme
         CTShapeStyle style = getSpStyle();
-        if (style == null) return null;
+        if (style == null) {
+            return null;
+        }
 
         // get a reference to a line style within the style matrix.
         CTStyleMatrixReference lnRef = style.getLnRef();
@@ -341,7 +360,7 @@ public abstract class XSLFSimpleShape ex
             CTLineProperties props = 
theme.getXmlObject().getThemeElements().getFmtScheme().getLnStyleLst().getLnArray(idx
 - 1);
             XSLFFillProperties fp = 
XSLFPropertiesDelegate.getFillDelegate(props);
             PackagePart pp = sheet.getPackagePart();
-            paint = selectPaint(fp, phClr, pp, theme);
+            paint = selectPaint(fp, phClr, pp, theme, hasPlaceholder);
         }
 
         return paint;
@@ -387,6 +406,7 @@ public abstract class XSLFSimpleShape ex
      */
     public double getLineWidth() {
         PropertyFetcher<Double> fetcher = new PropertyFetcher<Double>() {
+            @Override
             public boolean fetch(XSLFShape shape) {
                 CTLineProperties ln = getLn(shape, false);
                 if (ln != null) {
@@ -409,7 +429,9 @@ public abstract class XSLFSimpleShape ex
         if (fetcher.getValue() == null) {
             CTLineProperties defaultLn = getDefaultLineProperties();
             if (defaultLn != null) {
-                if (defaultLn.isSetW()) lineWidth = 
Units.toPoints(defaultLn.getW());
+                if (defaultLn.isSetW()) {
+                    lineWidth = Units.toPoints(defaultLn.getW());
+                }
             }
         } else {
             lineWidth = fetcher.getValue();
@@ -460,6 +482,7 @@ public abstract class XSLFSimpleShape ex
      */
     public LineCompound getLineCompound() {
         PropertyFetcher<Integer> fetcher = new PropertyFetcher<Integer>() {
+            @Override
             public boolean fetch(XSLFShape shape) {
                 CTLineProperties ln = getLn(shape, false);
                 if (ln != null) {
@@ -522,6 +545,7 @@ public abstract class XSLFSimpleShape ex
     public LineDash getLineDash() {
 
         PropertyFetcher<LineDash> fetcher = new PropertyFetcher<LineDash>() {
+            @Override
             public boolean fetch(XSLFShape shape) {
                 CTLineProperties ln = getLn(shape, false);
                 if (ln == null || !ln.isSetPrstDash()) {
@@ -569,6 +593,7 @@ public abstract class XSLFSimpleShape ex
      */
     public LineCap getLineCap() {
         PropertyFetcher<LineCap> fetcher = new PropertyFetcher<LineCap>() {
+            @Override
             public boolean fetch(XSLFShape shape) {
                 CTLineProperties ln = getLn(shape, false);
                 if (ln != null && ln.isSetCap()) {
@@ -640,8 +665,10 @@ public abstract class XSLFSimpleShape ex
     /**
      * @return shadow of this shape or null if shadow is disabled
      */
+    @Override
     public XSLFShadow getShadow() {
         PropertyFetcher<CTOuterShadowEffect> fetcher = new 
PropertyFetcher<CTOuterShadowEffect>() {
+            @Override
             public boolean fetch(XSLFShape shape) {
                 XSLFEffectProperties ep = 
XSLFPropertiesDelegate.getEffectDelegate(shape.getShapeProperties());
                 if (ep != null && ep.isSetEffectLst()) {
@@ -675,6 +702,7 @@ public abstract class XSLFSimpleShape ex
      *
      * @return definition of the shape geometry
      */
+    @Override
     public CustomGeometry getGeometry() {
         XSLFGeometryProperties gp = 
XSLFPropertiesDelegate.getGeometryDelegate(getShapeProperties());
         
@@ -949,6 +977,7 @@ public abstract class XSLFSimpleShape ex
         return ph != null;
     }
 
+    @Override
     public Guide getAdjustValue(String name) {
         XSLFGeometryProperties gp = 
XSLFPropertiesDelegate.getGeometryDelegate(getShapeProperties());
         
@@ -963,28 +992,35 @@ public abstract class XSLFSimpleShape ex
         return null;
     }
 
+    @Override
     public LineDecoration getLineDecoration() {
         return new LineDecoration() {
+            @Override
             public DecorationShape getHeadShape() {
                 return getLineHeadDecoration();
             }
 
+            @Override
             public DecorationSize getHeadWidth() {
                 return getLineHeadWidth();
             }
 
+            @Override
             public DecorationSize getHeadLength() {
                 return getLineHeadLength();
             }
 
+            @Override
             public DecorationShape getTailShape() {
                 return getLineTailDecoration();
             }
 
+            @Override
             public DecorationSize getTailWidth() {
                 return getLineTailWidth();
             }
 
+            @Override
             public DecorationSize getTailLength() {
                 return getLineTailLength();
             }
@@ -996,32 +1032,40 @@ public abstract class XSLFSimpleShape ex
      *
      * @return either Color or GradientPaint or TexturePaint or null
      */
+    @Override
     public FillStyle getFillStyle() {
         return new FillStyle() {
+            @Override
             public PaintStyle getPaint() {
                 return XSLFSimpleShape.this.getFillPaint();
             }
         };
     }
 
+    @Override
     public StrokeStyle getStrokeStyle() {
         return new StrokeStyle() {
+            @Override
             public PaintStyle getPaint() {
                 return XSLFSimpleShape.this.getLinePaint();
             }
 
+            @Override
             public LineCap getLineCap() {
                 return XSLFSimpleShape.this.getLineCap();
             }
 
+            @Override
             public LineDash getLineDash() {
                 return XSLFSimpleShape.this.getLineDash();
             }
 
+            @Override
             public double getLineWidth() {
                 return XSLFSimpleShape.this.getLineWidth();
             }
 
+            @Override
             public LineCompound getLineCompound() {
                 return XSLFSimpleShape.this.getLineCompound();
             }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java?rev=1782096&r1=1782095&r2=1782096&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java 
(original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java Wed 
Feb  8 01:12:22 2017
@@ -207,7 +207,7 @@ implements Slide<XSLFShape,XSLFTextParag
 
     @Override
     public boolean getFollowMasterGraphics(){
-        return _slide.isSetShowMasterSp() && _slide.getShowMasterSp();
+        return _slide.getShowMasterSp();
     }
 
     /**
@@ -306,4 +306,9 @@ implements Slide<XSLFShape,XSLFTextParag
         Drawable draw = drawFact.getDrawable(this);
         draw.draw(graphics);
     }
+
+    @Override
+    public boolean getDisplayPlaceholder(Placeholder placeholder) {
+        return false;
+    }
 }

Modified: 
poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideLayout.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideLayout.java?rev=1782096&r1=1782095&r2=1782096&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideLayout.java 
(original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideLayout.java 
Wed Feb  8 01:12:22 2017
@@ -104,7 +104,7 @@ implements MasterSheet<XSLFShape,XSLFTex
 
     @Override
     public boolean getFollowMasterGraphics() {
-        return _layout.isSetShowMasterSp() && _layout.getShowMasterSp();
+        return _layout.getShowMasterSp();
     }
 
     /**

Modified: 
poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTableCell.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTableCell.java?rev=1782096&r1=1782095&r2=1782096&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTableCell.java 
(original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTableCell.java 
Wed Feb  8 01:12:22 2017
@@ -145,7 +145,9 @@ public class XSLFTableCell extends XSLFT
         }
 
         CTTableCellProperties pr = getCellProperties(create);
-        if (pr == null) return null;
+        if (pr == null) {
+            return null;
+        }
 
         switch (edge) {
             case bottom:
@@ -164,7 +166,9 @@ public class XSLFTableCell extends XSLFT
     @Override
     public void removeBorder(BorderEdge edge) {
         CTTableCellProperties pr = getCellProperties(false);
-        if (pr == null) return;
+        if (pr == null) {
+            return;
+        }
         switch (edge) {
             case bottom:
                 if (pr.isSetLnB()) {
@@ -195,22 +199,27 @@ public class XSLFTableCell extends XSLFT
     public StrokeStyle getBorderStyle(final BorderEdge edge) {
         final Double width = getBorderWidth(edge);
         return (width == null) ? null : new StrokeStyle() {
+            @Override
             public PaintStyle getPaint() {
                 return DrawPaint.createSolidPaint(getBorderColor(edge));
             }
 
+            @Override
             public LineCap getLineCap() {
                 return getBorderCap(edge);
             }
 
+            @Override
             public LineDash getLineDash() {
                 return getBorderDash(edge);
             }
 
+            @Override
             public LineCompound getLineCompound() {
                 return getBorderCompound(edge);
             }
 
+            @Override
             public double getLineWidth() {
                 return width;
             }
@@ -306,7 +315,9 @@ public class XSLFTableCell extends XSLFT
 
     public Color getBorderColor(BorderEdge edge) {
         CTLineProperties ln = getCTLine(edge, false);
-        if (ln == null || ln.isSetNoFill() || !ln.isSetSolidFill()) return 
null;
+        if (ln == null || ln.isSetNoFill() || !ln.isSetSolidFill()) {
+            return null;
+        }
 
         CTSolidColorFillProperties fill = ln.getSolidFill();
         XSLFColor c = new XSLFColor(fill, getSheet().getTheme(), 
fill.getSchemeClr());
@@ -381,7 +392,9 @@ public class XSLFTableCell extends XSLFT
     public void setFillColor(Color color) {
         CTTableCellProperties spPr = getCellProperties(true);
         if (color == null) {
-            if(spPr.isSetSolidFill()) spPr.unsetSolidFill();
+            if(spPr.isSetSolidFill()) {
+                spPr.unsetSolidFill();
+            }
         } else {
             CTSolidColorFillProperties fill = spPr.isSetSolidFill() ? 
spPr.getSolidFill() : spPr.addNewSolidFill();
             XSLFColor c = new XSLFColor(fill, getSheet().getTheme(), 
fill.getSchemeClr());
@@ -409,10 +422,11 @@ public class XSLFTableCell extends XSLFT
     public PaintStyle getFillPaint() {
         XSLFSheet sheet = getSheet();
         XSLFTheme theme = sheet.getTheme();
+        final boolean hasPlaceholder = getPlaceholder() != null;
         XmlObject props = getCellProperties(false);
         XSLFFillProperties fp = XSLFPropertiesDelegate.getFillDelegate(props);
         if (fp != null) {
-            PaintStyle paint = selectPaint(fp, null, sheet.getPackagePart(), 
theme);
+            PaintStyle paint = selectPaint(fp, null, sheet.getPackagePart(), 
theme, hasPlaceholder);
             if (paint != null) {
                 return paint;
             }
@@ -438,7 +452,7 @@ public class XSLFTableCell extends XSLFT
         
         fp = XSLFPropertiesDelegate.getFillDelegate(props);
         if (fp != null)  {
-            PaintStyle paint = XSLFShape.selectPaint(fp, null, 
slideShow.getPackagePart(), theme);
+            PaintStyle paint = XSLFShape.selectPaint(fp, null, 
slideShow.getPackagePart(), theme, hasPlaceholder);
             if (paint != null) {
                 return paint;
             }

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=1782096&r1=1782095&r2=1782096&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 Feb  8 01:12:22 2017
@@ -72,23 +72,20 @@ public class XSLFTextParagraph implement
         _runs = new ArrayList<XSLFTextRun>();
         _shape = shape;
 
-        for(XmlObject ch : _p.selectPath("*")){
-            if(ch instanceof CTRegularTextRun){
-                CTRegularTextRun r = (CTRegularTextRun)ch;
-                _runs.add(newTextRun(r));
-            } else if (ch instanceof CTTextLineBreak){
-                CTTextLineBreak br = (CTTextLineBreak)ch;
-                CTRegularTextRun r = CTRegularTextRun.Factory.newInstance();
-                r.setRPr(br.getRPr());
-                r.setT("\n");
-                _runs.add(newTextRun(r));
-            } else if (ch instanceof CTTextField){
-                CTTextField f = (CTTextField)ch;
-                CTRegularTextRun r = CTRegularTextRun.Factory.newInstance();
-                r.setRPr(f.getRPr());
-                r.setT(f.getT());
-                _runs.add(newTextRun(r));
+        XmlCursor c = _p.newCursor();
+        try {
+            if (c.toFirstChild()) {
+                do {
+                    XmlObject r = c.getObject();
+                    if (r instanceof CTTextLineBreak) {
+                        _runs.add(new XSLFLineBreak((CTTextLineBreak)r, this));
+                    } else if (r instanceof CTRegularTextRun || r instanceof 
CTTextField) {
+                        _runs.add(new XSLFTextRun(r, this));
+                    }
+                } while (c.toNextSibling());
             }
+        } finally {
+            c.dispose();
         }
     }
 
@@ -147,17 +144,13 @@ public class XSLFTextParagraph implement
      * @return text run representing this line break ('\n')
      */
     public XSLFTextRun addLineBreak(){
-        CTTextLineBreak br = _p.addNewBr();
-        CTTextCharacterProperties brProps = br.addNewRPr();
+        XSLFLineBreak run = new XSLFLineBreak(_p.addNewBr(), this);
+        CTTextCharacterProperties brProps = run.getRPr(true);
         if(_runs.size() > 0){
             // by default line break has the font size of the last text run
             CTTextCharacterProperties prevRun = _runs.get(_runs.size() - 
1).getRPr(true);
             brProps.set(prevRun);
         }
-        CTRegularTextRun r = CTRegularTextRun.Factory.newInstance();
-        r.setRPr(brProps);
-        r.setT("\n");
-        XSLFTextRun run = new XSLFLineBreak(r, this, brProps);
         _runs.add(run);
         return run;
     }

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=1782096&r1=1782095&r2=1782096&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 
Feb  8 01:12:22 2017
@@ -18,6 +18,7 @@ package org.apache.poi.xslf.usermodel;
 
 import java.awt.Color;
 
+import org.apache.poi.openxml4j.exceptions.OpenXML4JRuntimeException;
 import org.apache.poi.openxml4j.opc.PackagePart;
 import org.apache.poi.sl.draw.DrawPaint;
 import org.apache.poi.sl.usermodel.PaintStyle;
@@ -26,13 +27,16 @@ import org.apache.poi.sl.usermodel.TextR
 import org.apache.poi.util.Beta;
 import org.apache.poi.xslf.model.CharacterPropertyFetcher;
 import org.apache.poi.xslf.usermodel.XSLFPropertiesDelegate.XSLFFillProperties;
+import org.apache.xmlbeans.XmlObject;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTHyperlink;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTRegularTextRun;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTShapeStyle;
 import 
org.openxmlformats.schemas.drawingml.x2006.main.CTSolidColorFillProperties;
 import 
org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTTextField;
 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;
@@ -45,12 +49,15 @@ import org.openxmlformats.schemas.presen
  */
 @Beta
 public class XSLFTextRun implements TextRun {
-    private final CTRegularTextRun _r;
+    private final XmlObject _r;
     private final XSLFTextParagraph _p;
 
-    protected XSLFTextRun(CTRegularTextRun r, XSLFTextParagraph p){
+    protected XSLFTextRun(XmlObject r, XSLFTextParagraph p){
         _r = r;
         _p = p;
+        if (!(r instanceof CTRegularTextRun || r instanceof CTTextLineBreak || 
r instanceof CTTextField)) {
+            throw new OpenXML4JRuntimeException("unsupported text run of type 
"+r.getClass());
+        }
     }
 
     XSLFTextParagraph getParentParagraph(){
@@ -58,11 +65,28 @@ public class XSLFTextRun implements Text
     }
 
     public String getRawText(){
-        return _r.getT();
+        if (_r instanceof CTTextField) {
+            return ((CTTextField)_r).getT();
+        } else if (_r instanceof CTTextLineBreak) {
+            return "\n";
+        }
+        return ((CTRegularTextRun)_r).getT();
     }
 
     String getRenderableText(){
-        String txt = _r.getT();
+        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";
+        }
+        
+        
+        String txt = ((CTRegularTextRun)_r).getT();
         TextCap cap = getTextCap();
         StringBuffer buf = new StringBuffer();
         for(int i = 0; i < txt.length(); i++) {
@@ -88,10 +112,24 @@ public class XSLFTextRun implements Text
     }
 
     public void setText(String text){
-        _r.setT(text);
+        if (_r instanceof CTTextField) {
+            ((CTTextField)_r).setT(text);
+        } else if (_r instanceof CTTextLineBreak) {
+            // ignored
+            return;
+        } else {
+            ((CTRegularTextRun)_r).setT(text);
+        }
     }
 
-    public CTRegularTextRun getXmlObject(){
+    /**
+     * Return the text run xmlbeans object.
+     * Depending on the type of text run, this can be {@link CTTextField},
+     * {@link CTTextLineBreak} or usually a {@link CTRegularTextRun}
+     *
+     * @return the xmlbeans object
+     */
+    public XmlObject getXmlObject(){
         return _r;
     }
 
@@ -117,6 +155,7 @@ public class XSLFTextRun implements Text
 
     @Override
     public PaintStyle getFontColor(){
+        final boolean hasPlaceholder = 
getParentParagraph().getParentShape().getPlaceholder() != null;
         CharacterPropertyFetcher<PaintStyle> fetcher = new 
CharacterPropertyFetcher<PaintStyle>(_p.getIndentLevel()){
             public boolean fetch(CTTextCharacterProperties props){
                 if (props == null) {
@@ -134,7 +173,7 @@ public class XSLFTextRun implements Text
                 XSLFSheet sheet = shape.getSheet();
                 PackagePart pp = sheet.getPackagePart();
                 XSLFTheme theme = sheet.getTheme();
-                PaintStyle ps = XSLFShape.selectPaint(fp, phClr, pp, theme);
+                PaintStyle ps = XSLFShape.selectPaint(fp, phClr, pp, theme, 
hasPlaceholder);
                 
                 if (ps != null)  {
                     setValue(ps);
@@ -459,13 +498,29 @@ public class XSLFTextRun implements Text
      * @return the character properties or null if create was false and the 
properties haven't exist
      */
     protected CTTextCharacterProperties getRPr(boolean create) {
-        if (_r.isSetRPr()) {
-            return _r.getRPr();
-        } else if (create) {
-            return _r.addNewRPr();
+        if (_r instanceof CTTextField) {
+            CTTextField tf = (CTTextField)_r;
+            if (tf.isSetRPr()) {
+                return tf.getRPr();
+            } else if (create) {
+                return tf.addNewRPr();
+            }
+        } else if (_r instanceof CTTextLineBreak) {
+            CTTextLineBreak tlb = (CTTextLineBreak)_r;
+            if (tlb.isSetRPr()) {
+                return tlb.getRPr();
+            } else if (create) {
+                return tlb.addNewRPr();
+            }
         } else {
-            return null;
+            CTRegularTextRun tr = (CTRegularTextRun)_r;
+            if (tr.isSetRPr()) {
+                return tr.getRPr();
+            } else if (create) {
+                return tr.addNewRPr();
+            }
         }
+        return null;
     }
 
     @Override
@@ -476,15 +531,17 @@ public class XSLFTextRun implements Text
     @Override
     public XSLFHyperlink createHyperlink(){
         XSLFHyperlink hl = getHyperlink();
-        if (hl == null) {
-            hl = new XSLFHyperlink(_r.getRPr().addNewHlinkClick(), 
_p.getParentShape().getSheet());
+        if (hl != null) {
+            return hl;
         }
-        return hl;
+
+        CTTextCharacterProperties rPr = getRPr(true);
+        return new XSLFHyperlink(rPr.addNewHlinkClick(), 
_p.getParentShape().getSheet());
     }
 
     @Override
     public XSLFHyperlink getHyperlink(){
-        CTTextCharacterProperties rPr = _r.getRPr();
+        CTTextCharacterProperties rPr = getRPr(false);
         if (rPr == null) { 
             return null;
         }
@@ -498,33 +555,33 @@ public class XSLFTextRun implements Text
     private boolean fetchCharacterProperty(CharacterPropertyFetcher<?> 
fetcher){
         XSLFTextShape shape = _p.getParentShape();
         XSLFSheet sheet = shape.getSheet();
-        boolean ok = false;
 
-        if (_r.isSetRPr()) ok = fetcher.fetch(getRPr(false));
-        if (ok) return true;
+        CTTextCharacterProperties rPr = getRPr(false);
+        if (rPr != null && fetcher.fetch(rPr)) {
+            return true;
+        }
         
-        ok = shape.fetchShapeProperty(fetcher);
-        if (ok) return true;
+        if (shape.fetchShapeProperty(fetcher)) {
+            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();
+            // TODO: determine master shape
             CTTextParagraphProperties themeProps = 
ppt.getDefaultParagraphStyle(_p.getIndentLevel());
-            if (themeProps != null) {
-                // TODO: determine master shape
-                ok = fetcher.fetch(themeProps);
+            if (themeProps != null && fetcher.fetch(themeProps)) {
+                return true;
             }
         }
-        if (ok) return true;
 
+        // TODO: determine master shape
         CTTextParagraphProperties defaultProps =  _p.getDefaultMasterStyle();
-        if(defaultProps != null) {
-            // TODO: determine master shape
-            ok = fetcher.fetch(defaultProps);
+        if(defaultProps != null && fetcher.fetch(defaultProps)) {
+            return true;
         }
-        if (ok) return true;
 
         return false;
     }
@@ -557,4 +614,16 @@ public class XSLFTextRun implements Text
         boolean strike = r.isStrikethrough();
         if(strike != isStrikethrough()) setStrikethrough(strike);
     }
+    
+    
+    @Override
+    public FieldType getFieldType() {
+        if (_r instanceof CTTextField) {
+            CTTextField tf = (CTTextField)_r;
+            if ("slidenum".equals(tf.getType())) {
+                return FieldType.SLIDE_NUMBER;
+            }
+        }
+        return null;
+    }
 }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTheme.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTheme.java?rev=1782096&r1=1782095&r2=1782096&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTheme.java 
(original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTheme.java Wed 
Feb  8 01:12:22 2017
@@ -169,5 +169,4 @@ public class XSLFTheme extends POIXMLDoc
         }
         return null;
     }
-
 }

Modified: 
poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/TestXSLFSlideShow.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/TestXSLFSlideShow.java?rev=1782096&r1=1782095&r2=1782096&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/TestXSLFSlideShow.java 
(original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/TestXSLFSlideShow.java 
Wed Feb  8 01:12:22 2017
@@ -108,7 +108,8 @@ public class TestXSLFSlideShow {
                // And again for the master
                CTSlideMasterIdListEntry[] masters = 
xml.getSlideMasterReferences().getSldMasterIdArray();
                
-               assertEquals(2147483648l, masters[0].getId());
+               // see SlideAtom.USES_MASTER_SLIDE_ID
+               assertEquals(0x80000000L, masters[0].getId());
                assertEquals("rId1", masters[0].getId2());
                assertNotNull(xml.getSlideMaster(masters[0]));
                

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=1782096&r1=1782095&r2=1782096&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 Feb  8 01:12:22 2017
@@ -105,7 +105,8 @@ public class TestXMLSlideShow extends Ba
       // Next up look for the slide master
       CTSlideMasterIdListEntry[] masters = 
xml.getCTPresentation().getSldMasterIdLst().getSldMasterIdArray();
 
-      assertEquals(2147483648l, masters[0].getId());
+      // see SlideAtom.USES_MASTER_SLIDE_ID
+      assertEquals(0x80000000L, masters[0].getId());
       assertEquals("rId1", masters[0].getId2());
       assertNotNull(xml.getSlideMasters().get(0));
 

Modified: 
poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFAutoShape.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFAutoShape.java?rev=1782096&r1=1782095&r2=1782096&view=diff
==============================================================================
--- 
poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFAutoShape.java
 (original)
+++ 
poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFAutoShape.java
 Wed Feb  8 01:12:22 2017
@@ -16,22 +16,26 @@
 ==================================================================== */
 package org.apache.poi.xslf.usermodel;
 
-import static org.junit.Assert.*;
+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.assertSame;
+import static org.junit.Assert.assertTrue;
 
 import java.io.IOException;
 
-import org.apache.poi.sl.usermodel.*;
+import org.apache.poi.sl.usermodel.ShapeType;
 import org.apache.poi.sl.usermodel.TextParagraph.TextAlign;
 import org.apache.poi.sl.usermodel.TextShape.TextAutofit;
 import org.apache.poi.sl.usermodel.TextShape.TextDirection;
+import org.apache.poi.sl.usermodel.VerticalAlignment;
 import org.apache.poi.util.Units;
 import org.junit.Test;
+import 
org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties;
 import org.openxmlformats.schemas.drawingml.x2006.main.STTextStrikeType;
 import org.openxmlformats.schemas.drawingml.x2006.main.STTextUnderlineType;
 
-/**
- * @author Yegor Kozlov
- */
 public class TestXSLFAutoShape {
     @Test
     public void testTextBodyProperies() throws IOException {
@@ -222,56 +226,58 @@ public class TestXSLFAutoShape {
         assertEquals(1, shape.getTextParagraphs().size());
         assertEquals(0, p.getTextRuns().size());
         XSLFTextRun r = p.addNewTextRun();
+        CTTextCharacterProperties rPr = r.getRPr(false);
+        assertNotNull(rPr);
         assertEquals(1, p.getTextRuns().size());
         assertSame(r, p.getTextRuns().get(0));
 
+        
         assertEquals(18.0, r.getFontSize(), 0); // default font size for text 
boxes
-        assertFalse(r.getXmlObject().getRPr().isSetSz());
+        assertFalse(rPr.isSetSz());
         r.setFontSize(10.0);
-        assertTrue(r.getXmlObject().isSetRPr());
-        assertEquals(1000, r.getXmlObject().getRPr().getSz());
+        assertEquals(1000, rPr.getSz());
         r.setFontSize(12.5);
-        assertEquals(1250, r.getXmlObject().getRPr().getSz());
+        assertEquals(1250, rPr.getSz());
         r.setFontSize(null);
-        assertFalse(r.getXmlObject().getRPr().isSetSz());
+        assertFalse(rPr.isSetSz());
 
-        assertFalse(r.getXmlObject().getRPr().isSetLatin());
+        assertFalse(rPr.isSetLatin());
         assertEquals("Calibri", r.getFontFamily()); // comes from the slide 
master
         r.setFontFamily(null);
         assertEquals("Calibri", r.getFontFamily()); // comes from the slide 
master
         r.setFontFamily("Arial");
         assertEquals("Arial", r.getFontFamily());
-        assertEquals("Arial", 
r.getXmlObject().getRPr().getLatin().getTypeface());
+        assertEquals("Arial", rPr.getLatin().getTypeface());
         r.setFontFamily("Symbol");
         assertEquals("Symbol", r.getFontFamily());
-        assertEquals("Symbol", 
r.getXmlObject().getRPr().getLatin().getTypeface());
+        assertEquals("Symbol", rPr.getLatin().getTypeface());
         r.setFontFamily(null);
         assertEquals("Calibri", r.getFontFamily()); // comes from the slide 
master
-        assertFalse(r.getXmlObject().getRPr().isSetLatin());
+        assertFalse(rPr.isSetLatin());
 
         assertFalse(r.isStrikethrough());
-        assertFalse(r.getXmlObject().getRPr().isSetStrike());
+        assertFalse(rPr.isSetStrike());
         r.setStrikethrough(true);
         assertTrue(r.isStrikethrough());
-        assertEquals(STTextStrikeType.SNG_STRIKE, 
r.getXmlObject().getRPr().getStrike());
+        assertEquals(STTextStrikeType.SNG_STRIKE, rPr.getStrike());
 
         assertFalse(r.isBold());
-        assertFalse(r.getXmlObject().getRPr().isSetB());
+        assertFalse(rPr.isSetB());
         r.setBold(true);
         assertTrue(r.isBold());
-        assertEquals(true, r.getXmlObject().getRPr().getB());
+        assertEquals(true, rPr.getB());
 
         assertFalse(r.isItalic());
-        assertFalse(r.getXmlObject().getRPr().isSetI());
+        assertFalse(rPr.isSetI());
         r.setItalic(true);
         assertTrue(r.isItalic());
-        assertEquals(true, r.getXmlObject().getRPr().getI());
+        assertEquals(true, rPr.getI());
 
         assertFalse(r.isUnderlined());
-        assertFalse(r.getXmlObject().getRPr().isSetU());
+        assertFalse(rPr.isSetU());
         r.setUnderlined(true);
         assertTrue(r.isUnderlined());
-        assertEquals(STTextUnderlineType.SNG, 
r.getXmlObject().getRPr().getU());
+        assertEquals(STTextUnderlineType.SNG, rPr.getU());
 
         r.setText("Apache");
         assertEquals("Apache", r.getRawText());

Modified: 
poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFHyperlink.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFHyperlink.java?rev=1782096&r1=1782095&r2=1782096&view=diff
==============================================================================
--- 
poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFHyperlink.java
 (original)
+++ 
poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFHyperlink.java
 Wed Feb  8 01:12:22 2017
@@ -123,10 +123,11 @@ public class TestXSLFHyperlink {
         XSLFTextBox tb3 = sl3.createTextBox();
         tb3.setAnchor(anchor);
         tb3.setText("text1 ");
-        XSLFTextRun r3 = tb3.appendText("lin\u000bk", false);
+        tb3.appendText("lin\u000bk", false);
         tb3.appendText(" text2", false);
-        XSLFHyperlink hl3 = r3.createHyperlink();
-        hl3.linkToSlide(slide1);
+        List<XSLFTextRun> tb3runs = 
tb3.getTextParagraphs().get(0).getTextRuns();
+        tb3runs.get(1).createHyperlink().linkToSlide(slide1); // "lin"
+        tb3runs.get(3).createHyperlink().linkToSlide(slide1); // "k"
         XSLFTextBox tb4 = ppt1.createSlide().createTextBox();
         tb4.setAnchor(anchor);
         XSLFTextRun r4 = tb4.setText("page4");
@@ -155,6 +156,8 @@ public class TestXSLFHyperlink {
         assertEquals(HyperlinkType.DOCUMENT, hl2.getTypeEnum());
 
         tb3 = (XSLFTextBox)slides.get(2).getShapes().get(0);
+        XSLFHyperlink hl3 = 
tb3.getTextParagraphs().get(0).getTextRuns().get(1).getHyperlink();
+        assertNotNull(hl3);
         hl3 = 
tb3.getTextParagraphs().get(0).getTextRuns().get(3).getHyperlink();
         assertNotNull(hl3);
         assertEquals("/ppt/slides/slide1.xml", hl3.getAddress());

Modified: 
poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFShape.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFShape.java?rev=1782096&r1=1782095&r2=1782096&view=diff
==============================================================================
--- 
poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFShape.java 
(original)
+++ 
poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFShape.java 
Wed Feb  8 01:12:22 2017
@@ -16,18 +16,17 @@
 ==================================================================== */
 package org.apache.poi.xslf.usermodel;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.util.List;
 
 import org.apache.poi.xslf.XSLFTestDataSamples;
 import org.junit.Test;
 import org.openxmlformats.schemas.drawingml.x2006.main.STTextUnderlineType;
 
-import java.io.IOException;
-import java.util.List;
-
-/**
- * @author Yegor Kozlov
- */
 public class TestXSLFShape {
 
     @Test
@@ -63,7 +62,7 @@ public class TestXSLFShape {
         assertEquals("PPTX ", r2.get(0).getRawText());
         assertEquals("Title", r2.get(1).getRawText());
         // Title is underlined
-        assertEquals(STTextUnderlineType.SNG, 
r2.get(1).getXmlObject().getRPr().getU());
+        assertEquals(STTextUnderlineType.SNG, r2.get(1).getRPr(false).getU());
 
 
         assertTrue(shapes2.get(1) instanceof XSLFAutoShape);
@@ -78,7 +77,7 @@ public class TestXSLFShape {
         assertEquals(1, paragraphs2.get(1).getTextRuns().size());
 
         assertEquals("Subtitle", 
paragraphs2.get(0).getTextRuns().get(0).getRawText());
-        
assertTrue(paragraphs2.get(0).getTextRuns().get(0).getXmlObject().getRPr().getB());
+        
assertTrue(paragraphs2.get(0).getTextRuns().get(0).getRPr(false).getB());
         assertEquals("And second line", 
paragraphs2.get(1).getTextRuns().get(0).getRawText());
         
         ppt.close();

Modified: 
poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSlide.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSlide.java?rev=1782096&r1=1782095&r2=1782096&view=diff
==============================================================================
--- 
poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSlide.java 
(original)
+++ 
poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSlide.java 
Wed Feb  8 01:12:22 2017
@@ -111,7 +111,7 @@ public class TestXSLFSlide {
         assertEquals(0, ppt.getSlides().size());
 
         XSLFSlide slide = ppt.createSlide();
-        assertFalse(slide.getFollowMasterGraphics());
+        assertTrue(slide.getFollowMasterGraphics());
         slide.setFollowMasterGraphics(false);
         assertFalse(slide.getFollowMasterGraphics());
         slide.setFollowMasterGraphics(true);



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

Reply via email to