[Libreoffice-commits] core.git: Branch 'libreoffice-6-4' - sfx2/source uui/source
Eike Rathke (via logerrit)
logerrit at kemper.freedesktop.org
Sat Nov 30 03:04:56 UTC 2019
sfx2/source/dialog/filedlghelper.cxx | 10 ++-
uui/source/iahndl-authentication.cxx | 90 ++++++++++++++++++-----------------
2 files changed, 53 insertions(+), 47 deletions(-)
New commits:
commit 8bf39e6cfd988089bd0eab0958c96f8fc3413b9d
Author: Eike Rathke <erack at redhat.com>
AuthorDate: Sat Nov 30 01:26:32 2019 +0100
Commit: Eike Rathke <erack at redhat.com>
CommitDate: Sat Nov 30 04:04:04 2019 +0100
Resolves: tdf#97086 Allow "unlimited" password length for OOXML encryption
Change-Id: I51175424e19ad02b81120c3fdea22732cd481a8d
Reviewed-on: https://gerrit.libreoffice.org/84097
Reviewed-by: Eike Rathke <erack at redhat.com>
Tested-by: Jenkins
(cherry picked from commit adb7106a7c805d332c8098891996a75e6ec4caf8)
Reviewed-on: https://gerrit.libreoffice.org/84100
diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx
index a6a9dc675054..8e99b47bd4bd 100644
--- a/sfx2/source/dialog/filedlghelper.cxx
+++ b/sfx2/source/dialog/filedlghelper.cxx
@@ -2660,8 +2660,11 @@ ErrCode RequestPassword(const std::shared_ptr<const SfxFilter>& pCurrentFilter,
uno::Reference<task::XInteractionHandler2> xInteractionHandler = task::InteractionHandler::createWithParent(::comphelper::getProcessComponentContext(), rParent);
// TODO: need a save way to distinguish MS filters from other filters
// for now MS-filters are the only alien filters that support encryption
- bool bMSType = !pCurrentFilter->IsOwnFormat();
- ::comphelper::DocPasswordRequestType eType = bMSType ?
+ const bool bMSType = !pCurrentFilter->IsOwnFormat();
+ // For OOXML we can use the standard password ("unlimited" characters)
+ // request, otherwise the MS limited password request is needed.
+ const bool bOOXML = bMSType && lclSupportsOOXMLEncryption( pCurrentFilter->GetFilterName());
+ const ::comphelper::DocPasswordRequestType eType = bMSType && !bOOXML ?
::comphelper::DocPasswordRequestType::MS :
::comphelper::DocPasswordRequestType::Standard;
@@ -2696,8 +2699,7 @@ ErrCode RequestPassword(const std::shared_ptr<const SfxFilter>& pCurrentFilter,
// TODO/LATER: The filters should show the password dialog themself in future
if ( bMSType )
{
- // Check if filter supports OOXML encryption
- if ( lclSupportsOOXMLEncryption( pCurrentFilter->GetFilterName() ) )
+ if (bOOXML)
{
::comphelper::SequenceAsHashMap aHashData;
aHashData[ OUString( "OOXPassword" ) ] <<= pPasswordRequest->getPassword();
diff --git a/uui/source/iahndl-authentication.cxx b/uui/source/iahndl-authentication.cxx
index b6c74f4926db..4835a485dd2a 100644
--- a/uui/source/iahndl-authentication.cxx
+++ b/uui/source/iahndl-authentication.cxx
@@ -488,7 +488,7 @@ executePasswordDialog(
LoginErrorInfo & rInfo,
task::PasswordRequestMode nMode,
const OUString& aDocName,
- bool bMSCryptoMode,
+ sal_uInt16 nMaxPasswordLen,
bool bIsPasswordToModify,
bool bIsSimplePasswordRequest )
{
@@ -508,11 +508,9 @@ executePasswordDialog(
}
else
{
- const sal_uInt16 nMaxPasswdLen = bMSCryptoMode ? 15 : 0; // 0 -> allow any length
-
VclAbstractDialogFactory * pFact = VclAbstractDialogFactory::Create();
ScopedVclPtr<AbstractPasswordToOpenModifyDialog> const pDialog(
- pFact->CreatePasswordToOpenModifyDialog(pParent, nMaxPasswdLen, bIsPasswordToModify));
+ pFact->CreatePasswordToOpenModifyDialog(pParent, nMaxPasswordLen, bIsPasswordToModify));
rInfo.SetResult( pDialog->Execute() == RET_OK ? DialogMask::ButtonsOk : DialogMask::ButtonsCancel );
rInfo.SetPassword( pDialog->GetPasswordToOpen() );
@@ -539,7 +537,7 @@ handlePasswordRequest_(
uno::Sequence< uno::Reference< task::XInteractionContinuation > > const &
rContinuations,
const OUString& aDocumentName,
- bool bMSCryptoMode,
+ sal_uInt16 nMaxPasswordLen,
bool bIsPasswordToModify,
bool bIsSimplePasswordRequest = false )
{
@@ -555,7 +553,7 @@ handlePasswordRequest_(
LoginErrorInfo aInfo;
executePasswordDialog( pParent, aInfo, nMode,
- aDocumentName, bMSCryptoMode, bIsPasswordToModify, bIsSimplePasswordRequest );
+ aDocumentName, nMaxPasswordLen, bIsPasswordToModify, bIsSimplePasswordRequest );
switch (aInfo.GetResult())
{
@@ -649,61 +647,67 @@ UUIInteractionHelper::handlePasswordRequest(
task::PasswordRequestMode nMode = task::PasswordRequestMode_PASSWORD_ENTER;
uno::Sequence< uno::Reference< task::XInteractionContinuation > > const & rContinuations = rRequest->getContinuations();
OUString aDocumentName;
- bool bMSCryptoMode = false;
+ sal_uInt16 nMaxPasswordLen = 0; // any length
bool bIsPasswordToModify = false;
bool bDoHandleRequest = false;
uno::Any aAnyRequest(rRequest->getRequest());
- task::DocumentPasswordRequest2 aDocumentPasswordRequest2;
- if (!bDoHandleRequest && (aAnyRequest >>= aDocumentPasswordRequest2))
+ do
{
- nMode = aDocumentPasswordRequest2.Mode;
- aDocumentName = aDocumentPasswordRequest2.Name;
- OSL_ENSURE( !bMSCryptoMode, "bMSCryptoMode should be false" );
- bIsPasswordToModify = aDocumentPasswordRequest2.IsRequestPasswordToModify;
+ task::DocumentPasswordRequest2 aDocumentPasswordRequest2;
+ if (aAnyRequest >>= aDocumentPasswordRequest2)
+ {
+ nMode = aDocumentPasswordRequest2.Mode;
+ aDocumentName = aDocumentPasswordRequest2.Name;
+ bIsPasswordToModify = aDocumentPasswordRequest2.IsRequestPasswordToModify;
- bDoHandleRequest = true;
- }
+ bDoHandleRequest = true;
+ break; // do
+ }
- task::DocumentPasswordRequest aDocumentPasswordRequest;
- if (!bDoHandleRequest && (aAnyRequest >>= aDocumentPasswordRequest))
- {
- nMode = aDocumentPasswordRequest.Mode;
- aDocumentName = aDocumentPasswordRequest.Name;
- OSL_ENSURE( !bMSCryptoMode, "bMSCryptoMode should be false" );
- OSL_ENSURE( !bIsPasswordToModify, "bIsPasswordToModify should be false" );
+ task::DocumentPasswordRequest aDocumentPasswordRequest;
+ if (aAnyRequest >>= aDocumentPasswordRequest)
+ {
+ nMode = aDocumentPasswordRequest.Mode;
+ aDocumentName = aDocumentPasswordRequest.Name;
+ OSL_ENSURE( !bIsPasswordToModify, "bIsPasswordToModify should be false" );
- bDoHandleRequest = true;
- }
+ bDoHandleRequest = true;
+ break; // do
+ }
- task::DocumentMSPasswordRequest2 aDocumentMSPasswordRequest2;
- if (!bDoHandleRequest && (aAnyRequest >>= aDocumentMSPasswordRequest2))
- {
- nMode = aDocumentMSPasswordRequest2.Mode;
- aDocumentName = aDocumentMSPasswordRequest2.Name;
- bMSCryptoMode = true;
- bIsPasswordToModify = aDocumentMSPasswordRequest2.IsRequestPasswordToModify;
+ task::DocumentMSPasswordRequest2 aDocumentMSPasswordRequest2;
+ if (aAnyRequest >>= aDocumentMSPasswordRequest2)
+ {
+ nMode = aDocumentMSPasswordRequest2.Mode;
+ aDocumentName = aDocumentMSPasswordRequest2.Name;
+ nMaxPasswordLen = 15;
+ bIsPasswordToModify = aDocumentMSPasswordRequest2.IsRequestPasswordToModify;
- bDoHandleRequest = true;
- }
+ bDoHandleRequest = true;
+ break; // do
+ }
- task::DocumentMSPasswordRequest aDocumentMSPasswordRequest;
- if (!bDoHandleRequest && (aAnyRequest >>= aDocumentMSPasswordRequest))
- {
- nMode = aDocumentMSPasswordRequest.Mode;
- aDocumentName = aDocumentMSPasswordRequest.Name;
- bMSCryptoMode = true;
- OSL_ENSURE( !bIsPasswordToModify, "bIsPasswordToModify should be false" );
+ task::DocumentMSPasswordRequest aDocumentMSPasswordRequest;
+ if (aAnyRequest >>= aDocumentMSPasswordRequest)
+ {
+ nMode = aDocumentMSPasswordRequest.Mode;
+ aDocumentName = aDocumentMSPasswordRequest.Name;
+ nMaxPasswordLen = 15;
+ OSL_ENSURE( !bIsPasswordToModify, "bIsPasswordToModify should be false" );
- bDoHandleRequest = true;
+ bDoHandleRequest = true;
+ break; // do
+ }
}
+ while (false);
if (bDoHandleRequest)
{
handlePasswordRequest_( Application::GetFrameWeld(xParent), nMode, rContinuations,
- aDocumentName, bMSCryptoMode, bIsPasswordToModify );
+ aDocumentName, nMaxPasswordLen, bIsPasswordToModify );
return true;
}
@@ -714,7 +718,7 @@ UUIInteractionHelper::handlePasswordRequest(
aPasswordRequest.Mode,
rRequest->getContinuations(),
OUString(),
- false /* bool bMSCryptoMode */,
+ 0 /* sal_uInt16 nMaxPasswordLen */,
false /* bool bIsPasswordToModify */,
true /* bool bIsSimplePasswordRequest */ );
return true;
More information about the Libreoffice-commits
mailing list