poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kiwiwi...@apache.org
Subject svn commit: r1777855 [2/2] - in /poi/trunk/src: examples/src/org/apache/poi/xssf/streaming/examples/ examples/src/org/apache/poi/xssf/usermodel/examples/ examples/src/org/apache/poi/xwpf/usermodel/examples/ java/org/apache/poi/util/ ooxml/java/org/apac...
Date Sun, 08 Jan 2017 00:38:41 GMT
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java?rev=1777855&r1=1777854&r2=1777855&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java Sun Jan  8 00:38:41
2017
@@ -352,15 +352,19 @@ public class XSSFWorkbook extends POIXML
             Map<String, ExternalLinksTable> elIdMap = new HashMap<String, ExternalLinksTable>();
             for(RelationPart rp : getRelationParts()){
                 POIXMLDocumentPart p = rp.getDocumentPart();
-                if(p instanceof SharedStringsTable) sharedStringSource = (SharedStringsTable)p;
-                else if(p instanceof StylesTable) stylesSource = (StylesTable)p;
-                else if(p instanceof ThemesTable) theme = (ThemesTable)p;
-                else if(p instanceof CalculationChain) calcChain = (CalculationChain)p;
-                else if(p instanceof MapInfo) mapInfo = (MapInfo)p;
-                else if (p instanceof XSSFSheet) {
+                if(p instanceof SharedStringsTable) {
+                    sharedStringSource = (SharedStringsTable)p;
+                } else if(p instanceof StylesTable) {
+                    stylesSource = (StylesTable)p;
+                } else if(p instanceof ThemesTable) {
+                    theme = (ThemesTable)p;
+                } else if(p instanceof CalculationChain) {
+                    calcChain = (CalculationChain)p;
+                } else if(p instanceof MapInfo) {
+                    mapInfo = (MapInfo)p;
+                } else if (p instanceof XSSFSheet) {
                     shIdMap.put(rp.getRelationship().getId(), (XSSFSheet)p);
-                }
-                else if (p instanceof ExternalLinksTable) {
+                } else if (p instanceof ExternalLinksTable) {
                     elIdMap.put(rp.getRelationship().getId(), (ExternalLinksTable)p);
                 }
             }
@@ -723,8 +727,9 @@ public class XSSFWorkbook extends POIXML
      */
     @Override
     public XSSFDataFormat createDataFormat() {
-        if (formatter == null)
+        if (formatter == null) {
             formatter = new XSSFDataFormat(stylesSource);
+        }
         return formatter;
     }
 
@@ -827,7 +832,9 @@ public class XSSFWorkbook extends POIXML
         validateSheetName(sheetname);
 
         // YK: Mimic Excel and silently truncate sheet names longer than 31 characters
-        if(sheetname.length() > 31) sheetname = sheetname.substring(0, 31);
+        if(sheetname.length() > 31) {
+            sheetname = sheetname.substring(0, 31);
+        }
         WorkbookUtil.validateSheetName(sheetname);
 
         CTSheet sheet = addSheet(sheetname);
@@ -860,7 +867,9 @@ public class XSSFWorkbook extends POIXML
         wrapper.sheet = sheet;
         sheet.setId(rp.getRelationship().getId());
         sheet.setSheetId(sheetNumber);
-        if (sheets.isEmpty()) wrapper.setSelected(true);
+        if (sheets.isEmpty()) {
+            wrapper.setSelected(true);
+        }
         sheets.add(wrapper);
         return wrapper;
     }
@@ -1082,7 +1091,9 @@ public class XSSFWorkbook extends POIXML
     @Override
     public String getPrintArea(int sheetIndex) {
         XSSFName name = getBuiltInName(XSSFName.BUILTIN_PRINT_AREA, sheetIndex);
-        if (name == null) return null;
+        if (name == null) {
+            return null;
+        }
         //adding one here because 0 indicates a global named region; doesnt make sense for
print areas
         return name.getRefersToFormula();
 
@@ -1146,7 +1157,9 @@ public class XSSFWorkbook extends POIXML
     public int getSheetIndex(Sheet sheet) {
         int idx = 0;
         for(XSSFSheet sh : sheets){
-            if(sh == sheet) return idx;
+            if(sh == sheet) {
+                return idx;
+            }
             idx++;
         }
         return -1;
@@ -1439,7 +1452,9 @@ public class XSSFWorkbook extends POIXML
         List<XSSFName> toRemove = new ArrayList<XSSFName>();
         for (XSSFName nm : namedRanges) {
             CTDefinedName ct = nm.getCTName();
-            if(!ct.isSetLocalSheetId()) continue;
+            if(!ct.isSetLocalSheetId()) {
+                continue;
+            }
             if (ct.getLocalSheetId() == index) {
                 toRemove.add(nm);
             } else if (ct.getLocalSheetId() > index){
@@ -1639,21 +1654,28 @@ public class XSSFWorkbook extends POIXML
      */
     @Override
     public void setSheetName(int sheetIndex, String sheetname) {
+        if (sheetname == null) {
+            throw new IllegalArgumentException( "sheetName must not be null" );
+        }
+        
         validateSheetIndex(sheetIndex);
         String oldSheetName = getSheetName(sheetIndex);
 
         // YK: Mimic Excel and silently truncate sheet names longer than 31 characters
-        if(sheetname != null && sheetname.length() > 31) sheetname = sheetname.substring(0,
31);
+        if(sheetname.length() > 31) {
+            sheetname = sheetname.substring(0, 31);
+        }
         WorkbookUtil.validateSheetName(sheetname);
-        // findbugs fix - validateSheetName has already checked for null value
-        assert(sheetname != null); 
 
         // Do nothing if no change
-        if (sheetname.equals(oldSheetName)) return;
+        if (sheetname.equals(oldSheetName)) {
+            return;
+        }
         
         // Check it isn't already taken
-        if (containsSheet(sheetname, sheetIndex ))
+        if (containsSheet(sheetname, sheetIndex )) {
             throw new IllegalArgumentException( "The workbook already contains a sheet of
this name" );
+        }
 
         // Update references to the name
         XSSFFormulaUtils utils = new XSSFFormulaUtils(this);
@@ -1822,7 +1844,9 @@ public class XSSFWorkbook extends POIXML
      * Returns the Theme of current workbook.
      */
     public ThemesTable getTheme() {
-        if (stylesSource == null) return null;
+        if (stylesSource == null) {
+            return null;
+        }
         return stylesSource.getTheme();
     }
 
@@ -1832,7 +1856,9 @@ public class XSSFWorkbook extends POIXML
      */
     @Override
     public XSSFCreationHelper getCreationHelper() {
-        if(_creationHelper == null) _creationHelper = new XSSFCreationHelper(this);
+        if(_creationHelper == null) {
+            _creationHelper = new XSSFCreationHelper(this);
+        }
         return _creationHelper;
     }
 
@@ -1857,8 +1883,9 @@ public class XSSFWorkbook extends POIXML
                 ctName = ctName.substring(0, MAX_SENSITIVE_SHEET_NAME_LEN);
             }
 
-            if (excludeSheetIdx != i && name.equalsIgnoreCase(ctName))
+            if (excludeSheetIdx != i && name.equalsIgnoreCase(ctName)) {
                 return true;
+            }
         }
         return false;
     }
@@ -2149,7 +2176,9 @@ public class XSSFWorkbook extends POIXML
      *  otherwise the given algorithm is used for calculating the hash password (Excel 2013)
      */
     public void setWorkbookPassword(String password, HashAlgorithm hashAlgo) {
-        if (password == null && !workbookProtectionPresent()) return;
+        if (password == null && !workbookProtectionPresent()) {
+            return;
+        }
         setPassword(safeGetWorkbookProtection(), password, hashAlgo, "workbook");
     }
 
@@ -2159,7 +2188,9 @@ public class XSSFWorkbook extends POIXML
      * @return true, if the hashes match (... though original password may differ ...)
      */
     public boolean validateWorkbookPassword(String password) {
-        if (!workbookProtectionPresent()) return (password == null);
+        if (!workbookProtectionPresent()) {
+            return (password == null);
+        }
         return validatePassword(safeGetWorkbookProtection(), password, "workbook");
     }
 
@@ -2171,7 +2202,9 @@ public class XSSFWorkbook extends POIXML
      *  otherwise the given algorithm is used for calculating the hash password (Excel 2013)
      */
     public void setRevisionsPassword(String password, HashAlgorithm hashAlgo) {
-        if (password == null && !workbookProtectionPresent()) return;
+        if (password == null && !workbookProtectionPresent()) {
+            return;
+        }
         setPassword(safeGetWorkbookProtection(), password, hashAlgo, "revisions");
     }
 
@@ -2181,7 +2214,9 @@ public class XSSFWorkbook extends POIXML
      * @return true if the hashes match (... though original password may differ ...)
      */
     public boolean validateRevisionsPassword(String password) {
-        if (!workbookProtectionPresent()) return (password == null);
+        if (!workbookProtectionPresent()) {
+            return (password == null);
+        }
         return validatePassword(safeGetWorkbookProtection(), password, "revisions");
     }
     

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/util/NumericRanges.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/util/NumericRanges.java?rev=1777855&r1=1777854&r2=1777855&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/util/NumericRanges.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/util/NumericRanges.java Sun Jan  8 00:38:41
2017
@@ -26,20 +26,19 @@ public class NumericRanges {
     public static final int OVERLAPS_2_WRAPS = 3;
     
     public static long[] getOverlappingRange(long[] range1, long[] range2) {
-        int overlappingType = getOverlappingType(range1, range2);
-        if (overlappingType == OVERLAPS_1_MINOR) {
-            return new long[]{range2[0], range1[1]};
+        switch(getOverlappingType(range1, range2)) {
+            case OVERLAPS_1_MINOR:
+                return new long[]{range2[0], range1[1]};
+            case OVERLAPS_2_MINOR:
+                return new long[]{range1[0], range2[1]};
+            case OVERLAPS_2_WRAPS:
+                return range1;
+            case OVERLAPS_1_WRAPS:
+                return range2;
+            default:
+            case NO_OVERLAPS:
+                return new long[]{-1, -1};
         }
-        else if (overlappingType == OVERLAPS_2_MINOR) {
-            return new long[]{range1[0], range2[1]};
-        }
-        else if (overlappingType == OVERLAPS_2_WRAPS) {
-            return range1;
-        }
-        else if (overlappingType == OVERLAPS_1_WRAPS) {
-            return range2;
-        }
-        return new long[]{-1, -1};
     }
     
     public static int getOverlappingType(long[] range1, long[] range2) {
@@ -47,17 +46,18 @@ public class NumericRanges {
         long max1 = range1[1];
         long min2 = range2[0];
         long max2 = range2[1];
-        if (min1 >= min2 && max1 <= max2) {
-            return OVERLAPS_2_WRAPS;
-        }
-        else if (min2 >= min1 && max2 <= max1) {
-            return OVERLAPS_1_WRAPS;
-        }
-        else if ((min2 >= min1 && min2 <= max1) && max2 >= max1)
{
-            return OVERLAPS_1_MINOR;
-        }
-        else if ((min1 >= min2 && min1 <= max2)  && max1 >= max2)
{
-            return OVERLAPS_2_MINOR;
+        if (min1 >= min2) {
+            if (max1 <= max2) {
+                return OVERLAPS_2_WRAPS;
+            } else if (min1 <= max2) {
+                return OVERLAPS_2_MINOR;
+            }
+        } else {
+            if (max1 >= max2) {
+                return OVERLAPS_1_WRAPS;
+            } else if (max1 >= min2) {
+                return OVERLAPS_1_MINOR;
+            }
         }
         return NO_OVERLAPS;
         

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=1777855&r1=1777854&r2=1777855&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 Sun Jan  8 00:38:41
2017
@@ -26,37 +26,7 @@ import org.apache.poi.util.Internal;
 import org.apache.poi.wp.usermodel.Paragraph;
 import org.apache.xmlbeans.XmlCursor;
 import org.apache.xmlbeans.XmlObject;
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTAbstractNum;
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBorder;
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTDecimalNumber;
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFtnEdnRef;
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTHyperlink;
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTInd;
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTJc;
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTLvl;
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTNum;
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTNumLvl;
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTOnOff;
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP;
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPBdr;
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPPr;
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTProofErr;
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTR;
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPr;
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRunTrackChange;
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSdtBlock;
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSdtRun;
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSimpleField;
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSmartTagRun;
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSpacing;
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTString;
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTText;
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTextAlignment;
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.STBorder;
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.STJc;
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.STLineSpacingRule;
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.STOnOff;
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.STTextAlignment;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.*;
 
 /**
  * <p>A Paragraph within a Document, Table, Header etc.</p>
@@ -114,8 +84,8 @@ public class XWPFParagraph implements IB
                     for (XWPFParagraph p : footnote.getParagraphs()) {
                         if (!first) {
                             footnoteText.append("\n");
-                            first = false;
                         }
+                        first = false;
                         footnoteText.append(p.getText());
                     }
 
@@ -204,6 +174,7 @@ public class XWPFParagraph implements IB
         return !paragraph.getDomNode().hasChildNodes();
     }
 
+    @Override
     public XWPFDocument getDocument() {
         return document;
     }
@@ -240,8 +211,9 @@ public class XWPFParagraph implements IB
     public String getStyleID() {
         if (paragraph.getPPr() != null) {
             if (paragraph.getPPr().getPStyle() != null) {
-                if (paragraph.getPPr().getPStyle().getVal() != null)
+                if (paragraph.getPPr().getPStyle().getVal() != null) {
                     return paragraph.getPPr().getPStyle().getVal();
+                }
             }
         }
         return null;
@@ -257,8 +229,9 @@ public class XWPFParagraph implements IB
     public BigInteger getNumID() {
         if (paragraph.getPPr() != null) {
             if (paragraph.getPPr().getNumPr() != null) {
-                if (paragraph.getPPr().getNumPr().getNumId() != null)
+                if (paragraph.getPPr().getNumPr().getNumId() != null) {
                     return paragraph.getPPr().getNumPr().getNumId().getVal();
+                }
             }
         }
         return null;
@@ -270,10 +243,12 @@ public class XWPFParagraph implements IB
      * @param numPos
      */
     public void setNumID(BigInteger numPos) {
-        if (paragraph.getPPr() == null)
+        if (paragraph.getPPr() == null) {
             paragraph.addNewPPr();
-        if (paragraph.getPPr().getNumPr() == null)
+        }
+        if (paragraph.getPPr().getNumPr() == null) {
             paragraph.getPPr().addNewNumPr();
+        }
         if (paragraph.getPPr().getNumPr().getNumId() == null) {
             paragraph.getPPr().getNumPr().addNewNumId();
         }
@@ -289,8 +264,9 @@ public class XWPFParagraph implements IB
     public BigInteger getNumIlvl() {
         if (paragraph.getPPr() != null) {
             if (paragraph.getPPr().getNumPr() != null) {
-                if (paragraph.getPPr().getNumPr().getIlvl() != null)
+                if (paragraph.getPPr().getNumPr().getIlvl() != null) {
                     return paragraph.getPPr().getNumPr().getIlvl().getVal();
+                }
             }
         }
         return null;
@@ -319,8 +295,9 @@ public class XWPFParagraph implements IB
                     }
                 }
                 if (level != null && level.getNumFmt() != null
-                        && level.getNumFmt().getVal() != null)
+                        && level.getNumFmt().getVal() != null) {
                     return level.getNumFmt().getVal().toString();
+                }
             }
         }
         return null;
@@ -339,26 +316,31 @@ public class XWPFParagraph implements IB
             if (num != null) {
                 BigInteger ilvl = getNumIlvl();
                 CTNum ctNum = num.getCTNum();
-                if (ctNum == null)
+                if (ctNum == null) {
                     return null;
+                }
 
                 CTDecimalNumber ctDecimalNumber = ctNum.getAbstractNumId();
-                if (ctDecimalNumber == null)
+                if (ctDecimalNumber == null) {
                     return null;
+                }
 
                 BigInteger abstractNumId = ctDecimalNumber.getVal();
-                if (abstractNumId == null)
+                if (abstractNumId == null) {
                     return null;
+                }
 
                 XWPFAbstractNum xwpfAbstractNum = numbering.getAbstractNum(abstractNumId);
 
-                if (xwpfAbstractNum == null)
+                if (xwpfAbstractNum == null) {
                     return null;
+                }
 
                 CTAbstractNum anum = xwpfAbstractNum.getCTAbstractNum();
 
-                if (anum == null)
+                if (anum == null) {
                     return null;
+                }
 
                 CTLvl level = null;
                 for (int i = 0; i < anum.sizeOfLvlArray(); i++) {
@@ -369,8 +351,9 @@ public class XWPFParagraph implements IB
                     }
                 }
                 if (level != null && level.getLvlText() != null
-                        && level.getLvlText().getVal() != null)
+                        && level.getLvlText().getVal() != null) {
                     return level.getLvlText().getVal().toString();
+                }
             }
         }
         return null;
@@ -486,10 +469,12 @@ public class XWPFParagraph implements IB
     /**
      * @return The raw alignment value, {@link #getAlignment()} is suggested
      */
+    @Override
     public int getFontAlignment() {
         return getAlignment().getValue();
     }
 
+    @Override
     public void setFontAlignment(int align) {
         ParagraphAlignment pAlign = ParagraphAlignment.valueOf(align);
         setAlignment(pAlign);
@@ -600,10 +585,11 @@ public class XWPFParagraph implements IB
         }
 
         CTBorder pr = (ct.isSetTop()) ? ct.getTop() : ct.addNewTop();
-        if (border.getValue() == Borders.NONE.getValue())
+        if (border.getValue() == Borders.NONE.getValue()) {
             ct.unsetTop();
-        else
+        } else {
             pr.setVal(STBorder.Enum.forInt(border.getValue()));
+        }
     }
 
     /**
@@ -654,10 +640,11 @@ public class XWPFParagraph implements IB
     public void setBorderBottom(Borders border) {
         CTPBdr ct = getCTPBrd(true);
         CTBorder pr = ct.isSetBottom() ? ct.getBottom() : ct.addNewBottom();
-        if (border.getValue() == Borders.NONE.getValue())
+        if (border.getValue() == Borders.NONE.getValue()) {
             ct.unsetBottom();
-        else
+        } else {
             pr.setVal(STBorder.Enum.forInt(border.getValue()));
+        }
     }
 
     /**
@@ -703,10 +690,11 @@ public class XWPFParagraph implements IB
     public void setBorderLeft(Borders border) {
         CTPBdr ct = getCTPBrd(true);
         CTBorder pr = ct.isSetLeft() ? ct.getLeft() : ct.addNewLeft();
-        if (border.getValue() == Borders.NONE.getValue())
+        if (border.getValue() == Borders.NONE.getValue()) {
             ct.unsetLeft();
-        else
+        } else {
             pr.setVal(STBorder.Enum.forInt(border.getValue()));
+        }
     }
 
     /**
@@ -752,10 +740,11 @@ public class XWPFParagraph implements IB
     public void setBorderRight(Borders border) {
         CTPBdr ct = getCTPBrd(true);
         CTBorder pr = ct.isSetRight() ? ct.getRight() : ct.addNewRight();
-        if (border.getValue() == Borders.NONE.getValue())
+        if (border.getValue() == Borders.NONE.getValue()) {
             ct.unsetRight();
-        else
+        } else {
             pr.setVal(STBorder.Enum.forInt(border.getValue()));
+        }
     }
 
     /**
@@ -805,10 +794,11 @@ public class XWPFParagraph implements IB
     public void setBorderBetween(Borders border) {
         CTPBdr ct = getCTPBrd(true);
         CTBorder pr = ct.isSetBetween() ? ct.getBetween() : ct.addNewBetween();
-        if (border.getValue() == Borders.NONE.getValue())
+        if (border.getValue() == Borders.NONE.getValue()) {
             ct.unsetBetween();
-        else
+        } else {
             pr.setVal(STBorder.Enum.forInt(border.getValue()));
+        }
     }
 
     /**
@@ -857,10 +847,11 @@ public class XWPFParagraph implements IB
         CTPPr ppr = getCTPPr();
         CTOnOff ctPageBreak = ppr.isSetPageBreakBefore() ? ppr
                 .getPageBreakBefore() : ppr.addNewPageBreakBefore();
-        if (pageBreak)
+        if (pageBreak) {
             ctPageBreak.setVal(STOnOff.TRUE);
-        else
+        } else {
             ctPageBreak.setVal(STOnOff.FALSE);
+        }
     }
 
     /**
@@ -1228,26 +1219,32 @@ public class XWPFParagraph implements IB
         indent.setFirstLine(bi);
     }
 
+    @Override
     public int getIndentFromLeft() {
         return getIndentationLeft();
     }
 
+    @Override
     public void setIndentFromLeft(int dxaLeft) {
         setIndentationLeft(dxaLeft);
     }
 
+    @Override
     public int getIndentFromRight() {
         return getIndentationRight();
     }
 
+    @Override
     public void setIndentFromRight(int dxaRight) {
         setIndentationRight(dxaRight);
     }
 
+    @Override
     public int getFirstLineIndent() {
         return getIndentationFirstLine();
     }
 
+    @Override
     public void setFirstLineIndent(int first) {
         setIndentationFirstLine(first);
     }
@@ -1260,6 +1257,7 @@ public class XWPFParagraph implements IB
      *
      * @return boolean
      */
+    @Override
     public boolean isWordWrapped() {
         CTOnOff wordWrap = getCTPPr().isSetWordWrap() ? getCTPPr()
                 .getWordWrap() : null;
@@ -1279,13 +1277,15 @@ public class XWPFParagraph implements IB
      *
      * @param wrap - boolean
      */
+    @Override
     public void setWordWrapped(boolean wrap) {
         CTOnOff wordWrap = getCTPPr().isSetWordWrap() ? getCTPPr()
                 .getWordWrap() : getCTPPr().addNewWordWrap();
-        if (wrap)
+        if (wrap) {
             wordWrap.setVal(STOnOff.TRUE);
-        else
+        } else {
             wordWrap.unsetVal();
+        }
     }
 
     public boolean isWordWrap() {
@@ -1325,8 +1325,9 @@ public class XWPFParagraph implements IB
     private CTPBdr getCTPBrd(boolean create) {
         CTPPr pr = getCTPPr();
         CTPBdr ct = pr.isSetPBdr() ? pr.getPBdr() : null;
-        if (create && ct == null)
+        if (create && ct == null) {
             ct = pr.addNewPBdr();
+        }
         return ct;
     }
 
@@ -1337,8 +1338,9 @@ public class XWPFParagraph implements IB
     private CTSpacing getCTSpacing(boolean create) {
         CTPPr pr = getCTPPr();
         CTSpacing ct = pr.getSpacing() == null ? null : pr.getSpacing();
-        if (create && ct == null)
+        if (create && ct == null) {
             ct = pr.addNewSpacing();
+        }
         return ct;
     }
 
@@ -1349,8 +1351,9 @@ public class XWPFParagraph implements IB
     private CTInd getCTInd(boolean create) {
         CTPPr pr = getCTPPr();
         CTInd ct = pr.getInd() == null ? null : pr.getInd();
-        if (create && ct == null)
+        if (create && ct == null) {
             ct = pr.addNewInd();
+        }
         return ct;
     }
 
@@ -1536,8 +1539,9 @@ public class XWPFParagraph implements IB
             for (int j = startText; j <= endText; j++) {
                 String tmpText = tArray[j].getStringValue();
                 int startChar = 0, endChar = tmpText.length() - 1;
-                if ((j == textBegin) && (i == runBegin))
+                if ((j == textBegin) && (i == runBegin)) {
                     startChar = charBegin;
+                }
                 if ((j == textEnd) && (i == runEnd)) {
                     endChar = charEnd;
                 }
@@ -1585,10 +1589,12 @@ public class XWPFParagraph implements IB
      *
      * @see org.apache.poi.xwpf.usermodel.IBodyElement#getElementType()
      */
+    @Override
     public BodyElementType getElementType() {
         return BodyElementType.PARAGRAPH;
     }
 
+    @Override
     public IBody getBody() {
         return part;
     }
@@ -1598,6 +1604,7 @@ public class XWPFParagraph implements IB
      *
      * @see org.apache.poi.xwpf.usermodel.IBody#getPart()
      */
+    @Override
     public POIXMLDocumentPart getPart() {
         if (part != null) {
             return part.getPart();
@@ -1610,6 +1617,7 @@ public class XWPFParagraph implements IB
      *
      * @see org.apache.poi.xwpf.usermodel.IBody#getPartType()
      */
+    @Override
     public BodyType getPartType() {
         return part.getPartType();
     }

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=1777855&r1=1777854&r2=1777855&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 Sun Jan  8
00:38:41 2017
@@ -156,11 +156,7 @@ public class XWPFPictureData extends POI
             } catch (IOException e) {
                 throw new POIXMLException(e);
             } finally {
-                try {
-                    if (is != null) is.close();
-                } catch (IOException e) {
-                    throw new POIXMLException(e);
-                }
+                IOUtils.closeQuietly(is);
             }
             this.checksum = IOUtils.calculateChecksum(data);
         }

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestSignatureInfo.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestSignatureInfo.java?rev=1777855&r1=1777854&r2=1777855&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestSignatureInfo.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestSignatureInfo.java Sun Jan
 8 00:38:41 2017
@@ -36,7 +36,11 @@ import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.net.*;
+import java.net.ConnectException;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.SocketTimeoutException;
+import java.net.URL;
 import java.security.Key;
 import java.security.KeyPair;
 import java.security.KeyStore;
@@ -389,17 +393,16 @@ public class TestSignatureInfo {
                 throw e;
             }
             if((e.getCause() instanceof ConnectException) || (e.getCause() instanceof SocketTimeoutException))
{
-                Assume.assumeTrue("Only allowing ConnectException with 'timed out' as message
here, but had: " + e,
+                Assume.assumeFalse("Only allowing ConnectException with 'timed out' as message
here, but had: " + e,
                         e.getCause().getMessage().contains("timed out"));
             } else if (e.getCause() instanceof IOException) {
-                Assume.assumeTrue("Only allowing IOException with 'Error contacting TSP server'
as message here, but had: " + e,
+                Assume.assumeFalse("Only allowing IOException with 'Error contacting TSP
server' as message here, but had: " + e,
                         e.getCause().getMessage().contains("Error contacting TSP server"));
             } else if (e.getCause() instanceof RuntimeException) {
-                Assume.assumeTrue("Only allowing RuntimeException with 'This site is cur'
as message here, but had: " + e,
+                Assume.assumeFalse("Only allowing RuntimeException with 'This site is cur'
as message here, but had: " + e,
                         e.getCause().getMessage().contains("This site is cur"));
-            } else {
-                throw e;
             }
+            throw e;
         }
         
         // verify
@@ -557,7 +560,9 @@ public class TestSignatureInfo {
                 boolean b = si.verifySignature();
                 assertTrue("Signature not correctly calculated for " + ha, b);
             } finally {
-                if (pkg != null) pkg.close();
+                if (pkg != null) {
+                    pkg.close();
+                }
             }
         }
     }



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


Mime
View raw message