You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ni...@apache.org on 2016/02/15 15:58:17 UTC

svn commit: r1730543 - in /poi/trunk/src: java/org/apache/poi/hssf/record/common/ java/org/apache/poi/ss/usermodel/ ooxml/java/org/apache/poi/xssf/usermodel/ ooxml/java/org/apache/poi/xssf/usermodel/helpers/ ooxml/testcases/org/apache/poi/xssf/usermodel/

Author: nick
Date: Mon Feb 15 14:58:16 2016
New Revision: 1730543

URL: http://svn.apache.org/viewvc?rev=1730543&view=rev
Log:
Add details of the ignored errors where the HSSF spec provides a good description, and a bit more refactoring. #56892

Modified:
    poi/trunk/src/java/org/apache/poi/hssf/record/common/FeatFormulaErr2.java
    poi/trunk/src/java/org/apache/poi/ss/usermodel/IgnoredErrorType.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFIgnoredErrorHelper.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/common/FeatFormulaErr2.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/common/FeatFormulaErr2.java?rev=1730543&r1=1730542&r2=1730543&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/common/FeatFormulaErr2.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/common/FeatFormulaErr2.java Mon Feb 15 14:58:16 2016
@@ -32,7 +32,8 @@ import org.apache.poi.util.LittleEndianO
  *  for a sheet, stored as part of a Shared Feature. It can be found in 
  *  records such as {@link FeatRecord}.
  * For the full meanings of the flags, see pages 669 and 670
- *  of the Excel binary file format documentation.
+ *  of the Excel binary file format documentation and/or
+ *  https://msdn.microsoft.com/en-us/library/dd924991%28v=office.12%29.aspx
  */
 public final class FeatFormulaErr2 implements SharedFeature {
 	static BitField checkCalculationErrors =

Modified: poi/trunk/src/java/org/apache/poi/ss/usermodel/IgnoredErrorType.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/usermodel/IgnoredErrorType.java?rev=1730543&r1=1730542&r2=1730543&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/usermodel/IgnoredErrorType.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/usermodel/IgnoredErrorType.java Mon Feb 15 14:58:16 2016
@@ -17,29 +17,67 @@
 
 package org.apache.poi.ss.usermodel;
 
-
 /**
  * Types of ignored workbook and worksheet error.
  * 
- * TODO Give more details on what these mean
+ * TODO Implement these for HSSF too, using FeatFormulaErr2,
+ *  see bugzilla bug #46136 for details
  */
 public enum IgnoredErrorType {
-
+    /**
+     * ????. Probably XSSF-only.
+     */
     CALCULATED_COLUMN,
     
+    /**
+     * Whether to check for references to empty cells.
+     * HSSF + XSSF.
+     */
     EMPTY_CELL_REFERENCE,
     
+    /**
+     * Whether to check for calculation/evaluation errors.
+     * HSSF + XSSF.
+     */
     EVALUATION_ERROR,
     
+    /**
+     * Whether to check formulas in the range of the shared feature 
+     *  that are inconsistent with formulas in neighbouring cells.
+     * HSSF + XSSF.
+     */
     FORMULA,
     
+    /**
+     * Whether to check formulas in the range of the shared feature 
+     * with references to less than the entirety of a range containing 
+     * continuous data.
+     * HSSF + XSSF.
+     */
     FORMULA_RANGE,
     
+    /**
+     * ????. Is this XSSF-specific the same as performDataValidation
+     *  in HSSF?
+     */
     LIST_DATA_VALIDATION,
     
+    /**
+     * Whether to check the format of string values and warn
+     *  if they look to actually be numeric values.
+     * HSSF + XSSF.
+     */
     NUMBER_STORED_AS_TEXT,
     
+    /**
+     * ????. Is this XSSF-specific the same as checkDateTimeFormats
+     *  in HSSF?
+     */
     TWO_DIGIT_TEXT_YEAR,
     
+    /**
+     * Whether to check for unprotected formulas.
+     * HSSF + XSSF.
+     */
     UNLOCKED_FORMULA;
 }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java?rev=1730543&r1=1730542&r2=1730543&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java Mon Feb 15 14:58:16 2016
@@ -4133,7 +4133,7 @@ public class XSSFSheet extends POIXMLDoc
         Map<IgnoredErrorType, Set<CellRangeAddress>> result = new LinkedHashMap<IgnoredErrorType, Set<CellRangeAddress>>();
         if (worksheet.isSetIgnoredErrors()) {
             for (CTIgnoredError err : worksheet.getIgnoredErrors().getIgnoredErrorList()) {
-                for (IgnoredErrorType errType : getErrorTypes(err)) {
+                for (IgnoredErrorType errType : XSSFIgnoredErrorHelper.getErrorTypes(err)) {
                     if (!result.containsKey(errType)) {
                         result.put(errType, new LinkedHashSet<CellRangeAddress>());
                     }
@@ -4149,20 +4149,6 @@ public class XSSFSheet extends POIXMLDoc
     private void addIgnoredErrors(String ref, IgnoredErrorType... ignoredErrorTypes) {
         CTIgnoredErrors ctIgnoredErrors = worksheet.isSetIgnoredErrors() ? worksheet.getIgnoredErrors() : worksheet.addNewIgnoredErrors();
         CTIgnoredError ctIgnoredError = ctIgnoredErrors.addNewIgnoredError();
-        ctIgnoredError.setSqref(Arrays.asList(ref));
-        for (IgnoredErrorType errType : ignoredErrorTypes) {
-            XSSFIgnoredErrorHelper.set(errType, ctIgnoredError);
-        }
-    }
-
-    private Set<IgnoredErrorType> getErrorTypes(CTIgnoredError err) {
-        Set<IgnoredErrorType> result = new LinkedHashSet<IgnoredErrorType>();
-        for (IgnoredErrorType errType : IgnoredErrorType.values()) {
-            if (XSSFIgnoredErrorHelper.isSet(errType, err)) {
-                result.add(errType);
-            }
-        }
-        return result;
+        XSSFIgnoredErrorHelper.addIgnoredErrors(ctIgnoredError, ref, ignoredErrorTypes);
     }
-    
 }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFIgnoredErrorHelper.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFIgnoredErrorHelper.java?rev=1730543&r1=1730542&r2=1730543&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFIgnoredErrorHelper.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFIgnoredErrorHelper.java Mon Feb 15 14:58:16 2016
@@ -17,8 +17,12 @@
 
 package org.apache.poi.xssf.usermodel.helpers;
 
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTIgnoredError;
+import java.util.Arrays;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
 import org.apache.poi.ss.usermodel.IgnoredErrorType;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTIgnoredError;
 
 /**
  * XSSF-specific code for working with ignored errors
@@ -82,4 +86,21 @@ public class XSSFIgnoredErrorHelper {
             throw new IllegalStateException();
         }
     }
+    
+    public static void addIgnoredErrors(CTIgnoredError err, String ref, IgnoredErrorType... ignoredErrorTypes) {
+        err.setSqref(Arrays.asList(ref));
+        for (IgnoredErrorType errType : ignoredErrorTypes) {
+            XSSFIgnoredErrorHelper.set(errType, err);
+        }
+    }
+
+    public static  Set<IgnoredErrorType> getErrorTypes(CTIgnoredError err) {
+        Set<IgnoredErrorType> result = new LinkedHashSet<IgnoredErrorType>();
+        for (IgnoredErrorType errType : IgnoredErrorType.values()) {
+            if (XSSFIgnoredErrorHelper.isSet(errType, err)) {
+                result.add(errType);
+            }
+        }
+        return result;
+    }
 }

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java?rev=1730543&r1=1730542&r2=1730543&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java Mon Feb 15 14:58:16 2016
@@ -49,6 +49,7 @@ import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.CellCopyPolicy;
 import org.apache.poi.ss.usermodel.ClientAnchor;
 import org.apache.poi.ss.usermodel.FormulaError;
+import org.apache.poi.ss.usermodel.IgnoredErrorType;
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Workbook;



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