Anonymous avatar Anonymous committed 034eba5

CWS-TOOLING: integrate CWS fwk121
2009-09-30 11:20:33 +0200 mav r276548 : #i105387# allow manifest.xml have no ODF version attribute even for ODF1.2
2009-09-30 10:54:46 +0200 mav r276545 : #i105387# allow manifest.xml have no ODF version attribute even for ODF1.2
2009-09-30 10:02:12 +0200 mav r276543 : #i105082# integrating the fix from fwk117, since it is necessary for some scenarios fixed in this cws
2009-09-30 07:33:48 +0200 jsc r276537 : #i105360# explicitly flush OStorageStream after write operations and OStoreFile when registry file is closed
2009-09-29 14:15:09 +0200 jsc r276528 : #i105360# explicitly flush OStorageStream after write operations and OStoreFile when registry file is closed
2009-09-29 09:45:28 +0200 dr r276507 : #i105325# set correct format while opening zip package
2009-09-28 18:46:45 +0200 mav r276500 : CWS-TOOLING: rebase CWS fwk121 to trunk@276429 (milestone: DEV300:m60)

Comments (0)

Files changed (6)

package/inc/ZipPackage.hxx

 	::rtl::OUString	 m_aURL;
 	sal_Bool 		 m_bHasEncryptedEntries;
 	sal_Bool 		 m_bHasNonEncryptedEntries;
+	sal_Bool 		 m_bInconsistent;
 	sal_Bool 		 m_bUseManifest;
 	sal_Bool		 m_bForceRecovery;
 	

package/source/xstor/xstorage.cxx

 
 	//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 )
 			aValue >>= m_pImpl->m_aMediaType;
 			m_pImpl->m_bControlMediaType = sal_True;
 	
-			m_pImpl->m_bBroadcastModified = sal_True;
-			m_pImpl->m_bIsModified = sal_True;
+            m_pImpl->m_bBroadcastModified = sal_True;
+            m_pImpl->m_bIsModified = sal_True;
 		}
 		else if ( aPropertyName.equalsAscii( "Version" ) )
 		{
 			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" )
 			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();

package/source/zippackage/ZipPackage.cxx

 : 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 )
             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 );
-        }
 	}
 }
 
 
 	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") ) )
 		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;

registry/source/keyimpl.cxx

         return REG_SET_VALUE_FAILED;
     }
 
+    rValue.flush();
     rtl_freeMemory(pBuffer);
     return REG_NO_ERROR;
 }
         return REG_SET_VALUE_FAILED;
     }
 
+    rValue.flush();
     rtl_freeMemory(pBuffer);
     return REG_NO_ERROR;
 }
         return REG_SET_VALUE_FAILED;
     }
 
+    rValue.flush();
     rtl_freeMemory(pBuffer);
     return REG_NO_ERROR;
 }
         return REG_SET_VALUE_FAILED;
     }
 
+    rValue.flush();
     rtl_freeMemory(pBuffer);
     return REG_NO_ERROR;
 }

registry/source/regimpl.cxx

     if (m_file.isValid())
     {
         closeKey(m_openKeyTable[ROOT]);
+	m_file.flush();
         m_file.close();
         m_isOpen = sal_False;
         return REG_NO_ERROR;
     {
         return REG_DELETE_KEY_FAILED;
     }
+    sFile.flush();
 
     // set flag deleted !!!
     ((ORegKey*)hOldKey)->setDeleted(sal_True);
             {
                 return REG_DELETE_VALUE_FAILED;
             }
+	    ((OStoreFile&)pKey->getStoreFile()).flush();
         }
 
         _err = rStoreDir.next(iter);
     {
         return REG_VALUE_NOT_EXISTS;
     }
+    pSourceKey->getStoreFile().flush();
 
     pBuffer = (sal_uInt8*)rtl_allocateMemory(VALUE_HEADERSIZE);
 
         rtl_freeMemory(pBuffer);
         return REG_INVALID_VALUE;
     }
+    rTargetFile.flush();
 
     if (rwBytes != nSize)
     {

xmloff/source/core/xmlimp.cxx

     if ( aODFVersion.getLength() && aODFVersion.compareTo( ODFVER_012_TEXT ) >= 0 )
     {
         // check the consistency only for the ODF1.2 and later ( according to content.xml )
+        // manifest.xml might have no version, it should be checked here and the correct version should be set
         try
         {
             uno::Reference< document::XStorageBasedDocument > xDoc( mxModel, uno::UNO_QUERY_THROW );
                     ::rtl::OUString aStorVersion;
                     xStorProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Version" ) ) )
                         >>= aStorVersion;
-                    bResult = aODFVersion.equals( aStorVersion );
+
+                    // if the storage version is set in manifest.xml, it must be the same as in content.xml
+                    // if not, set it explicitly to be used further ( it will work even for readonly storage )
+                    // This workaround is not nice, but I see no other way to handle it, since there are
+                    // ODF1.2 documents without version in manifest.xml
+                    if ( aStorVersion.getLength() )
+                        bResult = aODFVersion.equals( aStorVersion );
+                    else
+                        xStorProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Version" ) ),
+                                                      uno::makeAny( aODFVersion ) );
+                    
+                    if ( bResult )
+                    {
+                        sal_Bool bInconsistent = sal_False;
+                        xStorProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsInconsistent" ) ) )
+                            >>= bInconsistent;
+                        bResult = !bInconsistent; 
+                    }
                 }
             }
         }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.