summaryrefslogtreecommitdiff
path: root/filter
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-19 12:48:06 +0000
commit7ebe5e19fb379c88b8e455693a23fd9036c1b517 (patch)
treede08a8c75f8252060c7a85403f2d98a30f7b86b3 /filter
parentee8aa3dbaf6c02c9ea1bd7781e5e71847b4e614b (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> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145759 Tested-by: Jenkins Reviewed-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'filter')
-rw-r--r--filter/source/pdf/impdialog.cxx73
-rw-r--r--filter/source/pdf/impdialog.hxx4
2 files changed, 48 insertions, 29 deletions
diff --git a/filter/source/pdf/impdialog.cxx b/filter/source/pdf/impdialog.cxx
index 4a03de89fdef..2516342cde70 100644
--- a/filter/source/pdf/impdialog.cxx
+++ b/filter/source/pdf/impdialog.cxx
@@ -1171,6 +1171,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)
@@ -1261,40 +1265,51 @@ 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();
+
+ mpPasswordDialog->PreRun();
- if( mbHaveOwnerPassword )
+ weld::DialogController::runAsync(mpPasswordDialog, [this](sal_Int32 response){
+ if (response == RET_OK)
{
- maPreparedOwnerPassword = comphelper::OStorageHelper::CreatePackageEncryptionData( aOwnerPW );
+ 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 >();
}
- else
- maPreparedOwnerPassword = Sequence< NamedValue >();
- }
- enablePermissionControls();
+ 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 d0d63bccc86b..dd2a9a3add98 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();