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 2015/09/01 20:49:51 UTC

svn commit: r1700640 - in /poi/trunk/src/java/org/apache/poi: hssf/record/ hssf/usermodel/ ss/formula/atp/ ss/formula/functions/ ss/util/

Author: nick
Date: Tue Sep  1 18:49:50 2015
New Revision: 1700640

URL: http://svn.apache.org/r1700640
Log:
Fix some Forbidden APIs errors

Modified:
    poi/trunk/src/java/org/apache/poi/hssf/record/RecordFactory.java
    poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFPalette.java
    poi/trunk/src/java/org/apache/poi/ss/formula/atp/YearFracCalculator.java
    poi/trunk/src/java/org/apache/poi/ss/formula/functions/Days360.java
    poi/trunk/src/java/org/apache/poi/ss/formula/functions/EOMonth.java
    poi/trunk/src/java/org/apache/poi/ss/util/CellReference.java

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/RecordFactory.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/RecordFactory.java?rev=1700640&r1=1700639&r2=1700640&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/RecordFactory.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/RecordFactory.java Tue Sep  1 18:49:50 2015
@@ -28,6 +28,7 @@ import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
 
@@ -432,8 +433,10 @@ public final class RecordFactory {
             Integer key = Integer.valueOf(sid);
             if (result.containsKey(key)) {
                 Class<?> prevClass = result.get(key).getRecordClass();
-                throw new RuntimeException("duplicate record sid 0x" + Integer.toHexString(sid).toUpperCase()
-                        + " for classes (" + recClass.getName() + ") and (" + prevClass.getName() + ")");
+                throw new RuntimeException("duplicate record sid 0x" + 
+                        Integer.toHexString(sid).toUpperCase(Locale.ROOT)
+                        + " for classes (" + recClass.getName() + ") and ("
+                        + prevClass.getName() + ")");
             }
             result.put(key, getRecordCreator(recClass));
         }

Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFPalette.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFPalette.java?rev=1700640&r1=1700639&r2=1700640&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFPalette.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFPalette.java Tue Sep  1 18:49:50 2015
@@ -17,6 +17,8 @@
 
 package org.apache.poi.hssf.usermodel;
 
+import java.util.Locale;
+
 import org.apache.poi.hssf.record.PaletteRecord;
 import org.apache.poi.hssf.util.HSSFColor;
 
@@ -234,7 +236,7 @@ public final class HSSFPalette {
             {
                 int c = color & 0xff; //as unsigned
                 c = (c << 8) | c; //pad to 16-bit
-                s = Integer.toHexString(c).toUpperCase();
+                s = Integer.toHexString(c).toUpperCase(Locale.ROOT);
                 while (s.length() < 4)
                 {
                     s = "0" + s;

Modified: poi/trunk/src/java/org/apache/poi/ss/formula/atp/YearFracCalculator.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/atp/YearFracCalculator.java?rev=1700640&r1=1700639&r2=1700640&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/atp/YearFracCalculator.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/atp/YearFracCalculator.java Tue Sep  1 18:49:50 2015
@@ -19,6 +19,7 @@ package org.apache.poi.ss.formula.atp;
 
 import java.util.Calendar;
 import java.util.GregorianCalendar;
+import java.util.Locale;
 import java.util.TimeZone;
 
 import org.apache.poi.ss.formula.eval.ErrorEval;
@@ -316,7 +317,7 @@ final class YearFracCalculator {
 	}
 
 	private static SimpleDate createDate(int dayCount) {
-		GregorianCalendar calendar = new GregorianCalendar(UTC_TIME_ZONE);
+		GregorianCalendar calendar = new GregorianCalendar(UTC_TIME_ZONE, Locale.ROOT);
 		DateUtil.setCalendar(calendar, dayCount, 0, false, false);
 		return new SimpleDate(calendar);
 	}

Modified: poi/trunk/src/java/org/apache/poi/ss/formula/functions/Days360.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/functions/Days360.java?rev=1700640&r1=1700639&r2=1700640&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/functions/Days360.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/functions/Days360.java Tue Sep  1 18:49:50 2015
@@ -19,6 +19,7 @@ package org.apache.poi.ss.formula.functi
 import java.util.Calendar;
 import java.util.GregorianCalendar;
 import java.util.Locale;
+import java.util.TimeZone;
 
 import org.apache.poi.ss.formula.eval.EvaluationException;
 import org.apache.poi.ss.formula.eval.NumberEval;
@@ -31,10 +32,13 @@ import org.apache.poi.ss.usermodel.DateU
  * (twelve 30-day months), which is used in some accounting calculations. Use
  * this function to help compute payments if your accounting system is based on
  * twelve 30-day months.
- *
- * @author PUdalau
  */
 public class Days360 extends Var2or3ArgFunction {
+    /**
+     * Excel doesn't store TimeZone information in the file, so if in doubt,
+     *  use UTC to perform calculations
+     */
+    private static final TimeZone DEFAULT_TIMEZONE = TimeZone.getTimeZone("UTC");
 
     public ValueEval evaluate(int srcRowIndex, int srcColumnIndex, ValueEval arg0, ValueEval arg1) {
         double result;
@@ -73,7 +77,7 @@ public class Days360 extends Var2or3ArgF
     }
 
     private static Calendar getDate(double date) {
-        Calendar processedDate = new GregorianCalendar(Locale.ROOT);
+        Calendar processedDate = new GregorianCalendar(DEFAULT_TIMEZONE, Locale.ROOT);
         processedDate.setTime(DateUtil.getJavaDate(date, false));
         return processedDate;
     }

Modified: poi/trunk/src/java/org/apache/poi/ss/formula/functions/EOMonth.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/functions/EOMonth.java?rev=1700640&r1=1700639&r2=1700640&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/functions/EOMonth.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/functions/EOMonth.java Tue Sep  1 18:49:50 2015
@@ -21,6 +21,7 @@ import java.util.Calendar;
 import java.util.Date;
 import java.util.GregorianCalendar;
 import java.util.Locale;
+import java.util.TimeZone;
 
 import org.apache.poi.ss.formula.OperationEvaluationContext;
 import org.apache.poi.ss.formula.eval.ErrorEval;
@@ -44,7 +45,12 @@ import org.apache.poi.ss.usermodel.DateU
  * zero or negative (in the past).
  */
 public class EOMonth implements FreeRefFunction {
-
+    /**
+     * Excel doesn't store TimeZone information in the file, so if in doubt,
+     *  use UTC to perform calculations
+     */
+    private static final TimeZone DEFAULT_TIMEZONE = TimeZone.getTimeZone("UTC");
+    
     public static final FreeRefFunction instance = new EOMonth();
 
     @Override
@@ -64,7 +70,7 @@ public class EOMonth implements FreeRefF
 
             Date startDate = DateUtil.getJavaDate(startDateAsNumber, false);
 
-            Calendar cal = new GregorianCalendar(Locale.ROOT);
+            Calendar cal = new GregorianCalendar(DEFAULT_TIMEZONE, Locale.ROOT);
             cal.setTime(startDate);
             cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
             cal.set(Calendar.MILLISECOND, 0);
@@ -78,5 +84,4 @@ public class EOMonth implements FreeRefF
             return e.getErrorEval();
         }
     }
-
 }

Modified: poi/trunk/src/java/org/apache/poi/ss/util/CellReference.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/util/CellReference.java?rev=1700640&r1=1700639&r2=1700640&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/util/CellReference.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/util/CellReference.java Tue Sep  1 18:49:50 2015
@@ -173,7 +173,7 @@ public class CellReference {
      */
     public static int convertColStringToIndex(String ref) {
         int retval=0;
-        char[] refs = ref.toUpperCase().toCharArray();
+        char[] refs = ref.toUpperCase(Locale.ROOT).toCharArray();
         for (int k=0; k<refs.length; k++) {
             char thechar = refs[k];
             if (thechar == ABSOLUTE_REFERENCE_MARKER) {
@@ -311,7 +311,7 @@ public class CellReference {
             return false; // that was easy
         }
         if(numberOfLetters == lastColLength) {
-            if(colStr.toUpperCase().compareTo(lastCol) > 0) {
+            if(colStr.toUpperCase(Locale.ROOT).compareTo(lastCol) > 0) {
                 return false;
             }
         } else {
@@ -379,7 +379,7 @@ public class CellReference {
             }
         }
 
-        col = reference.substring(start,loc).toUpperCase();
+        col = reference.substring(start,loc).toUpperCase(Locale.ROOT);
         row = reference.substring(loc);
         CellRefParts cellRefParts = new CellRefParts(sheetName, row, col);
         return cellRefParts;



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