diff --git a/package/inc/ZipFile.hxx b/package/inc/ZipFile.hxx index 82d2b5071e63..0f11195fe6d0 100644 --- a/package/inc/ZipFile.hxx +++ b/package/inc/ZipFile.hxx @@ -2,9 +2,9 @@ * * $RCSfile: ZipFile.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: mtg $ $Date: 2000-11-24 10:34:26 $ + * last change: $Author: mtg $ $Date: 2000-11-28 16:49:34 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -85,6 +85,10 @@ #include "ByteGrabber.hxx" #endif +#ifndef _VOS_DIAGNOSE_H_ +#include +#endif + /* * We impose arbitrary but reasonable limit on ZIP files. */ diff --git a/package/inc/ZipPackage.hxx b/package/inc/ZipPackage.hxx index 82de1cf448b0..413d11ab91ca 100644 --- a/package/inc/ZipPackage.hxx +++ b/package/inc/ZipPackage.hxx @@ -2,9 +2,9 @@ * * $RCSfile: ZipPackage.hxx,v $ * - * $Revision: 1.10 $ + * $Revision: 1.11 $ * - * last change: $Author: mtg $ $Date: 2000-11-28 10:10:41 $ + * last change: $Author: mtg $ $Date: 2000-11-28 16:49:34 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -125,6 +125,10 @@ #include "ManifestWriter.hxx" #endif +#ifndef _MANIFEST_READER_HXX +#include "ManifestReader.hxx" +#endif + #include class ZipPackage : public cppu::WeakImplHelper4< diff --git a/package/source/zipapi/ZipOutputStream.cxx b/package/source/zipapi/ZipOutputStream.cxx index c775e554238e..055b5092dbd3 100644 --- a/package/source/zipapi/ZipOutputStream.cxx +++ b/package/source/zipapi/ZipOutputStream.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ZipOutputStream.cxx,v $ * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * - * last change: $Author: mtg $ $Date: 2000-11-28 13:13:29 $ + * last change: $Author: mtg $ $Date: 2000-11-28 16:49:07 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -126,12 +126,20 @@ void SAL_CALL ZipOutputStream::putNextEntry( const package::ZipEntry& rEntry ) pNonConstEntry->nVersion = 20; break; case STORED: + /* if (pNonConstEntry->nSize == -1) pNonConstEntry->nSize = pNonConstEntry->nCompressedSize; else if (pNonConstEntry->nCompressedSize == -1 || pNonConstEntry->nCompressedSize == 0) pNonConstEntry->nCompressedSize = pNonConstEntry->nSize; - pNonConstEntry->nVersion = 10; pNonConstEntry->nFlag = 0; + */ + pNonConstEntry->nVersion = 10; + if (pNonConstEntry->nSize == -1 || pNonConstEntry->nCompressedSize == -1 || + pNonConstEntry->nCrc == -1) + pNonConstEntry->nFlag = 8; + else if (pNonConstEntry->nSize != -1 && pNonConstEntry->nCompressedSize != -1 && + pNonConstEntry->nCrc != -1) + pNonConstEntry->nFlag = 0; break; } pNonConstEntry->nOffset = aChucker.getPosition(); @@ -185,12 +193,17 @@ void SAL_CALL ZipOutputStream::closeEntry( ) aDeflater.reset(); break; case STORED: + + pEntry->nCrc = aCRC.getValue(); + writeEXT(*pEntry); + /* if (static_cast < sal_uInt32 > (pEntry->nCrc) != static_cast (aCRC.getValue())) { // boom VOS_DEBUG_ONLY("Invalid entry crc32"); } + */ break; default: // boom; diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx index 00eda2eafd52..794e9bb6202c 100644 --- a/package/source/zippackage/ZipPackage.cxx +++ b/package/source/zippackage/ZipPackage.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ZipPackage.cxx,v $ * - * $Revision: 1.15 $ + * $Revision: 1.16 $ * - * last change: $Author: mtg $ $Date: 2000-11-28 12:07:00 $ + * last change: $Author: mtg $ $Date: 2000-11-28 16:48:39 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -318,6 +318,15 @@ void SAL_CALL ZipPackage::initialize( const Sequence< Any >& aArguments ) } } } + if (hasByHierarchicalName(OUString::createFromAscii("META-INF/manifest.xml"))) + { + Any aAny = getByHierarchicalName(OUString::createFromAscii("META-INF/manifest.xml")); + Reference < XUnoTunnel > xTunnel; + aAny >>= xTunnel; + Reference < XActiveDataSink > xSink (xTunnel, UNO_QUERY); + ManifestReader aReader(*this, xSink->getInputStream(), xFactory); + aReader.Read(); + } } // XHierarchicalNameAccess Any SAL_CALL ZipPackage::getByHierarchicalName( const OUString& aName ) @@ -347,10 +356,15 @@ Any SAL_CALL ZipPackage::getByHierarchicalName( const OUString& aName ) aAny >>= xRef; xCurrent = Reference < XNameContainer > (xRef, UNO_QUERY); } + else + throw (NoSuchElementException()); nOldIndex = nIndex+1; } OUString sStreamName = aName.copy( nOldIndex, aName.getLength() - nOldIndex); - aAny <<= xCurrent->getByName(sStreamName); + if (xCurrent->hasByName(sStreamName)) + aAny <<= xCurrent->getByName(sStreamName); + else + throw (NoSuchElementException()); } else { @@ -366,11 +380,16 @@ Any SAL_CALL ZipPackage::getByHierarchicalName( const OUString& aName ) aAny >>= xChildRef; xCurrent = Reference < XNameContainer > (xChildRef, UNO_QUERY); } + else + throw (NoSuchElementException()); + nOldIndex = nIndex+1; } OUString sStreamName = aName.copy( nOldIndex, aName.getLength() - nOldIndex); - - aAny <<= xCurrent->getByName(sStreamName); + if (xCurrent->hasByName(sStreamName)) + aAny <<= xCurrent->getByName(sStreamName); + else + throw (NoSuchElementException()); } return aAny; } @@ -402,6 +421,8 @@ sal_Bool SAL_CALL ZipPackage::hasByHierarchicalName( const OUString& aName ) aAny >>= xRef; xCurrent = Reference < XNameContainer > (xRef, UNO_QUERY); } + else + return sal_False; nOldIndex = nIndex+1; } OUString sStreamName = aName.copy( nOldIndex, aName.getLength() - nOldIndex); @@ -421,6 +442,8 @@ sal_Bool SAL_CALL ZipPackage::hasByHierarchicalName( const OUString& aName ) aAny >>= xChildRef; xCurrent = Reference < XNameContainer > (xChildRef, UNO_QUERY); } + else + return sal_False; nOldIndex = nIndex+1; } OUString sStreamName = aName.copy( nOldIndex, aName.getLength() - nOldIndex); @@ -458,6 +481,13 @@ void SAL_CALL ZipPackage::commitChanges( ) pFoo->closeInput(); #else std::vector < ManifestEntry * > aManList; + if (hasByHierarchicalName(OUString::createFromAscii("META-INF/manifest.xml"))) + { + Any aAny = getByHierarchicalName(OUString::createFromAscii("META-INF/")); + Reference < XNameContainer > xCont; + aAny >>= xCont; + xCont->removeByName(OUString::createFromAscii("manifest.xml")); + } pRootFolder->saveContents(OUString::createFromAscii(""), aManList); #endif ZipEntry *pEntry = new ZipEntry; @@ -481,6 +511,8 @@ void SAL_CALL ZipPackage::commitChanges( ) pZipOut->write(pBuffer->aBuffer, 0, pBuffer->getPosition()); pZipOut->closeEntry(); pZipOut->finish(); + pZipBuffer->seek(0); + pContent->writeStream(Reference < XInputStream > (pZipBuffer), sal_True); } sal_Bool SAL_CALL ZipPackage::hasPendingChanges( ) throw(RuntimeException) diff --git a/package/source/zippackage/ZipPackageFolder.cxx b/package/source/zippackage/ZipPackageFolder.cxx index b2e792740752..829c6185ae32 100644 --- a/package/source/zippackage/ZipPackageFolder.cxx +++ b/package/source/zippackage/ZipPackageFolder.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ZipPackageFolder.cxx,v $ * - * $Revision: 1.10 $ + * $Revision: 1.11 $ * - * last change: $Author: mtg $ $Date: 2000-11-28 12:07:00 $ + * last change: $Author: mtg $ $Date: 2000-11-28 16:48:39 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -200,7 +200,8 @@ sal_Bool SAL_CALL ZipPackageFolder::hasByName( const ::rtl::OUString& aName ) sName = aName.copy(1, aName.getLength()); else sName = aName; - return aContents.find(sName) != aContents.end(); + //return !(aContents.find(sName) == aContents.end()); + return aContents.count(sName); } // XNameReplace void SAL_CALL ZipPackageFolder::replaceByName( const ::rtl::OUString& aName, const uno::Any& aElement ) @@ -341,6 +342,8 @@ void ZipPackageFolder::saveContents(rtl::OUString &rPath, std::vector < Manifest pStream->aEntry.nSize = -1; pStream->aEntry.nCompressedSize = -1; rZipOut.putNextEntry(pStream->aEntry); + if (pStream->aEntry.nMethod == STORED) + pStream->aEntry.nSize = 0; while (1) { uno::Sequence < sal_Int8 > aSeq (65535); @@ -349,9 +352,13 @@ void ZipPackageFolder::saveContents(rtl::OUString &rPath, std::vector < Manifest if (nLength < 65535) aSeq.realloc(nLength); rZipOut.write(aSeq, 0, nLength); + if (pStream->aEntry.nMethod == STORED) + pStream->aEntry.nSize +=nLength; if (nLength < 65535) // EOF break; } + if (pStream->aEntry.nMethod == STORED) + pStream->aEntry.nCompressedSize = pStream->aEntry.nSize; rZipOut.closeEntry(); ManifestEntry *pMan = new ManifestEntry; uno::Any aAny = pStream->getPropertyValue(OUString::createFromAscii("MediaType")); diff --git a/package/source/zippackage/ZipPackageStream.cxx b/package/source/zippackage/ZipPackageStream.cxx index b94435647515..dc43c144c739 100644 --- a/package/source/zippackage/ZipPackageStream.cxx +++ b/package/source/zippackage/ZipPackageStream.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ZipPackageStream.cxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: mtg $ $Date: 2000-11-27 16:57:09 $ + * last change: $Author: mtg $ $Date: 2000-11-28 16:48:39 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -137,6 +137,7 @@ void SAL_CALL ZipPackageStream::setInputStream( const uno::Reference< io::XInput { xStream = aStream; bPackageMember = sal_False; + aEntry.nTime = -1; } uno::Reference< io::XInputStream > SAL_CALL ZipPackageStream::getInputStream( ) throw(uno::RuntimeException)