FindBugs - DLS_DEAD_LOCAL_STORE

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1696038 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andreas Beeker 2015-08-15 11:57:57 +00:00
parent 2df37edbae
commit 05c92b7a19
34 changed files with 139 additions and 1551 deletions

View File

@ -135,7 +135,6 @@ public class EscherComplexProperty extends EscherProperty {
} }
public String toXml(String tab){ public String toXml(String tab){
String dataStr = HexDump.toHex( _complexData, 32);
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append(tab).append("<").append(getClass().getSimpleName()).append(" id=\"0x").append(HexDump.toHex(getId())) builder.append(tab).append("<").append(getClass().getSimpleName()).append(" id=\"0x").append(HexDump.toHex(getId()))
.append("\" name=\"").append(getName()).append("\" blipId=\"") .append("\" name=\"").append(getName()).append("\" blipId=\"")

View File

@ -73,14 +73,12 @@ public final class EscherDump {
short options; // 4 bits for the version and 12 bits for the instance short options; // 4 bits for the version and 12 bits for the instance
short recordId; short recordId;
int recordBytesRemaining; // including enclosing records int recordBytesRemaining; // including enclosing records
StringBuffer stringBuf = new StringBuffer();
short nDumpSize; short nDumpSize;
String recordName; String recordName;
boolean atEOF = false; boolean atEOF = false;
while (!atEOF && (remainingBytes > 0)) { while (!atEOF && (remainingBytes > 0)) {
stringBuf = new StringBuffer();
options = LittleEndian.readShort( in ); options = LittleEndian.readShort( in );
recordId = LittleEndian.readShort( in ); recordId = LittleEndian.readShort( in );
recordBytesRemaining = LittleEndian.readInt( in ); recordBytesRemaining = LittleEndian.readInt( in );
@ -194,6 +192,7 @@ public final class EscherDump {
recordName = "UNKNOWN ID"; recordName = "UNKNOWN ID";
} }
StringBuilder stringBuf = new StringBuilder();
stringBuf.append( " " ); stringBuf.append( " " );
stringBuf.append( HexDump.toHex( recordId ) ); stringBuf.append( HexDump.toHex( recordId ) );
stringBuf.append( " " ).append( recordName ).append( " [" ); stringBuf.append( " " ).append( recordName ).append( " [" );
@ -203,6 +202,7 @@ public final class EscherDump {
stringBuf.append( "] instance: " ); stringBuf.append( "] instance: " );
stringBuf.append( HexDump.toHex( ( (short) ( options >> 4 ) ) ) ); stringBuf.append( HexDump.toHex( ( (short) ( options >> 4 ) ) ) );
out.println( stringBuf.toString() ); out.println( stringBuf.toString() );
stringBuf.setLength(0);
if ( recordId == (short) 0xF007 && 36 <= remainingBytes && 36 <= recordBytesRemaining ) if ( recordId == (short) 0xF007 && 36 <= remainingBytes && 36 <= recordBytesRemaining )
@ -213,7 +213,7 @@ public final class EscherDump {
// short n16; // short n16;
// int n32; // int n32;
stringBuf = new StringBuffer( " btWin32: " ); stringBuf = stringBuf.append( " btWin32: " );
n8 = (byte) in.read(); n8 = (byte) in.read();
stringBuf.append( HexDump.toHex( n8 ) ); stringBuf.append( HexDump.toHex( n8 ) );
stringBuf.append( getBlipType( n8 ) ); stringBuf.append( getBlipType( n8 ) );

View File

@ -55,7 +55,6 @@ public class LineShape
EscherContainerRecord spContainer = new EscherContainerRecord(); EscherContainerRecord spContainer = new EscherContainerRecord();
EscherSpRecord sp = new EscherSpRecord(); EscherSpRecord sp = new EscherSpRecord();
EscherOptRecord opt = new EscherOptRecord(); EscherOptRecord opt = new EscherOptRecord();
EscherRecord anchor = new EscherClientAnchorRecord();
EscherClientDataRecord clientData = new EscherClientDataRecord(); EscherClientDataRecord clientData = new EscherClientDataRecord();
spContainer.setRecordId( EscherContainerRecord.SP_CONTAINER ); spContainer.setRecordId( EscherContainerRecord.SP_CONTAINER );
@ -74,7 +73,7 @@ public class LineShape
sp.setFlags(sp.getFlags() | EscherSpRecord.FLAG_FLIPHORIZ); sp.setFlags(sp.getFlags() | EscherSpRecord.FLAG_FLIPHORIZ);
if (userAnchor.isVerticallyFlipped()) if (userAnchor.isVerticallyFlipped())
sp.setFlags(sp.getFlags() | EscherSpRecord.FLAG_FLIPVERT); sp.setFlags(sp.getFlags() | EscherSpRecord.FLAG_FLIPVERT);
anchor = createAnchor(userAnchor); EscherRecord anchor = createAnchor(userAnchor);
clientData.setRecordId( EscherClientDataRecord.RECORD_ID ); clientData.setRecordId( EscherClientDataRecord.RECORD_ID );
clientData.setOptions( (short) 0x0000 ); clientData.setOptions( (short) 0x0000 );

View File

@ -130,8 +130,6 @@ public class PolygonShape
*/ */
private ObjRecord createObjRecord( HSSFShape hssfShape, int shapeId ) private ObjRecord createObjRecord( HSSFShape hssfShape, int shapeId )
{ {
HSSFShape shape = hssfShape;
ObjRecord obj = new ObjRecord(); ObjRecord obj = new ObjRecord();
CommonObjectDataSubRecord c = new CommonObjectDataSubRecord(); CommonObjectDataSubRecord c = new CommonObjectDataSubRecord();
c.setObjectType( OBJECT_TYPE_MICROSOFT_OFFICE_DRAWING ); c.setObjectType( OBJECT_TYPE_MICROSOFT_OFFICE_DRAWING );

View File

@ -84,7 +84,6 @@ public class TextboxShape
EscherContainerRecord spContainer = new EscherContainerRecord(); EscherContainerRecord spContainer = new EscherContainerRecord();
EscherSpRecord sp = new EscherSpRecord(); EscherSpRecord sp = new EscherSpRecord();
EscherOptRecord opt = new EscherOptRecord(); EscherOptRecord opt = new EscherOptRecord();
EscherRecord anchor = new EscherClientAnchorRecord();
EscherClientDataRecord clientData = new EscherClientDataRecord(); EscherClientDataRecord clientData = new EscherClientDataRecord();
escherTextbox = new EscherTextboxRecord(); escherTextbox = new EscherTextboxRecord();
@ -113,7 +112,7 @@ public class TextboxShape
// sp.setFlags(sp.getFlags() | EscherSpRecord.FLAG_FLIPHORIZ); // sp.setFlags(sp.getFlags() | EscherSpRecord.FLAG_FLIPHORIZ);
// if (userAnchor.isVerticallyFlipped()) // if (userAnchor.isVerticallyFlipped())
// sp.setFlags(sp.getFlags() | EscherSpRecord.FLAG_FLIPVERT); // sp.setFlags(sp.getFlags() | EscherSpRecord.FLAG_FLIPVERT);
anchor = createAnchor( userAnchor ); EscherRecord anchor = createAnchor( userAnchor );
clientData.setRecordId( EscherClientDataRecord.RECORD_ID ); clientData.setRecordId( EscherClientDataRecord.RECORD_ID );
clientData.setOptions( (short) 0x0000 ); clientData.setOptions( (short) 0x0000 );
escherTextbox.setRecordId( EscherTextboxRecord.RECORD_ID ); escherTextbox.setRecordId( EscherTextboxRecord.RECORD_ID );

View File

@ -507,7 +507,7 @@ public final class HyperlinkRecord extends StandardRecord {
//From the spec: An optional unsigned integer that MUST be 3 if present //From the spec: An optional unsigned integer that MUST be 3 if present
// but some files has 4 // but some files has 4
int usKeyValue = in.readUShort(); /*int usKeyValue = */ in.readUShort();
_address = StringUtil.readUnicodeLE(in, charDataSize/2); _address = StringUtil.readUnicodeLE(in, charDataSize/2);
} else { } else {

View File

@ -72,22 +72,13 @@ public final class HSSFConditionalFormattingRule implements ConditionalFormattin
private HSSFFontFormatting getFontFormatting(boolean create) { private HSSFFontFormatting getFontFormatting(boolean create) {
FontFormatting fontFormatting = cfRuleRecord.getFontFormatting(); FontFormatting fontFormatting = cfRuleRecord.getFontFormatting();
if ( fontFormatting != null) if (fontFormatting == null) {
{ if (!create) return null;
cfRuleRecord.setFontFormatting(fontFormatting);
return new HSSFFontFormatting(cfRuleRecord, workbook);
}
else if( create )
{
fontFormatting = new FontFormatting(); fontFormatting = new FontFormatting();
cfRuleRecord.setFontFormatting(fontFormatting); cfRuleRecord.setFontFormatting(fontFormatting);
}
return new HSSFFontFormatting(cfRuleRecord, workbook); return new HSSFFontFormatting(cfRuleRecord, workbook);
} }
else
{
return null;
}
}
/** /**
* @return - font formatting object if defined, <code>null</code> otherwise * @return - font formatting object if defined, <code>null</code> otherwise
@ -106,22 +97,14 @@ public final class HSSFConditionalFormattingRule implements ConditionalFormattin
private HSSFBorderFormatting getBorderFormatting(boolean create) { private HSSFBorderFormatting getBorderFormatting(boolean create) {
BorderFormatting borderFormatting = cfRuleRecord.getBorderFormatting(); BorderFormatting borderFormatting = cfRuleRecord.getBorderFormatting();
if ( borderFormatting != null) if (borderFormatting == null) {
{ if (!create) return null;
cfRuleRecord.setBorderFormatting(borderFormatting);
return new HSSFBorderFormatting(cfRuleRecord, workbook);
}
else if( create )
{
borderFormatting = new BorderFormatting(); borderFormatting = new BorderFormatting();
cfRuleRecord.setBorderFormatting(borderFormatting); cfRuleRecord.setBorderFormatting(borderFormatting);
}
return new HSSFBorderFormatting(cfRuleRecord, workbook); return new HSSFBorderFormatting(cfRuleRecord, workbook);
} }
else
{
return null;
}
}
/** /**
* @return - border formatting object if defined, <code>null</code> otherwise * @return - border formatting object if defined, <code>null</code> otherwise
*/ */
@ -137,25 +120,15 @@ public final class HSSFConditionalFormattingRule implements ConditionalFormattin
return getBorderFormatting(true); return getBorderFormatting(true);
} }
private HSSFPatternFormatting getPatternFormatting(boolean create) private HSSFPatternFormatting getPatternFormatting(boolean create) {
{
PatternFormatting patternFormatting = cfRuleRecord.getPatternFormatting(); PatternFormatting patternFormatting = cfRuleRecord.getPatternFormatting();
if ( patternFormatting != null) if (patternFormatting == null) {
{ if (!create) return null;
cfRuleRecord.setPatternFormatting(patternFormatting);
return new HSSFPatternFormatting(cfRuleRecord, workbook);
}
else if( create )
{
patternFormatting = new PatternFormatting(); patternFormatting = new PatternFormatting();
cfRuleRecord.setPatternFormatting(patternFormatting); cfRuleRecord.setPatternFormatting(patternFormatting);
}
return new HSSFPatternFormatting(cfRuleRecord, workbook); return new HSSFPatternFormatting(cfRuleRecord, workbook);
} }
else
{
return null;
}
}
/** /**
* @return - pattern formatting object if defined, <code>null</code> otherwise * @return - pattern formatting object if defined, <code>null</code> otherwise
@ -176,21 +149,17 @@ public final class HSSFConditionalFormattingRule implements ConditionalFormattin
private HSSFDataBarFormatting getDataBarFormatting(boolean create) { private HSSFDataBarFormatting getDataBarFormatting(boolean create) {
CFRule12Record cfRule12Record = getCFRule12Record(create); CFRule12Record cfRule12Record = getCFRule12Record(create);
if (cfRule12Record == null) return null;
DataBarFormatting databarFormatting = cfRule12Record.getDataBarFormatting(); DataBarFormatting databarFormatting = cfRule12Record.getDataBarFormatting();
if (databarFormatting != null) if (databarFormatting == null) {
{ if (!create) return null;
cfRule12Record.createDataBarFormatting();
}
return new HSSFDataBarFormatting(cfRule12Record, sheet); return new HSSFDataBarFormatting(cfRule12Record, sheet);
} }
else if( create )
{
databarFormatting = cfRule12Record.createDataBarFormatting();
return new HSSFDataBarFormatting(cfRule12Record, sheet);
}
else
{
return null;
}
}
/** /**
* @return databar / data-bar formatting object if defined, <code>null</code> otherwise * @return databar / data-bar formatting object if defined, <code>null</code> otherwise
*/ */
@ -207,21 +176,16 @@ public final class HSSFConditionalFormattingRule implements ConditionalFormattin
private HSSFIconMultiStateFormatting getMultiStateFormatting(boolean create) { private HSSFIconMultiStateFormatting getMultiStateFormatting(boolean create) {
CFRule12Record cfRule12Record = getCFRule12Record(create); CFRule12Record cfRule12Record = getCFRule12Record(create);
if (cfRule12Record == null) return null;
IconMultiStateFormatting iconFormatting = cfRule12Record.getMultiStateFormatting(); IconMultiStateFormatting iconFormatting = cfRule12Record.getMultiStateFormatting();
if (iconFormatting != null) if (iconFormatting == null) {
{ if (!create) return null;
cfRule12Record.createMultiStateFormatting();
}
return new HSSFIconMultiStateFormatting(cfRule12Record, sheet); return new HSSFIconMultiStateFormatting(cfRule12Record, sheet);
} }
else if( create )
{
iconFormatting = cfRule12Record.createMultiStateFormatting();
return new HSSFIconMultiStateFormatting(cfRule12Record, sheet);
}
else
{
return null;
}
}
/** /**
* @return icon / multi-state formatting object if defined, <code>null</code> otherwise * @return icon / multi-state formatting object if defined, <code>null</code> otherwise
*/ */
@ -238,21 +202,17 @@ public final class HSSFConditionalFormattingRule implements ConditionalFormattin
private HSSFColorScaleFormatting getColorScaleFormatting(boolean create) { private HSSFColorScaleFormatting getColorScaleFormatting(boolean create) {
CFRule12Record cfRule12Record = getCFRule12Record(create); CFRule12Record cfRule12Record = getCFRule12Record(create);
if (cfRule12Record == null) return null;
ColorGradientFormatting colorFormatting = cfRule12Record.getColorGradientFormatting(); ColorGradientFormatting colorFormatting = cfRule12Record.getColorGradientFormatting();
if (colorFormatting != null) if (colorFormatting == null) {
{ if (!create) return null;
cfRule12Record.createColorGradientFormatting();
}
return new HSSFColorScaleFormatting(cfRule12Record, sheet); return new HSSFColorScaleFormatting(cfRule12Record, sheet);
} }
else if( create )
{
colorFormatting = cfRule12Record.createColorGradientFormatting();
return new HSSFColorScaleFormatting(cfRule12Record, sheet);
}
else
{
return null;
}
}
/** /**
* @return color scale / gradient formatting object if defined, <code>null</code> otherwise * @return color scale / gradient formatting object if defined, <code>null</code> otherwise
*/ */

View File

@ -148,7 +148,6 @@ public final class HSSFName implements Name {
// Update our comment, if there is one // Update our comment, if there is one
if(_commentRec != null) { if(_commentRec != null) {
String oldName = _commentRec.getNameText();
_commentRec.setNameText(nameName); _commentRec.setNameText(nameName);
_book.getWorkbook().updateNameCommentRecordCache(_commentRec); _book.getWorkbook().updateNameCommentRecordCache(_commentRec);
} }

View File

@ -36,7 +36,6 @@ import org.apache.poi.hssf.record.DrawingRecord;
import org.apache.poi.hssf.record.EscherAggregate; import org.apache.poi.hssf.record.EscherAggregate;
import org.apache.poi.hssf.record.ExtendedFormatRecord; import org.apache.poi.hssf.record.ExtendedFormatRecord;
import org.apache.poi.hssf.record.NameRecord; import org.apache.poi.hssf.record.NameRecord;
import org.apache.poi.hssf.record.NoteRecord;
import org.apache.poi.hssf.record.Record; import org.apache.poi.hssf.record.Record;
import org.apache.poi.hssf.record.RowRecord; import org.apache.poi.hssf.record.RowRecord;
import org.apache.poi.hssf.record.SCLRecord; import org.apache.poi.hssf.record.SCLRecord;
@ -1448,11 +1447,8 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet {
return; return;
} }
NoteRecord[] noteRecs;
if (moveComments) { if (moveComments) {
noteRecs = _sheet.getNoteRecords(); _sheet.getNoteRecords();
} else {
noteRecs = NoteRecord.EMPTY_ARRAY;
} }
shiftMerged(startRow, endRow, n, true); shiftMerged(startRow, endRow, n, true);

View File

@ -95,8 +95,7 @@ public class DataSpaceMapUtils {
} }
public DataSpaceMap(LittleEndianInput is) { public DataSpaceMap(LittleEndianInput is) {
@SuppressWarnings("unused") /*int length = */ is.readInt();
int length = is.readInt();
int entryCount = is.readInt(); int entryCount = is.readInt();
entries = new DataSpaceMapEntry[entryCount]; entries = new DataSpaceMapEntry[entryCount];
for (int i=0; i<entryCount; i++) { for (int i=0; i<entryCount; i++) {
@ -125,8 +124,7 @@ public class DataSpaceMapUtils {
} }
public DataSpaceMapEntry(LittleEndianInput is) { public DataSpaceMapEntry(LittleEndianInput is) {
@SuppressWarnings("unused") /*int length = */ is.readInt();
int length = is.readInt();
int referenceComponentCount = is.readInt(); int referenceComponentCount = is.readInt();
referenceComponentType = new int[referenceComponentCount]; referenceComponentType = new int[referenceComponentCount];
referenceComponent = new String[referenceComponentCount]; referenceComponent = new String[referenceComponentCount];
@ -158,8 +156,7 @@ public class DataSpaceMapUtils {
} }
public DataSpaceDefinition(LittleEndianInput is) { public DataSpaceDefinition(LittleEndianInput is) {
@SuppressWarnings("unused") /* int headerLength = */ is.readInt();
int headerLength = is.readInt();
int transformReferenceCount = is.readInt(); int transformReferenceCount = is.readInt();
transformer = new String[transformReferenceCount]; transformer = new String[transformReferenceCount];
for (int i=0; i<transformReferenceCount; i++) { for (int i=0; i<transformReferenceCount; i++) {
@ -230,8 +227,7 @@ public class DataSpaceMapUtils {
} }
public TransformInfoHeader(LittleEndianInput is) { public TransformInfoHeader(LittleEndianInput is) {
@SuppressWarnings("unused") /* int length = */ is.readInt();
int length = is.readInt();
transformType = is.readInt(); transformType = is.readInt();
transformerId = readUnicodeLPP4(is); transformerId = readUnicodeLPP4(is);
transformerName = readUnicodeLPP4(is); transformerName = readUnicodeLPP4(is);

View File

@ -197,7 +197,6 @@ public class CryptoAPIDecryptor extends Decryptor {
* *
* @see <a href="http://msdn.microsoft.com/en-us/library/dd943321(v=office.12).aspx">2.3.5.4 RC4 CryptoAPI Encrypted Summary Stream</a> * @see <a href="http://msdn.microsoft.com/en-us/library/dd943321(v=office.12).aspx">2.3.5.4 RC4 CryptoAPI Encrypted Summary Stream</a>
*/ */
@SuppressWarnings("unused")
public InputStream getDataStream(DirectoryNode dir) public InputStream getDataStream(DirectoryNode dir)
throws IOException, GeneralSecurityException { throws IOException, GeneralSecurityException {
NPOIFSFileSystem fsOut = new NPOIFSFileSystem(); NPOIFSFileSystem fsOut = new NPOIFSFileSystem();
@ -209,7 +208,7 @@ public class CryptoAPIDecryptor extends Decryptor {
SeekableByteArrayInputStream sbis = new SeekableByteArrayInputStream(bos.toByteArray()); SeekableByteArrayInputStream sbis = new SeekableByteArrayInputStream(bos.toByteArray());
LittleEndianInputStream leis = new LittleEndianInputStream(sbis); LittleEndianInputStream leis = new LittleEndianInputStream(sbis);
int streamDescriptorArrayOffset = (int) leis.readUInt(); int streamDescriptorArrayOffset = (int) leis.readUInt();
int streamDescriptorArraySize = (int) leis.readUInt(); /* int streamDescriptorArraySize = (int) */ leis.readUInt();
sbis.skip(streamDescriptorArrayOffset - 8); sbis.skip(streamDescriptorArrayOffset - 8);
sbis.setBlock(0); sbis.setBlock(0);
int encryptedStreamDescriptorCount = (int) leis.readUInt(); int encryptedStreamDescriptorCount = (int) leis.readUInt();
@ -222,7 +221,7 @@ public class CryptoAPIDecryptor extends Decryptor {
entry.block = leis.readUShort(); entry.block = leis.readUShort();
int nameSize = leis.readUByte(); int nameSize = leis.readUByte();
entry.flags = leis.readUByte(); entry.flags = leis.readUByte();
boolean isStream = StreamDescriptorEntry.flagStream.isSet(entry.flags); // boolean isStream = StreamDescriptorEntry.flagStream.isSet(entry.flags);
entry.reserved2 = leis.readInt(); entry.reserved2 = leis.readInt();
entry.streamName = StringUtil.readUnicodeLE(leis, nameSize); entry.streamName = StringUtil.readUnicodeLE(leis, nameSize);
leis.readShort(); leis.readShort();

View File

@ -35,11 +35,10 @@ public class CryptoAPIEncryptionInfoBuilder implements EncryptionInfoBuilder {
/** /**
* initialize the builder from a stream * initialize the builder from a stream
*/ */
@SuppressWarnings("unused")
public void initialize(EncryptionInfo info, LittleEndianInput dis) public void initialize(EncryptionInfo info, LittleEndianInput dis)
throws IOException { throws IOException {
this.info = info; this.info = info;
int hSize = dis.readInt(); /* int hSize = */ dis.readInt();
header = new CryptoAPIEncryptionHeader(dis); header = new CryptoAPIEncryptionHeader(dis);
verifier = new CryptoAPIEncryptionVerifier(dis, header); verifier = new CryptoAPIEncryptionVerifier(dis, header);
decryptor = new CryptoAPIDecryptor(this); decryptor = new CryptoAPIDecryptor(this);

View File

@ -40,8 +40,7 @@ public class StandardEncryptionInfoBuilder implements EncryptionInfoBuilder {
public void initialize(EncryptionInfo info, LittleEndianInput dis) throws IOException { public void initialize(EncryptionInfo info, LittleEndianInput dis) throws IOException {
this.info = info; this.info = info;
@SuppressWarnings("unused") /* int hSize = */ dis.readInt();
int hSize = dis.readInt();
header = new StandardEncryptionHeader(dis); header = new StandardEncryptionHeader(dis);
verifier = new StandardEncryptionVerifier(dis, header); verifier = new StandardEncryptionVerifier(dis, header);

View File

@ -101,10 +101,10 @@ public class DrawTextParagraph<T extends TextRun> implements Drawable {
indent -= leftMargin; indent -= leftMargin;
} }
Double rightMargin = paragraph.getRightMargin(); // Double rightMargin = paragraph.getRightMargin();
if (rightMargin == null) { // if (rightMargin == null) {
rightMargin = 0d; // rightMargin = 0d;
} // }
//The vertical line spacing //The vertical line spacing
Double spacing = paragraph.getLineSpacing(); Double spacing = paragraph.getLineSpacing();

View File

@ -63,7 +63,7 @@ public class PresetGeometries extends LinkedHashMap<String, CustomGeometry> {
XMLEventReader staxReader = staxFactory.createXMLEventReader(is); XMLEventReader staxReader = staxFactory.createXMLEventReader(is);
XMLEventReader staxFiltRd = staxFactory.createFilteredReader(staxReader, startElementFilter); XMLEventReader staxFiltRd = staxFactory.createFilteredReader(staxReader, startElementFilter);
// ignore StartElement: // ignore StartElement:
XMLEvent evDoc = staxFiltRd.nextEvent(); /* XMLEvent evDoc = */ staxFiltRd.nextEvent();
// JAXB: // JAXB:
JAXBContext jaxbContext = JAXBContext.newInstance(BINDING_PACKAGE); JAXBContext jaxbContext = JAXBContext.newInstance(BINDING_PACKAGE);
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();

View File

@ -69,14 +69,14 @@ public class Address implements Function {
throw new EvaluationException(ErrorEval.VALUE_INVALID); throw new EvaluationException(ErrorEval.VALUE_INVALID);
} }
boolean a1; // boolean a1;
if(args.length > 3){ // if(args.length > 3){
ValueEval ve = OperandResolver.getSingleValue(args[3], srcRowIndex, srcColumnIndex); // ValueEval ve = OperandResolver.getSingleValue(args[3], srcRowIndex, srcColumnIndex);
// TODO R1C1 style is not yet supported // // TODO R1C1 style is not yet supported
a1 = ve == MissingArgEval.instance ? true : OperandResolver.coerceValueToBoolean(ve, false); // a1 = ve == MissingArgEval.instance ? true : OperandResolver.coerceValueToBoolean(ve, false);
} else { // } else {
a1 = true; // a1 = true;
} // }
String sheetName; String sheetName;
if(args.length == 5){ if(args.length == 5){

View File

@ -68,7 +68,7 @@ public class Office2010SignatureFacet extends SignatureFacet {
} }
UnsignedSignaturePropertiesType unsignedSigProps = unsignedProps.getUnsignedSignatureProperties(); UnsignedSignaturePropertiesType unsignedSigProps = unsignedProps.getUnsignedSignatureProperties();
if (unsignedSigProps == null) { if (unsignedSigProps == null) {
unsignedSigProps = unsignedProps.addNewUnsignedSignatureProperties(); /* unsignedSigProps = */ unsignedProps.addNewUnsignedSignatureProperties();
} }
Node n = document.importNode(qualProps.getDomNode().getFirstChild(), true); Node n = document.importNode(qualProps.getDomNode().getFirstChild(), true);

File diff suppressed because it is too large Load Diff

View File

@ -187,7 +187,7 @@ public final class XmlSort
* The constructor accepts an argument indicating whether the comparison order is the same as * The constructor accepts an argument indicating whether the comparison order is the same as
* the lexicographic order of the strings or the reverse. * the lexicographic order of the strings or the reverse.
*/ */
public static final class QNameComparator implements Comparator public static final class QNameComparator implements Comparator<XmlCursor>
{ {
public static final int ASCENDING = 1; public static final int ASCENDING = 1;
public static final int DESCENDING = 2; public static final int DESCENDING = 2;
@ -202,10 +202,7 @@ public final class XmlSort
"comparison orders"); "comparison orders");
} }
public int compare(Object o, Object o1) public int compare(XmlCursor cursor1, XmlCursor cursor2) {
{
XmlCursor cursor1 = (XmlCursor) o;
XmlCursor cursor2 = (XmlCursor) o1;
QName qname1 = cursor1.getName(); QName qname1 = cursor1.getName();
QName qname2 = cursor2.getName(); QName qname2 = cursor2.getName();
int qnameComparisonRes = qname1.getNamespaceURI().compareTo(qname2.getNamespaceURI()); int qnameComparisonRes = qname1.getNamespaceURI().compareTo(qname2.getNamespaceURI());

View File

@ -21,7 +21,6 @@ package org.apache.poi.xslf.usermodel;
import org.apache.poi.sl.usermodel.ConnectorShape; import org.apache.poi.sl.usermodel.ConnectorShape;
import org.apache.poi.util.Beta; import org.apache.poi.util.Beta;
import org.openxmlformats.schemas.drawingml.x2006.main.CTLineProperties;
import org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps; import org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps;
import org.openxmlformats.schemas.drawingml.x2006.main.CTPresetGeometry2D; import org.openxmlformats.schemas.drawingml.x2006.main.CTPresetGeometry2D;
import org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties; import org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties;
@ -44,7 +43,6 @@ public class XSLFConnectorShape extends XSLFSimpleShape implements ConnectorShap
/** /**
* @param shapeId 1-based shapeId * @param shapeId 1-based shapeId
*/ */
@SuppressWarnings("unused")
static CTConnector prototype(int shapeId) { static CTConnector prototype(int shapeId) {
CTConnector ct = CTConnector.Factory.newInstance(); CTConnector ct = CTConnector.Factory.newInstance();
CTConnectorNonVisual nvSpPr = ct.addNewNvCxnSpPr(); CTConnectorNonVisual nvSpPr = ct.addNewNvCxnSpPr();
@ -57,7 +55,7 @@ public class XSLFConnectorShape extends XSLFSimpleShape implements ConnectorShap
CTPresetGeometry2D prst = spPr.addNewPrstGeom(); CTPresetGeometry2D prst = spPr.addNewPrstGeom();
prst.setPrst(STShapeType.LINE); prst.setPrst(STShapeType.LINE);
prst.addNewAvLst(); prst.addNewAvLst();
CTLineProperties ln = spPr.addNewLn(); /* CTLineProperties ln = */ spPr.addNewLn();
return ct; return ct;
} }

View File

@ -23,7 +23,12 @@ import javax.xml.namespace.QName;
import org.apache.poi.util.Internal; import org.apache.poi.util.Internal;
import org.apache.xmlbeans.XmlCursor; import org.apache.xmlbeans.XmlCursor;
import org.openxmlformats.schemas.drawingml.x2006.main.*; import org.openxmlformats.schemas.drawingml.x2006.main.CTGraphicalObjectData;
import org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps;
import org.openxmlformats.schemas.drawingml.x2006.main.CTPoint2D;
import org.openxmlformats.schemas.drawingml.x2006.main.CTPositiveSize2D;
import org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties;
import org.openxmlformats.schemas.drawingml.x2006.main.CTTransform2D;
import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTGraphicalObjectFrame; import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTGraphicalObjectFrame;
import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTGraphicalObjectFrameNonVisual; import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTGraphicalObjectFrameNonVisual;
import org.openxmlformats.schemas.officeDocument.x2006.relationships.STRelationshipId; import org.openxmlformats.schemas.officeDocument.x2006.relationships.STRelationshipId;
@ -79,7 +84,7 @@ public final class XSSFGraphicFrame extends XSSFShape {
offPoint.setX(0); offPoint.setX(0);
offPoint.setY(0); offPoint.setY(0);
CTGraphicalObject graphic = graphicFrame.addNewGraphic(); /* CTGraphicalObject graphic = */ graphicFrame.addNewGraphic();
prototype = graphicFrame; prototype = graphicFrame;
} }

View File

@ -94,7 +94,6 @@ public final class NewOleFile extends RandomAccessFile
int counter = 0; int counter = 0;
for(int x = 0; x < _num_bbd_blocks; x++) for(int x = 0; x < _num_bbd_blocks; x++)
{ {
byte[] bigBlock = new byte[512];
int offset = (_bbd_list[x] + 1) * 512; int offset = (_bbd_list[x] + 1) * 512;
seek(offset); seek(offset);
for(int y = 0; y < 128; y++) for(int y = 0; y < 128; y++)
@ -107,17 +106,12 @@ public final class NewOleFile extends RandomAccessFile
initializePropertySets(rootChain); initializePropertySets(rootChain);
} }
@SuppressWarnings("unused")
public static void main(String args[]) public static void main(String args[]) throws Exception {
{ NewOleFile nof = new NewOleFile(args[0], "r");
try nof.close();
{
NewOleFile file = new NewOleFile(args[0], "r");
}
catch(Exception e)
{
}
} }
protected int[] readChain(int[] blockChain, int startBlock) { protected int[] readChain(int[] blockChain, int startBlock) {
int[] tempChain = new int[blockChain.length]; int[] tempChain = new int[blockChain.length];

View File

@ -784,7 +784,6 @@ public final class WordDocument {
return context.getFontMetrics(font); return context.getFontMetrics(font);
}*/ }*/
@SuppressWarnings("unused")
private String createRegion(boolean before, HeaderFooter header, SEP sep, String name) private String createRegion(boolean before, HeaderFooter header, SEP sep, String name)
{ {
if(header.isEmpty()) if(header.isEmpty())
@ -820,8 +819,8 @@ public final class WordDocument {
sep._dyaBottom = Math.max(extent*20, sep._dyaBottom); sep._dyaBottom = Math.max(extent*20, sep._dyaBottom);
} }
int marginLeft = sep._dxaLeft/20; //int marginLeft = sep._dxaLeft/20;
int marginRight = sep._dxaRight/20; //int marginRight = sep._dxaRight/20;
return "<fo:region-" + where + " display-align=\"" + align + "\" extent=\"" return "<fo:region-" + where + " display-align=\"" + align + "\" extent=\""
+ extent + "pt\" "+region+"/>"; + extent + "pt\" "+region+"/>";

View File

@ -33,11 +33,11 @@ public final class HDFDocument
public HDFDocument(InputStream in, HDFParsingListener listener) throws IOException public HDFDocument(InputStream in, HDFParsingListener listener) throws IOException
{ {
EventBridge eb = new EventBridge(listener); EventBridge eb = new EventBridge(listener);
HDFObjectFactory factory = new HDFObjectFactory(in, eb); /* HDFObjectFactory factory = */ new HDFObjectFactory(in, eb);
} }
public HDFDocument(InputStream in) throws IOException public HDFDocument(InputStream in) throws IOException
{ {
_model = new HDFObjectModel(); _model = new HDFObjectModel();
HDFObjectFactory factory = new HDFObjectFactory(in, _model); /* HDFObjectFactory factory = */ new HDFObjectFactory(in, _model);
} }
} }

View File

@ -68,19 +68,10 @@ public final class HDFObjectFactory {
byte[] _tableBuffer; byte[] _tableBuffer;
@SuppressWarnings("unused") public static void main(String args[]) throws Exception {
public static void main(String args[]) new HDFObjectFactory(new FileInputStream("c:\\test.doc"));
{
try
{
HDFObjectFactory f = new HDFObjectFactory(new FileInputStream("c:\\test.doc"));
int k = 0;
}
catch(Exception t)
{
t.printStackTrace();
}
} }
/** Creates a new instance of HDFObjectFactory /** Creates a new instance of HDFObjectFactory
* *
* @param istream The InputStream that is the Word document * @param istream The InputStream that is the Word document
@ -133,8 +124,9 @@ public final class HDFObjectFactory {
List<FileInformationBlock> results = new ArrayList<FileInformationBlock>(1); List<FileInformationBlock> results = new ArrayList<FileInformationBlock>(1);
//do Ole stuff //do Ole stuff
POIFSFileSystem filesystem = new POIFSFileSystem(istream); POIFSFileSystem filesystem = null;
try {
filesystem = new POIFSFileSystem(istream);
DocumentEntry headerProps = DocumentEntry headerProps =
(DocumentEntry)filesystem.getRoot().getEntry("WordDocument"); (DocumentEntry)filesystem.getRoot().getEntry("WordDocument");
@ -146,6 +138,9 @@ public final class HDFObjectFactory {
results.add(fib); results.add(fib);
return results; return results;
} finally {
if (filesystem != null) filesystem.close();
}
} }
@ -477,7 +472,7 @@ public final class HDFObjectFactory {
{ {
int ccpText = _fib.getCcpText(); int ccpText = _fib.getCcpText();
int ccpFtn = _fib.getCcpFtn(); // int ccpFtn = _fib.getCcpFtn();
//sections //sections
int fcMin = _fib.getFcMin(); int fcMin = _fib.getFcMin();

View File

@ -329,15 +329,14 @@ public final class StyleSheet implements HDFType {
newCHP.setIco((byte)0); newCHP.setIco((byte)0);
break; break;
case 0x33: case 0x33:
try // ... this code has no effect ...
{ // try {
newCHP = (CharacterProperties)oldCHP.clone(); // newCHP = (CharacterProperties)oldCHP.clone();
} // }
catch(CloneNotSupportedException e) // catch(CloneNotSupportedException e) {
{ // //do nothing
//do nothing // }
} break;
return;
case 0x34: case 0x34:
break; break;
case 0x35: case 0x35:

View File

@ -73,8 +73,7 @@ public final class CompressedRTF extends LZWDecompresser {
compressedSize = LittleEndian.readInt(src); compressedSize = LittleEndian.readInt(src);
decompressedSize = LittleEndian.readInt(src); decompressedSize = LittleEndian.readInt(src);
int compressionType = LittleEndian.readInt(src); int compressionType = LittleEndian.readInt(src);
@SuppressWarnings("unused") /* int dataCRC = */ LittleEndian.readInt(src);
int dataCRC = LittleEndian.readInt(src);
// TODO - Handle CRC checking on the output side // TODO - Handle CRC checking on the output side

View File

@ -301,11 +301,8 @@ public final class HSLFSlideShow implements SlideShow {
// Slides or Notes, and possibly even other odd stuff.... // Slides or Notes, and possibly even other odd stuff....
// About the only thing you can say is that the master details are in // About the only thing you can say is that the master details are in
// the first SLWT. // the first SLWT.
SlideAtomsSet[] masterSets = new SlideAtomsSet[0];
if (masterSLWT != null) { if (masterSLWT != null) {
masterSets = masterSLWT.getSlideAtomsSets(); for (SlideAtomsSet sas : masterSLWT.getSlideAtomsSets()) {
for (SlideAtomsSet sas : masterSets) {
Record r = getCoreRecordForSAS(sas); Record r = getCoreRecordForSAS(sas);
int sheetNo = sas.getSlidePersistAtom().getSlideIdentifier(); int sheetNo = sas.getSlidePersistAtom().getSlideIdentifier();
if (r instanceof org.apache.poi.hslf.record.Slide) { if (r instanceof org.apache.poi.hslf.record.Slide) {
@ -327,27 +324,27 @@ public final class HSLFSlideShow implements SlideShow {
// Start by finding the notes records to go with the entries in // Start by finding the notes records to go with the entries in
// notesSLWT // notesSLWT
org.apache.poi.hslf.record.Notes[] notesRecords; org.apache.poi.hslf.record.Notes[] notesRecords;
SlideAtomsSet[] notesSets = new SlideAtomsSet[0];
Map<Integer,Integer> slideIdToNotes = new HashMap<Integer,Integer>(); Map<Integer,Integer> slideIdToNotes = new HashMap<Integer,Integer>();
if (notesSLWT == null) { if (notesSLWT == null) {
// None // None
notesRecords = new org.apache.poi.hslf.record.Notes[0]; notesRecords = new org.apache.poi.hslf.record.Notes[0];
} else { } else {
// Match up the records and the SlideAtomSets // Match up the records and the SlideAtomSets
notesSets = notesSLWT.getSlideAtomsSets();
List<org.apache.poi.hslf.record.Notes> notesRecordsL = List<org.apache.poi.hslf.record.Notes> notesRecordsL =
new ArrayList<org.apache.poi.hslf.record.Notes>(); new ArrayList<org.apache.poi.hslf.record.Notes>();
for (int i = 0; i < notesSets.length; i++) { int idx = -1;
for (SlideAtomsSet notesSet : notesSLWT.getSlideAtomsSets()) {
idx++;
// Get the right core record // Get the right core record
Record r = getCoreRecordForSAS(notesSets[i]); Record r = getCoreRecordForSAS(notesSet);
SlidePersistAtom spa = notesSet.getSlidePersistAtom();
String loggerLoc = "A Notes SlideAtomSet at "+idx+" said its record was at refID "+spa.getRefID();
// Ensure it really is a notes record // Ensure it really is a notes record
if (r == null || r instanceof org.apache.poi.hslf.record.Notes) { if (r == null || r instanceof org.apache.poi.hslf.record.Notes) {
if (r == null) { if (r == null) {
logger.log(POILogger.WARN, "A Notes SlideAtomSet at " + i logger.log(POILogger.WARN, loggerLoc+", but that record didn't exist - record ignored.");
+ " said its record was at refID "
+ notesSets[i].getSlidePersistAtom().getRefID()
+ ", but that record didn't exist - record ignored.");
} }
// we need to add also null-records, otherwise the index references to other existing // we need to add also null-records, otherwise the index references to other existing
// don't work anymore // don't work anymore
@ -355,14 +352,10 @@ public final class HSLFSlideShow implements SlideShow {
notesRecordsL.add(notesRecord); notesRecordsL.add(notesRecord);
// Record the match between slide id and these notes // Record the match between slide id and these notes
SlidePersistAtom spa = notesSets[i].getSlidePersistAtom();
int slideId = spa.getSlideIdentifier(); int slideId = spa.getSlideIdentifier();
slideIdToNotes.put(slideId, i); slideIdToNotes.put(slideId, idx);
} else { } else {
logger.log(POILogger.ERROR, "A Notes SlideAtomSet at " + i logger.log(POILogger.ERROR, loggerLoc+", but that was actually a " + r);
+ " said its record was at refID "
+ notesSets[i].getSlidePersistAtom().getRefID()
+ ", but that was actually a " + r);
} }
} }
notesRecords = new org.apache.poi.hslf.record.Notes[notesRecordsL.size()]; notesRecords = new org.apache.poi.hslf.record.Notes[notesRecordsL.size()];

View File

@ -221,7 +221,7 @@ public class HSLFSlideShowEncrypted {
cipher.doFinal(pictstream, offset, 8, pictstream, offset); cipher.doFinal(pictstream, offset, 8, pictstream, offset);
recInst = fieldRecInst.getValue(LittleEndian.getUShort(pictstream, offset)); recInst = fieldRecInst.getValue(LittleEndian.getUShort(pictstream, offset));
recType = LittleEndian.getUShort(pictstream, offset+2); recType = LittleEndian.getUShort(pictstream, offset+2);
rlen = (int)LittleEndian.getUInt(pictstream, offset+4); // rlen = (int)LittleEndian.getUInt(pictstream, offset+4);
offset += 8; offset += 8;
} }
@ -299,7 +299,7 @@ public class HSLFSlideShowEncrypted {
// update header data // update header data
recInst = fieldRecInst.getValue(LittleEndian.getUShort(pictstream, offset)); recInst = fieldRecInst.getValue(LittleEndian.getUShort(pictstream, offset));
recType = LittleEndian.getUShort(pictstream, offset+2); recType = LittleEndian.getUShort(pictstream, offset+2);
rlen = (int)LittleEndian.getUInt(pictstream, offset+4); // rlen = (int) LittleEndian.getUInt(pictstream, offset+4);
cipher.doFinal(pictstream, offset, 8, pictstream, offset); cipher.doFinal(pictstream, offset, 8, pictstream, offset);
offset += 8; offset += 8;
} }

View File

@ -752,10 +752,10 @@ public final class HSLFTextParagraph implements TextParagraph<HSLFTextRun> {
RecordContainer _txtbox = headerAtom.getParentRecord(); RecordContainer _txtbox = headerAtom.getParentRecord();
Record[] cr = _txtbox.getChildRecords(); Record[] cr = _txtbox.getChildRecords();
int headerIdx = -1, textIdx = -1, styleIdx = -1; int /* headerIdx = -1, */ textIdx = -1, styleIdx = -1;
for (int i = 0; i < cr.length; i++) { for (int i = 0; i < cr.length; i++) {
Record r = cr[i]; Record r = cr[i];
if (r == headerAtom) headerIdx = i; if (r == headerAtom) ; // headerIdx = i;
else if (r == oldRecord || r == newRecord) textIdx = i; else if (r == oldRecord || r == newRecord) textIdx = i;
else if (r == styleAtom) styleIdx = i; else if (r == styleAtom) styleIdx = i;
} }
@ -763,7 +763,7 @@ public final class HSLFTextParagraph implements TextParagraph<HSLFTextRun> {
if (textIdx == -1) { if (textIdx == -1) {
// the old record was never registered, ignore it // the old record was never registered, ignore it
_txtbox.addChildAfter(newRecord, headerAtom); _txtbox.addChildAfter(newRecord, headerAtom);
textIdx = headerIdx + 1; // textIdx = headerIdx + 1;
} else { } else {
// swap not appropriated records - noop if unchanged // swap not appropriated records - noop if unchanged
cr[textIdx] = newRecord; cr[textIdx] = newRecord;

View File

@ -112,7 +112,7 @@ public abstract class PropertiesChunk extends Chunk {
return null; return null;
} }
if (val instanceof ChunkBasedPropertyValue) { if (val instanceof ChunkBasedPropertyValue) {
ChunkBasedPropertyValue cval = (ChunkBasedPropertyValue)val; // ChunkBasedPropertyValue cval = (ChunkBasedPropertyValue)val;
// TODO Lookup // TODO Lookup
return Collections.emptyList(); return Collections.emptyList();
} else { } else {

View File

@ -347,7 +347,7 @@ public final class HWPFDocument extends HWPFDocumentCore
_ft = new FontTable(_tableStream, _fib.getFcSttbfffn(), _fib.getLcbSttbfffn()); _ft = new FontTable(_tableStream, _fib.getFcSttbfffn(), _fib.getLcbSttbfffn());
int listOffset = _fib.getFcPlfLst(); int listOffset = _fib.getFcPlfLst();
int lfoOffset = _fib.getFcPlfLfo(); // int lfoOffset = _fib.getFcPlfLfo();
if ( listOffset != 0 && _fib.getLcbPlfLst() != 0 ) if ( listOffset != 0 && _fib.getLcbPlfLst() != 0 )
{ {
_lt = new ListTables( _tableStream, listOffset, _fib.getFcPlfLfo(), _lt = new ListTables( _tableStream, listOffset, _fib.getFcPlfLfo(),

View File

@ -40,8 +40,8 @@ public final class StyleDescription implements HDFType
private final static int PARAGRAPH_STYLE = 1; private final static int PARAGRAPH_STYLE = 1;
private final static int CHARACTER_STYLE = 2; private final static int CHARACTER_STYLE = 2;
private final static int TABLE_STYLE = 3; // private final static int TABLE_STYLE = 3;
private final static int NUMBERING_STYLE = 4; // private final static int NUMBERING_STYLE = 4;
private int _baseLength; private int _baseLength;
private StdfBase _stdfBase; private StdfBase _stdfBase;
@ -86,7 +86,7 @@ public final class StyleDescription implements HDFType
if ( readStdfPost2000 ) if ( readStdfPost2000 )
{ {
_stdfPost2000 = new StdfPost2000( std, offset ); _stdfPost2000 = new StdfPost2000( std, offset );
offset += StdfPost2000.getSize(); // offset += StdfPost2000.getSize();
} }
//first byte(s) of variable length section of std is the length of the //first byte(s) of variable length section of std is the length of the

View File

@ -42,10 +42,10 @@ import org.apache.poi.util.LittleEndian;
public final class StyleSheet implements HDFType { public final class StyleSheet implements HDFType {
public static final int NIL_STYLE = 4095; public static final int NIL_STYLE = 4095;
private static final int PAP_TYPE = 1; // private static final int PAP_TYPE = 1;
private static final int CHP_TYPE = 2; // private static final int CHP_TYPE = 2;
private static final int SEP_TYPE = 4; // private static final int SEP_TYPE = 4;
private static final int TAP_TYPE = 5; // private static final int TAP_TYPE = 5;
@Deprecated @Deprecated
private final static ParagraphProperties NIL_PAP = new ParagraphProperties(); private final static ParagraphProperties NIL_PAP = new ParagraphProperties();
@ -144,7 +144,7 @@ public final class StyleSheet implements HDFType {
_stshif.setCstd( _styleDescriptions.length ); _stshif.setCstd( _styleDescriptions.length );
_stshif.serialize( buf, offset ); _stshif.serialize( buf, offset );
offset += Stshif.getSize(); // offset += Stshif.getSize();
out.write(buf); out.write(buf);
@ -156,7 +156,7 @@ public final class StyleSheet implements HDFType {
byte[] std = _styleDescriptions[x].toByteArray(); byte[] std = _styleDescriptions[x].toByteArray();
// adjust the size so it is always on a word boundary // adjust the size so it is always on a word boundary
LittleEndian.putShort(sizeHolder, (short)((std.length) + (std.length % 2))); LittleEndian.putShort(sizeHolder, 0, (short)((std.length) + (std.length % 2)));
out.write(sizeHolder); out.write(sizeHolder);
out.write(std); out.write(std);