Remove unnecessary local variables

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1808518 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dominik Stadler 2017-09-16 08:28:38 +00:00
parent 7937da6a10
commit 5341a131de
118 changed files with 195 additions and 337 deletions

View File

@ -139,8 +139,7 @@ public String[][] getParameterInfo() {
System.out.println(field); System.out.println(field);
field = uc.getHeaderField(i); field = uc.getHeaderField(i);
} }
BufferedInputStream is = new BufferedInputStream(uc.getInputStream()); return new BufferedInputStream(uc.getInputStream());
return is;
} }

View File

@ -40,8 +40,7 @@ public final class Word2Forrest
@SuppressWarnings("unused") @SuppressWarnings("unused")
public Word2Forrest(HWPFDocument doc, OutputStream stream) throws IOException public Word2Forrest(HWPFDocument doc, OutputStream stream) throws IOException
{ {
OutputStreamWriter out = new OutputStreamWriter (stream, Charset.forName("UTF-8")); _out = new OutputStreamWriter (stream, Charset.forName("UTF-8"));
_out = out;
_doc = doc; _doc = doc;
init (); init ();

View File

@ -76,10 +76,7 @@ public class CalculateMortgage implements FreeRefFunction {
double i = r / 12 ; double i = r / 12 ;
double n = y * 12 ; double n = y * 12 ;
double principalAndInterest = return p * (( i * Math.pow((1 + i),n ) ) / ( Math.pow((1 + i),n) - 1));
p * (( i * Math.pow((1 + i),n ) ) / ( Math.pow((1 + i),n) - 1)) ;
return principalAndInterest ;
} }
/** /**
* Excel does not support infinities and NaNs, rather, it gives a #NUM! error in these cases * Excel does not support infinities and NaNs, rather, it gives a #NUM! error in these cases

View File

@ -154,9 +154,8 @@ public class ExcelAntWorkbookUtil extends Typedef {
} }
UDFFinder udff1 = new DefaultUDFFinder(names, functions); UDFFinder udff1 = new DefaultUDFFinder(names, functions);
UDFFinder udff = new AggregatingUDFFinder(udff1);
return udff; return new AggregatingUDFFinder(udff1);
} }

View File

@ -78,10 +78,7 @@ public class CalculateMortgageFunction implements FreeRefFunction {
double i = r / 12 ; double i = r / 12 ;
double n = y * 12 ; double n = y * 12 ;
double principalAndInterest = return p * (( i * Math.pow((1 + i),n ) ) / ( Math.pow((1 + i),n) - 1));
p * (( i * Math.pow((1 + i),n ) ) / ( Math.pow((1 + i),n) - 1)) ;
return principalAndInterest ;
} }
/** /**
* Excel does not support infinities and NaNs, rather, it gives a #NUM! error in these cases * Excel does not support infinities and NaNs, rather, it gives a #NUM! error in these cases

View File

@ -218,12 +218,11 @@ public class EscherColorRef {
} }
public int[] getRGB() { public int[] getRGB() {
int rgb[] = { return new int[]{
FLAG_RED.getValue(colorRef), FLAG_RED.getValue(colorRef),
FLAG_GREEN.getValue(colorRef), FLAG_GREEN.getValue(colorRef),
FLAG_BLUE.getValue(colorRef) FLAG_BLUE.getValue(colorRef)
}; };
return rgb;
} }
/** /**

View File

@ -391,8 +391,7 @@ public class PropertySet {
*/ */
try { try {
final byte[] buffer = IOUtils.peekFirstNBytes(stream, BUFFER_SIZE); final byte[] buffer = IOUtils.peekFirstNBytes(stream, BUFFER_SIZE);
final boolean isPropertySetStream = isPropertySetStream(buffer, 0, buffer.length); return isPropertySetStream(buffer, 0, buffer.length);
return isPropertySetStream;
} catch (EmptyFileException e) { } catch (EmptyFileException e) {
return false; return false;
} }

View File

@ -955,8 +955,7 @@ public class Section {
for (int i = 0; i < pa.length; i++) { for (int i = 0; i < pa.length; i++) {
hashCode += pa[i].hashCode(); hashCode += pa[i].hashCode();
} }
final int returnHashCode = (int) (hashCode & 0x0ffffffffL); return (int) (hashCode & 0x0ffffffffL);
return returnHashCode;
} }

View File

@ -198,9 +198,8 @@ public final class Thumbnail {
*/ */
public long getClipboardFormatTag() public long getClipboardFormatTag()
{ {
long clipboardFormatTag = LittleEndian.getInt(getThumbnail(), return (long) LittleEndian.getInt(getThumbnail(),
OFFSET_CFTAG); OFFSET_CFTAG);
return clipboardFormatTag;
} }

View File

@ -143,12 +143,9 @@ public class HPSFPropertiesExtractor extends POIOLE2TextExtractor {
public static void main(String[] args) throws IOException { public static void main(String[] args) throws IOException {
for (String file : args) { for (String file : args) {
HPSFPropertiesExtractor ext = new HPSFPropertiesExtractor( try (HPSFPropertiesExtractor ext = new HPSFPropertiesExtractor(
new NPOIFSFileSystem(new File(file))); new NPOIFSFileSystem(new File(file)))) {
try {
System.out.println(ext.getText()); System.out.println(ext.getText());
} finally {
ext.close();
} }
} }
} }

View File

@ -422,8 +422,7 @@ public final class BiffViewer {
} else { } else {
boolean dumpInterpretedRecords = cmdArgs.shouldDumpRecordInterpretations(); boolean dumpInterpretedRecords = cmdArgs.shouldDumpRecordInterpretations();
boolean dumpHex = cmdArgs.shouldDumpBiffHex(); boolean dumpHex = cmdArgs.shouldDumpBiffHex();
boolean zeroAlignHexDump = dumpInterpretedRecords; // TODO - fix non-zeroAlign runBiffViewer(pw, is, dumpInterpretedRecords, dumpHex, dumpInterpretedRecords,
runBiffViewer(pw, is, dumpInterpretedRecords, dumpHex, zeroAlignHexDump,
cmdArgs.suppressHeader()); cmdArgs.suppressHeader());
} }
} finally { } finally {

View File

@ -491,10 +491,8 @@ public final class InternalWorkbook {
"There are only " + numfonts "There are only " + numfonts
+ " font records, you asked for " + idx); + " font records, you asked for " + idx);
} }
FontRecord retval =
( FontRecord ) records.get((records.getFontpos() - (numfonts - 1)) + index);
return retval; return ( FontRecord ) records.get((records.getFontpos() - (numfonts - 1)) + index);
} }
/** /**
@ -867,10 +865,8 @@ public final class InternalWorkbook {
int xfptr = records.getXfpos() - (numxfs - 1); int xfptr = records.getXfpos() - (numxfs - 1);
xfptr += index; xfptr += index;
ExtendedFormatRecord retval =
( ExtendedFormatRecord ) records.get(xfptr);
return retval; return ( ExtendedFormatRecord ) records.get(xfptr);
} }
/** /**

View File

@ -36,8 +36,7 @@ public abstract class CFHeaderBase extends StandardRecord implements Cloneable {
protected CFHeaderBase() { protected CFHeaderBase() {
} }
protected CFHeaderBase(CellRangeAddress[] regions, int nRules) { protected CFHeaderBase(CellRangeAddress[] regions, int nRules) {
CellRangeAddress[] unmergedRanges = regions; CellRangeAddress[] mergeCellRanges = CellRangeUtil.mergeCellRanges(regions);
CellRangeAddress[] mergeCellRanges = CellRangeUtil.mergeCellRanges(unmergedRanges);
setCellRanges(mergeCellRanges); setCellRanges(mergeCellRanges);
field_1_numcf = nRules; field_1_numcf = nRules;
} }

View File

@ -77,8 +77,7 @@ public final class EndSubRecord extends SubRecord implements Cloneable {
@Override @Override
public EndSubRecord clone() { public EndSubRecord clone() {
EndSubRecord rec = new EndSubRecord();
return rec; return new EndSubRecord();
} }
} }

View File

@ -522,8 +522,7 @@ public final class EscherAggregate extends AbstractEscherHolderRecord {
} }
for (NoteRecord noteRecord : tailRec.values()) { for (NoteRecord noteRecord : tailRec.values()) {
Record rec = noteRecord; pos += noteRecord.serialize(pos, data);
pos += rec.serialize(pos, data);
} }
int bytesWritten = pos - offset; int bytesWritten = pos - offset;
if (bytesWritten != getRecordSize()) if (bytesWritten != getRecordSize())

View File

@ -128,8 +128,7 @@ public final class FormatRecord extends StandardRecord implements Cloneable {
throw new IllegalArgumentException("Bad requested string length (" + requestedLength + ")"); throw new IllegalArgumentException("Bad requested string length (" + requestedLength + ")");
} }
char[] buf = null; char[] buf = null;
boolean isCompressedEncoding = pIsCompressedEncoding; int availableChars = pIsCompressedEncoding ? ris.remaining() : ris.remaining() / LittleEndianConsts.SHORT_SIZE;
int availableChars = isCompressedEncoding ? ris.remaining() : ris.remaining() / LittleEndianConsts.SHORT_SIZE;
//everything worked out. Great! //everything worked out. Great!
int remaining = ris.remaining(); int remaining = ris.remaining();
if (requestedLength == availableChars) { if (requestedLength == availableChars) {
@ -142,7 +141,7 @@ public final class FormatRecord extends StandardRecord implements Cloneable {
} }
for (int i = 0; i < buf.length; i++) { for (int i = 0; i < buf.length; i++) {
char ch; char ch;
if (isCompressedEncoding) { if (pIsCompressedEncoding) {
ch = (char) ris.readUByte(); ch = (char) ris.readUByte();
} else { } else {
ch = (char) ris.readShort(); ch = (char) ris.readShort();

View File

@ -82,8 +82,7 @@ public final class MergeCellsRecord extends StandardRecord implements Cloneable
@Override @Override
public void serialize(LittleEndianOutput out) { public void serialize(LittleEndianOutput out) {
int nItems = _numberOfRegions; out.writeShort(_numberOfRegions);
out.writeShort(nItems);
for (int i = 0; i < _numberOfRegions; i++) { for (int i = 0; i < _numberOfRegions; i++) {
_regions[_startIndex + i].serialize(out); _regions[_startIndex + i].serialize(out);
} }

View File

@ -84,22 +84,21 @@ public final class NameCommentRecord extends StandardRecord {
* @param ris the RecordInputstream to read the record from * @param ris the RecordInputstream to read the record from
*/ */
public NameCommentRecord(final RecordInputStream ris) { public NameCommentRecord(final RecordInputStream ris) {
final LittleEndianInput in = ris; field_1_record_type = ris.readShort();
field_1_record_type = in.readShort(); field_2_frt_cell_ref_flag = ris.readShort();
field_2_frt_cell_ref_flag = in.readShort(); field_3_reserved = ris.readLong();
field_3_reserved = in.readLong(); final int field_4_name_length = ris.readShort();
final int field_4_name_length = in.readShort(); final int field_5_comment_length = ris.readShort();
final int field_5_comment_length = in.readShort();
if (in.readByte() == 0) { if (ris.readByte() == 0) {
field_6_name_text = StringUtil.readCompressedUnicode(in, field_4_name_length); field_6_name_text = StringUtil.readCompressedUnicode(ris, field_4_name_length);
} else { } else {
field_6_name_text = StringUtil.readUnicodeLE(in, field_4_name_length); field_6_name_text = StringUtil.readUnicodeLE(ris, field_4_name_length);
} }
if (in.readByte() == 0) { if (ris.readByte() == 0) {
field_7_comment_text = StringUtil.readCompressedUnicode(in, field_5_comment_length); field_7_comment_text = StringUtil.readCompressedUnicode(ris, field_5_comment_length);
} else { } else {
field_7_comment_text = StringUtil.readUnicodeLE(in, field_5_comment_length); field_7_comment_text = StringUtil.readUnicodeLE(ris, field_5_comment_length);
} }
} }

View File

@ -103,13 +103,12 @@ public final class RecordFactoryInputStream {
} }
public RecordInputStream createDecryptingStream(InputStream original) { public RecordInputStream createDecryptingStream(InputStream original) {
FilePassRecord fpr = _filePassRec;
String userPassword = Biff8EncryptionKey.getCurrentUserPassword(); String userPassword = Biff8EncryptionKey.getCurrentUserPassword();
if (userPassword == null) { if (userPassword == null) {
userPassword = Decryptor.DEFAULT_PASSWORD; userPassword = Decryptor.DEFAULT_PASSWORD;
} }
EncryptionInfo info = fpr.getEncryptionInfo(); EncryptionInfo info = _filePassRec.getEncryptionInfo();
try { try {
if (!info.getDecryptor().verifyPassword(userPassword)) { if (!info.getDecryptor().verifyPassword(userPassword)) {
throw new EncryptedDocumentException( throw new EncryptedDocumentException(

View File

@ -363,12 +363,11 @@ public final class ColumnInfoRecordsAggregate extends RecordAggregate implements
attemptMergeColInfoRecords(k); attemptMergeColInfoRecords(k);
} else { } else {
//split to 3 records //split to 3 records
ColumnInfoRecord ciStart = ci;
ColumnInfoRecord ciMid = copyColInfo(ci); ColumnInfoRecord ciMid = copyColInfo(ci);
ColumnInfoRecord ciEnd = copyColInfo(ci); ColumnInfoRecord ciEnd = copyColInfo(ci);
int lastcolumn = ci.getLastColumn(); int lastcolumn = ci.getLastColumn();
ciStart.setLastColumn(targetColumnIx - 1); ci.setLastColumn(targetColumnIx - 1);
ciMid.setFirstColumn(targetColumnIx); ciMid.setFirstColumn(targetColumnIx);
ciMid.setLastColumn(targetColumnIx); ciMid.setLastColumn(targetColumnIx);

View File

@ -46,13 +46,12 @@ public final class MergedCellsTable extends RecordAggregate {
* @param rs * @param rs
*/ */
public void read(RecordStream rs) { public void read(RecordStream rs) {
List<CellRangeAddress> temp = _mergedRegions;
while (rs.peekNextClass() == MergeCellsRecord.class) { while (rs.peekNextClass() == MergeCellsRecord.class) {
MergeCellsRecord mcr = (MergeCellsRecord) rs.getNext(); MergeCellsRecord mcr = (MergeCellsRecord) rs.getNext();
int nRegions = mcr.getNumAreas(); int nRegions = mcr.getNumAreas();
for (int i = 0; i < nRegions; i++) { for (int i = 0; i < nRegions; i++) {
CellRangeAddress cra = mcr.getAreaAt(i); CellRangeAddress cra = mcr.getAreaAt(i);
temp.add(cra); _mergedRegions.add(cra);
} }
} }
} }
@ -67,10 +66,9 @@ public final class MergedCellsTable extends RecordAggregate {
int nMergedCellsRecords = nRegions / MAX_MERGED_REGIONS; int nMergedCellsRecords = nRegions / MAX_MERGED_REGIONS;
int nLeftoverMergedRegions = nRegions % MAX_MERGED_REGIONS; int nLeftoverMergedRegions = nRegions % MAX_MERGED_REGIONS;
int result = nMergedCellsRecords return nMergedCellsRecords
* (4 + CellRangeAddressList.getEncodedSize(MAX_MERGED_REGIONS)) + 4 * (4 + CellRangeAddressList.getEncodedSize(MAX_MERGED_REGIONS)) + 4
+ CellRangeAddressList.getEncodedSize(nLeftoverMergedRegions); + CellRangeAddressList.getEncodedSize(nLeftoverMergedRegions);
return result;
} }
public void visitContainedRecords(RecordVisitor rv) { public void visitContainedRecords(RecordVisitor rv) {

View File

@ -172,8 +172,7 @@ public final class SharedValueManager {
_groupsCache.put(getKeyForCache(group._firstCell),group); _groupsCache.put(getKeyForCache(group._firstCell),group);
} }
} }
SharedFormulaGroup sfg = _groupsCache.get(getKeyForCache(cellRef)); return _groupsCache.get(getKeyForCache(cellRef));
return sfg;
} }
private Integer getKeyForCache(final CellReference cellRef) { private Integer getKeyForCache(final CellReference cellRef) {

View File

@ -66,8 +66,7 @@ public final class BeginRecord extends StandardRecord implements Cloneable {
@Override @Override
public BeginRecord clone() { public BeginRecord clone() {
BeginRecord br = new BeginRecord();
// No data so nothing to copy // No data so nothing to copy
return br; return new BeginRecord();
} }
} }

View File

@ -67,8 +67,7 @@ public final class EndRecord extends StandardRecord implements Cloneable {
@Override @Override
public EndRecord clone() { public EndRecord clone() {
EndRecord er = new EndRecord();
// No data so nothing to copy // No data so nothing to copy
return er; return new EndRecord();
} }
} }

View File

@ -64,8 +64,6 @@ public final class PlotAreaRecord extends StandardRecord {
} }
public Object clone() { public Object clone() {
PlotAreaRecord rec = new PlotAreaRecord(); return new PlotAreaRecord();
return rec;
} }
} }

View File

@ -151,9 +151,8 @@ public class EscherGraphics extends Graphics
@Override @Override
public Graphics create() public Graphics create()
{ {
EscherGraphics g = new EscherGraphics(escherGroup, workbook, return new EscherGraphics(escherGroup, workbook,
foreground, font, verticalPointsPerPixel ); foreground, font, verticalPointsPerPixel );
return g;
} }
@Override @Override

View File

@ -127,8 +127,7 @@ public final class EscherGraphics2d extends Graphics2D {
public Graphics create() public Graphics create()
{ {
EscherGraphics2d g2d = new EscherGraphics2d(_escherGraphics); return new EscherGraphics2d(_escherGraphics);
return g2d;
} }
public void dispose() public void dispose()

View File

@ -108,8 +108,7 @@ public final class HSSFRichTextString implements Comparable<HSSFRichTextString>,
private UnicodeString cloneStringIfRequired() { private UnicodeString cloneStringIfRequired() {
if (_book == null) if (_book == null)
return _string; return _string;
UnicodeString s = (UnicodeString)_string.clone(); return (UnicodeString)_string.clone();
return s;
} }
private void addToSSTIfRequired() { private void addToSSTIfRequired() {

View File

@ -570,7 +570,6 @@ public class CryptoFunctions {
/* /*
* SET Intermediate3 TO Intermediate1 BITWISE OR Intermediate2 * SET Intermediate3 TO Intermediate1 BITWISE OR Intermediate2
*/ */
short intermediate3 = (short)(intermediate1 | intermediate2); return (short)(intermediate1 | intermediate2);
return intermediate3;
} }
} }

View File

@ -125,8 +125,7 @@ public class BinaryRC4Decryptor extends Decryptor implements Cloneable {
hash = new byte[5]; hash = new byte[5];
System.arraycopy(hashAlg.digest(), 0, hash, 0, 5); System.arraycopy(hashAlg.digest(), 0, hash, 0, 5);
SecretKey skey = new SecretKeySpec(hash, ver.getCipherAlgorithm().jceId); return new SecretKeySpec(hash, ver.getCipherAlgorithm().jceId);
return skey;
} }
@Override @Override

View File

@ -82,8 +82,7 @@ public class BinaryRC4Encryptor extends Encryptor implements Cloneable {
@Override @Override
public OutputStream getDataStream(DirectoryNode dir) public OutputStream getDataStream(DirectoryNode dir)
throws IOException, GeneralSecurityException { throws IOException, GeneralSecurityException {
OutputStream countStream = new BinaryRC4CipherOutputStream(dir); return new BinaryRC4CipherOutputStream(dir);
return countStream;
} }
@Override @Override

View File

@ -134,8 +134,7 @@ public class CryptoAPIDecryptor extends Decryptor implements Cloneable {
MessageDigest hashAlg = CryptoFunctions.getMessageDigest(hashAlgo); MessageDigest hashAlg = CryptoFunctions.getMessageDigest(hashAlgo);
hashAlg.update(ver.getSalt()); hashAlg.update(ver.getSalt());
byte hash[] = hashAlg.digest(StringUtil.getToUnicodeLE(password)); byte hash[] = hashAlg.digest(StringUtil.getToUnicodeLE(password));
SecretKey skey = new SecretKeySpec(hash, ver.getCipherAlgorithm().jceId); return new SecretKeySpec(hash, ver.getCipherAlgorithm().jceId);
return skey;
} }
@Override @Override

View File

@ -98,8 +98,7 @@ public class StandardDecryptor extends Decryptor implements Cloneable {
byte[] key = Arrays.copyOf(x3, keySize); byte[] key = Arrays.copyOf(x3, keySize);
SecretKey skey = new SecretKeySpec(key, ver.getCipherAlgorithm().jceId); return new SecretKeySpec(key, ver.getCipherAlgorithm().jceId);
return skey;
} }
protected static byte[] fillAndXor(byte hash[], byte fillByte) { protected static byte[] fillAndXor(byte hash[], byte fillByte) {

View File

@ -256,9 +256,8 @@ public class POIFSDocumentPath
} }
String[] parentComponents = new String[ length ]; String[] parentComponents = new String[ length ];
System.arraycopy(components, 0, parentComponents, 0, length); System.arraycopy(components, 0, parentComponents, 0, length);
POIFSDocumentPath parent = new POIFSDocumentPath(parentComponents);
return parent; return new POIFSDocumentPath(parentComponents);
} }
/** /**

View File

@ -38,10 +38,9 @@ public final class SmallBlockTableReader {
blockList.fetchBlocks(root.getStartBlock(), -1); blockList.fetchBlocks(root.getStartBlock(), -1);
// Turn that into a list // Turn that into a list
BlockList list =new SmallDocumentBlockList(
SmallDocumentBlock.extract(bigBlockSize, smallBlockBlocks));
return list; return new SmallDocumentBlockList(
SmallDocumentBlock.extract(bigBlockSize, smallBlockBlocks));
} }
private static BlockAllocationTableReader prepareReader( private static BlockAllocationTableReader prepareReader(
final POIFSBigBlockSize bigBlockSize, final POIFSBigBlockSize bigBlockSize,

View File

@ -256,9 +256,8 @@ public class DrawPaint {
LOG.log(POILogger.ERROR, "Can't load image data"); LOG.log(POILogger.ERROR, "Can't load image data");
return null; return null;
} }
Paint paint = new java.awt.TexturePaint(image, textAnchor);
return paint; return new java.awt.TexturePaint(image, textAnchor);
} }
/** /**

View File

@ -174,8 +174,7 @@ public enum AutoNumberingScheme {
public String format(int value) { public String format(int value) {
String index = formatIndex(value); String index = formatIndex(value);
String cased = formatCase(index); String cased = formatCase(index);
String seperated = formatSeperator(cased); return formatSeperator(cased);
return seperated;
} }
private String formatSeperator(String cased) { private String formatSeperator(String cased) {

View File

@ -245,13 +245,12 @@ public class CellNumberFormatter extends CellFormatter {
} else { } else {
StringBuffer fmtBuf = new StringBuffer(); StringBuffer fmtBuf = new StringBuffer();
boolean first = true; boolean first = true;
List<Special> specialList = integerSpecials;
if (integerSpecials.size() == 1) { if (integerSpecials.size() == 1) {
// If we don't do this, we get ".6e5" instead of "6e4" // If we don't do this, we get ".6e5" instead of "6e4"
fmtBuf.append("0"); fmtBuf.append("0");
first = false; first = false;
} else } else
for (Special s : specialList) { for (Special s : integerSpecials) {
if (isDigitFmt(s)) { if (isDigitFmt(s)) {
fmtBuf.append(first ? '#' : '0'); fmtBuf.append(first ? '#' : '0');
first = false; first = false;

View File

@ -132,13 +132,12 @@ public abstract class BaseFormulaEvaluator implements FormulaEvaluator, Workbook
if (cell == null) { if (cell == null) {
return null; return null;
} }
Cell result = cell;
if (cell.getCellTypeEnum() == CellType.FORMULA) { if (cell.getCellTypeEnum() == CellType.FORMULA) {
CellValue cv = evaluateFormulaCellValue(cell); CellValue cv = evaluateFormulaCellValue(cell);
setCellValue(cell, cv); setCellValue(cell, cv);
setCellType(cell, cv); // cell will no longer be a formula cell setCellType(cell, cv); // cell will no longer be a formula cell
} }
return result; return cell;
} }
protected abstract CellValue evaluateFormulaCellValue(Cell cell); protected abstract CellValue evaluateFormulaCellValue(Cell cell);

View File

@ -421,13 +421,12 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
return getMeaningfulValues(region, false, new ValueFunction() { return getMeaningfulValues(region, false, new ValueFunction() {
@Override @Override
public Set<ValueAndFormat> evaluate(List<ValueAndFormat> allValues) { public Set<ValueAndFormat> evaluate(List<ValueAndFormat> allValues) {
List<ValueAndFormat> values = allValues;
final ConditionFilterData conf = rule.getFilterConfiguration(); final ConditionFilterData conf = rule.getFilterConfiguration();
if (! conf.getBottom()) { if (! conf.getBottom()) {
Collections.sort(values, Collections.reverseOrder()); Collections.sort(allValues, Collections.reverseOrder());
} else { } else {
Collections.sort(values); Collections.sort(allValues);
} }
int limit = (int) conf.getRank(); int limit = (int) conf.getRank();
@ -447,15 +446,14 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
return getMeaningfulValues(region, true, new ValueFunction() { return getMeaningfulValues(region, true, new ValueFunction() {
@Override @Override
public Set<ValueAndFormat> evaluate(List<ValueAndFormat> allValues) { public Set<ValueAndFormat> evaluate(List<ValueAndFormat> allValues) {
List<ValueAndFormat> values = allValues; Collections.sort(allValues);
Collections.sort(values);
final Set<ValueAndFormat> unique = new HashSet<>(); final Set<ValueAndFormat> unique = new HashSet<>();
for (int i=0; i < values.size(); i++) { for (int i = 0; i < allValues.size(); i++) {
final ValueAndFormat v = values.get(i); final ValueAndFormat v = allValues.get(i);
// skip this if the current value matches the next one, or is the last one and matches the previous one // skip this if the current value matches the next one, or is the last one and matches the previous one
if ( (i < values.size()-1 && v.equals(values.get(i+1)) ) || ( i > 0 && i == values.size()-1 && v.equals(values.get(i-1)) ) ) { if ( (i < allValues.size()-1 && v.equals(allValues.get(i+1)) ) || ( i > 0 && i == allValues.size()-1 && v.equals(allValues.get(i-1)) ) ) {
// current value matches next value, skip both // current value matches next value, skip both
i++; i++;
continue; continue;
@ -472,15 +470,14 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
return getMeaningfulValues(region, true, new ValueFunction() { return getMeaningfulValues(region, true, new ValueFunction() {
@Override @Override
public Set<ValueAndFormat> evaluate(List<ValueAndFormat> allValues) { public Set<ValueAndFormat> evaluate(List<ValueAndFormat> allValues) {
List<ValueAndFormat> values = allValues; Collections.sort(allValues);
Collections.sort(values);
final Set<ValueAndFormat> dup = new HashSet<>(); final Set<ValueAndFormat> dup = new HashSet<>();
for (int i=0; i < values.size(); i++) { for (int i = 0; i < allValues.size(); i++) {
final ValueAndFormat v = values.get(i); final ValueAndFormat v = allValues.get(i);
// skip this if the current value matches the next one, or is the last one and matches the previous one // skip this if the current value matches the next one, or is the last one and matches the previous one
if ( (i < values.size()-1 && v.equals(values.get(i+1)) ) || ( i > 0 && i == values.size()-1 && v.equals(values.get(i-1)) ) ) { if ( (i < allValues.size()-1 && v.equals(allValues.get(i+1)) ) || ( i > 0 && i == allValues.size()-1 && v.equals(allValues.get(i-1)) ) ) {
// current value matches next value, add one // current value matches next value, add one
dup.add(v); dup.add(v);
i++; i++;
@ -499,19 +496,18 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
List<ValueAndFormat> values = new ArrayList<>(getMeaningfulValues(region, false, new ValueFunction() { List<ValueAndFormat> values = new ArrayList<>(getMeaningfulValues(region, false, new ValueFunction() {
@Override @Override
public Set<ValueAndFormat> evaluate(List<ValueAndFormat> allValues) { public Set<ValueAndFormat> evaluate(List<ValueAndFormat> allValues) {
List<ValueAndFormat> values = allValues;
double total = 0; double total = 0;
ValueEval[] pop = new ValueEval[values.size()]; ValueEval[] pop = new ValueEval[allValues.size()];
for (int i = 0; i < values.size(); i++) { for (int i = 0; i < allValues.size(); i++) {
ValueAndFormat v = values.get(i); ValueAndFormat v = allValues.get(i);
total += v.value.doubleValue(); total += v.value.doubleValue();
pop[i] = new NumberEval(v.value.doubleValue()); pop[i] = new NumberEval(v.value.doubleValue());
} }
final Set<ValueAndFormat> avgSet = new LinkedHashSet<>(1); final Set<ValueAndFormat> avgSet = new LinkedHashSet<>(1);
avgSet.add(new ValueAndFormat(new Double(values.size() == 0 ? 0 : total / values.size()), null)); avgSet.add(new ValueAndFormat(new Double(allValues.size() == 0 ? 0 : total / allValues.size()), null));
final double stdDev = values.size() <= 1 ? 0 : ((NumberEval) AggregateFunction.STDEV.evaluate(pop, 0, 0)).getNumberValue(); final double stdDev = allValues.size() <= 1 ? 0 : ((NumberEval) AggregateFunction.STDEV.evaluate(pop, 0, 0)).getNumberValue();
avgSet.add(new ValueAndFormat(new Double(stdDev), null)); avgSet.add(new ValueAndFormat(new Double(stdDev), null));
return avgSet; return avgSet;
} }

View File

@ -125,8 +125,7 @@ public final class WorkbookEvaluator {
} }
/* package */ EvaluationName getName(String name, int sheetIndex) { /* package */ EvaluationName getName(String name, int sheetIndex) {
EvaluationName evalName = _workbook.getName(name, sheetIndex); return _workbook.getName(name, sheetIndex);
return evalName;
} }
private static boolean isDebugLogEnabled() { private static boolean isDebugLogEnabled() {

View File

@ -342,8 +342,7 @@ public final class DStarRunner implements Function3Arg {
// Construct double from condition. // Construct double from condition.
double conditionValue = 0.0; double conditionValue = 0.0;
try { try {
int intValue = Integer.parseInt(condition); conditionValue = Integer.parseInt(condition);
conditionValue = intValue;
} catch (NumberFormatException e) { // It's not an int. } catch (NumberFormatException e) { // It's not an int.
try { try {
conditionValue = Double.parseDouble(condition); conditionValue = Double.parseDouble(condition);

View File

@ -40,8 +40,7 @@ public class Finance {
*/ */
// http://arachnoid.com/lutusp/finance.html // http://arachnoid.com/lutusp/finance.html
static public double pmt(double r, int nper, double pv, double fv, int type) { static public double pmt(double r, int nper, double pv, double fv, int type) {
double pmt = -r * (pv * Math.pow(1 + r, nper) + fv) / ((1 + r*type) * (Math.pow(1 + r, nper) - 1)); return -r * (pv * Math.pow(1 + r, nper) + fv) / ((1 + r*type) * (Math.pow(1 + r, nper) - 1));
return pmt;
} }
@ -153,8 +152,7 @@ public class Finance {
*/ */
//http://en.wikipedia.org/wiki/Future_value //http://en.wikipedia.org/wiki/Future_value
static public double fv(double r, int nper, double pmt, double pv, int type) { static public double fv(double r, int nper, double pmt, double pv, int type) {
double fv = -(pv * Math.pow(1 + r, nper) + pmt * (1+r*type) * (Math.pow(1 + r, nper) - 1) / r); return -(pv * Math.pow(1 + r, nper) + pmt * (1+r*type) * (Math.pow(1 + r, nper) - 1) / r);
return fv;
} }
/** /**

View File

@ -93,18 +93,17 @@ public final class Index implements Function2Arg, Function3Arg, Function4Arg {
} }
private static TwoDEval convertFirstArg(ValueEval arg0) { private static TwoDEval convertFirstArg(ValueEval arg0) {
ValueEval firstArg = arg0; if (arg0 instanceof RefEval) {
if (firstArg instanceof RefEval) {
// convert to area ref for simpler code in getValueFromArea() // convert to area ref for simpler code in getValueFromArea()
return ((RefEval)firstArg).offset(0, 0, 0, 0); return ((RefEval) arg0).offset(0, 0, 0, 0);
} }
if((firstArg instanceof TwoDEval)) { if((arg0 instanceof TwoDEval)) {
return (TwoDEval) firstArg; return (TwoDEval) arg0;
} }
// else the other variation of this function takes an array as the first argument // else the other variation of this function takes an array as the first argument
// it seems like interface 'ArrayEval' does not even exist yet // it seems like interface 'ArrayEval' does not even exist yet
throw new RuntimeException("Incomplete code - cannot handle first arg of type (" throw new RuntimeException("Incomplete code - cannot handle first arg of type ("
+ firstArg.getClass().getName() + ")"); + arg0.getClass().getName() + ")");
} }

View File

@ -365,11 +365,10 @@ public abstract class NumericFunction implements Function {
double d0 = NumericFunction.singleOperandEvaluate(arg0, srcRowIndex, srcColumnIndex); double d0 = NumericFunction.singleOperandEvaluate(arg0, srcRowIndex, srcColumnIndex);
double d1 = NumericFunction.singleOperandEvaluate(arg1, srcRowIndex, srcColumnIndex); double d1 = NumericFunction.singleOperandEvaluate(arg1, srcRowIndex, srcColumnIndex);
double logE = Math.log(d0); double logE = Math.log(d0);
double base = d1; if (Double.compare(d1, Math.E) == 0) {
if (Double.compare(base, Math.E) == 0) {
result = logE; result = logE;
} else { } else {
result = logE / Math.log(base); result = logE / Math.log(d1);
} }
NumericFunction.checkValue(result); NumericFunction.checkValue(result);
} catch (EvaluationException e) { } catch (EvaluationException e) {

View File

@ -78,8 +78,7 @@ public final class AttrPtg extends ControlPtg {
_options = in.readByte(); _options = in.readByte();
_data = in.readShort(); _data = in.readShort();
if (isOptimizedChoose()) { if (isOptimizedChoose()) {
int nCases = _data; int[] jumpTable = new int[(int) _data];
int[] jumpTable = new int[nCases];
for (int i = 0; i < jumpTable.length; i++) { for (int i = 0; i < jumpTable.length; i++) {
jumpTable[i] = in.readUShort(); jumpTable[i] = in.readUShort();
} }

View File

@ -79,9 +79,8 @@ public final class NameXPtg extends OperandPtg implements WorkbookDependentFormu
} }
public String toString(){ public String toString(){
String retValue = "NameXPtg:[sheetRefIndex:" + _sheetRefIndex + return "NameXPtg:[sheetRefIndex:" + _sheetRefIndex +
" , nameNumber:" + _nameNumber + "]" ; " , nameNumber:" + _nameNumber + "]";
return retValue;
} }
public byte getDefaultOperandClass() { public byte getDefaultOperandClass() {

View File

@ -153,7 +153,7 @@ public class CellCopyPolicy {
} }
public Builder createBuilder() { public Builder createBuilder() {
final Builder builder = new Builder() return new Builder()
.cellValue(copyCellValue) .cellValue(copyCellValue)
.cellStyle(copyCellStyle) .cellStyle(copyCellStyle)
.cellFormula(copyCellFormula) .cellFormula(copyCellFormula)
@ -162,7 +162,6 @@ public class CellCopyPolicy {
.rowHeight(copyRowHeight) .rowHeight(copyRowHeight)
.condenseRows(condenseRows) .condenseRows(condenseRows)
.mergedRegions(copyMergedRegions); .mergedRegions(copyMergedRegions);
return builder;
} }
/* /*

View File

@ -299,10 +299,9 @@ public abstract class CellRangeAddressBase {
@Override @Override
public int hashCode() { public int hashCode() {
int code = (getMinColumn() + return (getMinColumn() +
(getMaxColumn() << 8) + (getMaxColumn() << 8) +
(getMinRow() << 16) + (getMinRow() << 16) +
(getMaxRow() << 24)); (getMaxRow() << 24));
return code;
} }
} }

View File

@ -397,8 +397,7 @@ public class CellReference {
String col = matcher.group(1); String col = matcher.group(1);
String row = matcher.group(2); String row = matcher.group(2);
CellRefParts cellRefParts = new CellRefParts(sheetName, row, col); return new CellRefParts(sheetName, row, col);
return cellRefParts;
} }
private static String parseSheetName(String reference, int indexOfSheetNameDelimiter) { private static String parseSheetName(String reference, int indexOfSheetNameDelimiter) {

View File

@ -62,8 +62,7 @@ final class ExpandedDouble {
_significand = frac.shiftLeft(expAdj); _significand = frac.shiftLeft(expAdj);
_binaryExponent = (biasedExp & 0x07FF) - 1023 - expAdj; _binaryExponent = (biasedExp & 0x07FF) - 1023 - expAdj;
} else { } else {
BigInteger frac = getFrac(rawBits); _significand = getFrac(rawBits);
_significand = frac;
_binaryExponent = (biasedExp & 0x07FF) - 1023; _binaryExponent = (biasedExp & 0x07FF) - 1023;
} }
} }

View File

@ -210,12 +210,10 @@ public class ImageUtils {
anchor.setRow2(row2); anchor.setRow2(row2);
anchor.setDy2(dy2); anchor.setDy2(dy2);
Dimension dim = new Dimension( return new Dimension(
(int)Math.round(scaledWidth*EMU_PER_PIXEL), (int)Math.round(scaledWidth*EMU_PER_PIXEL),
(int)Math.round(scaledHeight*EMU_PER_PIXEL) (int)Math.round(scaledHeight*EMU_PER_PIXEL)
); );
return dim;
} }
/** /**

View File

@ -209,8 +209,7 @@ public final class PackagingURIHelper {
public static URI getPath(URI uri) { public static URI getPath(URI uri) {
if (uri != null) { if (uri != null) {
String path = uri.getPath(); String path = uri.getPath();
int len = path.length(); int num2 = path.length();
int num2 = len;
while (--num2 >= 0) { while (--num2 >= 0) {
char ch1 = path.charAt(num2); char ch1 = path.charAt(num2);
if (ch1 == PackagingURIHelper.FORWARD_SLASH_CHAR) { if (ch1 == PackagingURIHelper.FORWARD_SLASH_CHAR) {

View File

@ -41,8 +41,7 @@ public final class FileHelper {
public static File getDirectory(File f) { public static File getDirectory(File f) {
if (f != null) { if (f != null) {
String path = f.getPath(); String path = f.getPath();
int len = path.length(); int num2 = path.length();
int num2 = len;
while (--num2 >= 0) { while (--num2 >= 0) {
char ch1 = path.charAt(num2); char ch1 = path.charAt(num2);
if (ch1 == File.separatorChar) { if (ch1 == File.separatorChar) {

View File

@ -220,8 +220,7 @@ public class AgileEncryptor extends Encryptor implements Cloneable {
public OutputStream getDataStream(DirectoryNode dir) public OutputStream getDataStream(DirectoryNode dir)
throws IOException, GeneralSecurityException { throws IOException, GeneralSecurityException {
// TODO: initialize headers // TODO: initialize headers
AgileCipherOutputStream countStream = new AgileCipherOutputStream(dir); return new AgileCipherOutputStream(dir);
return countStream;
} }
/** /**

View File

@ -357,8 +357,7 @@ public class SignatureInfo implements SignatureConfigurable {
digestInfoValueBuf.write(signatureConfig.getHashMagic()); digestInfoValueBuf.write(signatureConfig.getHashMagic());
digestInfoValueBuf.write(digest); digestInfoValueBuf.write(digest);
byte[] digestInfoValue = digestInfoValueBuf.toByteArray(); byte[] digestInfoValue = digestInfoValueBuf.toByteArray();
byte[] signatureValue = cipher.doFinal(digestInfoValue); return cipher.doFinal(digestInfoValue);
return signatureValue;
} catch (Exception e) { } catch (Exception e) {
throw new EncryptedDocumentException(e); throw new EncryptedDocumentException(e);
} }

View File

@ -78,8 +78,7 @@ import org.openxmlformats.schemas.presentationml.x2006.main.NotesMasterDocument;
try { try {
try { try {
NotesMasterDocument doc = NotesMasterDocument.Factory.parse(is, DEFAULT_XML_OPTIONS); NotesMasterDocument doc = NotesMasterDocument.Factory.parse(is, DEFAULT_XML_OPTIONS);
CTNotesMaster slide = doc.getNotesMaster(); return doc.getNotesMaster();
return slide;
} finally { } finally {
is.close(); is.close();
} }

View File

@ -90,8 +90,7 @@ public class XSLFShadow extends XSLFShape implements Shadow<XSLFShape,XSLFTextPa
public Color getFillColor() { public Color getFillColor() {
SolidPaint ps = getFillStyle(); SolidPaint ps = getFillStyle();
if (ps == null) return null; if (ps == null) return null;
Color col = DrawPaint.applyColorTransform(ps.getSolidColor()); return DrawPaint.applyColorTransform(ps.getSolidColor());
return col;
} }
@Override @Override

View File

@ -485,8 +485,7 @@ public abstract class XSLFTextShape extends XSLFSimpleShape
@Override @Override
public Insets2D getInsets() { public Insets2D getInsets() {
Insets2D insets = new Insets2D(getTopInset(), getLeftInset(), getBottomInset(), getRightInset()); return new Insets2D(getTopInset(), getLeftInset(), getBottomInset(), getRightInset());
return insets;
} }
@Override @Override

View File

@ -223,8 +223,7 @@ public class XSSFComment implements Comment {
for (String s : position.split(",")) { for (String s : position.split(",")) {
pos[i++] = Integer.parseInt(s.trim()); pos[i++] = Integer.parseInt(s.trim());
} }
XSSFClientAnchor ca = new XSSFClientAnchor(pos[1]*EMU_PER_PIXEL, pos[3]*EMU_PER_PIXEL, pos[5]*EMU_PER_PIXEL, pos[7]*EMU_PER_PIXEL, pos[0], pos[2], pos[4], pos[6]); return new XSSFClientAnchor(pos[1]*EMU_PER_PIXEL, pos[3]*EMU_PER_PIXEL, pos[5]*EMU_PER_PIXEL, pos[7]*EMU_PER_PIXEL, pos[0], pos[2], pos[4], pos[6]);
return ca;
} }
/** /**

View File

@ -122,8 +122,7 @@ public class XSSFFont implements Font {
*/ */
public int getCharSet() { public int getCharSet() {
CTIntProperty charset = _ctFont.sizeOfCharsetArray() == 0 ? null : _ctFont.getCharsetArray(0); CTIntProperty charset = _ctFont.sizeOfCharsetArray() == 0 ? null : _ctFont.getCharsetArray(0);
int val = charset == null ? FontCharset.ANSI.getValue() : FontCharset.valueOf(charset.getVal()).getValue(); return charset == null ? FontCharset.ANSI.getValue() : FontCharset.valueOf(charset.getVal()).getValue();
return val;
} }
@ -214,8 +213,7 @@ public class XSSFFont implements Font {
private double getFontHeightRaw() { private double getFontHeightRaw() {
CTFontSize size = _ctFont.sizeOfSzArray() == 0 ? null : _ctFont.getSzArray(0); CTFontSize size = _ctFont.sizeOfSzArray() == 0 ? null : _ctFont.getSzArray(0);
if (size != null) { if (size != null) {
double fontHeight = size.getVal(); return size.getVal();
return fontHeight;
} }
return DEFAULT_FONT_SIZE; return DEFAULT_FONT_SIZE;
} }

View File

@ -225,8 +225,7 @@ public class XSSFPivotTable extends POIXMLDocumentPart {
protected AreaReference getPivotArea() { protected AreaReference getPivotArea() {
final Workbook wb = getDataSheet().getWorkbook(); final Workbook wb = getDataSheet().getWorkbook();
AreaReference pivotArea = getPivotCacheDefinition().getPivotArea(wb); return getPivotCacheDefinition().getPivotArea(wb);
return pivotArea;
} }
/** /**

View File

@ -612,8 +612,7 @@ public class XSSFTextParagraph implements Iterable<XSSFTextRun>{
}; };
fetchParagraphProperty(fetcher); fetchParagraphProperty(fetcher);
double spcBef = fetcher.getValue() == null ? 0 : fetcher.getValue(); return fetcher.getValue() == null ? 0 : fetcher.getValue();
return spcBef;
} }
/** /**

View File

@ -74,8 +74,7 @@ public class XSSFSingleXmlCell {
public String getXpath(){ public String getXpath(){
CTXmlCellPr xmlCellPr = singleXmlCell.getXmlCellPr(); CTXmlCellPr xmlCellPr = singleXmlCell.getXmlCellPr();
CTXmlPr xmlPr = xmlCellPr.getXmlPr(); CTXmlPr xmlPr = xmlCellPr.getXmlPr();
String xpath = xmlPr.getXpath(); return xmlPr.getXpath();
return xpath;
} }
public long getMapId(){ public long getMapId(){

View File

@ -1431,8 +1431,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
public XWPFPictureData getPictureDataByID(String blipID) { public XWPFPictureData getPictureDataByID(String blipID) {
POIXMLDocumentPart relatedPart = getRelationById(blipID); POIXMLDocumentPart relatedPart = getRelationById(blipID);
if (relatedPart instanceof XWPFPictureData) { if (relatedPart instanceof XWPFPictureData) {
XWPFPictureData xwpfPicData = (XWPFPictureData) relatedPart; return (XWPFPictureData) relatedPart;
return xwpfPicData;
} }
return null; return null;
} }

View File

@ -1378,9 +1378,8 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para
* a new instance. * a new instance.
*/ */
private CTPPr getCTPPr() { private CTPPr getCTPPr() {
CTPPr pr = paragraph.getPPr() == null ? paragraph.addNewPPr() return paragraph.getPPr() == null ? paragraph.addNewPPr()
: paragraph.getPPr(); : paragraph.getPPr();
return pr;
} }

View File

@ -106,8 +106,7 @@ public class PkiTestUtils {
SecureRandom random = new SecureRandom(); SecureRandom random = new SecureRandom();
keyPairGenerator.initialize(new RSAKeyGenParameterSpec(1024, keyPairGenerator.initialize(new RSAKeyGenParameterSpec(1024,
RSAKeyGenParameterSpec.F4), random); RSAKeyGenParameterSpec.F4), random);
KeyPair keyPair = keyPairGenerator.generateKeyPair(); return keyPairGenerator.generateKeyPair();
return keyPair;
} }
static X509Certificate generateCertificate(PublicKey subjectPublicKey, static X509Certificate generateCertificate(PublicKey subjectPublicKey,
@ -218,8 +217,7 @@ public class PkiTestUtils {
documentBuilderFactory.setNamespaceAware(true); documentBuilderFactory.setNamespaceAware(true);
DocumentBuilder documentBuilder = documentBuilderFactory DocumentBuilder documentBuilder = documentBuilderFactory
.newDocumentBuilder(); .newDocumentBuilder();
Document document = documentBuilder.parse(inputSource); return documentBuilder.parse(inputSource);
return document;
} }
static String toString(Node dom) throws TransformerException { static String toString(Node dom) throws TransformerException {
@ -310,8 +308,7 @@ public class PkiTestUtils {
OCSPRespBuilder ocspRespBuilder = new OCSPRespBuilder(); OCSPRespBuilder ocspRespBuilder = new OCSPRespBuilder();
OCSPResp ocspResp = ocspRespBuilder.build(OCSPRespBuilder.SUCCESSFUL, basicOCSPResp);
return ocspResp; return ocspRespBuilder.build(OCSPRespBuilder.SUCCESSFUL, basicOCSPResp);
} }
} }

View File

@ -341,8 +341,7 @@ public class TestXSSFDataValidation extends BaseTestDataValidation {
DataValidationHelper dataValidationHelper = sheet.getDataValidationHelper(); DataValidationHelper dataValidationHelper = sheet.getDataValidationHelper();
DataValidationConstraint constraint = dataValidationHelper.createCustomConstraint("true"); DataValidationConstraint constraint = dataValidationHelper.createCustomConstraint("true");
final XSSFDataValidation validation = (XSSFDataValidation) dataValidationHelper.createValidation(constraint, new CellRangeAddressList(0, 0, 0, 0)); return (XSSFDataValidation) dataValidationHelper.createValidation(constraint, new CellRangeAddressList(0, 0, 0, 0));
return validation;
} }
@Test @Test

View File

@ -722,8 +722,7 @@ public final class TestXSSFSheet extends BaseTestXSheet {
// Now check the low level stuff, and check that's all // Now check the low level stuff, and check that's all
// been set correctly // been set correctly
XSSFSheet xs = sheet; CTWorksheet cts = sheet.getCTWorksheet();
CTWorksheet cts = xs.getCTWorksheet();
assertEquals(1, cts.sizeOfColsArray()); assertEquals(1, cts.sizeOfColsArray());
CTCols cols = cts.getColsArray(0); CTCols cols = cts.getColsArray(0);

View File

@ -166,8 +166,6 @@ public final class SlideIdListing {
long type = LittleEndian.getUShort(fileContents, pos+2); long type = LittleEndian.getUShort(fileContents, pos+2);
long rlen = LittleEndian.getUInt(fileContents, pos+4); long rlen = LittleEndian.getUInt(fileContents, pos+4);
Record r = Record.createRecordForType(type,fileContents,pos,(int)rlen+8); return Record.createRecordForType(type,fileContents,pos,(int)rlen+8);
return r;
} }
} }

View File

@ -124,8 +124,6 @@ public final class UserEditAndPersistListing {
long type = LittleEndian.getUShort(fileContents, pos+2); long type = LittleEndian.getUShort(fileContents, pos+2);
long rlen = LittleEndian.getUInt(fileContents, pos+4); long rlen = LittleEndian.getUInt(fileContents, pos+4);
Record r = Record.createRecordForType(type,fileContents,pos,(int)rlen+8); return Record.createRecordForType(type,fileContents,pos,(int)rlen+8);
return r;
} }
} }

View File

@ -144,8 +144,7 @@ public final class QuickButCruddyTextExtractor {
// Start walking the file, looking for the records // Start walking the file, looking for the records
while(walkPos != -1) { while(walkPos != -1) {
int newPos = findTextRecords(walkPos,textV); walkPos = findTextRecords(walkPos,textV);
walkPos = newPos;
} }
// Return what we find // Return what we find

View File

@ -182,8 +182,7 @@ public final class ColorSchemeAtom extends RecordAtom {
byte[] with_zero = new byte[4]; byte[] with_zero = new byte[4];
System.arraycopy(rgb,0,with_zero,0,3); System.arraycopy(rgb,0,with_zero,0,3);
with_zero[3] = 0; with_zero[3] = 0;
int ret = LittleEndian.getInt(with_zero,0); return LittleEndian.getInt(with_zero,0);
return ret;
} }

View File

@ -137,8 +137,7 @@ public abstract class Record
} }
// Turn the vector into an array, and return // Turn the vector into an array, and return
Record[] cRecords = children.toArray( new Record[children.size()] ); return children.toArray( new Record[children.size()] );
return cRecords;
} }
/** /**

View File

@ -192,8 +192,7 @@ public final class TextRulerAtom extends RecordAtom {
0x00, 0x00, (byte)0xA6, 0x0F, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, (byte)0xA6, 0x0F, 0x0A, 0x00, 0x00, 0x00,
0x10, 0x03, 0x00, 0x00, (byte)0xF9, 0x00, 0x41, 0x01, 0x41, 0x01 0x10, 0x03, 0x00, 0x00, (byte)0xF9, 0x00, 0x41, 0x01, 0x41, 0x01
}; };
TextRulerAtom ruler = new TextRulerAtom(data, 0, data.length); return new TextRulerAtom(data, 0, data.length);
return ruler;
} }
public void setParagraphIndent(short tetxOffset, short bulletOffset){ public void setParagraphIndent(short tetxOffset, short bulletOffset){

View File

@ -221,14 +221,13 @@ implements HSLFShapeContainer, GroupShape<HSLFShape,HSLFTextParagraph> {
x2 = clientAnchor.getDx1(); x2 = clientAnchor.getDx1();
y2 = clientAnchor.getRow1(); y2 = clientAnchor.getRow1();
} }
Rectangle2D anchor= new Rectangle2D.Double(
return new Rectangle2D.Double(
(x1 == -1 ? -1 : Units.masterToPoints(x1)), (x1 == -1 ? -1 : Units.masterToPoints(x1)),
(y1 == -1 ? -1 : Units.masterToPoints(y1)), (y1 == -1 ? -1 : Units.masterToPoints(y1)),
(x2 == -1 ? -1 : Units.masterToPoints(x2-x1)), (x2 == -1 ? -1 : Units.masterToPoints(x2-x1)),
(y2 == -1 ? -1 : Units.masterToPoints(y2-y1)) (y2 == -1 ? -1 : Units.masterToPoints(y2-y1))
); );
return anchor;
} }
/** /**

View File

@ -168,14 +168,13 @@ public abstract class HSLFShape implements Shape<HSLFShape,HSLFTextParagraph> {
} }
// TODO: find out where this -1 value comes from at #57820 (link to ms docs?) // TODO: find out where this -1 value comes from at #57820 (link to ms docs?)
Rectangle2D anchor = new Rectangle2D.Double(
return new Rectangle2D.Double(
(x1 == -1 ? -1 : Units.masterToPoints(x1)), (x1 == -1 ? -1 : Units.masterToPoints(x1)),
(y1 == -1 ? -1 : Units.masterToPoints(y1)), (y1 == -1 ? -1 : Units.masterToPoints(y1)),
(x2 == -1 ? -1 : Units.masterToPoints(x2-x1)), (x2 == -1 ? -1 : Units.masterToPoints(x2-x1)),
(y2 == -1 ? -1 : Units.masterToPoints(y2-y1)) (y2 == -1 ? -1 : Units.masterToPoints(y2-y1))
); );
return anchor;
} }
/** /**

View File

@ -131,8 +131,7 @@ public abstract class HSLFSimpleShape extends HSLFShape implements SimpleShape<H
public double getLineWidth(){ public double getLineWidth(){
AbstractEscherOptRecord opt = getEscherOptRecord(); AbstractEscherOptRecord opt = getEscherOptRecord();
EscherSimpleProperty prop = getEscherProperty(opt, EscherProperties.LINESTYLE__LINEWIDTH); EscherSimpleProperty prop = getEscherProperty(opt, EscherProperties.LINESTYLE__LINEWIDTH);
double width = (prop == null) ? DEFAULT_LINE_WIDTH : Units.toPoints(prop.getPropertyValue()); return (prop == null) ? DEFAULT_LINE_WIDTH : Units.toPoints(prop.getPropertyValue());
return width;
} }
/** /**

View File

@ -402,8 +402,7 @@ implements HSLFShapeContainer, TableShape<HSLFShape,HSLFTextParagraph> {
} }
// TODO: check for merged cols // TODO: check for merged cols
double width = cells[0][col].getAnchor().getWidth(); return cells[0][col].getAnchor().getWidth();
return width;
} }
@Override @Override

View File

@ -1212,8 +1212,7 @@ public final class HSLFTextParagraph implements TextParagraph<HSLFShape,HSLFText
* representation * representation
*/ */
protected static String toInternalString(String s) { protected static String toInternalString(String s) {
String ns = s.replaceAll("\\r?\\n", "\r"); return s.replaceAll("\\r?\\n", "\r");
return ns;
} }
/** /**

View File

@ -415,8 +415,7 @@ public final class HSLFTextRun implements TextRun {
return null; return null;
} }
Color color = HSLFTextParagraph.getColorFromColorIndexStruct(tp.getValue(), parentParagraph.getSheet()); Color color = HSLFTextParagraph.getColorFromColorIndexStruct(tp.getValue(), parentParagraph.getSheet());
SolidPaint ps = DrawPaint.createSolidPaint(color); return DrawPaint.createSolidPaint(color);
return ps;
} }
/** /**

View File

@ -723,8 +723,7 @@ implements TextShape<HSLFShape,HSLFTextParagraph> {
@Override @Override
public Insets2D getInsets() { public Insets2D getInsets() {
Insets2D insets = new Insets2D(getTopInset(), getLeftInset(), getBottomInset(), getRightInset()); return new Insets2D(getTopInset(), getLeftInset(), getBottomInset(), getRightInset());
return insets;
} }
@Override @Override

View File

@ -185,11 +185,10 @@ public class AbstractExcelUtils
{ {
CellRangeAddress[] mergedRangeRowInfo = rowNumber < mergedRanges.length ? mergedRanges[rowNumber] CellRangeAddress[] mergedRangeRowInfo = rowNumber < mergedRanges.length ? mergedRanges[rowNumber]
: null; : null;
CellRangeAddress cellRangeAddress = mergedRangeRowInfo != null
return mergedRangeRowInfo != null
&& columnNumber < mergedRangeRowInfo.length ? mergedRangeRowInfo[columnNumber] && columnNumber < mergedRangeRowInfo.length ? mergedRangeRowInfo[columnNumber]
: null; : null;
return cellRangeAddress;
} }
static boolean isEmpty( String str ) static boolean isEmpty( String str )

View File

@ -154,8 +154,7 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter
XMLHelper.getDocumentBuilderFactory().newDocumentBuilder() XMLHelper.getDocumentBuilderFactory().newDocumentBuilder()
.newDocument() ); .newDocument() );
excelToHtmlConverter.processWorkbook( workbook ); excelToHtmlConverter.processWorkbook( workbook );
Document doc = excelToHtmlConverter.getDocument(); return excelToHtmlConverter.getDocument();
return doc;
} }
private String cssClassContainerCell; private String cssClassContainerCell;

View File

@ -597,8 +597,7 @@ public final class HSSFChart {
private PlotAreaRecord createPlotAreaRecord() private PlotAreaRecord createPlotAreaRecord()
{ {
PlotAreaRecord r = new PlotAreaRecord( ); return new PlotAreaRecord( );
return r;
} }
private AxisLineFormatRecord createAxisLineFormatRecord( short format ) private AxisLineFormatRecord createAxisLineFormatRecord( short format )

View File

@ -667,7 +667,6 @@ public final class HWPFDocument extends HWPFDocumentCore {
// get fcMin and fcMac because we will be writing the actual text with the // get fcMin and fcMac because we will be writing the actual text with the
// complex table. // complex table.
int fcMin = mainOffset;
/* /*
* clx (encoding of the sprm lists for a complex file and piece table * clx (encoding of the sprm lists for a complex file and piece table
@ -736,7 +735,7 @@ public final class HWPFDocument extends HWPFDocumentCore {
// write out the CHPBinTable. // write out the CHPBinTable.
_fib.setFcPlcfbteChpx(tableOffset); _fib.setFcPlcfbteChpx(tableOffset);
_cbt.writeTo(wordDocumentStream, tableStream, fcMin, _cft.getTextPieceTable()); _cbt.writeTo(wordDocumentStream, tableStream, mainOffset, _cft.getTextPieceTable());
_fib.setLcbPlcfbteChpx(tableStream.size() - tableOffset); _fib.setLcbPlcfbteChpx(tableStream.size() - tableOffset);
tableOffset = tableStream.size(); tableOffset = tableStream.size();
@ -892,7 +891,7 @@ public final class HWPFDocument extends HWPFDocumentCore {
tableOffset = tableStream.size(); tableOffset = tableStream.size();
// set some variables in the FileInformationBlock. // set some variables in the FileInformationBlock.
_fib.getFibBase().setFcMin(fcMin); _fib.getFibBase().setFcMin(mainOffset);
_fib.getFibBase().setFcMac(fcMac); _fib.getFibBase().setFcMac(fcMac);
_fib.setCbMac(wordDocumentStream.size()); _fib.setCbMac(wordDocumentStream.size());

View File

@ -194,8 +194,7 @@ public abstract class AbstractWordConverter
original.bold = characterRun.isBold(); original.bold = characterRun.isBold();
original.italic = characterRun.isItalic(); original.italic = characterRun.isItalic();
original.fontName = characterRun.getFontName(); original.fontName = characterRun.getFontName();
Triplet updated = getFontReplacer().update( original ); return getFontReplacer().update( original );
return updated;
} }
public abstract Document getDocument(); public abstract Document getDocument();

View File

@ -111,8 +111,7 @@ public class HtmlDocumentFacade
stringBuilder.append( "}\n" ); stringBuilder.append( "}\n" );
} }
} }
final String stylesheetText = stringBuilder.toString(); return stringBuilder.toString();
return stylesheetText;
} }
public Element createBlock() public Element createBlock()
@ -179,8 +178,7 @@ public class HtmlDocumentFacade
public Element createSelect() public Element createSelect()
{ {
Element result = document.createElement( "select" ); return document.createElement( "select" );
return result;
} }
public Element createTable() public Element createTable()

View File

@ -118,8 +118,7 @@ public class RecordUtil
for ( int x = 0; x < parentSize; x++ ) for ( int x = 0; x < parentSize; x++ )
{ {
int temp = mask; numBits += ( mask >> x ) & 0x1;
numBits += ( temp >> x ) & 0x1;
} }
if ( numBits == 1 ) if ( numBits == 1 )

View File

@ -226,8 +226,7 @@ public class CHPBinTable
final int boundary = objBoundary.intValue(); final int boundary = objBoundary.intValue();
final int startInclusive = lastTextRunStart; final int startInclusive = lastTextRunStart;
final int endExclusive = boundary; lastTextRunStart = boundary;
lastTextRunStart = endExclusive;
int startPosition = binarySearch( oldChpxSortedByStartPos, boundary ); int startPosition = binarySearch( oldChpxSortedByStartPos, boundary );
startPosition = Math.abs( startPosition ); startPosition = Math.abs( startPosition );
@ -246,7 +245,7 @@ public class CHPBinTable
break; break;
int left = Math.max( startInclusive, chpx.getStart() ); int left = Math.max( startInclusive, chpx.getStart() );
int right = Math.min( endExclusive, chpx.getEnd() ); int right = Math.min(boundary, chpx.getEnd() );
if ( left < right ) if ( left < right )
{ {
@ -258,10 +257,10 @@ public class CHPBinTable
{ {
logger.log( POILogger.WARN, "Text piece [", logger.log( POILogger.WARN, "Text piece [",
Integer.valueOf( startInclusive ), "; ", Integer.valueOf( startInclusive ), "; ",
Integer.valueOf( endExclusive ), Integer.valueOf(boundary),
") has no CHPX. Creating new one." ); ") has no CHPX. Creating new one." );
// create it manually // create it manually
CHPX chpx = new CHPX( startInclusive, endExclusive, CHPX chpx = new CHPX( startInclusive, boundary,
new SprmBuffer( 0 ) ); new SprmBuffer( 0 ) );
newChpxs.add( chpx ); newChpxs.add( chpx );
continue; continue;
@ -272,7 +271,7 @@ public class CHPBinTable
// can we reuse existing? // can we reuse existing?
CHPX existing = chpxs.get( 0 ); CHPX existing = chpxs.get( 0 );
if ( existing.getStart() == startInclusive if ( existing.getStart() == startInclusive
&& existing.getEnd() == endExclusive ) && existing.getEnd() == boundary)
{ {
newChpxs.add( existing ); newChpxs.add( existing );
continue; continue;
@ -286,7 +285,7 @@ public class CHPBinTable
{ {
sprmBuffer.append( chpx.getGrpprl(), 0 ); sprmBuffer.append( chpx.getGrpprl(), 0 );
} }
CHPX newChpx = new CHPX( startInclusive, endExclusive, sprmBuffer ); CHPX newChpx = new CHPX( startInclusive, boundary, sprmBuffer );
newChpxs.add( newChpx ); newChpxs.add( newChpx );
continue; continue;

View File

@ -72,9 +72,8 @@ public final class CHPX extends BytePropertyNode<CHPX>
} }
CharacterProperties baseStyle = ss.getCharacterStyle( istd ); CharacterProperties baseStyle = ss.getCharacterStyle( istd );
CharacterProperties props = CharacterSprmUncompressor.uncompressCHP( return CharacterSprmUncompressor.uncompressCHP(
ss, baseStyle, getGrpprl(), 0 ); ss, baseStyle, getGrpprl(), 0 );
return props;
} }
public String toString() { public String toString() {

View File

@ -151,8 +151,7 @@ public final class ListTables
return null; return null;
} }
if(level < lst.numLevels()) { if(level < lst.numLevels()) {
ListLevel lvl = lst.getLevels()[level]; return lst.getLevels()[level];
return lvl;
} }
if (log.check(POILogger.WARN)) { if (log.check(POILogger.WARN)) {
log.log(POILogger.WARN, "Requested level " + level + " which was greater than the maximum defined (" + lst.numLevels() + ")"); log.log(POILogger.WARN, "Requested level " + level + " which was greater than the maximum defined (" + lst.numLevels() + ")");

View File

@ -361,8 +361,6 @@ public final class PAPFormattedDiskPage extends FormattedDiskPage {
{ {
int pheOffset = _offset + 1 + (((_crun + 1) * 4) + (index * 13)); int pheOffset = _offset + 1 + (((_crun + 1) * 4) + (index * 13));
ParagraphHeight phe = new ParagraphHeight(_fkp, pheOffset); return new ParagraphHeight(_fkp, pheOffset);
return phe;
} }
} }

View File

@ -151,8 +151,7 @@ public final class PAPX extends BytePropertyNode<PAPX> {
short istd = getIstd(); short istd = getIstd();
ParagraphProperties baseStyle = ss.getParagraphStyle(istd); ParagraphProperties baseStyle = ss.getParagraphStyle(istd);
ParagraphProperties props = ParagraphSprmUncompressor.uncompressPAP(baseStyle, getGrpprl(), 2); return ParagraphSprmUncompressor.uncompressPAP(baseStyle, getGrpprl(), 2);
return props;
} }
@Override @Override

View File

@ -64,8 +64,7 @@ public class PlexOfField
} }
public String toString() { public String toString() {
String str = String.format(Locale.ROOT, "[%d, %d) - FLD - 0x%x; 0x%x" return String.format(Locale.ROOT, "[%d, %d) - FLD - 0x%x; 0x%x"
, getFcStart(), getFcEnd(), fld.getBoundaryType(), fld.getFlt()); , getFcStart(), getFcEnd(), fld.getBoundaryType(), fld.getFlt());
return str;
} }
} }

View File

@ -89,14 +89,13 @@ public class SectionTable
// Some files seem to lie about their unicode status, which // Some files seem to lie about their unicode status, which
// is very very pesky. Try to work around these, but this // is very very pesky. Try to work around these, but this
// is getting on for black magic... // is getting on for black magic...
int mainEndsAt = mainLength;
boolean matchAt = false; boolean matchAt = false;
boolean matchHalf = false; boolean matchHalf = false;
for (int i=0; i<_sections.size(); i++) { for (int i=0; i<_sections.size(); i++) {
SEPX s = _sections.get(i); SEPX s = _sections.get(i);
if (s.getEnd() == mainEndsAt) { if (s.getEnd() == mainLength) {
matchAt = true; matchAt = true;
} else if(s.getEnd() == mainEndsAt || s.getEnd() == mainEndsAt-1) { } else if(s.getEnd() == mainLength || s.getEnd() == mainLength -1) {
matchHalf = true; matchHalf = true;
} }
} }

View File

@ -107,11 +107,10 @@ public final class StyleDescription implements HDFType
_name = StringUtil.getFromUnicodeLE(std, nameStart, (nameLength*multiplier)/2); _name = StringUtil.getFromUnicodeLE(std, nameStart, (nameLength*multiplier)/2);
//length then null terminator. //length then null terminator.
int grupxStart = ((nameLength + 1) * multiplier) + nameStart;
// the spec only refers to two possible upxs but it mentions // the spec only refers to two possible upxs but it mentions
// that more may be added in the future // that more may be added in the future
int varOffset = grupxStart; int varOffset = ((nameLength + 1) * multiplier) + nameStart;
int countOfUPX = _stdfBase.getCupx(); int countOfUPX = _stdfBase.getCupx();
_upxs = new UPX[countOfUPX]; _upxs = new UPX[countOfUPX];
for(int x = 0; x < countOfUPX; x++) for(int x = 0; x < countOfUPX; x++)

View File

@ -73,12 +73,11 @@ public class TextPiece extends PropertyNode<TextPiece> {
* Create the StringBuilder from the text and unicode flag * Create the StringBuilder from the text and unicode flag
*/ */
private static StringBuilder buildInitSB(byte[] text, PieceDescriptor pd) { private static StringBuilder buildInitSB(byte[] text, PieceDescriptor pd) {
byte[] textBuffer = text;
if (StringUtil.BIG5.equals(pd.getCharset())) { if (StringUtil.BIG5.equals(pd.getCharset())) {
return new StringBuilder(CodePageUtil.cp950ToString(text, 0, text.length)); return new StringBuilder(CodePageUtil.cp950ToString(text, 0, text.length));
} }
String str = new String(textBuffer, 0, textBuffer.length, (pd.isUnicode()) ? StringUtil.UTF16LE : pd.getCharset()); String str = new String(text, 0, text.length, (pd.isUnicode()) ? StringUtil.UTF16LE : pd.getCharset());
return new StringBuilder(str); return new StringBuilder(str);
} }

View File

@ -657,8 +657,7 @@ public final class CharacterRun extends Range
getPicOffset() ); getPicOffset() );
FFData ffData = new FFData( data.getBinData(), 0 ); FFData ffData = new FFData( data.getBinData(), 0 );
String[] values = ffData.getDropList(); return ffData.getDropList();
return values;
} }
} }
return null; return null;

View File

@ -54,7 +54,7 @@ public final class DateAndTime
public Calendar getDate() { public Calendar getDate() {
// TODO Discover if the timezone is stored somewhere else or not // TODO Discover if the timezone is stored somewhere else or not
Calendar cal = LocaleUtil.getLocaleCalendar( return LocaleUtil.getLocaleCalendar(
_years.getValue(_info2)+1900, _years.getValue(_info2)+1900,
_months.getValue(_info2)-1, _months.getValue(_info2)-1,
_dom.getValue(_info), _dom.getValue(_info),
@ -62,7 +62,6 @@ public final class DateAndTime
_minutes.getValue(_info), _minutes.getValue(_info),
0 0
); );
return cal;
} }
public void serialize(byte[] buf, int offset) public void serialize(byte[] buf, int offset)

Some files were not shown because too many files have changed in this diff Show More