poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From talli...@apache.org
Subject svn commit: r1682473 [4/8] - in /poi/trunk/src/ooxml: java/org/apache/poi/util/ java/org/apache/poi/xwpf/ java/org/apache/poi/xwpf/extractor/ java/org/apache/poi/xwpf/model/ java/org/apache/poi/xwpf/usermodel/ testcases/org/apache/poi/xwpf/ testcases/o...
Date Fri, 29 May 2015 14:01:33 GMT
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java?rev=1682473&r1=1682472&r2=1682473&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java Fri May 29 14:01:31 2015
@@ -20,6 +20,7 @@ import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
+
 import org.apache.poi.POIXMLDocumentPart;
 import org.apache.poi.util.Internal;
 import org.apache.poi.wp.usermodel.Paragraph;
@@ -58,16 +59,18 @@ import org.openxmlformats.schemas.wordpr
 import org.openxmlformats.schemas.wordprocessingml.x2006.main.STTextAlignment;
 
 /**
- * <p>A Paragraph within a Document, Table, Header etc.</p> 
- * 
+ * <p>A Paragraph within a Document, Table, Header etc.</p>
+ * <p/>
  * <p>A paragraph has a lot of styling information, but the
- *  actual text (possibly along with more styling) is held on
- *  the child {@link XWPFRun}s.</p>
+ * actual text (possibly along with more styling) is held on
+ * the child {@link XWPFRun}s.</p>
  */
 public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Paragraph {
     private final CTP paragraph;
     protected IBody part;
-    /** For access to the document's hyperlink, comments, tables etc */
+    /**
+     * For access to the document's hyperlink, comments, tables etc
+     */
     protected XWPFDocument document;
     protected List<XWPFRun> runs;
     protected List<IRunElement> iruns;
@@ -77,10 +80,10 @@ public class XWPFParagraph implements IB
     public XWPFParagraph(CTP prgrph, IBody part) {
         this.paragraph = prgrph;
         this.part = part;
-        
+
         this.document = part.getXWPFDocument();
 
-        if (document==null) {
+        if (document == null) {
             throw new NullPointerException();
         }
 
@@ -90,7 +93,7 @@ public class XWPFParagraph implements IB
         buildRunsInOrderFromXml(paragraph);
 
         // Look for bits associated with the runs
-        for(XWPFRun run : runs) {
+        for (XWPFRun run : runs) {
             CTR r = run.getCTR();
 
             // Check for bits that only apply when attached to a core document
@@ -99,13 +102,13 @@ public class XWPFParagraph implements IB
             c.selectPath("child::*");
             while (c.toNextSelection()) {
                 XmlObject o = c.getObject();
-                if(o instanceof CTFtnEdnRef) {
-                    CTFtnEdnRef ftn = (CTFtnEdnRef)o;
+                if (o instanceof CTFtnEdnRef) {
+                    CTFtnEdnRef ftn = (CTFtnEdnRef) o;
                     footnoteText.append(" [").append(ftn.getId()).append(": ");
                     XWPFFootnote footnote =
-                        ftn.getDomNode().getLocalName().equals("footnoteReference") ?
-                            document.getFootnoteByID(ftn.getId().intValue()) :
-                            document.getEndnoteByID(ftn.getId().intValue());
+                            ftn.getDomNode().getLocalName().equals("footnoteReference") ?
+                                    document.getFootnoteByID(ftn.getId().intValue()) :
+                                    document.getEndnoteByID(ftn.getId().intValue());
 
                     boolean first = true;
                     for (XWPFParagraph p : footnote.getParagraphs()) {
@@ -125,8 +128,8 @@ public class XWPFParagraph implements IB
 
     /**
      * Identifies (in order) the parts of the paragraph /
-     *  sub-paragraph that correspond to character text
-     *  runs, and builds the appropriate runs for these.
+     * sub-paragraph that correspond to character text
+     * runs, and builds the appropriate runs for these.
      */
     private void buildRunsInOrderFromXml(XmlObject object) {
         XmlCursor c = object.newCursor();
@@ -134,71 +137,72 @@ public class XWPFParagraph implements IB
         while (c.toNextSelection()) {
             XmlObject o = c.getObject();
             if (o instanceof CTR) {
-               XWPFRun r = new XWPFRun((CTR) o, this);
-               runs.add(r);
-               iruns.add(r);
-           }
-           if (o instanceof CTHyperlink) {
-               CTHyperlink link = (CTHyperlink) o;
-               for (CTR r : link.getRArray()) {
-                   XWPFHyperlinkRun hr = new XWPFHyperlinkRun(link, r, this);
-                   runs.add(hr);
-                   iruns.add(hr);
-               }
-           }
-           if (o instanceof CTSdtBlock) {
-               XWPFSDT cc = new XWPFSDT((CTSdtBlock) o, part);
-               iruns.add(cc);
-           }
-           if (o instanceof CTSdtRun) {
-               XWPFSDT cc = new XWPFSDT((CTSdtRun) o, part);
-               iruns.add(cc);
-           }
-           if (o instanceof CTRunTrackChange) {
-               for (CTR r : ((CTRunTrackChange) o).getRArray()) {
-                   XWPFRun cr = new XWPFRun(r, this);
-                   runs.add(cr);
-                   iruns.add(cr);
-               }
-           }
-           if (o instanceof CTSimpleField) {
-               for (CTR r : ((CTSimpleField) o).getRArray()) {
-                   XWPFRun cr = new XWPFRun(r, this);
-                   runs.add(cr);
-                   iruns.add(cr);
-               }
-           }
+                XWPFRun r = new XWPFRun((CTR) o, this);
+                runs.add(r);
+                iruns.add(r);
+            }
+            if (o instanceof CTHyperlink) {
+                CTHyperlink link = (CTHyperlink) o;
+                for (CTR r : link.getRArray()) {
+                    XWPFHyperlinkRun hr = new XWPFHyperlinkRun(link, r, this);
+                    runs.add(hr);
+                    iruns.add(hr);
+                }
+            }
+            if (o instanceof CTSdtBlock) {
+                XWPFSDT cc = new XWPFSDT((CTSdtBlock) o, part);
+                iruns.add(cc);
+            }
+            if (o instanceof CTSdtRun) {
+                XWPFSDT cc = new XWPFSDT((CTSdtRun) o, part);
+                iruns.add(cc);
+            }
+            if (o instanceof CTRunTrackChange) {
+                for (CTR r : ((CTRunTrackChange) o).getRArray()) {
+                    XWPFRun cr = new XWPFRun(r, this);
+                    runs.add(cr);
+                    iruns.add(cr);
+                }
+            }
+            if (o instanceof CTSimpleField) {
+                for (CTR r : ((CTSimpleField) o).getRArray()) {
+                    XWPFRun cr = new XWPFRun(r, this);
+                    runs.add(cr);
+                    iruns.add(cr);
+                }
+            }
             if (o instanceof CTSmartTagRun) {
-                // Smart Tags can be nested many times. 
+                // Smart Tags can be nested many times.
                 // This implementation does not preserve the tagging information
                 buildRunsInOrderFromXml(o);
             }
         }
         c.dispose();
     }
-    
+
     @Internal
     public CTP getCTP() {
         return paragraph;
     }
 
-    public List<XWPFRun> getRuns(){
+    public List<XWPFRun> getRuns() {
         return Collections.unmodifiableList(runs);
     }
-    
+
     /**
      * Return literal runs and sdt/content control objects.
+     *
      * @return List<IRunElement>
      */
     public List<IRunElement> getIRuns() {
         return Collections.unmodifiableList(iruns);
     }
-    
-    public boolean isEmpty(){
+
+    public boolean isEmpty() {
         return !paragraph.getDomNode().hasChildNodes();
     }
 
-    public XWPFDocument getDocument(){
+    public XWPFDocument getDocument() {
         return document;
     }
 
@@ -209,8 +213,8 @@ public class XWPFParagraph implements IB
     public String getText() {
         StringBuffer out = new StringBuffer();
         for (IRunElement run : iruns) {
-            if (run instanceof XWPFSDT){
-                out.append(((XWPFSDT)run).getContent().getText());
+            if (run instanceof XWPFSDT) {
+                out.append(((XWPFSDT) run).getContent().getText());
             } else {
                 out.append(run.toString());
             }
@@ -221,28 +225,31 @@ public class XWPFParagraph implements IB
 
     /**
      * Return styleID of the paragraph if style exist for this paragraph
-     * if not, null will be returned     
-     * @return        styleID as String
+     * if not, null will be returned
+     *
+     * @return styleID as String
      */
     public String getStyleID() {
         if (paragraph.getPPr() != null) {
-            if(paragraph.getPPr().getPStyle()!= null) {
-                if (paragraph.getPPr().getPStyle().getVal()!= null)
+            if (paragraph.getPPr().getPStyle() != null) {
+                if (paragraph.getPPr().getPStyle().getVal() != null)
                     return paragraph.getPPr().getPStyle().getVal();
             }
         }
         return null;
-    }        
+    }
+
     /**
      * If style exist for this paragraph
      * NumId of the paragraph will be returned.
-     * If style not exist null will be returned     
-     * @return    NumID as BigInteger
+     * If style not exist null will be returned
+     *
+     * @return NumID as BigInteger
      */
-    public BigInteger getNumID(){
-        if(paragraph.getPPr()!=null){
-            if(paragraph.getPPr().getNumPr()!=null){
-                if(paragraph.getPPr().getNumPr().getNumId()!=null)
+    public BigInteger getNumID() {
+        if (paragraph.getPPr() != null) {
+            if (paragraph.getPPr().getNumPr() != null) {
+                if (paragraph.getPPr().getNumPr().getNumId() != null)
                     return paragraph.getPPr().getNumPr().getNumId().getVal();
             }
         }
@@ -250,14 +257,31 @@ public class XWPFParagraph implements IB
     }
 
     /**
+     * setNumID of Paragraph
+     *
+     * @param numPos
+     */
+    public void setNumID(BigInteger numPos) {
+        if (paragraph.getPPr() == null)
+            paragraph.addNewPPr();
+        if (paragraph.getPPr().getNumPr() == null)
+            paragraph.getPPr().addNewNumPr();
+        if (paragraph.getPPr().getNumPr().getNumId() == null) {
+            paragraph.getPPr().getNumPr().addNewNumId();
+        }
+        paragraph.getPPr().getNumPr().getNumId().setVal(numPos);
+    }
+
+    /**
      * Returns Ilvl of the numeric style for this paragraph.
      * Returns null if this paragraph does not have numeric style.
+     *
      * @return Ilvl as BigInteger
      */
     public BigInteger getNumIlvl() {
-        if(paragraph.getPPr()!=null){
-            if(paragraph.getPPr().getNumPr()!=null){
-                if(paragraph.getPPr().getNumPr().getIlvl()!=null)
+        if (paragraph.getPPr() != null) {
+            if (paragraph.getPPr().getNumPr() != null) {
+                if (paragraph.getPPr().getNumPr().getIlvl() != null)
                     return paragraph.getPPr().getNumPr().getIlvl().getVal();
             }
         }
@@ -266,28 +290,28 @@ public class XWPFParagraph implements IB
 
     /**
      * Returns numbering format for this paragraph, eg bullet or
-     *  lowerLetter.
+     * lowerLetter.
      * Returns null if this paragraph does not have numeric style.
      */
     public String getNumFmt() {
         BigInteger numID = getNumID();
         XWPFNumbering numbering = document.getNumbering();
-        if(numID != null && numbering != null) {
+        if (numID != null && numbering != null) {
             XWPFNum num = numbering.getNum(numID);
-            if(num != null) {
+            if (num != null) {
                 BigInteger ilvl = getNumIlvl();
                 BigInteger abstractNumId = num.getCTNum().getAbstractNumId().getVal();
                 CTAbstractNum anum = numbering.getAbstractNum(abstractNumId).getAbstractNum();
                 CTLvl level = null;
-                for(int i = 0; i < anum.sizeOfLvlArray(); i++) {
+                for (int i = 0; i < anum.sizeOfLvlArray(); i++) {
                     CTLvl lvl = anum.getLvlArray(i);
-                    if(lvl.getIlvl().equals(ilvl)) {
+                    if (lvl.getIlvl().equals(ilvl)) {
                         level = lvl;
                         break;
                     }
                 }
-                if(level != null && level.getNumFmt() != null
-                    && level.getNumFmt().getVal() != null)
+                if (level != null && level.getNumFmt() != null
+                        && level.getNumFmt().getVal() != null)
                     return level.getNumFmt().getVal().toString();
             }
         }
@@ -302,9 +326,9 @@ public class XWPFParagraph implements IB
     public String getNumLevelText() {
         BigInteger numID = getNumID();
         XWPFNumbering numbering = document.getNumbering();
-        if(numID != null && numbering != null) {
+        if (numID != null && numbering != null) {
             XWPFNum num = numbering.getNum(numID);
-            if(num != null) {
+            if (num != null) {
                 BigInteger ilvl = getNumIlvl();
                 CTNum ctNum = num.getCTNum();
                 if (ctNum == null)
@@ -329,68 +353,54 @@ public class XWPFParagraph implements IB
                     return null;
 
                 CTLvl level = null;
-                for(int i = 0; i < anum.sizeOfLvlArray(); i++) {
+                for (int i = 0; i < anum.sizeOfLvlArray(); i++) {
                     CTLvl lvl = anum.getLvlArray(i);
-                    if(lvl != null && lvl.getIlvl() != null && lvl.getIlvl().equals(ilvl)) {
+                    if (lvl != null && lvl.getIlvl() != null && lvl.getIlvl().equals(ilvl)) {
                         level = lvl;
                         break;
                     }
                 }
-                if(level != null && level.getLvlText() != null
-                    && level.getLvlText().getVal() != null)
+                if (level != null && level.getLvlText() != null
+                        && level.getLvlText().getVal() != null)
                     return level.getLvlText().getVal().toString();
             }
         }
         return null;
     }
 
-
     /**
      * Gets the numstartOverride for the paragraph numbering for this paragraph.
+     *
      * @return returns the overridden start number or null if there is no override for this paragraph.
      */
     public BigInteger getNumStartOverride() {
         BigInteger numID = getNumID();
         XWPFNumbering numbering = document.getNumbering();
-        if(numID != null && numbering != null) {
+        if (numID != null && numbering != null) {
             XWPFNum num = numbering.getNum(numID);
 
-            if(num != null) {
+            if (num != null) {
                 CTNum ctNum = num.getCTNum();
                 if (ctNum == null) {
                     return null;
                 }
                 BigInteger ilvl = getNumIlvl();
                 CTNumLvl level = null;
-                for(int i = 0; i < ctNum.sizeOfLvlOverrideArray(); i++) {
+                for (int i = 0; i < ctNum.sizeOfLvlOverrideArray(); i++) {
                     CTNumLvl ctNumLvl = ctNum.getLvlOverrideArray(i);
-                    if(ctNumLvl != null && ctNumLvl.getIlvl() != null &&
-                        ctNumLvl.getIlvl().equals(ilvl)) {
+                    if (ctNumLvl != null && ctNumLvl.getIlvl() != null &&
+                            ctNumLvl.getIlvl().equals(ilvl)) {
                         level = ctNumLvl;
                         break;
                     }
                 }
-                if(level != null && level.getStartOverride() != null) {
+                if (level != null && level.getStartOverride() != null) {
                     return level.getStartOverride().getVal();
                 }
             }
         }
         return null;
     }
-    /**
-     * setNumID of Paragraph
-     * @param numPos
-     */
-    public void setNumID(BigInteger numPos) {
-        if(paragraph.getPPr()==null)
-            paragraph.addNewPPr();
-        if(paragraph.getPPr().getNumPr()==null)
-            paragraph.getPPr().addNewNumPr();
-        if(paragraph.getPPr().getNumPr().getNumId()==null){
-            paragraph.getPPr().getNumPr().addNewNumId();
-        }
-        paragraph.getPPr().getNumPr().getNumId().setVal(numPos);
-    }
 
     /**
      * Returns the text of the paragraph, but not of any objects in the
@@ -398,7 +408,7 @@ public class XWPFParagraph implements IB
      */
     public String getParagraphText() {
         StringBuffer out = new StringBuffer();
-        for(XWPFRun run : runs) {
+        for (XWPFRun run : runs) {
             out.append(run.toString());
         }
         return out.toString();
@@ -409,7 +419,7 @@ public class XWPFParagraph implements IB
      */
     public String getPictureText() {
         StringBuffer out = new StringBuffer();
-        for(XWPFRun run : runs) {
+        for (XWPFRun run : runs) {
             out.append(run.getPictureText());
         }
         return out.toString();
@@ -418,7 +428,7 @@ public class XWPFParagraph implements IB
     /**
      * Returns the footnote text of the paragraph
      *
-     * @return  the footnote text or empty string if the paragraph does not have footnotes
+     * @return the footnote text or empty string if the paragraph does not have footnotes
      */
     public String getFootnoteText() {
         return footnoteText.toString();
@@ -471,6 +481,7 @@ public class XWPFParagraph implements IB
     public int getFontAlignment() {
         return getAlignment().getValue();
     }
+
     public void setFontAlignment(int align) {
         ParagraphAlignment pAlign = ParagraphAlignment.valueOf(align);
         setAlignment(pAlign);
@@ -498,7 +509,7 @@ public class XWPFParagraph implements IB
         CTPPr pr = getCTPPr();
         return (pr == null || !pr.isSetTextAlignment()) ? TextAlignment.AUTO
                 : TextAlignment.valueOf(pr.getTextAlignment().getVal()
-                        .intValue());
+                .intValue());
     }
 
     /**
@@ -524,9 +535,27 @@ public class XWPFParagraph implements IB
         CTPPr pr = getCTPPr();
         CTTextAlignment textAlignment = pr.isSetTextAlignment() ? pr
                 .getTextAlignment() : pr.addNewTextAlignment();
-                STTextAlignment.Enum en = STTextAlignment.Enum
-                        .forInt(valign.getValue());
-                textAlignment.setVal(en);
+        STTextAlignment.Enum en = STTextAlignment.Enum
+                .forInt(valign.getValue());
+        textAlignment.setVal(en);
+    }
+
+    /**
+     * Specifies the border which shall be displayed above a set of paragraphs
+     * which have the same set of paragraph border settings.
+     *
+     * @return paragraphBorder - the top border for the paragraph
+     * @see #setBorderTop(Borders)
+     * @see Borders a list of all types of borders
+     */
+    public Borders getBorderTop() {
+        CTPBdr border = getCTPBrd(false);
+        CTBorder ct = null;
+        if (border != null) {
+            ct = border.getTop();
+        }
+        STBorder.Enum ptrn = (ct != null) ? ct.getVal() : STBorder.NONE;
+        return Borders.valueOf(ptrn.intValue());
     }
 
     /**
@@ -570,20 +599,20 @@ public class XWPFParagraph implements IB
     }
 
     /**
-     * Specifies the border which shall be displayed above a set of paragraphs
-     * which have the same set of paragraph border settings.
+     * Specifies the border which shall be displayed below a set of
+     * paragraphs which have the same set of paragraph border settings.
      *
-     * @return paragraphBorder - the top border for the paragraph
-     * @see #setBorderTop(Borders)
+     * @return paragraphBorder - the bottom border for the paragraph
+     * @see #setBorderBottom(Borders)
      * @see Borders a list of all types of borders
      */
-    public Borders getBorderTop() {
+    public Borders getBorderBottom() {
         CTPBdr border = getCTPBrd(false);
         CTBorder ct = null;
         if (border != null) {
-            ct = border.getTop();
+            ct = border.getBottom();
         }
-        STBorder.Enum ptrn = (ct != null) ? ct.getVal() : STBorder.NONE;
+        STBorder.Enum ptrn = ct != null ? ct.getVal() : STBorder.NONE;
         return Borders.valueOf(ptrn.intValue());
     }
 
@@ -624,18 +653,18 @@ public class XWPFParagraph implements IB
     }
 
     /**
-     * Specifies the border which shall be displayed below a set of
-     * paragraphs which have the same set of paragraph border settings.
+     * Specifies the border which shall be displayed on the left side of the
+     * page around the specified paragraph.
      *
-     * @return paragraphBorder - the bottom border for the paragraph
-     * @see #setBorderBottom(Borders)
-     * @see Borders a list of all types of borders
+     * @return ParagraphBorder - the left border for the paragraph
+     * @see #setBorderLeft(Borders)
+     * @see Borders for a list of all possible borders
      */
-    public Borders getBorderBottom() {
+    public Borders getBorderLeft() {
         CTPBdr border = getCTPBrd(false);
         CTBorder ct = null;
         if (border != null) {
-            ct = border.getBottom();
+            ct = border.getLeft();
         }
         STBorder.Enum ptrn = ct != null ? ct.getVal() : STBorder.NONE;
         return Borders.valueOf(ptrn.intValue());
@@ -673,18 +702,18 @@ public class XWPFParagraph implements IB
     }
 
     /**
-     * Specifies the border which shall be displayed on the left side of the
+     * Specifies the border which shall be displayed on the right side of the
      * page around the specified paragraph.
      *
-     * @return ParagraphBorder - the left border for the paragraph
-     * @see #setBorderLeft(Borders)
+     * @return ParagraphBorder - the right border for the paragraph
+     * @see #setBorderRight(Borders)
      * @see Borders for a list of all possible borders
      */
-    public Borders getBorderLeft() {
+    public Borders getBorderRight() {
         CTPBdr border = getCTPBrd(false);
         CTBorder ct = null;
         if (border != null) {
-            ct = border.getLeft();
+            ct = border.getRight();
         }
         STBorder.Enum ptrn = ct != null ? ct.getVal() : STBorder.NONE;
         return Borders.valueOf(ptrn.intValue());
@@ -722,18 +751,18 @@ public class XWPFParagraph implements IB
     }
 
     /**
-     * Specifies the border which shall be displayed on the right side of the
-     * page around the specified paragraph.
+     * Specifies the border which shall be displayed between each paragraph in a
+     * set of paragraphs which have the same set of paragraph border settings.
      *
-     * @return ParagraphBorder - the right border for the paragraph
-     * @see #setBorderRight(Borders)
+     * @return ParagraphBorder - the between border for the paragraph
+     * @see #setBorderBetween(Borders)
      * @see Borders for a list of all possible borders
      */
-    public Borders getBorderRight() {
+    public Borders getBorderBetween() {
         CTPBdr border = getCTPBrd(false);
         CTBorder ct = null;
         if (border != null) {
-            ct = border.getRight();
+            ct = border.getBetween();
         }
         STBorder.Enum ptrn = ct != null ? ct.getVal() : STBorder.NONE;
         return Borders.valueOf(ptrn.intValue());
@@ -775,21 +804,29 @@ public class XWPFParagraph implements IB
     }
 
     /**
-     * Specifies the border which shall be displayed between each paragraph in a
-     * set of paragraphs which have the same set of paragraph border settings.
+     * Specifies that when rendering this document in a paginated
+     * view, the contents of this paragraph are rendered on the start of a new
+     * page in the document.
+     * <p/>
+     * If this element is omitted on a given paragraph,
+     * its value is determined by the setting previously set at any level of the
+     * style hierarchy (i.e. that previous setting remains unchanged). If this
+     * setting is never specified in the style hierarchy, then this property
+     * shall not be applied. Since the paragraph is specified to start on a new
+     * page, it begins page two even though it could have fit on page one.
+     * </p>
      *
-     * @return ParagraphBorder - the between border for the paragraph
-     * @see #setBorderBetween(Borders)
-     * @see Borders for a list of all possible borders
+     * @return boolean - if page break is set
      */
-    public Borders getBorderBetween() {
-        CTPBdr border = getCTPBrd(false);
-        CTBorder ct = null;
-        if (border != null) {
-            ct = border.getBetween();
+    public boolean isPageBreak() {
+        CTPPr ppr = getCTPPr();
+        CTOnOff ct_pageBreak = ppr.isSetPageBreakBefore() ? ppr
+                .getPageBreakBefore() : null;
+        if (ct_pageBreak != null
+                && ct_pageBreak.getVal().intValue() == STOnOff.INT_TRUE) {
+            return true;
         }
-        STBorder.Enum ptrn = ct != null ? ct.getVal() : STBorder.NONE;
-        return Borders.valueOf(ptrn.intValue());
+        return false;
     }
 
     /**
@@ -819,29 +856,14 @@ public class XWPFParagraph implements IB
     }
 
     /**
-     * Specifies that when rendering this document in a paginated
-     * view, the contents of this paragraph are rendered on the start of a new
-     * page in the document.
-     * <p/>
-     * If this element is omitted on a given paragraph,
-     * its value is determined by the setting previously set at any level of the
-     * style hierarchy (i.e. that previous setting remains unchanged). If this
-     * setting is never specified in the style hierarchy, then this property
-     * shall not be applied. Since the paragraph is specified to start on a new
-     * page, it begins page two even though it could have fit on page one.
-     * </p>
+     * Specifies the spacing that should be added after the last line in this
+     * paragraph in the document in absolute units.
      *
-     * @return boolean - if page break is set
+     * @return int - value representing the spacing after the paragraph
      */
-    public boolean isPageBreak() {
-        CTPPr ppr = getCTPPr();
-        CTOnOff ct_pageBreak = ppr.isSetPageBreakBefore() ? ppr
-                .getPageBreakBefore() : null;
-        if (ct_pageBreak != null
-                && ct_pageBreak.getVal().intValue() == STOnOff.INT_TRUE) {
-            return true;
-        }
-        return false;
+    public int getSpacingAfter() {
+        CTSpacing spacing = getCTSpacing(false);
+        return (spacing != null && spacing.isSetAfter()) ? spacing.getAfter().intValue() : -1;
     }
 
     /**
@@ -869,11 +891,12 @@ public class XWPFParagraph implements IB
      * Specifies the spacing that should be added after the last line in this
      * paragraph in the document in absolute units.
      *
-     * @return int - value representing the spacing after the paragraph
+     * @return bigInteger - value representing the spacing after the paragraph
+     * @see #setSpacingAfterLines(int)
      */
-    public int getSpacingAfter() {
+    public int getSpacingAfterLines() {
         CTSpacing spacing = getCTSpacing(false);
-        return (spacing != null && spacing.isSetAfter()) ? spacing.getAfter().intValue() : -1;
+        return (spacing != null && spacing.isSetAfterLines()) ? spacing.getAfterLines().intValue() : -1;
     }
 
     /**
@@ -899,20 +922,18 @@ public class XWPFParagraph implements IB
         spacing.setAfterLines(bi);
     }
 
-
     /**
-     * Specifies the spacing that should be added after the last line in this
+     * Specifies the spacing that should be added above the first line in this
      * paragraph in the document in absolute units.
      *
-     * @return bigInteger - value representing the spacing after the paragraph
-     * @see #setSpacingAfterLines(int)
+     * @return the spacing that should be added above the first line
+     * @see #setSpacingBefore(int)
      */
-    public int getSpacingAfterLines() {
+    public int getSpacingBefore() {
         CTSpacing spacing = getCTSpacing(false);
-        return (spacing != null && spacing.isSetAfterLines()) ? spacing.getAfterLines().intValue() : -1;
+        return (spacing != null && spacing.isSetBefore()) ? spacing.getBefore().intValue() : -1;
     }
 
-
     /**
      * Specifies the spacing that should be added above the first line in this
      * paragraph in the document in absolute units.
@@ -930,15 +951,16 @@ public class XWPFParagraph implements IB
     }
 
     /**
-     * Specifies the spacing that should be added above the first line in this
-     * paragraph in the document in absolute units.
+     * Specifies the spacing that should be added before the first line in this paragraph in the
+     * document in line units.
+     * The value of this attribute is specified in one hundredths of a line.
      *
-     * @return the spacing that should be added above the first line
-     * @see #setSpacingBefore(int)
+     * @return the spacing that should be added before the first line in this paragraph
+     * @see #setSpacingBeforeLines(int)
      */
-    public int getSpacingBefore() {
+    public int getSpacingBeforeLines() {
         CTSpacing spacing = getCTSpacing(false);
-        return (spacing != null && spacing.isSetBefore()) ? spacing.getBefore().intValue() : -1;
+        return (spacing != null && spacing.isSetBeforeLines()) ? spacing.getBeforeLines().intValue() : -1;
     }
 
     /**
@@ -960,19 +982,20 @@ public class XWPFParagraph implements IB
     }
 
     /**
-     * Specifies the spacing that should be added before the first line in this paragraph in the
-     * document in line units.
-     * The value of this attribute is specified in one hundredths of a line.
+     * Specifies how the spacing between lines is calculated as stored in the
+     * line attribute. If this attribute is omitted, then it shall be assumed to
+     * be of a value auto if a line attribute value is present.
      *
-     * @return the spacing that should be added before the first line in this paragraph
-     * @see #setSpacingBeforeLines(int)
+     * @return rule
+     * @see LineSpacingRule
+     * @see #setSpacingLineRule(LineSpacingRule)
      */
-    public int getSpacingBeforeLines() {
+    public LineSpacingRule getSpacingLineRule() {
         CTSpacing spacing = getCTSpacing(false);
-        return (spacing != null && spacing.isSetBeforeLines()) ? spacing.getBeforeLines().intValue() : -1;
+        return (spacing != null && spacing.isSetLineRule()) ? LineSpacingRule.valueOf(spacing
+                .getLineRule().intValue()) : LineSpacingRule.AUTO;
     }
 
-
     /**
      * Specifies how the spacing between lines is calculated as stored in the
      * line attribute. If this attribute is omitted, then it shall be assumed to
@@ -987,21 +1010,24 @@ public class XWPFParagraph implements IB
     }
 
     /**
-     * Specifies how the spacing between lines is calculated as stored in the
-     * line attribute. If this attribute is omitted, then it shall be assumed to
-     * be of a value auto if a line attribute value is present.
+     * Specifies the indentation which shall be placed between the left text
+     * margin for this paragraph and the left edge of that paragraph's content
+     * in a left to right paragraph, and the right text margin and the right
+     * edge of that paragraph's text in a right to left paragraph
+     * <p/>
+     * If this attribute is omitted, its value shall be assumed to be zero.
+     * Negative values are defined such that the text is moved past the text margin,
+     * positive values move the text inside the text margin.
+     * </p>
      *
-     * @return rule
-     * @see LineSpacingRule
-     * @see #setSpacingLineRule(LineSpacingRule)
+     * @return indentation or null if indentation is not set
      */
-    public LineSpacingRule getSpacingLineRule() {
-        CTSpacing spacing = getCTSpacing(false);
-        return (spacing != null && spacing.isSetLineRule()) ? LineSpacingRule.valueOf(spacing
-                .getLineRule().intValue()) : LineSpacingRule.AUTO;
+    public int getIndentationLeft() {
+        CTInd indentation = getCTInd(false);
+        return (indentation != null && indentation.isSetLeft()) ? indentation.getLeft().intValue()
+                : -1;
     }
 
-
     /**
      * Specifies the indentation which shall be placed between the left text
      * margin for this paragraph and the left edge of that paragraph's content
@@ -1022,8 +1048,8 @@ public class XWPFParagraph implements IB
     }
 
     /**
-     * Specifies the indentation which shall be placed between the left text
-     * margin for this paragraph and the left edge of that paragraph's content
+     * Specifies the indentation which shall be placed between the right text
+     * margin for this paragraph and the right edge of that paragraph's content
      * in a left to right paragraph, and the right text margin and the right
      * edge of that paragraph's text in a right to left paragraph
      * <p/>
@@ -1034,12 +1060,13 @@ public class XWPFParagraph implements IB
      *
      * @return indentation or null if indentation is not set
      */
-    public int getIndentationLeft() {
+
+    public int getIndentationRight() {
         CTInd indentation = getCTInd(false);
-        return (indentation != null && indentation.isSetLeft()) ? indentation.getLeft().intValue()
+        return (indentation != null && indentation.isSetRight()) ? indentation.getRight().intValue()
                 : -1;
     }
-    
+
     /**
      * Specifies the indentation which shall be placed between the right text
      * margin for this paragraph and the right edge of that paragraph's content
@@ -1060,23 +1087,21 @@ public class XWPFParagraph implements IB
     }
 
     /**
-     * Specifies the indentation which shall be placed between the right text
-     * margin for this paragraph and the right edge of that paragraph's content
-     * in a left to right paragraph, and the right text margin and the right
-     * edge of that paragraph's text in a right to left paragraph
-     * <p/>
-     * If this attribute is omitted, its value shall be assumed to be zero.
-     * Negative values are defined such that the text is moved past the text margin,
-     * positive values move the text inside the text margin.
-     * </p>
+     * Specifies the indentation which shall be removed from the first line of
+     * the parent paragraph, by moving the indentation on the first line back
+     * towards the beginning of the direction of text flow.
+     * This indentation is
+     * specified relative to the paragraph indentation which is specified for
+     * all other lines in the parent paragraph.
+     * The firstLine and hanging
+     * attributes are mutually exclusive, if both are specified, then the
+     * firstLine value is ignored.
      *
      * @return indentation or null if indentation is not set
      */
-
-    public int getIndentationRight() {
+    public int getIndentationHanging() {
         CTInd indentation = getCTInd(false);
-        return (indentation != null && indentation.isSetRight()) ? indentation.getRight().intValue()
-                : -1;
+        return (indentation != null && indentation.isSetHanging()) ? indentation.getHanging().intValue() : -1;
     }
 
     /**
@@ -1100,24 +1125,6 @@ public class XWPFParagraph implements IB
     }
 
     /**
-     * Specifies the indentation which shall be removed from the first line of
-     * the parent paragraph, by moving the indentation on the first line back
-     * towards the beginning of the direction of text flow.
-     * This indentation is
-     * specified relative to the paragraph indentation which is specified for
-     * all other lines in the parent paragraph.
-     * The firstLine and hanging
-     * attributes are mutually exclusive, if both are specified, then the
-     * firstLine value is ignored.
-     *
-     * @return indentation or null if indentation is not set
-     */
-    public int getIndentationHanging() {
-        CTInd indentation = getCTInd(false);
-        return (indentation != null && indentation.isSetHanging()) ? indentation.getHanging().intValue() : -1;
-    }
-
-    /**
      * Specifies the additional indentation which shall be applied to the first
      * line of the parent paragraph. This additional indentation is specified
      * relative to the paragraph indentation which is specified for all other
@@ -1126,15 +1133,16 @@ public class XWPFParagraph implements IB
      * mutually exclusive, if both are specified, then the firstLine value is
      * ignored.
      * If the firstLineChars attribute is also specified, then this
-     * value is ignored. If this attribute is omitted, then its value shall be
+     * value is ignored.
+     * If this attribute is omitted, then its value shall be
      * assumed to be zero (if needed).
      *
-     * @param indentation
+     * @return indentation or null if indentation is not set
      */
-    public void setIndentationFirstLine(int indentation) {
-        CTInd indent = getCTInd(true);
-        BigInteger bi = new BigInteger("" + indentation);
-        indent.setFirstLine(bi);
+    public int getIndentationFirstLine() {
+        CTInd indentation = getCTInd(false);
+        return (indentation != null && indentation.isSetFirstLine()) ? indentation.getFirstLine().intValue()
+                : -1;
     }
 
     /**
@@ -1146,21 +1154,21 @@ public class XWPFParagraph implements IB
      * mutually exclusive, if both are specified, then the firstLine value is
      * ignored.
      * If the firstLineChars attribute is also specified, then this
-     * value is ignored.
-     * If this attribute is omitted, then its value shall be
+     * value is ignored. If this attribute is omitted, then its value shall be
      * assumed to be zero (if needed).
      *
-     * @return indentation or null if indentation is not set
+     * @param indentation
      */
-    public int getIndentationFirstLine() {
-        CTInd indentation = getCTInd(false);
-        return (indentation != null && indentation.isSetFirstLine()) ? indentation.getFirstLine().intValue()
-                : -1;
+    public void setIndentationFirstLine(int indentation) {
+        CTInd indent = getCTInd(true);
+        BigInteger bi = new BigInteger("" + indentation);
+        indent.setFirstLine(bi);
     }
 
     public int getIndentFromLeft() {
         return getIndentFromLeft();
     }
+
     public void setIndentFromLeft(int dxaLeft) {
         setIndentationLeft(dxaLeft);
     }
@@ -1168,6 +1176,7 @@ public class XWPFParagraph implements IB
     public int getIndentFromRight() {
         return getIndentFromRight();
     }
+
     public void setIndentFromRight(int dxaRight) {
         setIndentationRight(dxaRight);
     }
@@ -1175,6 +1184,7 @@ public class XWPFParagraph implements IB
     public int getFirstLineIndent() {
         return getIndentationFirstLine();
     }
+
     public void setFirstLineIndent(int first) {
         setIndentationFirstLine(first);
     }
@@ -1185,6 +1195,25 @@ public class XWPFParagraph implements IB
      * (breaking on the character level) or by moving the word to the following
      * line (breaking on the word level).
      *
+     * @return boolean
+     */
+    public boolean isWordWrapped() {
+        CTOnOff wordWrap = getCTPPr().isSetWordWrap() ? getCTPPr()
+                .getWordWrap() : null;
+        if (wordWrap != null) {
+            return (wordWrap.getVal() == STOnOff.ON
+                    || wordWrap.getVal() == STOnOff.TRUE || wordWrap.getVal() == STOnOff.X_1) ? true
+                    : false;
+        }
+        return false;
+    }
+
+    /**
+     * This element specifies whether a consumer shall break Latin text which
+     * exceeds the text extents of a line by breaking the word across two lines
+     * (breaking on the character level) or by moving the word to the following
+     * line (breaking on the word level).
+     *
      * @param wrap - boolean
      */
     public void setWordWrapped(boolean wrap) {
@@ -1195,36 +1224,29 @@ public class XWPFParagraph implements IB
         else
             wordWrap.unsetVal();
     }
+
+    public boolean isWordWrap() {
+        return isWordWrapped();
+    }
+
     @Deprecated
     public void setWordWrap(boolean wrap) {
         setWordWrapped(wrap);
     }
 
     /**
-     * This element specifies whether a consumer shall break Latin text which
-     * exceeds the text extents of a line by breaking the word across two lines
-     * (breaking on the character level) or by moving the word to the following
-     * line (breaking on the word level).
-     *
-     * @return boolean
+     * @return the style of the paragraph
      */
-    public boolean isWordWrapped() {
-        CTOnOff wordWrap = getCTPPr().isSetWordWrap() ? getCTPPr()
-                .getWordWrap() : null;
-        if (wordWrap != null) {
-            return (wordWrap.getVal() == STOnOff.ON
-                    || wordWrap.getVal() == STOnOff.TRUE || wordWrap.getVal() == STOnOff.X_1) ? true
-                    : false;
-        }
-        return false;
-    }
-    public boolean isWordWrap() {
-        return isWordWrapped();
+    public String getStyle() {
+        CTPPr pr = getCTPPr();
+        CTString style = pr.isSetPStyle() ? pr.getPStyle() : null;
+        return style != null ? style.getVal() : null;
     }
 
     /**
      * This method provides a style to the paragraph
      * This is useful when, e.g. an Heading style has to be assigned
+     *
      * @param newStyle
      */
     public void setStyle(String newStyle) {
@@ -1232,15 +1254,6 @@ public class XWPFParagraph implements IB
         CTString style = pr.getPStyle() != null ? pr.getPStyle() : pr.addNewPStyle();
         style.setVal(newStyle);
     }
-    
-    /**
-     * @return  the style of the paragraph
-     */
-    public String getStyle() {
-        CTPPr pr = getCTPPr();
-        CTString style = pr.isSetPStyle() ? pr.getPStyle() : null;
-        return style != null ? style.getVal() : null;
-    }
 
     /**
      * Get a <b>copy</b> of the currently used CTPBrd, if none is used, return
@@ -1287,20 +1300,21 @@ public class XWPFParagraph implements IB
                 : paragraph.getPPr();
         return pr;
     }
-    
-    
+
+
     /**
-     * add a new run at the end of the position of 
+     * add a new run at the end of the position of
      * the content of parameter run
+     *
      * @param run
      */
-    protected void addRun(CTR run){
+    protected void addRun(CTR run) {
         int pos;
         pos = paragraph.sizeOfRArray();
         paragraph.addNewR();
         paragraph.setRArray(pos, run);
     }
-    
+
     /**
      * Appends a new run to this paragraph
      *
@@ -1315,14 +1329,15 @@ public class XWPFParagraph implements IB
 
     /**
      * insert a new Run in RunArray
+     *
      * @param pos
-     * @return  the inserted run
+     * @return the inserted run
      */
-    public XWPFRun insertNewRun(int pos){
+    public XWPFRun insertNewRun(int pos) {
         if (pos >= 0 && pos <= paragraph.sizeOfRArray()) {
             CTR ctRun = paragraph.insertNewR(pos);
             XWPFRun newRun = new XWPFRun(ctRun, this);
-            
+
             // To update the iruns, find where we're going
             // in the normal runs, and go in there
             int iPos = iruns.size();
@@ -1334,10 +1349,10 @@ public class XWPFParagraph implements IB
                 }
             }
             iruns.add(iPos, newRun);
-            
+
             // Runs itself is easy to update
             runs.add(pos, newRun);
-            
+
             return newRun;
         }
         return null;
@@ -1347,42 +1362,43 @@ public class XWPFParagraph implements IB
      * this methods parse the paragraph and search for the string searched.
      * If it finds the string, it will return true and the position of the String
      * will be saved in the parameter startPos.
+     *
      * @param searched
      * @param startPos
      */
-    public TextSegement searchText(String searched,PositionInParagraph startPos) {
-        int startRun = startPos.getRun(), 
-            startText = startPos.getText(),
-            startChar = startPos.getChar();
+    public TextSegement searchText(String searched, PositionInParagraph startPos) {
+        int startRun = startPos.getRun(),
+                startText = startPos.getText(),
+                startChar = startPos.getChar();
         int beginRunPos = 0, candCharPos = 0;
         boolean newList = false;
         CTR[] rArray = paragraph.getRArray();
-        for (int runPos=startRun; runPos<rArray.length; runPos++) {
-            int beginTextPos = 0,beginCharPos = 0, textPos = 0,  charPos = 0;    
+        for (int runPos = startRun; runPos < rArray.length; runPos++) {
+            int beginTextPos = 0, beginCharPos = 0, textPos = 0, charPos = 0;
             CTR ctRun = rArray[runPos];
             XmlCursor c = ctRun.newCursor();
             c.selectPath("./*");
-            while(c.toNextSelection()){
+            while (c.toNextSelection()) {
                 XmlObject o = c.getObject();
-                if(o instanceof CTText){
-                    if(textPos>=startText){
-                        String candidate = ((CTText)o).getStringValue();
-                        if(runPos==startRun)
-                            charPos= startChar;
+                if (o instanceof CTText) {
+                    if (textPos >= startText) {
+                        String candidate = ((CTText) o).getStringValue();
+                        if (runPos == startRun)
+                            charPos = startChar;
                         else
                             charPos = 0;
-                        
-                        for(; charPos<candidate.length(); charPos++){
-                            if((candidate.charAt(charPos)==searched.charAt(0))&&(candCharPos==0)){
+
+                        for (; charPos < candidate.length(); charPos++) {
+                            if ((candidate.charAt(charPos) == searched.charAt(0)) && (candCharPos == 0)) {
                                 beginTextPos = textPos;
                                 beginCharPos = charPos;
                                 beginRunPos = runPos;
                                 newList = true;
                             }
-                            if(candidate.charAt(charPos)==searched.charAt(candCharPos)){
-                                if(candCharPos+1<searched.length())
+                            if (candidate.charAt(charPos) == searched.charAt(candCharPos)) {
+                                if (candCharPos + 1 < searched.length())
                                     candCharPos++;
-                                else if(newList){
+                                else if (newList) {
                                     TextSegement segement = new TextSegement();
                                     segement.setBeginRun(beginRunPos);
                                     segement.setBeginText(beginTextPos);
@@ -1392,57 +1408,55 @@ public class XWPFParagraph implements IB
                                     segement.setEndChar(charPos);
                                     return segement;
                                 }
-                            }
-                            else {
-                                candCharPos=0;
+                            } else {
+                                candCharPos = 0;
                             }
                         }
                     }
                     textPos++;
-                }
-                else if(o instanceof CTProofErr){
+                } else if (o instanceof CTProofErr) {
                     c.removeXml();
-                }
-                else if(o instanceof CTRPr);
+                } else if (o instanceof CTRPr) ;
                     //do nothing
                 else
-                    candCharPos=0;
+                    candCharPos = 0;
             }
 
             c.dispose();
         }
         return null;
     }
-    
+
     /**
      * get a Text
+     *
      * @param segment
      */
-    public String getText(TextSegement segment){
+    public String getText(TextSegement segment) {
         int runBegin = segment.getBeginRun();
         int textBegin = segment.getBeginText();
-        int charBegin = segment.getBeginChar(); 
+        int charBegin = segment.getBeginChar();
         int runEnd = segment.getEndRun();
         int textEnd = segment.getEndText();
-        int charEnd    = segment.getEndChar();
+        int charEnd = segment.getEndChar();
         StringBuilder out = new StringBuilder();
         CTR[] rArray = paragraph.getRArray();
-        for(int i=runBegin; i<=runEnd;i++){
+        for (int i = runBegin; i <= runEnd; i++) {
             CTText[] tArray = rArray[i].getTArray();
-            int startText=0, endText = tArray.length-1;
-            if(i==runBegin)
-                startText=textBegin;
-            if(i==runEnd)
+            int startText = 0, endText = tArray.length - 1;
+            if (i == runBegin)
+                startText = textBegin;
+            if (i == runEnd)
                 endText = textEnd;
-            for(int j=startText;j<=endText;j++){
+            for (int j = startText; j <= endText; j++) {
                 String tmpText = tArray[j].getStringValue();
-                int startChar=0, endChar = tmpText.length()-1;
-                if((j==textBegin)&&(i==runBegin))
-                    startChar=charBegin;
-                if((j==textEnd)&&(i==runEnd)){
+                int startChar = 0, endChar = tmpText.length() - 1;
+                if ((j == textBegin) && (i == runBegin))
+                    startChar = charBegin;
+                if ((j == textEnd) && (i == runEnd)) {
                     endChar = charEnd;
                 }
-                out.append(tmpText.substring(startChar, endChar+1));
+                out.append(tmpText.substring(startChar, endChar + 1));
             }
         }
         return out.toString();
@@ -1450,10 +1464,11 @@ public class XWPFParagraph implements IB
 
     /**
      * removes a Run at the position pos in the paragraph
+     *
      * @param pos
      * @return true if the run was removed
      */
-    public boolean removeRun(int pos){
+    public boolean removeRun(int pos) {
         if (pos >= 0 && pos < paragraph.sizeOfRArray()) {
             // Remove the run from our high level lists
             XWPFRun run = runs.get(pos);
@@ -1468,23 +1483,24 @@ public class XWPFParagraph implements IB
 
     /**
      * returns the type of the BodyElement Paragraph
+     *
      * @see org.apache.poi.xwpf.usermodel.IBodyElement#getElementType()
      */
     public BodyElementType getElementType() {
         return BodyElementType.PARAGRAPH;
     }
 
-    public IBody getBody()
-    {
+    public IBody getBody() {
         return part;
     }
 
     /**
      * returns the part of the bodyElement
+     *
      * @see org.apache.poi.xwpf.usermodel.IBody#getPart()
      */
     public POIXMLDocumentPart getPart() {
-        if(part != null){
+        if (part != null) {
             return part.getPart();
         }
         return null;
@@ -1492,7 +1508,7 @@ public class XWPFParagraph implements IB
 
     /**
      * returns the partType of the bodyPart which owns the bodyElement
-     * 
+     *
      * @see org.apache.poi.xwpf.usermodel.IBody#getPartType()
      */
     public BodyType getPartType() {
@@ -1501,7 +1517,7 @@ public class XWPFParagraph implements IB
 
     /**
      * adds a new Run to the Paragraph
-     * 
+     *
      * @param r
      */
     public void addRun(XWPFRun r) {
@@ -1512,7 +1528,7 @@ public class XWPFParagraph implements IB
 
     /**
      * return the XWPFRun-Element which owns the CTR run-Element
-     * 
+     *
      * @param r
      */
     public XWPFRun getRun(CTR r) {

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFPicture.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFPicture.java?rev=1682473&r1=1682472&r2=1682473&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFPicture.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFPicture.java Fri May 29 14:01:31 2015
@@ -28,51 +28,51 @@ import org.openxmlformats.schemas.drawin
 public class XWPFPicture {
 
     private CTPicture ctPic;
-    private String description;
-    private XWPFRun run;
-
-    public XWPFPicture(CTPicture ctPic, XWPFRun run){
-        this.run = run;
-        this.ctPic = ctPic;
-        description = ctPic.getNvPicPr().getCNvPr().getDescr();
+    private String description;
+    private XWPFRun run;
+
+    public XWPFPicture(CTPicture ctPic, XWPFRun run) {
+        this.run = run;
+        this.ctPic = ctPic;
+        description = ctPic.getNvPicPr().getCNvPr().getDescr();
     }
-
-    /**
-     * Link Picture with PictureData
-     * @param rel
-     */
-    public void setPictureReference(PackageRelationship rel){
-        ctPic.getBlipFill().getBlip().setEmbed(rel.getId());
-    }
-
+
+    /**
+     * Link Picture with PictureData
+     *
+     * @param rel
+     */
+    public void setPictureReference(PackageRelationship rel) {
+        ctPic.getBlipFill().getBlip().setEmbed(rel.getId());
+    }
+
     /**
      * Return the underlying CTPicture bean that holds all properties for this picture
-     *
-     * @return the underlying CTPicture bean
-     */
-    public CTPicture getCTPicture(){
-        return ctPic;
-    }
-
+     *
+     * @return the underlying CTPicture bean
+     */
+    public CTPicture getCTPicture() {
+        return ctPic;
+    }
+
     /**
-     * Get the PictureData of the Picture, if present.
-     * Note - not all kinds of picture have data
-     */
-    public XWPFPictureData getPictureData(){
-        CTBlipFillProperties blipProps = ctPic.getBlipFill();
-
-        if(blipProps == null || !blipProps.isSetBlip()) {
-            // return null if Blip data is missing
-            return null;
-        }
-
-        String blipId = blipProps.getBlip().getEmbed();
-        POIXMLDocumentPart part = run.getParent().getPart();
-        if (part != null)
-        {
-            POIXMLDocumentPart relatedPart = part.getRelationById(blipId);
-            if (relatedPart instanceof XWPFPictureData) {
-                return (XWPFPictureData) relatedPart;
+     * Get the PictureData of the Picture, if present.
+     * Note - not all kinds of picture have data
+     */
+    public XWPFPictureData getPictureData() {
+        CTBlipFillProperties blipProps = ctPic.getBlipFill();
+
+        if (blipProps == null || !blipProps.isSetBlip()) {
+            // return null if Blip data is missing
+            return null;
+        }
+
+        String blipId = blipProps.getBlip().getEmbed();
+        POIXMLDocumentPart part = run.getParent().getPart();
+        if (part != null) {
+            POIXMLDocumentPart relatedPart = part.getRelationById(blipId);
+            if (relatedPart instanceof XWPFPictureData) {
+                return (XWPFPictureData) relatedPart;
             }
         }
         return null;

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFPictureData.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFPictureData.java?rev=1682473&r1=1682472&r2=1682473&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFPictureData.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFPictureData.java Fri May 29 14:01:31 2015
@@ -40,12 +40,13 @@ import org.apache.poi.util.IOUtils;
 public class XWPFPictureData extends POIXMLDocumentPart {
 
     /**
-     * Relationships for each known picture type
-     */
-    protected static final POIXMLRelation[] RELATIONS;
-    static {
-        RELATIONS = new POIXMLRelation[13];
-        RELATIONS[Document.PICTURE_TYPE_EMF] = XWPFRelation.IMAGE_EMF;
+     * Relationships for each known picture type
+     */
+    protected static final POIXMLRelation[] RELATIONS;
+
+    static {
+        RELATIONS = new POIXMLRelation[13];
+        RELATIONS[Document.PICTURE_TYPE_EMF] = XWPFRelation.IMAGE_EMF;
         RELATIONS[Document.PICTURE_TYPE_WMF] = XWPFRelation.IMAGE_WMF;
         RELATIONS[Document.PICTURE_TYPE_PICT] = XWPFRelation.IMAGE_PICT;
         RELATIONS[Document.PICTURE_TYPE_JPEG] = XWPFRelation.IMAGE_JPEG;
@@ -59,24 +60,23 @@ public class XWPFPictureData extends POI
     }
 
     private Long checksum = null;
-
-    /**
-     * Create a new XWPFGraphicData node
-     *
-     */
-    protected XWPFPictureData() {
-        super();
+
+    /**
+     * Create a new XWPFGraphicData node
+     */
+    protected XWPFPictureData() {
+        super();
     }
 
     /**
      * Construct XWPFPictureData from a package part
-     *
-     * @param part the package part holding the drawing data,
-     * @param rel  the package relationship holding this drawing,
-     * the relationship type must be http://schemas.openxmlformats.org/officeDocument/2006/relationships/image
-     */
-    public XWPFPictureData(PackagePart part, PackageRelationship rel) {
-        super(part, rel);
+     *
+     * @param part the package part holding the drawing data,
+     * @param rel  the package relationship holding this drawing,
+     *             the relationship type must be http://schemas.openxmlformats.org/officeDocument/2006/relationships/image
+     */
+    public XWPFPictureData(PackagePart part, PackageRelationship rel) {
+        super(part, rel);
     }
 
     @Override
@@ -91,12 +91,13 @@ public class XWPFPictureData extends POI
      * You can grab the picture data directly from the underlying package part as follows:
      * <br/>
      * <code>
-     * InputStream is = getPackagePart().getInputStream();
-     * </code>
-     * </p>
-     * @return the Picture data.
-     */
-    public byte[] getData() {
+     * InputStream is = getPackagePart().getInputStream();
+     * </code>
+     * </p>
+     *
+     * @return the Picture data.
+     */
+    public byte[] getData() {
         try {
             return IOUtils.toByteArray(getPackagePart().getInputStream());
         } catch (IOException e) {
@@ -115,21 +116,22 @@ public class XWPFPictureData extends POI
             return null;
         return name.substring(name.lastIndexOf('/') + 1);
     }
-
-    /**
-     * Suggests a file extension for this image.
-     * @return the file extension.
-     */
-    public String suggestFileExtension() {
+
+    /**
+     * Suggests a file extension for this image.
+     *
+     * @return the file extension.
+     */
+    public String suggestFileExtension() {
         return getPackagePart().getPartName().getExtension();
     }
-
-    /**
-     * Return an integer constant that specifies type of this picture
-     * 
-     * @return an integer constant that specifies type of this picture
-     * @see org.apache.poi.xwpf.usermodel.Document#PICTURE_TYPE_EMF
-     * @see org.apache.poi.xwpf.usermodel.Document#PICTURE_TYPE_WMF
+
+    /**
+     * Return an integer constant that specifies type of this picture
+     *
+     * @return an integer constant that specifies type of this picture
+     * @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
@@ -217,13 +219,13 @@ public class XWPFPictureData extends POI
 
                 if (!ownPackage.equals(foreignPackage)) {
                     return false;
-                }
-            }
-        }
-        
-        Long foreignChecksum = picData.getChecksum();
-        Long localChecksum = getChecksum();
-
+                }
+            }
+        }
+
+        Long foreignChecksum = picData.getChecksum();
+        Long localChecksum = getChecksum();
+
         if (!(localChecksum.equals(foreignChecksum))) {
             return false;
         }
@@ -233,13 +235,13 @@ public class XWPFPictureData extends POI
     @Override
     public int hashCode() {
         return getChecksum().hashCode();
-    }
-
-    /**
-     * *PictureData objects store the actual content in the part directly without keeping a 
-     * copy like all others therefore we need to handle them differently.
-     */
-    @Override
+    }
+
+    /**
+     * *PictureData objects store the actual content in the part directly without keeping a
+     * copy like all others therefore we need to handle them differently.
+     */
+    @Override
     protected void prepareForCommit() {
         // do not clear the part here
     }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRelation.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRelation.java?rev=1682473&r1=1682472&r2=1682473&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRelation.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRelation.java Fri May 29 14:01:31 2015
@@ -33,7 +33,6 @@ public final class XWPFRelation extends
      */
     protected static final Map<String, XWPFRelation> _table = new HashMap<String, XWPFRelation>();
 
-
     public static final XWPFRelation DOCUMENT = new XWPFRelation(
             "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml",
             "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument",
@@ -41,10 +40,10 @@ public final class XWPFRelation extends
             null
     );
     public static final XWPFRelation TEMPLATE = new XWPFRelation(
-          "application/vnd.openxmlformats-officedocument.wordprocessingml.template.main+xml",
-          "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument",
-          "/word/document.xml",
-          null
+            "application/vnd.openxmlformats-officedocument.wordprocessingml.template.main+xml",
+            "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument",
+            "/word/document.xml",
+            null
     );
     public static final XWPFRelation MACRO_DOCUMENT = new XWPFRelation(
             "application/vnd.ms-word.document.macroEnabled.main+xml",
@@ -64,12 +63,11 @@ public final class XWPFRelation extends
             "/word/glossary/document.xml",
             null
     );
-        
     public static final XWPFRelation NUMBERING = new XWPFRelation(
-    		"application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml",
-    		"http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering",
-    		"/word/numbering.xml",
-    		XWPFNumbering.class
+            "application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml",
+            "http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering",
+            "/word/numbering.xml",
+            XWPFNumbering.class
     );
     public static final XWPFRelation FONT_TABLE = new XWPFRelation(
             "application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml",
@@ -126,10 +124,10 @@ public final class XWPFRelation extends
             null
     );
     public static final XWPFRelation FOOTNOTE = new XWPFRelation(
-           "application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml",
-           "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes",
-           "/word/footnotes.xml",
-           XWPFFootnotes.class
+            "application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml",
+            "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes",
+            "/word/footnotes.xml",
+            XWPFFootnotes.class
     );
     public static final XWPFRelation ENDNOTE = new XWPFRelation(
             null,
@@ -137,52 +135,51 @@ public final class XWPFRelation extends
             null,
             null
     );
-
     /**
      * Supported image formats
      */
     public static final XWPFRelation IMAGE_EMF = new XWPFRelation(
-          "image/x-emf",
-          "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
-          "/word/media/image#.emf",
-          XWPFPictureData.class
-	);
-	public static final XWPFRelation IMAGE_WMF = new XWPFRelation(
-	      "image/x-wmf",
-	      "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
-	      "/word/media/image#.wmf",
-	      XWPFPictureData.class
-	);
-	public static final XWPFRelation IMAGE_PICT = new XWPFRelation(
-	      "image/pict",
-	      "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
-	      "/word/media/image#.pict",
-	      XWPFPictureData.class
-	);
-	public static final XWPFRelation IMAGE_JPEG = new XWPFRelation(
-	      "image/jpeg",
-	      "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
-	      "/word/media/image#.jpeg",
-	      XWPFPictureData.class
-	);
-	public static final XWPFRelation IMAGE_PNG = new XWPFRelation(
-	      "image/png",
-	      "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
-	      "/word/media/image#.png",
-	      XWPFPictureData.class
-	);
-	public static final XWPFRelation IMAGE_DIB = new XWPFRelation(
-	      "image/dib",
-	      "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
-	      "/word/media/image#.dib",
-	      XWPFPictureData.class
-	);
-	public static final XWPFRelation IMAGE_GIF = new XWPFRelation(
-	      "image/gif",
-	      "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
-	      "/word/media/image#.gif",
-	      XWPFPictureData.class
-	);
+            "image/x-emf",
+            "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
+            "/word/media/image#.emf",
+            XWPFPictureData.class
+    );
+    public static final XWPFRelation IMAGE_WMF = new XWPFRelation(
+            "image/x-wmf",
+            "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
+            "/word/media/image#.wmf",
+            XWPFPictureData.class
+    );
+    public static final XWPFRelation IMAGE_PICT = new XWPFRelation(
+            "image/pict",
+            "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
+            "/word/media/image#.pict",
+            XWPFPictureData.class
+    );
+    public static final XWPFRelation IMAGE_JPEG = new XWPFRelation(
+            "image/jpeg",
+            "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
+            "/word/media/image#.jpeg",
+            XWPFPictureData.class
+    );
+    public static final XWPFRelation IMAGE_PNG = new XWPFRelation(
+            "image/png",
+            "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
+            "/word/media/image#.png",
+            XWPFPictureData.class
+    );
+    public static final XWPFRelation IMAGE_DIB = new XWPFRelation(
+            "image/dib",
+            "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
+            "/word/media/image#.dib",
+            XWPFPictureData.class
+    );
+    public static final XWPFRelation IMAGE_GIF = new XWPFRelation(
+            "image/gif",
+            "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
+            "/word/media/image#.gif",
+            XWPFPictureData.class
+    );
     public static final XWPFRelation IMAGE_TIFF = new XWPFRelation(
             "image/tiff",
             "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
@@ -207,14 +204,12 @@ public final class XWPFRelation extends
             "/word/media/image#.wpg",
             XWPFPictureData.class
     );
-
-	public static final XWPFRelation IMAGES = new XWPFRelation(
-	      null,
-	      "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
-	      null,
-	      null
-	);	
-
+    public static final XWPFRelation IMAGES = new XWPFRelation(
+            null,
+            "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
+            null,
+            null
+    );
 
     private XWPFRelation(String type, String rel, String defaultName, Class<? extends POIXMLDocumentPart> cls) {
         super(type, rel, defaultName, cls);



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


Mime
View raw message