summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--comphelper/inc/comphelper/docpasswordhelper.hxx212
-rw-r--r--comphelper/inc/comphelper/docpasswordrequest.hxx91
-rw-r--r--comphelper/inc/comphelper/mediadescriptor.hxx2
-rw-r--r--comphelper/source/misc/docpasswordhelper.cxx152
-rw-r--r--comphelper/source/misc/docpasswordrequest.cxx153
-rw-r--r--comphelper/source/misc/makefile.mk2
-rw-r--r--comphelper/source/misc/mediadescriptor.cxx12
-rw-r--r--svtools/inc/docmspasswdrequest.hxx72
-rw-r--r--svtools/inc/docpasswdrequest.hxx71
-rw-r--r--svtools/source/misc1/docmspasswdrequest.cxx143
-rw-r--r--svtools/source/misc1/docpasswdrequest.cxx142
-rw-r--r--svtools/source/misc1/makefile.mk4
12 files changed, 625 insertions, 431 deletions
diff --git a/comphelper/inc/comphelper/docpasswordhelper.hxx b/comphelper/inc/comphelper/docpasswordhelper.hxx
new file mode 100644
index 000000000000..90927a3e9c6c
--- /dev/null
+++ b/comphelper/inc/comphelper/docpasswordhelper.hxx
@@ -0,0 +1,212 @@
+/*************************************************************************
+ *
+ * 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
+
diff --git a/comphelper/inc/comphelper/docpasswordrequest.hxx b/comphelper/inc/comphelper/docpasswordrequest.hxx
new file mode 100644
index 000000000000..b1e042e876bd
--- /dev/null
+++ b/comphelper/inc/comphelper/docpasswordrequest.hxx
@@ -0,0 +1,91 @@
+/*************************************************************************
+ *
+ * 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
+
diff --git a/comphelper/inc/comphelper/mediadescriptor.hxx b/comphelper/inc/comphelper/mediadescriptor.hxx
index 5cd36d2e687b..e388c0b4ca3c 100644
--- a/comphelper/inc/comphelper/mediadescriptor.hxx
+++ b/comphelper/inc/comphelper/mediadescriptor.hxx
@@ -74,8 +74,10 @@ class COMPHELPER_DLLPUBLIC MediaDescriptor : public SequenceAsHashMap
does not work as expected under windows (under unix it works as well)
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();
diff --git a/comphelper/source/misc/docpasswordhelper.cxx b/comphelper/source/misc/docpasswordhelper.cxx
new file mode 100644
index 000000000000..1f362c02f881
--- /dev/null
+++ b/comphelper/source/misc/docpasswordhelper.cxx
@@ -0,0 +1,152 @@
+/*************************************************************************
+ *
+ * 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
+
diff --git a/comphelper/source/misc/docpasswordrequest.cxx b/comphelper/source/misc/docpasswordrequest.cxx
new file mode 100644
index 000000000000..187642e10fe9
--- /dev/null
+++ b/comphelper/source/misc/docpasswordrequest.cxx
@@ -0,0 +1,153 @@
+/*************************************************************************
+ *
+ * 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
+
diff --git a/comphelper/source/misc/makefile.mk b/comphelper/source/misc/makefile.mk
index f50f57c47eb3..d0ffc368fd20 100644
--- a/comphelper/source/misc/makefile.mk
+++ b/comphelper/source/misc/makefile.mk
@@ -57,6 +57,8 @@ SLOFILES= \
$(SLO)$/componentcontext.obj \
$(SLO)$/componentmodule.obj \
$(SLO)$/configurationhelper.obj \
+ $(SLO)$/docpasswordhelper.obj \
+ $(SLO)$/docpasswordrequest.obj \
$(SLO)$/documentinfo.obj \
$(SLO)$/documentiologring.obj \
$(SLO)$/evtlistenerhlp.obj \
diff --git a/comphelper/source/misc/mediadescriptor.cxx b/comphelper/source/misc/mediadescriptor.cxx
index 9f463cdf0380..44578f840da9 100644
--- a/comphelper/source/misc/mediadescriptor.cxx
+++ b/comphelper/source/misc/mediadescriptor.cxx
@@ -114,6 +114,12 @@ namespace css = ::com::sun::star;
/*-----------------------------------------------
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"));
@@ -126,6 +132,12 @@ const ::rtl::OUString& MediaDescriptor::PROP_CHARACTERSET()
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"));
diff --git a/svtools/inc/docmspasswdrequest.hxx b/svtools/inc/docmspasswdrequest.hxx
deleted file mode 100644
index 684bffe71760..000000000000
--- a/svtools/inc/docmspasswdrequest.hxx
+++ /dev/null
@@ -1,72 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright IBM Corporation 2009.
- * Copyright 2009 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: docmspasswdrequest.hxx,v $
- * $Revision: 1.0 $
- *
- * 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 INCLUDED_SVTOOLS_DOCMSPASSWDREQUEST_HXX
-#define INCLUDED_SVTOOLS_DOCMSPASSWDREQUEST_HXX
-
-#include "svtools/svldllapi.h"
-#include <com/sun/star/task/DocumentMSPasswordRequest.hpp>
-#include <com/sun/star/task/XInteractionRequest.hpp>
-#include <rtl/ustring.hxx>
-#include <cppuhelper/implbase1.hxx>
-
-class MSAbortContinuation;
-class MSPasswordContinuation;
-
-class SVL_DLLPUBLIC RequestMSDocumentPassword : public ::cppu::WeakImplHelper1< ::com::sun::star::task::XInteractionRequest >
-{
- ::com::sun::star::uno::Any m_aRequest;
-
- ::com::sun::star::uno::Sequence<
- ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation >
- > m_lContinuations;
-
- MSAbortContinuation* m_pAbort;
- MSPasswordContinuation* m_pPassword;
-
-public:
- RequestMSDocumentPassword( ::com::sun::star::task::PasswordRequestMode nMode, ::rtl::OUString aName );
-
- sal_Bool isAbort();
- sal_Bool isPassword();
-
- ::rtl::OUString getPassword();
-
- 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 );
-};
-
-#endif /* INCLUDED_SVTOOLS_DOCMSPASSWDREQUEST_HXX */
diff --git a/svtools/inc/docpasswdrequest.hxx b/svtools/inc/docpasswdrequest.hxx
deleted file mode 100644
index 69095fbe5a5c..000000000000
--- a/svtools/inc/docpasswdrequest.hxx
+++ /dev/null
@@ -1,71 +0,0 @@
-/*************************************************************************
- *
- * 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: docpasswdrequest.hxx,v $
- * $Revision: 1.4 $
- *
- * 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 INCLUDED_SVTOOLS_DOCPASSWDREQUEST_HXX
-#define INCLUDED_SVTOOLS_DOCPASSWDREQUEST_HXX
-
-#include "svtools/svldllapi.h"
-#include <com/sun/star/task/DocumentPasswordRequest.hpp>
-#include <com/sun/star/task/XInteractionRequest.hpp>
-#include <rtl/ustring.hxx>
-#include <cppuhelper/implbase1.hxx>
-
-class AbortContinuation;
-class PasswordContinuation;
-
-class SVL_DLLPUBLIC RequestDocumentPassword : public ::cppu::WeakImplHelper1< ::com::sun::star::task::XInteractionRequest >
-{
- ::com::sun::star::uno::Any m_aRequest;
-
- ::com::sun::star::uno::Sequence<
- ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation >
- > m_lContinuations;
-
- AbortContinuation* m_pAbort;
- PasswordContinuation* m_pPassword;
-
-public:
- RequestDocumentPassword( ::com::sun::star::task::PasswordRequestMode nMode, ::rtl::OUString aName );
-
- sal_Bool isAbort();
- sal_Bool isPassword();
-
- ::rtl::OUString getPassword();
-
- 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 );
-};
-
-#endif /* INCLUDED_SVTOOLS_DOCPASSWDREQUEST_HXX */
diff --git a/svtools/source/misc1/docmspasswdrequest.cxx b/svtools/source/misc1/docmspasswdrequest.cxx
deleted file mode 100644
index e892d3a57d1a..000000000000
--- a/svtools/source/misc1/docmspasswdrequest.cxx
+++ /dev/null
@@ -1,143 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright IBM Corporation 2009.
- * Copyright 2009 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: docmspasswdrequest.cxx,v $
- * $Revision: 1.0 $
- *
- * 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_svtools.hxx"
-
-#include "docmspasswdrequest.hxx"
-#include <com/sun/star/task/XInteractionAbort.hpp>
-#include <com/sun/star/task/XInteractionPassword.hpp>
-
-//==========================================================================
-
-class MSAbortContinuation : public ::cppu::WeakImplHelper1< ::com::sun::star::task::XInteractionAbort >
-{
- sal_Bool mbSelected;
-
-public:
- MSAbortContinuation() : mbSelected( sal_False ) {}
-
- sal_Bool isSelected() { return mbSelected; }
-
- void reset() { mbSelected = sal_False; }
-
- virtual void SAL_CALL select() throw(::com::sun::star::uno::RuntimeException) { mbSelected = sal_True; }
-};
-
-//==========================================================================
-
-class MSPasswordContinuation : public ::cppu::WeakImplHelper1< ::com::sun::star::task::XInteractionPassword >
-{
- sal_Bool mbSelected;
- ::rtl::OUString maPassword;
-
-public:
- MSPasswordContinuation() : mbSelected( sal_False ) {}
-
- sal_Bool isSelected() { return mbSelected; }
-
- void reset() { mbSelected = sal_False; }
-
- virtual void SAL_CALL select() throw(::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL setPassword( const ::rtl::OUString& aPass ) throw (::com::sun::star::uno::RuntimeException);
- virtual ::rtl::OUString SAL_CALL getPassword( ) throw (::com::sun::star::uno::RuntimeException);
-};
-
-void SAL_CALL MSPasswordContinuation::select()
- throw(::com::sun::star::uno::RuntimeException)
-{
- mbSelected = sal_True;
-}
-
-void SAL_CALL MSPasswordContinuation::setPassword( const ::rtl::OUString& aPass )
- throw (::com::sun::star::uno::RuntimeException)
-{
- maPassword = aPass;
-}
-
-::rtl::OUString SAL_CALL MSPasswordContinuation::getPassword()
- throw (::com::sun::star::uno::RuntimeException)
-{
- return maPassword;
-}
-
-//==========================================================================
-
-RequestMSDocumentPassword::RequestMSDocumentPassword( ::com::sun::star::task::PasswordRequestMode nMode, ::rtl::OUString aName )
-{
- ::rtl::OUString temp;
- ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > temp2;
- ::com::sun::star::task::DocumentMSPasswordRequest
- aDocumentMSPasswordRequest( temp,
- temp2,
- ::com::sun::star::task::InteractionClassification_QUERY,
- nMode,
- aName );
-
- m_aRequest <<= aDocumentMSPasswordRequest;
-
- m_pAbort = new MSAbortContinuation;
- m_pPassword = new MSPasswordContinuation;
-
- m_lContinuations.realloc( 2 );
- m_lContinuations[0] = ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation >( m_pAbort );
- m_lContinuations[1] = ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation >( m_pPassword );
-}
-
-sal_Bool RequestMSDocumentPassword::isAbort()
-{
- return m_pAbort->isSelected();
-}
-
-sal_Bool RequestMSDocumentPassword::isPassword()
-{
- return m_pPassword->isSelected();
-}
-
-::rtl::OUString RequestMSDocumentPassword::getPassword()
-{
- return m_pPassword->getPassword();
-}
-
-::com::sun::star::uno::Any SAL_CALL RequestMSDocumentPassword::getRequest()
- throw( ::com::sun::star::uno::RuntimeException )
-{
- return m_aRequest;
-}
-
-::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > >
- SAL_CALL RequestMSDocumentPassword::getContinuations()
- throw( ::com::sun::star::uno::RuntimeException )
-{
- return m_lContinuations;
-}
-
-
diff --git a/svtools/source/misc1/docpasswdrequest.cxx b/svtools/source/misc1/docpasswdrequest.cxx
deleted file mode 100644
index 37ceb85ec132..000000000000
--- a/svtools/source/misc1/docpasswdrequest.cxx
+++ /dev/null
@@ -1,142 +0,0 @@
-/*************************************************************************
- *
- * 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: docpasswdrequest.cxx,v $
- * $Revision: 1.5 $
- *
- * 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_svtools.hxx"
-
-#include "docpasswdrequest.hxx"
-#include <com/sun/star/task/XInteractionAbort.hpp>
-#include <com/sun/star/task/XInteractionPassword.hpp>
-
-//==========================================================================
-
-class AbortContinuation : public ::cppu::WeakImplHelper1< ::com::sun::star::task::XInteractionAbort >
-{
- sal_Bool mbSelected;
-
-public:
- AbortContinuation() : mbSelected( sal_False ) {}
-
- sal_Bool isSelected() { return mbSelected; }
-
- void reset() { mbSelected = sal_False; }
-
- virtual void SAL_CALL select() throw(::com::sun::star::uno::RuntimeException) { mbSelected = sal_True; }
-};
-
-//==========================================================================
-
-class PasswordContinuation : public ::cppu::WeakImplHelper1< ::com::sun::star::task::XInteractionPassword >
-{
- sal_Bool mbSelected;
- ::rtl::OUString maPassword;
-
-public:
- PasswordContinuation() : mbSelected( sal_False ) {}
-
- sal_Bool isSelected() { return mbSelected; }
-
- void reset() { mbSelected = sal_False; }
-
- virtual void SAL_CALL select() throw(::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL setPassword( const ::rtl::OUString& aPass ) throw (::com::sun::star::uno::RuntimeException);
- virtual ::rtl::OUString SAL_CALL getPassword( ) throw (::com::sun::star::uno::RuntimeException);
-};
-
-void SAL_CALL PasswordContinuation::select()
- throw(::com::sun::star::uno::RuntimeException)
-{
- mbSelected = sal_True;
-}
-
-void SAL_CALL PasswordContinuation::setPassword( const ::rtl::OUString& aPass )
- throw (::com::sun::star::uno::RuntimeException)
-{
- maPassword = aPass;
-}
-
-::rtl::OUString SAL_CALL PasswordContinuation::getPassword()
- throw (::com::sun::star::uno::RuntimeException)
-{
- return maPassword;
-}
-
-//==========================================================================
-
-RequestDocumentPassword::RequestDocumentPassword( ::com::sun::star::task::PasswordRequestMode nMode, ::rtl::OUString aName )
-{
- ::rtl::OUString temp;
- ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > temp2;
- ::com::sun::star::task::DocumentPasswordRequest
- aDocumentPasswordRequest( temp,
- temp2,
- ::com::sun::star::task::InteractionClassification_QUERY,
- nMode,
- aName );
-
- m_aRequest <<= aDocumentPasswordRequest;
-
- m_pAbort = new AbortContinuation;
- m_pPassword = new PasswordContinuation;
-
- m_lContinuations.realloc( 2 );
- m_lContinuations[0] = ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation >( m_pAbort );
- m_lContinuations[1] = ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation >( m_pPassword );
-}
-
-sal_Bool RequestDocumentPassword::isAbort()
-{
- return m_pAbort->isSelected();
-}
-
-sal_Bool RequestDocumentPassword::isPassword()
-{
- return m_pPassword->isSelected();
-}
-
-::rtl::OUString RequestDocumentPassword::getPassword()
-{
- return m_pPassword->getPassword();
-}
-
-::com::sun::star::uno::Any SAL_CALL RequestDocumentPassword::getRequest()
- throw( ::com::sun::star::uno::RuntimeException )
-{
- return m_aRequest;
-}
-
-::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > >
- SAL_CALL RequestDocumentPassword::getContinuations()
- throw( ::com::sun::star::uno::RuntimeException )
-{
- return m_lContinuations;
-}
-
-
diff --git a/svtools/source/misc1/makefile.mk b/svtools/source/misc1/makefile.mk
index 3ca57ff36f92..e74afd81d83c 100644
--- a/svtools/source/misc1/makefile.mk
+++ b/svtools/source/misc1/makefile.mk
@@ -1,7 +1,7 @@
#*************************************************************************
#
# 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
@@ -49,8 +49,6 @@ EXCEPTIONSFILES=\
SLOFILES=\
$(EXCEPTIONSFILES) \
$(SLO)$/adrparse.obj \
- $(SLO)$/docpasswdrequest.obj \
- $(SLO)$/docmspasswdrequest.obj \
$(SLO)$/filenotation.obj \
$(SLO)$/inethist.obj \
$(SLO)$/inettype.obj \