From bfaa449c45b0e7ba007a9be0e9676bb7ddd7b6f2 Mon Sep 17 00:00:00 2001 From: Martin Gallwey Date: Wed, 7 Feb 2001 08:13:57 +0000 Subject: Allow the setting of the MediaType on the root folder --- package/dtd/Manifest.dtd | 12 +++++++----- package/source/zipapi/ZipOutputStream.cxx | 20 ++++++++++++++++++-- package/source/zippackage/ZipPackage.cxx | 18 ++++++++++++++++-- package/source/zippackage/ZipPackageEntry.cxx | 20 ++++++++++---------- package/source/zippackage/ZipPackageFolder.cxx | 25 ++++++++++++++++++++++--- 5 files changed, 73 insertions(+), 22 deletions(-) (limited to 'package') diff --git a/package/dtd/Manifest.dtd b/package/dtd/Manifest.dtd index 66ce33331409..8dbf5e6197ee 100644 --- a/package/dtd/Manifest.dtd +++ b/package/dtd/Manifest.dtd @@ -1,5 +1,6 @@ + - + - + diff --git a/package/source/zipapi/ZipOutputStream.cxx b/package/source/zipapi/ZipOutputStream.cxx index 3be842d7f7ef..304bf2dd87b8 100644 --- a/package/source/zipapi/ZipOutputStream.cxx +++ b/package/source/zipapi/ZipOutputStream.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ZipOutputStream.cxx,v $ * - * $Revision: 1.19 $ + * $Revision: 1.20 $ * - * last change: $Author: mtg $ $Date: 2001-01-17 13:42:25 $ + * last change: $Author: mtg $ $Date: 2001-02-07 09:13:57 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -220,6 +220,22 @@ void SAL_CALL ZipOutputStream::closeEntry( ) void SAL_CALL ZipOutputStream::write( const uno::Sequence< sal_Int8 >& rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength ) throw(io::IOException, uno::RuntimeException) { + sal_Int32 nSize = rBuffer.getLength(); + sal_Bool bFound = sal_False; + const sal_Int8 *pBuf = rBuffer.getConstArray(); + for (sal_Int32 nIter = 0; nIter < nSize ; nIter++ ) + { + if (*(pBuf+nIter) == '>') + { + if (bFound) + *((int*)0) = 42; + else + bFound = sal_True; + } + else + bFound = sal_False; + } + switch (pCurrentEntry->nMethod) { case DEFLATED: diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx index 9c71fe8cdfc4..8749f20e69a1 100644 --- a/package/source/zippackage/ZipPackage.cxx +++ b/package/source/zippackage/ZipPackage.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ZipPackage.cxx,v $ * - * $Revision: 1.27 $ + * $Revision: 1.28 $ * - * last change: $Author: mtg $ $Date: 2001-01-10 11:36:01 $ + * last change: $Author: mtg $ $Date: 2001-02-07 09:13:57 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -537,6 +537,20 @@ ZipPackageBuffer & SAL_CALL ZipPackage::writeToBuffer( ) if (xRootFolder->hasByName(OUString::createFromAscii("META-INF"))) xRootFolder->removeByName(OUString::createFromAscii("META-INF")); + ManifestEntry *pMan = new ManifestEntry; + ZipPackageFolder::copyZipEntry(pMan->aEntry, pRootFolder->aEntry); + pMan->aEntry.sName = OUString::createFromAscii("/"); + try + { + Any aAny = pRootFolder->getPropertyValue(OUString::createFromAscii("MediaType")); + aAny >>= pMan->sMediaType; + } + catch (::com::sun::star::beans::UnknownPropertyException & ) + { + VOS_ENSURE( 0, "MediaType is an unknown property!!" ); + } + + aManList.push_back(pMan); pRootFolder->saveContents(OUString::createFromAscii(""), aManList, *pZipOut); ZipPackageFolder *pMetaInfFolder = new ZipPackageFolder(); diff --git a/package/source/zippackage/ZipPackageEntry.cxx b/package/source/zippackage/ZipPackageEntry.cxx index c3e552ec9da1..6ce0092e7458 100644 --- a/package/source/zippackage/ZipPackageEntry.cxx +++ b/package/source/zippackage/ZipPackageEntry.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ZipPackageEntry.cxx,v $ * - * $Revision: 1.12 $ + * $Revision: 1.13 $ * - * last change: $Author: mtg $ $Date: 2001-01-17 15:36:06 $ + * last change: $Author: mtg $ $Date: 2001-02-07 09:13:57 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -144,7 +144,7 @@ uno::Reference< beans::XPropertySetInfo > SAL_CALL ZipPackageEntry::getPropertyS void SAL_CALL ZipPackageEntry::setPropertyValue( const ::rtl::OUString& aPropertyName, const uno::Any& aValue ) throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) { - if (aPropertyName == OUString::createFromAscii("MediaType")) + if (aPropertyName.equalsAsciiL("MediaType", 9)) { aValue >>= sMediaType; @@ -156,12 +156,12 @@ void SAL_CALL ZipPackageEntry::setPropertyValue( const ::rtl::OUString& aPropert bToBeCompressed = sal_False; } } - else if (aPropertyName == OUString::createFromAscii("Size")) + else if (aPropertyName.equalsAsciiL("Size", 4)) aValue >>= aEntry.nSize; #if SUPD>617 - else if (aPropertyName == OUString::createFromAscii("Compressed")) + else if (aPropertyName.equalsAsciiL("Compressed",10)) #else - else if (aPropertyName == OUString::createFromAscii("Compress")) + else if (aPropertyName.equalsAsciiL("Compress", 8)) #endif aValue >>= bToBeCompressed; else @@ -171,20 +171,20 @@ uno::Any SAL_CALL ZipPackageEntry::getPropertyValue( const ::rtl::OUString& Prop throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) { uno::Any aAny; - if (PropertyName == OUString::createFromAscii("MediaType")) + if (PropertyName.equalsAsciiL("MediaType", 9)) { aAny <<= sMediaType; return aAny; } - else if (PropertyName == OUString::createFromAscii("Size")) + else if (PropertyName.equalsAsciiL("Size", 4)) { aAny <<= aEntry.nSize; return aAny; } #if SUPD>617 - else if (PropertyName == OUString::createFromAscii("Compressed")) + else if (PropertyName.equalsAsciiL("Compressed",10)) #else - else if (PropertyName == OUString::createFromAscii("Compress")) + else if (PropertyName.equalsAsciiL("Compress", 8)) #endif { aAny <<= bToBeCompressed; diff --git a/package/source/zippackage/ZipPackageFolder.cxx b/package/source/zippackage/ZipPackageFolder.cxx index 4f1e8a4a445d..e58086398aaf 100644 --- a/package/source/zippackage/ZipPackageFolder.cxx +++ b/package/source/zippackage/ZipPackageFolder.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ZipPackageFolder.cxx,v $ * - * $Revision: 1.28 $ + * $Revision: 1.29 $ * - * last change: $Author: kz $ $Date: 2001-01-23 13:54:12 $ + * last change: $Author: mtg $ $Date: 2001-02-07 09:13:57 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -304,6 +304,15 @@ void ZipPackageFolder::saveContents(rtl::OUString &rPath, std::vector < Manifest VOS_ENSURE( 0, "Error writing ZipOutputStream" ); } // Then copy it back + try + { + uno::Any aAny = pFolder->getPropertyValue(OUString::createFromAscii("MediaType")); + aAny >>= pMan->sMediaType; + } + catch (::com::sun::star::beans::UnknownPropertyException & ) + { + VOS_ENSURE( 0, "MediaType is an unknown property!!" ); + } ZipPackageFolder::copyZipEntry(pFolder->aEntry, pMan->aEntry); pFolder->aEntry.nOffset *= -1; rManList.push_back (pMan); @@ -337,7 +346,16 @@ void ZipPackageFolder::saveContents(rtl::OUString &rPath, std::vector < Manifest { VOS_ENSURE( 0, "Error writing ZipOutputStream" ); } - pMan->sMediaType = OUString::createFromAscii(""); + try + { + uno::Any aAny = pFolder->getPropertyValue(OUString::createFromAscii("MediaType")); + aAny >>= pMan->sMediaType; + } + catch (::com::sun::star::beans::UnknownPropertyException & ) + { + VOS_ENSURE( 0, "MediaType is an unknown property!!" ); + } + // Then copy it back ZipPackageFolder::copyZipEntry(pFolder->aEntry, pMan->aEntry); pFolder->aEntry.nOffset *= -1; @@ -453,6 +471,7 @@ void ZipPackageFolder::saveContents(rtl::OUString &rPath, std::vector < Manifest VOS_ENSURE( 0, "Error writing ZipOutputStream" ); } } + try { uno::Any aAny = pStream->getPropertyValue(OUString::createFromAscii("MediaType")); -- cgit v1.2.3