Kaydet (Commit) da9aa49f authored tarafından Caolán McNamara's avatar Caolán McNamara

weld PasswordToOpenModifyDialog

Change-Id: I42ebbd1c94a54fb1d4c755fbcc6758c93614bc33
Reviewed-on: https://gerrit.libreoffice.org/51729Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 48295429
......@@ -17,163 +17,111 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <vcl/svapp.hxx>
#include <passwdomdlg.hxx>
#include <strings.hrc>
#include <dialmgr.hxx>
#include <sfx2/tabdlg.hxx>
#include <vcl/fixed.hxx>
#include <vcl/edit.hxx>
#include <vcl/button.hxx>
#include <vcl/weld.hxx>
#include <vcl/settings.hxx>
struct PasswordToOpenModifyDialog_Impl
{
VclPtr<PasswordToOpenModifyDialog> m_pParent;
VclPtr<Edit> m_pPasswdToOpenED;
VclPtr<Edit> m_pReenterPasswdToOpenED;
VclPtr<VclExpander> m_pOptionsExpander;
VclPtr<OKButton> m_pOk;
VclPtr<CheckBox> m_pOpenReadonlyCB;
VclPtr<Edit> m_pPasswdToModifyED;
VclPtr<Edit> m_pReenterPasswdToModifyED;
OUString m_aOneMismatch;
OUString m_aTwoMismatch;
OUString m_aInvalidStateForOkButton;
OUString m_aInvalidStateForOkButton_v2;
bool m_bIsPasswordToModify;
DECL_LINK( OkBtnClickHdl, Button*, void );
PasswordToOpenModifyDialog_Impl( PasswordToOpenModifyDialog * pParent,
sal_uInt16 nMaxPasswdLen, bool bIsPasswordToModify );
};
PasswordToOpenModifyDialog_Impl::PasswordToOpenModifyDialog_Impl(
PasswordToOpenModifyDialog * pParent,
sal_uInt16 nMaxPasswdLen,
bool bIsPasswordToModify )
: m_pParent( pParent )
, m_aOneMismatch( CuiResId( RID_SVXSTR_ONE_PASSWORD_MISMATCH ) )
, m_aTwoMismatch( CuiResId( RID_SVXSTR_TWO_PASSWORDS_MISMATCH ) )
, m_aInvalidStateForOkButton( CuiResId( RID_SVXSTR_INVALID_STATE_FOR_OK_BUTTON ) )
, m_aInvalidStateForOkButton_v2( CuiResId( RID_SVXSTR_INVALID_STATE_FOR_OK_BUTTON_V2 ) )
, m_bIsPasswordToModify( bIsPasswordToModify )
{
pParent->get(m_pPasswdToOpenED, "newpassEntry");
pParent->get(m_pReenterPasswdToOpenED, "confirmpassEntry");
pParent->get(m_pOk, "ok");
pParent->get(m_pOpenReadonlyCB, "readonly");
pParent->get(m_pPasswdToModifyED, "newpassroEntry");
pParent->get(m_pReenterPasswdToModifyED, "confirmropassEntry");
pParent->get(m_pOptionsExpander, "expander");
m_pOk->SetClickHdl( LINK( this, PasswordToOpenModifyDialog_Impl, OkBtnClickHdl ) );
if (nMaxPasswdLen)
{
m_pPasswdToOpenED->SetMaxTextLen( nMaxPasswdLen );
m_pReenterPasswdToOpenED->SetMaxTextLen( nMaxPasswdLen );
m_pPasswdToModifyED->SetMaxTextLen( nMaxPasswdLen );
m_pReenterPasswdToModifyED->SetMaxTextLen( nMaxPasswdLen );
}
m_pPasswdToOpenED->GrabFocus();
m_pOptionsExpander->Enable(bIsPasswordToModify);
if (!bIsPasswordToModify)
m_pOptionsExpander->Hide();
}
IMPL_LINK(PasswordToOpenModifyDialog_Impl, OkBtnClickHdl, Button *, pButton, void)
IMPL_LINK_NOARG(PasswordToOpenModifyDialog, OkBtnClickHdl, weld::Button&, void)
{
bool bInvalidState = !m_pOpenReadonlyCB->IsChecked() &&
m_pPasswdToOpenED->GetText().isEmpty() &&
m_pPasswdToModifyED->GetText().isEmpty();
bool bInvalidState = !m_xOpenReadonlyCB->get_active() &&
m_xPasswdToOpenED->get_text().isEmpty() &&
m_xPasswdToModifyED->get_text().isEmpty();
if (bInvalidState)
{
std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(pButton->GetFrameWeld(),
std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(m_xDialog.get(),
VclMessageType::Warning, VclButtonsType::Ok,
m_bIsPasswordToModify? m_aInvalidStateForOkButton : m_aInvalidStateForOkButton_v2));
xErrorBox->run();
}
else // check for mismatched passwords...
{
const bool bToOpenMatch = m_pPasswdToOpenED->GetText() == m_pReenterPasswdToOpenED->GetText();
const bool bToModifyMatch = m_pPasswdToModifyED->GetText() == m_pReenterPasswdToModifyED->GetText();
const bool bToOpenMatch = m_xPasswdToOpenED->get_text() == m_xReenterPasswdToOpenED->get_text();
const bool bToModifyMatch = m_xPasswdToModifyED->get_text() == m_xReenterPasswdToModifyED->get_text();
const int nMismatch = (bToOpenMatch? 0 : 1) + (bToModifyMatch? 0 : 1);
if (nMismatch > 0)
{
std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(pButton->GetFrameWeld(),
std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(m_xDialog.get(),
VclMessageType::Warning, VclButtonsType::Ok,
nMismatch == 1 ? m_aOneMismatch : m_aTwoMismatch));
xErrorBox->run();
Edit* pEdit = !bToOpenMatch ? m_pPasswdToOpenED.get() : m_pPasswdToModifyED.get();
Edit* pRepeatEdit = !bToOpenMatch? m_pReenterPasswdToOpenED.get() : m_pReenterPasswdToModifyED.get();
weld::Entry* pEdit = !bToOpenMatch ? m_xPasswdToOpenED.get() : m_xPasswdToModifyED.get();
weld::Entry* pRepeatEdit = !bToOpenMatch? m_xReenterPasswdToOpenED.get() : m_xReenterPasswdToModifyED.get();
if (nMismatch == 1)
{
pEdit->SetText( "" );
pRepeatEdit->SetText( "" );
pEdit->set_text( "" );
pRepeatEdit->set_text( "" );
}
else if (nMismatch == 2)
{
m_pPasswdToOpenED->SetText( "" );
m_pReenterPasswdToOpenED->SetText( "" );
m_pPasswdToModifyED->SetText( "" );
m_pReenterPasswdToModifyED->SetText( "" );
m_xPasswdToOpenED->set_text( "" );
m_xReenterPasswdToOpenED->set_text( "" );
m_xPasswdToModifyED->set_text( "" );
m_xReenterPasswdToModifyED->set_text( "" );
}
pEdit->GrabFocus();
pEdit->grab_focus();
}
else
{
m_pParent->EndDialog( RET_OK );
m_xDialog->response(RET_OK);
}
}
}
PasswordToOpenModifyDialog::PasswordToOpenModifyDialog(
vcl::Window * pParent,
sal_uInt16 nMaxPasswdLen, bool bIsPasswordToModify)
: SfxModalDialog( pParent, "PasswordDialog", "cui/ui/password.ui" )
PasswordToOpenModifyDialog::PasswordToOpenModifyDialog(weld::Window * pParent, sal_uInt16 nMaxPasswdLen, bool bIsPasswordToModify)
: GenericDialogController(pParent, "cui/ui/password.ui", "PasswordDialog")
, m_xPasswdToOpenED(m_xBuilder->weld_entry("newpassEntry"))
, m_xReenterPasswdToOpenED(m_xBuilder->weld_entry("confirmpassEntry"))
, m_xOptionsExpander(m_xBuilder->weld_expander("expander"))
, m_xOk(m_xBuilder->weld_button("ok"))
, m_xOpenReadonlyCB(m_xBuilder->weld_check_button("readonly"))
, m_xPasswdToModifyED(m_xBuilder->weld_entry("newpassroEntry"))
, m_xReenterPasswdToModifyED(m_xBuilder->weld_entry("confirmropassEntry"))
, m_aOneMismatch( CuiResId( RID_SVXSTR_ONE_PASSWORD_MISMATCH ) )
, m_aTwoMismatch( CuiResId( RID_SVXSTR_TWO_PASSWORDS_MISMATCH ) )
, m_aInvalidStateForOkButton( CuiResId( RID_SVXSTR_INVALID_STATE_FOR_OK_BUTTON ) )
, m_aInvalidStateForOkButton_v2( CuiResId( RID_SVXSTR_INVALID_STATE_FOR_OK_BUTTON_V2 ) )
, m_bIsPasswordToModify( bIsPasswordToModify )
{
m_pImpl.reset(new PasswordToOpenModifyDialog_Impl(this,
nMaxPasswdLen, bIsPasswordToModify ) );
}
m_xOk->connect_clicked(LINK(this, PasswordToOpenModifyDialog, OkBtnClickHdl));
if (nMaxPasswdLen)
{
m_xPasswdToOpenED->set_max_length( nMaxPasswdLen );
m_xReenterPasswdToOpenED->set_max_length( nMaxPasswdLen );
m_xPasswdToModifyED->set_max_length( nMaxPasswdLen );
m_xReenterPasswdToModifyED->set_max_length( nMaxPasswdLen );
}
PasswordToOpenModifyDialog::~PasswordToOpenModifyDialog()
{
disposeOnce();
m_xPasswdToOpenED->grab_focus();
m_xOptionsExpander->set_sensitive(bIsPasswordToModify);
if (!bIsPasswordToModify)
m_xOptionsExpander->hide();
}
OUString PasswordToOpenModifyDialog::GetPasswordToOpen() const
{
const bool bPasswdOk =
!m_pImpl->m_pPasswdToOpenED->GetText().isEmpty() &&
m_pImpl->m_pPasswdToOpenED->GetText() == m_pImpl->m_pReenterPasswdToOpenED->GetText();
return bPasswdOk ? m_pImpl->m_pPasswdToOpenED->GetText() : OUString();
!m_xPasswdToOpenED->get_text().isEmpty() &&
m_xPasswdToOpenED->get_text() == m_xReenterPasswdToOpenED->get_text();
return bPasswdOk ? m_xPasswdToOpenED->get_text() : OUString();
}
OUString PasswordToOpenModifyDialog::GetPasswordToModify() const
{
const bool bPasswdOk =
!m_pImpl->m_pPasswdToModifyED->GetText().isEmpty() &&
m_pImpl->m_pPasswdToModifyED->GetText() == m_pImpl->m_pReenterPasswdToModifyED->GetText();
return bPasswdOk ? m_pImpl->m_pPasswdToModifyED->GetText() : OUString();
!m_xPasswdToModifyED->get_text().isEmpty() &&
m_xPasswdToModifyED->get_text() == m_xReenterPasswdToModifyED->get_text();
return bPasswdOk ? m_xPasswdToModifyED->get_text() : OUString();
}
bool PasswordToOpenModifyDialog::IsRecommendToOpenReadonly() const
{
return m_pImpl->m_pOpenReadonlyCB->IsChecked();
return m_xOpenReadonlyCB->get_active();
}
......
......@@ -143,7 +143,12 @@ IMPL_ABSTDLG_BASE(AbstractInsertObjectDialog_Impl);
IMPL_ABSTDLG_BASE(AbstractLinksDialog_Impl);
IMPL_ABSTDLG_BASE(AbstractSpellDialog_Impl);
IMPL_ABSTDLG_BASE(AbstractSvxPostItDialog_Impl);
IMPL_ABSTDLG_BASE(AbstractPasswordToOpenModifyDialog_Impl);
short AbstractPasswordToOpenModifyDialog_Impl::Execute()
{
return m_xDlg->run();
}
IMPL_ABSTDLG_BASE(AbstractScreenshotAnnotationDlg_Impl);
......@@ -785,15 +790,17 @@ vcl::Window * AbstractSvxPostItDialog_Impl::GetWindow()
OUString AbstractPasswordToOpenModifyDialog_Impl::GetPasswordToOpen() const
{
return pDlg->GetPasswordToOpen();
return m_xDlg->GetPasswordToOpen();
}
OUString AbstractPasswordToOpenModifyDialog_Impl::GetPasswordToModify() const
{
return pDlg->GetPasswordToModify();
return m_xDlg->GetPasswordToModify();
}
bool AbstractPasswordToOpenModifyDialog_Impl::IsRecommendToOpenReadonly() const
{
return pDlg->IsRecommendToOpenReadonly();
return m_xDlg->IsRecommendToOpenReadonly();
}
// Create dialogs with simplest interface
......@@ -1515,11 +1522,9 @@ VclPtr<SvxAbstractInsRowColDlg> AbstractDialogFactory_Impl::CreateSvxInsRowColDl
}
VclPtr<AbstractPasswordToOpenModifyDialog> AbstractDialogFactory_Impl::CreatePasswordToOpenModifyDialog(
vcl::Window * pParent,
sal_uInt16 nMaxPasswdLen, bool bIsPasswordToModify )
weld::Window * pParent, sal_uInt16 nMaxPasswdLen, bool bIsPasswordToModify)
{
VclPtrInstance<PasswordToOpenModifyDialog> pDlg( pParent, nMaxPasswdLen, bIsPasswordToModify );
return VclPtr<AbstractPasswordToOpenModifyDialog_Impl>::Create( pDlg );
return VclPtr<AbstractPasswordToOpenModifyDialog_Impl>::Create(new PasswordToOpenModifyDialog(pParent, nMaxPasswdLen, bIsPasswordToModify));
}
VclPtr<AbstractScreenshotAnnotationDlg> AbstractDialogFactory_Impl::CreateScreenshotAnnotationDlg(
......
......@@ -458,8 +458,14 @@ private:
class PasswordToOpenModifyDialog;
class AbstractPasswordToOpenModifyDialog_Impl : public AbstractPasswordToOpenModifyDialog
{
DECL_ABSTDLG_BASE( AbstractPasswordToOpenModifyDialog_Impl, PasswordToOpenModifyDialog )
protected:
std::unique_ptr<PasswordToOpenModifyDialog> m_xDlg;
public:
explicit AbstractPasswordToOpenModifyDialog_Impl(PasswordToOpenModifyDialog* p)
: m_xDlg(p)
{
}
virtual short Execute() override;
virtual OUString GetPasswordToOpen() const override;
virtual OUString GetPasswordToModify() const override;
virtual bool IsRecommendToOpenReadonly() const override;
......@@ -648,7 +654,7 @@ public:
virtual VclPtr<SvxAbstractInsRowColDlg> CreateSvxInsRowColDlg(weld::Window* pParent, bool bCol, const OString& rHelpId) override;
virtual VclPtr<AbstractPasswordToOpenModifyDialog> CreatePasswordToOpenModifyDialog(vcl::Window * pParent, sal_uInt16 nMaxPasswdLen, bool bIsPasswordToModify) override;
virtual VclPtr<AbstractPasswordToOpenModifyDialog> CreatePasswordToOpenModifyDialog(weld::Window * pParent, sal_uInt16 nMaxPasswdLen, bool bIsPasswordToModify) override;
virtual VclPtr<AbstractScreenshotAnnotationDlg> CreateScreenshotAnnotationDlg(vcl::Window * pParent, Dialog& rParentDialog) override;
};
......
......@@ -19,26 +19,37 @@
#ifndef INCLUDED_CUI_SOURCE_INC_PASSWDOMDLG_HXX
#define INCLUDED_CUI_SOURCE_INC_PASSWDOMDLG_HXX
#include <vcl/weld.hxx>
#include <memory>
#include <sfx2/basedlgs.hxx>
#include <memory>
class PasswordToOpenModifyDialog : public weld::GenericDialogController
{
std::unique_ptr<weld::Entry> m_xPasswdToOpenED;
std::unique_ptr<weld::Entry> m_xReenterPasswdToOpenED;
std::unique_ptr<weld::Expander> m_xOptionsExpander;
std::unique_ptr<weld::Button> m_xOk;
std::unique_ptr<weld::CheckButton> m_xOpenReadonlyCB;
std::unique_ptr<weld::Entry> m_xPasswdToModifyED;
std::unique_ptr<weld::Entry> m_xReenterPasswdToModifyED;
OUString m_aOneMismatch;
OUString m_aTwoMismatch;
OUString m_aInvalidStateForOkButton;
OUString m_aInvalidStateForOkButton_v2;
struct PasswordToOpenModifyDialog_Impl;
bool m_bIsPasswordToModify;
class PasswordToOpenModifyDialog : public SfxModalDialog
{
std::unique_ptr< PasswordToOpenModifyDialog_Impl > m_pImpl;
DECL_LINK(OkBtnClickHdl, weld::Button&, void);
PasswordToOpenModifyDialog( const PasswordToOpenModifyDialog & ) = delete;
PasswordToOpenModifyDialog & operator = ( const PasswordToOpenModifyDialog & ) = delete;
public:
PasswordToOpenModifyDialog( vcl::Window * pParent,
PasswordToOpenModifyDialog(weld::Window* pParent,
sal_uInt16 nMaxPasswdLen /* 0 -> no max len enforced */,
bool bIsPasswordToModify );
virtual ~PasswordToOpenModifyDialog() override;
// AbstractPasswordToOpenModifyDialog
OUString GetPasswordToOpen() const;
......@@ -46,7 +57,6 @@ public:
bool IsRecommendToOpenReadonly() const;
};
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This diff is collapsed.
......@@ -31,7 +31,11 @@
namespace vcl { class Window; }
class Dialog;
class Bitmap;
namespace weld { class DialogController; }
namespace weld
{
class DialogController;
class Window;
}
/**
* Some things multiple-inherit from VclAbstractDialog and OutputDevice,
......@@ -120,7 +124,7 @@ public:
virtual VclPtr<VclAbstractDialog> CreateVclDialog(vcl::Window* pParent, sal_uInt32 nId) = 0;
// creates instance of PasswordToOpenModifyDialog from cui
virtual VclPtr<AbstractPasswordToOpenModifyDialog> CreatePasswordToOpenModifyDialog( vcl::Window * pParent, sal_uInt16 nMaxPasswdLen, bool bIsPasswordToModify ) = 0;
virtual VclPtr<AbstractPasswordToOpenModifyDialog> CreatePasswordToOpenModifyDialog(weld::Window * pParent, sal_uInt16 nMaxPasswdLen, bool bIsPasswordToModify) = 0;
// creates instance of ScreenshotAnnotationDlg from cui
virtual VclPtr<AbstractScreenshotAnnotationDlg> CreateScreenshotAnnotationDlg(
......
......@@ -500,7 +500,7 @@ handleMasterPasswordRequest_(
void
executePasswordDialog(
vcl::Window * pParent,
weld::Window * pParent,
LoginErrorInfo & rInfo,
task::PasswordRequestMode nMode,
const OUString& aDocName,
......@@ -517,7 +517,7 @@ executePasswordDialog(
{
if (bIsSimplePasswordRequest)
{
std::unique_ptr<PasswordDialog> xDialog(new PasswordDialog(pParent ? pParent->GetFrameWeld() : nullptr, nMode,
std::unique_ptr<PasswordDialog> xDialog(new PasswordDialog(pParent, nMode,
aResLocale, aDocName, bIsPasswordToModify, bIsSimplePasswordRequest));
xDialog->SetMinLen(0);
......@@ -540,7 +540,7 @@ executePasswordDialog(
}
else // enter password or reenter password
{
std::unique_ptr<PasswordDialog> xDialog(new PasswordDialog(pParent ? pParent->GetFrameWeld() : nullptr, nMode,
std::unique_ptr<PasswordDialog> xDialog(new PasswordDialog(pParent, nMode,
aResLocale, aDocName, bIsPasswordToModify, bIsSimplePasswordRequest));
xDialog->SetMinLen(0);
......@@ -558,7 +558,7 @@ executePasswordDialog(
void
handlePasswordRequest_(
vcl::Window * pParent,
weld::Window * pParent,
task::PasswordRequestMode nMode,
uno::Sequence< uno::Reference< task::XInteractionContinuation > > const &
rContinuations,
......@@ -723,7 +723,7 @@ UUIInteractionHelper::handlePasswordRequest(
if (bDoHandleRequest)
{
handlePasswordRequest_( pParent, nMode, rContinuations,
handlePasswordRequest_( pParent ? pParent->GetFrameWeld() : nullptr, nMode, rContinuations,
aDocumentName, bMSCryptoMode, bIsPasswordToModify );
return true;
}
......@@ -731,7 +731,7 @@ UUIInteractionHelper::handlePasswordRequest(
task::PasswordRequest aPasswordRequest;
if( aAnyRequest >>= aPasswordRequest )
{
handlePasswordRequest_(getParentProperty(),
handlePasswordRequest_(pParent ? pParent->GetFrameWeld() : nullptr,
aPasswordRequest.Mode,
rRequest->getContinuations(),
OUString(),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment