mirror of https://github.com/apache/poi.git
Fix some Forbidden APIs errors
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1700677 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a49d4bdd07
commit
82bbbed2b5
|
@ -18,15 +18,13 @@
|
|||
package org.apache.poi.hpsf;
|
||||
|
||||
import org.apache.poi.util.HexDump;
|
||||
import org.apache.poi.util.StringUtil;
|
||||
|
||||
/**
|
||||
* <p>Represents a class ID (16 bytes). Unlike other little-endian
|
||||
* type the {@link ClassID} is not just 16 bytes stored in the wrong
|
||||
* order. Instead, it is a double word (4 bytes) followed by two
|
||||
* words (2 bytes each) followed by 8 bytes.</p>
|
||||
*
|
||||
* @author Rainer Klute <a
|
||||
* href="mailto:klute@rainer-klute.de"><klute@rainer-klute.de></a>
|
||||
*/
|
||||
public class ClassID
|
||||
{
|
||||
|
@ -238,11 +236,9 @@ public class ClassID
|
|||
*/
|
||||
public int hashCode()
|
||||
{
|
||||
return new String(bytes).hashCode();
|
||||
return new String(bytes, StringUtil.UTF8).hashCode();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* <p>Returns a human-readable representation of the Class ID in standard
|
||||
* format <code>"{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}"</code>.</p>
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.apache.poi.util.Internal;
|
|||
import org.apache.poi.util.LittleEndian;
|
||||
import org.apache.poi.util.POILogFactory;
|
||||
import org.apache.poi.util.POILogger;
|
||||
import org.apache.poi.util.StringUtil;
|
||||
|
||||
@Internal
|
||||
class CodePageString
|
||||
|
@ -64,7 +65,7 @@ class CodePageString
|
|||
{
|
||||
String result;
|
||||
if ( codepage == -1 )
|
||||
result = new String( _value );
|
||||
result = new String( _value, StringUtil.UTF8 );
|
||||
else
|
||||
result = CodePageUtil.getStringFromCodePage(_value, codepage);
|
||||
final int terminator = result.indexOf( '\0' );
|
||||
|
@ -96,7 +97,7 @@ class CodePageString
|
|||
{
|
||||
String stringNT = string + "\0";
|
||||
if ( codepage == -1 )
|
||||
_value = stringNT.getBytes();
|
||||
_value = stringNT.getBytes(StringUtil.UTF8);
|
||||
else
|
||||
_value = CodePageUtil.getBytesInCodePage(stringNT, codepage);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ package org.apache.poi.hpsf;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.poi.hpsf.wellknown.PropertyIDMap;
|
||||
|
@ -345,7 +346,7 @@ public abstract class SpecialPropertySet extends MutablePropertySet
|
|||
return Long.toString( LittleEndian.getUInt(b) );
|
||||
}
|
||||
// Maybe it's a string? who knows!
|
||||
return new String(b);
|
||||
return new String(b, Charset.forName("ASCII"));
|
||||
}
|
||||
return propertyValue.toString();
|
||||
}
|
||||
|
|
|
@ -23,7 +23,9 @@ import java.io.FileNotFoundException;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.PrintWriter;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
@ -1713,7 +1715,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
|||
DrawingGroupRecord r = (DrawingGroupRecord) workbook.findFirstRecordBySid( DrawingGroupRecord.sid );
|
||||
r.decode();
|
||||
List<EscherRecord> escherRecords = r.getEscherRecords();
|
||||
PrintWriter w = new PrintWriter(System.out);
|
||||
PrintWriter w = new PrintWriter(new OutputStreamWriter(System.out, Charset.defaultCharset()));
|
||||
for ( Iterator<EscherRecord> iterator = escherRecords.iterator(); iterator.hasNext(); )
|
||||
{
|
||||
EscherRecord escherRecord = iterator.next();
|
||||
|
|
|
@ -51,8 +51,6 @@ import org.apache.poi.ss.formula.eval.*;
|
|||
* <li>If this argument is negative, this function returns the #NUM! error value.</li>
|
||||
* <li>If this argument contains a decimal value, this function ignores the numbers to the right side of the decimal point.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @author cedric dot walter @ gmail dot com
|
||||
*/
|
||||
public final class Dec2Hex extends Var1or2ArgFunction implements FreeRefFunction {
|
||||
|
||||
|
@ -111,7 +109,7 @@ public final class Dec2Hex extends Var1or2ArgFunction implements FreeRefFunction
|
|||
|
||||
String hex;
|
||||
if (placesNumber != 0) {
|
||||
hex = String.format("%0"+placesNumber+"X", number1.intValue());
|
||||
hex = String.format("%0"+placesNumber+"X", number1.intValue(), Locale.ROOT);
|
||||
}
|
||||
else {
|
||||
hex = Integer.toHexString(number1.intValue());
|
||||
|
|
|
@ -19,6 +19,8 @@ package org.apache.poi.ss.formula.functions;
|
|||
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.apache.poi.ss.formula.OperationEvaluationContext;
|
||||
import org.apache.poi.ss.formula.eval.BlankEval;
|
||||
|
@ -33,6 +35,12 @@ import org.apache.poi.ss.usermodel.DateUtil;
|
|||
* Implementation for Excel EDATE () function.
|
||||
*/
|
||||
public class EDate 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 EDate();
|
||||
|
||||
public ValueEval evaluate(ValueEval[] args, OperationEvaluationContext ec) {
|
||||
|
@ -44,7 +52,7 @@ public class EDate implements FreeRefFunction {
|
|||
int offsetInMonthAsNumber = (int) getValue(args[1]);
|
||||
|
||||
Date startDate = DateUtil.getJavaDate(startDateAsNumber);
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
Calendar calendar = Calendar.getInstance(DEFAULT_TIMEZONE, Locale.ROOT);
|
||||
calendar.setTime(startDate);
|
||||
calendar.add(Calendar.MONTH, offsetInMonthAsNumber);
|
||||
return new NumberEval(DateUtil.getExcelDate(calendar.getTime()));
|
||||
|
|
|
@ -19,12 +19,9 @@ package org.apache.poi.hssf.dev;
|
|||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import org.apache.poi.POIDataSamples;
|
||||
import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestBiffViewer extends BaseXLSIteratingTest {
|
||||
static {
|
||||
|
@ -52,7 +49,7 @@ public class TestBiffViewer extends BaseXLSIteratingTest {
|
|||
InputStream is = BiffViewer.getPOIFSInputStream(fs);
|
||||
try {
|
||||
// use a NullOutputStream to not write the bytes anywhere for best runtime
|
||||
BiffViewer.runBiffViewer(new PrintStream(NULL_OUTPUT_STREAM), is, true, true, true, false);
|
||||
BiffViewer.runBiffViewer(new PrintWriter(NULL_OUTPUT_STREAM), is, true, true, true, false);
|
||||
} finally {
|
||||
is.close();
|
||||
fs.close();
|
||||
|
|
Loading…
Reference in New Issue