Anonymous avatar Anonymous committed b4ca8c9

CWS-TOOLING: integrate CWS dr72
2009-08-26 10:24:00 +0200 dr r275402 : #i92645# CODEPAGE is encrypted...
2009-08-24 14:37:36 +0200 dr r275316 : #i10000# enable exceptions for xlroot.cxx
2009-08-24 14:33:15 +0200 dr r275313 : #i10000# link openssl under solaris correctly
2009-08-21 17:41:16 +0200 dr r275267 : #i10000# unxlngi6 warning
2009-08-21 15:35:56 +0200 dr r275265 : #i10000# remove files again, already deleted in previous milestone...
2009-08-21 11:24:57 +0200 dr r275227 : #160401# port to DEV300
2009-08-21 09:53:45 +0200 dr r275221 : #i92645# full support for encrypted Word2007 files
2009-08-21 09:50:52 +0200 dr r275219 : #i92645# final changes for decryption
2009-08-20 19:48:40 +0200 dr r275195 : #i104370# missing parentheses, patch from cmc
2009-08-20 18:28:22 +0200 dr r275193 : #i92645# rework package decryption to repair 'Reload Document' functionality
2009-08-20 13:55:14 +0200 dr r275179 : #i92645# add new property names
2009-08-19 19:24:21 +0200 dr r275159 : #160401# open writeprotected files read-only, merged to DEV300
2009-08-18 14:41:47 +0200 dr r275109 : #i92645# add 'Aborted' property
2009-08-18 11:20:34 +0200 dr r275084 : #i92645# write back password to medium
2009-08-17 17:52:51 +0200 dr r275066 : #i92645# detect Word2007 docs with oox detection impl, this adds support of encryped Word2007; correct detection of templates and macro-enabled docs
2009-08-17 17:51:31 +0200 dr r275065 : #i92645# detect Word2007 docs with oox detection impl, this adds support of encryped Word2007; correct detection of templates and macro-enabled docs
2009-08-17 11:06:39 +0200 dr r275035 : #i92645# more password handling
2009-08-17 11:05:21 +0200 dr r275034 : #i92645# use new password input mechanism for BIFF filter and dumper in oox
2009-08-14 16:33:53 +0200 nn r274996 : #i104228# DelBroadcastAreasInRange: remove area from hash_set before deleting
2009-08-14 16:27:12 +0200 nn r274995 : #i104059# restore a change lost in the integration of fhawfixes1
2009-08-14 16:24:00 +0200 dr r274994 : #i92645# adapt BIFF import to latest changes
2009-08-14 16:21:30 +0200 dr r274993 : #i92645# adapt BIFF import to latest changes
2009-08-14 16:20:43 +0200 dr r274992 : #i92645# do not add default passwords to media descriptor
2009-08-13 19:20:45 +0200 dr r274965 : #i92645# add a helper to request a document password
2009-08-13 19:09:35 +0200 dr r274964 : #i92645# add a helper to request a document password
2009-08-13 19:09:03 +0200 dr r274963 : #i92645# add a helper to request a document password
2009-08-13 14:35:01 +0200 dr r274946 : #i92645# comment typo
2009-08-13 14:33:47 +0200 dr r274945 : #i92645# add a helper to request a document password
2009-08-13 14:04:47 +0200 dr r274941 : #i92645# add a helper to request a document password
2009-08-13 14:04:22 +0200 dr r274940 : #i92645# add a helper to request a document password
2009-08-13 11:16:27 +0200 dr r274927 : #i42303# show quick help if field name too long for button
2009-08-13 10:55:48 +0200 dr r274925 : #i31600# cut field name and add ellipsis, if too long for button
2009-08-12 18:47:26 +0200 dr r274914 : #i92645# ask user for a password
2009-08-12 18:02:39 +0200 dr r274909 : #i104183# move svtools/DocPasswordRequest to comphelper to be able to use it in oox
2009-08-12 16:59:11 +0200 dr r274906 : #i104183# move svtools/DocPasswordRequest to comphelper to be able to use it in oox
2009-08-12 16:41:18 +0200 dr r274905 : #i104183# move svtools/DocPasswordRequest to comphelper to be able to use it in oox
2009-08-12 16:40:33 +0200 dr r274904 : #i104183# move svtools/DocPasswordRequest to comphelper to be able to use it in oox
2009-08-12 16:40:08 +0200 dr r274903 : #i104183# move svtools/DocPasswordRequest to comphelper to be able to use it in oox
2009-08-12 16:39:30 +0200 dr r274902 : #i104183# move svtools/DocPasswordRequest to comphelper to be able to use it in oox
2009-08-12 16:15:28 +0200 dr r274899 : #i104183# move svtools/DocPasswordRequest to comphelper to be able to use it in oox
2009-08-11 19:51:12 +0200 dr r274877 : #i92645# open encrypted MSOOXML package protected with standard XL password 'VelvetSweatshop'

Comments (0)

Files changed (77)

comphelper/inc/comphelper/docpasswordhelper.hxx

+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: docpasswordhelper.hxx,v $
+ * $Revision: 1.1 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org.  If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef COMPHELPER_DOCPASSWORDHELPR_HXX
+#define COMPHELPER_DOCPASSWORDHELPR_HXX
+
+#include "comphelper/comphelperdllapi.h"
+#include <vector>
+#include "comphelper/docpasswordrequest.hxx"
+
+namespace com { namespace sun { namespace star { namespace task { class XInteractionHandler; } } } }
+
+namespace comphelper {
+
+class MediaDescriptor;
+
+// ============================================================================
+
+enum DocPasswordVerifierResult
+{
+    DocPasswordVerifierResult_OK,
+    DocPasswordVerifierResult_WRONG_PASSWORD,
+    DocPasswordVerifierResult_ABORT
+};
+
+// ============================================================================
+
+/** Base class for a password verifier used by the DocPasswordHelper class
+    below.
+
+    Users have to implement the virtual function and pass an instance of the
+    verifier to one of the password request functions.
+ */
+class COMPHELPER_DLLPUBLIC IDocPasswordVerifier
+{
+public:
+    virtual             ~IDocPasswordVerifier();
+
+    /** Will be called everytime a password needs to be verified.
+
+        @return  The result of the verification.
+            - DocPasswordVerifierResult_OK, if and only if the passed password
+              is valid and can be used to process the related document.
+            - DocPasswordVerifierResult_WRONG_PASSWORD, if the password is
+              wrong. The user may be asked again for a new password.
+            - DocPasswordVerifierResult_ABORT, if an unrecoverable error
+              occured while password verification. The password request loop
+              will be aborted.
+     */
+    virtual DocPasswordVerifierResult verifyPassword( const ::rtl::OUString& rPassword ) = 0;
+
+};
+
+// ============================================================================
+
+/** Helper that asks for a document password and checks its validity.
+ */
+class COMPHELPER_DLLPUBLIC DocPasswordHelper
+{
+public:
+    // ------------------------------------------------------------------------
+
+    /** This helper function tries to request and verify a password to load a
+        protected document.
+
+        First, the list of default passwords will be tried if provided. This is
+        needed by import filters for external file formats that have to check a
+        predefined password in some cases without asking the user for a
+        password. Every password is checked using the passed password verifier.
+
+        If not successful, the passed password of a medium is tried, that has
+        been set e.g. by an API call to load a document. If existing, the
+        password is checked using the passed password verifier.
+
+        If still not successful, the passed interaction handler is used to
+        request a password from the user. This will be repeated until the
+        passed password verifier validates the entered password, or if the user
+        chooses to cancel password input.
+
+        @param rVerifier
+            The password verifier used to check every processed password.
+
+        @param rMediaPassword
+            If not empty, will be passed to the password validator before
+            requesting a password from the user. This password usually should
+            be querried from a media descriptor.
+
+        @param rxInteractHandler
+            The interaction handler that will be used to request a password
+            from the user, e.g. by showing a password input dialog.
+
+        @param rDocumentName
+            The name of the related document that will be shown in the password
+            input dialog.
+
+        @param eRequestType
+            The password request type that will be passed to the
+            DocPasswordRequest object created internally. See
+            docpasswordrequest.hxx for more details.
+
+        @param pDefaultPasswords
+            If not null, contains default passwords that will be tried before a
+            password will be requested from the media descriptor or the user.
+
+        @param pbIsDefaultPassword
+            (output parameter) If not null, the type of the found password will
+            be returned. True means the password has been found in the passed
+            list of default passwords. False means the password has been taken
+            from the rMediaPassword parameter or has been entered by the user.
+
+        @return
+            If not empty, contains the password that has been validated by the
+            passed password verifier. If empty, no valid password has been
+            found, or the user has chossen to cancel password input.
+     */
+    static ::rtl::OUString requestAndVerifyDocPassword(
+                            IDocPasswordVerifier& rVerifier,
+                            const ::rtl::OUString& rMediaPassword,
+                            const ::com::sun::star::uno::Reference<
+                                ::com::sun::star::task::XInteractionHandler >& rxInteractHandler,
+                            const ::rtl::OUString& rDocumentName,
+                            DocPasswordRequestType eRequestType,
+                            const ::std::vector< ::rtl::OUString >* pDefaultPasswords = 0,
+                            bool* pbIsDefaultPassword = 0 );
+
+    // ------------------------------------------------------------------------
+
+    /** This helper function tries to find a password for the document
+        described by the passed media descriptor.
+
+        First, the list of default passwords will be tried if provided. This is
+        needed by import filters for external file formats that have to check a
+        predefined password in some cases without asking the user for a
+        password. Every password is checked using the passed password verifier.
+
+        If not successful, the passed media descriptor is asked for a password,
+        that has been set e.g. by an API call to load a document. If existing,
+        the password is checked using the passed password verifier.
+
+        If still not successful, the interaction handler contained in the
+        passed nmedia descriptor is used to request a password from the user.
+        This will be repeated until the passed password verifier validates the
+        entered password, or if the user chooses to cancel password input.
+
+        @param rVerifier
+            The password verifier used to check every processed password.
+
+        @param rMediaDesc
+            The media descriptor of the document that needs to be opened with
+            a password. If a valid password (that is not contained in the
+            passed list of default passwords) was found, it will be inserted
+            into the "Password" property of this descriptor.
+
+        @param eRequestType
+            The password request type that will be passed to the
+            DocPasswordRequest object created internally. See
+            docpasswordrequest.hxx for more details.
+
+        @param pDefaultPasswords
+            If not null, contains default passwords that will be tried before a
+            password will be requested from the media descriptor or the user.
+
+        @return
+            If not empty, contains the password that has been validated by the
+            passed password verifier. If empty, no valid password has been
+            found, or the user has chossen to cancel password input.
+     */
+    static ::rtl::OUString requestAndVerifyDocPassword(
+                            IDocPasswordVerifier& rVerifier,
+                            MediaDescriptor& rMediaDesc,
+                            DocPasswordRequestType eRequestType,
+                            const ::std::vector< ::rtl::OUString >* pDefaultPasswords = 0 );
+
+    // ------------------------------------------------------------------------
+
+private:
+                        ~DocPasswordHelper();
+};
+
+// ============================================================================
+
+} // namespace comphelper
+
+#endif
+

comphelper/inc/comphelper/docpasswordrequest.hxx

+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: docpasswordrequest.hxx,v $
+ * $Revision: 1.1 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org.  If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef COMPHELPER_DOCPASSWORDREQUEST_HXX
+#define COMPHELPER_DOCPASSWORDREQUEST_HXX
+
+#include "comphelper/comphelperdllapi.h"
+#include <com/sun/star/task/PasswordRequestMode.hpp>
+#include <com/sun/star/task/XInteractionRequest.hpp>
+#include <cppuhelper/implbase1.hxx>
+
+namespace comphelper {
+
+// ============================================================================
+
+/** Selects which UNO document password request type to use. */
+enum DocPasswordRequestType
+{
+    DocPasswordRequestType_STANDARD,    /// Uses the standard com.sun.star.task.DocumentPasswordRequest request.
+    DocPasswordRequestType_MS           /// Uses the com.sun.star.task.DocumentMSPasswordRequest request.
+};
+
+// ============================================================================
+
+class AbortContinuation;
+class PasswordContinuation;
+
+/** Implements the task.XInteractionRequest interface for requesting a password
+    string for a document.
+ */
+class COMPHELPER_DLLPUBLIC DocPasswordRequest : public ::cppu::WeakImplHelper1< ::com::sun::star::task::XInteractionRequest >
+{
+public:
+    explicit            DocPasswordRequest(
+                            DocPasswordRequestType eType,
+                            ::com::sun::star::task::PasswordRequestMode eMode,
+                            const ::rtl::OUString& rDocumentName );
+    virtual             ~DocPasswordRequest();
+
+    bool                isAbort() const;
+    bool                isPassword() const;
+    ::rtl::OUString     getPassword() const;
+
+private:
+    virtual ::com::sun::star::uno::Any SAL_CALL
+                        getRequest() throw( ::com::sun::star::uno::RuntimeException );
+
+    virtual ::com::sun::star::uno::Sequence<
+                ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > > SAL_CALL
+                        getContinuations() throw( ::com::sun::star::uno::RuntimeException );
+
+private:
+    ::com::sun::star::uno::Any maRequest;
+    ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > > maContinuations;
+    AbortContinuation*  mpAbort;
+    PasswordContinuation* mpPassword;
+};
+
+// ============================================================================
+
+} // namespace comphelper
+
+#endif
+

comphelper/inc/comphelper/mediadescriptor.hxx

 /*************************************************************************
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- * 
+ *
  * Copyright 2008 by Sun Microsystems, Inc.
  *
  * OpenOffice.org - a multi-platform office productivity suite
 // definitions
 
 /** @short  can be used to work with a <type scope="::com::sun::star::document">MediaDescriptor</type>
-            struct.  
+            struct.
 
     @descr  It wraps a ::std::hash_map around the Sequence< css::beans::PropertyValue >, which
             represent the MediaDescriptor item.
             Further this helper defines often used functions (as e.g. open of the required streams,
             consistent checks etcpp.) and it defines all useable property names.
-            
-    @attention  This class isnt threadsafe and must be guarded from outside!            
+
+    @attention  This class isnt threadsafe and must be guarded from outside!
  */
 class COMPHELPER_DLLPUBLIC MediaDescriptor : public SequenceAsHashMap
 {
     //-------------------------------------------
     // const
     public:
-    
+
         //---------------------------------------
         /** @short  these methods can be used to get the different property names
                     as static const OUString values.
-                    
+
             @descr  Because definition and declaration of static const class members
                     does not work as expected under windows (under unix it works as well)
-                    these way must be used :-(                    
+                    these way must be used :-(
           */
+        static const ::rtl::OUString& PROP_ABORTED();
         static const ::rtl::OUString& PROP_ASTEMPLATE();
         static const ::rtl::OUString& PROP_CHARACTERSET();
+        static const ::rtl::OUString& PROP_COMPONENTDATA();
         static const ::rtl::OUString& PROP_DEEPDETECTION();
         static const ::rtl::OUString& PROP_DETECTSERVICE();
         static const ::rtl::OUString& PROP_DOCUMENTSERVICE();
         //---------------------------------------
         /** @short  these ctors do nothing - excepting that they forward
                     the given parameters to the base class ctors.
-                    
+
             @descr  The ctros must be overwritten to resolve conflicts with
                     the default ctors of the compiler :-(.
-         */                    
+         */
         MediaDescriptor();
         MediaDescriptor(const ::com::sun::star::uno::Any& aSource);
         MediaDescriptor(const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& lSource);
         MediaDescriptor(const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& lSource);
-        
+
         //---------------------------------------
         /** @short  it checks if the descriptor already has a valid
                     InputStream item and creates a new one, if not.
             @descr  This method uses the current items of this MediaDescriptor,
                     to open the stream (as e.g. URL, ReadOnly, PostData etcpp.).
                     It creates a seekable stream and put it into the descriptor.
-                    
+
                     A might existing InteractionHandler will be used automaticly,
                     to solve problems!
 
                     In case of local file the system file locking is used.
- 
+
             @return TRUE, if the stream was already part of the descriptor or could
                     be created as new item. FALSE otherwhise.
          */
             @descr  This method uses the current items of this MediaDescriptor,
                     to open the stream (as e.g. URL, ReadOnly, PostData etcpp.).
                     It creates a seekable stream and put it into the descriptor.
-                    
+
                     A might existing InteractionHandler will be used automaticly,
                     to solve problems!
- 
+
                     In case of local file the system file locking is used based on
                     configuration settings.
 
                     be created as new item. FALSE otherwhise.
          */
         sal_Bool addInputStreamOwnLock();
-        
+
         //---------------------------------------
         /** @short  it checks if the descriptor describes a readonly stream.
 
             @descr  The descriptor itself isnt changed doing so.
                     It's only checked if the stream seems to be based
                     of a real readonly file.
-                    
+
             @Attention
                     We dont check the property "ReadOnly" here. Because
                     this property can be set from outside and overwrites
                     If e.g. the stream could be opened read/write ...
                     but "ReadOnly" property is set to TRUE, this means:
                     show a readonly UI on top of this read/write stream.
-                    
+
             @return TRUE, if the stream must be interpreted as readonly ...
                     FALSE otherwhise.
          */
         sal_Bool isStreamReadOnly() const;
-        
+
     //-------------------------------------------
     // helper
     private:
-    
+
         //---------------------------------------
         /** @short  tries to open a stream by using the given PostData stream.
-        
-            @descr  The stream is used directly ...  
-            
+
+            @descr  The stream is used directly ...
+
                     The MediaDescriptor itself is changed inside this method.
                     Means: the stream is added internal and not returned by a value.
-                    
+
             @param  _rxPostData
                     the PostData stream.
-                    
+
             @return TRUE if the stream could be added successfully.
                     Note: If FALSE is returned, the error was already handled inside!
-            
+
             @throw  [css::uno::RuntimeException]
                     if the MediaDescriptor seems to be invalid!
 
         COMPHELPER_DLLPRIVATE sal_Bool impl_openStreamWithPostData(
             const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& _rxPostData
             )   throw(::com::sun::star::uno::RuntimeException);
-        
+
         //---------------------------------------
         /** @short  tries to open a stream by using the given URL.
-        
+
             @descr  First it tries to open the content in r/w mode (if its
                     allowed to do so). Only in case its not allowed or it failed
                     the stream will be tried to open in readonly mode.
-            
+
                     The MediaDescriptor itself is changed inside this method.
                     Means: the stream is added internal and not returned by a value.
-                    
+
             @param  sURL
                     the URL for open.
- 
+
             @param  bLockFile
                     specifies whether the file should be locked
 
             @return TRUE if the stream could be added successfully.
                     Note: If FALSE is returned, the error was already handled inside!
-            
+
             @throw  [css::uno::RuntimeException]
                     if the MediaDescriptor seems to be invalid!
          */
             const ::rtl::OUString& sURL,
             sal_Bool bLockFile
             ) throw(::com::sun::star::uno::RuntimeException);
-            
+
         //---------------------------------------
         /** @short  some URL parts can make trouble for opening streams (e.g. jumpmarks.)
                     An URL should be "normalized" before its used.
-                    
+
             @param  sURL
                     the original URL (e.g. including a jumpmark)
-                    
+
             @return [string]
                     the "normalized" URL (e.g. without jumpmark)
          */
-        COMPHELPER_DLLPRIVATE ::rtl::OUString impl_normalizeURL(const ::rtl::OUString& sURL);            
+        COMPHELPER_DLLPRIVATE ::rtl::OUString impl_normalizeURL(const ::rtl::OUString& sURL);
 
         //---------------------------------------
         /** @short  it checks if the descriptor already has a valid
             @descr  This method uses the current items of this MediaDescriptor,
                     to open the stream (as e.g. URL, ReadOnly, PostData etcpp.).
                     It creates a seekable stream and put it into the descriptor.
-                    
+
                     A might existing InteractionHandler will be used automaticly,
                     to solve problems!
- 
+
             @param  bLockFile
                     specifies whether the file should be locked
 

comphelper/source/misc/docpasswordhelper.cxx

+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: docpasswordhelper.cxx,v $
+ * $Revision: 1.1 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org.  If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_comphelper.hxx"
+
+#include "comphelper/docpasswordhelper.hxx"
+#include <com/sun/star/task/XInteractionHandler.hpp>
+#include "comphelper/mediadescriptor.hxx"
+
+using ::rtl::OUString;
+using ::com::sun::star::uno::Exception;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::UNO_SET_THROW;
+using ::com::sun::star::task::PasswordRequestMode;
+using ::com::sun::star::task::PasswordRequestMode_PASSWORD_ENTER;
+using ::com::sun::star::task::PasswordRequestMode_PASSWORD_REENTER;
+using ::com::sun::star::task::XInteractionHandler;
+using ::com::sun::star::task::XInteractionRequest;
+
+namespace comphelper {
+
+// ============================================================================
+
+IDocPasswordVerifier::~IDocPasswordVerifier()
+{
+}
+
+// ============================================================================
+
+/*static*/ OUString DocPasswordHelper::requestAndVerifyDocPassword(
+        IDocPasswordVerifier& rVerifier,
+        const OUString& rMediaPassword,
+        const Reference< XInteractionHandler >& rxInteractHandler,
+        const OUString& rDocumentName,
+        DocPasswordRequestType eRequestType,
+        const ::std::vector< OUString >* pDefaultPasswords,
+        bool* pbIsDefaultPassword )
+{
+    OUString aPassword;
+    DocPasswordVerifierResult eResult = DocPasswordVerifierResult_WRONG_PASSWORD;
+
+    // first, try provided default passwords
+    if( pbIsDefaultPassword )
+        *pbIsDefaultPassword = false;
+    if( pDefaultPasswords )
+    {
+        for( ::std::vector< OUString >::const_iterator aIt = pDefaultPasswords->begin(), aEnd = pDefaultPasswords->end(); (eResult == DocPasswordVerifierResult_WRONG_PASSWORD) && (aIt != aEnd); ++aIt )
+        {
+            aPassword = *aIt;
+            OSL_ENSURE( aPassword.getLength() > 0, "DocPasswordHelper::requestAndVerifyDocPassword - unexpected empty default password" );
+            if( aPassword.getLength() > 0 )
+            {
+                eResult = rVerifier.verifyPassword( aPassword );
+                if( pbIsDefaultPassword )
+                    *pbIsDefaultPassword = eResult == DocPasswordVerifierResult_OK;
+            }
+        }
+    }
+
+    // try media password (skip, if result is OK or ABORT)
+    if( eResult == DocPasswordVerifierResult_WRONG_PASSWORD )
+    {
+        aPassword = rMediaPassword;
+        if( aPassword.getLength() > 0 )
+            eResult = rVerifier.verifyPassword( aPassword );
+    }
+
+    // request a password (skip, if result is OK or ABORT)
+    if( (eResult == DocPasswordVerifierResult_WRONG_PASSWORD) && rxInteractHandler.is() ) try
+    {
+        PasswordRequestMode eRequestMode = PasswordRequestMode_PASSWORD_ENTER;
+        while( eResult == DocPasswordVerifierResult_WRONG_PASSWORD )
+        {
+            DocPasswordRequest* pRequest = new DocPasswordRequest( eRequestType, eRequestMode, rDocumentName );
+            Reference< XInteractionRequest > xRequest( pRequest );
+            rxInteractHandler->handle( xRequest );
+            if( pRequest->isPassword() )
+            {
+                aPassword = pRequest->getPassword();
+                if( aPassword.getLength() > 0 )
+                    eResult = rVerifier.verifyPassword( aPassword );
+            }
+            else
+            {
+                eResult = DocPasswordVerifierResult_ABORT;
+            }
+            eRequestMode = PasswordRequestMode_PASSWORD_REENTER;
+        }
+    }
+    catch( Exception& )
+    {
+    }
+
+    return (eResult == DocPasswordVerifierResult_OK) ? aPassword : OUString();
+}
+
+/*static*/ OUString DocPasswordHelper::requestAndVerifyDocPassword(
+        IDocPasswordVerifier& rVerifier,
+        MediaDescriptor& rMediaDesc,
+        DocPasswordRequestType eRequestType,
+        const ::std::vector< OUString >* pDefaultPasswords )
+{
+    OUString aMediaPassword = rMediaDesc.getUnpackedValueOrDefault(
+        MediaDescriptor::PROP_PASSWORD(), OUString() );
+    Reference< XInteractionHandler > xInteractHandler = rMediaDesc.getUnpackedValueOrDefault(
+        MediaDescriptor::PROP_INTERACTIONHANDLER(), Reference< XInteractionHandler >() );
+    OUString aDocumentName = rMediaDesc.getUnpackedValueOrDefault(
+        MediaDescriptor::PROP_URL(), OUString() );
+
+    bool bIsDefaultPassword = false;
+    OUString aPassword = requestAndVerifyDocPassword(
+        rVerifier, aMediaPassword, xInteractHandler, aDocumentName, eRequestType, pDefaultPasswords, &bIsDefaultPassword );
+
+    // insert valid password into media descriptor (but not a default password)
+    if( (aPassword.getLength() > 0) && !bIsDefaultPassword )
+        rMediaDesc[ MediaDescriptor::PROP_PASSWORD() ] <<= aPassword;
+
+    return aPassword;
+}
+
+// ============================================================================
+
+} // namespace comphelper
+

comphelper/source/misc/docpasswordrequest.cxx

+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: docpasswordrequest.cxx,v $
+ * $Revision: 1.1 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org.  If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_comphelper.hxx"
+
+#include "comphelper/docpasswordrequest.hxx"
+#include <com/sun/star/task/DocumentMSPasswordRequest.hpp>
+#include <com/sun/star/task/DocumentPasswordRequest.hpp>
+#include <com/sun/star/task/XInteractionAbort.hpp>
+#include <com/sun/star/task/XInteractionPassword.hpp>
+
+using ::rtl::OUString;
+using ::com::sun::star::uno::Any;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::RuntimeException;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::uno::XInterface;
+using ::com::sun::star::task::InteractionClassification_QUERY;
+using ::com::sun::star::task::DocumentMSPasswordRequest;
+using ::com::sun::star::task::DocumentPasswordRequest;
+using ::com::sun::star::task::PasswordRequestMode;
+using ::com::sun::star::task::XInteractionAbort;
+using ::com::sun::star::task::XInteractionContinuation;
+using ::com::sun::star::task::XInteractionPassword;
+
+namespace comphelper {
+
+// ============================================================================
+
+class AbortContinuation : public ::cppu::WeakImplHelper1< XInteractionAbort >
+{
+public:
+    inline explicit     AbortContinuation() : mbSelected( false ) {}
+
+    inline bool         isSelected() const { return mbSelected; }
+    inline void         reset() { mbSelected = false; }
+
+    virtual void SAL_CALL select() throw( RuntimeException ) { mbSelected = true; }
+
+private:
+    bool                mbSelected;
+};
+
+// ============================================================================
+
+class PasswordContinuation : public ::cppu::WeakImplHelper1< XInteractionPassword >
+{
+public:
+    inline explicit     PasswordContinuation() : mbSelected( false ) {}
+
+    inline bool         isSelected() const { return mbSelected; }
+    inline void         reset() { mbSelected = false; }
+
+    virtual void SAL_CALL select() throw( RuntimeException ) { mbSelected = true; }
+    virtual void SAL_CALL setPassword( const OUString& rPass ) throw( RuntimeException ) { maPassword = rPass; }
+    virtual OUString SAL_CALL getPassword() throw( RuntimeException ) { return maPassword; }
+
+private:
+    OUString            maPassword;
+    bool                mbSelected;
+};
+
+// ============================================================================
+
+DocPasswordRequest::DocPasswordRequest( DocPasswordRequestType eType,
+        PasswordRequestMode eMode, const OUString& rDocumentName )
+{
+    switch( eType )
+    {
+        case DocPasswordRequestType_STANDARD:
+        {
+            DocumentPasswordRequest aRequest( OUString(), Reference< XInterface >(),
+                InteractionClassification_QUERY, eMode, rDocumentName );
+            maRequest <<= aRequest;
+        }
+        break;
+        case DocPasswordRequestType_MS:
+        {
+            DocumentMSPasswordRequest aRequest( OUString(), Reference< XInterface >(),
+                InteractionClassification_QUERY, eMode, rDocumentName );
+            maRequest <<= aRequest;
+        }
+        break;
+        /*  no 'default', so compilers will complain about missing
+            implementation of a new enum value. */
+    }
+
+    maContinuations.realloc( 2 );
+    maContinuations[ 0 ].set( mpAbort = new AbortContinuation );
+    maContinuations[ 1 ].set( mpPassword = new PasswordContinuation );
+}
+
+DocPasswordRequest::~DocPasswordRequest()
+{
+}
+
+bool DocPasswordRequest::isAbort() const
+{
+    return mpAbort->isSelected();
+}
+
+bool DocPasswordRequest::isPassword() const
+{
+    return mpPassword->isSelected();
+}
+
+OUString DocPasswordRequest::getPassword() const
+{
+    return mpPassword->getPassword();
+}
+
+Any SAL_CALL DocPasswordRequest::getRequest() throw( RuntimeException )
+{
+    return maRequest;
+}
+
+Sequence< Reference< XInteractionContinuation > > SAL_CALL DocPasswordRequest::getContinuations() throw( RuntimeException )
+{
+    return maContinuations;
+}
+
+// ============================================================================
+
+} // namespace comphelper
+

comphelper/source/misc/makefile.mk

             $(SLO)$/componentcontext.obj \
             $(SLO)$/componentmodule.obj \
             $(SLO)$/configurationhelper.obj \
+            $(SLO)$/docpasswordhelper.obj \
+            $(SLO)$/docpasswordrequest.obj \
             $(SLO)$/documentinfo.obj \
             $(SLO)$/documentiologring.obj \
             $(SLO)$/evtlistenerhlp.obj \

comphelper/source/misc/mediadescriptor.cxx

 /*************************************************************************
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- * 
+ *
  * Copyright 2008 by Sun Microsystems, Inc.
  *
  * OpenOffice.org - a multi-platform office productivity suite
 /*-----------------------------------------------
     10.03.2004 07:35
 -----------------------------------------------*/
+const ::rtl::OUString& MediaDescriptor::PROP_ABORTED()
+{
+    static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("Aborted"));
+    return sProp;
+}
+
 const ::rtl::OUString& MediaDescriptor::PROP_ASTEMPLATE()
 {
     static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("AsTemplate"));
     return sProp;
 }
 
+const ::rtl::OUString& MediaDescriptor::PROP_COMPONENTDATA()
+{
+    static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("ComponentData"));
+    return sProp;
+}
+
 const ::rtl::OUString& MediaDescriptor::PROP_DEEPDETECTION()
 {
     static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("DeepDetection"));

filter/source/config/fragments/types/writer_MS_Word_2007_XML.xcu

     <node oor:name="writer_MS_Word_2007" oor:op="replace" >
-        <prop oor:name="DetectService"><value>com.sun.star.comp.Writer.WriterFilterDetector</value></prop>
+	<prop oor:name="DetectService"><value>com.sun.star.comp.oox.FormatDetector</value></prop>
         <prop oor:name="URLPattern"/>
         <prop oor:name="Extensions"><value>docx docm</value></prop>
         <prop oor:name="MediaType"><value>application/msword</value></prop>

filter/source/config/fragments/types/writer_MS_Word_2007_XML_Template.xcu

     <node oor:name="writer_MS_Word_2007_Template" oor:op="replace" >
-        <prop oor:name="DetectService"><value>com.sun.star.comp.Writer.WriterFilterDetector</value></prop>
+	<prop oor:name="DetectService"><value>com.sun.star.comp.oox.FormatDetector</value></prop>
         <prop oor:name="URLPattern"/>
         <prop oor:name="Extensions"><value>dotx dotm</value></prop>
         <prop oor:name="MediaType"><value>application/msword</value></prop>

offapi/com/sun/star/document/MediaDescriptor.idl

 /*************************************************************************
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- * 
+ *
  * Copyright 2008 by Sun Microsystems, Inc.
  *
  * OpenOffice.org - a multi-platform office productivity suite
  */
 published service MediaDescriptor
 {
+    //-------------------------------------------------------------------------
+    /** May be set by filters or detection services if user has choosen to
+        abort loading/saving, e.g. while entering a password.
+     */
+    [optional,property] boolean Aborted;
+
 	//-------------------------------------------------------------------------
     /** document is a template
 
         </p>
      */
     [optional,property] any ComponentData;
-	
+
 	//-------------------------------------------------------------------------
 	/** The base URL of the document to be used to resolve relative links.
 	 */
     /** let the document be opened in repair mode
 
         <p>
-        For loading of corrupted zip packages: Setting this to <TRUE/> let the document 
+        For loading of corrupted zip packages: Setting this to <TRUE/> let the document
 		be opened in repair mode, so as much as possible information will be retrieved.
         </p>
 

oox/inc/oox/core/binarycodec.hxx

 #include <rtl/cipher.h>
 #include <rtl/digest.h>
 
+namespace oox { class AttributeList; }
+
 namespace oox {
 namespace core {
 
 // ============================================================================
 
+class CodecHelper
+{
+public:
+    /** Returns the password hash if it is in the required 16-bit limit. */
+    static sal_uInt16   getPasswordHash( const AttributeList& rAttribs, sal_Int32 nElement );
+
+private:
+                        CodecHelper();
+                        ~CodecHelper();
+};
+
+// ============================================================================
+
 /** Encodes and decodes data from/to protected MS Office documents.
 
     Implements a simple XOR encoding/decoding algorithm used in MS Office
         @param pnPassData
             Unicode character array containing the password. Must be zero
             terminated, which results in a maximum length of 15 characters.
-        @param pnUnique
-            Unique document identifier read from or written to the file.
+        @param pnSalt
+            Random salt data block read from or written to the file.
      */
     void                initKey(
                             const sal_uInt16 pnPassData[ 16 ],
-                            const sal_uInt8 pnUnique[ 16 ] );
+                            const sal_uInt8 pnSalt[ 16 ] );
 
     /** Verifies the validity of the password using the passed salt data.
 
             The codec must be initialized with the initKey() function before
             this function can be used.
 
-        @param pnSaltData
-            Salt data block read from the file.
-        @param pnSaltDigest
-            Salt digest read from the file.
+        @param pnVerifier
+            Verifier block read from the file.
+        @param pnVerifierHash
+            Verifier hash read from the file.
 
         @return
             True = test was successful.
      */
     bool                verifyKey(
-                            const sal_uInt8 pnSaltData[ 16 ],
-                            const sal_uInt8 pnSaltDigest[ 16 ] );
+                            const sal_uInt8 pnVerifier[ 16 ],
+                            const sal_uInt8 pnVerifierHash[ 16 ] );
 
     /** Rekeys the codec using the specified counter.
 

oox/inc/oox/core/binaryfilterbase.hxx

 
 private:
     virtual StorageRef  implCreateStorage(
-                            ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStream,
-                            ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream >& rxOutStream ) const;
+                            const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStream ) const;
+    virtual StorageRef  implCreateStorage(
+                            const ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream >& rxOutStream ) const;
 };
 
 typedef ::rtl::Reference< BinaryFilterBase > BinaryFilterRef;

oox/inc/oox/core/filterbase.hxx

 #include <cppuhelper/implbase5.hxx>
 #include "oox/helper/binarystreambase.hxx"
 #include "oox/helper/storagebase.hxx"
-#include <oox/dllapi.h>
+#include "oox/dllapi.h"
 
 namespace com { namespace sun { namespace star {
     namespace lang { class XMultiServiceFactory; }
     namespace graphic { class XGraphic; }
 } } }
 
+namespace comphelper {
+    class IDocPasswordVerifier;
+    class MediaDescriptor;
+}
+
 namespace oox {
     class GraphicHelper;
     class ModelObjectHelper;
     const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&
                         getGlobalFactory() const;
 
+    /** Returns the media descriptor. */
+    ::comphelper::MediaDescriptor& getMediaDescriptor() const;
+
     /** Returns the document model (always existing). */
     const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >&
                         getModel() const;
     /** Returns a system color specified by the passed XML token identifier. */
     sal_Int32           getSystemColor( sal_Int32 nToken, sal_Int32 nDefaultRgb = -1 ) const;
 
+    /** Requests a password from the media descriptor or from the user. On
+        success, the password will be inserted into the media descriptor. */
+    ::rtl::OUString     requestPassword( ::comphelper::IDocPasswordVerifier& rVerifier ) const;
+
     /** Imports the raw binary data from the specified stream.
         @return  True, if the data could be imported from the stream. */
     bool                importBinaryData( StreamDataSequence& orDataSeq, const ::rtl::OUString& rStreamName );
     // com.sun.star.document.XFilter interface --------------------------------
 
     virtual sal_Bool SAL_CALL filter(
-                            const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rDescriptor )
+                            const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rMediaDescSeq )
                             throw( ::com::sun::star::uno::RuntimeException );
 
     virtual void SAL_CALL cancel()
                             throw( ::com::sun::star::uno::RuntimeException );
 
     // ------------------------------------------------------------------------
+protected:
+    virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >
+                        implGetInputStream( ::comphelper::MediaDescriptor& rMediaDesc ) const;
+    virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream >
+                        implGetOutputStream( ::comphelper::MediaDescriptor& rMediaDesc ) const;
+
 private:
+    void                setMediaDescriptor(
+                            const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rMediaDescSeq );
+
     virtual ::rtl::OUString implGetImplementationName() const = 0;
 
     virtual StorageRef  implCreateStorage(
-                            ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStream,
-                            ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream >& rxOutStream ) const = 0;
+                            const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStream ) const = 0;
+    virtual StorageRef  implCreateStorage(
+                            const ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream >& rxOutStream ) const = 0;
 
 private:
     ::std::auto_ptr< FilterBaseImpl > mxImpl;

oox/inc/oox/core/filterdetect.hxx

+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: filterdetect.hxx,v $
+ * $Revision: 1.1 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org.  If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef OOX_CORE_FILTERDETECT_HXX
+#define OOX_CORE_FILTERDETECT_HXX
+
+#include <vector>
+#include <com/sun/star/document/XExtendedFilterDetection.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/xml/sax/XFastDocumentHandler.hpp>
+#include <cppuhelper/implbase1.hxx>
+#include <cppuhelper/implbase2.hxx>
+#include "oox/dllapi.h"
+
+namespace com { namespace sun { namespace star {
+    namespace io { class XInputStream; }
+} } }
+
+namespace comphelper { class MediaDescriptor; }
+namespace oox { class AttributeList; }
+
+namespace oox {
+namespace core {
+
+// ============================================================================
+
+/** Document handler specifically designed for detecting OOXML file formats.
+
+    It takes a reference to the filter string object via its constructor, and
+    puts the name of the detected filter to it, if it successfully finds one.
+ */
+class FilterDetectDocHandler : public ::cppu::WeakImplHelper1< ::com::sun::star::xml::sax::XFastDocumentHandler >
+{
+public:
+    explicit            FilterDetectDocHandler( ::rtl::OUString& rFilter );
+    virtual             ~FilterDetectDocHandler();
+
+    // XFastDocumentHandler
+    virtual void SAL_CALL startDocument() throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+    virtual void SAL_CALL endDocument() throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+    virtual void SAL_CALL setDocumentLocator( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator >& xLocator ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+
+    // XFastContextHandler
+    virtual void SAL_CALL startFastElement( sal_Int32 nElement, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+    virtual void SAL_CALL startUnknownElement( const ::rtl::OUString& Namespace, const ::rtl::OUString& Name, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+    virtual void SAL_CALL endFastElement( sal_Int32 Element ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+    virtual void SAL_CALL endUnknownElement( const ::rtl::OUString& Namespace, const ::rtl::OUString& Name ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+    virtual ::com::sun::star::uno::Reference< XFastContextHandler > SAL_CALL createFastChildContext( sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+    virtual ::com::sun::star::uno::Reference< XFastContextHandler > SAL_CALL createUnknownChildContext( const ::rtl::OUString& Namespace, const ::rtl::OUString& Name, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+    virtual void SAL_CALL characters( const ::rtl::OUString& aChars ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+    virtual void SAL_CALL ignorableWhitespace( const ::rtl::OUString& aWhitespaces ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+    virtual void SAL_CALL processingInstruction( const ::rtl::OUString& aTarget, const ::rtl::OUString& aData ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+
+private:
+    void                parseRelationship( const AttributeList& rAttribs );
+
+    ::rtl::OUString     getFilterNameFromContentType( const ::rtl::OUString& rContentType ) const;
+    void                parseContentTypesDefault( const AttributeList& rAttribs );
+    void                parseContentTypesOverride( const AttributeList& rAttribs );
+
+private:
+    typedef ::std::vector< sal_Int32 > ContextVector;
+
+    ::rtl::OUString&    mrFilterName;
+    ContextVector       maContextStack;
+    ::rtl::OUString     maTargetPath;
+};
+
+// ============================================================================
+
+class OOX_DLLPUBLIC FilterDetect : public ::cppu::WeakImplHelper2< ::com::sun::star::document::XExtendedFilterDetection, ::com::sun::star::lang::XServiceInfo >
+{
+public:
+    explicit            FilterDetect( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxFactory );
+    virtual             ~FilterDetect();
+
+    /** Tries to extract an unencrypted ZIP package from the passed media
+        descriptor.
+
+        First, this function checks if the input stream provided by the media
+        descriptor property 'InputStream' contains a ZIP package. If yes, this
+        stream is returned.
+
+        Second, this function checks if the 'ComponentData' property exists and
+        contains a sequence of com.sun.star.beans.NamedValue. If yes, a named
+        value is searched with the name 'DecryptedPackage' and a value of type
+        com.sun.star.io.XStream. If the input stream provided by this XStream
+        contains a ZIP package, this input stream is returned.
+
+        Third, this function checks if the input stream of the media descriptor
+        contains an OLE package. If yes, it checks the existence of the streams
+        'EncryptionInfo' and 'EncyptedPackage' and tries to decrypt the package
+        into a temporary file. This may include requesting a password from the
+        media descriptor property 'Password' or from the user, using the
+        interaction handler provided by the descriptor. On success, and if the
+        decrypted package is a ZIP package, the XStream of the temporary file
+        is stored in the property 'ComponentData' of the media descriptor and
+        its input stream is returned.
+     */
+    ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >
+                        extractUnencryptedPackage( ::comphelper::MediaDescriptor& rMediaDesc ) const;
+
+    // com.sun.star.lang.XServiceInfo interface -------------------------------
+
+    virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException );
+    virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& rServiceName ) throw( ::com::sun::star::uno::RuntimeException );
+    virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException );
+
+    // com.sun.star.document.XExtendedFilterDetection interface ---------------
+
+    /** Detects MS Office 2007 file types and supports package decryption.
+
+        The following file types are detected:
+        - MS Word 2007 XML Document (*.docx, *.docm)
+        - MS Word 2007 XML Template (*.dotx, *.dotm)
+        - MS Excel 2007 XML Document (*.xlsx, *.xlsm)
+        - MS Excel 2007 BIFF12 Document (*.xlsb)
+        - MS Excel 2007 XML Template (*.xltx, *.xltm)
+        - MS Powerpoint 2007 XML Document (*.pptx, *.pptm)
+        - MS Powerpoint 2007 XML Template (*.potx, *.potm)
+
+        If the package is encrypted, the detection tries to decrypt it into a
+        temporary file. The user may be asked for a password. The XStream
+        interface of the temporary file will be stored in the 'ComponentData'
+        property of the passed media descriptor.
+     */
+    virtual ::rtl::OUString SAL_CALL detect(
+                            ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rMediaDescSeq )
+                            throw( ::com::sun::star::uno::RuntimeException );
+
+private:
+    ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxFactory;
+};
+
+// ============================================================================
+
+} // namespace core
+} // namespace oox
+
+#endif
+

oox/inc/oox/core/xmlfilterbase.hxx

      */
     XmlFilterBase& exportDocumentProperties( ::com::sun::star::uno::Reference< ::com::sun::star::document::XDocumentProperties > xProperties );
 
+protected:
+    virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >
+                        implGetInputStream( ::comphelper::MediaDescriptor& rMediaDesc ) const;
+
 private:
     virtual StorageRef  implCreateStorage(
-                            ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStream,
-                            ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream >& rxOutStream ) const;
+                            const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStream ) const;
+    virtual StorageRef  implCreateStorage(
+                            const ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream >& rxOutStream ) const;
 
 private:
     ::std::auto_ptr< XmlFilterBaseImpl > mxImpl;

oox/inc/oox/dump/dumperbase.hxx

 #include <rtl/ustrbuf.hxx>
 #include <com/sun/star/uno/Reference.hxx>
 #include <com/sun/star/util/DateTime.hpp>
+#include <comphelper/mediadescriptor.hxx>
 #include "oox/helper/helper.hxx"
 #include "oox/helper/storagebase.hxx"
 #include "oox/helper/binaryinputstream.hxx"
     namespace lang { class XMultiServiceFactory; }
 } } }
 
+namespace comphelper {
+    class IDocPasswordVerifier;
+}
+
 namespace oox {
     class BinaryOutputStream;
 }
                             const ::rtl::OUString& rFileName,
                             const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxFactory,
                             const StorageRef& rxRootStrg,
-                            const ::rtl::OUString& rSysFileName );
+                            const ::rtl::OUString& rSysFileName,
+                            ::comphelper::MediaDescriptor& rMediaDesc );
 
     virtual             ~SharedConfigData();
 
     void                eraseNameList( const ::rtl::OUString& rListName );
     NameListRef         getNameList( const ::rtl::OUString& rListName ) const;
 
+    ::rtl::OUString     requestPassword( ::comphelper::IDocPasswordVerifier& rVerifier );
+    inline bool         isPasswordCancelled() const { return mbPwCancelled; }
+
 protected:
     virtual bool        implIsValid() const;
     virtual void        implProcessConfigItemStr(
     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxFactory;
     StorageRef          mxRootStrg;
     ::rtl::OUString     maSysFileName;
+    ::comphelper::MediaDescriptor& mrMediaDesc;
     ConfigFileSet       maConfigFiles;
     ConfigDataMap       maConfigData;
     NameListMap         maNameLists;
     ::rtl::OUString     maConfigPath;
     bool                mbLoaded;
+    bool                mbPwCancelled;
 };
 
 // ----------------------------------------------------------------------------
                             const sal_Char* pcEnvVar,
                             const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxFactory,
                             const StorageRef& rxRootStrg,
-                            const ::rtl::OUString& rSysFileName );
+                            const ::rtl::OUString& rSysFileName,
+                            ::comphelper::MediaDescriptor& rMediaDesc );
 
     virtual             ~Config();
 
     template< typename Type >
     bool                hasName( const NameListWrapper& rListWrp, Type nKey ) const;
 
+    ::rtl::OUString     requestPassword( ::comphelper::IDocPasswordVerifier& rVerifier );
+    bool                isPasswordCancelled() const;
+
 protected:
     inline explicit     Config() {}
     void                construct( const Config& rParent );
                             const sal_Char* pcEnvVar,
                             const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxFactory,
                             const StorageRef& rxRootStrg,
-                            const ::rtl::OUString& rSysFileName );
+                            const ::rtl::OUString& rSysFileName,
+                            ::comphelper::MediaDescriptor& rMediaDesc );
 
     virtual bool        implIsValid() const;
     virtual const ::rtl::OUString* implGetOption( const ::rtl::OUString& rKey ) const;
 protected:
     inline explicit     RecordObjectBase() {}
 
-    inline sal_Int64    getRecPos() const { return mnRecPos; }
-    inline sal_Int64    getRecId() const { return mnRecId; }
-    inline sal_Int64    getRecSize() const { return mnRecSize; }
-    inline NameListRef  getRecNames() const { return maRecNames.getNameList( cfg() ); }
-
     using               InputObjectBase::construct;
     void                construct(
                             const ObjectBase& rParent,
                             const String& rRecNames,
                             const String& rSimpleRecs = EMPTY_STRING );
 
+    inline sal_Int64    getRecPos() const { return mnRecPos; }
+    inline sal_Int64    getRecId() const { return mnRecId; }
+    inline sal_Int64    getRecSize() const { return mnRecSize; }
+    inline NameListRef  getRecNames() const { return maRecNames.getNameList( cfg() ); }
+
+    inline void         setBinaryOnlyMode( bool bBinaryOnly ) { mbBinaryOnly = bBinaryOnly; }
+    inline bool         isBinaryOnlyMode() const { return mbBinaryOnly; }
+
     virtual bool        implIsValid() const;
     virtual void        implDump();
 
     sal_Int64           mnRecId;
     sal_Int64           mnRecSize;
     bool                mbShowRecPos;
+    bool                mbBinaryOnly;
 };
 
 // ============================================================================
     virtual             ~DumperBase();
 
     bool                isImportEnabled() const;
+    bool                isImportCancelled() const;
 
 protected:
     inline explicit     DumperBase() {}
 } // namespace dump
 } // namespace oox
 
-#define OOX_DUMP_FILE( DumperClassName )    \
-do {                                        \
-    DumperClassName aDumper( *this );       \
-    aDumper.dump();                         \
-    if( !aDumper.isImportEnabled() )        \
-        return aDumper.isValid();           \
+#define OOX_DUMP_FILE( DumperClassName )            \
+do {                                                \
+    DumperClassName aDumper( *this );               \
+    aDumper.dump();                                 \
+    bool bCancelled = aDumper.isImportCancelled();  \
+    if( !aDumper.isImportEnabled() || bCancelled )  \
+        return aDumper.isValid() && !bCancelled;    \
 } while( false )
 
 #else   // OOX_INCLUDE_DUMPER

oox/inc/oox/xls/biffcodec.hxx

 #define OOX_XLS_BIFFCODEC_HXX
 
 #include <vector>
+#include <comphelper/docpasswordhelper.hxx>
 #include "oox/core/binarycodec.hxx"
 #include "oox/xls/workbookhelper.hxx"
 
 
 // ============================================================================
 
-const sal_Int32 CODEC_OK                    = 0;
-const sal_Int32 CODEC_ERROR_WRONG_PASS      = 1;
-const sal_Int32 CODEC_ERROR_UNSUPP_CRYPT    = 2;
-
 const sal_Int64 BIFF_RCF_BLOCKSIZE          = 1024;
 
 // ============================================================================
 
 /** Base class for BIFF stream decoders. */
-class BiffDecoderBase : public WorkbookHelper
+class BiffDecoderBase : public ::comphelper::IDocPasswordVerifier
 {
 public:
-    explicit            BiffDecoderBase( const WorkbookHelper& rHelper );
+    explicit            BiffDecoderBase();
     virtual             ~BiffDecoderBase();
 
     /** Derived classes return a clone of the decoder for usage in new streams. */
     inline BiffDecoderBase* clone() { return implClone(); }
 
-    /** Returns the current error code of the decoder. */
-    inline sal_Int32    getErrorCode() const { return mnError; }
-    /** Returns true, if the decoder has been constructed successfully.
-        This means especially that construction happened with a valid password. */
-    inline bool         isValid() const { return mnError == CODEC_OK; }
+    /** Implementation of the ::comphelper::IDocPasswordVerifier interface,
+        calls the new virtual function implVerify(). */
+    virtual ::comphelper::DocPasswordVerifierResult
+                        verifyPassword( const ::rtl::OUString& rPassword );
+
+    /** Returns true, if the decoder has been initialized correctly. */
+    inline bool         isValid() const { return mbValid; }
 
     /** Decodes nBytes bytes and writes encrypted data into the buffer pnDestData. */
     void                decode(
                             sal_Int64 nStreamPos,
                             sal_uInt16 nBytes );
 
-protected:
-    /** Copy constructor for cloning. */
-                        BiffDecoderBase( const BiffDecoderBase& rDecoder );
-
-    /** Sets the decoder to a state showing whether the password was correct. */
-    void                setHasValidPassword( bool bValid );
-
 private:
     /** Derived classes return a clone of the decoder for usage in new streams. */
     virtual BiffDecoderBase* implClone() = 0;
 
+    /** Derived classes implement password verification and initialization of
+        the decoder. */
+    virtual bool        implVerify( const ::rtl::OUString& rPassword ) = 0;
+
     /** Implementation of decryption of a memory block. */
     virtual void        implDecode(
                             sal_uInt8* pnDestData,
                             sal_uInt16 nBytes ) = 0;
 
 private:
-    sal_Int32           mnError;        /// Decoder error code.
+    bool                mbValid;        /// True = decoder is correctly initialized.
 };
 
 typedef ::boost::shared_ptr< BiffDecoderBase > BiffDecoderRef;
 class BiffDecoder_XOR : public BiffDecoderBase
 {
 public:
-    /** Constructs the decoder.
-
-        Checks if the passed key and hash specify workbook protection. Asks for
-        a password otherwise.
-
-        @param nKey
-            Password key from FILEPASS record to verify password.
-        @param nHash
-            Password hash value from FILEPASS record to verify password.
-     */
-    explicit            BiffDecoder_XOR(
-                            const WorkbookHelper& rHelper,
-                            sal_uInt16 nKey, sal_uInt16 nHash );
+    explicit            BiffDecoder_XOR( sal_uInt16 nKey, sal_uInt16 nHash );
 
 private:
     /** Copy constructor for cloning. */
                         BiffDecoder_XOR( const BiffDecoder_XOR& rDecoder );
 
-    /** Initializes the wrapped codec object. After that, internal status can
-        be querried with isValid(). */
-    void                init( const ::rtl::OString& rPass );
-
     /** Returns a clone of the decoder for usage in new streams. */
     virtual BiffDecoder_XOR* implClone();
 
+    /** Implements password verification and initialization of the decoder. */
+    virtual bool        implVerify( const ::rtl::OUString& rPassword );
+
     /** Implementation of decryption of a memory block. */
     virtual void        implDecode(
                             sal_uInt8* pnDestData,
 
 private:
     ::oox::core::BinaryCodec_XOR maCodec;   /// Cipher algorithm implementation.
-    ::rtl::OString      maPass;
+    ::std::vector< sal_uInt8 > maPassword;
     sal_uInt16          mnKey;
     sal_uInt16          mnHash;
 };
 class BiffDecoder_RCF : public BiffDecoderBase
 {
 public:
-    /** Constructs the decoder.
-
-        Checks if the passed salt data specifies workbook protection. Asks for
-        a password otherwise.
-
-        @param pnDocId
-            Unique document identifier from FILEPASS record.
-        @param pnSaltData
-            Salt data from FILEPASS record.
-        @param pnSaltHash
-            Salt hash value from FILEPASS record.
-     */
     explicit            BiffDecoder_RCF(
-                            const WorkbookHelper& rHelper,
-                            sal_uInt8 pnDocId[ 16 ],
-                            sal_uInt8 pnSaltData[ 16 ],
-                            sal_uInt8 pnSaltHash[ 16 ] );
+                            sal_uInt8 pnSalt[ 16 ],
+                            sal_uInt8 pnVerifier[ 16 ],
+                            sal_uInt8 pnVerifierHash[ 16 ] );
 
 private:
     /** Copy constructor for cloning. */
                         BiffDecoder_RCF( const BiffDecoder_RCF& rDecoder );
 
-    /** Initializes the wrapped codec object. After that, internal status can
-        be querried with isValid(). */
-    void                init( const ::rtl::OUString& rPass );
-
     /** Returns a clone of the decoder for usage in new streams. */
     virtual BiffDecoder_RCF* implClone();
 
+    /** Implements password verification and initialization of the decoder. */
+    virtual bool        implVerify( const ::rtl::OUString& rPassword );
+
     /** Implementation of decryption of a memory block. */
     virtual void        implDecode(
                             sal_uInt8* pnDestData,
 
 private:
     ::oox::core::BinaryCodec_RCF maCodec;   /// Cipher algorithm implementation.
-    ::rtl::OUString     maPass;
-    ::std::vector< sal_uInt8 > maDocId;
-    ::std::vector< sal_uInt8 > maSaltData;
-    ::std::vector< sal_uInt8 > maSaltHash;
+    ::std::vector< sal_uInt16 > maPassword;
+    ::std::vector< sal_uInt8 > maSalt;
+    ::std::vector< sal_uInt8 > maVerifier;
+    ::std::vector< sal_uInt8 > maVerifierHash;
 };
 
 // ============================================================================
 public:
     explicit            BiffCodecHelper( const WorkbookHelper& rHelper );
 
-    /** Returns the fixed password for workbook protection. */
-    static const ::rtl::OString& getBiff5WbProtPassword();
-    /** Returns the fixed password for workbook protection. */
-    static const ::rtl::OUString& getBiff8WbProtPassword();
+    /** Implementation helper, reads the FILEPASS and returns a decoder object. */
+    static BiffDecoderRef implReadFilePass( BiffInputStream& rStrm, BiffType eBiff );
 
-    /** Looks for a password provided via API, or queries it via GUI. */
-    ::rtl::OUString     queryPassword();
-
-    /** Imports the FILEPASS record and sets a decoder at the stream. */
+    /** Imports the FILEPASS record, asks for a password and sets a decoder at the stream. */
     bool                importFilePass( BiffInputStream& rStrm );
     /** Clones the contained decoder object if existing and sets it at the passed stream. */
     void                cloneDecoder( BiffInputStream& rStrm );
 
 private:
-    void                importFilePass_XOR( BiffInputStream& rStrm );
-    void                importFilePass_RCF( BiffInputStream& rStrm );
-    void                importFilePass_Strong( BiffInputStream& rStrm );
-    void                importFilePass2( BiffInputStream& rStrm );
-    void                importFilePass8( BiffInputStream& rStrm );
-
-private:
     BiffDecoderRef      mxDecoder;          /// The decoder for import filter.
-    ::rtl::OUString     maPassword;         /// Password for stream encoder/decoder.
-    bool                mbHasPassword;      /// True = password already querried.
 };
 
 // ============================================================================

oox/inc/oox/xls/biffhelper.hxx

 const sal_Int32 OOBIN_ID_EXTSHEETDATA       = 0x016B;
 const sal_Int32 OOBIN_ID_EXTERNALNAMEFLAGS  = 0x024A;
 const sal_Int32 OOBIN_ID_EXTSHEETNAMES      = 0x0167;
+const sal_Int32 OOBIN_ID_FILESHARING        = 0x0224;
 const sal_Int32 OOBIN_ID_FILEVERSION        = 0x0080;
 const sal_Int32 OOBIN_ID_FILL               = 0x002D;
 const sal_Int32 OOBIN_ID_FILLS              = 0x025B;
 const sal_uInt16 BIFF_ID_EXTERNSHEET        = 0x0017;
 const sal_uInt16 BIFF_ID_EXTSST             = 0x00FF;
 const sal_uInt16 BIFF_ID_FILEPASS           = 0x002F;
+const sal_uInt16 BIFF_ID_FILESHARING        = 0x005B;
 const sal_uInt16 BIFF2_ID_FONT              = 0x0031;
 const sal_uInt16 BIFF3_ID_FONT              = 0x0231;
 const sal_uInt16 BIFF5_ID_FONT              = 0x0031;
 const sal_uInt16 BIFF3_ID_IMGDATA           = 0x007F;
 const sal_uInt16 BIFF8_ID_IMGDATA           = 0x00E9;
 const sal_uInt16 BIFF2_ID_INTEGER           = 0x0002;
+const sal_uInt16 BIFF_ID_INTERFACEHDR       = 0x00E1;
 const sal_uInt16 BIFF_ID_ITERATION          = 0x0011;
 const sal_uInt16 BIFF_ID_IXFE               = 0x0044;
 const sal_uInt16 BIFF2_ID_LABEL             = 0x0004;

oox/inc/oox/xls/workbooksettings.hxx

 
 // ============================================================================
 
+/** Settings for workbook write protection. */
+struct FileSharingModel
+{
+    ::rtl::OUString     maUserName;             /// User who added the write protection password.
+    sal_uInt16          mnPasswordHash;         /// Hash value of the write protection password.
+    bool                mbRecommendReadOnly;    /// True = recommend read-only mode on opening.
+
+    explicit            FileSharingModel();
+};
+
+// ============================================================================
+
 /** Global workbook settings. */
 struct WorkbookSettingsModel
 {
 public:
     explicit            WorkbookSettings( const WorkbookHelper& rHelper );
 
+    /** Imports the fileSharing element containing write protection settings. */
+    void                importFileSharing( const AttributeList& rAttribs );
     /** Imports the workbookPr element containing global workbook settings. */
     void                importWorkbookPr( const AttributeList& rAttribs );
     /** Imports the calcPr element containing workbook calculation settings. */
     void                importCalcPr( const AttributeList& rAttribs );
 
+    /** Imports the FILESHARING record containing write protection settings. */
+    void                importFileSharing( RecordInputStream& rStrm );
     /** Imports the WORKBOOKPR record containing global workbook settings. */
     void                importWorkbookPr( RecordInputStream& rStrm );
     /** Imports the CALCPR record containing workbook calculation settings. */
 
     /** Sets the save external linked values flag, e.g. from the WSBOOL record. */
     void                setSaveExtLinkValues( bool bSaveExtLinks );
+    /** Imports the FILESHARING record. */
+    void                importFileSharing( BiffInputStream& rStrm );
     /** Imports the BOOKBOOL record. */
     void                importBookBool( BiffInputStream& rStrm );
     /** Imports the CALCCOUNT record. */
     void                setDateMode( bool bDateMode1904 );
 
 private:
+    FileSharingModel    maFileSharing;
     WorkbookSettingsModel maBookSettings;
     CalcSettingsModel   maCalcSettings;
 };

oox/prj/build.lst

-oox	oox : vos cppu cppuhelper comphelper sal offapi sax basegfx tools vcl BOOST:boost NULL
+oox	oox : vos cppu cppuhelper comphelper sal offapi sax basegfx tools vcl BOOST:boost OPENSSL:openssl NULL
 oox	oox				usr1	-   all	oox_mkout NULL
 oox	oox\prj				get	-   all	oox_prj NULL
 oox	oox\source\token		nmake	-   all	oox_token NULL
 mkdir: %_DEST%\inc%_EXT%\oox
+mkdir: %_DEST%\inc%_EXT%\oox\helper
 mkdir: %_DEST%\inc%_EXT%\oox\core
-mkdir: %_DEST%\inc%_EXT%\oox\helper
-mkdir: %_DEST%\inc%_EXT%\oox\vml
 mkdir: %_DEST%\inc%_EXT%\oox\drawingml
 mkdir: %_DEST%\inc%_EXT%\oox\drawingml\chart
 mkdir: %_DEST%\inc%_EXT%\oox\drawingml\table
+mkdir: %_DEST%\inc%_EXT%\oox\vml
 
 ..\%__SRC%\misc\*.map %_DEST%\bin%_EXT%\*.map
 ..\%__SRC%\lib\ixo.lib %_DEST%\lib%_EXT%\ixo.lib
 ..\%__SRC%\bin\*.dll %_DEST%\bin%_EXT%\*.dll
 ..\%__SRC%\lib\lib*.so %_DEST%\lib%_EXT%\lib*.so
 ..\%__SRC%\lib\i*.lib %_DEST%\lib%_EXT%\i*.lib
+..\%__SRC%\lib\*.dylib %_DEST%\lib%_EXT%\*.dylib
 
+..\%__SRC%\inc\tokens.hxx %_DEST%\inc%_EXT%\oox\core\tokens.hxx
+
+..\source\token\tokens.txt %_DEST%\inc%_EXT%\oox\token.txt
 ..\inc\oox\dllapi.h %_DEST%\inc%_EXT%\oox\dllapi.h
-..\source\token\tokens.txt %_DEST%\inc%_EXT%\oox\token.txt
-..\inc\oox\core\filterbase.hxx %_DEST%\inc%_EXT%\oox\core\filterbase.hxx
-..\inc\oox\core\relations.hxx %_DEST%\inc%_EXT%\oox\core\relations.hxx
-..\%__SRC%\inc\tokens.hxx %_DEST%\inc%_EXT%\oox\core\tokens.hxx
-..\inc\oox\core\xmlfilterbase.hxx %_DEST%\inc%_EXT%\oox\core\xmlfilterbase.hxx
 ..\inc\oox\helper\binarystreambase.hxx %_DEST%\inc%_EXT%\oox\helper\binarystreambase.hxx
 ..\inc\oox\helper\helper.hxx %_DEST%\inc%_EXT%\oox\helper\helper.hxx
 ..\inc\oox\helper\storagebase.hxx %_DEST%\inc%_EXT%\oox\helper\storagebase.hxx
 ..\inc\oox\helper\zipstorage.hxx %_DEST%\inc%_EXT%\oox\helper\zipstorage.hxx
-..\inc\oox\vml\drawing.hxx %_DEST%\inc%_EXT%\oox\vml\drawing.hxx
+..\inc\oox\core\filterbase.hxx %_DEST%\inc%_EXT%\oox\core\filterbase.hxx
+..\inc\oox\core\filterdetect.hxx %_DEST%\inc%_EXT%\oox\core\filterdetect.hxx
+..\inc\oox\core\relations.hxx %_DEST%\inc%_EXT%\oox\core\relations.hxx
+..\inc\oox\core\xmlfilterbase.hxx %_DEST%\inc%_EXT%\oox\core\xmlfilterbase.hxx
 ..\inc\oox\drawingml\chart\chartconverter.hxx %_DEST%\inc%_EXT%\oox\drawingml\chart\chartconverter.hxx
 ..\inc\oox\drawingml\table\tablestylelist.hxx %_DEST%\inc%_EXT%\oox\drawingml\table\tablestylelist.hxx
-..\inc\oox\vml\shape.hxx %_DEST%\inc%_EXT%\oox\vml\shape.hxx
-
-..\%__SRC%\lib\*.dylib %_DEST%\lib%_EXT%\*.dylib
+..\inc\oox\vml\vmldrawing.hxx %_DEST%\inc%_EXT%\oox\vml\vmldrawing.hxx
+..\inc\oox\vml\vmlshape.hxx %_DEST%\inc%_EXT%\oox\vml\vmlshape.hxx
 
 dos: sh -c "if test %OS% = MACOSX; then create-bundle %_DEST%\lib%_EXT%\*.dylib; fi"
 

oox/source/core/binarycodec.cxx

 /*************************************************************************
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- * 
+ *
  * Copyright 2008 by Sun Microsystems, Inc.
  *
  * OpenOffice.org - a multi-platform office productivity suite
 #include "oox/core/binarycodec.hxx"
 #include <algorithm>
 #include <string.h>
-#include <osl/diagnose.h>
+#include "oox/helper/attributelist.hxx"
 
 namespace oox {
 namespace core {
 
 // ============================================================================
 
+/*static*/ sal_uInt16 CodecHelper::getPasswordHash( const AttributeList& rAttribs, sal_Int32 nElement )
+{
+    sal_Int32 nPasswordHash = rAttribs.getIntegerHex( nElement, 0 );
+    OSL_ENSURE( (0 <= nPasswordHash) && (nPasswordHash <= SAL_MAX_UINT16), "CodecHelper::getPasswordHash - invalid password hash" );
+    return static_cast< sal_uInt16 >( ((0 <= nPasswordHash) && (nPasswordHash <= SAL_MAX_UINT16)) ? nPasswordHash : 0 );
+}
+
+// ============================================================================
+
 BinaryCodec_XOR::BinaryCodec_XOR( CodecType eCodecType ) :
     meCodecType( eCodecType ),
     mnOffset( 0 ),
     rtl_cipher_destroy( mhCipher );
 }
 
-void BinaryCodec_RCF::initKey( const sal_uInt16 pnPassData[ 16 ], const sal_uInt8 pnUnique[ 16 ] )
+void BinaryCodec_RCF::initKey( const sal_uInt16 pnPassData[ 16 ], const sal_uInt8 pnSalt[ 16 ] )
 {
     // create little-endian key data array from password data
     sal_uInt8 pnKeyData[ 64 ];
     (void)rtl_digest_updateMD5( mhDigest, pnKeyData, sizeof( pnKeyData ) );
     (void)rtl_digest_rawMD5( mhDigest, pnKeyData, RTL_DIGEST_LENGTH_MD5 );
 
-    // update digest with key data and passed unique data
+    // update digest with key data and passed salt data
     for( size_t nIndex = 0; nIndex < 16; ++nIndex )
     {
         rtl_digest_updateMD5( mhDigest, pnKeyData, 5 );
-        rtl_digest_updateMD5( mhDigest, pnUnique, 16 );
+        rtl_digest_updateMD5( mhDigest, pnSalt, 16 );
     }
 
     // update digest with padding
     (void)memset( pnKeyData, 0, sizeof( pnKeyData ) );
 }
 
-bool BinaryCodec_RCF::verifyKey( const sal_uInt8 pnSaltData[ 16 ], const sal_uInt8 pnSaltDigest[ 16 ] )
+bool BinaryCodec_RCF::verifyKey( const sal_uInt8 pnVerifier[ 16 ], const sal_uInt8 pnVerifierHash[ 16 ] )
 {
     if( !startBlock( 0 ) )
         return false;
     sal_uInt8 pnBuffer[ 64 ];
 
     // decode salt data into buffer
-    rtl_cipher_decode( mhCipher, pnSaltData, 16, pnBuffer, sizeof( pnBuffer ) );
+    rtl_cipher_decode( mhCipher, pnVerifier, 16, pnBuffer, sizeof( pnBuffer ) );
 
     pnBuffer[ 16 ] = 0x80;
     (void)memset( pnBuffer + 17, 0, sizeof( pnBuffer ) - 17 );
     rtl_digest_rawMD5( mhDigest, pnDigest, sizeof( pnDigest ) );
 
     // decode original salt digest into buffer
-    rtl_cipher_decode( mhCipher, pnSaltDigest, 16, pnBuffer, sizeof( pnBuffer ) );
+    rtl_cipher_decode( mhCipher, pnVerifierHash, 16, pnBuffer, sizeof( pnBuffer ) );
 
     // compare buffer with computed digest
     bool bResult = memcmp( pnBuffer, pnDigest, sizeof( pnDigest ) ) == 0;

oox/source/core/binaryfilterbase.cxx

 {
 }
 
-StorageRef BinaryFilterBase::implCreateStorage(
-        Reference< XInputStream >& rxInStream, Reference< XStream >& rxOutStream ) const
+// private --------------------------------------------------------------------
+
+StorageRef BinaryFilterBase::implCreateStorage( const Reference< XInputStream >& rxInStream ) const
 {
-    StorageRef xStorage;
-    if( rxInStream.is() )
-        xStorage.reset( new OleStorage( getGlobalFactory(), rxInStream, true ) );
-    else if( rxOutStream.is() )
-        xStorage.reset( new OleStorage( getGlobalFactory(), rxOutStream, true ) );
-    return xStorage;
+    return StorageRef( new OleStorage( getGlobalFactory(), rxInStream, true ) );
+}
+
+StorageRef BinaryFilterBase::implCreateStorage( const Reference< XStream >& rxOutStream ) const
+{
+    return StorageRef( new OleStorage( getGlobalFactory(), rxOutStream, true ) );
 }
 
 // ============================================================================

oox/source/core/filterbase.cxx

 #include <osl/mutex.hxx>
 #include <rtl/instance.hxx>
 #include <rtl/uri.hxx>