summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--package/inc/ZipPackage.hxx1
-rw-r--r--package/source/xstor/xstorage.cxx18
-rw-r--r--package/source/zippackage/ZipPackage.cxx20
3 files changed, 30 insertions, 9 deletions
diff --git a/package/inc/ZipPackage.hxx b/package/inc/ZipPackage.hxx
index 0549c06b6bb7..72cba808de15 100644
--- a/package/inc/ZipPackage.hxx
+++ b/package/inc/ZipPackage.hxx
@@ -91,6 +91,7 @@ protected:
::rtl::OUString m_aURL;
sal_Bool m_bHasEncryptedEntries;
sal_Bool m_bHasNonEncryptedEntries;
+ sal_Bool m_bInconsistent;
sal_Bool m_bUseManifest;
sal_Bool m_bForceRecovery;
diff --git a/package/source/xstor/xstorage.cxx b/package/source/xstor/xstorage.cxx
index 4d0af7bb7619..74c30049e9bd 100644
--- a/package/source/xstor/xstorage.cxx
+++ b/package/source/xstor/xstorage.cxx
@@ -4780,7 +4780,10 @@ void SAL_CALL OStorage::setPropertyValue( const ::rtl::OUString& aPropertyName,
//TODO: think about interaction handler
- if ( m_pData->m_bReadOnlyWrap )
+ // WORKAROUND:
+ // The old document might have no version in the manifest.xml, so we have to allow to set the version
+ // even for readonly storages, so that the version from content.xml can be used.
+ if ( m_pData->m_bReadOnlyWrap && !aPropertyName.equals( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Version" ) ) ) )
throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); // TODO: Access denied
if ( m_pData->m_nStorageType == ZIP_STORAGE )
@@ -4800,11 +4803,16 @@ void SAL_CALL OStorage::setPropertyValue( const ::rtl::OUString& aPropertyName,
aValue >>= m_pImpl->m_aVersion;
m_pImpl->m_bControlVersion = sal_True;
- m_pImpl->m_bBroadcastModified = sal_True;
- m_pImpl->m_bIsModified = sal_True;
+ // this property can be set even for readonly storage
+ if ( !m_pData->m_bReadOnlyWrap )
+ {
+ m_pImpl->m_bBroadcastModified = sal_True;
+ m_pImpl->m_bIsModified = sal_True;
+ }
}
else if ( m_pData->m_bIsRoot && ( aPropertyName.equalsAscii( "HasEncryptedEntries" )
|| aPropertyName.equalsAscii( "HasNonEncryptedEntries" )
+ || aPropertyName.equalsAscii( "IsInconsistent" )
|| aPropertyName.equalsAscii( "URL" )
|| aPropertyName.equalsAscii( "RepairPackage" ) )
|| aPropertyName.equalsAscii( "IsRoot" )
@@ -4939,7 +4947,9 @@ uno::Any SAL_CALL OStorage::getPropertyValue( const ::rtl::OUString& aPropertyNa
return uno::makeAny( sal_False ); // RepairPackage
}
else if ( m_pData->m_nStorageType == PACKAGE_STORAGE
- && ( aPropertyName.equalsAscii( "HasEncryptedEntries" ) || aPropertyName.equalsAscii( "HasNonEncryptedEntries" ) ) )
+ && ( aPropertyName.equalsAscii( "HasEncryptedEntries" )
+ || aPropertyName.equalsAscii( "HasNonEncryptedEntries" )
+ || aPropertyName.equalsAscii( "IsInconsistent" ) ) )
{
try {
m_pImpl->ReadContents();
diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx
index b95711778e77..6ca9981d2291 100644
--- a/package/source/zippackage/ZipPackage.cxx
+++ b/package/source/zippackage/ZipPackage.cxx
@@ -201,6 +201,7 @@ ZipPackage::ZipPackage (const uno::Reference < XMultiServiceFactory > &xNewFacto
: m_aMutexHolder( new SotMutexHolder )
, m_bHasEncryptedEntries ( sal_False )
, m_bHasNonEncryptedEntries ( sal_False )
+, m_bInconsistent ( sal_False )
, m_bUseManifest ( sal_True )
, m_bForceRecovery ( sal_False )
, m_bMediaTypeFallbackUsed ( sal_False )
@@ -426,20 +427,23 @@ void ZipPackage::parseManifest()
m_xRootFolder->removeByName( sMimetype );
}
+ m_bInconsistent = m_pRootFolder->LookForUnexpectedODF12Streams( ::rtl::OUString() );
+
sal_Bool bODF12AndOlder = ( m_pRootFolder->GetVersion().compareTo( ODFVER_012_TEXT ) >= 0 );
- if ( !m_bForceRecovery && bODF12AndOlder && m_pRootFolder->LookForUnexpectedODF12Streams( ::rtl::OUString() ) )
+ if ( !m_bForceRecovery && bODF12AndOlder && m_bInconsistent )
{
- // this is an ODF1.2 document that contains streams not referred in the manifest.xml
+ // this is an ODF1.2 document that contains streams not referred in the manifest.xml;
+ // in case of ODF1.2 documents without version in manifest.xml the property IsInconsistent
+ // should be checked later
throw ZipIOException(
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "there are streams not referred in manifest.xml\n" ) ),
uno::Reference< uno::XInterface >() );
}
+ // in case it is a correct ODF1.2 document, the version must be set
+ // and the META-INF folder is reserved for package format
if ( bODF12AndOlder )
- {
- // it is ODF1.2 or later, let the META-INF folder be unavailable for user
m_xRootFolder->removeByName( sMeta );
- }
}
}
@@ -1633,6 +1637,7 @@ void SAL_CALL ZipPackage::setPropertyValue( const OUString& aPropertyName, const
if (aPropertyName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("HasEncryptedEntries") )
||aPropertyName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("HasNonEncryptedEntries") )
+ ||aPropertyName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("IsInconsistent") )
||aPropertyName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("MediaTypeFallbackUsed") ) )
throw PropertyVetoException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
else if (aPropertyName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("EncryptionKey") ) )
@@ -1671,6 +1676,11 @@ Any SAL_CALL ZipPackage::getPropertyValue( const OUString& PropertyName )
aAny <<= m_bHasNonEncryptedEntries;
return aAny;
}
+ else if (PropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "IsInconsistent" ) ) )
+ {
+ aAny <<= m_bInconsistent;
+ return aAny;
+ }
else if (PropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "UseManifest" ) ) )
{
aAny <<= m_bUseManifest;