summaryrefslogtreecommitdiff
path: root/comphelper
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2013-11-12 18:12:26 +0100
committerStephan Bergmann <sbergman@redhat.com>2013-11-14 11:13:23 +0100
commit8061c8c70b7ffcd8f472d2f5b909911f2095fec7 (patch)
treeda1cee91243467e3d88ad763d7786c147eb93a7d /comphelper
parent18be6f161de20f3b0e05d0dd494242eda16ee5c4 (diff)
Make requestAndVerifyDocPassword var with MediaDescriptor a mem fn of latter
Change-Id: I645d554c7ce592d93ca0696fa7e6068ce40c9058
Diffstat (limited to 'comphelper')
-rw-r--r--comphelper/source/misc/docpasswordhelper.cxx33
-rw-r--r--comphelper/source/misc/mediadescriptor.cxx29
2 files changed, 30 insertions, 32 deletions
diff --git a/comphelper/source/misc/docpasswordhelper.cxx b/comphelper/source/misc/docpasswordhelper.cxx
index 6f177e68bf2a..9d312a341f58 100644
--- a/comphelper/source/misc/docpasswordhelper.cxx
+++ b/comphelper/source/misc/docpasswordhelper.cxx
@@ -19,8 +19,8 @@
#include "comphelper/docpasswordhelper.hxx"
+#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/task/XInteractionHandler.hpp>
-#include "comphelper/mediadescriptor.hxx"
#include <osl/time.h>
#include <rtl/digest.h>
@@ -412,37 +412,6 @@ Sequence< sal_Int8 > DocPasswordHelper::GetXLHashAsSequence(
return (eResult == DocPasswordVerifierResult_OK) ? aEncData : uno::Sequence< beans::NamedValue >();
}
-/*static*/ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > DocPasswordHelper::requestAndVerifyDocPassword(
- IDocPasswordVerifier& rVerifier,
- MediaDescriptor& rMediaDesc,
- DocPasswordRequestType eRequestType,
- const ::std::vector< OUString >* pDefaultPasswords )
-{
- uno::Sequence< beans::NamedValue > aMediaEncData = rMediaDesc.getUnpackedValueOrDefault(
- MediaDescriptor::PROP_ENCRYPTIONDATA(), uno::Sequence< beans::NamedValue >() );
- 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;
- uno::Sequence< beans::NamedValue > aEncryptionData = requestAndVerifyDocPassword(
- rVerifier, aMediaEncData, aMediaPassword, xInteractHandler, aDocumentName, eRequestType, pDefaultPasswords, &bIsDefaultPassword );
-
- rMediaDesc.erase( MediaDescriptor::PROP_PASSWORD() );
- rMediaDesc.erase( MediaDescriptor::PROP_ENCRYPTIONDATA() );
-
- // insert valid password into media descriptor (but not a default password)
- if( (aEncryptionData.getLength() > 0) && !bIsDefaultPassword )
- rMediaDesc[ MediaDescriptor::PROP_ENCRYPTIONDATA() ] <<= aEncryptionData;
-
- return aEncryptionData;
-}
-
-// ============================================================================
-
} // namespace comphelper
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/comphelper/source/misc/mediadescriptor.cxx b/comphelper/source/misc/mediadescriptor.cxx
index fd2ff28c0e5f..44665c5b956a 100644
--- a/comphelper/source/misc/mediadescriptor.cxx
+++ b/comphelper/source/misc/mediadescriptor.cxx
@@ -17,6 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <comphelper/docpasswordhelper.hxx>
#include <comphelper/mediadescriptor.hxx>
#include <comphelper/namedvaluecollection.hxx>
#include <comphelper/stillreadwriteinteraction.hxx>
@@ -444,6 +445,34 @@ void MediaDescriptor::clearComponentDataEntry( const OUString& rName )
}
}
+::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > MediaDescriptor::requestAndVerifyDocPassword(
+ IDocPasswordVerifier& rVerifier,
+ DocPasswordRequestType eRequestType,
+ const ::std::vector< OUString >* pDefaultPasswords )
+{
+ css::uno::Sequence< css::beans::NamedValue > aMediaEncData = getUnpackedValueOrDefault(
+ PROP_ENCRYPTIONDATA(), css::uno::Sequence< css::beans::NamedValue >() );
+ OUString aMediaPassword = getUnpackedValueOrDefault(
+ PROP_PASSWORD(), OUString() );
+ css::uno::Reference< css::task::XInteractionHandler > xInteractHandler = getUnpackedValueOrDefault(
+ PROP_INTERACTIONHANDLER(), css::uno::Reference< css::task::XInteractionHandler >() );
+ OUString aDocumentName = getUnpackedValueOrDefault(
+ PROP_URL(), OUString() );
+
+ bool bIsDefaultPassword = false;
+ css::uno::Sequence< css::beans::NamedValue > aEncryptionData = DocPasswordHelper::requestAndVerifyDocPassword(
+ rVerifier, aMediaEncData, aMediaPassword, xInteractHandler, aDocumentName, eRequestType, pDefaultPasswords, &bIsDefaultPassword );
+
+ erase( PROP_PASSWORD() );
+ erase( PROP_ENCRYPTIONDATA() );
+
+ // insert valid password into media descriptor (but not a default password)
+ if( (aEncryptionData.getLength() > 0) && !bIsDefaultPassword )
+ (*this)[ PROP_ENCRYPTIONDATA() ] <<= aEncryptionData;
+
+ return aEncryptionData;
+}
+
sal_Bool MediaDescriptor::addInputStream()
{
return impl_addInputStream( sal_True );