Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions main/DDF/DefaultEscherRecordFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public virtual EscherRecord CreateRecord(byte[] data, int offset)
escherRecord = (EscherRecord)recordConstructor.Invoke(new object[] { });
//escherRecord = (EscherRecord)Activator.CreateInstance(recordConstructor);
}
catch (Exception)
catch
{
return new UnknownEscherRecord();
}
Expand Down Expand Up @@ -143,7 +143,7 @@ private static Dictionary<short, ConstructorInfo> RecordsToMap(Type[] records)
{
sid = (short)recordType.GetField("RECORD_ID").GetValue(null);
}
catch (Exception)
catch
{
throw new RecordFormatException(
"Unable to determine record types");
Expand Down
4 changes: 2 additions & 2 deletions main/DDF/EscherTextboxRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public override String ToString()
theDumpHex += HexDump.Dump(_thedata, 0, 0);
}
}
catch (Exception)
catch
{
theDumpHex = "Error!!";
}
Expand All @@ -194,7 +194,7 @@ public override String ToXml(String tab)
theDumpHex += HexDump.Dump(_thedata, 0, 0);
}
}
catch (Exception)
catch
{
theDumpHex = "Error!!";
}
Expand Down
2 changes: 1 addition & 1 deletion main/DDF/UnknownEscherRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public override String ToString()
theDumpHex += HexDump.Dump(_thedata, 0, 0);
}
}
catch (Exception)
catch
{
theDumpHex = "Error!!";
}
Expand Down
11 changes: 2 additions & 9 deletions main/HPSF/MutableSection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -279,15 +279,8 @@ public override int Size
{
if (dirty)
{
try
{
size = CalcSize();
dirty = false;
}
catch (Exception)
{
throw;
}
size = CalcSize();
dirty = false;
}
return size;
}
Expand Down
15 changes: 4 additions & 11 deletions main/HSSF/Extractor/EventBasedExcelExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,19 +123,12 @@ public override String Text
get
{
String text = null;
try
{
TextListener tl = TriggerExtraction();
TextListener tl = TriggerExtraction();

text = tl.text.ToString();
if (!text.EndsWith("\n", StringComparison.Ordinal))
{
text = text + "\n";
}
}
catch (IOException)
text = tl.text.ToString();
if (!text.EndsWith("\n", StringComparison.Ordinal))
{
throw;
text = text + "\n";
}

return text;
Expand Down
8 changes: 4 additions & 4 deletions main/HSSF/Extractor/OldExcelExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,19 @@ public OldExcelExtractor(FileInfo f)
{
Open(biffStream);
}
catch (IOException e)
catch (IOException)
{
// ensure that the stream is properly closed here if an Exception
// is thrown while opening
biffStream.Close();
throw e;
throw;
}
catch (RuntimeException e)
catch (RuntimeException)
{
// ensure that the stream is properly closed here if an Exception
// is thrown while opening
biffStream.Close();
throw e;
throw;
}
}
public OldExcelExtractor(NPOIFSFileSystem fs)
Expand Down
4 changes: 2 additions & 2 deletions main/HSSF/Record/RecordFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ private static I_RecordCreator GetRecordCreator(Type recClass)
if (constructor != null)
return new ReflectionConstructorRecordCreator(constructor);
}
catch (Exception)
catch
{
// fall through and look for other construction methods
}
Expand All @@ -665,7 +665,7 @@ private static I_RecordCreator GetRecordCreator(Type recClass)
MethodInfo m = recClass.GetMethod("Create", CONSTRUCTOR_ARGS);
return new ReflectionMethodRecordCreator(m);
}
catch (Exception)
catch
{
throw new RuntimeException("Failed to find constructor or create method for (" + recClass.Name + ").");
}
Expand Down
18 changes: 2 additions & 16 deletions main/HSSF/UserModel/OperationEvaluatorFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,7 @@ private static void Add(Hashtable m, Type ptgClass, Type evalClass)
}

ConstructorInfo constructor;
try
{
constructor = evalClass.GetConstructor(OPERATION_CONSTRUCTOR_CLASS_ARRAY);
}
catch (Exception)
{
throw;
}
constructor = evalClass.GetConstructor(OPERATION_CONSTRUCTOR_CLASS_ARRAY);
if (!constructor.IsPublic)
{
throw new Exception("Eval constructor must be public");
Expand Down Expand Up @@ -128,14 +121,7 @@ public static OperationEval Create(OperationPtg ptg)

Object result;
Object[] initargs = { ptg };
try
{
result = constructor.Invoke(initargs);
}
catch (Exception)
{
throw;
}
result = constructor.Invoke(initargs);
return (OperationEval)result;
}
}
Expand Down
2 changes: 1 addition & 1 deletion main/HSSF/Util/HSSFCellUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ public static void CopyCell(HSSFCell oldCell, HSSFCell newCell, IDictionary<Int3
newCell.SetCellType(CellType.Numeric);
newCell.SetCellValue(oldCell.NumericCellValue);
}
catch (Exception)
catch
{
newCell.SetCellType(CellType.String);
newCell.SetCellValue(oldCell.ToString());
Expand Down
6 changes: 3 additions & 3 deletions main/POIFS/Crypt/Standard/StandardDecryptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,10 @@ private int getMoreData()
{
this.obuffer = this.cipher.Update(this.ibuffer, 0, i);
}
catch (Exception ex)
catch
{
this.obuffer = null;
throw ex;
throw;
}
this.ostart = 0;
if (this.obuffer == null)
Expand Down Expand Up @@ -293,7 +293,7 @@ public override void Close()
{
this.cipher.DoFinal();
}
catch (Exception)
catch
{
}
}
Expand Down
2 changes: 1 addition & 1 deletion main/POIFS/Crypt/Standard/StandardEncryptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ public override void Close()
{
this.obuffer = this.cipher.DoFinal();
}
catch (Exception)
catch
{
this.obuffer = null;
}
Expand Down
37 changes: 11 additions & 26 deletions main/POIFS/FileSystem/DirectoryNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -401,25 +401,17 @@ public DocumentInputStream CreateDocumentInputStream(string documentName)

public DocumentEntry CreateDocument(NPOIFSDocument document)
{
try
{
DocumentProperty property = document.DocumentProperty;
DocumentNode rval = new DocumentNode(property, this);

((DirectoryProperty)Property).AddChild(property);
DocumentProperty property = document.DocumentProperty;
DocumentNode rval = new DocumentNode(property, this);

_nFilesSystem.AddDocument(document);
((DirectoryProperty)Property).AddChild(property);

_entries.Add(rval);
_byname[property.Name] = rval;
_nFilesSystem.AddDocument(document);

return rval;
_entries.Add(rval);
_byname[property.Name] = rval;

}
catch (IOException ex)
{
throw ex;
}
return rval;
}


Expand Down Expand Up @@ -529,20 +521,13 @@ protected override bool IsDeleteOK

public DocumentEntry CreateDocument(string name, Stream stream)
{
try
if (_nFilesSystem != null)
{
if (_nFilesSystem != null)
{
return CreateDocument(new NPOIFSDocument(name, _nFilesSystem, stream));
}
else
{
return CreateDocument(new OPOIFSDocument(name, stream));
}
return CreateDocument(new NPOIFSDocument(name, _nFilesSystem, stream));
}
catch (IOException ex)
else
{
throw ex;
return CreateDocument(new OPOIFSDocument(name, stream));
}
}

Expand Down
12 changes: 4 additions & 8 deletions main/POIFS/FileSystem/NPOIFSFileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,26 +216,22 @@ public NPOIFSFileSystem(FileStream channel, FileInfo srcFile, bool readOnly, boo
//_data = new FileBackedDataSource(channel, readOnly);
ReadCoreContents();
}
catch (Exception)
{
throw;
}
finally
{
if (channel != null)
channel.Close();
}
}
catch (IOException e)
catch (IOException)
{
if (closeChannelOnError && channel != null)
{
channel.Close();
channel = null;
}
throw e;
throw;
}
catch (RuntimeException e)
catch (RuntimeException)
{
// Comes from Iterators etc.
// TODO Decide if we can handle these better whilst
Expand All @@ -245,7 +241,7 @@ public NPOIFSFileSystem(FileStream channel, FileInfo srcFile, bool readOnly, boo
channel.Close();
channel = null;
}
throw e;
throw;
}
}

Expand Down
4 changes: 2 additions & 2 deletions main/POIFS/Macros/VBAMacroReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,13 @@ private void OpenOOXML(Stream zipFile)
this.fs = new NPOIFSFileSystem(zis);
return;
}
catch (IOException e)
catch (IOException)
{
// Tidy up
zis.Close();

// Pass on
throw e;
throw;
}
}
}
Expand Down
57 changes: 18 additions & 39 deletions main/POIFS/Storage/HeaderBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,21 +105,13 @@ public class HeaderBlock : HeaderBlockConstants
/// <param name="stream">the source Stream</param>
public HeaderBlock(Stream stream)
{
try
stream.Position = 0;
PrivateHeaderBlock(ReadFirst512(stream));
if (bigBlockSize.GetBigBlockSize() != 512)
{
stream.Position = 0;
PrivateHeaderBlock(ReadFirst512(stream));
if (bigBlockSize.GetBigBlockSize() != 512)
{
int rest = bigBlockSize.GetBigBlockSize() - 512;
byte[] temp = new byte[rest];
IOUtils.ReadFully(stream, temp);
}

}
catch(IOException ex)
{
throw ex;
int rest = bigBlockSize.GetBigBlockSize() - 512;
byte[] temp = new byte[rest];
IOUtils.ReadFully(stream, temp);
}
}

Expand All @@ -130,15 +122,9 @@ public HeaderBlock(ByteBuffer buffer)

public HeaderBlock(byte[] buffer)
{
try
{
PrivateHeaderBlock(buffer);
}
catch (IOException ex)
{
throw ex;
}
PrivateHeaderBlock(buffer);
}

public void PrivateHeaderBlock(byte[] data)
{
_data = data;
Expand Down Expand Up @@ -425,26 +411,19 @@ public POIFSBigBlockSize BigBlockSize

public void WriteData(Stream stream)
{
try
{
new IntegerField(_bat_count_offset, _bat_count, _data);
new IntegerField(_property_start_offset, _property_start, _data);
new IntegerField(_sbat_start_offset, _sbat_start, _data);
new IntegerField(_sbat_block_count_offset, _sbat_count, _data);
new IntegerField(_xbat_start_offset, _xbat_start, _data);
new IntegerField(_xbat_count_offset, _xbat_count, _data);
new IntegerField(_bat_count_offset, _bat_count, _data);
new IntegerField(_property_start_offset, _property_start, _data);
new IntegerField(_sbat_start_offset, _sbat_start, _data);
new IntegerField(_sbat_block_count_offset, _sbat_count, _data);
new IntegerField(_xbat_start_offset, _xbat_start, _data);
new IntegerField(_xbat_count_offset, _xbat_count, _data);

stream.Write(_data, 0, 512);
stream.Write(_data, 0, 512);

for (int i = POIFSConstants.SMALLER_BIG_BLOCK_SIZE; i < bigBlockSize.GetBigBlockSize(); i++)
{
//stream.Write(Write(0);
stream.WriteByte(0);
}
}
catch (IOException ex)
for (int i = POIFSConstants.SMALLER_BIG_BLOCK_SIZE; i < bigBlockSize.GetBigBlockSize(); i++)
{
throw ex;
//stream.Write(Write(0);
stream.WriteByte(0);
}
}

Expand Down
Loading