#80556# Initial revision of manifest support + ignores leading slash in zip package folders
This commit is contained in:
@@ -2,9 +2,9 @@
|
||||
*
|
||||
* $RCSfile: ZipPackage.cxx,v $
|
||||
*
|
||||
* $Revision: 1.10 $
|
||||
* $Revision: 1.11 $
|
||||
*
|
||||
* last change: $Author: mtg $ $Date: 2000-11-27 16:10:30 $
|
||||
* last change: $Author: mtg $ $Date: 2000-11-27 16:55:07 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
@@ -301,6 +301,8 @@ void SAL_CALL ZipPackage::initialize( const Sequence< Any >& aArguments )
|
||||
pPkgStream->setParent( Reference < XInterface > (xCurrent, UNO_QUERY));
|
||||
pPkgStream->setZipEntry( aEntry );
|
||||
pPkgStream->setName( sStreamName );
|
||||
aAny <<= OUString::createFromAscii("text/plain");
|
||||
pPkgStream->setPropertyValue(OUString::createFromAscii("MediaType"), aAny);
|
||||
aAny <<= Reference < XUnoTunnel > (pPkgStream);
|
||||
xCurrent->insertByName(sStreamName, aAny);
|
||||
}
|
||||
@@ -368,7 +370,15 @@ sal_Bool SAL_CALL ZipPackage::hasByHierarchicalName( const OUString& aName )
|
||||
sal_Int32 nOldIndex =0,nIndex = 0;
|
||||
Any aAny;
|
||||
Reference < XNameContainer > xCurrent = Reference < XNameContainer > (pRootFolder);
|
||||
if (aName.lastIndexOf('/') == aName.getLength()-1)
|
||||
|
||||
if (aName[nOldIndex] == '/')
|
||||
nOldIndex++;
|
||||
|
||||
if (aName == OUString::createFromAscii("/"))
|
||||
{
|
||||
return sal_True;
|
||||
}
|
||||
else if (aName.lastIndexOf('/') == aName.getLength()-1)
|
||||
{
|
||||
while ((nIndex = aName.indexOf('/', nOldIndex)) != -1)
|
||||
{
|
||||
@@ -433,12 +443,31 @@ void SAL_CALL ZipPackage::commitChanges( )
|
||||
{
|
||||
#ifdef _DEBUG_RECURSION_
|
||||
TestZip *pFoo = new TestZip(L"e:/clean/foo.txt", sal_False);
|
||||
|
||||
pRootFolder->saveContents(OUString::createFromAscii(""), *pFoo);
|
||||
pFoo->closeInput();
|
||||
#else
|
||||
pRootFolder->saveContents(OUString::createFromAscii(""));
|
||||
std::vector < ManifestEntry * > aManList;
|
||||
pRootFolder->saveContents(OUString::createFromAscii(""), aManList);
|
||||
#endif
|
||||
|
||||
ZipEntry aEntry;
|
||||
ZipPackageBuffer *pBuffer = new ZipPackageBuffer(65535);
|
||||
Reference < XOutputStream > xOutStream = pBuffer;
|
||||
aEntry.nVersion = -1;
|
||||
aEntry.nFlag = -1;
|
||||
aEntry.nMethod = STORED;
|
||||
aEntry.nTime = -1;
|
||||
aEntry.nCrc = -1;
|
||||
aEntry.nCompressedSize = -1;
|
||||
aEntry.nSize = -1;
|
||||
aEntry.nOffset = -1;
|
||||
aEntry.sName = OUString::createFromAscii("META-INF/manifest.xml");
|
||||
pZipOut->putNextEntry(aEntry);
|
||||
ManifestWriter aWriter ( xOutStream, aManList);
|
||||
aWriter.Write();
|
||||
pBuffer->aBuffer.realloc(pBuffer->getPosition());
|
||||
pZipOut->write(pBuffer->aBuffer, 0, pBuffer->getPosition());
|
||||
pZipOut->closeEntry();
|
||||
pZipOut->finish();
|
||||
}
|
||||
sal_Bool SAL_CALL ZipPackage::hasPendingChanges( )
|
||||
|
@@ -2,9 +2,9 @@
|
||||
*
|
||||
* $RCSfile: ZipPackageBuffer.cxx,v $
|
||||
*
|
||||
* $Revision: 1.3 $
|
||||
* $Revision: 1.4 $
|
||||
*
|
||||
* last change: $Author: mtg $ $Date: 2000-11-23 14:15:52 $
|
||||
* last change: $Author: mtg $ $Date: 2000-11-27 16:55:07 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
@@ -166,9 +166,6 @@ void SAL_CALL ZipPackageBuffer::seek( sal_Int64 location )
|
||||
sal_Int64 SAL_CALL ZipPackageBuffer::getPosition( )
|
||||
throw(IOException, RuntimeException)
|
||||
{
|
||||
sal_Int8 nP = aBuffer[nCurrent];
|
||||
sal_Int8 nR = aBuffer[nEnd];
|
||||
int i =0;
|
||||
return nCurrent;
|
||||
}
|
||||
sal_Int64 SAL_CALL ZipPackageBuffer::getLength( )
|
||||
|
@@ -2,9 +2,9 @@
|
||||
*
|
||||
* $RCSfile: ZipPackageFolder.cxx,v $
|
||||
*
|
||||
* $Revision: 1.7 $
|
||||
* $Revision: 1.8 $
|
||||
*
|
||||
* last change: $Author: mtg $ $Date: 2000-11-24 10:34:27 $
|
||||
* last change: $Author: mtg $ $Date: 2000-11-27 16:55:07 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
@@ -121,19 +121,30 @@ void SAL_CALL ZipPackageFolder::release( )
|
||||
void SAL_CALL ZipPackageFolder::insertByName( const ::rtl::OUString& aName, const uno::Any& aElement )
|
||||
throw(lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException)
|
||||
{
|
||||
if (hasByName(aName))
|
||||
OUString sName;
|
||||
if (aName.indexOf('/', 0 ) == 0)
|
||||
sName = aName.copy(1, aName.getLength());
|
||||
else
|
||||
sName = aName;
|
||||
|
||||
if (hasByName(sName))
|
||||
throw container::ElementExistException();
|
||||
else
|
||||
{
|
||||
uno::Reference < lang::XUnoTunnel > xRef;
|
||||
aElement >>= xRef;
|
||||
aContents[aName] = xRef;
|
||||
aContents[sName] = xRef;
|
||||
}
|
||||
}
|
||||
void SAL_CALL ZipPackageFolder::removeByName( const ::rtl::OUString& Name )
|
||||
throw(container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
|
||||
{
|
||||
aContents.erase(Name);
|
||||
OUString sName;
|
||||
if (Name.indexOf('/', 0 ) == 0)
|
||||
sName = Name.copy(1, Name.getLength());
|
||||
else
|
||||
sName = Name;
|
||||
aContents.erase(sName);
|
||||
}
|
||||
// XEnumerationAccess
|
||||
uno::Reference< container::XEnumeration > SAL_CALL ZipPackageFolder::createEnumeration( )
|
||||
@@ -157,7 +168,12 @@ uno::Any SAL_CALL ZipPackageFolder::getByName( const ::rtl::OUString& aName )
|
||||
throw(container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
|
||||
{
|
||||
uno::Any aAny;
|
||||
TunnelHash::const_iterator aCI = aContents.find(aName);
|
||||
OUString sName;
|
||||
if (aName.indexOf('/', 0 ) == 0)
|
||||
sName = aName.copy(1, aName.getLength());
|
||||
else
|
||||
sName = aName;
|
||||
TunnelHash::const_iterator aCI = aContents.find(sName);
|
||||
if (aCI == aContents.end())
|
||||
throw container::NoSuchElementException();
|
||||
// rtl::OUString sTemp = aCI->first;
|
||||
@@ -177,13 +193,24 @@ uno::Sequence< ::rtl::OUString > SAL_CALL ZipPackageFolder::getElementNames( )
|
||||
sal_Bool SAL_CALL ZipPackageFolder::hasByName( const ::rtl::OUString& aName )
|
||||
throw(uno::RuntimeException)
|
||||
{
|
||||
return aContents.find(aName) != aContents.end();
|
||||
OUString sName;
|
||||
if (aName.indexOf('/', 0 ) == 0)
|
||||
sName = aName.copy(1, aName.getLength());
|
||||
else
|
||||
sName = aName;
|
||||
return aContents.find(sName) != aContents.end();
|
||||
}
|
||||
// XNameReplace
|
||||
void SAL_CALL ZipPackageFolder::replaceByName( const ::rtl::OUString& aName, const uno::Any& aElement )
|
||||
throw(lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
|
||||
{
|
||||
removeByName(aName);
|
||||
OUString sName;
|
||||
if (aName.indexOf('/', 0 ) == 0)
|
||||
sName = aName.copy(1, aName.getLength());
|
||||
else
|
||||
sName = aName;
|
||||
if (hasByName(aName))
|
||||
removeByName(aName);
|
||||
insertByName(aName, aElement);
|
||||
}
|
||||
//XPropertySet
|
||||
@@ -239,7 +266,7 @@ void SAL_CALL ZipPackageFolder::removeVetoableChangeListener( const ::rtl::OUStr
|
||||
#ifdef _DEBUG_RECURSION_
|
||||
void ZipPackageFolder::saveContents(rtl::OUString &rPath, TestZip &rFoo)
|
||||
#else
|
||||
void ZipPackageFolder::saveContents(rtl::OUString &rPath)
|
||||
void ZipPackageFolder::saveContents(rtl::OUString &rPath, std::vector < ManifestEntry *> &rManList)
|
||||
#endif
|
||||
{
|
||||
uno::Reference < lang::XUnoTunnel > xTunnel;
|
||||
@@ -282,10 +309,14 @@ void ZipPackageFolder::saveContents(rtl::OUString &rPath)
|
||||
pFolder->aEntry.nTime = ZipOutputStream::tmDateToDosDate ( *localtime(&nTime));
|
||||
rZipOut.putNextEntry(pFolder->aEntry);
|
||||
rZipOut.closeEntry();
|
||||
ManifestEntry *pMan = new ManifestEntry;
|
||||
pMan->sMediaType = OUString::createFromAscii("");
|
||||
pMan->sFullPath = pFolder->aEntry.sName;
|
||||
rManList.push_back (pMan);
|
||||
#ifdef _DEBUG_RECURSION_
|
||||
pFolder->saveContents(pFolder->aEntry.sName, rFoo);
|
||||
#else
|
||||
pFolder->saveContents(pFolder->aEntry.sName);
|
||||
pFolder->saveContents(pFolder->aEntry.sName, rManList);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
@@ -315,6 +346,11 @@ void ZipPackageFolder::saveContents(rtl::OUString &rPath)
|
||||
break;
|
||||
}
|
||||
rZipOut.closeEntry();
|
||||
ManifestEntry *pMan = new ManifestEntry;
|
||||
uno::Any aAny = pStream->getPropertyValue(OUString::createFromAscii("MediaType"));
|
||||
aAny >>= pMan->sMediaType;
|
||||
pMan->sFullPath = pStream->aEntry.sName;
|
||||
rManList.push_back (pMan);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -2,9 +2,9 @@
|
||||
#
|
||||
# $RCSfile: makefile.mk,v $
|
||||
#
|
||||
# $Revision: 1.7 $
|
||||
# $Revision: 1.8 $
|
||||
#
|
||||
# last change: $Author: mtg $ $Date: 2000-11-24 11:16:13 $
|
||||
# last change: $Author: mtg $ $Date: 2000-11-27 16:55:07 $
|
||||
#
|
||||
# The Contents of this file are made available subject to the terms of
|
||||
# either of the following licenses
|
||||
@@ -76,12 +76,15 @@ ENABLE_EXCEPTIONS=TRUE
|
||||
# --- Files --------------------------------------------------------
|
||||
|
||||
SLOFILES= \
|
||||
$(SLO)$/ZipPackage.obj \
|
||||
$(SLO)$/ZipPackageBuffer.obj \
|
||||
$(SLO)$/ZipPackageEntry.obj \
|
||||
$(SLO)$/ZipPackageFolder.obj \
|
||||
$(SLO)$/ZipPackage.obj \
|
||||
$(SLO)$/ZipPackageBuffer.obj \
|
||||
$(SLO)$/ZipPackageEntry.obj \
|
||||
$(SLO)$/ZipPackageFolder.obj \
|
||||
$(SLO)$/ManifestExport.obj \
|
||||
$(SLO)$/ManifestWriter.obj \
|
||||
$(SLO)$/AttributeList.obj \
|
||||
$(SLO)$/ZipPackageFolderEnumeration.obj \
|
||||
$(SLO)$/ZipPackageSink.obj \
|
||||
$(SLO)$/ZipPackageSink.obj \
|
||||
$(SLO)$/ZipPackageStream.obj
|
||||
|
||||
# --- UNO stuff ---------------------------------------------------
|
||||
|
Reference in New Issue
Block a user