You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ki...@apache.org on 2015/07/19 21:00:38 UTC

svn commit: r1691843 [18/30] - in /poi/branches/common_sl: ./ .settings/ legal/ osgi/ osgi/src/ src/examples/src/org/apache/poi/hpsf/examples/ src/examples/src/org/apache/poi/hssf/usermodel/examples/ src/examples/src/org/apache/poi/ss/examples/ src/exa...

Modified: poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java (original)
+++ poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java Sun Jul 19 19:00:32 2015
@@ -32,19 +32,52 @@ import org.apache.poi.wp.usermodel.Chara
 import org.apache.xmlbeans.XmlCursor;
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
-import org.apache.xmlbeans.XmlString;
-import org.apache.xmlbeans.XmlToken;
-import org.apache.xmlbeans.impl.values.XmlAnyTypeImpl;
-import org.openxmlformats.schemas.drawingml.x2006.main.*;
-import org.openxmlformats.schemas.drawingml.x2006.picture.CTPicture;
-import org.openxmlformats.schemas.drawingml.x2006.picture.CTPictureNonVisual;
-import org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing.CTAnchor;
-import org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing.CTInline;
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.*;
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTColor;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
-
+import org.apache.xmlbeans.XmlString;
+import org.apache.xmlbeans.XmlToken;
+import org.apache.xmlbeans.impl.values.XmlAnyTypeImpl;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTBlip;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTBlipFillProperties;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTGraphicalObject;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTGraphicalObjectData;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualPictureProperties;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTPoint2D;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTPositiveSize2D;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTPresetGeometry2D;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTTransform2D;
+import org.openxmlformats.schemas.drawingml.x2006.main.STShapeType;
+import org.openxmlformats.schemas.drawingml.x2006.picture.CTPicture;
+import org.openxmlformats.schemas.drawingml.x2006.picture.CTPictureNonVisual;
+import org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing.CTAnchor;
+import org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing.CTInline;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBr;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTColor;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTDrawing;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTEmpty;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFFCheckBox;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFldChar;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFonts;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFtnEdnRef;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTHpsMeasure;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTOnOff;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPTab;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTR;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPr;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSignedHpsMeasure;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSignedTwipsMeasure;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTText;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTUnderline;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTVerticalAlignRun;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.STBrClear;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.STBrType;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.STFldCharType;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.STOnOff;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.STUnderline;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.STVerticalAlignRun;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+
 /**
  * XWPFRun object defines a region of text with a common set of properties
  */
@@ -52,22 +85,12 @@ public class XWPFRun implements ISDTCont
     private CTR run;
     private String pictureText;
     private IRunBody parent;
-    private List<XWPFPicture> pictures;
-
-    /**
-     * @see <a href="http://msdn.microsoft.com/en-us/library/ff533743(v=office.12).aspx">[MS-OI29500] Run Fonts</a> 
-     */
-    public static enum FontCharRange {
-        ascii /* char 0-127 */,
-        cs /* complex symbol */,
-        eastAsia /* east asia */,
-        hAnsi /* high ansi */
-    };
-    
-    /**
-     * @param r the CTR bean which holds the run attributes
-     * @param p the parent paragraph
-     */
+    private List<XWPFPicture> pictures;
+
+    /**
+     * @param r the CTR bean which holds the run attributes
+     * @param p the parent paragraph
+     */
     @SuppressWarnings("deprecation")
     public XWPFRun(CTR r, IRunBody p) {
         this.run = r;
@@ -92,13 +115,13 @@ public class XWPFRun implements ISDTCont
 
         // Look for any text in any of our pictures or drawings
         StringBuilder text = new StringBuilder();
-        List<XmlObject> pictTextObjs = new ArrayList<XmlObject>();
-        pictTextObjs.addAll(Arrays.asList(r.getPictArray()));
-        pictTextObjs.addAll(Arrays.asList(r.getDrawingArray()));
-        for(XmlObject o : pictTextObjs) {
-            XmlObject[] ts = o.selectPath("declare namespace w='http://schemas.openxmlformats.org/wordprocessingml/2006/main' .//w:t");
-            for (XmlObject t : ts) {
-                NodeList kids = t.getDomNode().getChildNodes();
+        List<XmlObject> pictTextObjs = new ArrayList<XmlObject>();
+        pictTextObjs.addAll(Arrays.asList(r.getPictArray()));
+        pictTextObjs.addAll(Arrays.asList(r.getDrawingArray()));
+        for (XmlObject o : pictTextObjs) {
+            XmlObject[] ts = o.selectPath("declare namespace w='http://schemas.openxmlformats.org/wordprocessingml/2006/main' .//w:t");
+            for (XmlObject t : ts) {
+                NodeList kids = t.getDomNode().getChildNodes();
                 for (int n = 0; n < kids.getLength(); n++) {
                     if (kids.item(n) instanceof Text) {
                         if (text.length() > 0)
@@ -110,112 +133,134 @@ public class XWPFRun implements ISDTCont
         }
         pictureText = text.toString();
 
-        // Do we have any embedded pictures?
-        // (They're a different CTPicture, under the drawingml namespace)
-        pictures = new ArrayList<XWPFPicture>();
-        for(XmlObject o : pictTextObjs) {
-            for(CTPicture pict : getCTPictures(o)) {
-                XWPFPicture picture = new XWPFPicture(pict, this);
-                pictures.add(picture);
-            }
-        }
-    }
-    /**
-     * @deprecated Use {@link XWPFRun#XWPFRun(CTR, IRunBody)}
-     */
-    public XWPFRun(CTR r, XWPFParagraph p) {
-        this(r, (IRunBody)p);
-    }
-
-    private List<CTPicture> getCTPictures(XmlObject o) {
-        List<CTPicture> pictures = new ArrayList<CTPicture>(); 
-        XmlObject[] picts = o.selectPath("declare namespace pic='"+CTPicture.type.getName().getNamespaceURI()+"' .//pic:pic");
-        for(XmlObject pict : picts) {
-            if(pict instanceof XmlAnyTypeImpl) {
-                // Pesky XmlBeans bug - see Bugzilla #49934
-                try {
-                    pict = CTPicture.Factory.parse( pict.toString() );
-                } catch(XmlException e) {
-                    throw new POIXMLException(e);
-                }
-            }
-            if(pict instanceof CTPicture) {
-                pictures.add((CTPicture)pict);
-            }
-        }
-        return pictures;
-    }
-
-    /**
-     * Get the currently used CTR object
-     * @return ctr object
-     */
-    @Internal
+        // Do we have any embedded pictures?
+        // (They're a different CTPicture, under the drawingml namespace)
+        pictures = new ArrayList<XWPFPicture>();
+        for (XmlObject o : pictTextObjs) {
+            for (CTPicture pict : getCTPictures(o)) {
+                XWPFPicture picture = new XWPFPicture(pict, this);
+                pictures.add(picture);
+            }
+        }
+    }
+
+    ;
+
+    /**
+     * @deprecated Use {@link XWPFRun#XWPFRun(CTR, IRunBody)}
+     */
+    public XWPFRun(CTR r, XWPFParagraph p) {
+        this(r, (IRunBody) p);
+    }
+
+    /**
+     * Add the xml:spaces="preserve" attribute if the string has leading or trailing white spaces
+     *
+     * @param xs the string to check
+     */
+    static void preserveSpaces(XmlString xs) {
+        String text = xs.getStringValue();
+        if (text != null && (text.startsWith(" ") || text.endsWith(" "))) {
+            XmlCursor c = xs.newCursor();
+            c.toNextToken();
+            c.insertAttributeWithValue(new QName("http://www.w3.org/XML/1998/namespace", "space"), "preserve");
+            c.dispose();
+        }
+    }
+
+    private List<CTPicture> getCTPictures(XmlObject o) {
+        List<CTPicture> pictures = new ArrayList<CTPicture>();
+        XmlObject[] picts = o.selectPath("declare namespace pic='" + CTPicture.type.getName().getNamespaceURI() + "' .//pic:pic");
+        for (XmlObject pict : picts) {
+            if (pict instanceof XmlAnyTypeImpl) {
+                // Pesky XmlBeans bug - see Bugzilla #49934
+                try {
+                    pict = CTPicture.Factory.parse(pict.toString());
+                } catch (XmlException e) {
+                    throw new POIXMLException(e);
+                }
+            }
+            if (pict instanceof CTPicture) {
+                pictures.add((CTPicture) pict);
+            }
+        }
+        return pictures;
+    }
+
+    /**
+     * Get the currently used CTR object
+     *
+     * @return ctr object
+     */
+    @Internal
     public CTR getCTR() {
         return run;
     }
-
-    /**
-     * Get the currently referenced paragraph/SDT object
-     * @return current parent
-     */
-    public IRunBody getParent() {
-        return parent;
-    }
-    /**
-     * Get the currently referenced paragraph, or null if a SDT object
-     * @deprecated use {@link XWPFRun#getParent()} instead
-     */
-    public XWPFParagraph getParagraph() {
-        if (parent instanceof XWPFParagraph)
-            return (XWPFParagraph)parent;
-        return null;
-    }
-
-    /**
-     * @return The {@link XWPFDocument} instance, this run belongs to, or
-     *         <code>null</code> if parent structure (paragraph > document) is not properly set.
-     */
-    public XWPFDocument getDocument() {
-        if (parent != null) {
+
+    /**
+     * Get the currently referenced paragraph/SDT object
+     *
+     * @return current parent
+     */
+    public IRunBody getParent() {
+        return parent;
+    }
+
+    /**
+     * Get the currently referenced paragraph, or null if a SDT object
+     *
+     * @deprecated use {@link XWPFRun#getParent()} instead
+     */
+    public XWPFParagraph getParagraph() {
+        if (parent instanceof XWPFParagraph)
+            return (XWPFParagraph) parent;
+        return null;
+    }
+
+    /**
+     * @return The {@link XWPFDocument} instance, this run belongs to, or
+     * <code>null</code> if parent structure (paragraph > document) is not properly set.
+     */
+    public XWPFDocument getDocument() {
+        if (parent != null) {
             return parent.getDocument();
         }
         return null;
     }
 
     /**
-     * For isBold, isItalic etc
-     */
-    private boolean isCTOnOff(CTOnOff onoff) {
-        if(! onoff.isSetVal())
-            return true;
-        if(onoff.getVal() == STOnOff.ON)
-            return true;
-        if(onoff.getVal() == STOnOff.TRUE)
-            return true;
-        return false;
-    }
+     * For isBold, isItalic etc
+     */
+    private boolean isCTOnOff(CTOnOff onoff) {
+        if (!onoff.isSetVal())
+            return true;
+        if (onoff.getVal() == STOnOff.ON)
+            return true;
+        if (onoff.getVal() == STOnOff.TRUE)
+            return true;
+        return false;
+    }
 
     /**
      * Whether the bold property shall be applied to all non-complex script
      * characters in the contents of this run when displayed in a document
      *
      * @return <code>true</code> if the bold property is applied
-     */
-    public boolean isBold() {
-        CTRPr pr = run.getRPr();
-        if(pr == null || !pr.isSetB()) {
-            return false;
-        }
-        return isCTOnOff(pr.getB());
-    }
-
-    /**
-     * Whether the bold property shall be applied to all non-complex script
-     * characters in the contents of this run when displayed in a document. 
-     * <p>
-     * This formatting property is a toggle property, which specifies that its
-     * behavior differs between its use within a style definition and its use as
+     */
+    public boolean isBold() {
+        CTRPr pr = run.getRPr();
+        if (pr == null || !pr.isSetB()) {
+            return false;
+        }
+        return isCTOnOff(pr.getB());
+    }
+
+    /**
+     * Whether the bold property shall be applied to all non-complex script
+     * characters in the contents of this run when displayed in a document.
+     * <p>
+     * This formatting property is a toggle property, which specifies that its
+     * behavior differs between its use within a style definition and its use as
      * direct formatting. When used as part of a style definition, setting this
      * property shall toggle the current state of that property as specified up
      * to this point in the hierarchy (i.e. applied to not applied, and vice
@@ -241,25 +286,26 @@ public class XWPFRun implements ISDTCont
     }
 
     /**
-     * Get text color. The returned value is a string in the hex form "RRGGBB".
-     */
-    public String getColor() {
-    	String color = null;
-        if (run.isSetRPr()) {
-        	CTRPr pr = run.getRPr();
-        	if (pr.isSetColor()) {
-        		CTColor clr = pr.getColor();
-        		color = clr.xgetVal().getStringValue();
-        	}
-        }
-    	return color;
-    }
-
-    /**
-     * Set text color.
-     * @param rgbStr - the desired color, in the hex form "RRGGBB".
-     */
-    public void setColor(String rgbStr) {
+     * Get text color. The returned value is a string in the hex form "RRGGBB".
+     */
+    public String getColor() {
+        String color = null;
+        if (run.isSetRPr()) {
+            CTRPr pr = run.getRPr();
+            if (pr.isSetColor()) {
+                CTColor clr = pr.getColor();
+                color = clr.xgetVal().getStringValue();
+            }
+        }
+        return color;
+    }
+
+    /**
+     * Set text color.
+     *
+     * @param rgbStr - the desired color, in the hex form "RRGGBB".
+     */
+    public void setColor(String rgbStr) {
         CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
         CTColor color = pr.isSetColor() ? pr.getColor() : pr.addNewColor();
         color.setVal(rgbStr);
@@ -285,23 +331,24 @@ public class XWPFRun implements ISDTCont
     /**
      * Sets the text of this text run
      *
-     * @param value the literal text which shall be displayed in the document
-     */
-    public void setText(String value) {
-        setText(value,run.sizeOfTArray());
-    }
-
-    /**
-     * Sets the text of this text run in the 
-     *
-     * @param value the literal text which shall be displayed in the document
-     * @param pos - position in the text array (NB: 0 based)
-     */
-    public void setText(String value, int pos) {
-        if(pos > run.sizeOfTArray()) throw new ArrayIndexOutOfBoundsException("Value too large for the parameter position in XWPFRun.setText(String value,int pos)");
-        CTText t = (pos < run.sizeOfTArray() && pos >= 0) ? run.getTArray(pos) : run.addNewT();
-        t.setStringValue(value);
-        preserveSpaces(t);
+     * @param value the literal text which shall be displayed in the document
+     */
+    public void setText(String value) {
+        setText(value, run.sizeOfTArray());
+    }
+
+    /**
+     * Sets the text of this text run in the
+     *
+     * @param value the literal text which shall be displayed in the document
+     * @param pos   - position in the text array (NB: 0 based)
+     */
+    public void setText(String value, int pos) {
+        if (pos > run.sizeOfTArray())
+            throw new ArrayIndexOutOfBoundsException("Value too large for the parameter position in XWPFRun.setText(String value,int pos)");
+        CTText t = (pos < run.sizeOfTArray() && pos >= 0) ? run.getTArray(pos) : run.addNewT();
+        t.setStringValue(value);
+        preserveSpaces(t);
     }
 
     /**
@@ -309,13 +356,13 @@ public class XWPFRun implements ISDTCont
      * characters in the contents of this run when displayed in a document.
      *
      * @return <code>true</code> if the italic property is applied
-     */
-    public boolean isItalic() {
-        CTRPr pr = run.getRPr();
-        if(pr == null || !pr.isSetI())
-            return false;
-        return isCTOnOff(pr.getI());
-    }
+     */
+    public boolean isItalic() {
+        CTRPr pr = run.getRPr();
+        if (pr == null || !pr.isSetI())
+            return false;
+        return isCTOnOff(pr.getI());
+    }
 
     /**
      * Whether the bold property shall be applied to all non-complex script
@@ -354,14 +401,14 @@ public class XWPFRun implements ISDTCont
      *
      * @return the Underline pattern applyed to this run
      * @see UnderlinePatterns
-     */
-    public UnderlinePatterns getUnderline() {
-        CTRPr pr = run.getRPr();
-        return (pr != null && pr.isSetU() && pr.getU().getVal() != null) 
-                ? UnderlinePatterns.valueOf(pr.getU().getVal().intValue()) 
-                : UnderlinePatterns.NONE;
-    }
-
+     */
+    public UnderlinePatterns getUnderline() {
+        CTRPr pr = run.getRPr();
+        return (pr != null && pr.isSetU() && pr.getU().getVal() != null)
+                ? UnderlinePatterns.valueOf(pr.getU().getVal().intValue())
+                : UnderlinePatterns.NONE;
+    }
+
     /**
      * Specifies that the contents of this run should be displayed along with an
      * underline appearing directly below the character heigh
@@ -388,32 +435,16 @@ public class XWPFRun implements ISDTCont
      * horizontal line through the center of the line.
      *
      * @return <code>true</code> if the strike property is applied
-     */
-    public boolean isStrikeThrough() {
-        CTRPr pr = run.getRPr();
-        if(pr == null || !pr.isSetStrike())
-            return false;
-        return isCTOnOff(pr.getStrike());
-    }
-    @Deprecated
-    public boolean isStrike() {
-        return isStrikeThrough();
-    }
-    /**
-     * Specifies that the contents of this run shall be displayed with a double
-     * horizontal line through the center of the line.
-     *
-     * @return <code>true</code> if the double strike property is applied
-     */
-    public boolean isDoubleStrikeThrough() {
-        CTRPr pr = run.getRPr();
-        if(pr == null || !pr.isSetDstrike())
-            return false;
-        return isCTOnOff(pr.getDstrike());
-    }
-
-    /**
-     * Specifies that the contents of this run shall be displayed with a single
+     */
+    public boolean isStrikeThrough() {
+        CTRPr pr = run.getRPr();
+        if (pr == null || !pr.isSetStrike())
+            return false;
+        return isCTOnOff(pr.getStrike());
+    }
+
+    /**
+     * Specifies that the contents of this run shall be displayed with a single
      * horizontal line through the center of the line.
      * <p/>
      * This formatting property is a toggle property, which specifies that its
@@ -438,86 +469,113 @@ public class XWPFRun implements ISDTCont
      */
     public void setStrikeThrough(boolean value) {
         CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
-        CTOnOff strike = pr.isSetStrike() ? pr.getStrike() : pr.addNewStrike();
-        strike.setVal(value ? STOnOff.TRUE : STOnOff.FALSE);
-    }
-    @Deprecated
-    public void setStrike(boolean value) {
-        setStrikeThrough(value);
-    }
-    /**
-     * Specifies that the contents of this run shall be displayed with a
-     * double horizontal line through the center of the line.
-     * @see #setStrikeThrough(boolean) for the rules about this
-     */
-    public void setDoubleStrikethrough(boolean value) {
+        CTOnOff strike = pr.isSetStrike() ? pr.getStrike() : pr.addNewStrike();
+        strike.setVal(value ? STOnOff.TRUE : STOnOff.FALSE);
+    }
+
+    @Deprecated
+    public boolean isStrike() {
+        return isStrikeThrough();
+    }
+
+    @Deprecated
+    public void setStrike(boolean value) {
+        setStrikeThrough(value);
+    }
+
+    /**
+     * Specifies that the contents of this run shall be displayed with a double
+     * horizontal line through the center of the line.
+     *
+     * @return <code>true</code> if the double strike property is applied
+     */
+    public boolean isDoubleStrikeThrough() {
+        CTRPr pr = run.getRPr();
+        if (pr == null || !pr.isSetDstrike())
+            return false;
+        return isCTOnOff(pr.getDstrike());
+    }
+
+    /**
+     * Specifies that the contents of this run shall be displayed with a
+     * double horizontal line through the center of the line.
+     *
+     * @see #setStrikeThrough(boolean) for the rules about this
+     */
+    public void setDoubleStrikethrough(boolean value) {
         CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
         CTOnOff dstrike = pr.isSetDstrike() ? pr.getDstrike() : pr.addNewDstrike();
         dstrike.setVal(value ? STOnOff.TRUE : STOnOff.FALSE);
     }
-
-    public boolean isSmallCaps() {
-        CTRPr pr = run.getRPr();
-        if(pr == null || !pr.isSetSmallCaps())
-            return false;
-        return isCTOnOff(pr.getSmallCaps());
-    }
-    public void setSmallCaps(boolean value) {
-        CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
-        CTOnOff caps = pr.isSetSmallCaps() ? pr.getSmallCaps() : pr.addNewSmallCaps();
-        caps.setVal(value ? STOnOff.TRUE : STOnOff.FALSE);
-    }
-    public boolean isCapitalized() {
-        CTRPr pr = run.getRPr();
-        if(pr == null || !pr.isSetCaps())
-            return false;
-        return isCTOnOff(pr.getCaps());
-    }
-    public void setCapitalized(boolean value) {
-        CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
-        CTOnOff caps = pr.isSetCaps() ? pr.getCaps() : pr.addNewCaps();
-        caps.setVal(value ? STOnOff.TRUE : STOnOff.FALSE);
-    }
-    
-    public boolean isShadowed() {
-        CTRPr pr = run.getRPr();
-        if(pr == null || !pr.isSetShadow())
-            return false;
-        return isCTOnOff(pr.getShadow());
-    }
-    public void setShadow(boolean value) {
-        CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
-        CTOnOff shadow = pr.isSetShadow() ? pr.getShadow() : pr.addNewShadow();
-        shadow.setVal(value ? STOnOff.TRUE : STOnOff.FALSE);
-    }
-    
-    public boolean isImprinted() {
-        CTRPr pr = run.getRPr();
-        if(pr == null || !pr.isSetImprint())
-            return false;
-        return isCTOnOff(pr.getImprint());
-    }
-    public void setImprinted(boolean value) {
-        CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
-        CTOnOff imprinted = pr.isSetImprint() ? pr.getImprint() : pr.addNewImprint();
-        imprinted.setVal(value ? STOnOff.TRUE : STOnOff.FALSE);
-    }
-    
-    public boolean isEmbossed() {
-        CTRPr pr = run.getRPr();
-        if(pr == null || !pr.isSetEmboss())
-            return false;
-        return isCTOnOff(pr.getEmboss());
-    }
-    public void setEmbossed(boolean value) {
-        CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
-        CTOnOff emboss = pr.isSetEmboss() ? pr.getEmboss() : pr.addNewEmboss();
-        emboss.setVal(value ? STOnOff.TRUE : STOnOff.FALSE);
-    }
-    
-    /**
-     * Specifies the alignment which shall be applied to the contents of this
-     * run in relation to the default appearance of the run's text.
+
+    public boolean isSmallCaps() {
+        CTRPr pr = run.getRPr();
+        if (pr == null || !pr.isSetSmallCaps())
+            return false;
+        return isCTOnOff(pr.getSmallCaps());
+    }
+
+    public void setSmallCaps(boolean value) {
+        CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
+        CTOnOff caps = pr.isSetSmallCaps() ? pr.getSmallCaps() : pr.addNewSmallCaps();
+        caps.setVal(value ? STOnOff.TRUE : STOnOff.FALSE);
+    }
+
+    public boolean isCapitalized() {
+        CTRPr pr = run.getRPr();
+        if (pr == null || !pr.isSetCaps())
+            return false;
+        return isCTOnOff(pr.getCaps());
+    }
+
+    public void setCapitalized(boolean value) {
+        CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
+        CTOnOff caps = pr.isSetCaps() ? pr.getCaps() : pr.addNewCaps();
+        caps.setVal(value ? STOnOff.TRUE : STOnOff.FALSE);
+    }
+
+    public boolean isShadowed() {
+        CTRPr pr = run.getRPr();
+        if (pr == null || !pr.isSetShadow())
+            return false;
+        return isCTOnOff(pr.getShadow());
+    }
+
+    public void setShadow(boolean value) {
+        CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
+        CTOnOff shadow = pr.isSetShadow() ? pr.getShadow() : pr.addNewShadow();
+        shadow.setVal(value ? STOnOff.TRUE : STOnOff.FALSE);
+    }
+
+    public boolean isImprinted() {
+        CTRPr pr = run.getRPr();
+        if (pr == null || !pr.isSetImprint())
+            return false;
+        return isCTOnOff(pr.getImprint());
+    }
+
+    public void setImprinted(boolean value) {
+        CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
+        CTOnOff imprinted = pr.isSetImprint() ? pr.getImprint() : pr.addNewImprint();
+        imprinted.setVal(value ? STOnOff.TRUE : STOnOff.FALSE);
+    }
+
+    public boolean isEmbossed() {
+        CTRPr pr = run.getRPr();
+        if (pr == null || !pr.isSetEmboss())
+            return false;
+        return isCTOnOff(pr.getEmboss());
+    }
+
+    public void setEmbossed(boolean value) {
+        CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
+        CTOnOff emboss = pr.isSetEmboss() ? pr.getEmboss() : pr.addNewEmboss();
+        emboss.setVal(value ? STOnOff.TRUE : STOnOff.FALSE);
+    }
+
+    /**
+     * Specifies the alignment which shall be applied to the contents of this
+     * run in relation to the default appearance of the run's text.
      * This allows the text to be repositioned as subscript or superscript without
      * altering the font size of the run properties.
      *
@@ -550,105 +608,106 @@ public class XWPFRun implements ISDTCont
         CTVerticalAlignRun ctValign = pr.isSetVertAlign() ? pr.getVertAlign() : pr.addNewVertAlign();
         ctValign.setVal(STVerticalAlignRun.Enum.forInt(valign.getValue()));
     }
-
-    public int getKerning() {
-        CTRPr pr = run.getRPr();
-        if(pr == null || !pr.isSetKern())
-            return 0;
-        return pr.getKern().getVal().intValue();
-    }
-    public void setKerning(int kern) {
-        CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
-        CTHpsMeasure kernmes = pr.isSetKern() ? pr.getKern() : pr.addNewKern();
-        kernmes.setVal(BigInteger.valueOf(kern));
-    }
-    
-    public int getCharacterSpacing() {
-        CTRPr pr = run.getRPr();
-        if(pr == null || !pr.isSetSpacing())
-            return 0;
-        return pr.getSpacing().getVal().intValue();
-    }
-    public void setCharacterSpacing(int twips) {
-        CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
-        CTSignedTwipsMeasure spc = pr.isSetSpacing() ? pr.getSpacing() : pr.addNewSpacing();
-        spc.setVal(BigInteger.valueOf(twips));
-    }
-    
-    /**
-     * Gets the fonts which shall be used to display the text contents of
-     * this run. Specifies a font which shall be used to format all characters
+
+    public int getKerning() {
+        CTRPr pr = run.getRPr();
+        if (pr == null || !pr.isSetKern())
+            return 0;
+        return pr.getKern().getVal().intValue();
+    }
+
+    public void setKerning(int kern) {
+        CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
+        CTHpsMeasure kernmes = pr.isSetKern() ? pr.getKern() : pr.addNewKern();
+        kernmes.setVal(BigInteger.valueOf(kern));
+    }
+
+    public int getCharacterSpacing() {
+        CTRPr pr = run.getRPr();
+        if (pr == null || !pr.isSetSpacing())
+            return 0;
+        return pr.getSpacing().getVal().intValue();
+    }
+
+    public void setCharacterSpacing(int twips) {
+        CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
+        CTSignedTwipsMeasure spc = pr.isSetSpacing() ? pr.getSpacing() : pr.addNewSpacing();
+        spc.setVal(BigInteger.valueOf(twips));
+    }
+
+    /**
+     * Gets the fonts which shall be used to display the text contents of
+     * this run. Specifies a font which shall be used to format all characters
      * in the ASCII range (0 - 127) within the parent run
      *
      * @return a string representing the font family
      */
-    public String getFontFamily() {
-        return getFontFamily(null);
-    }
-    /**
-     * Alias for {@link #getFontFamily()}
-     */
-    public String getFontName() {
+    public String getFontFamily() {
+        return getFontFamily(null);
+    }
+
+    /**
+     * Specifies the fonts which shall be used to display the text contents of
+     * this run. Specifies a font which shall be used to format all characters
+     * in the ASCII range (0 - 127) within the parent run.
+     * <p/>
+     * Also sets the other font ranges, if they haven't been set before
+     *
+     * @param fontFamily
+     * @see FontCharRange
+     */
+    public void setFontFamily(String fontFamily) {
+        setFontFamily(fontFamily, null);
+    }
+
+    /**
+     * Alias for {@link #getFontFamily()}
+     */
+    public String getFontName() {
         return getFontFamily();
     }
 
     /**
      * Gets the font family for the specified font char range.
-     * If fcr is null, the font char range "ascii" is used
-     *
-     * @param fcr the font char range, defaults to "ansi"
-     * @return  a string representing the font famil
-     */
-    public String getFontFamily(FontCharRange fcr) {
-        CTRPr pr = run.getRPr();
-        if (pr == null || !pr.isSetRFonts()) return null;
-        
-        CTFonts fonts = pr.getRFonts();
-        switch (fcr == null ? FontCharRange.ascii : fcr) {
-        default:
-        case ascii:
-            return fonts.getAscii();
-        case cs:
-            return fonts.getCs();
-        case eastAsia:
-            return fonts.getEastAsia();
-        case hAnsi:
-            return fonts.getHAnsi();
-        }
-    }
-    
-    
-    /**
-     * Specifies the fonts which shall be used to display the text contents of
-     * this run. Specifies a font which shall be used to format all characters
-     * in the ASCII range (0 - 127) within the parent run.
-     * 
-     * Also sets the other font ranges, if they haven't been set before 
-     *
-     * @param fontFamily
-     * 
-     * @see FontCharRange
-     */
-    public void setFontFamily(String fontFamily) {
-        setFontFamily(fontFamily, null);
-    }
-    
-    /**
-     * Specifies the fonts which shall be used to display the text contents of
-     * this run. The default handling for fcr == null is to overwrite the
-     * ascii font char range with the given font family and also set all not
-     * specified font ranges
-     *
-     * @param fontFamily
-     * @param fcr FontCharRange or null for default handling
-     */
-    public void setFontFamily(String fontFamily, FontCharRange fcr) {
-        CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
-        CTFonts fonts = pr.isSetRFonts() ? pr.getRFonts() : pr.addNewRFonts();
-        
-        if (fcr == null) {
-            fonts.setAscii(fontFamily);
-            if (!fonts.isSetHAnsi()) {
+     * If fcr is null, the font char range "ascii" is used
+     *
+     * @param fcr the font char range, defaults to "ansi"
+     * @return a string representing the font famil
+     */
+    public String getFontFamily(FontCharRange fcr) {
+        CTRPr pr = run.getRPr();
+        if (pr == null || !pr.isSetRFonts()) return null;
+
+        CTFonts fonts = pr.getRFonts();
+        switch (fcr == null ? FontCharRange.ascii : fcr) {
+            default:
+            case ascii:
+                return fonts.getAscii();
+            case cs:
+                return fonts.getCs();
+            case eastAsia:
+                return fonts.getEastAsia();
+            case hAnsi:
+                return fonts.getHAnsi();
+        }
+    }
+
+    /**
+     * Specifies the fonts which shall be used to display the text contents of
+     * this run. The default handling for fcr == null is to overwrite the
+     * ascii font char range with the given font family and also set all not
+     * specified font ranges
+     *
+     * @param fontFamily
+     * @param fcr        FontCharRange or null for default handling
+     */
+    public void setFontFamily(String fontFamily, FontCharRange fcr) {
+        CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
+        CTFonts fonts = pr.isSetRFonts() ? pr.getRFonts() : pr.addNewRFonts();
+
+        if (fcr == null) {
+            fonts.setAscii(fontFamily);
+            if (!fonts.isSetHAnsi()) {
                 fonts.setHAnsi(fontFamily);
             }
             if (!fonts.isSetCs()) {
@@ -656,24 +715,24 @@ public class XWPFRun implements ISDTCont
             }
             if (!fonts.isSetEastAsia()) {
                 fonts.setEastAsia(fontFamily);
-            }
-        } else {
-            switch (fcr) {
-            case ascii:
-                fonts.setAscii(fontFamily);
-                break;
-            case cs:
-                fonts.setCs(fontFamily);
-                break;
-            case eastAsia:
-                fonts.setEastAsia(fontFamily);
-                break;
-            case hAnsi:
-                fonts.setHAnsi(fontFamily);
-                break;
-            }
-        }
-    }
+            }
+        } else {
+            switch (fcr) {
+                case ascii:
+                    fonts.setAscii(fontFamily);
+                    break;
+                case cs:
+                    fonts.setCs(fontFamily);
+                    break;
+                case eastAsia:
+                    fonts.setEastAsia(fontFamily);
+                    break;
+                case hAnsi:
+                    fonts.setHAnsi(fontFamily);
+                    break;
+            }
+        }
+    }
 
     /**
      * Specifies the font size which shall be applied to all non complex script
@@ -696,13 +755,13 @@ public class XWPFRun implements ISDTCont
      * be used for non complex script characters.
      * </p>
      *
-     * @param size
-     */
-    public void setFontSize(int size) {
-        BigInteger bint=new BigInteger(""+size);
-        CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
-        CTHpsMeasure ctSize = pr.isSetSz() ? pr.getSz() : pr.addNewSz();
-        ctSize.setVal(bint.multiply(new BigInteger("2")));
+     * @param size
+     */
+    public void setFontSize(int size) {
+        BigInteger bint = new BigInteger("" + size);
+        CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
+        CTHpsMeasure ctSize = pr.isSetSz() ? pr.getSz() : pr.addNewSz();
+        ctSize.setVal(bint.multiply(new BigInteger("2")));
     }
 
     /**
@@ -739,52 +798,54 @@ public class XWPFRun implements ISDTCont
      * contents of this run.
      * </p>
      *
-     * @param val
-     */
-    public void setTextPosition(int val) {
-        BigInteger bint=new BigInteger(""+val);
-        CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
-        CTSignedHpsMeasure position = pr.isSetPosition() ? pr.getPosition() : pr.addNewPosition();
-        position.setVal(bint);
-    }
-
-    /**
-     * 
-     */
-    public void removeBreak() {
-        // TODO
-    }
-
-    /**
-     * Specifies that a break shall be placed at the current location in the run
-     * content. 
-     * A break is a special character which is used to override the
-     * normal line breaking that would be performed based on the normal layout
-     * of the document's contents. 
-     * @see #addCarriageReturn() 
-     */
-    public void addBreak() {
-        run.addNewBr();
-    } 
-
-    /**
-     * Specifies that a break shall be placed at the current location in the run
+     * @param val
+     */
+    public void setTextPosition(int val) {
+        BigInteger bint = new BigInteger("" + val);
+        CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
+        CTSignedHpsMeasure position = pr.isSetPosition() ? pr.getPosition() : pr.addNewPosition();
+        position.setVal(bint);
+    }
+
+    /**
+     *
+     */
+    public void removeBreak() {
+        // TODO
+    }
+
+    /**
+     * Specifies that a break shall be placed at the current location in the run
+     * content.
+     * A break is a special character which is used to override the
+     * normal line breaking that would be performed based on the normal layout
+     * of the document's contents.
+     *
+     * @see #addCarriageReturn()
+     */
+    public void addBreak() {
+        run.addNewBr();
+    }
+
+    /**
+     * Specifies that a break shall be placed at the current location in the run
      * content.
      * A break is a special character which is used to override the
      * normal line breaking that would be performed based on the normal layout
      * of the document's contents.
      * <p>
      * The behavior of this break character (the
-     * location where text shall be restarted after this break) shall be
-     * determined by its type values.
-     * </p>
-     * @see BreakType
-     */
-    public void addBreak(BreakType type){
-        CTBr br=run.addNewBr();
-        br.setType(STBrType.Enum.forInt(type.getValue()));
-    }
-
+     * location where text shall be restarted after this break) shall be
+     * determined by its type values.
+     * </p>
+     *
+     * @see BreakType
+     */
+    public void addBreak(BreakType type) {
+        CTBr br = run.addNewBr();
+        br.setType(STBrType.Enum.forInt(type.getValue()));
+    }
+
     /**
      * Specifies that a break shall be placed at the current location in the run
      * content. A break is a special character which is used to override the
@@ -792,31 +853,32 @@ public class XWPFRun implements ISDTCont
      * of the document's contents.
      * <p>
      * The behavior of this break character (the
-     * location where text shall be restarted after this break) shall be
-     * determined by its type (in this case is BreakType.TEXT_WRAPPING as default) and clear attribute values.
-     * </p>
-     * @see BreakClear
-     */
-    public void addBreak(BreakClear clear){
-        CTBr br=run.addNewBr();
-        br.setType(STBrType.Enum.forInt(BreakType.TEXT_WRAPPING.getValue()));
-        br.setClear(STBrClear.Enum.forInt(clear.getValue()));
-    }
-
-    /**
-     * Specifies that a tab shall be placed at the current location in 
-     *  the run content.
-     */
-    public void addTab() {
-        run.addNewTab();
-    }
-
-    public void removeTab() {
-        //TODO
-    }    
-
-    /**
-     * Specifies that a carriage return shall be placed at the
+     * location where text shall be restarted after this break) shall be
+     * determined by its type (in this case is BreakType.TEXT_WRAPPING as default) and clear attribute values.
+     * </p>
+     *
+     * @see BreakClear
+     */
+    public void addBreak(BreakClear clear) {
+        CTBr br = run.addNewBr();
+        br.setType(STBrType.Enum.forInt(BreakType.TEXT_WRAPPING.getValue()));
+        br.setClear(STBrClear.Enum.forInt(clear.getValue()));
+    }
+
+    /**
+     * Specifies that a tab shall be placed at the current location in
+     * the run content.
+     */
+    public void addTab() {
+        run.addNewTab();
+    }
+
+    public void removeTab() {
+        //TODO
+    }
+
+    /**
+     * Specifies that a carriage return shall be placed at the
      * current location in the run content.
      * A carriage return is used to end the current line of text in
      * Wordprocess.
@@ -830,34 +892,33 @@ public class XWPFRun implements ISDTCont
     public void addCarriageReturn() {
         run.addNewCr();
     }
-
-    public void removeCarriageReturn() {
-        //TODO
-    }    
-
-    /**
-     * Adds a picture to the run. This method handles
-     *  attaching the picture data to the overall file.
-     *  
-     * @see org.apache.poi.xwpf.usermodel.Document#PICTURE_TYPE_EMF
-     * @see org.apache.poi.xwpf.usermodel.Document#PICTURE_TYPE_WMF
-     * @see org.apache.poi.xwpf.usermodel.Document#PICTURE_TYPE_PICT
-     * @see org.apache.poi.xwpf.usermodel.Document#PICTURE_TYPE_JPEG
-     * @see org.apache.poi.xwpf.usermodel.Document#PICTURE_TYPE_PNG
-     * @see org.apache.poi.xwpf.usermodel.Document#PICTURE_TYPE_DIB
-     *  
-     * @param pictureData The raw picture data
-     * @param pictureType The type of the picture, eg {@link Document#PICTURE_TYPE_JPEG}
-     * @param width width in EMUs. To convert to / from points use {@link org.apache.poi.util.Units}
-     * @param height height in EMUs. To convert to / from points use {@link org.apache.poi.util.Units}
-     * @throws org.apache.poi.openxml4j.exceptions.InvalidFormatException
-     * @throws IOException
-     */
-    public XWPFPicture addPicture(InputStream pictureData, int pictureType, String filename, int width, int height)
-    throws InvalidFormatException, IOException {
-        XWPFDocument doc = parent.getDocument();
-
-        // Add the picture + relationship
+
+    public void removeCarriageReturn() {
+        //TODO
+    }
+
+    /**
+     * Adds a picture to the run. This method handles
+     * attaching the picture data to the overall file.
+     *
+     * @param pictureData The raw picture data
+     * @param pictureType The type of the picture, eg {@link Document#PICTURE_TYPE_JPEG}
+     * @param width       width in EMUs. To convert to / from points use {@link org.apache.poi.util.Units}
+     * @param height      height in EMUs. To convert to / from points use {@link org.apache.poi.util.Units}
+     * @throws org.apache.poi.openxml4j.exceptions.InvalidFormatException
+     * @throws IOException
+     * @see org.apache.poi.xwpf.usermodel.Document#PICTURE_TYPE_EMF
+     * @see org.apache.poi.xwpf.usermodel.Document#PICTURE_TYPE_WMF
+     * @see org.apache.poi.xwpf.usermodel.Document#PICTURE_TYPE_PICT
+     * @see org.apache.poi.xwpf.usermodel.Document#PICTURE_TYPE_JPEG
+     * @see org.apache.poi.xwpf.usermodel.Document#PICTURE_TYPE_PNG
+     * @see org.apache.poi.xwpf.usermodel.Document#PICTURE_TYPE_DIB
+     */
+    public XWPFPicture addPicture(InputStream pictureData, int pictureType, String filename, int width, int height)
+            throws InvalidFormatException, IOException {
+        XWPFDocument doc = parent.getDocument();
+
+        // Add the picture + relationship
         String relationId = doc.addPictureData(pictureData, pictureType);
         XWPFPictureData picData = (XWPFPictureData) doc.getRelationById(relationId);
 
@@ -865,18 +926,18 @@ public class XWPFRun implements ISDTCont
         try {
             CTDrawing drawing = run.addNewDrawing();
             CTInline inline = drawing.addNewInline();
-
-            // Do the fiddly namespace bits on the inline
-            // (We need full control of what goes where and as what)
-            String xml = 
-                "<a:graphic xmlns:a=\"" + CTGraphicalObject.type.getName().getNamespaceURI() + "\">" +
-                "<a:graphicData uri=\"" + CTPicture.type.getName().getNamespaceURI() + "\">" +
-                "<pic:pic xmlns:pic=\"" + CTPicture.type.getName().getNamespaceURI() + "\" />" +
-                "</a:graphicData>" +
-                "</a:graphic>";
-            inline.set(XmlToken.Factory.parse(xml));
-
-            // Setup the inline
+
+            // Do the fiddly namespace bits on the inline
+            // (We need full control of what goes where and as what)
+            String xml =
+                    "<a:graphic xmlns:a=\"" + CTGraphicalObject.type.getName().getNamespaceURI() + "\">" +
+                            "<a:graphicData uri=\"" + CTPicture.type.getName().getNamespaceURI() + "\">" +
+                            "<pic:pic xmlns:pic=\"" + CTPicture.type.getName().getNamespaceURI() + "\" />" +
+                            "</a:graphicData>" +
+                            "</a:graphic>";
+            inline.set(XmlToken.Factory.parse(xml));
+
+            // Setup the inline
             inline.setDistT(0);
             inline.setDistR(0);
             inline.setDistB(0);
@@ -910,13 +971,13 @@ public class XWPFRun implements ISDTCont
 
             CTNonVisualPictureProperties cNvPicPr = nvPicPr.addNewCNvPicPr();
             cNvPicPr.addNewPicLocks().setNoChangeAspect(true);
-
-            CTBlipFillProperties blipFill = pic.addNewBlipFill();
-            CTBlip blip = blipFill.addNewBlip();
-            blip.setEmbed( picData.getPackageRelationship().getId() );
-            blipFill.addNewStretch().addNewFillRect();
-
-            CTShapeProperties spPr = pic.addNewSpPr();
+
+            CTBlipFillProperties blipFill = pic.addNewBlipFill();
+            CTBlip blip = blipFill.addNewBlip();
+            blip.setEmbed(picData.getPackageRelationship().getId());
+            blipFill.addNewStretch().addNewFillRect();
+
+            CTShapeProperties spPr = pic.addNewSpPr();
             CTTransform2D xfrm = spPr.addNewXfrm();
 
             CTPoint2D off = xfrm.addNewOff();
@@ -932,50 +993,36 @@ public class XWPFRun implements ISDTCont
             prstGeom.addNewAvLst();
 
             // Finish up
-            XWPFPicture xwpfPicture = new XWPFPicture(pic, this);
-            pictures.add(xwpfPicture);
-            return xwpfPicture;
-        } catch(XmlException e) {
-            throw new IllegalStateException(e);
-        }
-    }
-
-    /**
-     * Returns the embedded pictures of the run. These
-     *  are pictures which reference an external, 
-     *  embedded picture image such as a .png or .jpg
-     */
-    public List<XWPFPicture> getEmbeddedPictures() {
-        return pictures;
-    }
-
-    /**
-     * Add the xml:spaces="preserve" attribute if the string has leading or trailing white spaces
-     *
-     * @param xs    the string to check
-     */
-    static void preserveSpaces(XmlString xs) {
-        String text = xs.getStringValue();
-        if (text != null && (text.startsWith(" ") || text.endsWith(" "))) {
-            XmlCursor c = xs.newCursor();
-            c.toNextToken();
-            c.insertAttributeWithValue(new QName("http://www.w3.org/XML/1998/namespace", "space"), "preserve");
-            c.dispose();
-        }
-    }
-
-    /**
-     * Returns the string version of the text
-     */
-    public String toString() {
-        return text();
-    }
-    /**
-     * Returns the string version of the text, with tabs and
-     *  carriage returns in place of their xml equivalents.
-     */
-    public String text() {
-        StringBuffer text = new StringBuffer();
+            XWPFPicture xwpfPicture = new XWPFPicture(pic, this);
+            pictures.add(xwpfPicture);
+            return xwpfPicture;
+        } catch (XmlException e) {
+            throw new IllegalStateException(e);
+        }
+    }
+
+    /**
+     * Returns the embedded pictures of the run. These
+     * are pictures which reference an external,
+     * embedded picture image such as a .png or .jpg
+     */
+    public List<XWPFPicture> getEmbeddedPictures() {
+        return pictures;
+    }
+
+    /**
+     * Returns the string version of the text
+     */
+    public String toString() {
+        return text();
+    }
+
+    /**
+     * Returns the string version of the text, with tabs and
+     * carriage returns in place of their xml equivalents.
+     */
+    public String text() {
+        StringBuffer text = new StringBuffer();
 
         // Grab the text and tabs of the text run
         // Do so in a way that preserves the ordering
@@ -989,26 +1036,26 @@ public class XWPFRun implements ISDTCont
                 //  come up as instances of CTText, but we don't want them
                 //  in the normal text output
                 if (!"w:instrText".equals(tagName)) {
-                    text.append(((CTText) o).getStringValue());
-                }
-            }
-            
-            // Complex type evaluation (currently only for extraction of check boxes)
-            if(o instanceof CTFldChar) {
-                CTFldChar ctfldChar = ((CTFldChar)o);
-                    if(ctfldChar.getFldCharType() == STFldCharType.BEGIN) {
-                        if(ctfldChar.getFfData() != null) {
-                            for(CTFFCheckBox checkBox : ctfldChar.getFfData().getCheckBoxList()) {
-                                if(checkBox.getDefault().getVal() == STOnOff.X_1) {
-                                    text.append("|X|");
-                                } else {
-                                    text.append("|_|");
-                                }
-                            }
-                        }
-                }
-            }
-
+                    text.append(((CTText) o).getStringValue());
+                }
+            }
+
+            // Complex type evaluation (currently only for extraction of check boxes)
+            if (o instanceof CTFldChar) {
+                CTFldChar ctfldChar = ((CTFldChar) o);
+                if (ctfldChar.getFldCharType() == STFldCharType.BEGIN) {
+                    if (ctfldChar.getFfData() != null) {
+                        for (CTFFCheckBox checkBox : ctfldChar.getFfData().getCheckBoxList()) {
+                            if (checkBox.getDefault().getVal() == STOnOff.X_1) {
+                                text.append("|X|");
+                            } else {
+                                text.append("|_|");
+                            }
+                        }
+                    }
+                }
+            }
+
             if (o instanceof CTPTab) {
                 text.append("\t");
             }
@@ -1030,23 +1077,33 @@ public class XWPFRun implements ISDTCont
                 }
                 if ("w:cr".equals(tagName) || "cr".equals(tagName)) {
                     text.append("\n");
-                }
-            }
-            if (o instanceof CTFtnEdnRef) {
-                CTFtnEdnRef ftn = (CTFtnEdnRef)o;
-                String footnoteRef = ftn.getDomNode().getLocalName().equals("footnoteReference") ?
-                    "[footnoteRef:" + ftn.getId().intValue() + "]" : "[endnoteRef:" + ftn.getId().intValue() + "]";
-                text.append(footnoteRef);
-            }            
-        }
-
-        c.dispose();
-
-        // Any picture text?
-        if(pictureText != null && pictureText.length() > 0) {
-            text.append("\n").append(pictureText);
-        }
-
-        return text.toString();
-    }
-}
+                }
+            }
+            if (o instanceof CTFtnEdnRef) {
+                CTFtnEdnRef ftn = (CTFtnEdnRef) o;
+                String footnoteRef = ftn.getDomNode().getLocalName().equals("footnoteReference") ?
+                        "[footnoteRef:" + ftn.getId().intValue() + "]" : "[endnoteRef:" + ftn.getId().intValue() + "]";
+                text.append(footnoteRef);
+            }
+        }
+
+        c.dispose();
+
+        // Any picture text?
+        if (pictureText != null && pictureText.length() > 0) {
+            text.append("\n").append(pictureText);
+        }
+
+        return text.toString();
+    }
+
+    /**
+     * @see <a href="http://msdn.microsoft.com/en-us/library/ff533743(v=office.12).aspx">[MS-OI29500] Run Fonts</a>
+     */
+    public static enum FontCharRange {
+        ascii /* char 0-127 */,
+        cs /* complex symbol */,
+        eastAsia /* east asia */,
+        hAnsi /* high ansi */
+    }
+}

Modified: poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSDT.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSDT.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSDT.java (original)
+++ poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSDT.java Sun Jul 19 19:00:32 2015
@@ -17,31 +17,30 @@
 package org.apache.poi.xwpf.usermodel;
 
 import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSdtBlock;
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSdtRun;
-
-/**
- * Experimental class to offer rudimentary read-only processing of 
- *  of StructuredDocumentTags/ContentControl
- *
- * WARNING - APIs expected to change rapidly
- * 
- */
-public class XWPFSDT extends AbstractXWPFSDT
-    implements IBodyElement, IRunBody, ISDTContents, IRunElement {
-   private final ISDTContent content;
-
-   public XWPFSDT(CTSdtRun sdtRun, IBody part){
-       super(sdtRun.getSdtPr(), part);
-       this.content = new XWPFSDTContent(sdtRun.getSdtContent(), part, this);
-   }
-   
-   public XWPFSDT(CTSdtBlock block, IBody part){
-      super(block.getSdtPr(), part);
-      this.content = new XWPFSDTContent( block.getSdtContent(), part, this);
-   }
-
-   public ISDTContent getContent(){
-      return content;
-   }
-
-}
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSdtRun;
+
+/**
+ * Experimental class to offer rudimentary read-only processing of
+ * of StructuredDocumentTags/ContentControl
+ * <p/>
+ * WARNING - APIs expected to change rapidly
+ */
+public class XWPFSDT extends AbstractXWPFSDT
+        implements IBodyElement, IRunBody, ISDTContents, IRunElement {
+    private final ISDTContent content;
+
+    public XWPFSDT(CTSdtRun sdtRun, IBody part) {
+        super(sdtRun.getSdtPr(), part);
+        this.content = new XWPFSDTContent(sdtRun.getSdtContent(), part, this);
+    }
+
+    public XWPFSDT(CTSdtBlock block, IBody part) {
+        super(block.getSdtPr(), part);
+        this.content = new XWPFSDTContent(block.getSdtContent(), part, this);
+    }
+
+    public ISDTContent getContent() {
+        return content;
+    }
+
+}

Modified: poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSDTCell.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSDTCell.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSDTCell.java (original)
+++ poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSDTCell.java Sun Jul 19 19:00:32 2015
@@ -16,29 +16,28 @@
 ==================================================================== */
 package org.apache.poi.xwpf.usermodel;
 
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSdtCell;
-
-/**
- * Experimental class to offer rudimentary read-only processing of 
- *  of StructuredDocumentTags/ContentControl that can appear
- *  in a table row as if a table cell.
- *  <p>
- *  These can contain one or more cells or other SDTs within them.
- *
- * WARNING - APIs expected to change rapidly
- * 
- */
-public class XWPFSDTCell extends AbstractXWPFSDT implements ICell {
-   private final XWPFSDTContentCell cellContent;
-
-   public XWPFSDTCell(CTSdtCell sdtCell, XWPFTableRow xwpfTableRow, IBody part){
-       super(sdtCell.getSdtPr(), part);
-       cellContent = new XWPFSDTContentCell(sdtCell.getSdtContent(), xwpfTableRow, part);
-   }
-
-   @Override
-   public ISDTContent getContent(){
-      return cellContent;
-   }
-   
-}
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSdtCell;
+
+/**
+ * Experimental class to offer rudimentary read-only processing of
+ * of StructuredDocumentTags/ContentControl that can appear
+ * in a table row as if a table cell.
+ * <p/>
+ * These can contain one or more cells or other SDTs within them.
+ * <p/>
+ * WARNING - APIs expected to change rapidly
+ */
+public class XWPFSDTCell extends AbstractXWPFSDT implements ICell {
+    private final XWPFSDTContentCell cellContent;
+
+    public XWPFSDTCell(CTSdtCell sdtCell, XWPFTableRow xwpfTableRow, IBody part) {
+        super(sdtCell.getSdtPr(), part);
+        cellContent = new XWPFSDTContentCell(sdtCell.getSdtContent(), xwpfTableRow, part);
+    }
+
+    @Override
+    public ISDTContent getContent() {
+        return cellContent;
+    }
+
+}

Modified: poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSDTContent.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSDTContent.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSDTContent.java (original)
+++ poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSDTContent.java Sun Jul 19 19:00:32 2015
@@ -16,93 +16,91 @@
 ==================================================================== */
 package org.apache.poi.xwpf.usermodel;
 
-import java.util.ArrayList;
-import java.util.List;
-
-
-import org.apache.xmlbeans.XmlCursor;
-import org.apache.xmlbeans.XmlObject;
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP;
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTR;
-
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSdtBlock;
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSdtContentBlock;
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSdtContentRun;
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTbl;
-
-/**
- * Experimental class to offer rudimentary read-only processing of 
- *  of the contentblock of an SDT/ContentControl.
- *  
- *
- *
- * WARNING - APIs expected to change rapidly
- * 
- */
-public class XWPFSDTContent implements ISDTContent {
-
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.xmlbeans.XmlCursor;
+import org.apache.xmlbeans.XmlObject;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTR;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSdtBlock;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSdtContentBlock;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSdtContentRun;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTbl;
+
+/**
+ * Experimental class to offer rudimentary read-only processing of
+ * of the contentblock of an SDT/ContentControl.
+ * <p/>
+ * <p/>
+ * <p/>
+ * WARNING - APIs expected to change rapidly
+ */
+public class XWPFSDTContent implements ISDTContent {
+
     // private final IBody part;
     // private final XWPFDocument document;
     private List<XWPFParagraph> paragraphs = new ArrayList<XWPFParagraph>();
     private List<XWPFTable> tables = new ArrayList<XWPFTable>();
     private List<XWPFRun> runs = new ArrayList<XWPFRun>();
-    private List<XWPFSDT> contentControls = new ArrayList<XWPFSDT>();
-    private List<ISDTContents> bodyElements = new ArrayList<ISDTContents>();
-
-    public XWPFSDTContent(CTSdtContentRun sdtRun, IBody part, IRunBody parent){
-        for (CTR ctr : sdtRun.getRArray()){
-            XWPFRun run = new XWPFRun(ctr, parent);
-            runs.add(run);
-            bodyElements.add(run);
-        }
-    }
-    public XWPFSDTContent(CTSdtContentBlock block, IBody part, IRunBody parent){
-        XmlCursor cursor = block.newCursor();
-        cursor.selectPath("./*");
-        while (cursor.toNextSelection()) {
+    private List<XWPFSDT> contentControls = new ArrayList<XWPFSDT>();
+    private List<ISDTContents> bodyElements = new ArrayList<ISDTContents>();
+
+    public XWPFSDTContent(CTSdtContentRun sdtRun, IBody part, IRunBody parent) {
+        for (CTR ctr : sdtRun.getRArray()) {
+            XWPFRun run = new XWPFRun(ctr, parent);
+            runs.add(run);
+            bodyElements.add(run);
+        }
+    }
+
+    public XWPFSDTContent(CTSdtContentBlock block, IBody part, IRunBody parent) {
+        XmlCursor cursor = block.newCursor();
+        cursor.selectPath("./*");
+        while (cursor.toNextSelection()) {
             XmlObject o = cursor.getObject();
             if (o instanceof CTP) {
                 XWPFParagraph p = new XWPFParagraph((CTP) o, part);
                 bodyElements.add(p);
                 paragraphs.add(p);
             } else if (o instanceof CTTbl) {
-                XWPFTable t = new XWPFTable((CTTbl) o, part);
-                bodyElements.add(t);
-                tables.add(t);
-            } else if (o instanceof CTSdtBlock){
-                XWPFSDT c = new XWPFSDT(((CTSdtBlock)o), part);
-                bodyElements.add(c);
-                contentControls.add(c);
-            } else if (o instanceof CTR) {
+                XWPFTable t = new XWPFTable((CTTbl) o, part);
+                bodyElements.add(t);
+                tables.add(t);
+            } else if (o instanceof CTSdtBlock) {
+                XWPFSDT c = new XWPFSDT(((CTSdtBlock) o), part);
+                bodyElements.add(c);
+                contentControls.add(c);
+            } else if (o instanceof CTR) {
                 XWPFRun run = new XWPFRun((CTR) o, parent);
                 runs.add(run);
                 bodyElements.add(run);
             }
-        }
-    }
-
-    public String getText(){
-        StringBuilder text = new StringBuilder();
-        boolean addNewLine = false;
-        for (int i = 0; i < bodyElements.size(); i++){
-            Object o = bodyElements.get(i);
-            if (o instanceof XWPFParagraph){
-                appendParagraph((XWPFParagraph)o, text);
-                addNewLine = true;
-            } else if (o instanceof XWPFTable){
-                appendTable((XWPFTable)o, text);
-                addNewLine = true;
-            } else if (o instanceof XWPFSDT){
-                text.append(((XWPFSDT)o).getContent().getText());
-                addNewLine = true;
-            } else if (o instanceof XWPFRun){
-                text.append(((XWPFRun)o).toString());
-                addNewLine = false;
-            }
-            if (addNewLine == true && i < bodyElements.size()-1){
-                text.append("\n");
-            }
-        }
+        }
+    }
+
+    public String getText() {
+        StringBuilder text = new StringBuilder();
+        boolean addNewLine = false;
+        for (int i = 0; i < bodyElements.size(); i++) {
+            Object o = bodyElements.get(i);
+            if (o instanceof XWPFParagraph) {
+                appendParagraph((XWPFParagraph) o, text);
+                addNewLine = true;
+            } else if (o instanceof XWPFTable) {
+                appendTable((XWPFTable) o, text);
+                addNewLine = true;
+            } else if (o instanceof XWPFSDT) {
+                text.append(((XWPFSDT) o).getContent().getText());
+                addNewLine = true;
+            } else if (o instanceof XWPFRun) {
+                text.append(((XWPFRun) o).toString());
+                addNewLine = false;
+            }
+            if (addNewLine == true && i < bodyElements.size() - 1) {
+                text.append("\n");
+            }
+        }
         return text.toString();
     }
 
@@ -110,28 +108,28 @@ public class XWPFSDTContent implements I
         //this works recursively to pull embedded tables from within cells
         for (XWPFTableRow row : table.getRows()) {
             List<ICell> cells = row.getTableICells();
-            for (int i = 0; i < cells.size(); i++) {
-                ICell cell = cells.get(i);
-                if (cell instanceof XWPFTableCell) {
-                    text.append(((XWPFTableCell)cell).getTextRecursively());
-                } else if (cell instanceof XWPFSDTCell) {
-                    text.append(((XWPFSDTCell)cell).getContent().getText());
-                }
-                if (i < cells.size()-1) {
-                    text.append("\t");
-                }
-            }
-            text.append('\n');
-        }
-    }
-    
-    private void appendParagraph(XWPFParagraph paragraph, StringBuilder text) {
-        for(IRunElement run : paragraph.getRuns()) {
-            text.append(run.toString());
-        }
-    }
-    
-    public String toString(){
-        return getText();
-    }
+            for (int i = 0; i < cells.size(); i++) {
+                ICell cell = cells.get(i);
+                if (cell instanceof XWPFTableCell) {
+                    text.append(((XWPFTableCell) cell).getTextRecursively());
+                } else if (cell instanceof XWPFSDTCell) {
+                    text.append(((XWPFSDTCell) cell).getContent().getText());
+                }
+                if (i < cells.size() - 1) {
+                    text.append("\t");
+                }
+            }
+            text.append('\n');
+        }
+    }
+
+    private void appendParagraph(XWPFParagraph paragraph, StringBuilder text) {
+        for (IRunElement run : paragraph.getRuns()) {
+            text.append(run.toString());
+        }
+    }
+
+    public String toString() {
+        return getText();
+    }
 }

Modified: poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSDTContentCell.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSDTContentCell.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSDTContentCell.java (original)
+++ poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSDTContentCell.java Sun Jul 19 19:00:32 2015
@@ -18,54 +18,52 @@ package org.apache.poi.xwpf.usermodel;
 
 
 import javax.xml.namespace.QName;
-
-import org.apache.xmlbeans.XmlCursor;
-import org.apache.xmlbeans.XmlCursor.TokenType;
-
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSdtContentCell;
-
-
-
-/**
- * Experimental class to offer rudimentary read-only processing of 
- *  of the XWPFSDTCellContent.  
-
- * WARNING - APIs expected to change rapidly
- * 
- */
-public class XWPFSDTContentCell implements ISDTContent {
-
+
+import org.apache.xmlbeans.XmlCursor;
+import org.apache.xmlbeans.XmlCursor.TokenType;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSdtContentCell;
+
+
+/**
+ * Experimental class to offer rudimentary read-only processing of
+ * of the XWPFSDTCellContent.
+ * <p/>
+ * WARNING - APIs expected to change rapidly
+ */
+public class XWPFSDTContentCell implements ISDTContent {
+
     //A full implementation would grab the icells
     //that a content cell can contain.  This would require
     //significant changes, including changing the notion that the
     //parent of a cell can be not just a row, but an sdt.
     //For now we are just grabbing the text out of the text tokentypes.
 
-    //private List<ICell> cells = new ArrayList<ICell>().
-
-    private String text = "";
-    public XWPFSDTContentCell(CTSdtContentCell sdtContentCell, 
-            XWPFTableRow xwpfTableRow, IBody part){
-        super();
-        StringBuilder sb = new StringBuilder();
-        XmlCursor cursor = sdtContentCell.newCursor();
-
-        //keep track of the following,
-        //and add "\n" only before the start of a body
-        //element if it is not the first body element.
-        
-        //index of cell in row
-        int tcCnt = 0;
-        //count of body objects
+    //private List<ICell> cells = new ArrayList<ICell>().
+
+    private String text = "";
+
+    public XWPFSDTContentCell(CTSdtContentCell sdtContentCell,
+                              XWPFTableRow xwpfTableRow, IBody part) {
+        super();
+        StringBuilder sb = new StringBuilder();
+        XmlCursor cursor = sdtContentCell.newCursor();
+
+        //keep track of the following,
+        //and add "\n" only before the start of a body
+        //element if it is not the first body element.
+
+        //index of cell in row
+        int tcCnt = 0;
+        //count of body objects
         int iBodyCnt = 0;
         int depth = 1;
-
-        while (cursor.hasNextToken() && depth > 0) {
-            TokenType t = cursor.toNextToken();
-            if (t.isText()){
-                sb.append(cursor.getTextValue());
-            } else if (isStartToken(cursor, "tr")) {
-                tcCnt = 0;
+
+        while (cursor.hasNextToken() && depth > 0) {
+            TokenType t = cursor.toNextToken();
+            if (t.isText()) {
+                sb.append(cursor.getTextValue());
+            } else if (isStartToken(cursor, "tr")) {
+                tcCnt = 0;
                 iBodyCnt = 0;
             } else if (isStartToken(cursor, "tc")) {
                 if (tcCnt++ > 0) {
@@ -77,38 +75,37 @@ public class XWPFSDTContentCell implemen
                     isStartToken(cursor, "sdt")) {
                 if (iBodyCnt > 0) {
                     sb.append("\n");
-                }
-                iBodyCnt++;
-            }
-            if (cursor.isStart()){
-                depth++;
-            } else if (cursor.isEnd()){
-                depth--;
-            }
-        }
-        text = sb.toString();
-    }
-
-
-
-    private boolean isStartToken(XmlCursor cursor, String string) {
-        if (! cursor.isStart()) {
-            return false;
-        }
-        QName qName = cursor.getName();
+                }
+                iBodyCnt++;
+            }
+            if (cursor.isStart()) {
+                depth++;
+            } else if (cursor.isEnd()) {
+                depth--;
+            }
+        }
+        text = sb.toString();
+    }
+
+
+    private boolean isStartToken(XmlCursor cursor, String string) {
+        if (!cursor.isStart()) {
+            return false;
+        }
+        QName qName = cursor.getName();
         if (qName != null && qName.getLocalPart() != null &&
                 qName.getLocalPart().equals(string)) {
             return true;
         }
         return false;
-    }
-
-
-    public String getText(){
-        return text;
-    }
-
-    public String toString(){
-        return getText();
-    }
+    }
+
+
+    public String getText() {
+        return text;
+    }
+
+    public String toString() {
+        return getText();
+    }
 }

Modified: poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSettings.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSettings.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSettings.java (original)
+++ poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSettings.java Sun Jul 19 19:00:32 2015
@@ -59,8 +59,7 @@ public class XWPFSettings extends POIXML
     }
 
     @Override
-    protected void onDocumentRead() throws IOException
-    {
+    protected void onDocumentRead() throws IOException {
         super.onDocumentRead();
         readFrom(getPackagePart().getInputStream());
     }
@@ -74,17 +73,18 @@ public class XWPFSettings extends POIXML
      * <pre>
      *    &lt;w:zoom w:percent="50" /&gt;
      * <pre>
+     *
      * @return percentage as an integer of zoom level
      */
     public long getZoomPercent() {
-       CTZoom zoom;
-       if (!ctSettings.isSetZoom()) {
-          zoom = ctSettings.addNewZoom();
-       } else {
-          zoom = ctSettings.getZoom();
-       }
+        CTZoom zoom;
+        if (!ctSettings.isSetZoom()) {
+            zoom = ctSettings.addNewZoom();
+        } else {
+            zoom = ctSettings.getZoom();
+        }
 
-       return zoom.getPercent().longValue();
+        return zoom.getPercent().longValue();
     }
 
     /**
@@ -92,31 +92,31 @@ public class XWPFSettings extends POIXML
      * In the zoom tag inside settings.xml file <br/>
      * it sets the value of zoom
      * <br/>
-     * sample snippet from settings.xml 
+     * sample snippet from settings.xml
      * <pre>
-     *    &lt;w:zoom w:percent="50" /&gt; 
+     *    &lt;w:zoom w:percent="50" /&gt;
      * <pre>
      */
     public void setZoomPercent(long zoomPercent) {
-       if (! ctSettings.isSetZoom()) {
-          ctSettings.addNewZoom();
-       }
-       CTZoom zoom = ctSettings.getZoom();
-       zoom.setPercent(BigInteger.valueOf(zoomPercent));
+        if (!ctSettings.isSetZoom()) {
+            ctSettings.addNewZoom();
+        }
+        CTZoom zoom = ctSettings.getZoom();
+        zoom.setPercent(BigInteger.valueOf(zoomPercent));
     }
 
     /**
      * Verifies the documentProtection tag inside settings.xml file <br/>
      * if the protection is enforced (w:enforcement="1") <br/>
      * and if the kind of protection equals to passed (STDocProtect.Enum editValue) <br/>
-     * 
+     * <p/>
      * <br/>
      * sample snippet from settings.xml
      * <pre>
      *     &lt;w:settings  ... &gt;
      *         &lt;w:documentProtection w:edit=&quot;readOnly&quot; w:enforcement=&quot;1&quot;/&gt;
      * </pre>
-     * 
+     *
      * @return true if documentProtection is enforced with option readOnly
      */
     public boolean isEnforcedWith(STDocProtect.Enum editValue) {
@@ -152,23 +152,23 @@ public class XWPFSettings extends POIXML
      * <br/>
      * sample snippet from settings.xml
      * <pre>
-     *   &lt;w:documentProtection w:edit=&quot;[passed editValue]&quot; w:enforcement=&quot;1&quot; 
+     *   &lt;w:documentProtection w:edit=&quot;[passed editValue]&quot; w:enforcement=&quot;1&quot;
      *       w:cryptProviderType=&quot;rsaAES&quot; w:cryptAlgorithmClass=&quot;hash&quot;
      *       w:cryptAlgorithmType=&quot;typeAny&quot; w:cryptAlgorithmSid=&quot;14&quot;
      *       w:cryptSpinCount=&quot;100000&quot; w:hash=&quot;...&quot; w:salt=&quot;....&quot;
      *   /&gt;
      * </pre>
-     * 
+     *
      * @param editValue the protection type
-     * @param password the plaintext password, if null no password will be applied
-     * @param hashAlgo the hash algorithm - only md2, m5, sha1, sha256, sha384 and sha512 are supported.
-     *   if null, it will default default to sha1
+     * @param password  the plaintext password, if null no password will be applied
+     * @param hashAlgo  the hash algorithm - only md2, m5, sha1, sha256, sha384 and sha512 are supported.
+     *                  if null, it will default default to sha1
      */
     public void setEnforcementEditValue(org.openxmlformats.schemas.wordprocessingml.x2006.main.STDocProtect.Enum editValue,
-            String password, HashAlgorithm hashAlgo) {
+                                        String password, HashAlgorithm hashAlgo) {
         safeGetDocumentProtection().setEnforcement(STOnOff.X_1);
         safeGetDocumentProtection().setEdit(editValue);
-        
+
         if (password == null) {
             if (safeGetDocumentProtection().isSetCryptProviderType()) {
                 safeGetDocumentProtection().unsetCryptProviderType();
@@ -177,23 +177,23 @@ public class XWPFSettings extends POIXML
             if (safeGetDocumentProtection().isSetCryptAlgorithmClass()) {
                 safeGetDocumentProtection().unsetCryptAlgorithmClass();
             }
-            
+
             if (safeGetDocumentProtection().isSetCryptAlgorithmType()) {
                 safeGetDocumentProtection().unsetCryptAlgorithmType();
             }
-            
+
             if (safeGetDocumentProtection().isSetCryptAlgorithmSid()) {
                 safeGetDocumentProtection().unsetCryptAlgorithmSid();
             }
-            
+
             if (safeGetDocumentProtection().isSetSalt()) {
                 safeGetDocumentProtection().unsetSalt();
             }
-            
+
             if (safeGetDocumentProtection().isSetCryptSpinCount()) {
                 safeGetDocumentProtection().unsetCryptSpinCount();
             }
-            
+
             if (safeGetDocumentProtection().isSetHash()) {
                 safeGetDocumentProtection().unsetHash();
             }
@@ -201,47 +201,47 @@ public class XWPFSettings extends POIXML
             final STCryptProv.Enum providerType;
             final int sid;
             switch (hashAlgo) {
-            case md2:
-                providerType = STCryptProv.RSA_FULL;
-                sid = 1;
-                break;
-            case md4:
-                providerType = STCryptProv.RSA_FULL;
-                sid = 2;
-                break;
-            case md5:
-                providerType = STCryptProv.RSA_FULL;
-                sid = 3;
-                break;
-            case sha1:
-                providerType = STCryptProv.RSA_FULL;
-                sid = 4;
-                break;
-            case sha256:
-                providerType = STCryptProv.RSA_AES;
-                sid = 12;
-                break;
-            case sha384:
-                providerType = STCryptProv.RSA_AES;
-                sid = 13;
-                break;
-            case sha512:
-                providerType = STCryptProv.RSA_AES;
-                sid = 14;
-                break;
-            default:
-                throw new EncryptedDocumentException
-                ("Hash algorithm '"+hashAlgo+"' is not supported for document write protection.");
+                case md2:
+                    providerType = STCryptProv.RSA_FULL;
+                    sid = 1;
+                    break;
+                case md4:
+                    providerType = STCryptProv.RSA_FULL;
+                    sid = 2;
+                    break;
+                case md5:
+                    providerType = STCryptProv.RSA_FULL;
+                    sid = 3;
+                    break;
+                case sha1:
+                    providerType = STCryptProv.RSA_FULL;
+                    sid = 4;
+                    break;
+                case sha256:
+                    providerType = STCryptProv.RSA_AES;
+                    sid = 12;
+                    break;
+                case sha384:
+                    providerType = STCryptProv.RSA_AES;
+                    sid = 13;
+                    break;
+                case sha512:
+                    providerType = STCryptProv.RSA_AES;
+                    sid = 14;
+                    break;
+                default:
+                    throw new EncryptedDocumentException
+                            ("Hash algorithm '" + hashAlgo + "' is not supported for document write protection.");
             }
 
-        
-            SecureRandom random = new SecureRandom(); 
+
+            SecureRandom random = new SecureRandom();
             byte salt[] = random.generateSeed(16);
-    
+
             // Iterations specifies the number of times the hashing function shall be iteratively run (using each
             // iteration's result as the input for the next iteration).
             int spinCount = 100000;
-    
+
             if (hashAlgo == null) hashAlgo = HashAlgorithm.sha1;
 
             String legacyHash = CryptoFunctions.xorHashPasswordReversed(password);
@@ -257,7 +257,7 @@ public class XWPFSettings extends POIXML
             safeGetDocumentProtection().setCryptAlgorithmClass(STAlgClass.HASH);
             safeGetDocumentProtection().setCryptProviderType(providerType);
             safeGetDocumentProtection().setCryptAlgorithmSid(BigInteger.valueOf(sid));
-        }        
+        }
     }
 
     /**
@@ -271,30 +271,45 @@ public class XWPFSettings extends POIXML
         byte hash[] = safeGetDocumentProtection().getHash();
         byte salt[] = safeGetDocumentProtection().getSalt();
         BigInteger spinCount = safeGetDocumentProtection().getCryptSpinCount();
-        
+
         if (sid == null || hash == null || salt == null || spinCount == null) return false;
-        
+
         HashAlgorithm hashAlgo;
         switch (sid.intValue()) {
-        case 1: hashAlgo = HashAlgorithm.md2; break;
-        case 2: hashAlgo = HashAlgorithm.md4; break;
-        case 3: hashAlgo = HashAlgorithm.md5; break;
-        case 4: hashAlgo = HashAlgorithm.sha1; break;
-        case 12: hashAlgo = HashAlgorithm.sha256; break;
-        case 13: hashAlgo = HashAlgorithm.sha384; break;
-        case 14: hashAlgo = HashAlgorithm.sha512; break;
-        default: return false;
+            case 1:
+                hashAlgo = HashAlgorithm.md2;
+                break;
+            case 2:
+                hashAlgo = HashAlgorithm.md4;
+                break;
+            case 3:
+                hashAlgo = HashAlgorithm.md5;
+                break;
+            case 4:
+                hashAlgo = HashAlgorithm.sha1;
+                break;
+            case 12:
+                hashAlgo = HashAlgorithm.sha256;
+                break;
+            case 13:
+                hashAlgo = HashAlgorithm.sha384;
+                break;
+            case 14:
+                hashAlgo = HashAlgorithm.sha512;
+                break;
+            default:
+                return false;
         }
-        
+
         String legacyHash = CryptoFunctions.xorHashPasswordReversed(password);
         // Implementation Notes List:
         // --> In this third stage, the reversed byte order legacy hash from the second stage shall
         //     be converted to Unicode hex string representation
         byte hash2[] = CryptoFunctions.hashPassword(legacyHash, hashAlgo, salt, spinCount.intValue(), false);
-        
+
         return Arrays.equals(hash, hash2);
     }
-    
+
     /**
      * Removes protection enforcement.<br/>
      * In the documentProtection tag inside settings.xml file <br/>
@@ -308,18 +323,18 @@ public class XWPFSettings extends POIXML
      * Enforces fields update on document open (in Word).
      * In the settings.xml file <br/>
      * sets the updateSettings value to true (w:updateSettings w:val="true")
-     * 
-     *  NOTICES:
-     *  <ul>
-     *  	<li>Causing Word to ask on open: "This document contains fields that may refer to other files. Do you want to update the fields in this document?"
-     *           (if "Update automatic links at open" is enabled)</li>
-     *  	<li>Flag is removed after saving with changes in Word </li>
-     *  </ul> 
+     * <p/>
+     * NOTICES:
+     * <ul>
+     * <li>Causing Word to ask on open: "This document contains fields that may refer to other files. Do you want to update the fields in this document?"
+     * (if "Update automatic links at open" is enabled)</li>
+     * <li>Flag is removed after saving with changes in Word </li>
+     * </ul>
      */
     public void setUpdateFields() {
-    	CTOnOff onOff = CTOnOff.Factory.newInstance();
-    	onOff.setVal(STOnOff.TRUE);
-    	ctSettings.setUpdateFields(onOff);
+        CTOnOff onOff = CTOnOff.Factory.newInstance();
+        onOff.setVal(STOnOff.TRUE);
+        ctSettings.setUpdateFields(onOff);
     }
 
     boolean isUpdateFields() {
@@ -328,7 +343,7 @@ public class XWPFSettings extends POIXML
 
     /**
      * Check if revision tracking is turned on.
-     * 
+     *
      * @return <code>true</code> if revision tracking is turned on
      */
     public boolean isTrackRevisions() {
@@ -337,16 +352,16 @@ public class XWPFSettings extends POIXML
 
     /**
      * Enable or disable revision tracking.
-     * 
+     *
      * @param enable <code>true</code> to  turn on revision tracking, <code>false</code> to turn off revision tracking
      */
     public void setTrackRevisions(boolean enable) {
-        if(enable) {
-            if(!ctSettings.isSetTrackRevisions()) {
+        if (enable) {
+            if (!ctSettings.isSetTrackRevisions()) {
                 ctSettings.addNewTrackRevisions();
             }
         } else {
-            if(ctSettings.isSetTrackRevisions()) {
+            if (ctSettings.isSetTrackRevisions()) {
                 ctSettings.unsetTrackRevisions();
             }
         }
@@ -355,7 +370,7 @@ public class XWPFSettings extends POIXML
     @Override
     protected void commit() throws IOException {
         if (ctSettings == null) {
-           throw new IllegalStateException("Unable to write out settings that were never read in!");
+            throw new IllegalStateException("Unable to write out settings that were never read in!");
         }
 
         XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS);



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