#80556# make it build

This commit is contained in:
Martin Gallwey
2000-11-28 15:49:34 +00:00
parent 65de56e98c
commit 81c60a38c4
6 changed files with 78 additions and 17 deletions

View File

@@ -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 <vos/diagnose.hxx>
#endif
/*
* We impose arbitrary but reasonable limit on ZIP files.
*/

View File

@@ -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 <vector>
class ZipPackage : public cppu::WeakImplHelper4<

View File

@@ -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 <sal_uInt32> (aCRC.getValue()))
{
// boom
VOS_DEBUG_ONLY("Invalid entry crc32");
}
*/
break;
default:
// boom;

View File

@@ -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)

View File

@@ -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"));

View File

@@ -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)