diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-03-04 17:05:19 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-03-05 00:32:13 +0100 |
commit | d6f1c3dece1ab321230cbaf6b5a11318ba04b216 (patch) | |
tree | 9a09218d3fb27dfef8939c8924dd100378196f78 | |
parent | 77db2da61658906c354084b13a95f1102949fbd0 (diff) |
weld SfxPasswordDialog Dialog
Change-Id: If8c9757986f4af7b7927717221860e65c8c7285e
Reviewed-on: https://gerrit.libreoffice.org/50755
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | basctl/source/basicide/bastypes.cxx | 11 | ||||
-rw-r--r-- | dbaccess/source/ui/dlg/UserAdmin.cxx | 10 | ||||
-rw-r--r-- | filter/source/pdf/impdialog.cxx | 20 | ||||
-rw-r--r-- | include/sfx2/passwd.hxx | 68 | ||||
-rw-r--r-- | sc/source/ui/docshell/docsh4.cxx | 20 | ||||
-rw-r--r-- | sc/source/ui/view/tabvwsh3.cxx | 50 | ||||
-rw-r--r-- | sfx2/source/dialog/passwd.cxx | 203 | ||||
-rw-r--r-- | sfx2/source/dialog/securitypage.cxx | 19 | ||||
-rw-r--r-- | sfx2/source/doc/docinsert.cxx | 8 | ||||
-rw-r--r-- | sfx2/uiconfig/ui/password.ui | 20 | ||||
-rw-r--r-- | sw/source/ui/dialog/uiregionsw.cxx | 26 | ||||
-rw-r--r-- | sw/source/uibase/dbui/mailmergehelper.cxx | 8 | ||||
-rw-r--r-- | sw/source/uibase/uiview/view2.cxx | 24 | ||||
-rw-r--r-- | writerperfect/source/calc/MSWorksCalcImportFilter.cxx | 8 | ||||
-rw-r--r-- | writerperfect/source/writer/StarOfficeWriterImportFilter.cxx | 8 | ||||
-rw-r--r-- | writerperfect/source/writer/WordPerfectImportFilter.cxx | 8 |
16 files changed, 247 insertions, 264 deletions
diff --git a/basctl/source/basicide/bastypes.cxx b/basctl/source/basicide/bastypes.cxx index a770bd986213..d645a74fc272 100644 --- a/basctl/source/basicide/bastypes.cxx +++ b/basctl/source/basicide/bastypes.cxx @@ -755,19 +755,20 @@ bool QueryPassword( const Reference< script::XLibraryContainer >& xLibContainer, do { // password dialog - ScopedVclPtrInstance< SfxPasswordDialog > aDlg(Application::GetDefDialogParent()); - aDlg->SetMinLen( 1 ); + vcl::Window* pWin = Application::GetDefDialogParent(); + SfxPasswordDialog aDlg(pWin ? pWin->GetFrameWeld() : nullptr); + aDlg.SetMinLen(1); // set new title if ( bNewTitle ) { OUString aTitle(IDEResId(RID_STR_ENTERPASSWORD)); aTitle = aTitle.replaceAll("XX", rLibName); - aDlg->SetText( aTitle ); + aDlg.set_title(aTitle); } // execute dialog - nRet = aDlg->Execute(); + nRet = aDlg.run(); // verify password if ( nRet == RET_OK ) @@ -777,7 +778,7 @@ bool QueryPassword( const Reference< script::XLibraryContainer >& xLibContainer, Reference< script::XLibraryContainerPassword > xPasswd( xLibContainer, UNO_QUERY ); if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( rLibName ) && !xPasswd->isLibraryPasswordVerified( rLibName ) ) { - rPassword = aDlg->GetPassword(); + rPassword = aDlg.GetPassword(); // OUString aOUPassword( rPassword ); bOK = xPasswd->verifyLibraryPassword( rLibName, rPassword ); diff --git a/dbaccess/source/ui/dlg/UserAdmin.cxx b/dbaccess/source/ui/dlg/UserAdmin.cxx index b4d23c0815ba..1c7ce5531b15 100644 --- a/dbaccess/source/ui/dlg/UserAdmin.cxx +++ b/dbaccess/source/ui/dlg/UserAdmin.cxx @@ -214,16 +214,16 @@ IMPL_LINK( OUserAdmin, UserHdl, Button *, pButton, void ) { if(pButton == m_pNEWUSER) { - ScopedVclPtrInstance< SfxPasswordDialog > aPwdDlg(this); - aPwdDlg->ShowExtras(SfxShowExtras::ALL); - if(aPwdDlg->Execute()) + SfxPasswordDialog aPwdDlg(GetFrameWeld()); + aPwdDlg.ShowExtras(SfxShowExtras::ALL); + if (aPwdDlg.run()) { Reference<XDataDescriptorFactory> xUserFactory(m_xUsers,UNO_QUERY); Reference<XPropertySet> xNewUser = xUserFactory->createDataDescriptor(); if(xNewUser.is()) { - xNewUser->setPropertyValue(PROPERTY_NAME,makeAny(aPwdDlg->GetUser())); - xNewUser->setPropertyValue(PROPERTY_PASSWORD,makeAny(aPwdDlg->GetPassword())); + xNewUser->setPropertyValue(PROPERTY_NAME,makeAny(aPwdDlg.GetUser())); + xNewUser->setPropertyValue(PROPERTY_PASSWORD,makeAny(aPwdDlg.GetPassword())); Reference<XAppend> xAppend(m_xUsers,UNO_QUERY); if(xAppend.is()) xAppend->appendByDescriptor(xNewUser); diff --git a/filter/source/pdf/impdialog.cxx b/filter/source/pdf/impdialog.cxx index 7cdc56634414..1f65e3bad4b5 100644 --- a/filter/source/pdf/impdialog.cxx +++ b/filter/source/pdf/impdialog.cxx @@ -1330,17 +1330,17 @@ void ImpPDFTabSecurityPage::SetFilterConfigItem( const ImpPDFTabDialog* paParen IMPL_LINK_NOARG(ImpPDFTabSecurityPage, ClickmaPbSetPwdHdl, Button*, void) { - ScopedVclPtrInstance< SfxPasswordDialog > aPwdDialog( this, &msUserPwdTitle ); - aPwdDialog->SetMinLen( 0 ); - aPwdDialog->ShowMinLengthText(false); - aPwdDialog->ShowExtras( SfxShowExtras::CONFIRM | SfxShowExtras::PASSWORD2 | SfxShowExtras::CONFIRM2 ); - aPwdDialog->SetText(msStrSetPwd); - aPwdDialog->SetGroup2Text(msOwnerPwdTitle); - aPwdDialog->AllowAsciiOnly(); - if( aPwdDialog->Execute() == RET_OK ) // OK issued get password and set it + SfxPasswordDialog aPwdDialog(GetFrameWeld(), &msUserPwdTitle); + aPwdDialog.SetMinLen(0); + aPwdDialog.ShowMinLengthText(false); + aPwdDialog.ShowExtras( SfxShowExtras::CONFIRM | SfxShowExtras::PASSWORD2 | SfxShowExtras::CONFIRM2 ); + aPwdDialog.set_title(msStrSetPwd); + aPwdDialog.SetGroup2Text(msOwnerPwdTitle); + aPwdDialog.AllowAsciiOnly(); + if (aPwdDialog.run() == RET_OK) // OK issued get password and set it { - OUString aUserPW( aPwdDialog->GetPassword() ); - OUString aOwnerPW( aPwdDialog->GetPassword2() ); + OUString aUserPW(aPwdDialog.GetPassword()); + OUString aOwnerPW(aPwdDialog.GetPassword2()); mbHaveUserPassword = !aUserPW.isEmpty(); mbHaveOwnerPassword = !aOwnerPW.isEmpty(); diff --git a/include/sfx2/passwd.hxx b/include/sfx2/passwd.hxx index 7c1a5c79b598..2b30d56ae428 100644 --- a/include/sfx2/passwd.hxx +++ b/include/sfx2/passwd.hxx @@ -21,12 +21,8 @@ #include <sal/config.h> #include <sfx2/dllapi.h> -#include <vcl/button.hxx> -#include <vcl/dialog.hxx> -#include <vcl/edit.hxx> -#include <vcl/fixed.hxx> -#include <vcl/layout.hxx> #include <sfx2/app.hxx> +#include <vcl/weld.hxx> #include <o3tl/typed_flags_set.hxx> // defines --------------------------------------------------------------- @@ -47,26 +43,29 @@ namespace o3tl // class SfxPasswordDialog ----------------------------------------------- -class SFX2_DLLPUBLIC SfxPasswordDialog : public ModalDialog +class SFX2_DLLPUBLIC SfxPasswordDialog { private: - VclPtr<VclFrame> mpPassword1Box; - VclPtr<FixedText> mpUserFT; - VclPtr<Edit> mpUserED; - VclPtr<FixedText> mpPassword1FT; - VclPtr<Edit> mpPassword1ED; - VclPtr<FixedText> mpConfirm1FT; - VclPtr<Edit> mpConfirm1ED; + std::unique_ptr<weld::Builder> m_xBuilder; + std::unique_ptr<weld::Dialog> m_xDialog; - VclPtr<VclFrame> mpPassword2Box; - VclPtr<FixedText> mpPassword2FT; - VclPtr<Edit> mpPassword2ED; - VclPtr<FixedText> mpConfirm2FT; - VclPtr<Edit> mpConfirm2ED; + std::unique_ptr<weld::Frame> m_xPassword1Box; + std::unique_ptr<weld::Label> m_xUserFT; + std::unique_ptr<weld::Entry> m_xUserED; + std::unique_ptr<weld::Label> m_xPassword1FT; + std::unique_ptr<weld::Entry> m_xPassword1ED; + std::unique_ptr<weld::Label> m_xConfirm1FT; + std::unique_ptr<weld::Entry> m_xConfirm1ED; - VclPtr<FixedText> mpMinLengthFT; + std::unique_ptr<weld::Frame> m_xPassword2Box; + std::unique_ptr<weld::Label> m_xPassword2FT; + std::unique_ptr<weld::Entry> m_xPassword2ED; + std::unique_ptr<weld::Label> m_xConfirm2FT; + std::unique_ptr<weld::Entry> m_xConfirm2ED; - VclPtr<OKButton> mpOKBtn; + std::unique_ptr<weld::Label> m_xMinLengthFT; + + std::unique_ptr<weld::Button> m_xOKBtn; OUString maMinLenPwdStr; OUString maMinLenPwdStr1; @@ -76,47 +75,46 @@ private: SfxShowExtras mnExtras; bool mbAsciiOnly; - DECL_DLLPRIVATE_LINK(EditModifyHdl, Edit&, void); - DECL_DLLPRIVATE_LINK(OKHdl, Button *, void); - void ModifyHdl(Edit*); + DECL_DLLPRIVATE_LINK(OKHdl, weld::Button&, void); + DECL_DLLPRIVATE_LINK(InsertTextHdl, OUString&, bool); + DECL_DLLPRIVATE_LINK(EditModifyHdl, weld::Entry&, void); + void ModifyHdl(); void SetPasswdText(); public: - SfxPasswordDialog(vcl::Window* pParent, const OUString* pGroupText = nullptr); - virtual ~SfxPasswordDialog() override; - virtual void dispose() override; + SfxPasswordDialog(weld::Window* pParent, const OUString* pGroupText = nullptr); OUString GetUser() const { - return mpUserED->GetText(); + return m_xUserED->get_text(); } OUString GetPassword() const { - return mpPassword1ED->GetText(); + return m_xPassword1ED->get_text(); } OUString GetConfirm() const { - return mpConfirm1ED->GetText(); + return m_xConfirm1ED->get_text(); } OUString GetPassword2() const { - return mpPassword2ED->GetText(); + return m_xPassword2ED->get_text(); } void SetGroup2Text(const OUString& i_rText) { - mpPassword2Box->set_label(i_rText); + m_xPassword2Box->set_label(i_rText); } void SetMinLen(sal_uInt16 Len); void SetEditHelpId(const OString& rId) { - mpPassword1ED->SetHelpId( rId ); + m_xPassword1ED->set_help_id(rId); } /* tdf#60874 we need a custom help ID for the Confirm field of the Protect Document window */ void SetConfirmHelpId(const OString& rId) { - mpConfirm1ED->SetHelpId( rId ); + m_xConfirm1ED->set_help_id(rId); } void ShowExtras(SfxShowExtras nExtras) @@ -130,7 +128,9 @@ public: void ShowMinLengthText(bool bShow); - virtual short Execute() override; + void set_title(const OUString& rTitle) { m_xDialog->set_title(rTitle); } + void set_help_id(const OString& rHelpId) { m_xDialog->set_help_id(rHelpId); } + short run(); }; #endif // INCLUDED_SFX2_PASSWD_HXX diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx index 5091cafd1803..6a7d258c6c71 100644 --- a/sc/source/ui/docshell/docsh4.cxx +++ b/sc/source/ui/docshell/docsh4.cxx @@ -1285,17 +1285,16 @@ bool ScDocShell::ExecuteChangeProtectionDialog( bool bJustQueryIfProtected ) OUString aText( ScResId( SCSTR_PASSWORD ) ); OUString aPassword; - ScopedVclPtrInstance<SfxPasswordDialog> pDlg( - GetActiveDialogParent(), &aText ); - pDlg->SetText( aTitle ); - pDlg->SetMinLen( 1 ); - pDlg->SetHelpId( GetStaticInterface()->GetSlot(SID_CHG_PROTECT)->GetCommand() ); - pDlg->SetEditHelpId( HID_CHG_PROTECT ); + vcl::Window* pWin = ScDocShell::GetActiveDialogParent(); + SfxPasswordDialog aDlg(pWin ? pWin->GetFrameWeld() : nullptr, &aText); + aDlg.set_title(aTitle); + aDlg.SetMinLen(1); + aDlg.set_help_id(GetStaticInterface()->GetSlot(SID_CHG_PROTECT)->GetCommand()); + aDlg.SetEditHelpId( HID_CHG_PROTECT ); if ( !bProtected ) - pDlg->ShowExtras( SfxShowExtras::CONFIRM ); - if ( pDlg->Execute() == RET_OK ) - aPassword = pDlg->GetPassword(); - pDlg.disposeAndClear(); + aDlg.ShowExtras(SfxShowExtras::CONFIRM); + if (aDlg.run() == RET_OK) + aPassword = aDlg.GetPassword(); if (!aPassword.isEmpty()) { @@ -1311,7 +1310,6 @@ bool ScDocShell::ExecuteChangeProtectionDialog( bool bJustQueryIfProtected ) } else { - vcl::Window* pWin = ScDocShell::GetActiveDialogParent(); std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr, VclMessageType::Info, VclButtonsType::Ok, ScResId(SCSTR_WRONGPASSWORD))); diff --git a/sc/source/ui/view/tabvwsh3.cxx b/sc/source/ui/view/tabvwsh3.cxx index a1450c31bf06..dde0b99b3484 100644 --- a/sc/source/ui/view/tabvwsh3.cxx +++ b/sc/source/ui/view/tabvwsh3.cxx @@ -1050,6 +1050,7 @@ void ScTabViewShell::Execute( SfxRequest& rReq ) } } + vcl::Window* pWin = GetDialogParent(); ScDocProtection* pProtect = pDoc->GetDocProtection(); if (pProtect && pProtect->isProtected()) { @@ -1060,14 +1061,14 @@ void ScTabViewShell::Execute( SfxRequest& rReq ) { OUString aText(ScResId(SCSTR_PASSWORD)); - VclPtrInstance< SfxPasswordDialog > pDlg(GetDialogParent(), &aText); - pDlg->SetText( ScResId(SCSTR_UNPROTECTDOC) ); - pDlg->SetMinLen( 0 ); - pDlg->SetHelpId( GetStaticInterface()->GetSlot(FID_PROTECT_DOC)->GetCommand() ); - pDlg->SetEditHelpId( HID_PASSWD_DOC ); + SfxPasswordDialog aDlg(pWin ? pWin->GetFrameWeld() : nullptr, &aText); + aDlg.set_title(ScResId(SCSTR_UNPROTECTDOC)); + aDlg.SetMinLen(0); + aDlg.set_help_id(GetStaticInterface()->GetSlot(FID_PROTECT_DOC)->GetCommand()); + aDlg.SetEditHelpId(HID_PASSWD_DOC); - if (pDlg->Execute() == RET_OK) - aPassword = pDlg->GetPassword(); + if (aDlg.run() == RET_OK) + aPassword = aDlg.GetPassword(); else bCancel = true; } @@ -1082,17 +1083,17 @@ void ScTabViewShell::Execute( SfxRequest& rReq ) { OUString aText(ScResId(SCSTR_PASSWORDOPT)); - VclPtrInstance< SfxPasswordDialog > pDlg(GetDialogParent(), &aText); - pDlg->SetText( ScResId(SCSTR_PROTECTDOC) ); - pDlg->SetMinLen( 0 ); - pDlg->SetHelpId( GetStaticInterface()->GetSlot(FID_PROTECT_DOC)->GetCommand() ); - pDlg->SetEditHelpId( HID_PASSWD_DOC ); - pDlg->ShowExtras( SfxShowExtras::CONFIRM ); - pDlg->SetConfirmHelpId( HID_PASSWD_DOC_CONFIRM ); + SfxPasswordDialog aDlg(pWin ? pWin->GetFrameWeld() : nullptr, &aText); + aDlg.set_title(ScResId(SCSTR_PROTECTDOC)); + aDlg.SetMinLen( 0 ); + aDlg.set_help_id(GetStaticInterface()->GetSlot(FID_PROTECT_DOC)->GetCommand()); + aDlg.SetEditHelpId(HID_PASSWD_DOC); + aDlg.ShowExtras(SfxShowExtras::CONFIRM); + aDlg.SetConfirmHelpId(HID_PASSWD_DOC_CONFIRM); - if (pDlg->Execute() == RET_OK) + if (aDlg.run() == RET_OK) { - OUString aPassword = pDlg->GetPassword(); + OUString aPassword = aDlg.GetPassword(); Protect( TABLEID_DOC, aPassword ); rReq.AppendItem( SfxBoolItem( FID_PROTECT_DOC, true ) ); rReq.Done(); @@ -1129,15 +1130,16 @@ void ScTabViewShell::Execute( SfxRequest& rReq ) if (pProtect && pProtect->isProtectedWithPass()) { OUString aText( ScResId(SCSTR_PASSWORDOPT) ); - VclPtrInstance< SfxPasswordDialog > pDlg(GetDialogParent(), &aText); - pDlg->SetText( ScResId(SCSTR_UNPROTECTTAB) ); - pDlg->SetMinLen( 0 ); - pDlg->SetHelpId( GetStaticInterface()->GetSlot(FID_PROTECT_TABLE)->GetCommand() ); - pDlg->SetEditHelpId( HID_PASSWD_TABLE ); - - if (pDlg->Execute() == RET_OK) + vcl::Window* pWin = GetDialogParent(); + SfxPasswordDialog aDlg(pWin ? pWin->GetFrameWeld() : nullptr, &aText); + aDlg.set_title(ScResId(SCSTR_UNPROTECTTAB)); + aDlg.SetMinLen(0); + aDlg.set_help_id(GetStaticInterface()->GetSlot(FID_PROTECT_TABLE)->GetCommand()); + aDlg.SetEditHelpId(HID_PASSWD_TABLE); + + if (aDlg.run() == RET_OK) { - OUString aPassword = pDlg->GetPassword(); + OUString aPassword = aDlg.GetPassword(); Unprotect(nTab, aPassword); } } diff --git a/sfx2/source/dialog/passwd.cxx b/sfx2/source/dialog/passwd.cxx index 8c0f2378329c..7b4f236f39af 100644 --- a/sfx2/source/dialog/passwd.cxx +++ b/sfx2/source/dialog/passwd.cxx @@ -23,64 +23,81 @@ #include <sfx2/strings.hrc> #include <vcl/weld.hxx> -IMPL_LINK( SfxPasswordDialog, EditModifyHdl, Edit&, rEdit, void ) +IMPL_LINK_NOARG(SfxPasswordDialog, EditModifyHdl, weld::Entry&, void) { - ModifyHdl(&rEdit); + ModifyHdl(); } -void SfxPasswordDialog::ModifyHdl(Edit* pEdit) +void SfxPasswordDialog::ModifyHdl() { - if (mbAsciiOnly && (pEdit == mpPassword1ED || pEdit == mpPassword2ED)) - { - OUString aTest( pEdit->GetText() ); - const sal_Unicode* pTest = aTest.getStr(); - sal_Int32 nLen = aTest.getLength(); - OUStringBuffer aFilter( nLen ); - bool bReset = false; - for( sal_Int32 i = 0; i < nLen; i++ ) - { - if( *pTest > 0x007f ) - bReset = true; - else - aFilter.append( *pTest ); - pTest++; - } - if( bReset ) - { - pEdit->SetSelection( Selection( 0, nLen ) ); - pEdit->ReplaceSelected( aFilter.makeStringAndClear() ); - } + bool bEnable = m_xPassword1ED->get_text().getLength() >= mnMinLen; + if (m_xPassword2ED->get_visible()) + bEnable = (bEnable && (m_xPassword2ED->get_text().getLength() >= mnMinLen)); + m_xOKBtn->set_sensitive(bEnable); +} +IMPL_LINK(SfxPasswordDialog, InsertTextHdl, OUString&, rTest, bool) +{ + if (!mbAsciiOnly) + return true; + + const sal_Unicode* pTest = rTest.getStr(); + sal_Int32 nLen = rTest.getLength(); + OUStringBuffer aFilter(nLen); + bool bReset = false; + for (sal_Int32 i = 0; i < nLen; ++i) + { + if( *pTest > 0x007f ) + bReset = true; + else + aFilter.append(*pTest); + ++pTest; } - bool bEnable = mpPassword1ED->GetText().getLength() >= mnMinLen; - if( mpPassword2ED->IsVisible() ) - bEnable = (bEnable && (mpPassword2ED->GetText().getLength() >= mnMinLen)); - mpOKBtn->Enable( bEnable ); + + if (bReset) + rTest = aFilter.makeStringAndClear(); + + return true; } -IMPL_LINK_NOARG(SfxPasswordDialog, OKHdl, Button*, void) +IMPL_LINK_NOARG(SfxPasswordDialog, OKHdl, weld::Button&, void) { bool bConfirmFailed = bool( mnExtras & SfxShowExtras::CONFIRM ) && ( GetConfirm() != GetPassword() ); - if( ( mnExtras & SfxShowExtras::CONFIRM2 ) && ( mpConfirm2ED->GetText() != GetPassword2() ) ) + if( ( mnExtras & SfxShowExtras::CONFIRM2 ) && ( m_xConfirm2ED->get_text() != GetPassword2() ) ) bConfirmFailed = true; if ( bConfirmFailed ) { - std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(), + std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_xDialog.get(), VclMessageType::Warning, VclButtonsType::Ok, SfxResId(STR_ERROR_WRONG_CONFIRM))); xBox->run(); - mpConfirm1ED->SetText( OUString() ); - mpConfirm1ED->GrabFocus(); + m_xConfirm1ED->set_text(OUString()); + m_xConfirm1ED->grab_focus(); } else - EndDialog( RET_OK ); + m_xDialog->response(RET_OK); } // CTOR / DTOR ----------------------------------------------------------- -SfxPasswordDialog::SfxPasswordDialog(vcl::Window* pParent, const OUString* pGroupText) - : ModalDialog(pParent, "PasswordDialog", "sfx/ui/password.ui") +SfxPasswordDialog::SfxPasswordDialog(weld::Window* pParent, const OUString* pGroupText) + : m_xBuilder(Application::CreateBuilder(pParent, "sfx/ui/password.ui")) + , m_xDialog(m_xBuilder->weld_dialog("PasswordDialog")) + , m_xPassword1Box(m_xBuilder->weld_frame("password1frame")) + , m_xUserFT(m_xBuilder->weld_label("userft")) + , m_xUserED(m_xBuilder->weld_entry("usered")) + , m_xPassword1FT(m_xBuilder->weld_label("pass1ft")) + , m_xPassword1ED(m_xBuilder->weld_entry("pass1ed")) + , m_xConfirm1FT(m_xBuilder->weld_label("confirm1ft")) + , m_xConfirm1ED(m_xBuilder->weld_entry("confirm1ed")) + , m_xPassword2Box(m_xBuilder->weld_frame("password2frame")) + , m_xPassword2FT(m_xBuilder->weld_label("pass2ft")) + , m_xPassword2ED(m_xBuilder->weld_entry("pass2ed")) + , m_xConfirm2FT(m_xBuilder->weld_label("confirm2ft")) + , m_xConfirm2ED(m_xBuilder->weld_entry("confirm2ed")) + , m_xMinLengthFT(m_xBuilder->weld_label("minlenft")) + , m_xOKBtn(m_xBuilder->weld_button("ok")) , maMinLenPwdStr(SfxResId(STR_PASSWD_MIN_LEN)) , maMinLenPwdStr1(SfxResId(STR_PASSWD_MIN_LEN1)) , maEmptyPwdStr(SfxResId(STR_PASSWD_EMPTY)) @@ -88,74 +105,35 @@ SfxPasswordDialog::SfxPasswordDialog(vcl::Window* pParent, const OUString* pGrou , mnExtras(SfxShowExtras::NONE) , mbAsciiOnly(false) { - get(mpPassword1Box, "password1frame"); - get(mpUserFT, "userft"); - get(mpUserED, "usered"); - get(mpPassword1FT, "pass1ft"); - get(mpPassword1ED, "pass1ed"); - get(mpConfirm1FT, "confirm1ft"); - get(mpConfirm1ED, "confirm1ed"); - - get(mpPassword2Box, "password2frame"); - get(mpPassword2FT, "pass2ft"); - get(mpPassword2ED, "pass2ed"); - get(mpConfirm2FT, "confirm2ft"); - get(mpConfirm2ED, "confirm2ed"); - - get(mpMinLengthFT, "minlenft"); - - get(mpOKBtn, "ok"); - - Link<Edit&,void> aLink = LINK( this, SfxPasswordDialog, EditModifyHdl ); - mpPassword1ED->SetModifyHdl( aLink ); - mpPassword2ED->SetModifyHdl( aLink ); - mpOKBtn->SetClickHdl( LINK( this, SfxPasswordDialog, OKHdl ) ); + Link<weld::Entry&,void> aLink = LINK(this, SfxPasswordDialog, EditModifyHdl); + m_xPassword1ED->connect_changed(aLink); + m_xPassword2ED->connect_changed(aLink); + Link<OUString&,bool> aLink2 = LINK(this, SfxPasswordDialog, InsertTextHdl); + m_xPassword1ED->connect_insert_text(aLink2); + m_xPassword2ED->connect_insert_text(aLink2); + m_xOKBtn->connect_clicked(LINK(this, SfxPasswordDialog, OKHdl)); if (pGroupText) - mpPassword1Box->set_label(*pGroupText); + m_xPassword1Box->set_label(*pGroupText); //set the text to the password length SetPasswdText(); } -SfxPasswordDialog::~SfxPasswordDialog() -{ - disposeOnce(); -} - -void SfxPasswordDialog::dispose() -{ - mpPassword1Box.clear(); - mpUserFT.clear(); - mpUserED.clear(); - mpPassword1FT.clear(); - mpPassword1ED.clear(); - mpConfirm1FT.clear(); - mpConfirm1ED.clear(); - mpPassword2Box.clear(); - mpPassword2FT.clear(); - mpPassword2ED.clear(); - mpConfirm2FT.clear(); - mpConfirm2ED.clear(); - mpMinLengthFT.clear(); - mpOKBtn.clear(); - ModalDialog::dispose(); -} - void SfxPasswordDialog::SetPasswdText( ) { -//set the new string to the minimum password length - if( mnMinLen == 0 ) - mpMinLengthFT->SetText(maEmptyPwdStr); + //set the new string to the minimum password length + if (mnMinLen == 0) + m_xMinLengthFT->set_label(maEmptyPwdStr); else { if( mnMinLen == 1 ) - mpMinLengthFT->SetText(maMinLenPwdStr1); + m_xMinLengthFT->set_label(maMinLenPwdStr1); else { maMainPwdStr = maMinLenPwdStr; maMainPwdStr = maMainPwdStr.replaceAll( "$(MINLEN)", OUString::number(static_cast<sal_Int32>(mnMinLen) ) ); - mpMinLengthFT->SetText(maMainPwdStr); + m_xMinLengthFT->set_label(maMainPwdStr); } } } @@ -165,54 +143,53 @@ void SfxPasswordDialog::SetMinLen( sal_uInt16 nLen ) { mnMinLen = nLen; SetPasswdText(); - ModifyHdl( nullptr ); + ModifyHdl(); } void SfxPasswordDialog::ShowMinLengthText(bool bShow) { - mpMinLengthFT->Show(bShow); + m_xMinLengthFT->show(bShow); } - -short SfxPasswordDialog::Execute() +short SfxPasswordDialog::run() { - mpUserFT->Hide(); - mpUserED->Hide(); - mpConfirm1FT->Hide(); - mpConfirm1ED->Hide(); - mpPassword1FT->Hide(); - mpPassword2Box->Hide(); - mpPassword2FT->Hide(); - mpPassword2ED->Hide(); - mpPassword2FT->Hide(); - mpConfirm2FT->Hide(); - mpConfirm2ED->Hide(); + m_xUserFT->hide(); + m_xUserED->hide(); + m_xConfirm1FT->hide(); + m_xConfirm1ED->hide(); + m_xPassword1FT->hide(); + m_xPassword2Box->hide(); + m_xPassword2FT->hide(); + m_xPassword2ED->hide(); + m_xPassword2FT->hide(); + m_xConfirm2FT->hide(); + m_xConfirm2ED->hide(); if (mnExtras != SfxShowExtras::NONE) - mpPassword1FT->Show(); + m_xPassword1FT->show(); if (mnExtras & SfxShowExtras::USER) { - mpUserFT->Show(); - mpUserED->Show(); + m_xUserFT->show(); + m_xUserED->show(); } if (mnExtras & SfxShowExtras::CONFIRM) { - mpConfirm1FT->Show(); - mpConfirm1ED->Show(); + m_xConfirm1FT->show(); + m_xConfirm1ED->show(); } if (mnExtras & SfxShowExtras::PASSWORD2) { - mpPassword2Box->Show(); - mpPassword2FT->Show(); - mpPassword2ED->Show(); + m_xPassword2Box->show(); + m_xPassword2FT->show(); + m_xPassword2ED->show(); } if (mnExtras & SfxShowExtras::CONFIRM2) { - mpConfirm2FT->Show(); - mpConfirm2ED->Show(); + m_xConfirm2FT->show(); + m_xConfirm2ED->show(); } - return ModalDialog::Execute(); + return m_xDialog->run(); } diff --git a/sfx2/source/dialog/securitypage.cxx b/sfx2/source/dialog/securitypage.cxx index 8d9ef33a9293..fcd78d3f0ab5 100644 --- a/sfx2/source/dialog/securitypage.cxx +++ b/sfx2/source/dialog/securitypage.cxx @@ -92,18 +92,18 @@ namespace static bool lcl_GetPassword( - vcl::Window *pParent, + weld::Window *pParent, bool bProtect, /*out*/OUString &rPassword ) { bool bRes = false; - ScopedVclPtrInstance< SfxPasswordDialog > aPasswdDlg(pParent); - aPasswdDlg->SetMinLen( 1 ); + SfxPasswordDialog aPasswdDlg(pParent); + aPasswdDlg.SetMinLen(1); if (bProtect) - aPasswdDlg->ShowExtras( SfxShowExtras::CONFIRM ); - if (RET_OK == aPasswdDlg->Execute() && !aPasswdDlg->GetPassword().isEmpty()) + aPasswdDlg.ShowExtras( SfxShowExtras::CONFIRM ); + if (RET_OK == aPasswdDlg.run() && !aPasswdDlg.GetPassword().isEmpty()) { - rPassword = aPasswdDlg->GetPassword(); + rPassword = aPasswdDlg.GetPassword(); bRes = true; } return bRes; @@ -332,8 +332,7 @@ IMPL_LINK_NOARG(SfxSecurityPage_Impl, RecordChangesCBToggleHdl, CheckBox&, void) bool bAlreadyDone = false; if (!m_bEndRedliningWarningDone) { - vcl::Window* pWin = m_rMyTabPage.GetParent(); - std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr, + std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(m_rMyTabPage.GetFrameWeld(), VclMessageType::Warning, VclButtonsType::YesNo, m_aEndRedliningWarning)); xWarn->set_default_response(RET_NO); @@ -350,7 +349,7 @@ IMPL_LINK_NOARG(SfxSecurityPage_Impl, RecordChangesCBToggleHdl, CheckBox&, void) OUString aPasswordText; // dialog canceled or no password provided - if (!lcl_GetPassword( m_rMyTabPage.GetParent(), false, aPasswordText )) + if (!lcl_GetPassword( m_rMyTabPage.GetFrameWeld(), false, aPasswordText )) bAlreadyDone = true; // ask for password and if dialog is canceled or no password provided return @@ -390,7 +389,7 @@ IMPL_LINK_NOARG(SfxSecurityPage_Impl, ChangeProtectionPBHdl, Button*, void) if (bNeedPassword) { // ask for password and if dialog is canceled or no password provided return - if (!lcl_GetPassword( m_rMyTabPage.GetParent(), bNewProtection, aPasswordText )) + if (!lcl_GetPassword(m_rMyTabPage.GetFrameWeld(), bNewProtection, aPasswordText)) return; // provided password still needs to be checked? diff --git a/sfx2/source/doc/docinsert.cxx b/sfx2/source/doc/docinsert.cxx index de150152f6a2..2f53b7519163 100644 --- a/sfx2/source/doc/docinsert.cxx +++ b/sfx2/source/doc/docinsert.cxx @@ -216,12 +216,12 @@ IMPL_LINK_NOARG(DocumentInserter, DialogClosedHdl, sfx2::FileDialogHelper*, void if ( ( aValue >>= bPassWord ) && bPassWord ) { // ask for the password - ScopedVclPtrInstance< SfxPasswordDialog > aPasswordDlg(nullptr); - aPasswordDlg->ShowExtras( SfxShowExtras::CONFIRM ); - short nRet = aPasswordDlg->Execute(); + SfxPasswordDialog aPasswordDlg(m_xParent ? m_xParent->GetFrameWeld() : nullptr); + aPasswordDlg.ShowExtras( SfxShowExtras::CONFIRM ); + short nRet = aPasswordDlg.run(); if ( RET_OK == nRet ) { - m_pItemSet->Put( SfxStringItem( SID_PASSWORD, aPasswordDlg->GetPassword() ) ); + m_pItemSet->Put( SfxStringItem( SID_PASSWORD, aPasswordDlg.GetPassword() ) ); } else { diff --git a/sfx2/uiconfig/ui/password.ui b/sfx2/uiconfig/ui/password.ui index 09fbb09cf9ee..086c3965806a 100644 --- a/sfx2/uiconfig/ui/password.ui +++ b/sfx2/uiconfig/ui/password.ui @@ -1,11 +1,14 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.20.0 --> +<!-- Generated with glade 3.20.2 --> <interface domain="sfx"> - <requires lib="gtk+" version="3.0"/> + <requires lib="gtk+" version="3.20"/> <object class="GtkDialog" id="PasswordDialog"> <property name="can_focus">False</property> <property name="border_width">6</property> <property name="title" translatable="yes" context="password|PasswordDialog">Enter Password</property> + <property name="modal">True</property> + <property name="default_width">0</property> + <property name="default_height">0</property> <property name="type_hint">dialog</property> <child internal-child="vbox"> <object class="GtkBox" id="dialog-vbox1"> @@ -22,6 +25,7 @@ <property name="visible">True</property> <property name="sensitive">False</property> <property name="can_focus">True</property> + <property name="can_default">True</property> <property name="has_default">True</property> <property name="receives_default">True</property> <property name="use_stock">True</property> @@ -152,7 +156,7 @@ <property name="can_focus">True</property> <property name="hexpand">True</property> <property name="visibility">False</property> - <property name="invisible_char">●</property> + <property name="input_purpose">password</property> <child internal-child="accessible"> <object class="AtkObject" id="pass1ed-atkobject"> <property name="AtkObject::accessible-name" translatable="yes" context="password|pass1ed-atkobject">Password</property> @@ -170,7 +174,7 @@ <property name="can_focus">True</property> <property name="hexpand">True</property> <property name="visibility">False</property> - <property name="invisible_char">●</property> + <property name="input_purpose">password</property> </object> <packing> <property name="left_attach">1</property> @@ -250,7 +254,7 @@ <property name="can_focus">True</property> <property name="hexpand">True</property> <property name="visibility">False</property> - <property name="invisible_char">●</property> + <property name="input_purpose">password</property> </object> <packing> <property name="left_attach">1</property> @@ -263,7 +267,7 @@ <property name="can_focus">True</property> <property name="hexpand">True</property> <property name="visibility">False</property> - <property name="invisible_char">●</property> + <property name="input_purpose">password</property> </object> <packing> <property name="left_attach">1</property> @@ -314,9 +318,11 @@ </object> </child> <action-widgets> - <action-widget response="-5">ok</action-widget> <action-widget response="-6">cancel</action-widget> <action-widget response="-11">help</action-widget> </action-widgets> + <child> + <placeholder/> + </child> </object> </interface> diff --git a/sw/source/ui/dialog/uiregionsw.cxx b/sw/source/ui/dialog/uiregionsw.cxx index 1096103092da..b513bbcffa2b 100644 --- a/sw/source/ui/dialog/uiregionsw.cxx +++ b/sw/source/ui/dialog/uiregionsw.cxx @@ -407,11 +407,11 @@ bool SwEditRegionDlg::CheckPasswd(CheckBox* pBox) if (!pRepr->GetTempPasswd().getLength() && pRepr->GetSectionData().GetPassword().getLength()) { - ScopedVclPtrInstance< SfxPasswordDialog > aPasswdDlg(this); + SfxPasswordDialog aPasswdDlg(GetFrameWeld()); bRet = false; - if (aPasswdDlg->Execute()) + if (aPasswdDlg.run()) { - const OUString sNewPasswd( aPasswdDlg->GetPassword() ); + const OUString sNewPasswd(aPasswdDlg.GetPassword()); css::uno::Sequence <sal_Int8 > aNewPasswd; SvPasswordHelper::GetHashPassword( aNewPasswd, sNewPasswd ); if (SvPasswordHelper::CompareHashPassword( @@ -1260,12 +1260,12 @@ IMPL_LINK( SwEditRegionDlg, ChangePasswdHdl, Button *, pBox, void ) { if(!pRepr->GetTempPasswd().getLength() || bChange) { - ScopedVclPtrInstance< SfxPasswordDialog > aPasswdDlg(this); - aPasswdDlg->ShowExtras(SfxShowExtras::CONFIRM); - if(RET_OK == aPasswdDlg->Execute()) + SfxPasswordDialog aPasswdDlg(GetFrameWeld()); + aPasswdDlg.ShowExtras(SfxShowExtras::CONFIRM); + if (RET_OK == aPasswdDlg.run()) { - const OUString sNewPasswd( aPasswdDlg->GetPassword() ); - if( aPasswdDlg->GetConfirm() == sNewPasswd ) + const OUString sNewPasswd(aPasswdDlg.GetPassword()); + if (aPasswdDlg.GetConfirm() == sNewPasswd) { SvPasswordHelper::GetHashPassword( pRepr->GetTempPasswd(), sNewPasswd ); } @@ -1700,12 +1700,12 @@ IMPL_LINK( SwInsertSectionTabPage, ChangePasswdHdl, Button *, pButton, void ) { if(!m_aNewPasswd.getLength() || bChange) { - ScopedVclPtrInstance< SfxPasswordDialog > aPasswdDlg(this); - aPasswdDlg->ShowExtras(SfxShowExtras::CONFIRM); - if(RET_OK == aPasswdDlg->Execute()) + SfxPasswordDialog aPasswdDlg(GetFrameWeld()); + aPasswdDlg.ShowExtras(SfxShowExtras::CONFIRM); + if(RET_OK == aPasswdDlg.run()) { - const OUString sNewPasswd( aPasswdDlg->GetPassword() ); - if( aPasswdDlg->GetConfirm() == sNewPasswd ) + const OUString sNewPasswd(aPasswdDlg.GetPassword()); + if (aPasswdDlg.GetConfirm() == sNewPasswd) { SvPasswordHelper::GetHashPassword( m_aNewPasswd, sNewPasswd ); } diff --git a/sw/source/uibase/dbui/mailmergehelper.cxx b/sw/source/uibase/dbui/mailmergehelper.cxx index 70e156639498..6125e58b2f77 100644 --- a/sw/source/uibase/dbui/mailmergehelper.cxx +++ b/sw/source/uibase/dbui/mailmergehelper.cxx @@ -613,10 +613,10 @@ OUString SwAuthenticator::getPassword( ) { if(!m_aUserName.isEmpty() && m_aPassword.isEmpty() && m_pParentWindow) { - ScopedVclPtrInstance<SfxPasswordDialog> pPasswdDlg( m_pParentWindow ); - pPasswdDlg->SetMinLen( 0 ); - if(RET_OK == pPasswdDlg->Execute()) - m_aPassword = pPasswdDlg->GetPassword(); + SfxPasswordDialog aPasswdDlg(m_pParentWindow->GetFrameWeld()); + aPasswdDlg.SetMinLen(0); + if (RET_OK == aPasswdDlg.run()) + m_aPassword = aPasswdDlg.GetPassword(); } return m_aPassword; } diff --git a/sw/source/uibase/uiview/view2.cxx b/sw/source/uibase/uiview/view2.cxx index 31f7deb72e16..d1707627f7ef 100644 --- a/sw/source/uibase/uiview/view2.cxx +++ b/sw/source/uibase/uiview/view2.cxx @@ -563,12 +563,12 @@ void SwView::Execute(SfxRequest &rReq) { OSL_ENSURE( !static_cast<const SfxBoolItem*>(pItem)->GetValue(), "SwView::Execute(): password set an redlining off doesn't match!" ); // xmlsec05: new password dialog - vcl::Window* pParent = &GetViewFrame()->GetWindow(); - ScopedVclPtrInstance< SfxPasswordDialog > aPasswdDlg( pParent ); - aPasswdDlg->SetMinLen( 1 ); + weld::Window* pParent = GetViewFrame()->GetWindow().GetFrameWeld(); + SfxPasswordDialog aPasswdDlg(pParent); + aPasswdDlg.SetMinLen(1); //#i69751# the result of Execute() can be ignored - (void)aPasswdDlg->Execute(); - OUString sNewPasswd( aPasswdDlg->GetPassword() ); + (void)aPasswdDlg.run(); + OUString sNewPasswd(aPasswdDlg.GetPassword()); Sequence <sal_Int8> aNewPasswd = rIDRA.GetRedlinePassword(); SvPasswordHelper::GetHashPassword( aNewPasswd, sNewPasswd ); if(SvPasswordHelper::CompareHashPassword(aPasswd, sNewPasswd)) @@ -604,15 +604,15 @@ void SwView::Execute(SfxRequest &rReq) // xmlsec05: new password dialog // message box for wrong password - vcl::Window* pParent = &GetViewFrame()->GetWindow(); - ScopedVclPtrInstance< SfxPasswordDialog > aPasswdDlg( pParent ); - aPasswdDlg->SetMinLen( 1 ); - if(!aPasswd.getLength()) - aPasswdDlg->ShowExtras(SfxShowExtras::CONFIRM); - if (aPasswdDlg->Execute()) + weld::Window* pParent = GetViewFrame()->GetWindow().GetFrameWeld(); + SfxPasswordDialog aPasswdDlg(pParent); + aPasswdDlg.SetMinLen(1); + if (!aPasswd.getLength()) + aPasswdDlg.ShowExtras(SfxShowExtras::CONFIRM); + if (aPasswdDlg.run()) { RedlineFlags nOn = RedlineFlags::On; - OUString sNewPasswd( aPasswdDlg->GetPassword() ); + OUString sNewPasswd(aPasswdDlg.GetPassword()); Sequence <sal_Int8> aNewPasswd = rIDRA.GetRedlinePassword(); SvPasswordHelper::GetHashPassword( aNewPasswd, sNewPasswd ); diff --git a/writerperfect/source/calc/MSWorksCalcImportFilter.cxx b/writerperfect/source/calc/MSWorksCalcImportFilter.cxx index 2cef6152f4a8..f3a365dd1bd6 100644 --- a/writerperfect/source/calc/MSWorksCalcImportFilter.cxx +++ b/writerperfect/source/calc/MSWorksCalcImportFilter.cxx @@ -241,11 +241,11 @@ bool MSWorksCalcImportFilter::doImportDocument(librevenge::RVNGInputStream &rInp // try to ask for a password try { - ScopedVclPtrInstance< SfxPasswordDialog > aPasswdDlg(nullptr); - aPasswdDlg->SetMinLen(1); - if (!aPasswdDlg->Execute()) + SfxPasswordDialog aPasswdDlg(nullptr); + aPasswdDlg.SetMinLen(1); + if (!aPasswdDlg.run()) return false; - OUString aPasswd = aPasswdDlg->GetPassword(); + OUString aPasswd = aPasswdDlg.GetPassword(); aUtf8Passwd = OUStringToOString(aPasswd, RTL_TEXTENCODING_UTF8); } catch (...) diff --git a/writerperfect/source/writer/StarOfficeWriterImportFilter.cxx b/writerperfect/source/writer/StarOfficeWriterImportFilter.cxx index 5d083131b6f6..6c0ac8ecf13c 100644 --- a/writerperfect/source/writer/StarOfficeWriterImportFilter.cxx +++ b/writerperfect/source/writer/StarOfficeWriterImportFilter.cxx @@ -45,11 +45,11 @@ bool StarOfficeWriterImportFilter::doImportDocument(librevenge::RVNGInputStream // try to ask for a password try { - ScopedVclPtrInstance< SfxPasswordDialog > aPasswdDlg(nullptr); - aPasswdDlg->SetMinLen(0); - if (!aPasswdDlg->Execute()) + SfxPasswordDialog aPasswdDlg(nullptr); + aPasswdDlg.SetMinLen(0); + if (!aPasswdDlg.run()) return false; - OUString aPasswd = aPasswdDlg->GetPassword(); + OUString aPasswd = aPasswdDlg.GetPassword(); aUtf8Passwd = OUStringToOString(aPasswd, RTL_TEXTENCODING_UTF8); } catch (...) diff --git a/writerperfect/source/writer/WordPerfectImportFilter.cxx b/writerperfect/source/writer/WordPerfectImportFilter.cxx index 6a32a7d37c36..1975a7084b1c 100644 --- a/writerperfect/source/writer/WordPerfectImportFilter.cxx +++ b/writerperfect/source/writer/WordPerfectImportFilter.cxx @@ -112,11 +112,11 @@ bool WordPerfectImportFilter::importImpl(const Sequence< css::beans::PropertyVal int unsuccessfulAttempts = 0; while (true) { - ScopedVclPtrInstance< SfxPasswordDialog > aPasswdDlg(nullptr); - aPasswdDlg->SetMinLen(0); - if (!aPasswdDlg->Execute()) + SfxPasswordDialog aPasswdDlg(nullptr); + aPasswdDlg.SetMinLen(0); + if (!aPasswdDlg.run()) return false; - OUString aPasswd = aPasswdDlg->GetPassword(); + OUString aPasswd = aPasswdDlg.GetPassword(); aUtf8Passwd = OUStringToOString(aPasswd, RTL_TEXTENCODING_UTF8); if (libwpd::WPD_PASSWORD_MATCH_OK == libwpd::WPDocument::verifyPassword(&input, aUtf8Passwd.getStr())) break; |