summaryrefslogtreecommitdiffstats
path: root/package/source/zipapi
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2014-05-23 12:03:21 +0200
committerNoel Grandin <noel@peralex.com>2014-05-23 15:06:00 +0200
commite7bc3cab019fbf040f9fb8b53ae2cf3f977d200b (patch)
treebc507bccee9fb71134e362b72d22991561e32aa0 /package/source/zipapi
parentadd default value for Context param in uno::Exception constructors (diff)
downloadcore-e7bc3cab019fbf040f9fb8b53ae2cf3f977d200b.tar.gz
core-e7bc3cab019fbf040f9fb8b53ae2cf3f977d200b.zip
remove boilerplate in UNO Exception constructor calls
Now that we have default values for Exception constructor params, remove lots of boilerplate code. Change-Id: I620bd641eecfed38e6123873b3b94aaf47922e74
Diffstat (limited to 'package/source/zipapi')
-rw-r--r--package/source/zipapi/ByteGrabber.cxx6
-rw-r--r--package/source/zipapi/XUnbufferedStream.cxx20
-rw-r--r--package/source/zipapi/ZipFile.cxx79
-rw-r--r--package/source/zipapi/ZipOutputStream.cxx13
-rw-r--r--package/source/zipapi/blowfishcontext.cxx9
-rw-r--r--package/source/zipapi/sha1context.cxx3
6 files changed, 55 insertions, 75 deletions
diff --git a/package/source/zipapi/ByteGrabber.cxx b/package/source/zipapi/ByteGrabber.cxx
index 2b0b049a4c04..8b670ff80726 100644
--- a/package/source/zipapi/ByteGrabber.cxx
+++ b/package/source/zipapi/ByteGrabber.cxx
@@ -77,7 +77,7 @@ sal_Int64 SAL_CALL ByteGrabber::seek( sal_Int64 location )
return location;
}
else
- throw io::IOException(THROW_WHERE, uno::Reference< uno::XInterface >() );
+ throw io::IOException(THROW_WHERE );
}
sal_Int64 SAL_CALL ByteGrabber::getPosition( )
@@ -87,7 +87,7 @@ sal_Int64 SAL_CALL ByteGrabber::getPosition( )
if (xSeek.is() )
return xSeek->getPosition();
else
- throw io::IOException(THROW_WHERE, uno::Reference< uno::XInterface >() );
+ throw io::IOException(THROW_WHERE );
}
sal_Int64 SAL_CALL ByteGrabber::getLength( )
@@ -97,7 +97,7 @@ sal_Int64 SAL_CALL ByteGrabber::getLength( )
if (xSeek.is() )
return xSeek->getLength();
else
- throw io::IOException(THROW_WHERE, uno::Reference< uno::XInterface >() );
+ throw io::IOException(THROW_WHERE );
}
ByteGrabber& ByteGrabber::operator >> (sal_Int8& rInt8)
diff --git a/package/source/zipapi/XUnbufferedStream.cxx b/package/source/zipapi/XUnbufferedStream.cxx
index 1488c3b9d7af..ff1e15135dfd 100644
--- a/package/source/zipapi/XUnbufferedStream.cxx
+++ b/package/source/zipapi/XUnbufferedStream.cxx
@@ -78,7 +78,7 @@ XUnbufferedStream::XUnbufferedStream(
}
if (mnZipSize < 0)
- throw ZipIOException("The stream seems to be broken!", uno::Reference< XInterface >());
+ throw ZipIOException("The stream seems to be broken!");
bool bHaveEncryptData = ( rData.is() && rData->m_aSalt.getLength() && rData->m_aInitVector.getLength() && rData->m_nIterationCount != 0 ) ? sal_True : sal_False;
bool bMustDecrypt = ( nStreamMode == UNBUFF_STREAM_DATA && bHaveEncryptData && bIsEncrypted ) ? sal_True : sal_False;
@@ -229,16 +229,13 @@ sal_Int32 SAL_CALL XUnbufferedStream::readBytes( Sequence< sal_Int8 >& aData, sa
if ( nRead > nRequestedBytes )
throw RuntimeException(
- "Should not be possible to read more then requested!",
- Reference< XInterface >() );
+ "Should not be possible to read more then requested!" );
if ( maInflater.finished() || maInflater.getLastInflateError() )
- throw ZipIOException("The stream seems to be broken!",
- Reference< XInterface >() );
+ throw ZipIOException("The stream seems to be broken!" );
if ( maInflater.needsDictionary() )
- throw ZipIOException("Dictionaries are not supported!",
- Reference< XInterface >() );
+ throw ZipIOException("Dictionaries are not supported!" );
sal_Int32 nDiff = static_cast< sal_Int32 >( mnZipEnd - mnZipCurrent );
if ( nDiff > 0 )
@@ -252,8 +249,7 @@ sal_Int32 SAL_CALL XUnbufferedStream::readBytes( Sequence< sal_Int8 >& aData, sa
sal_Int32 nZipRead = mxZipStream->readBytes( maCompBuffer, nToRead );
if ( nZipRead < nToRead )
- throw ZipIOException("No expected data!",
- Reference< XInterface >() );
+ throw ZipIOException("No expected data!" );
mnZipCurrent += nZipRead;
// maCompBuffer now has the data, check if we need to decrypt
@@ -279,8 +275,7 @@ sal_Int32 SAL_CALL XUnbufferedStream::readBytes( Sequence< sal_Int8 >& aData, sa
}
else
{
- throw ZipIOException("The stream seems to be broken!",
- Reference< XInterface >() );
+ throw ZipIOException("The stream seems to be broken!" );
}
}
}
@@ -296,8 +291,7 @@ sal_Int32 SAL_CALL XUnbufferedStream::readBytes( Sequence< sal_Int8 >& aData, sa
maCRC.update( aData );
if ( mnZipSize + maHeader.getLength() == mnMyCurrent && maCRC.getValue() != maEntry.nCrc )
- throw ZipIOException("The stream seems to be broken!",
- Reference< XInterface >() );
+ throw ZipIOException("The stream seems to be broken!" );
}
}
diff --git a/package/source/zipapi/ZipFile.cxx b/package/source/zipapi/ZipFile.cxx
index 2c8d7e856454..493a6cb49622 100644
--- a/package/source/zipapi/ZipFile.cxx
+++ b/package/source/zipapi/ZipFile.cxx
@@ -79,7 +79,7 @@ ZipFile::ZipFile( uno::Reference < XInputStream > &xInput, const uno::Reference
if ( readCEN() == -1 )
{
aEntries.clear();
- throw ZipException( "stream data looks to be broken", uno::Reference < XInterface > () );
+ throw ZipException( "stream data looks to be broken" );
}
}
}
@@ -103,7 +103,7 @@ ZipFile::ZipFile( uno::Reference < XInputStream > &xInput, const uno::Reference
else if ( readCEN() == -1 )
{
aEntries.clear();
- throw ZipException("stream data looks to be broken", uno::Reference < XInterface > () );
+ throw ZipException("stream data looks to be broken" );
}
}
}
@@ -149,8 +149,7 @@ uno::Reference< xml::crypto::XCipherContext > ZipFile::StaticGetCipher( const un
{
if (xEncryptionData->m_nDerivedKeySize < 0)
{
- throw ZipIOException("Invalid derived key length!",
- uno::Reference< XInterface >() );
+ throw ZipIOException("Invalid derived key length!" );
}
uno::Sequence< sal_Int8 > aDerivedKey( xEncryptionData->m_nDerivedKeySize );
@@ -162,8 +161,7 @@ uno::Reference< xml::crypto::XCipherContext > ZipFile::StaticGetCipher( const un
xEncryptionData->m_aSalt.getLength(),
xEncryptionData->m_nIterationCount ) )
{
- throw ZipIOException("Can not create derived key!",
- uno::Reference< XInterface >() );
+ throw ZipIOException("Can not create derived key!" );
}
if ( xEncryptionData->m_nEncAlg == xml::crypto::CipherID::AES_CBC_W3C_PADDING )
@@ -182,8 +180,7 @@ uno::Reference< xml::crypto::XCipherContext > ZipFile::StaticGetCipher( const un
}
else
{
- throw ZipIOException("Unknown cipher algorithm is requested!",
- uno::Reference< XInterface >() );
+ throw ZipIOException("Unknown cipher algorithm is requested!" );
}
}
catch( ... )
@@ -384,16 +381,14 @@ uno::Reference< XInputStream > ZipFile::StaticGetDataFromRawStream( const uno::R
throw ( packages::WrongPasswordException, ZipIOException, RuntimeException )
{
if ( !rData.is() )
- throw ZipIOException("Encrypted stream without encryption data!\n",
- uno::Reference< XInterface >() );
+ throw ZipIOException("Encrypted stream without encryption data!\n" );
if ( !rData->m_aKey.getLength() )
- throw packages::WrongPasswordException(THROW_WHERE, uno::Reference< uno::XInterface >() );
+ throw packages::WrongPasswordException(THROW_WHERE );
uno::Reference< XSeekable > xSeek( xStream, UNO_QUERY );
if ( !xSeek.is() )
- throw ZipIOException("The stream must be seekable!\n",
- uno::Reference< XInterface >() );
+ throw ZipIOException("The stream must be seekable!\n" );
// if we have a digest, then this file is an encrypted one and we should
// check if we can decrypt it or not
@@ -414,7 +409,7 @@ uno::Reference< XInputStream > ZipFile::StaticGetDataFromRawStream( const uno::R
xStream->readBytes( aReadBuffer, nSize );
if ( !StaticHasValidPassword( rxContext, aReadBuffer, rData ) )
- throw packages::WrongPasswordException(THROW_WHERE, uno::Reference< uno::XInterface >() );
+ throw packages::WrongPasswordException(THROW_WHERE );
}
return new XUnbufferedStream( rxContext, xStream, rData );
@@ -580,14 +575,13 @@ uno::Reference< XInputStream > SAL_CALL ZipFile::getDataStream( ZipEntry& rEntry
// in case no digest is provided there is no way
// to detect password correctness
if ( !rData.is() )
- throw ZipException("Encrypted stream without encryption data!\n",
- uno::Reference< XInterface >() );
+ throw ZipException("Encrypted stream without encryption data!" );
// if we have a digest, then this file is an encrypted one and we should
// check if we can decrypt it or not
OSL_ENSURE( rData->m_aDigest.getLength(), "Can't detect password correctness without digest!\n" );
if ( rData->m_aDigest.getLength() && !hasValidPassword ( rEntry, rData ) )
- throw packages::WrongPasswordException(THROW_WHERE, uno::Reference< uno::XInterface >() );
+ throw packages::WrongPasswordException(THROW_WHERE );
}
else
bNeedRawStream = ( rEntry.nMethod == STORED );
@@ -626,7 +620,7 @@ uno::Reference< XInputStream > SAL_CALL ZipFile::getWrappedRawStream(
::osl::MutexGuard aGuard( m_aMutex );
if ( !rData.is() )
- throw packages::NoEncryptionException(THROW_WHERE, uno::Reference< uno::XInterface >() );
+ throw packages::NoEncryptionException(THROW_WHERE );
if ( rEntry.nOffset <= 0 )
readLOC( rEntry );
@@ -647,7 +641,7 @@ bool ZipFile::readLOC( ZipEntry &rEntry )
aGrabber >> nTestSig;
if (nTestSig != LOCSIG)
- throw ZipIOException("Invalid LOC header (bad signature)", uno::Reference < XInterface > () );
+ throw ZipIOException("Invalid LOC header (bad signature)" );
aGrabber >> nVersion;
aGrabber >> nFlag;
aGrabber >> nHow;
@@ -701,8 +695,7 @@ bool ZipFile::readLOC( ZipEntry &rEntry )
}
if ( bBroken && !bRecoveryMode )
- throw ZipIOException("The stream seems to be broken!",
- uno::Reference< XInterface >() );
+ throw ZipIOException("The stream seems to be broken!" );
return true;
}
@@ -736,17 +729,17 @@ sal_Int32 ZipFile::findEND( )
}
catch ( IllegalArgumentException& )
{
- throw ZipException("Zip END signature not found!", uno::Reference < XInterface > () );
+ throw ZipException("Zip END signature not found!" );
}
catch ( NotConnectedException& )
{
- throw ZipException("Zip END signature not found!", uno::Reference < XInterface > () );
+ throw ZipException("Zip END signature not found!" );
}
catch ( BufferSizeExceededException& )
{
- throw ZipException("Zip END signature not found!", uno::Reference < XInterface > () );
+ throw ZipException("Zip END signature not found!" );
}
- throw ZipException("Zip END signature not found!", uno::Reference < XInterface > () );
+ throw ZipException("Zip END signature not found!" );
}
sal_Int32 ZipFile::readCEN()
@@ -767,25 +760,25 @@ sal_Int32 ZipFile::readCEN()
aGrabber >> nCenOff;
if ( nTotal * CENHDR > nCenLen )
- throw ZipException("invalid END header (bad entry count)", uno::Reference < XInterface > () );
+ throw ZipException("invalid END header (bad entry count)" );
if ( nTotal > ZIP_MAXENTRIES )
- throw ZipException("too many entries in ZIP File", uno::Reference < XInterface > () );
+ throw ZipException("too many entries in ZIP File" );
if ( nCenLen < 0 || nCenLen > nEndPos )
- throw ZipException("Invalid END header (bad central directory size)", uno::Reference < XInterface > () );
+ throw ZipException("Invalid END header (bad central directory size)" );
nCenPos = nEndPos - nCenLen;
if ( nCenOff < 0 || nCenOff > nCenPos )
- throw ZipException("Invalid END header (bad central directory size)", uno::Reference < XInterface > () );
+ throw ZipException("Invalid END header (bad central directory size)" );
nLocPos = nCenPos - nCenOff;
aGrabber.seek( nCenPos );
Sequence < sal_Int8 > aCENBuffer ( nCenLen );
sal_Int64 nRead = aGrabber.readBytes ( aCENBuffer, nCenLen );
if ( static_cast < sal_Int64 > ( nCenLen ) != nRead )
- throw ZipException ("Error reading CEN into memory buffer!", uno::Reference < XInterface > () );
+ throw ZipException ("Error reading CEN into memory buffer!" );
MemoryByteGrabber aMemGrabber ( aCENBuffer );
@@ -797,19 +790,19 @@ sal_Int32 ZipFile::readCEN()
{
aMemGrabber >> nTestSig;
if ( nTestSig != CENSIG )
- throw ZipException("Invalid CEN header (bad signature)", uno::Reference < XInterface > () );
+ throw ZipException("Invalid CEN header (bad signature)" );
aMemGrabber.skipBytes ( 2 );
aMemGrabber >> aEntry.nVersion;
if ( ( aEntry.nVersion & 1 ) == 1 )
- throw ZipException("Invalid CEN header (encrypted entry)", uno::Reference < XInterface > () );
+ throw ZipException("Invalid CEN header (encrypted entry)" );
aMemGrabber >> aEntry.nFlag;
aMemGrabber >> aEntry.nMethod;
if ( aEntry.nMethod != STORED && aEntry.nMethod != DEFLATED)
- throw ZipException("Invalid CEN header (bad compression method)", uno::Reference < XInterface > () );
+ throw ZipException("Invalid CEN header (bad compression method)" );
aMemGrabber >> aEntry.nTime;
aMemGrabber >> aEntry.nCrc;
@@ -828,7 +821,7 @@ sal_Int32 ZipFile::readCEN()
if ( nSize == 0xffffffff ||
nOffset == 0xffffffff ||
nCompressedSize == 0xffffffff ) {
- throw ZipException("PK64 zip file entry", uno::Reference < XInterface > () );
+ throw ZipException("PK64 zip file entry" );
} else {
aEntry.nCompressedSize = nCompressedSize;
aEntry.nSize = nSize;
@@ -839,13 +832,13 @@ sal_Int32 ZipFile::readCEN()
aEntry.nOffset *= -1;
if ( aEntry.nPathLen < 0 )
- throw ZipException("unexpected name length", uno::Reference < XInterface > () );
+ throw ZipException("unexpected name length" );
if ( nCommentLen < 0 )
- throw ZipException("unexpected comment length", uno::Reference < XInterface > () );
+ throw ZipException("unexpected comment length" );
if ( aEntry.nExtraLen < 0 )
- throw ZipException("unexpected extra header info length", uno::Reference < XInterface > () );
+ throw ZipException("unexpected extra header info length" );
// read always in UTF8, some tools seem not to set UTF8 bit
aEntry.sPath = OUString::intern ( (sal_Char *) aMemGrabber.getCurrentPos(),
@@ -853,14 +846,14 @@ sal_Int32 ZipFile::readCEN()
RTL_TEXTENCODING_UTF8 );
if ( !::comphelper::OStorageHelper::IsValidZipEntryFileName( aEntry.sPath, true ) )
- throw ZipException("Zip entry has an invalid name.", uno::Reference < XInterface > () );
+ throw ZipException("Zip entry has an invalid name." );
aMemGrabber.skipBytes( aEntry.nPathLen + aEntry.nExtraLen + nCommentLen );
aEntries[aEntry.sPath] = aEntry;
}
if (nCount != nTotal)
- throw ZipException("Count != Total", uno::Reference < XInterface > () );
+ throw ZipException("Count != Total" );
}
catch ( IllegalArgumentException & )
{
@@ -924,7 +917,7 @@ sal_Int32 ZipFile::recover()
// FIXME64: need to read the 64bit header instead
if ( nSize == 0xffffffff ||
nCompressedSize == 0xffffffff ) {
- throw ZipException("PK64 zip file entry", uno::Reference < XInterface > () );
+ throw ZipException("PK64 zip file entry" );
} else {
aEntry.nCompressedSize = nCompressedSize;
aEntry.nSize = nSize;
@@ -1040,15 +1033,15 @@ sal_Int32 ZipFile::recover()
}
catch ( IllegalArgumentException& )
{
- throw ZipException("Zip END signature not found!", uno::Reference < XInterface > () );
+ throw ZipException("Zip END signature not found!" );
}
catch ( NotConnectedException& )
{
- throw ZipException("Zip END signature not found!", uno::Reference < XInterface > () );
+ throw ZipException("Zip END signature not found!" );
}
catch ( BufferSizeExceededException& )
{
- throw ZipException("Zip END signature not found!", uno::Reference < XInterface > () );
+ throw ZipException("Zip END signature not found!" );
}
}
diff --git a/package/source/zipapi/ZipOutputStream.cxx b/package/source/zipapi/ZipOutputStream.cxx
index b6bc5cfaf494..cd4f9e797f64 100644
--- a/package/source/zipapi/ZipOutputStream.cxx
+++ b/package/source/zipapi/ZipOutputStream.cxx
@@ -319,7 +319,7 @@ void ZipOutputStream::writeCEN( const ZipEntry &rEntry )
throw(IOException, RuntimeException)
{
if ( !::comphelper::OStorageHelper::IsValidZipEntryFileName( rEntry.sPath, true ) )
- throw IOException("Unexpected character is used in file name.", uno::Reference< XInterface >() );
+ throw IOException("Unexpected character is used in file name." );
OString sUTF8Name = OUStringToOString( rEntry.sPath, RTL_TEXTENCODING_UTF8 );
sal_Int16 nNameLength = static_cast < sal_Int16 > ( sUTF8Name.getLength() );
@@ -359,8 +359,7 @@ void ZipOutputStream::writeCEN( const ZipEntry &rEntry )
// FIXME64: need to append a ZIP64 header instead of throwing
// We're about to silently lose people's data - which they are
// unlikely to appreciate so fail instead:
- throw IOException( "File contains streams that are too large.",
- uno::Reference< XInterface >() );
+ throw IOException( "File contains streams that are too large." );
}
Sequence < sal_Int8 > aSequence( (sal_Int8*)sUTF8Name.getStr(), sUTF8Name.getLength() );
@@ -381,8 +380,7 @@ void ZipOutputStream::writeEXT( const ZipEntry &rEntry )
// FIXME64: need to append a ZIP64 header instead of throwing
// We're about to silently lose people's data - which they are
// unlikely to appreciate so fail instead:
- throw IOException( "File contains streams that are too large.",
- uno::Reference< XInterface >() );
+ throw IOException( "File contains streams that are too large." );
}
}
@@ -390,7 +388,7 @@ sal_Int32 ZipOutputStream::writeLOC( const ZipEntry &rEntry )
throw(IOException, RuntimeException)
{
if ( !::comphelper::OStorageHelper::IsValidZipEntryFileName( rEntry.sPath, true ) )
- throw IOException("Unexpected character is used in file name.", uno::Reference< XInterface >() );
+ throw IOException("Unexpected character is used in file name." );
OString sUTF8Name = OUStringToOString( rEntry.sPath, RTL_TEXTENCODING_UTF8 );
sal_Int16 nNameLength = static_cast < sal_Int16 > ( sUTF8Name.getLength() );
@@ -435,8 +433,7 @@ sal_Int32 ZipOutputStream::writeLOC( const ZipEntry &rEntry )
// FIXME64: need to append a ZIP64 header instead of throwing
// We're about to silently lose people's data - which they are
// unlikely to appreciate so fail instead:
- throw IOException( "File contains streams that are too large.",
- uno::Reference< XInterface >() );
+ throw IOException( "File contains streams that are too large." );
}
Sequence < sal_Int8 > aSequence( (sal_Int8*)sUTF8Name.getStr(), sUTF8Name.getLength() );
diff --git a/package/source/zipapi/blowfishcontext.cxx b/package/source/zipapi/blowfishcontext.cxx
index fac26fba52d6..f60f299d7bca 100644
--- a/package/source/zipapi/blowfishcontext.cxx
+++ b/package/source/zipapi/blowfishcontext.cxx
@@ -30,8 +30,7 @@ uno::Reference< xml::crypto::XCipherContext > BlowfishCFB8CipherContext::Create(
::rtl::Reference< BlowfishCFB8CipherContext > xResult = new BlowfishCFB8CipherContext();
xResult->m_pCipher = rtl_cipher_create( rtl_Cipher_AlgorithmBF, rtl_Cipher_ModeStream );
if ( !xResult->m_pCipher )
- throw uno::RuntimeException("Can not create cipher!",
- uno::Reference< XInterface >() );
+ throw uno::RuntimeException("Can not create cipher!" );
if ( rtl_Cipher_E_None != rtl_cipher_init(
xResult->m_pCipher,
@@ -41,8 +40,7 @@ uno::Reference< xml::crypto::XCipherContext > BlowfishCFB8CipherContext::Create(
reinterpret_cast< const sal_uInt8* >( aInitVector.getConstArray() ),
aInitVector.getLength() ) )
{
- throw uno::RuntimeException("Can not initialize cipher!",
- uno::Reference< XInterface >() );
+ throw uno::RuntimeException("Can not initialize cipher!" );
}
xResult->m_bEncrypt = bEncrypt;
@@ -88,8 +86,7 @@ uno::Sequence< sal_Int8 > SAL_CALL BlowfishCFB8CipherContext::convertWithCipherC
if ( rtl_Cipher_E_None != nError )
{
- throw uno::RuntimeException("Can not decrypt/encrypt with cipher!",
- uno::Reference< uno::XInterface >() );
+ throw uno::RuntimeException("Can not decrypt/encrypt with cipher!" );
}
return aResult;
diff --git a/package/source/zipapi/sha1context.cxx b/package/source/zipapi/sha1context.cxx
index ba8e782eaaac..b300aba71d8d 100644
--- a/package/source/zipapi/sha1context.cxx
+++ b/package/source/zipapi/sha1context.cxx
@@ -30,8 +30,7 @@ uno::Reference< xml::crypto::XDigestContext > SHA1DigestContext::Create()
::rtl::Reference< SHA1DigestContext > xResult = new SHA1DigestContext();
xResult->m_pDigest = rtl_digest_createSHA1();
if ( !xResult->m_pDigest )
- throw uno::RuntimeException("Can not create cipher!",
- uno::Reference< XInterface >() );
+ throw uno::RuntimeException("Can not create cipher!" );
return uno::Reference< xml::crypto::XDigestContext >( xResult.get() );
}