summaryrefslogtreecommitdiff
path: root/package/source
diff options
context:
space:
mode:
authorOliver Bolte <obo@openoffice.org>2006-10-13 10:52:06 +0000
committerOliver Bolte <obo@openoffice.org>2006-10-13 10:52:06 +0000
commit6925465ef7d9e4a571242f2c3474995778b44d42 (patch)
tree462038cab04ace874d9ee72a775079e7cd638794 /package/source
parent2128c967fa13fe49f17b2ae5ce3afdfcddc9956a (diff)
INTEGRATION: CWS opofxmlstorage (1.80.20); FILE MERGED
2006/04/21 11:37:00 mav 1.80.20.1: #i64612# support OFOPXML format
Diffstat (limited to 'package/source')
-rw-r--r--package/source/zippackage/ZipPackageFolder.cxx52
1 files changed, 44 insertions, 8 deletions
diff --git a/package/source/zippackage/ZipPackageFolder.cxx b/package/source/zippackage/ZipPackageFolder.cxx
index 81064a778b6f..e23f1287db17 100644
--- a/package/source/zippackage/ZipPackageFolder.cxx
+++ b/package/source/zippackage/ZipPackageFolder.cxx
@@ -4,9 +4,9 @@
*
* $RCSfile: ZipPackageFolder.cxx,v $
*
- * $Revision: 1.81 $
+ * $Revision: 1.82 $
*
- * last change: $Author: obo $ $Date: 2006-09-17 17:29:24 $
+ * last change: $Author: obo $ $Date: 2006-10-13 11:52:06 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -93,15 +93,16 @@ using namespace com::sun::star::io;
using namespace cppu;
using namespace rtl;
using namespace std;
+using namespace ::com::sun::star;
using vos::ORef;
Sequence < sal_Int8 > ZipPackageFolder::aImplementationId = Sequence < sal_Int8 > ();
ZipPackageFolder::ZipPackageFolder ( const Reference< XMultiServiceFactory >& xFactory,
- sal_Bool bPackageFormat,
+ sal_Int16 nFormat,
sal_Bool bAllowRemoveOnInsert )
: m_xFactory( xFactory )
-, m_bPackageFormat( bPackageFormat )
+, m_nFormat( nFormat )
{
OSL_ENSURE( m_xFactory.is(), "No factory is provided to the package folder!" );
@@ -127,6 +128,33 @@ ZipPackageFolder::~ZipPackageFolder()
{
}
+void ZipPackageFolder::setChildStreamsTypeByExtension( const beans::StringPair& aPair )
+{
+ ::rtl::OUString aExt;
+ if ( aPair.First.toChar() == (sal_Unicode)'.' )
+ aExt = aPair.First;
+ else
+ aExt = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "." ) ) + aPair.First;
+
+ for ( ContentHash::const_iterator aCI = maContents.begin(), aEnd = maContents.end();
+ aCI != aEnd;
+ aCI++)
+ {
+ const OUString &rShortName = (*aCI).first;
+ const ContentInfo &rInfo = *(*aCI).second;
+
+ if ( rInfo.bFolder )
+ rInfo.pFolder->setChildStreamsTypeByExtension( aPair );
+ else
+ {
+ sal_Int32 nNameLength = rShortName.getLength();
+ sal_Int32 nExtLength = aExt.getLength();
+ if ( nNameLength >= nExtLength && rShortName.match( aExt, nNameLength - nExtLength ) )
+ rInfo.pStream->SetMediaType( aPair.Second );
+ }
+ }
+}
+
void ZipPackageFolder::copyZipEntry( ZipEntry &rDest, const ZipEntry &rSource)
{
rDest.nVersion = rSource.nVersion;
@@ -272,7 +300,7 @@ void ZipPackageFolder::saveContents(OUString &rPath, std::vector < Sequence < Pr
sal_Bool bHaveEncryptionKey = rEncryptionKey.getLength() ? sal_True : sal_False;
- if ( maContents.begin() == maContents.end() && rPath.getLength() )
+ if ( maContents.begin() == maContents.end() && rPath.getLength() && m_nFormat != OFOPXML_FORMAT )
{
// it is an empty subfolder, use workaround to store it
ZipEntry* pTempEntry = new ZipEntry();
@@ -646,7 +674,10 @@ void ZipPackageFolder::saveContents(OUString &rPath, std::vector < Sequence < Pr
pStream->aEntry.nOffset *= -1;
}
}
- rManList.push_back (aPropSet);
+
+ // folder can have a mediatype only in package format
+ if ( m_nFormat == PACKAGE_FORMAT || ( m_nFormat == OFOPXML_FORMAT && !rInfo.bFolder ) )
+ rManList.push_back( aPropSet );
}
if( bWritingFailed )
@@ -696,8 +727,8 @@ void SAL_CALL ZipPackageFolder::setPropertyValue( const OUString& aPropertyName,
{
if (aPropertyName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("MediaType")))
{
- if ( !m_bPackageFormat )
- throw PropertyVetoException();
+ if ( m_nFormat != PACKAGE_FORMAT )
+ throw UnknownPropertyException();
aValue >>= sMediaType;
}
@@ -710,7 +741,12 @@ Any SAL_CALL ZipPackageFolder::getPropertyValue( const OUString& PropertyName )
throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
{
if (PropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "MediaType" ) ) )
+ {
+ if ( m_nFormat != PACKAGE_FORMAT )
+ throw UnknownPropertyException();
+
return makeAny ( sMediaType );
+ }
else if (PropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "Size" ) ) )
return makeAny ( aEntry.nSize );
else