summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNickWingate <nick.wingate@collabora.com>2022-12-28 17:27:31 +0000
committerAndras Timar <andras.timar@collabora.com>2023-01-18 22:03:24 +0000
commit6213ede2d6f3b9ae8c386d48cbcb99ce74b74c98 (patch)
tree2013e5a8da832d44d3fe03540a98e5838bf5c485
parenta9c45cabdae874f4b1626b2f33dc848367244287 (diff)
Make PDFExport Password Subdialog Async
Dialog in File>Export As PDF>Security>Set Password Close subdialog when parent dialog is closed Signed-off-by: NickWingate <nick.wingate@collabora.com> Change-Id: I9db8459309f2806ed47f9f932e0bde246400b2dc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144854 Reviewed-by: Szymon Kłos <szymon.klos@collabora.com> Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
-rw-r--r--filter/source/pdf/impdialog.cxx76
-rw-r--r--filter/source/pdf/impdialog.hxx4
-rw-r--r--include/sfx2/passwd.hxx6
-rw-r--r--sfx2/source/dialog/passwd.cxx30
-rw-r--r--vcl/jsdialog/enabled.cxx4
5 files changed, 81 insertions, 39 deletions
diff --git a/filter/source/pdf/impdialog.cxx b/filter/source/pdf/impdialog.cxx
index 5552b92e3efe..57f284a6379b 100644
--- a/filter/source/pdf/impdialog.cxx
+++ b/filter/source/pdf/impdialog.cxx
@@ -1161,6 +1161,10 @@ ImpPDFTabSecurityPage::ImpPDFTabSecurityPage(weld::Container* pPage, weld::Dialo
ImpPDFTabSecurityPage::~ImpPDFTabSecurityPage()
{
+ if (mpPasswordDialog)
+ mpPasswordDialog->response(RET_CANCEL);
+ if (mpUnsupportedMsgDialog)
+ mpUnsupportedMsgDialog->response(RET_CANCEL);
}
std::unique_ptr<SfxTabPage> ImpPDFTabSecurityPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet)
@@ -1251,40 +1255,52 @@ void ImpPDFTabSecurityPage::SetFilterConfigItem( const ImpPDFTabDialog* pParent
IMPL_LINK_NOARG(ImpPDFTabSecurityPage, ClickmaPbSetPwdHdl, weld::Button&, void)
{
- SfxPasswordDialog aPwdDialog(m_xContainer.get(), &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());
+ if(mpPasswordDialog)
+ mpPasswordDialog->response(RET_CANCEL);
- mbHaveUserPassword = !aUserPW.isEmpty();
- mbHaveOwnerPassword = !aOwnerPW.isEmpty();
+ mpPasswordDialog = std::make_shared<SfxPasswordDialog>(m_xContainer.get(), &msUserPwdTitle);
- mxPreparedPasswords = vcl::PDFWriter::InitEncryption( aOwnerPW, aUserPW );
- if (!mxPreparedPasswords.is()) {
- OUString msg;
- ErrorHandler::GetErrorString(ERRCODE_IO_NOTSUPPORTED, msg); //TODO: handle failure
- std::unique_ptr<weld::MessageDialog>(
- Application::CreateMessageDialog(
- GetFrameWeld(), VclMessageType::Error, VclButtonsType::Ok, msg))
- ->run();
- return;
- }
+ mpPasswordDialog->SetMinLen(0);
+ mpPasswordDialog->ShowMinLengthText(false);
+ mpPasswordDialog->ShowExtras( SfxShowExtras::CONFIRM | SfxShowExtras::PASSWORD2 | SfxShowExtras::CONFIRM2 );
+ mpPasswordDialog->set_title(msStrSetPwd);
+ mpPasswordDialog->SetGroup2Text(msOwnerPwdTitle);
+ mpPasswordDialog->AllowAsciiOnly();
- if( mbHaveOwnerPassword )
+ mpPasswordDialog->PreRun();
+
+ weld::DialogController::runAsync(mpPasswordDialog, [this](sal_Int32 response){
+ if (response == RET_OK)
{
- maPreparedOwnerPassword = comphelper::OStorageHelper::CreatePackageEncryptionData( aOwnerPW );
- }
- else
- maPreparedOwnerPassword = Sequence< NamedValue >();
- }
- enablePermissionControls();
+ OUString aUserPW(mpPasswordDialog->GetPassword());
+ OUString aOwnerPW(mpPasswordDialog->GetPassword2());
+
+ mbHaveUserPassword = !aUserPW.isEmpty();
+ mbHaveOwnerPassword = !aOwnerPW.isEmpty();
+
+ mxPreparedPasswords = vcl::PDFWriter::InitEncryption( aOwnerPW, aUserPW );
+ if (!mxPreparedPasswords.is()) {
+ OUString msg;
+ ErrorHandler::GetErrorString(ERRCODE_IO_NOTSUPPORTED, msg); //TODO: handle failure
+ mpUnsupportedMsgDialog = std::shared_ptr<weld::MessageDialog>(
+ Application::CreateMessageDialog(
+ GetFrameWeld(), VclMessageType::Error, VclButtonsType::Ok, msg));
+
+ mpUnsupportedMsgDialog->runAsync(mpUnsupportedMsgDialog, [](sal_Int32){ });
+ return;
+ }
+
+ if( mbHaveOwnerPassword )
+ {
+ maPreparedOwnerPassword = comphelper::OStorageHelper::CreatePackageEncryptionData( aOwnerPW );
+ }
+ else
+ maPreparedOwnerPassword = Sequence< NamedValue >();
+ }
+ if (response != RET_CANCEL)
+ enablePermissionControls();
+ mpPasswordDialog.reset();
+ });
}
void ImpPDFTabSecurityPage::enablePermissionControls()
diff --git a/filter/source/pdf/impdialog.hxx b/filter/source/pdf/impdialog.hxx
index 2e7a13df9290..210412e87fd8 100644
--- a/filter/source/pdf/impdialog.hxx
+++ b/filter/source/pdf/impdialog.hxx
@@ -20,6 +20,7 @@
#pragma once
#include <sfx2/tabdlg.hxx>
+#include <sfx2/passwd.hxx>
#include <svx/AccessibilityCheckDialog.hxx>
#include <vcl/pdfwriter.hxx>
@@ -346,6 +347,9 @@ class ImpPDFTabSecurityPage : public SfxTabPage
std::unique_ptr<weld::CheckButton> mxCbEnableAccessibility;
std::unique_ptr<weld::Label> mxPasswordTitle;
+ std::shared_ptr< SfxPasswordDialog > mpPasswordDialog;
+ std::shared_ptr< weld::MessageDialog > mpUnsupportedMsgDialog;
+
DECL_LINK(ClickmaPbSetPwdHdl, weld::Button&, void);
void enablePermissionControls();
diff --git a/include/sfx2/passwd.hxx b/include/sfx2/passwd.hxx
index cbbbf7a4a33d..a3bee5877e89 100644
--- a/include/sfx2/passwd.hxx
+++ b/include/sfx2/passwd.hxx
@@ -63,6 +63,8 @@ private:
std::unique_ptr<weld::Button> m_xOKBtn;
+ std::shared_ptr<weld::MessageDialog> m_xConfirmFailedDialog;
+
OUString maMinLenPwdStr;
OUString maMinLenPwdStr1;
OUString maEmptyPwdStr;
@@ -124,7 +126,11 @@ public:
void ShowMinLengthText(bool bShow);
+ void PreRun();
+
virtual short run() override;
+
+ ~SfxPasswordDialog();
};
#endif // INCLUDED_SFX2_PASSWD_HXX
diff --git a/sfx2/source/dialog/passwd.cxx b/sfx2/source/dialog/passwd.cxx
index efc108278c09..e0e1d829afe0 100644
--- a/sfx2/source/dialog/passwd.cxx
+++ b/sfx2/source/dialog/passwd.cxx
@@ -69,12 +69,18 @@ IMPL_LINK_NOARG(SfxPasswordDialog, OKHdl, weld::Button&, void)
bConfirmFailed = true;
if ( bConfirmFailed )
{
- std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_xDialog.get(),
- VclMessageType::Warning, VclButtonsType::Ok,
- SfxResId(STR_ERROR_WRONG_CONFIRM)));
- xBox->run();
- m_xConfirm1ED->set_text(OUString());
- m_xConfirm1ED->grab_focus();
+ if (m_xConfirmFailedDialog)
+ m_xConfirmFailedDialog->response(RET_CANCEL);
+
+ m_xConfirmFailedDialog =
+ std::shared_ptr<weld::MessageDialog>(Application::CreateMessageDialog(m_xDialog.get(),
+ VclMessageType::Warning, VclButtonsType::Ok,
+ SfxResId(STR_ERROR_WRONG_CONFIRM)));
+ m_xConfirmFailedDialog->runAsync(m_xConfirmFailedDialog, [this](sal_uInt32 response){
+ m_xConfirm1ED->set_text(OUString());
+ m_xConfirm1ED->grab_focus();
+ m_xConfirmFailedDialog->response(response);
+ });
}
else
m_xDialog->response(RET_OK);
@@ -151,7 +157,7 @@ void SfxPasswordDialog::ShowMinLengthText(bool bShow)
m_xMinLengthFT->set_visible(bShow);
}
-short SfxPasswordDialog::run()
+void SfxPasswordDialog::PreRun()
{
m_xUserFT->hide();
m_xUserED->hide();
@@ -188,8 +194,18 @@ short SfxPasswordDialog::run()
m_xConfirm2FT->show();
m_xConfirm2ED->show();
}
+}
+
+short SfxPasswordDialog::run()
+{
+ PreRun();
return GenericDialogController::run();
}
+SfxPasswordDialog::~SfxPasswordDialog()
+{
+ if (m_xConfirmFailedDialog)
+ m_xConfirmFailedDialog->response(RET_CANCEL);
+}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/jsdialog/enabled.cxx b/vcl/jsdialog/enabled.cxx
index 81a1a6f4603b..bc0a6f65f59b 100644
--- a/vcl/jsdialog/enabled.cxx
+++ b/vcl/jsdialog/enabled.cxx
@@ -86,6 +86,7 @@ bool isBuilderEnabled(std::u16string_view rUIFile, bool bMobile)
|| rUIFile == u"sfx/ui/documentpropertiesdialog.ui"
|| rUIFile == u"sfx/ui/editdurationdialog.ui"
|| rUIFile == u"sfx/ui/linefragment.ui"
+ || rUIFile == u"sfx/ui/password.ui"
// svx
|| rUIFile == u"svx/ui/accessibilitycheckdialog.ui"
|| rUIFile == u"svx/ui/accessibilitycheckentry.ui"
@@ -106,8 +107,7 @@ bool isBuilderEnabled(std::u16string_view rUIFile, bool bMobile)
|| rUIFile == u"filter/ui/pdflinkspage.ui"
|| rUIFile == u"filter/ui/warnpdfdialog.ui"
|| rUIFile == u"filter/ui/pdfsignpage.ui"
- || rUIFile == u"writerperfect/ui/exportepub.ui"
- )
+ || rUIFile == u"writerperfect/ui/exportepub.ui")
{
return true;
}