mirror of https://github.com/apache/poi.git
Fix some Forbidden APIs errors
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1700640 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4ee2705d7a
commit
a3007f613a
|
@ -28,6 +28,7 @@ import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
@ -432,8 +433,10 @@ public final class RecordFactory {
|
||||||
Integer key = Integer.valueOf(sid);
|
Integer key = Integer.valueOf(sid);
|
||||||
if (result.containsKey(key)) {
|
if (result.containsKey(key)) {
|
||||||
Class<?> prevClass = result.get(key).getRecordClass();
|
Class<?> prevClass = result.get(key).getRecordClass();
|
||||||
throw new RuntimeException("duplicate record sid 0x" + Integer.toHexString(sid).toUpperCase()
|
throw new RuntimeException("duplicate record sid 0x" +
|
||||||
+ " for classes (" + recClass.getName() + ") and (" + prevClass.getName() + ")");
|
Integer.toHexString(sid).toUpperCase(Locale.ROOT)
|
||||||
|
+ " for classes (" + recClass.getName() + ") and ("
|
||||||
|
+ prevClass.getName() + ")");
|
||||||
}
|
}
|
||||||
result.put(key, getRecordCreator(recClass));
|
result.put(key, getRecordCreator(recClass));
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
|
|
||||||
package org.apache.poi.hssf.usermodel;
|
package org.apache.poi.hssf.usermodel;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import org.apache.poi.hssf.record.PaletteRecord;
|
import org.apache.poi.hssf.record.PaletteRecord;
|
||||||
import org.apache.poi.hssf.util.HSSFColor;
|
import org.apache.poi.hssf.util.HSSFColor;
|
||||||
|
|
||||||
|
@ -234,7 +236,7 @@ public final class HSSFPalette {
|
||||||
{
|
{
|
||||||
int c = color & 0xff; //as unsigned
|
int c = color & 0xff; //as unsigned
|
||||||
c = (c << 8) | c; //pad to 16-bit
|
c = (c << 8) | c; //pad to 16-bit
|
||||||
s = Integer.toHexString(c).toUpperCase();
|
s = Integer.toHexString(c).toUpperCase(Locale.ROOT);
|
||||||
while (s.length() < 4)
|
while (s.length() < 4)
|
||||||
{
|
{
|
||||||
s = "0" + s;
|
s = "0" + s;
|
||||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.poi.ss.formula.atp;
|
||||||
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
import org.apache.poi.ss.formula.eval.ErrorEval;
|
import org.apache.poi.ss.formula.eval.ErrorEval;
|
||||||
|
@ -316,7 +317,7 @@ final class YearFracCalculator {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static SimpleDate createDate(int dayCount) {
|
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);
|
DateUtil.setCalendar(calendar, dayCount, 0, false, false);
|
||||||
return new SimpleDate(calendar);
|
return new SimpleDate(calendar);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.poi.ss.formula.functions;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.TimeZone;
|
||||||
|
|
||||||
import org.apache.poi.ss.formula.eval.EvaluationException;
|
import org.apache.poi.ss.formula.eval.EvaluationException;
|
||||||
import org.apache.poi.ss.formula.eval.NumberEval;
|
import org.apache.poi.ss.formula.eval.NumberEval;
|
||||||
|
@ -31,10 +32,13 @@ import org.apache.poi.ss.usermodel.DateUtil;
|
||||||
* (twelve 30-day months), which is used in some accounting calculations. Use
|
* (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
|
* this function to help compute payments if your accounting system is based on
|
||||||
* twelve 30-day months.
|
* twelve 30-day months.
|
||||||
*
|
|
||||||
* @author PUdalau
|
|
||||||
*/
|
*/
|
||||||
public class Days360 extends Var2or3ArgFunction {
|
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) {
|
public ValueEval evaluate(int srcRowIndex, int srcColumnIndex, ValueEval arg0, ValueEval arg1) {
|
||||||
double result;
|
double result;
|
||||||
|
@ -73,7 +77,7 @@ public class Days360 extends Var2or3ArgFunction {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Calendar getDate(double date) {
|
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));
|
processedDate.setTime(DateUtil.getJavaDate(date, false));
|
||||||
return processedDate;
|
return processedDate;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.TimeZone;
|
||||||
|
|
||||||
import org.apache.poi.ss.formula.OperationEvaluationContext;
|
import org.apache.poi.ss.formula.OperationEvaluationContext;
|
||||||
import org.apache.poi.ss.formula.eval.ErrorEval;
|
import org.apache.poi.ss.formula.eval.ErrorEval;
|
||||||
|
@ -44,6 +45,11 @@ import org.apache.poi.ss.usermodel.DateUtil;
|
||||||
* zero or negative (in the past).
|
* zero or negative (in the past).
|
||||||
*/
|
*/
|
||||||
public class EOMonth implements FreeRefFunction {
|
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();
|
public static final FreeRefFunction instance = new EOMonth();
|
||||||
|
|
||||||
|
@ -64,7 +70,7 @@ public class EOMonth implements FreeRefFunction {
|
||||||
|
|
||||||
Date startDate = DateUtil.getJavaDate(startDateAsNumber, false);
|
Date startDate = DateUtil.getJavaDate(startDateAsNumber, false);
|
||||||
|
|
||||||
Calendar cal = new GregorianCalendar(Locale.ROOT);
|
Calendar cal = new GregorianCalendar(DEFAULT_TIMEZONE, Locale.ROOT);
|
||||||
cal.setTime(startDate);
|
cal.setTime(startDate);
|
||||||
cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
|
cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
|
||||||
cal.set(Calendar.MILLISECOND, 0);
|
cal.set(Calendar.MILLISECOND, 0);
|
||||||
|
@ -78,5 +84,4 @@ public class EOMonth implements FreeRefFunction {
|
||||||
return e.getErrorEval();
|
return e.getErrorEval();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,7 +173,7 @@ public class CellReference {
|
||||||
*/
|
*/
|
||||||
public static int convertColStringToIndex(String ref) {
|
public static int convertColStringToIndex(String ref) {
|
||||||
int retval=0;
|
int retval=0;
|
||||||
char[] refs = ref.toUpperCase().toCharArray();
|
char[] refs = ref.toUpperCase(Locale.ROOT).toCharArray();
|
||||||
for (int k=0; k<refs.length; k++) {
|
for (int k=0; k<refs.length; k++) {
|
||||||
char thechar = refs[k];
|
char thechar = refs[k];
|
||||||
if (thechar == ABSOLUTE_REFERENCE_MARKER) {
|
if (thechar == ABSOLUTE_REFERENCE_MARKER) {
|
||||||
|
@ -311,7 +311,7 @@ public class CellReference {
|
||||||
return false; // that was easy
|
return false; // that was easy
|
||||||
}
|
}
|
||||||
if(numberOfLetters == lastColLength) {
|
if(numberOfLetters == lastColLength) {
|
||||||
if(colStr.toUpperCase().compareTo(lastCol) > 0) {
|
if(colStr.toUpperCase(Locale.ROOT).compareTo(lastCol) > 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} 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);
|
row = reference.substring(loc);
|
||||||
CellRefParts cellRefParts = new CellRefParts(sheetName, row, col);
|
CellRefParts cellRefParts = new CellRefParts(sheetName, row, col);
|
||||||
return cellRefParts;
|
return cellRefParts;
|
||||||
|
|
Loading…
Reference in New Issue