summaryrefslogtreecommitdiff
path: root/package/source/zippackage
diff options
context:
space:
mode:
Diffstat (limited to 'package/source/zippackage')
-rw-r--r--package/source/zippackage/ZipPackage.cxx222
-rw-r--r--package/source/zippackage/ZipPackageFolder.cxx118
-rw-r--r--package/source/zippackage/ZipPackageStream.cxx20
3 files changed, 255 insertions, 105 deletions
diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx
index 23d0b7678368..35df1213b1ae 100644
--- a/package/source/zippackage/ZipPackage.cxx
+++ b/package/source/zippackage/ZipPackage.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ZipPackage.cxx,v $
*
- * $Revision: 1.20 $
+ * $Revision: 1.21 $
*
- * last change: $Author: mtg $ $Date: 2000-12-01 10:50:49 $
+ * last change: $Author: mtg $ $Date: 2000-12-04 11:30:09 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -83,7 +83,15 @@ ZipPackage::ZipPackage (Reference < XInputStream > &xNewInput,
, xContentSeek (xNewInput, UNO_QUERY)
, xFactory(xNewFactory)
{
- pZipFile = new ZipFile(xContentStream);
+ try
+ {
+ pZipFile = new ZipFile(xContentStream, sal_True);
+ }
+ catch (ZipException& rException)
+ {
+ VOS_DEBUG_ONLY(rException.Message);
+ }
+
xZipFile = Reference < XZipFile > ( pZipFile );
pRootFolder = new ZipPackageFolder( );
xRootFolder = Reference < XUnoTunnel > ( pRootFolder );
@@ -141,7 +149,7 @@ void ZipPackage::destroyFolderTree( Reference < XUnoTunnel > xFolder )
pFolder = reinterpret_cast < ZipPackageFolder* > (xTunnel->getSomething(ZipPackageFolder::getUnoTunnelImplementationId()));
bIsFolder = sal_True;
}
- catch (RuntimeException)
+ catch (RuntimeException&)
{
pStream = reinterpret_cast < ZipPackageStream* > (xTunnel->getSomething(ZipPackageStream::getUnoTunnelImplementationId()));
bIsFolder = sal_False;
@@ -185,7 +193,14 @@ void ZipPackage::getZipFileContents()
{
pPkgFolder = new ZipPackageFolder();//*this);
pPkgFolder->setName(sTemp);
- pPkgFolder->setParent( Reference < XInterface >(xCurrent, UNO_QUERY));
+ try
+ {
+ pPkgFolder->setParent( Reference < XInterface > (xCurrent, UNO_QUERY) );
+ }
+ catch ( NoSupportException& )
+ {
+ VOS_DEBUG_ONLY("setParent threw an exception: attempted to set Parent to non-existing interface!");
+ }
aAny <<= Reference < XUnoTunnel > (pPkgFolder);
//xCurrent->insertByName(sTemp, aAny);
xCurrent = Reference < XNameContainer > (pPkgFolder);
@@ -212,7 +227,14 @@ void ZipPackage::getZipFileContents()
{
pPkgFolder = new ZipPackageFolder();//*this);
pPkgFolder->setName(sTemp);
- pPkgFolder->setParent( Reference < XInterface >(xCurrent, UNO_QUERY));
+ try
+ {
+ pPkgFolder->setParent( Reference < XInterface >(xCurrent, UNO_QUERY));
+ }
+ catch ( NoSupportException& )
+ {
+ VOS_DEBUG_ONLY("setParent threw an exception: attempted to set Parent to non-existing interface!");
+ }
aAny <<= Reference < XUnoTunnel > (pPkgFolder);
//xCurrent->insertByName(sTemp, aAny);
xCurrent = Reference < XNameContainer > (pPkgFolder);
@@ -234,7 +256,14 @@ void ZipPackage::getZipFileContents()
aContainedZips.push_back (Reference < XSingleServiceFactory > (pInZip));
pPkgFolder = pInZip->getRootFolder();
pPkgFolder->setName(sStreamName);
- pPkgFolder->setParent( Reference < XInterface >(xCurrent, UNO_QUERY));
+ try
+ {
+ pPkgFolder->setParent( Reference < XInterface >(xCurrent, UNO_QUERY));
+ }
+ catch ( NoSupportException& )
+ {
+ VOS_DEBUG_ONLY("setParent threw an exception: attempted to set Parent to non-existing interface!");
+ }
aAny <<= Reference < XUnoTunnel > (pPkgFolder);
//xCurrent->insertByName(sStreamName, aAny);
}
@@ -244,7 +273,14 @@ void ZipPackage::getZipFileContents()
pPkgStream->bPackageMember = sal_True;
pPkgStream->setZipEntry( aEntry );
pPkgStream->setName( sStreamName );
- pPkgStream->setParent( Reference < XInterface > (xCurrent, UNO_QUERY));
+ try
+ {
+ pPkgStream->setParent( Reference < XInterface > (xCurrent, UNO_QUERY));
+ }
+ catch ( NoSupportException& )
+ {
+ VOS_DEBUG_ONLY("setParent threw an exception: attempted to set Parent to non-existing interface!");
+ }
aAny <<= Reference < XUnoTunnel > (pPkgStream);
//xCurrent->insertByName(sStreamName, aAny);
}
@@ -256,8 +292,18 @@ void ZipPackage::getZipFileContents()
Reference < XUnoTunnel > xTunnel;
aAny >>= xTunnel;
Reference < XActiveDataSink > xSink (xTunnel, UNO_QUERY);
- ManifestReader aReader(*this, xSink->getInputStream(), xFactory);
- aReader.Read();
+ if (xSink.is())
+ {
+ try
+ {
+ ManifestReader aReader(*this, xSink->getInputStream(), xFactory);
+ aReader.Read();
+ }
+ catch ( com::sun::star::xml::sax::SAXException & )
+ {
+ VOS_DEBUG_ONLY( "SAX threw an exception when reading XML Manifest!");
+ }
+ }
}
}
// XInitialization
@@ -268,13 +314,26 @@ void SAL_CALL ZipPackage::initialize( const Sequence< Any >& aArguments )
aArguments[0] >>= sURL;
pContent = new ::ucb::Content(sURL, Reference < com::sun::star::ucb::XCommandEnvironment >() );
Reference < XActiveDataSink > xSink = new ZipPackageSink;
- if (pContent->openStream ( xSink) )
- xContentStream = xSink->getInputStream();
-
- xContentSeek = Reference < XSeekable > (xContentStream, UNO_QUERY);
- pZipFile = new ZipFile(xContentStream);
- xZipFile = Reference < XZipFile > ( pZipFile );
- getZipFileContents();
+ try
+ {
+ if (pContent->openStream ( xSink) )
+ xContentStream = xSink->getInputStream();
+ xContentSeek = Reference < XSeekable > (xContentStream, UNO_QUERY);
+ try
+ {
+ pZipFile = new ZipFile(xContentStream, sal_True);
+ xZipFile = Reference < XZipFile > ( pZipFile );
+ }
+ catch (ZipException& rException)
+ {
+ VOS_DEBUG_ONLY(rException.Message);
+ }
+ getZipFileContents();
+ }
+ catch (::com::sun::star::ucb::CommandAbortedException&)
+ {
+ // File doesn't exist, we'll create it at commitChanges time
+ }
}
// XHierarchicalNameAccess
Any SAL_CALL ZipPackage::getByHierarchicalName( const OUString& aName )
@@ -339,7 +398,7 @@ Any SAL_CALL ZipPackage::getByHierarchicalName( const OUString& aName )
sal_Bool SAL_CALL ZipPackage::hasByHierarchicalName( const OUString& aName )
throw(RuntimeException)
{
- sal_Int32 nOldIndex =0,nIndex = 0;
+ sal_Int32 nOldIndex = 0, nIndex = 0;
Any aAny;
Reference < XNameContainer > xCurrent = Reference < XNameContainer > (pRootFolder);
@@ -355,7 +414,7 @@ sal_Bool SAL_CALL ZipPackage::hasByHierarchicalName( const OUString& aName )
while ((nIndex = aName.indexOf('/', nOldIndex)) != -1)
{
OUString sTemp = aName.copy (nOldIndex, nIndex - nOldIndex);
- if (nIndex == nOldIndex) //sTemp.getLength() == 1)
+ if (nIndex == nOldIndex)
break;
if (xCurrent->hasByName(sTemp))
{
@@ -375,7 +434,7 @@ sal_Bool SAL_CALL ZipPackage::hasByHierarchicalName( const OUString& aName )
while ((nIndex = aName.indexOf('/', nOldIndex)) != -1)
{
OUString sTemp = aName.copy (nOldIndex, nIndex - nOldIndex);
- if (nIndex == nOldIndex) //sTemp.getLength() == 1)
+ if (nIndex == nOldIndex)
break;
if (xCurrent->hasByName(sTemp))
{
@@ -416,10 +475,13 @@ Reference< XInterface > SAL_CALL ZipPackage::createInstanceWithArguments( const
void SAL_CALL ZipPackage::commitChanges( )
throw(WrappedTargetException, RuntimeException)
{
- Reference < XNameContainer > xMetaFolder;
- Reference < XUnoTunnel > xMetaTunnel;
std::vector < ManifestEntry * > aManList;
Any aAny;
+
+ // Set up output buffer. ZipPackageBuffer implements both
+ // XInputStream and XOutputStream as the UCB requires an XInputStream
+ // and the ZipOutputStream writes to an XOutputStream
+
ZipPackageBuffer *pZipBuffer = new ZipPackageBuffer( 65535 );
Reference < XOutputStream > xOutStream (pZipBuffer);
ZipOutputStream *pZipOut = new ZipOutputStream( xOutStream, 65535 );
@@ -427,71 +489,101 @@ void SAL_CALL ZipPackage::commitChanges( )
pZipOut->setMethod(DEFLATED);
pZipOut->setLevel(DEFAULT_COMPRESSION);
+ Reference < XNameContainer > xZipRoot = Reference < XNameContainer > (xRootFolder, UNO_QUERY);
+
sal_Bool bAddMetaFolder = sal_False;
- if (hasByHierarchicalName(OUString::createFromAscii("META-INF/")))
- {
- aAny = getByHierarchicalName(OUString::createFromAscii("META-INF/"));
- aAny >>= xMetaTunnel;
- xMetaFolder = Reference < XNameContainer > (xMetaTunnel, UNO_QUERY);
- if (xMetaFolder->hasByName(OUString::createFromAscii("manifest.xml")))
- xMetaFolder->removeByName(OUString::createFromAscii("manifest.xml"));
- }
- else
- bAddMetaFolder = sal_True;
+
+ // Remove the old META-INF directory as this will be re-generated below.
+ // Pass save-contents a vector which will be used to store the entries which
+ // are placed inside the Manifest et al. Note: saveContents is called
+ // recursively.
+
+ if (xZipRoot->hasByName(OUString::createFromAscii("META-INF")))
+ xZipRoot->removeByName(OUString::createFromAscii("META-INF"));
pRootFolder->saveContents(OUString::createFromAscii(""), aManList, *pZipOut);
- if (bAddMetaFolder)
- {
- sal_Bool bFolder = sal_True;
- aAny <<= bFolder;
- xMetaFolder = Reference < XNameContainer> (createInstanceWithArguments( Sequence < Any > (&aAny, 1)), UNO_QUERY);
- Reference < XNameContainer > xZipRoot = Reference < XNameContainer > (xRootFolder, UNO_QUERY);
- xMetaTunnel = Reference < XUnoTunnel > (xMetaFolder, UNO_QUERY);
- aAny <<= xMetaTunnel;
- xZipRoot->insertByName(OUString::createFromAscii("META-INF"), aAny);
- }
+ ZipPackageFolder *pMetaInfFolder = new ZipPackageFolder();
+ ZipPackageStream *pManifestStream = new ZipPackageStream( pZipFile );
+ aAny <<= Reference < XUnoTunnel > (pMetaInfFolder);
+ xZipRoot->insertByName(OUString::createFromAscii("META-INF"), aAny);
- Reference < XUnoTunnel > xManifestStream = Reference < XUnoTunnel > (createInstance(), UNO_QUERY);
- ZipPackageStream * pManifestStream = reinterpret_cast < ZipPackageStream * > (xManifestStream->getSomething(ZipPackageStream::getUnoTunnelImplementationId()));
ZipPackageBuffer *pBuffer = new ZipPackageBuffer(65535);
-
Reference < XOutputStream > xManOutStream (pBuffer);
+
pManifestStream->aEntry.sName = OUString::createFromAscii("META-INF/manifest.xml");
- pManifestStream->aEntry.nVersion = -1;
- pManifestStream->aEntry.nFlag = 0;
pManifestStream->aEntry.nMethod = STORED;
- pManifestStream->aEntry.nTime = -1;
- pManifestStream->aEntry.nCrc = 0;
- pManifestStream->aEntry.nOffset = -1;
pManifestStream->bPackageMember = sal_True;
- ManifestWriter aWriter ( xManOutStream, xFactory, aManList);
- aWriter.Write();
+ try
+ {
+ ManifestWriter aWriter ( xManOutStream, xFactory, aManList);
+ aWriter.Write();
+ }
+ catch ( com::sun::star::xml::sax::SAXException & )
+ {
+ VOS_DEBUG_ONLY( "SAX threw an exception when writing XML Manifest!");
+ }
+ pManifestStream->setInputStream(Reference < XInputStream > (xManOutStream, UNO_QUERY));
+
pManifestStream->aEntry.nSize = pManifestStream->aEntry.nCompressedSize = static_cast < sal_Int32 > (pBuffer->getPosition());
- pBuffer->aBuffer.realloc(static_cast < sal_Int32 > (pBuffer->getPosition()));
+ pBuffer->aBuffer.realloc(pManifestStream->aEntry.nSize);
CRC32 aCRC;
aCRC.update(pBuffer->aBuffer);
pManifestStream->aEntry.nCrc = aCRC.getValue();
- pZipOut->putNextEntry(pManifestStream->aEntry);
- pZipOut->write(pBuffer->aBuffer, 0, static_cast < sal_Int32 > (pBuffer->getPosition()));
- pZipOut->closeEntry();
+ try
+ {
+ pZipOut->putNextEntry(pManifestStream->aEntry);
+ pZipOut->write(pBuffer->aBuffer, 0, pManifestStream->aEntry.nSize);
+ pZipOut->closeEntry();
+ pZipOut->finish();
+ }
+ catch (::com::sun::star::io::IOException & )
+ {
+ VOS_DEBUG_ONLY ( "Error writing ZipOutputStream" );
+ }
- pZipOut->finish();
pZipBuffer->seek(0);
- aAny <<= xManifestStream;
- xMetaFolder->insertByName(OUString::createFromAscii("manifest.xml"), aAny);
+ aAny <<= Reference < XUnoTunnel > (pManifestStream);
+ pMetaInfFolder->insertByName(OUString::createFromAscii("manifest.xml"), aAny);
+
- pZipFile->updateFromManList( aManList );
for (sal_uInt32 i=0 ; i < aManList.size(); i++)
{
ZipEntry * pEntry = aManList[i]->pEntry;
pEntry->sName = aManList[i]->sShortName;
}
- pContent->writeStream(Reference < XInputStream > (pZipBuffer), sal_True);
+ try
+ {
+ pContent->writeStream(Reference < XInputStream > (pZipBuffer), sal_True);
+ }
+ catch (::com::sun::star::ucb::CommandAbortedException&)
+ {
+ VOS_DEBUG_ONLY( "Unable to write Zip File to disk!");
+ }
+ if (!pZipFile)
+ {
+ // If we have a valid pZipFile pointer, then we opened a stream
+ // earlier and read from it
+ // Otherwise we are writing a new ZipFile
+ xContentStream = Reference < XInputStream > (pZipBuffer);
+ xContentSeek = Reference < XSeekable > (pZipBuffer);
+ try
+ {
+ pZipFile = new ZipFile(xContentStream, sal_False);
+ xZipFile = Reference < XZipFile > ( pZipFile );
+ pRootFolder->updateReferences ( pZipFile );
+ }
+ catch (ZipException& rException)
+ {
+ VOS_DEBUG_ONLY(rException.Message);
+ }
+ }
+ pZipFile->updateFromManList( aManList );
}
+
sal_Bool SAL_CALL ZipPackage::hasPendingChanges( )
throw(RuntimeException)
{
@@ -505,14 +597,18 @@ Sequence< ElementChange > SAL_CALL ZipPackage::getPendingChanges( )
sal_Bool ZipPackage::isZipFile(com::sun::star::package::ZipEntry &rEntry)
{
- Reference < XInputStream > xContentStream = pZipFile->getInputStream(rEntry);
+ Reference < XInputStream > xEntryStream = pZipFile->getInputStream(rEntry);
Sequence < sal_Int8 > aSequence (4);
- xContentStream->readBytes(aSequence, 4);
+
+ if (xEntryStream->readBytes(aSequence, 4) < 4)
+ return sal_False;
+
sal_uInt32 nTestSig = static_cast < sal_uInt32 >
(static_cast < sal_uInt8> (aSequence[0]& 0xFF)
| static_cast < sal_uInt8> (aSequence[1]& 0xFF) << 8
| static_cast < sal_uInt8> (aSequence[2]& 0xFF) << 16
| static_cast < sal_uInt8> (aSequence[3]& 0xFF) << 24);
+
if (nTestSig == LOCSIG)
return sal_True;
else
diff --git a/package/source/zippackage/ZipPackageFolder.cxx b/package/source/zippackage/ZipPackageFolder.cxx
index 7b144699e367..4f46a974abf3 100644
--- a/package/source/zippackage/ZipPackageFolder.cxx
+++ b/package/source/zippackage/ZipPackageFolder.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ZipPackageFolder.cxx,v $
*
- * $Revision: 1.16 $
+ * $Revision: 1.17 $
*
- * last change: $Author: mtg $ $Date: 2000-12-01 10:50:49 $
+ * last change: $Author: mtg $ $Date: 2000-12-04 11:30:09 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -66,8 +66,7 @@ using namespace com::sun::star::package::ZipConstants;
using namespace com::sun::star;
using namespace rtl;
-ZipPackageFolder::ZipPackageFolder (void) //ZipOutputStream &rStream)//ZipPackage &rInPackage)
-//: rZipOut(rStream)
+ZipPackageFolder::ZipPackageFolder (void)
{
aEntry.nVersion = -1;
aEntry.nFlag = 0;
@@ -138,7 +137,14 @@ void SAL_CALL ZipPackageFolder::insertByName( const ::rtl::OUString& aName, cons
uno::Reference < uno::XInterface > xInterface (*this);
xNamed->setName (sName);
aContents[sName] = xRef;
- xChild->setParent (xInterface);
+ try
+ {
+ xChild->setParent (xInterface);
+ }
+ catch ( lang::NoSupportException& )
+ {
+ VOS_DEBUG_ONLY("setParent threw an exception: attempted to set Parent to non-existing interface!");
+ }
}
}
void SAL_CALL ZipPackageFolder::removeByName( const ::rtl::OUString& Name )
@@ -272,12 +278,13 @@ void SAL_CALL ZipPackageFolder::removeVetoableChangeListener( const ::rtl::OUStr
{
}
void ZipPackageFolder::saveContents(rtl::OUString &rPath, std::vector < ManifestEntry *> &rManList, ZipOutputStream & rZipOut)
+ throw(uno::RuntimeException)
{
uno::Reference < lang::XUnoTunnel > xTunnel;
package::ZipEntry *aEntry = NULL;
ZipPackageFolder *pFolder = NULL;
ZipPackageStream *pStream = NULL;
- sal_Bool bIsFolder;
+ sal_Bool bIsFolder = sal_False;
TunnelHash::const_iterator aCI = aContents.begin();
//rPath = rPath + getName();
@@ -285,14 +292,23 @@ void ZipPackageFolder::saveContents(rtl::OUString &rPath, std::vector < Manifest
for (;aCI!=aContents.end();aCI++)
{
xTunnel = uno::Reference < lang::XUnoTunnel> ((*aCI).second, uno::UNO_QUERY);
- try
+ sal_Int64 nTest=0;
+ if ((nTest = xTunnel->getSomething(ZipPackageFolder::getUnoTunnelImplementationId())) != 0)
{
- pFolder = reinterpret_cast < ZipPackageFolder* > (xTunnel->getSomething(ZipPackageFolder::getUnoTunnelImplementationId()));
+ pFolder = reinterpret_cast < ZipPackageFolder* > ( nTest );
bIsFolder = sal_True;
}
- catch (uno::RuntimeException)
+ else
{
- pStream = reinterpret_cast < ZipPackageStream* > (xTunnel->getSomething(ZipPackageStream::getUnoTunnelImplementationId()));
+ // If this getSomething call returns 0, it means that
+ // something evil has crept into the contents hash_map, which
+ // should mean that something has gone very wrong somewhere, and someone
+ // else should deal with it
+
+ nTest = xTunnel->getSomething(ZipPackageFolder::getUnoTunnelImplementationId());
+ if (nTest == 0)
+ throw (uno::RuntimeException());
+ pStream = reinterpret_cast < ZipPackageStream* > ( nTest );
bIsFolder = sal_False;
}
@@ -306,12 +322,18 @@ void ZipPackageFolder::saveContents(rtl::OUString &rPath, std::vector < Manifest
pFolder->aEntry.nCrc = 0;
pFolder->aEntry.nSize = 0;
pFolder->aEntry.nCompressedSize = 0;
- rZipOut.putNextEntry(pFolder->aEntry);
- rZipOut.closeEntry();
+ try
+ {
+ rZipOut.putNextEntry(pFolder->aEntry);
+ rZipOut.closeEntry();
+ }
+ catch (::com::sun::star::io::IOException & )
+ {
+ VOS_DEBUG_ONLY ( "Error writing ZipOutputStream" );
+ }
pMan->sMediaType = OUString::createFromAscii("");
pMan->pEntry = &(pFolder->aEntry);
pFolder->saveContents(pFolder->aEntry.sName, rManList, rZipOut);
- //setEntry(pMan->aEntry, pFolder->aEntry);
rManList.push_back (pMan);
}
else
@@ -337,28 +359,41 @@ void ZipPackageFolder::saveContents(rtl::OUString &rPath, std::vector < Manifest
}
}
- rZipOut.putNextEntry(pStream->aEntry);
- while (1)
+ try
{
- uno::Sequence < sal_Int8 > aSeq (65535);
- sal_Int32 nLength;
- nLength = xStream->readBytes(aSeq, 65535);
- if (nLength < 65535)
- aSeq.realloc(nLength);
- rZipOut.write(aSeq, 0, nLength);
- if (bTrackLength)
- pStream->aEntry.nSize+=nLength;
- if (nLength < 65535) // EOF
+ rZipOut.putNextEntry(pStream->aEntry);
+ while (1)
+ {
+ uno::Sequence < sal_Int8 > aSeq (65535);
+ sal_Int32 nLength;
+ nLength = xStream->readBytes(aSeq, 65535);
+ if (nLength < 65535)
+ aSeq.realloc(nLength);
+ rZipOut.write(aSeq, 0, nLength);
+ if (bTrackLength)
+ pStream->aEntry.nSize+=nLength;
+ if (nLength < 65535) // EOF
break;
+ }
+ if (bTrackLength)
+ pStream->aEntry.nCompressedSize = pStream->aEntry.nSize;
+ pStream->bPackageMember = sal_True;
+ rZipOut.closeEntry();
+ }
+ catch (::com::sun::star::io::IOException & )
+ {
+ VOS_DEBUG_ONLY ( "Error writing ZipOutputStream" );
+ }
+ try
+ {
+ uno::Any aAny = pStream->getPropertyValue(OUString::createFromAscii("MediaType"));
+ aAny >>= pMan->sMediaType;
+ }
+ catch (::com::sun::star::beans::UnknownPropertyException & )
+ {
+ VOS_DEBUG_ONLY ( "MediaType is an unknown property!!" );
}
- if (bTrackLength)
- pStream->aEntry.nCompressedSize = pStream->aEntry.nSize;
- pStream->bPackageMember = sal_True;
- rZipOut.closeEntry();
- uno::Any aAny = pStream->getPropertyValue(OUString::createFromAscii("MediaType"));
- aAny >>= pMan->sMediaType;
pMan->pEntry = &(pStream->aEntry);
- //setEntry(pMan->aEntry, pStream->aEntry);
rManList.push_back (pMan);
}
}
@@ -388,14 +423,23 @@ void ZipPackageFolder::updateReferences( ZipFile * pNewZipFile)
for (;aCI!=aContents.end();aCI++)
{
xTunnel = uno::Reference < lang::XUnoTunnel> ((*aCI).second, uno::UNO_QUERY);
- try
+ sal_Int64 nTest=0;
+ if ((nTest = xTunnel->getSomething(ZipPackageFolder::getUnoTunnelImplementationId())) != 0)
{
- pFolder = reinterpret_cast < ZipPackageFolder* > (xTunnel->getSomething(ZipPackageFolder::getUnoTunnelImplementationId()));
+ pFolder = reinterpret_cast < ZipPackageFolder* > ( nTest );
bIsFolder = sal_True;
}
- catch (uno::RuntimeException)
+ else
{
- pStream = reinterpret_cast < ZipPackageStream* > (xTunnel->getSomething(ZipPackageStream::getUnoTunnelImplementationId()));
+ // If this getSomething call returns 0, it means that
+ // something evil has crept into the contents hash_map, which
+ // should mean that something has gone very wrong somewhere, and someone
+ // else should deal with it
+
+ nTest = xTunnel->getSomething(ZipPackageFolder::getUnoTunnelImplementationId());
+ if (nTest == 0)
+ throw (uno::RuntimeException());
+ pStream = reinterpret_cast < ZipPackageStream* > ( nTest );
bIsFolder = sal_False;
}
@@ -426,7 +470,7 @@ sal_Int64 SAL_CALL ZipPackageFolder::getSomething( const uno::Sequence< sal_Int8
throw(uno::RuntimeException)
{
if (aIdentifier.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), aIdentifier.getConstArray(), 16 ) )
- return reinterpret_cast<sal_Int64>(this);
+ return reinterpret_cast < sal_Int64 > ( this );
- throw uno::RuntimeException();
+ return 0;
}
diff --git a/package/source/zippackage/ZipPackageStream.cxx b/package/source/zippackage/ZipPackageStream.cxx
index eb8475520f4b..4a425771fbad 100644
--- a/package/source/zippackage/ZipPackageStream.cxx
+++ b/package/source/zippackage/ZipPackageStream.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ZipPackageStream.cxx,v $
*
- * $Revision: 1.9 $
+ * $Revision: 1.10 $
*
- * last change: $Author: mtg $ $Date: 2000-11-29 03:21:56 $
+ * last change: $Author: mtg $ $Date: 2000-12-04 11:30:09 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -143,7 +143,17 @@ uno::Reference< io::XInputStream > SAL_CALL ZipPackageStream::getInputStream( )
throw(uno::RuntimeException)
{
if (bPackageMember)
- return pZipFile->getInputStream(aEntry);
+ {
+ try
+ {
+ return pZipFile->getInputStream(aEntry);
+ }
+ catch (package::ZipException &rException)
+ {
+ VOS_DEBUG_ONLY(rException.Message);
+ return uno::Reference < io::XInputStream > ();
+ }
+ }
else
return xStream;
}
@@ -217,7 +227,7 @@ sal_Int64 SAL_CALL ZipPackageStream::getSomething( const uno::Sequence< sal_Int8
throw(uno::RuntimeException)
{
if (aIdentifier.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), aIdentifier.getConstArray(), 16 ) )
- return reinterpret_cast<sal_Int64>(this);
+ return reinterpret_cast < sal_Int64 > ( this );
- throw uno::RuntimeException();
+ return 0;
}