poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kiwiwi...@apache.org
Subject svn commit: r1845617 [3/5] - in /poi/branches/hemf: ./ jenkins/ maven/ sonar/ src/examples/src/org/apache/poi/hssf/usermodel/examples/ src/examples/src/org/apache/poi/ss/examples/ src/examples/src/org/apache/poi/xssf/usermodel/examples/ src/java/org/ap...
Date Fri, 02 Nov 2018 18:35:35 GMT
Modified: poi/branches/hemf/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java?rev=1845617&r1=1845616&r2=1845617&view=diff
==============================================================================
--- poi/branches/hemf/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java (original)
+++ poi/branches/hemf/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java Fri Nov  2 18:35:34 2018
@@ -147,6 +147,7 @@ import org.openxmlformats.schemas.spread
  * contain text, numbers, dates, and formulas. Cells can also be formatted.
  * </p>
  */
+@SuppressWarnings("deprecation")
 public class XSSFSheet extends POIXMLDocumentPart implements Sheet  {
     private static final POILogger logger = POILogFactory.getLogger(XSSFSheet.class);
 
@@ -472,7 +473,7 @@ public class XSSFSheet extends POIXMLDoc
     /**
      * Verify that candidate region does not intersect with an existing merged region in this sheet
      *
-     * @param candidateRegion
+     * @param candidateRegion the range of cells to verify
      * @throws IllegalStateException if candidate region intersects an existing merged region in this sheet (or candidateRegion is already merged in this sheet)
      */
     private void validateMergedRegions(CellRangeAddress candidateRegion) {
@@ -855,8 +856,8 @@ public class XSSFSheet extends POIXMLDoc
     /**
      * Get a Hyperlink in this sheet anchored at row, column
      *
-     * @param row
-     * @param column
+     * @param row The row where the hyperlink is anchored
+     * @param column The column where the hyperlinkn is anchored
      * @return hyperlink if there is a hyperlink anchored at row, column; otherwise returns null
      */
     @Override
@@ -1480,8 +1481,9 @@ public class XSSFSheet extends POIXMLDoc
      *
      * @param startRowNum the first row number in this sheet to return
      * @param endRowNum the last row number in this sheet to return
-     * @param createRowIfMissing
-     * @return All rows between startRow and endRow, inclusive
+     * @param createRowIfMissing If missing rows should be created.
+     * @return All rows between startRow and endRow, inclusive. If createRowIfMissing is false,
+     *      only previously existing rows are returned, otherwise empty rows are added as necessary
      * @throws IllegalArgumentException if startRowNum and endRowNum are not in ascending order
      */
     private List<XSSFRow> getRows(int startRowNum, int endRowNum, boolean createRowIfMissing) {
@@ -2472,7 +2474,7 @@ public class XSSFSheet extends POIXMLDoc
      * 'Collapsed' state is stored in a single column col info record
      * immediately after the outline group
      *
-     * @param idx
+     * @param idx The column-index to check
      * @return a boolean represented if the column is collapsed
      */
     private boolean isColumnGroupCollapsed(int idx) {
@@ -3052,7 +3054,7 @@ public class XSSFSheet extends POIXMLDoc
         rebuildRows();
     }
 
-    private final void rebuildRows() {
+    private void rebuildRows() {
         //rebuild the _rows map
         List<XSSFRow> rowList = new ArrayList<>(_rows.values());
         _rows.clear();
@@ -3114,25 +3116,22 @@ public class XSSFSheet extends POIXMLDoc
         // then do the actual moving and also adjust comments/rowHeight
         // we need to sort it in a way so the shifting does not mess up the structures,
         // i.e. when shifting down, start from down and go up, when shifting up, vice-versa
-        SortedMap<XSSFComment, Integer> commentsToShift = new TreeMap<>(new Comparator<XSSFComment>() {
-            @Override
-            public int compare(XSSFComment o1, XSSFComment o2) {
-                int row1 = o1.getRow();
-                int row2 = o2.getRow();
-
-                if (row1 == row2) {
-                    // ordering is not important when row is equal, but don't return zero to still
-                    // get multiple comments per row into the map
-                    return o1.hashCode() - o2.hashCode();
-                }
+        SortedMap<XSSFComment, Integer> commentsToShift = new TreeMap<>((o1, o2) -> {
+            int row1 = o1.getRow();
+            int row2 = o2.getRow();
+
+            if (row1 == row2) {
+                // ordering is not important when row is equal, but don't return zero to still
+                // get multiple comments per row into the map
+                return o1.hashCode() - o2.hashCode();
+            }
 
-                // when shifting down, sort higher row-values first
-                if (n > 0) {
-                    return row1 < row2 ? 1 : -1;
-                } else {
-                    // sort lower-row values first when shifting up
-                    return row1 > row2 ? 1 : -1;
-                }
+            // when shifting down, sort higher row-values first
+            if (n > 0) {
+                return row1 < row2 ? 1 : -1;
+            } else {
+                // sort lower-row values first when shifting up
+                return row1 > row2 ? 1 : -1;
             }
         });
 
@@ -3211,25 +3210,22 @@ public class XSSFSheet extends POIXMLDoc
         // then do the actual moving and also adjust comments/rowHeight
         // we need to sort it in a way so the shifting does not mess up the structures, 
         // i.e. when shifting down, start from down and go up, when shifting up, vice-versa
-        SortedMap<XSSFComment, Integer> commentsToShift = new TreeMap<>(new Comparator<XSSFComment>() {
-            @Override
-            public int compare(XSSFComment o1, XSSFComment o2) {
-                int column1 = o1.getColumn();
-                int column2 = o2.getColumn();
-
-                if (column1 == column2) {
-                    // ordering is not important when row is equal, but don't return zero to still 
-                    // get multiple comments per row into the map
-                    return o1.hashCode() - o2.hashCode();
-                }
+        SortedMap<XSSFComment, Integer> commentsToShift = new TreeMap<>((o1, o2) -> {
+            int column1 = o1.getColumn();
+            int column2 = o2.getColumn();
+
+            if (column1 == column2) {
+                // ordering is not important when row is equal, but don't return zero to still
+                // get multiple comments per row into the map
+                return o1.hashCode() - o2.hashCode();
+            }
 
-                // when shifting down, sort higher row-values first
-                if (n > 0) {
-                    return column1 < column2 ? 1 : -1;
-                } else {
-                    // sort lower-row values first when shifting up
-                    return column1 > column2 ? 1 : -1;
-                }
+            // when shifting down, sort higher row-values first
+            if (n > 0) {
+                return column1 < column2 ? 1 : -1;
+            } else {
+                // sort lower-row values first when shifting up
+                return column1 > column2 ? 1 : -1;
             }
         });
 
@@ -4096,7 +4092,7 @@ public class XSSFSheet extends POIXMLDoc
      * Creates a new Table, and associates it with this Sheet.
      *
      * @param tableArea
-     *            the area that the table should cover, should not be {@null}
+     *            the area that the table should cover, should not be null
      * @return the created table
      * @since 4.0.0
      */
@@ -4421,18 +4417,15 @@ public class XSSFSheet extends POIXMLDoc
                     + "defined source sheet " + sourceSheet.getSheetName() + ".");
         }
 
-        return createPivotTable(position, sourceSheet, new PivotTableReferenceConfigurator() {
-            @Override
-            public void configureReference(CTWorksheetSource wsSource) {
-                final String[] firstCell = source.getFirstCell().getCellRefParts();
-                final String firstRow = firstCell[1];
-                final String firstCol = firstCell[2];
-                final String[] lastCell = source.getLastCell().getCellRefParts();
-                final String lastRow = lastCell[1];
-                final String lastCol = lastCell[2];
-                final String ref = firstCol+firstRow+':'+lastCol+lastRow; //or just source.formatAsString()
-                wsSource.setRef(ref);
-            }
+        return createPivotTable(position, sourceSheet, wsSource -> {
+            final String[] firstCell = source.getFirstCell().getCellRefParts();
+            final String firstRow = firstCell[1];
+            final String firstCol = firstCell[2];
+            final String[] lastCell = source.getLastCell().getCellRefParts();
+            final String lastRow = lastCell[1];
+            final String lastCol = lastCell[2];
+            final String ref = firstCol+firstRow+':'+lastCol+lastRow; //or just source.formatAsString()
+            wsSource.setRef(ref);
         });
     }
 
@@ -4494,12 +4487,7 @@ public class XSSFSheet extends POIXMLDoc
                     + "defined source sheet " + sourceSheet.getSheetName() + ".");
         }
 
-        return createPivotTable(position, sourceSheet, new PivotTableReferenceConfigurator() {
-            @Override
-            public void configureReference(CTWorksheetSource wsSource) {
-                wsSource.setName(source.getNameName());
-            }
-        });
+        return createPivotTable(position, sourceSheet, wsSource -> wsSource.setName(source.getNameName()));
     }
 
     /**
@@ -4523,12 +4511,7 @@ public class XSSFSheet extends POIXMLDoc
      */
     @Beta
     public XSSFPivotTable createPivotTable(final Table source, CellReference position) {
-        return createPivotTable(position, getWorkbook().getSheet(source.getSheetName()), new PivotTableReferenceConfigurator() {
-            @Override
-            public void configureReference(CTWorksheetSource wsSource) {
-                wsSource.setName(source.getName());
-            }
-        });
+        return createPivotTable(position, getWorkbook().getSheet(source.getSheetName()), wsSource -> wsSource.setName(source.getName()));
     }
 
     /**
@@ -4621,8 +4604,10 @@ public class XSSFSheet extends POIXMLDoc
 
     /**
      *  when a cell with a 'master' shared formula is removed,  the next cell in the range becomes the master
+     * @param cell The cell that is removed
+     * @param evalWb BaseXSSFEvaluationWorkbook in use, if one exists
      */
-    protected void onDeleteFormula(XSSFCell cell){
+    protected void onDeleteFormula(XSSFCell cell, BaseXSSFEvaluationWorkbook evalWb){
 
         CTCellFormula f = cell.getCTCell().getF();
         if (f != null && f.getT() == STCellFormulaType.SHARED && f.isSetRef() && f.getStringValue() != null) {
@@ -4634,9 +4619,9 @@ public class XSSFSheet extends POIXMLDoc
                     XSSFRow row = getRow(i);
                     if(row != null) for(int j = cell.getColumnIndex(); j <= ref.getLastColumn(); j++){
                         XSSFCell nextCell = row.getCell(j);
-                        if(nextCell != null && nextCell != cell){
+                        if(nextCell != null && nextCell != cell && nextCell.getCellType() == CellType.FORMULA){
                             CTCellFormula nextF = nextCell.getCTCell().getF();
-                            nextF.setStringValue(nextCell.getCellFormula());
+                            nextF.setStringValue(nextCell.getCellFormula(evalWb));
                             CellRangeAddress nextRef = new CellRangeAddress(
                                     nextCell.getRowIndex(), ref.getLastRow(),
                                     nextCell.getColumnIndex(), ref.getLastColumn());

Modified: poi/branches/hemf/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbookFactory.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbookFactory.java?rev=1845617&r1=1845616&r2=1845617&view=diff
==============================================================================
--- poi/branches/hemf/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbookFactory.java (original)
+++ poi/branches/hemf/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbookFactory.java Fri Nov  2 18:35:34 2018
@@ -29,6 +29,14 @@ import org.apache.poi.openxml4j.opc.ZipP
 import org.apache.poi.ss.usermodel.WorkbookFactory;
 
 public class XSSFWorkbookFactory extends WorkbookFactory {
+    /**
+     * Create a new empty Workbook
+     *
+     * @return The created workbook
+     */
+    public static XSSFWorkbook createWorkbook() {
+        return new XSSFWorkbook();
+    }
 
     /**
      * Creates a XSSFWorkbook from the given OOXML Package.
@@ -42,7 +50,6 @@ public class XSSFWorkbookFactory extends
      *  @return The created Workbook
      *
      *  @throws IOException if an error occurs while reading the data
-     * @throws InvalidFormatException
      */
     public static XSSFWorkbook create(OPCPackage pkg) throws IOException {
         return createWorkbook(pkg);
@@ -59,7 +66,6 @@ public class XSSFWorkbookFactory extends
      *  @return The created Workbook
      *
      *  @throws IOException if an error occurs while reading the data
-     * @throws InvalidFormatException
      */
     public static XSSFWorkbook createWorkbook(ZipPackage pkg) throws IOException {
         return createWorkbook((OPCPackage)pkg);
@@ -76,7 +82,6 @@ public class XSSFWorkbookFactory extends
      *  @return The created Workbook
      *
      *  @throws IOException if an error occurs while reading the data
-     * @throws InvalidFormatException
      */
     public static XSSFWorkbook createWorkbook(OPCPackage pkg) throws IOException {
         try {
@@ -122,13 +127,11 @@ public class XSSFWorkbookFactory extends
      * @return The created Workbook
      *
      * @throws IOException if an error occurs while reading the data
-     * @throws InvalidFormatException
+     * @throws InvalidFormatException if the package is not valid.
      */
     @SuppressWarnings("resource")
     public static XSSFWorkbook createWorkbook(InputStream stream) throws IOException, InvalidFormatException {
         OPCPackage pkg = OPCPackage.open(stream);
         return createWorkbook(pkg);
     }
-
-
 }

Modified: poi/branches/hemf/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/ColumnHelper.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/ColumnHelper.java?rev=1845617&r1=1845616&r2=1845617&view=diff
==============================================================================
--- poi/branches/hemf/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/ColumnHelper.java (original)
+++ poi/branches/hemf/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/ColumnHelper.java Fri Nov  2 18:35:34 2018
@@ -50,7 +50,7 @@ public class ColumnHelper {
         TreeSet<CTCol> trackedCols = new TreeSet<>(CTColComparator.BY_MIN_MAX);
         CTCols newCols = CTCols.Factory.newInstance();
         CTCols[] colsArray = worksheet.getColsArray();
-        int i = 0;
+        int i;
         for (i = 0; i < colsArray.length; i++) {
             CTCols cols = colsArray[i];
             for (CTCol col : cols.getColList()) {
@@ -61,7 +61,7 @@ public class ColumnHelper {
             worksheet.removeCols(y);
         }
         
-        newCols.setColArray(trackedCols.toArray(new CTCol[trackedCols.size()]));
+        newCols.setColArray(trackedCols.toArray(new CTCol[0]));
         worksheet.addNewCols();
         worksheet.setColsArray(0, newCols);
     }

Modified: poi/branches/hemf/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSDTContent.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSDTContent.java?rev=1845617&r1=1845616&r2=1845617&view=diff
==============================================================================
--- poi/branches/hemf/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSDTContent.java (original)
+++ poi/branches/hemf/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSDTContent.java Fri Nov  2 18:35:34 2018
@@ -40,21 +40,27 @@ public class XWPFSDTContent implements I
 
     // private final IBody part;
     // private final XWPFDocument document;
-    private List<XWPFParagraph> paragraphs = new ArrayList<>();
-    private List<XWPFTable> tables = new ArrayList<>();
-    private List<XWPFRun> runs = new ArrayList<>();
-    private List<XWPFSDT> contentControls = new ArrayList<>();
+    // private List<XWPFParagraph> paragraphs = new ArrayList<>();
+    // private List<XWPFTable> tables = new ArrayList<>();
+    // private List<XWPFRun> runs = new ArrayList<>();
+    // private List<XWPFSDT> contentControls = new ArrayList<>();
     private List<ISDTContents> bodyElements = new ArrayList<>();
 
     public XWPFSDTContent(CTSdtContentRun sdtRun, IBody part, IRunBody parent) {
+        if (sdtRun == null) {
+            return;
+        }
         for (CTR ctr : sdtRun.getRArray()) {
             XWPFRun run = new XWPFRun(ctr, parent);
-            runs.add(run);
+            // runs.add(run);
             bodyElements.add(run);
         }
     }
 
     public XWPFSDTContent(CTSdtContentBlock block, IBody part, IRunBody parent) {
+        if (block == null) {
+            return;
+        }
         XmlCursor cursor = block.newCursor();
         cursor.selectPath("./*");
         while (cursor.toNextSelection()) {
@@ -62,24 +68,25 @@ public class XWPFSDTContent implements I
             if (o instanceof CTP) {
                 XWPFParagraph p = new XWPFParagraph((CTP) o, part);
                 bodyElements.add(p);
-                paragraphs.add(p);
+                // paragraphs.add(p);
             } else if (o instanceof CTTbl) {
                 XWPFTable t = new XWPFTable((CTTbl) o, part);
                 bodyElements.add(t);
-                tables.add(t);
+                // tables.add(t);
             } else if (o instanceof CTSdtBlock) {
                 XWPFSDT c = new XWPFSDT(((CTSdtBlock) o), part);
                 bodyElements.add(c);
-                contentControls.add(c);
+                // contentControls.add(c);
             } else if (o instanceof CTR) {
                 XWPFRun run = new XWPFRun((CTR) o, parent);
-                runs.add(run);
+                // runs.add(run);
                 bodyElements.add(run);
             }
         }
         cursor.dispose();
     }
 
+    @Override
     public String getText() {
         StringBuilder text = new StringBuilder();
         boolean addNewLine = false;
@@ -130,6 +137,7 @@ public class XWPFSDTContent implements I
         }
     }
 
+    @Override
     public String toString() {
         return getText();
     }

Modified: poi/branches/hemf/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTable.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTable.java?rev=1845617&r1=1845616&r2=1845617&view=diff
==============================================================================
--- poi/branches/hemf/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTable.java (original)
+++ poi/branches/hemf/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTable.java Fri Nov  2 18:35:34 2018
@@ -161,8 +161,9 @@ public class XWPFTable implements IBodyE
         this.ctTbl = table;
 
         // is an empty table: I add one row and one column as default
-        if (table.sizeOfTrArray() == 0)
+        if (table.sizeOfTrArray() == 0) {
             createEmptyTable(table);
+        }
 
         for (CTRow row : table.getTrList()) {
             StringBuilder rowText = new StringBuilder();
@@ -233,7 +234,7 @@ public class XWPFTable implements IBodyE
         return text.toString();
     }
 
-    
+
     /**
      * This method has existed since 2008 without an implementation.
      * It will be removed unless an implementation is provided.
@@ -288,7 +289,7 @@ public class XWPFTable implements IBodyE
     /**
      * Get the width value as an integer.
      * <p>If the width type is AUTO, DXA, or NIL, the value is 20ths of a point. If
-     * the width type is PCT, the value is the percentage times 50 (e.g., 2500 for 50%).</p> 
+     * the width type is PCT, the value is the percentage times 50 (e.g., 2500 for 50%).</p>
      * @return width value as an integer
      */
     public int getWidth() {
@@ -322,7 +323,7 @@ public class XWPFTable implements IBodyE
     }
 
     /**
-     * Returns CTTblPr object for table. If force parameter is true, will 
+     * Returns CTTblPr object for table. If force parameter is true, will
      * create the element if necessary. If force parameter is false, returns
      * null when CTTblPr element is missing.
      *
@@ -343,7 +344,7 @@ public class XWPFTable implements IBodyE
     private CTTblBorders getTblBorders(boolean force) {
         CTTblPr tblPr = getTblPr(force);
         return tblPr == null ? null
-               : tblPr.isSetTblBorders() ? tblPr.getTblBorders() 
+               : tblPr.isSetTblBorders() ? tblPr.getTblBorders()
                : force ? tblPr.addNewTblBorders()
                : null;
     }
@@ -413,18 +414,18 @@ public class XWPFTable implements IBodyE
                 : tPr.isSetJc() ? TableRowAlign.valueOf(tPr.getJc().getVal().intValue())
                 : null;
     }
-    
+
     /**
      * Set table alignment to specified {@link TableRowAlign}
      *
-     * @param ha {@link TableRowAlign} to set
+     * @param tra {@link TableRowAlign} to set
      */
     public void setTableAlignment(TableRowAlign tra) {
         CTTblPr tPr = getTblPr(true);
         CTJc jc = tPr.isSetJc() ? tPr.getJc() : tPr.addNewJc();
         jc.setVal(STJc.Enum.forInt(tra.getValue()));
     }
-    
+
     /**
      * Removes the table alignment attribute from a table
      */
@@ -434,7 +435,7 @@ public class XWPFTable implements IBodyE
             tPr.unsetJc();
         }
     }
-    
+
     private void addColumn(XWPFTableRow tabRow, int sizeCol) {
         if (sizeCol > 0) {
             for (int i = 0; i < sizeCol; i++) {
@@ -486,7 +487,7 @@ public class XWPFTable implements IBodyE
 
     /**
      * Get inside horizontal border size
-     * 
+     *
      * @return The width of the Inside Horizontal borders in 1/8th points,
      * -1 if missing.
      */
@@ -496,7 +497,7 @@ public class XWPFTable implements IBodyE
 
     /**
      * Get inside horizontal border spacing
-     * 
+     *
      * @return The offset to the Inside Horizontal borders in points,
      * -1 if missing.
      */
@@ -506,7 +507,7 @@ public class XWPFTable implements IBodyE
 
     /**
      * Get inside horizontal border color
-     * 
+     *
      * @return The color of the Inside Horizontal borders, null if missing.
      */
     public String getInsideHBorderColor() {
@@ -524,7 +525,7 @@ public class XWPFTable implements IBodyE
 
     /**
      * Get inside vertical border size
-     * 
+     *
      * @return The width of the Inside vertical borders in 1/8th points,
      * -1 if missing.
      */
@@ -534,7 +535,7 @@ public class XWPFTable implements IBodyE
 
     /**
      * Get inside vertical border spacing
-     * 
+     *
      * @return The offset to the Inside vertical borders in points,
      * -1 if missing.
      */
@@ -544,7 +545,7 @@ public class XWPFTable implements IBodyE
 
     /**
      * Get inside vertical border color
-     * 
+     *
      * @return The color of the Inside vertical borders, null if missing.
      */
     public String getInsideVBorderColor() {
@@ -562,7 +563,7 @@ public class XWPFTable implements IBodyE
 
     /**
      * Get top border size
-     * 
+     *
      * @return The width of the top borders in 1/8th points,
      * -1 if missing.
      */
@@ -572,7 +573,7 @@ public class XWPFTable implements IBodyE
 
     /**
      * Get top border spacing
-     * 
+     *
      * @return The offset to the top borders in points,
      * -1 if missing.
      */
@@ -582,7 +583,7 @@ public class XWPFTable implements IBodyE
 
     /**
      * Get top border color
-     * 
+     *
      * @return The color of the top borders, null if missing.
      */
     public String getTopBorderColor() {
@@ -600,7 +601,7 @@ public class XWPFTable implements IBodyE
 
     /**
      * Get bottom border size
-     * 
+     *
      * @return The width of the bottom borders in 1/8th points,
      * -1 if missing.
      */
@@ -610,7 +611,7 @@ public class XWPFTable implements IBodyE
 
     /**
      * Get bottom border spacing
-     * 
+     *
      * @return The offset to the bottom borders in points,
      * -1 if missing.
      */
@@ -620,7 +621,7 @@ public class XWPFTable implements IBodyE
 
     /**
      * Get bottom border color
-     * 
+     *
      * @return The color of the bottom borders, null if missing.
      */
     public String getBottomBorderColor() {
@@ -638,7 +639,7 @@ public class XWPFTable implements IBodyE
 
     /**
      * Get Left border size
-     * 
+     *
      * @return The width of the Left borders in 1/8th points,
      * -1 if missing.
      */
@@ -648,7 +649,7 @@ public class XWPFTable implements IBodyE
 
     /**
      * Get Left border spacing
-     * 
+     *
      * @return The offset to the Left borders in points,
      * -1 if missing.
      */
@@ -658,7 +659,7 @@ public class XWPFTable implements IBodyE
 
     /**
      * Get Left border color
-     * 
+     *
      * @return The color of the Left borders, null if missing.
      */
     public String getLeftBorderColor() {
@@ -676,7 +677,7 @@ public class XWPFTable implements IBodyE
 
     /**
      * Get Right border size
-     * 
+     *
      * @return The width of the Right borders in 1/8th points,
      * -1 if missing.
      */
@@ -686,7 +687,7 @@ public class XWPFTable implements IBodyE
 
     /**
      * Get Right border spacing
-     * 
+     *
      * @return The offset to the Right borders in points,
      * -1 if missing.
      */
@@ -696,7 +697,7 @@ public class XWPFTable implements IBodyE
 
     /**
      * Get Right border color
-     * 
+     *
      * @return The color of the Right borders, null if missing.
      */
     public String getRightBorderColor() {
@@ -770,7 +771,7 @@ public class XWPFTable implements IBodyE
      *      of a point) and a maximum value of 96 (twelve points). Any values outside this
      *      range may be reassigned to a more appropriate value.
      * @param space - Specifies the spacing offset that shall be used to place this border on the table
-     * @param rgbColor - This color may either be presented as a hex value (in RRGGBB format), 
+     * @param rgbColor - This color may either be presented as a hex value (in RRGGBB format),
      *      or auto to allow a consumer to automatically determine the border color as appropriate.
      */
     public void setInsideHBorder(XWPFBorderType type, int size, int space, String rgbColor) {
@@ -786,7 +787,7 @@ public class XWPFTable implements IBodyE
      *      of a point) and a maximum value of 96 (twelve points). Any values outside this
      *      range may be reassigned to a more appropriate value.
      * @param space - Specifies the spacing offset that shall be used to place this border on the table
-     * @param rgbColor - This color may either be presented as a hex value (in RRGGBB format), 
+     * @param rgbColor - This color may either be presented as a hex value (in RRGGBB format),
      *      or auto to allow a consumer to automatically determine the border color as appropriate.
      */
     public void setInsideVBorder(XWPFBorderType type, int size, int space, String rgbColor) {
@@ -802,7 +803,7 @@ public class XWPFTable implements IBodyE
      *      of a point) and a maximum value of 96 (twelve points). Any values outside this
      *      range may be reassigned to a more appropriate value.
      * @param space - Specifies the spacing offset that shall be used to place this border on the table
-     * @param rgbColor - This color may either be presented as a hex value (in RRGGBB format), 
+     * @param rgbColor - This color may either be presented as a hex value (in RRGGBB format),
      *      or auto to allow a consumer to automatically determine the border color as appropriate.
      */
     public void setTopBorder(XWPFBorderType type, int size, int space, String rgbColor) {
@@ -818,7 +819,7 @@ public class XWPFTable implements IBodyE
      *      of a point) and a maximum value of 96 (twelve points). Any values outside this
      *      range may be reassigned to a more appropriate value.
      * @param space - Specifies the spacing offset that shall be used to place this border on the table
-     * @param rgbColor - This color may either be presented as a hex value (in RRGGBB format), 
+     * @param rgbColor - This color may either be presented as a hex value (in RRGGBB format),
      *      or auto to allow a consumer to automatically determine the border color as appropriate.
      */
     public void setBottomBorder(XWPFBorderType type, int size, int space, String rgbColor) {
@@ -834,7 +835,7 @@ public class XWPFTable implements IBodyE
      *      of a point) and a maximum value of 96 (twelve points). Any values outside this
      *      range may be reassigned to a more appropriate value.
      * @param space - Specifies the spacing offset that shall be used to place this border on the table
-     * @param rgbColor - This color may either be presented as a hex value (in RRGGBB format), 
+     * @param rgbColor - This color may either be presented as a hex value (in RRGGBB format),
      *      or auto to allow a consumer to automatically determine the border color as appropriate.
      */
     public void setLeftBorder(XWPFBorderType type, int size, int space, String rgbColor) {
@@ -850,7 +851,7 @@ public class XWPFTable implements IBodyE
      *      of a point) and a maximum value of 96 (twelve points). Any values outside this
      *      range may be reassigned to a more appropriate value.
      * @param space - Specifies the spacing offset that shall be used to place this border on the table
-     * @param rgbColor - This color may either be presented as a hex value (in RRGGBB format), 
+     * @param rgbColor - This color may either be presented as a hex value (in RRGGBB format),
      *      or auto to allow a consumer to automatically determine the border color as appropriate.
      */
     public void setRightBorder(XWPFBorderType type, int size, int space, String rgbColor) {
@@ -872,14 +873,14 @@ public class XWPFTable implements IBodyE
     public void removeInsideHBorder() {
         removeBorder(Border.INSIDE_H);
     }
-    
+
     /**
      * Remove inside vertical borders for table
      */
     public void removeInsideVBorder() {
         removeBorder(Border.INSIDE_V);
     }
-    
+
     /**
      * Remove top borders for table
      */
@@ -893,21 +894,21 @@ public class XWPFTable implements IBodyE
     public void removeBottomBorder() {
         removeBorder(Border.BOTTOM);
     }
-    
+
     /**
      * Remove left borders for table
      */
     public void removeLeftBorder() {
         removeBorder(Border.LEFT);
     }
-    
+
     /**
      * Remove right borders for table
      */
     public void removeRightBorder() {
         removeBorder(Border.RIGHT);
     }
-    
+
     /**
      * Remove all borders from table
      */
@@ -959,7 +960,7 @@ public class XWPFTable implements IBodyE
     }
 
     /**
-     * removes the Borders node from Table properties if there are 
+     * removes the Borders node from Table properties if there are
      * no border elements
      */
     private void cleanupTblBorders() {
@@ -976,7 +977,7 @@ public class XWPFTable implements IBodyE
             }
         }
     }
-    
+
     public int getCellMarginTop() {
         return getCellMargin(CTTblCellMar::getTop);
     }
@@ -1095,10 +1096,12 @@ public class XWPFTable implements IBodyE
      *
      * @see org.apache.poi.xwpf.usermodel.IBodyElement#getElementType()
      */
+    @Override
     public BodyElementType getElementType() {
         return BodyElementType.TABLE;
     }
 
+    @Override
     public IBody getBody() {
         return part;
     }
@@ -1108,6 +1111,7 @@ public class XWPFTable implements IBodyE
      *
      * @see org.apache.poi.xwpf.usermodel.IBody#getPart()
      */
+    @Override
     public POIXMLDocumentPart getPart() {
         if (part != null) {
             return part.getPart();
@@ -1120,6 +1124,7 @@ public class XWPFTable implements IBodyE
      *
      * @see org.apache.poi.xwpf.usermodel.IBody#getPartType()
      */
+    @Override
     public BodyType getPartType() {
         return part.getPartType();
     }
@@ -1130,11 +1135,13 @@ public class XWPFTable implements IBodyE
      */
     public XWPFTableRow getRow(CTRow row) {
         for (int i = 0; i < getRows().size(); i++) {
-            if (getRows().get(i).getCtRow() == row) return getRow(i);
+            if (getRows().get(i).getCtRow() == row) {
+                return getRow(i);
+            }
         }
         return null;
     }
-    
+
     /**
      * Get the table width as a decimal value.
      * <p>If the width type is DXA or AUTO, then the value will always have
@@ -1159,14 +1166,14 @@ public class XWPFTable implements IBodyE
     protected static double getWidthDecimal(CTTblWidth ctWidth) {
         double result = 0.0;
         STTblWidth.Enum typeValue = ctWidth.getType();
-        if (typeValue == STTblWidth.DXA 
-                || typeValue == STTblWidth.AUTO 
+        if (typeValue == STTblWidth.DXA
+                || typeValue == STTblWidth.AUTO
                 || typeValue == STTblWidth.NIL) {
             result = 0.0 + ctWidth.getW().intValue();
         } else if (typeValue == STTblWidth.PCT) {
             // Percentage values are stored as integers that are 50 times
             // percentage.
-            result = ctWidth.getW().intValue() / 50.0;                    
+            result = ctWidth.getW().intValue() / 50.0;
         } else {
             // Should never get here
         }
@@ -1230,7 +1237,7 @@ public class XWPFTable implements IBodyE
     protected static void setWidthValue(String widthValue, CTTblWidth ctWidth) {
         if (!widthValue.matches(REGEX_WIDTH_VALUE)) {
             throw new RuntimeException("Table width value \"" + widthValue + "\" "
-                    + "must match regular expression \"" + REGEX_WIDTH_VALUE + "\"."); 
+                    + "must match regular expression \"" + REGEX_WIDTH_VALUE + "\".");
         }
         if (widthValue.matches("auto")) {
             ctWidth.setType(STTblWidth.AUTO);
@@ -1240,13 +1247,13 @@ public class XWPFTable implements IBodyE
         } else {
             // Must be an integer
             ctWidth.setW(new BigInteger(widthValue));
-            ctWidth.setType(STTblWidth.DXA);            
+            ctWidth.setType(STTblWidth.DXA);
         }
     }
 
     /**
      * Set the underlying table width value to a percentage value.
-     * @param ctWidth The CTTblWidth to set the value on 
+     * @param ctWidth The CTTblWidth to set the value on
      * @param widthValue String width value in form "33.3%" or an integer that is 50 times desired percentage value (e.g,
      * 2500 for 50%)
      * @since 4.0.0
@@ -1257,7 +1264,7 @@ public class XWPFTable implements IBodyE
             String numberPart = widthValue.substring(0,  widthValue.length() - 1);
             double percentage = Double.parseDouble(numberPart) * 50;
             long intValue = Math.round(percentage);
-            ctWidth.setW(BigInteger.valueOf(intValue));            
+            ctWidth.setW(BigInteger.valueOf(intValue));
         } else if (widthValue.matches("[0-9]+")) {
             ctWidth.setW(new BigInteger(widthValue));
         } else {
@@ -1275,7 +1282,7 @@ public class XWPFTable implements IBodyE
      * @since 4.0.0
      */
     public void setWidthType(TableWidthType widthType) {
-        setWidthType(widthType, getTblPr().getTblW());        
+        setWidthType(widthType, getTblPr().getTblW());
     }
 
     /**

Modified: poi/branches/hemf/src/ooxml/testcases/org/apache/poi/ooxml/util/OOXMLLite.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/ooxml/testcases/org/apache/poi/ooxml/util/OOXMLLite.java?rev=1845617&r1=1845616&r2=1845617&view=diff
==============================================================================
--- poi/branches/hemf/src/ooxml/testcases/org/apache/poi/ooxml/util/OOXMLLite.java (original)
+++ poi/branches/hemf/src/ooxml/testcases/org/apache/poi/ooxml/util/OOXMLLite.java Fri Nov  2 18:35:34 2018
@@ -17,18 +17,6 @@
 
 package org.apache.poi.ooxml.util;
 
-import junit.framework.TestCase;
-import org.apache.poi.util.IOUtils;
-import org.apache.poi.util.StringUtil;
-import org.apache.poi.util.SuppressForbidden;
-import org.apache.xmlbeans.StringEnumAbstractBase;
-import org.junit.Test;
-import org.junit.internal.TextListener;
-import org.junit.runner.Description;
-import org.junit.runner.JUnitCore;
-import org.junit.runner.Result;
-import org.reflections.Reflections;
-
 import java.io.File;
 import java.io.IOException;
 import java.lang.reflect.Field;
@@ -38,11 +26,29 @@ import java.security.AccessController;
 import java.security.CodeSource;
 import java.security.PrivilegedAction;
 import java.security.ProtectionDomain;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.Vector;
 import java.util.jar.JarEntry;
 import java.util.jar.JarFile;
 import java.util.regex.Pattern;
 
+import org.apache.poi.util.IOUtils;
+import org.apache.poi.util.StringUtil;
+import org.apache.poi.util.SuppressForbidden;
+import org.apache.xmlbeans.StringEnumAbstractBase;
+import org.junit.Test;
+import org.junit.internal.TextListener;
+import org.junit.runner.Description;
+import org.junit.runner.JUnitCore;
+import org.junit.runner.Result;
+import org.reflections.Reflections;
+
+import junit.framework.TestCase;
+
 /**
  * Build a 'lite' version of the ooxml-schemas.jar
  *
@@ -74,12 +80,12 @@ public final class OOXMLLite {
     }
 
     public static void main(String[] args) throws IOException {
-        System.out.println("Free memory (bytes): " + 
+        System.out.println("Free memory (bytes): " +
                 Runtime.getRuntime().freeMemory());
         long maxMemory = Runtime.getRuntime().maxMemory();
-        System.out.println("Maximum memory (bytes): " + 
+        System.out.println("Maximum memory (bytes): " +
         (maxMemory == Long.MAX_VALUE ? "no limit" : maxMemory));
-        System.out.println("Total memory (bytes): " + 
+        System.out.println("Total memory (bytes): " +
                 Runtime.getRuntime().totalMemory());
 
         String dest = null, test = null, ooxml = null;
@@ -87,13 +93,13 @@ public final class OOXMLLite {
         for (int i = 0; i < args.length; i++) {
             switch (args[i]) {
                 case "-dest":
-                    dest = args[++i];
+                    dest = args[++i]; // lgtm[java/index-out-of-bounds]
                     break;
                 case "-test":
-                    test = args[++i];
+                    test = args[++i]; // lgtm[java/index-out-of-bounds]
                     break;
                 case "-ooxml":
-                    ooxml = args[++i];
+                    ooxml = args[++i]; // lgtm[java/index-out-of-bounds]
                     break;
             }
         }
@@ -248,7 +254,7 @@ public final class OOXMLLite {
                 return true;
             }
         }
-        
+
         // also check super classes
         if(testclass.getSuperclass() != null) {
             for (Method m : testclass.getSuperclass().getDeclaredMethods()) {
@@ -257,7 +263,7 @@ public final class OOXMLLite {
                 }
             }
         }
-        
+
         System.out.println("Class " + testclass.getName() + " does not derive from TestCase and does not have a @Test annotation");
 
         // Should we also look at superclasses to find cases
@@ -286,8 +292,12 @@ public final class OOXMLLite {
             String path = arg.getAbsolutePath();
             String prefix = root.getAbsolutePath();
             String cls = path.substring(prefix.length() + 1).replace(File.separator, ".");
-            if(!cls.matches(ptrn)) return;
-            if (cls.matches(exclude)) return;
+            if(!cls.matches(ptrn)) {
+                return;
+            }
+            if (cls.matches(exclude)) {
+                return;
+            }
             //ignore inner classes defined in tests
             if (cls.indexOf('$') != -1) {
                 System.out.println("Inner class " + cls + " not included");
@@ -315,10 +325,11 @@ public final class OOXMLLite {
      */
     @SuppressWarnings("unchecked")
     private static Set<Class<?>> getLoadedClasses(String ptrn) {
-        // make the field accessible, we defer this from static initialization to here to 
+        // make the field accessible, we defer this from static initialization to here to
         // allow JDKs which do not have this field (e.g. IBM JDK) to at least load the class
         // without failing, see https://issues.apache.org/bugzilla/show_bug.cgi?id=56550
         final Field _classes = AccessController.doPrivileged(new PrivilegedAction<Field>() {
+            @Override
             @SuppressForbidden("TODO: Reflection works until Java 8 on Oracle/Sun JDKs, but breaks afterwards (different classloader types, access checks)")
             public Field run() {
                 try {
@@ -339,11 +350,17 @@ public final class OOXMLLite {
             for (Class<?> cls : classes) {
                 // e.g. proxy-classes, ...
                 ProtectionDomain pd = cls.getProtectionDomain();
-                if (pd == null) continue;
+                if (pd == null) {
+                    continue;
+                }
                 CodeSource cs = pd.getCodeSource();
-                if (cs == null) continue;
+                if (cs == null) {
+                    continue;
+                }
                 URL loc = cs.getLocation();
-                if (loc == null) continue;
+                if (loc == null) {
+                    continue;
+                }
 
                 String jar = loc.toString();
                 if (jar.contains(ptrn)) {

Modified: poi/branches/hemf/src/ooxml/testcases/org/apache/poi/openxml4j/opc/ZipFileAssert.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/ooxml/testcases/org/apache/poi/openxml4j/opc/ZipFileAssert.java?rev=1845617&r1=1845616&r2=1845617&view=diff
==============================================================================
--- poi/branches/hemf/src/ooxml/testcases/org/apache/poi/openxml4j/opc/ZipFileAssert.java (original)
+++ poi/branches/hemf/src/ooxml/testcases/org/apache/poi/openxml4j/opc/ZipFileAssert.java Fri Nov  2 18:35:34 2018
@@ -30,7 +30,6 @@ import java.io.IOException;
 import java.util.Set;
 import java.util.TreeMap;
 
-import junit.framework.AssertionFailedError;
 import org.apache.commons.compress.archivers.ArchiveEntry;
 import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream;
 import org.apache.poi.util.IOUtils;
@@ -44,125 +43,130 @@ import org.xmlunit.diff.Diff;
 import org.xmlunit.diff.DifferenceEvaluator;
 import org.xmlunit.diff.ElementSelectors;
 
+import junit.framework.AssertionFailedError;
+
 /**
  * Compare the contents of 2 zip files.
  */
 public final class ZipFileAssert {
-	private ZipFileAssert() {
-	}
+    private ZipFileAssert() {
+    }
 
-	private static void equals(
-			TreeMap<String, ByteArrayOutputStream> file1,
-			TreeMap<String, ByteArrayOutputStream> file2) {
-		Set<String> listFile1 = file1.keySet();
-		Assert.assertEquals("not the same number of files in zip:", listFile1.size(), file2.keySet().size());
-		
-		for (String fileName : listFile1) {
-			// extract the contents for both
-			ByteArrayOutputStream contain1 = file1.get(fileName);
-			ByteArrayOutputStream contain2 = file2.get(fileName);
-
-			assertNotNull(fileName + " not found in 2nd zip", contain2);
-			// no need to check for contain1. The key come from it
-
-			if (fileName.matches(".*\\.(xml|rels)$")) {
-				// we have a xml file
-				final Diff diff = DiffBuilder.
-						compare(Input.fromByteArray(contain1.toByteArray())).
-						withTest(Input.fromByteArray(contain2.toByteArray())).
-						ignoreWhitespace().
-						checkForSimilar().
-						withDifferenceEvaluator(new IgnoreXMLDeclEvaluator()).
-						withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byNameAndAllAttributes, ElementSelectors.byNameAndText)).
-						build();
-				assertFalse(fileName+": "+diff.toString(), diff.hasDifferences());
+    private static void equals(
+            TreeMap<String, ByteArrayOutputStream> file1,
+            TreeMap<String, ByteArrayOutputStream> file2) {
+        Set<String> listFile1 = file1.keySet();
+        Assert.assertEquals("not the same number of files in zip:", listFile1.size(), file2.keySet().size());
+
+        for (String fileName : listFile1) {
+            // extract the contents for both
+            ByteArrayOutputStream contain1 = file1.get(fileName);
+            ByteArrayOutputStream contain2 = file2.get(fileName);
+
+            assertNotNull(fileName + " not found in 2nd zip", contain2);
+            // no need to check for contain1. The key come from it
+
+            if (fileName.matches(".*\\.(xml|rels)$")) {
+                // we have a xml file
+                final Diff diff = DiffBuilder.
+                        compare(Input.fromByteArray(contain1.toByteArray())).
+                        withTest(Input.fromByteArray(contain2.toByteArray())).
+                        ignoreWhitespace().
+                        checkForSimilar().
+                        withDifferenceEvaluator(new IgnoreXMLDeclEvaluator()).
+                        withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byNameAndAllAttributes, ElementSelectors.byNameAndText)).
+                        build();
+                assertFalse(fileName+": "+diff.toString(), diff.hasDifferences());
             } else {
-				// not xml, may be an image or other binary format
+                // not xml, may be an image or other binary format
                 Assert.assertEquals(fileName + " does not have the same size in both zip:", contain1.size(), contain2.size());
-				assertArrayEquals("contents differ", contain1.toByteArray(), contain2.toByteArray());
-			}
-		}
-	}
-
-	private static TreeMap<String, ByteArrayOutputStream> decompress(
-			File filename) throws IOException {
-		// store the zip content in memory
-		// let s assume it is not Go ;-)
-		TreeMap<String, ByteArrayOutputStream> zipContent = new TreeMap<>();
-
-		/* Open file to decompress */
-		FileInputStream file_decompress = new FileInputStream(filename);
-
-		/* Create a buffer for the decompressed files */
-		BufferedInputStream buffi = new BufferedInputStream(file_decompress);
-
-		/* Open the file with the buffer */
-		ZipArchiveInputStream zis = new ZipArchiveInputStream(buffi);
-
-		/* Processing entries of the zip file */
-		ArchiveEntry entree;
-		while ((entree = zis.getNextEntry()) != null) {
-
-			/* Create a array for the current entry */
-			ByteArrayOutputStream byteArray = new ByteArrayOutputStream();
-			IOUtils.copy(zis, byteArray);
-			zipContent.put(entree.getName(), byteArray);
-		}
-
-		zis.close();
-
-		return zipContent;
-	}
-
-	/**
-	 * Asserts that two files are equal. Throws an <tt>AssertionFailedError</tt>
-	 * if they are not.
-	 * <p>
-	 * 
-	 */
-	public static void assertEquals(File expected, File actual) {
-		assertNotNull(expected);
-		assertNotNull(actual);
-
-		assertTrue("File does not exist [" + expected.getAbsolutePath()
-				+ "]", expected.exists());
-		assertTrue("File does not exist [" + actual.getAbsolutePath()
-				+ "]", actual.exists());
-
-		assertTrue("Expected file not readable", expected.canRead());
-		assertTrue("Actual file not readable", actual.canRead());
-
-		try {
-			TreeMap<String, ByteArrayOutputStream> file1 = decompress(expected);
-			TreeMap<String, ByteArrayOutputStream> file2 = decompress(actual);
-			equals(file1, file2);
-		} catch (IOException e) {
-			throw new AssertionFailedError(e.toString());
-		}
-	}
-
-	private static class IgnoreXMLDeclEvaluator implements DifferenceEvaluator {
-		public ComparisonResult evaluate(final Comparison comparison, final ComparisonResult outcome) {
-			if (outcome != ComparisonResult.EQUAL) {
-				// only evaluate differences
-				switch (comparison.getType()) {
-					case CHILD_NODELIST_SEQUENCE:
-					case XML_STANDALONE:
-					case NAMESPACE_PREFIX:
-						return ComparisonResult.SIMILAR;
-					case TEXT_VALUE:
-						switch (comparison.getControlDetails().getTarget().getParentNode().getNodeName()) {
-						case "dcterms:created":
-						case "dc:creator":
-							return ComparisonResult.SIMILAR;
-						}
-						break;
-					default:
-						break;
-				}
-			}
-
-			return outcome;
-		}
-	}
+                assertArrayEquals("contents differ", contain1.toByteArray(), contain2.toByteArray());
+            }
+        }
+    }
+
+    private static TreeMap<String, ByteArrayOutputStream> decompress(
+            File filename) throws IOException {
+        // store the zip content in memory
+        // let s assume it is not Go ;-)
+        TreeMap<String, ByteArrayOutputStream> zipContent = new TreeMap<>();
+
+        try (
+        /* Open file to decompress */
+        FileInputStream file_decompress = new FileInputStream(filename);
+
+        /* Create a buffer for the decompressed files */
+        BufferedInputStream buffi = new BufferedInputStream(file_decompress);
+
+        /* Open the file with the buffer */
+        ZipArchiveInputStream zis = new ZipArchiveInputStream(buffi);
+        ) {
+
+            /* Processing entries of the zip file */
+            ArchiveEntry entree;
+            while ((entree = zis.getNextEntry()) != null) {
+
+                /* Create a array for the current entry */
+                ByteArrayOutputStream byteArray = new ByteArrayOutputStream();
+                IOUtils.copy(zis, byteArray);
+                zipContent.put(entree.getName(), byteArray);
+            }
+
+        }
+
+        return zipContent;
+    }
+
+    /**
+     * Asserts that two files are equal. Throws an <tt>AssertionFailedError</tt>
+     * if they are not.
+     * <p>
+     *
+     */
+    public static void assertEquals(File expected, File actual) {
+        assertNotNull(expected);
+        assertNotNull(actual);
+
+        assertTrue("File does not exist [" + expected.getAbsolutePath()
+                + "]", expected.exists());
+        assertTrue("File does not exist [" + actual.getAbsolutePath()
+                + "]", actual.exists());
+
+        assertTrue("Expected file not readable", expected.canRead());
+        assertTrue("Actual file not readable", actual.canRead());
+
+        try {
+            TreeMap<String, ByteArrayOutputStream> file1 = decompress(expected);
+            TreeMap<String, ByteArrayOutputStream> file2 = decompress(actual);
+            equals(file1, file2);
+        } catch (IOException e) {
+            throw new AssertionFailedError(e.toString());
+        }
+    }
+
+    private static class IgnoreXMLDeclEvaluator implements DifferenceEvaluator {
+        @Override
+        public ComparisonResult evaluate(final Comparison comparison, final ComparisonResult outcome) {
+            if (outcome != ComparisonResult.EQUAL) {
+                // only evaluate differences
+                switch (comparison.getType()) {
+                    case CHILD_NODELIST_SEQUENCE:
+                    case XML_STANDALONE:
+                    case NAMESPACE_PREFIX:
+                        return ComparisonResult.SIMILAR;
+                    case TEXT_VALUE:
+                        switch (comparison.getControlDetails().getTarget().getParentNode().getNodeName()) {
+                        case "dcterms:created":
+                        case "dc:creator":
+                            return ComparisonResult.SIMILAR;
+                        }
+                        break;
+                    default:
+                        break;
+                }
+            }
+
+            return outcome;
+        }
+    }
 }

Modified: poi/branches/hemf/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/TestOPCComplianceCoreProperties.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/TestOPCComplianceCoreProperties.java?rev=1845617&r1=1845616&r2=1845617&view=diff
==============================================================================
--- poi/branches/hemf/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/TestOPCComplianceCoreProperties.java (original)
+++ poi/branches/hemf/src/ooxml/testcases/org/apache/poi/openxml4j/opc/compliance/TestOPCComplianceCoreProperties.java Fri Nov  2 18:35:34 2018
@@ -83,9 +83,7 @@ public final class TestOPCComplianceCore
         try {
             InputStream is = OpenXML4JTestDataSamples.openComplianceSampleStream("OPCCompliance_CoreProperties_OnlyOneCorePropertiesPart.docx");
             pkg = OPCPackage.open(is);
-        } catch (InvalidFormatException e) {
-            throw new RuntimeException(e);
-        } catch (IOException e) {
+        } catch (InvalidFormatException | IOException e) {
             throw new RuntimeException(e);
         }
         pkg.revert();
@@ -151,9 +149,7 @@ public final class TestOPCComplianceCore
         OPCPackage pkg;
         try {
             pkg = OPCPackage.open(is);
-        } catch (InvalidFormatException e) {
-            throw new RuntimeException(e);
-        } catch (IOException e) {
+        } catch (InvalidFormatException | IOException e) {
             throw new RuntimeException(e);
         }
         URI partUri = createURI("/docProps/core2.xml");

Modified: poi/branches/hemf/src/ooxml/testcases/org/apache/poi/sl/TestFonts.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/ooxml/testcases/org/apache/poi/sl/TestFonts.java?rev=1845617&r1=1845616&r2=1845617&view=diff
==============================================================================
--- poi/branches/hemf/src/ooxml/testcases/org/apache/poi/sl/TestFonts.java (original)
+++ poi/branches/hemf/src/ooxml/testcases/org/apache/poi/sl/TestFonts.java Fri Nov  2 18:35:34 2018
@@ -74,7 +74,7 @@ public class TestFonts {
     // currently linux and mac return quite different values
     private static final int[] expected_sizes = {
             304, // windows 10, 1080p, MS Office 2016, system text scaling 100% instead of default 125%
-            306, // Windows 10, 15.6" 3840x2160
+            306, 308,// Windows 10, 15.6" 3840x2160
             311, 312, 313, 318,
             348, // Windows 10, 15.6" 3840x2160
             362, // Windows 10, 13.3" 1080p high-dpi

Modified: poi/branches/hemf/src/ooxml/testcases/org/apache/poi/ss/TestWorkbookFactory.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/ooxml/testcases/org/apache/poi/ss/TestWorkbookFactory.java?rev=1845617&r1=1845616&r2=1845617&view=diff
==============================================================================
--- poi/branches/hemf/src/ooxml/testcases/org/apache/poi/ss/TestWorkbookFactory.java (original)
+++ poi/branches/hemf/src/ooxml/testcases/org/apache/poi/ss/TestWorkbookFactory.java Fri Nov  2 18:35:34 2018
@@ -17,18 +17,25 @@
 
 package org.apache.poi.ss;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 import java.io.ByteArrayInputStream;
 import java.io.File;
+import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.FileNotFoundException;
 
 import org.apache.poi.EmptyFileException;
 import org.apache.poi.EncryptedDocumentException;
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.POIDataSamples;
 import org.apache.poi.hssf.HSSFTestDataSamples;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.openxml4j.opc.OPCPackage;
+import org.apache.poi.openxml4j.opc.PackageAccess;
 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.ss.usermodel.WorkbookFactory;
@@ -36,16 +43,14 @@ import org.apache.poi.util.POILogFactory
 import org.apache.poi.util.POILogger;
 import org.apache.poi.util.TempFile;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
-import org.apache.poi.openxml4j.opc.OPCPackage;
-import org.apache.poi.openxml4j.opc.PackageAccess;
 import org.apache.poi.xssf.usermodel.XSSFWorkbookFactory;
 import org.junit.Test;
 
 public final class TestWorkbookFactory {
     private static final String xls = "SampleSS.xls";
     private static final String xlsx = "SampleSS.xlsx";
-    private static final String[] xls_prot = new String[] {"password.xls", "password"};
-    private static final String[] xlsx_prot = new String[]{"protected_passtika.xlsx", "tika"};
+    private static final String[] xls_protected = new String[] {"password.xls", "password"};
+    private static final String[] xlsx_protected = new String[]{"protected_passtika.xlsx", "tika"};
     private static final String txt = "SampleSS.txt";
     
     private static final POILogger LOGGER = POILogFactory.getLogger(TestWorkbookFactory.class);
@@ -105,6 +110,13 @@ public final class TestWorkbookFactory {
         assertTrue(wb instanceof HSSFWorkbook);
         assertCloseDoesNotModifyFile(xls, wb);
 
+        wb = WorkbookFactory.create(
+                new POIFSFileSystem(HSSFTestDataSamples.openSampleFileStream(xls)).getRoot()
+        );
+        assertNotNull(wb);
+        assertTrue(wb instanceof HSSFWorkbook);
+        assertCloseDoesNotModifyFile(xls, wb);
+
         // Package -> xssf
         wb = XSSFWorkbookFactory.create(
                 OPCPackage.open(
@@ -195,7 +207,6 @@ public final class TestWorkbookFactory {
     public void testCreateWithPasswordFromStream() throws Exception {
         Workbook wb;
 
-
         // Unprotected, no password given, opens normally
         wb = WorkbookFactory.create(
                 HSSFTestDataSamples.openSampleFileStream(xls), null
@@ -230,26 +241,26 @@ public final class TestWorkbookFactory {
 
         // Protected, correct password, opens fine
         wb = WorkbookFactory.create(
-                HSSFTestDataSamples.openSampleFileStream(xls_prot[0]), xls_prot[1]
+                HSSFTestDataSamples.openSampleFileStream(xls_protected[0]), xls_protected[1]
         );
         assertNotNull(wb);
         assertTrue(wb instanceof HSSFWorkbook);
-        assertCloseDoesNotModifyFile(xls_prot[0], wb);
+        assertCloseDoesNotModifyFile(xls_protected[0], wb);
 
         wb = WorkbookFactory.create(
-                HSSFTestDataSamples.openSampleFileStream(xlsx_prot[0]), xlsx_prot[1]
+                HSSFTestDataSamples.openSampleFileStream(xlsx_protected[0]), xlsx_protected[1]
         );
         assertNotNull(wb);
         assertTrue(wb instanceof XSSFWorkbook);
-        assertCloseDoesNotModifyFile(xlsx_prot[0], wb);
+        assertCloseDoesNotModifyFile(xlsx_protected[0], wb);
 
 
         // Protected, wrong password, throws Exception
         try {
             wb = WorkbookFactory.create(
-                    HSSFTestDataSamples.openSampleFileStream(xls_prot[0]), "wrong"
+                    HSSFTestDataSamples.openSampleFileStream(xls_protected[0]), "wrong"
             );
-            assertCloseDoesNotModifyFile(xls_prot[0], wb);
+            assertCloseDoesNotModifyFile(xls_protected[0], wb);
             fail("Shouldn't be able to open with the wrong password");
         } catch (EncryptedDocumentException e) {
             // expected here
@@ -257,9 +268,9 @@ public final class TestWorkbookFactory {
 
         try {
             wb = WorkbookFactory.create(
-                    HSSFTestDataSamples.openSampleFileStream(xlsx_prot[0]), "wrong"
+                    HSSFTestDataSamples.openSampleFileStream(xlsx_protected[0]), "wrong"
             );
-            assertCloseDoesNotModifyFile(xlsx_prot[0], wb);
+            assertCloseDoesNotModifyFile(xlsx_protected[0], wb);
             fail("Shouldn't be able to open with the wrong password");
         } catch (EncryptedDocumentException e) {
             // expected here
@@ -305,28 +316,28 @@ public final class TestWorkbookFactory {
 
         // Protected, correct password, opens fine
         wb = WorkbookFactory.create(
-                HSSFTestDataSamples.getSampleFile(xls_prot[0]), xls_prot[1]
+                HSSFTestDataSamples.getSampleFile(xls_protected[0]), xls_protected[1]
         );
         assertNotNull(wb);
         assertTrue(wb instanceof HSSFWorkbook);
-        assertCloseDoesNotModifyFile(xls_prot[0], wb);
+        assertCloseDoesNotModifyFile(xls_protected[0], wb);
 
         wb = WorkbookFactory.create(
-                HSSFTestDataSamples.getSampleFile(xlsx_prot[0]), xlsx_prot[1]
+                HSSFTestDataSamples.getSampleFile(xlsx_protected[0]), xlsx_protected[1]
         );
         assertNotNull(wb);
         assertTrue(wb instanceof XSSFWorkbook);
         assertTrue(wb.getNumberOfSheets() > 0);
         assertNotNull(wb.getSheetAt(0));
         assertNotNull(wb.getSheetAt(0).getRow(0));
-        assertCloseDoesNotModifyFile(xlsx_prot[0], wb);
+        assertCloseDoesNotModifyFile(xlsx_protected[0], wb);
 
         // Protected, wrong password, throws Exception
         try {
             wb = WorkbookFactory.create(
-                    HSSFTestDataSamples.getSampleFile(xls_prot[0]), "wrong"
+                    HSSFTestDataSamples.getSampleFile(xls_protected[0]), "wrong"
             );
-            assertCloseDoesNotModifyFile(xls_prot[0], wb);
+            assertCloseDoesNotModifyFile(xls_protected[0], wb);
             fail("Shouldn't be able to open with the wrong password");
         } catch (EncryptedDocumentException e) {
             // expected here
@@ -334,9 +345,9 @@ public final class TestWorkbookFactory {
 
         try {
             wb = WorkbookFactory.create(
-                    HSSFTestDataSamples.getSampleFile(xlsx_prot[0]), "wrong"
+                    HSSFTestDataSamples.getSampleFile(xlsx_protected[0]), "wrong"
             );
-            assertCloseDoesNotModifyFile(xlsx_prot[0], wb);
+            assertCloseDoesNotModifyFile(xlsx_protected[0], wb);
             fail("Shouldn't be able to open with the wrong password");
         } catch (EncryptedDocumentException e) {
             // expected here
@@ -387,4 +398,59 @@ public final class TestWorkbookFactory {
         }
     }
 
+    /**
+     * See Bugzilla bug #62831 - #WorkbookFactory.create(File) needs
+     *  to work for sub-classes of File too, eg JFileChooser
+     */
+    @Test
+    public void testFileSubclass() throws Exception {
+        File normalXLS = HSSFTestDataSamples.getSampleFile(xls);
+        File normalXLSX = HSSFTestDataSamples.getSampleFile(xlsx);
+        File altXLS = new TestFile(normalXLS.getAbsolutePath());
+        File altXLSX = new TestFile(normalXLSX.getAbsolutePath());
+        assertTrue(altXLS.exists());
+        assertTrue(altXLSX.exists());
+
+        Workbook wb = WorkbookFactory.create(altXLS);
+        assertNotNull(wb);
+        assertTrue(wb instanceof HSSFWorkbook);
+        closeOrRevert(wb);
+
+        wb = WorkbookFactory.create(altXLSX);
+        assertNotNull(wb);
+        assertTrue(wb instanceof XSSFWorkbook);
+        closeOrRevert(wb);
+    }
+    
+    private static class TestFile extends File {
+        public TestFile(String file) {
+            super(file);
+        }
+    }
+
+    /**
+     * Check that the overloaded file methods which take passwords work properly
+     */
+    @Test
+    public void testCreateEmpty() throws Exception {
+        Workbook wb = WorkbookFactory.create(false);
+        assertTrue(wb instanceof HSSFWorkbook);
+        closeOrRevert(wb);
+
+        wb = WorkbookFactory.create(true);
+        assertTrue(wb instanceof XSSFWorkbook);
+        closeOrRevert(wb);
+    }
+
+    @Test
+    public void testInvalidFormatException() {
+        String filename = "OPCCompliance_DerivedPartNameFAIL.docx";
+        try {
+            WorkbookFactory.create(POIDataSamples.getOpenXML4JInstance().openResourceAsStream(filename));
+            fail("Expecting an Exception for this document");
+        } catch (IOException e) {
+            // expected here
+        }
+    }
+
 }

Modified: poi/branches/hemf/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextParagraph.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextParagraph.java?rev=1845617&r1=1845616&r2=1845617&view=diff
==============================================================================
--- poi/branches/hemf/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextParagraph.java (original)
+++ poi/branches/hemf/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextParagraph.java Fri Nov  2 18:35:34 2018
@@ -47,22 +47,22 @@ public class TestXSLFTextParagraph {
         DrawTextParagraphProxy(XSLFTextParagraph p) {
             super(p);
         }
-        
+
         @Override
         public void breakText(Graphics2D graphics) {
             super.breakText(graphics);
         }
-        
+
         @Override
         public double getWrappingWidth(boolean firstLine, Graphics2D graphics) {
             return super.getWrappingWidth(firstLine, graphics);
         }
-        
+
         public List<DrawTextFragment> getLines() {
             return lines;
         }
     }
-    
+
     @Test
     public void testWrappingWidth() throws IOException {
         XMLSlideShow ppt = new XMLSlideShow();
@@ -78,11 +78,11 @@ public class TestXSLFTextParagraph {
 
         Rectangle2D anchor = new Rectangle2D.Double(50, 50, 300, 200);
         sh.setAnchor(anchor);
-        
+
         DrawTextParagraphProxy dtp = new DrawTextParagraphProxy(p);
 
-        Double leftInset = sh.getLeftInset();
-        Double rightInset = sh.getRightInset();
+        double leftInset = sh.getLeftInset();
+        double rightInset = sh.getRightInset();
         assertEquals(7.2, leftInset, 0);
         assertEquals(7.2, rightInset, 0);
 
@@ -142,13 +142,13 @@ public class TestXSLFTextParagraph {
         indent = p.getIndent();
         assertEquals(-72.0, indent, 0);
         expectedWidth = anchor.getWidth() - leftInset - rightInset;
-        assertEquals(280.0, expectedWidth, 0); // 300 - 10 - 10 
+        assertEquals(280.0, expectedWidth, 0); // 300 - 10 - 10
         assertEquals(expectedWidth, dtp.getWrappingWidth(true, null), 0); // first line is NOT indented
         // other lines are indented by leftMargin (the value of indent is not used)
         expectedWidth = anchor.getWidth() - leftInset - rightInset - leftMargin;
-        assertEquals(244.0, expectedWidth, 0); // 300 - 10 - 10 - 36 
+        assertEquals(244.0, expectedWidth, 0); // 300 - 10 - 10 - 36
         assertEquals(expectedWidth, dtp.getWrappingWidth(false, null), 0);
-        
+
         ppt.close();
      }
 
@@ -294,13 +294,13 @@ public class TestXSLFTextParagraph {
         assertEquals(-20.0, p.getBulletFontSize(), 0);
 
         assertEquals(72.0, p.getDefaultTabSize(), 0);
-        
+
         assertNull(p.getIndent());
         p.setIndent(72.0);
         assertEquals(72.0, p.getIndent(), 0);
         p.setIndent(-1d); // the value of -1.0 resets to the defaults (not any more ...)
         assertEquals(-1d, p.getIndent(), 0);
-        p.setIndent(null); 
+        p.setIndent(null);
         assertNull(p.getIndent());
 
         assertEquals(0.0, p.getLeftMargin(), 0);

Modified: poi/branches/hemf/src/ooxml/testcases/org/apache/poi/xssf/XSSFTestDataSamples.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/ooxml/testcases/org/apache/poi/xssf/XSSFTestDataSamples.java?rev=1845617&r1=1845616&r2=1845617&view=diff
==============================================================================
--- poi/branches/hemf/src/ooxml/testcases/org/apache/poi/xssf/XSSFTestDataSamples.java (original)
+++ poi/branches/hemf/src/ooxml/testcases/org/apache/poi/xssf/XSSFTestDataSamples.java Fri Nov  2 18:35:34 2018
@@ -28,13 +28,12 @@ import java.io.InputStream;
 import org.apache.poi.hssf.HSSFTestDataSamples;
 import org.apache.poi.openxml4j.opc.OPCPackage;
 import org.apache.poi.ss.usermodel.Workbook;
-import org.apache.poi.util.IOUtils;
 import org.apache.poi.util.TempFile;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 
 /**
- * Centralises logic for finding/opening sample files in the test-data/spreadsheet folder. 
- * 
+ * Centralises logic for finding/opening sample files in the test-data/spreadsheet folder.
+ *
  * @author Josh Micich
  */
 public class XSSFTestDataSamples {
@@ -63,7 +62,7 @@ public class XSSFTestDataSamples {
             throw new RuntimeException(e);
         }
     }
-    
+
     /**
      * Write out workbook <code>wb</code> to {@link #TEST_OUTPUT_DIR}/testName.xlsx
      * (or create a temporary file if <code>TEST_OUTPUT_DIR</code> is not defined).
@@ -78,11 +77,13 @@ public class XSSFTestDataSamples {
         writeOut(wb, file);
         return file;
     }
-    
+
     private static <R extends Workbook> void writeOut(R wb, File file) throws IOException {
-        IOUtils.write(wb,  new FileOutputStream(file));
+        try (FileOutputStream out = new FileOutputStream(file)) {
+            wb.write(out);
+        }
     }
-    
+
     // Anticipates the location of where a workbook will be written to
     // Note that if TEST_OUTPUT_DIR is not set, this will create temporary files
     // with unique names. Subsequent calls with the same argument may return a different file.
@@ -107,7 +108,7 @@ public class XSSFTestDataSamples {
         }
         return file;
     }
-    
+
     /**
      * Write out workbook <code>wb</code> to a memory buffer
      *
@@ -120,18 +121,18 @@ public class XSSFTestDataSamples {
         wb.write(out);
         return out;
     }
-    
+
     /**
-     * Write out the workbook then closes the workbook. 
+     * Write out the workbook then closes the workbook.
      * This should be used when there is insufficient memory to have
      * both workbooks open.
-     * 
+     *
      * Make sure there are no references to any objects in the workbook
      * so that garbage collection may free the workbook.
-     * 
+     *
      * After calling this method, null the reference to <code>wb</code>,
      * then call {@link #readBack(File)} or {@link #readBackAndDelete(File)} to re-read the file.
-     * 
+     *
      * Alternatively, use {@link #writeOutAndClose(Workbook)} to use a ByteArrayOutputStream/ByteArrayInputStream
      * to avoid creating a temporary file. However, this may complicate the calling
      * code to avoid having the workbook, BAOS, and BAIS open at the same time.
@@ -152,8 +153,8 @@ public class XSSFTestDataSamples {
             throw new RuntimeException(e);
         }
     }
-    
-    
+
+
     /**
      * Write out workbook <code>wb</code> to a memory buffer,
      * then close the workbook
@@ -173,7 +174,7 @@ public class XSSFTestDataSamples {
             throw new RuntimeException(e);
         }
     }
-    
+
     /**
      * Read back a workbook that was written out to a file with
      * {@link #writeOut(Workbook, String))} or {@link #writeOutAndClose(Workbook, String)}.
@@ -186,11 +187,11 @@ public class XSSFTestDataSamples {
      */
     public static XSSFWorkbook readBackAndDelete(File file) throws IOException {
         XSSFWorkbook wb = readBack(file);
-        // do not delete the file if there's an error--might be helpful for debugging 
+        // do not delete the file if there's an error--might be helpful for debugging
         file.delete();
         return wb;
     }
-    
+
     /**
      * Read back a workbook that was written out to a file with
      * {@link #writeOut(Workbook, String)} or {@link #writeOutAndClose(Workbook, String)}.
@@ -208,12 +209,12 @@ public class XSSFTestDataSamples {
             in.close();
         }
     }
-    
+
     /**
      * Read back a workbook that was written out to a memory buffer with
      * {@link #writeOut(Workbook)} or {@link #writeOutAndClose(Workbook)}.
      *
-     * @param file the workbook file to read
+     * @param out the output stream to read back from
      * @return the read back workbook
      * @throws IOException
      */
@@ -227,15 +228,15 @@ public class XSSFTestDataSamples {
             is.close();
         }
     }
-    
+
     /**
      * Write out and read back using a memory buffer to avoid disk I/O.
      * If there is not enough memory to have two workbooks open at the same time,
      * consider using:
-     * 
+     *
      * Workbook wb = new XSSFWorkbook();
      * String testName = "example";
-     * 
+     *
      * <code>
      * File file = writeOutAndClose(wb, testName);
      * // clear all references that would prevent the workbook from getting garbage collected
@@ -257,7 +258,7 @@ public class XSSFTestDataSamples {
         R r = (R) result;
         return r;
     }
-    
+
     /**
      * Write out, close, and read back the workbook using a memory buffer to avoid disk I/O.
      *
@@ -274,18 +275,18 @@ public class XSSFTestDataSamples {
         @SuppressWarnings("unchecked")
         R r = (R) result;
         return r;
-        
+
     }
-    
+
     /**
-     * Writes the Workbook either into a file or into a byte array, depending on presence of 
+     * Writes the Workbook either into a file or into a byte array, depending on presence of
      * the system property {@value #TEST_OUTPUT_DIR}, and reads it in a new instance of the Workbook back.
      * If TEST_OUTPUT_DIR is set, the file will NOT be deleted at the end of this function.
      * @param wb workbook to write
      * @param testName file name to be used if writing into a file. The old file with the same name will be overridden.
      * @return new instance read from the stream written by the wb parameter.
      */
-    
+
     public static <R extends Workbook> R writeOutAndReadBack(R wb, String testName) {
         if (System.getProperty(TEST_OUTPUT_DIR) == null) {
             return writeOutAndReadBack(wb);

Modified: poi/branches/hemf/src/ooxml/testcases/org/apache/poi/xssf/extractor/TestXSSFBEventBasedExcelExtractor.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/ooxml/testcases/org/apache/poi/xssf/extractor/TestXSSFBEventBasedExcelExtractor.java?rev=1845617&r1=1845616&r2=1845617&view=diff
==============================================================================
--- poi/branches/hemf/src/ooxml/testcases/org/apache/poi/xssf/extractor/TestXSSFBEventBasedExcelExtractor.java (original)
+++ poi/branches/hemf/src/ooxml/testcases/org/apache/poi/xssf/extractor/TestXSSFBEventBasedExcelExtractor.java Fri Nov  2 18:35:34 2018
@@ -26,6 +26,10 @@ import static org.junit.Assert.assertTru
 import org.apache.poi.xssf.XSSFTestDataSamples;
 import org.junit.Test;
 
+import java.io.BufferedReader;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+
 /**
  * Tests for {@link XSSFBEventBasedExcelExtractor}
  */
@@ -110,4 +114,23 @@ public class TestXSSFBEventBasedExcelExt
                 "This is an example spreadsheet created with Microsoft Excel 2007 Beta 2.");
     }
 
+    @Test
+    public void test62815() throws Exception {
+        //test file based on http://oss.sheetjs.com/test_files/RkNumber.xlsb
+        XSSFEventBasedExcelExtractor extractor = getExtractor("62815.xlsb");
+        extractor.setIncludeCellComments(true);
+        String[] rows = extractor.getText().split("[\r\n]+");
+        assertEquals(283, rows.length);
+        BufferedReader reader = Files.newBufferedReader(XSSFTestDataSamples.getSampleFile("62815.xlsb.txt").toPath(),
+                StandardCharsets.UTF_8);
+        String line = reader.readLine();
+        for (int i = 0; i < rows.length; i++) {
+            assertEquals(line, rows[i]);
+            line = reader.readLine();
+            while (line != null && line.startsWith("#")) {
+                line = reader.readLine();
+            }
+        }
+    }
+
 }

Modified: poi/branches/hemf/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbook.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbook.java?rev=1845617&r1=1845616&r2=1845617&view=diff
==============================================================================
--- poi/branches/hemf/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbook.java (original)
+++ poi/branches/hemf/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbook.java Fri Nov  2 18:35:34 2018
@@ -38,7 +38,6 @@ import java.util.Arrays;
 
 import org.apache.poi.POIDataSamples;
 import org.apache.poi.POITestCase;
-import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
 import org.apache.poi.openxml4j.opc.OPCPackage;
 import org.apache.poi.openxml4j.opc.PackageAccess;
 import org.apache.poi.ss.usermodel.BaseTestXWorkbook;
@@ -55,7 +54,6 @@ import org.apache.poi.xssf.XSSFTestDataS
 import org.apache.poi.xssf.model.SharedStringsTable;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.junit.After;
-import org.junit.Assume;
 import org.junit.Ignore;
 import org.junit.Test;
 
@@ -103,9 +101,9 @@ public final class TestSXSSFWorkbook ext
      *  changes.
      */
     @Override
+    @Ignore("SXSSF doesn't update formulas on sheet name changes, as most cells probably aren't in memory at the time")
     @Test
     public void setSheetName() {
-        Assume.assumeTrue("SXSSF doesn't update formulas on sheet name changes, as most cells probably aren't in memory at the time", false);
     }
 
     @Test
@@ -374,7 +372,7 @@ public final class TestSXSSFWorkbook ext
     @Test
     public void bug53515a() throws Exception {
         File out = new File("Test.xlsx");
-        out.delete();
+        assertTrue(!out.exists() || out.delete());
         for (int i = 0; i < 2; i++) {
             final SXSSFWorkbook wb;
             if (out.exists()) {
@@ -402,7 +400,8 @@ public final class TestSXSSFWorkbook ext
             }
             wb.close();
         }
-        out.delete();
+        assertTrue(out.exists());
+        assertTrue(out.delete());
     }
 
     private static void populateWorkbook(Workbook wb) {
@@ -500,33 +499,37 @@ public final class TestSXSSFWorkbook ext
     @Test
     @Ignore
     public void createFromReadOnlyWorkbook() throws Exception {
-        File input = XSSFTestDataSamples.getSampleFile("sample.xlsx");
-        OPCPackage pkg = OPCPackage.open(input, PackageAccess.READ);
-        XSSFWorkbook xssf = new XSSFWorkbook(pkg);
-        SXSSFWorkbook wb = new SXSSFWorkbook(xssf, 2);
-        
         String sheetName = "Test SXSSF";
-        Sheet s = wb.createSheet(sheetName);
-        for (int i=0; i<10; i++) {
-            Row r = s.createRow(i);
-            r.createCell(0).setCellValue(true);
-            r.createCell(1).setCellValue(2.4);
-            r.createCell(2).setCellValue("Test Row " + i);
+        File input = XSSFTestDataSamples.getSampleFile("sample.xlsx");
+
+        try (OPCPackage pkg = OPCPackage.open(input, PackageAccess.READ)) {
+            ByteArrayOutputStream bos = new ByteArrayOutputStream();
+            try (XSSFWorkbook xssf = new XSSFWorkbook(pkg)) {
+                try (SXSSFWorkbook wb = new SXSSFWorkbook(xssf, 2)) {
+                    Sheet s = wb.createSheet(sheetName);
+                    for (int i = 0; i < 10; i++) {
+                        Row r = s.createRow(i);
+                        r.createCell(0).setCellValue(true);
+                        r.createCell(1).setCellValue(2.4);
+                        r.createCell(2).setCellValue("Test Row " + i);
+                    }
+                    assertEquals(10, s.getLastRowNum());
+
+                    wb.write(bos);
+                    wb.dispose();
+                }
+            }
+
+            try (XSSFWorkbook xssf = new XSSFWorkbook(new ByteArrayInputStream(bos.toByteArray()))) {
+                Sheet s = xssf.getSheet(sheetName);
+                assertEquals(10, s.getLastRowNum());
+                assertTrue(s.getRow(0).getCell(0).getBooleanCellValue());
+                assertEquals("Test Row 9", s.getRow(9).getCell(2).getStringCellValue());
+            }
         }
-        assertEquals(10, s.getLastRowNum());
-        
-        ByteArrayOutputStream bos = new ByteArrayOutputStream();
-        wb.write(bos);
-        wb.dispose();
-        wb.close();
-        
-        xssf = new XSSFWorkbook(new ByteArrayInputStream(bos.toByteArray()));
-        s = xssf.getSheet(sheetName);
-        assertEquals(10, s.getLastRowNum());
-        assertTrue(s.getRow(0).getCell(0).getBooleanCellValue());
-        assertEquals("Test Row 9", s.getRow(9).getCell(2).getStringCellValue());
     }
 
+
     @Test
     public void test56557() throws IOException {
         Workbook wb = XSSFTestDataSamples.openSampleWorkbook("56557.xlsx");

Modified: poi/branches/hemf/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java?rev=1845617&r1=1845616&r2=1845617&view=diff
==============================================================================
--- poi/branches/hemf/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java (original)
+++ poi/branches/hemf/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java Fri Nov  2 18:35:34 2018
@@ -47,15 +47,15 @@ import java.util.TreeMap;
 import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
 import org.apache.commons.compress.archivers.zip.ZipFile;
 import org.apache.poi.POIDataSamples;
-import org.apache.poi.ooxml.POIXMLDocumentPart;
-import org.apache.poi.ooxml.POIXMLDocumentPart.RelationPart;
-import org.apache.poi.ooxml.POIXMLException;
-import org.apache.poi.ooxml.POIXMLProperties;
 import org.apache.poi.common.usermodel.HyperlinkType;
 import org.apache.poi.hssf.HSSFITestDataProvider;
 import org.apache.poi.hssf.HSSFTestDataSamples;
 import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ooxml.POIXMLDocumentPart;
+import org.apache.poi.ooxml.POIXMLDocumentPart.RelationPart;
+import org.apache.poi.ooxml.POIXMLException;
+import org.apache.poi.ooxml.POIXMLProperties;
 import org.apache.poi.ooxml.util.DocumentHelper;
 import org.apache.poi.ooxml.util.SAXHelper;
 import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
@@ -82,7 +82,31 @@ import org.apache.poi.ss.formula.eval.Er
 import org.apache.poi.ss.formula.eval.NumberEval;
 import org.apache.poi.ss.formula.functions.Function;
 import org.apache.poi.ss.formula.ptg.Ptg;
-import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.ss.usermodel.BaseTestBugzillaIssues;
+import org.apache.poi.ss.usermodel.BorderStyle;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellStyle;
+import org.apache.poi.ss.usermodel.CellType;
+import org.apache.poi.ss.usermodel.CellValue;
+import org.apache.poi.ss.usermodel.ClientAnchor;
+import org.apache.poi.ss.usermodel.Comment;
+import org.apache.poi.ss.usermodel.CreationHelper;
+import org.apache.poi.ss.usermodel.DataFormat;
+import org.apache.poi.ss.usermodel.DataFormatter;
+import org.apache.poi.ss.usermodel.DateUtil;
+import org.apache.poi.ss.usermodel.Drawing;
+import org.apache.poi.ss.usermodel.FillPatternType;
+import org.apache.poi.ss.usermodel.Font;
+import org.apache.poi.ss.usermodel.FormulaError;
+import org.apache.poi.ss.usermodel.FormulaEvaluator;
+import org.apache.poi.ss.usermodel.IndexedColors;
+import org.apache.poi.ss.usermodel.Name;
+import org.apache.poi.ss.usermodel.PrintSetup;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.SheetConditionalFormatting;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.ss.usermodel.WorkbookFactory;
 import org.apache.poi.ss.util.AreaReference;
 import org.apache.poi.ss.util.CellAddress;
 import org.apache.poi.ss.util.CellRangeAddress;
@@ -2261,7 +2285,7 @@ public final class TestXSSFBugs extends
      * problems when deleting columns, conditionally to stop recursion
      */
     private static final String FORMULA1 =
-            "IF( INDIRECT( ADDRESS( ROW(), COLUMN()-1 ) ) = 0, 0,"
+            "IF( INDIRECT( ADDRESS( ROW(), COLUMN()-1 ) ) = 0, 0, "
                     + "INDIRECT( ADDRESS( ROW(), COLUMN()-1 ) ) ) + 2";
 
     /**
@@ -2269,7 +2293,7 @@ public final class TestXSSFBugs extends
      * problems when deleting rows, conditionally to stop recursion
      */
     private static final String FORMULA2 =
-            "IF( INDIRECT( ADDRESS( ROW()-1, COLUMN() ) ) = 0, 0,"
+            "IF( INDIRECT( ADDRESS( ROW()-1, COLUMN() ) ) = 0, 0, "
                     + "INDIRECT( ADDRESS( ROW()-1, COLUMN() ) ) ) + 2";
 
     /**
@@ -2847,7 +2871,7 @@ public final class TestXSSFBugs extends
     @Test
     public void test57236() throws IOException {
         // Having very small numbers leads to different formatting, Excel uses the scientific notation, but POI leads to "0"
-        
+
         /*
         DecimalFormat format = new DecimalFormat("#.##########", new DecimalFormatSymbols(Locale.getDefault()));
         double d = 3.0E-104;
@@ -2969,13 +2993,21 @@ public final class TestXSSFBugs extends
         cell.setCellStyle(style);
 
         // Everything is fine at this point, cell is red
+        XSSFColor actual = cell.getCellStyle().getFillBackgroundColorColor();
+        assertNull(actual);
+        actual = cell.getCellStyle().getFillForegroundColorColor();
+        assertNotNull(actual);
+        assertEquals(color.getARGBHex(), actual.getARGBHex());
 
         Map<String, Object> properties = new HashMap<>();
         properties.put(CellUtil.BORDER_BOTTOM, BorderStyle.THIN);
         CellUtil.setCellStyleProperties(cell, properties);
 
         // Now the cell is all black
-        XSSFColor actual = cell.getCellStyle().getFillBackgroundColorColor();
+        actual = cell.getCellStyle().getFillBackgroundColorColor();
+        assertNotNull(actual);
+        assertNull(actual.getARGBHex());
+        actual = cell.getCellStyle().getFillForegroundColorColor();
         assertNotNull(actual);
         assertEquals(color.getARGBHex(), actual.getARGBHex());
 
@@ -3290,7 +3322,7 @@ public final class TestXSSFBugs extends
 
         wb.close();
     }
-    
+
     /**
      * Auto column sizing failed when there were loads of fonts with
      *  errors like ArrayIndexOutOfBoundsException: -32765
@@ -3300,7 +3332,7 @@ public final class TestXSSFBugs extends
         XSSFWorkbook wb = new XSSFWorkbook();
         XSSFSheet sheet = wb.createSheet();
         XSSFRow row = sheet.createRow(0);
-        
+
         // Create lots of fonts
         XSSFDataFormat formats = wb.createDataFormat();
         XSSFFont[] fonts = new XSSFFont[50000];
@@ -3309,23 +3341,23 @@ public final class TestXSSFBugs extends
             font.setFontHeight(i);
             fonts[i] = font;
         }
-        
+
         // Create a moderate number of columns, which use
         //  fonts from the start and end of the font list
         final int numCols = 125;
         for (int i=0; i<numCols; i++) {
             XSSFCellStyle cs = wb.createCellStyle();
             cs.setDataFormat(formats.getFormat("'Test "+i+"' #,###"));
-            
+
             XSSFFont font = fonts[i];
             if (i%2==1) { font = fonts[fonts.length-i]; }
             cs.setFont(font);
-            
+
             XSSFCell c = row.createCell(i);
             c.setCellValue(i);
             c.setCellStyle(cs);
         }
-        
+
         // Do the auto-size
         for (int i=0; i<numCols; i++) {
             sheet.autoSizeColumn(i);



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


Mime
View raw message