cui/source/dialogs/passwdomdlg.cxx   |    8 +++++++-
 cui/source/factory/dlgfact.cxx       |    5 +++++
 cui/source/factory/dlgfact.hxx       |    1 +
 cui/source/inc/passwdomdlg.hxx       |    2 ++
 include/sfx2/filedlghelper.hxx       |    5 +++--
 include/vcl/abstdlg.hxx              |    1 +
 sc/source/ui/inc/delcodlg.hxx        |    1 -
 sc/source/ui/miscdlgs/delcodlg.cxx   |    1 -
 sfx2/source/dialog/dinfdlg.cxx       |    4 +++-
 sfx2/source/dialog/filedlghelper.cxx |   15 ++++++++++++++-
 vcl/jsdialog/enabled.cxx             |    3 ++-
 11 files changed, 38 insertions(+), 8 deletions(-)

New commits:
commit 5762aa5c0efb75e8b7713b4c2ee8bd9300fc06cf
Author:     Szymon Kłos <[email protected]>
AuthorDate: Thu Nov 17 21:40:54 2022 +0100
Commit:     Szymon Kłos <[email protected]>
CommitDate: Mon Nov 21 12:36:50 2022 +0100

    jsdialog: enable Delete content dialog
    
    Dialog had unused m_xBtnOk which has defined standard
    response in .ui file - no need to bind anything in the code.
    
    Change-Id: Ie743485bb30a03b82a87dc69015a704e14c39384
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142903
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Michael Meeks <[email protected]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142993
    Tested-by: Jenkins
    Reviewed-by: Szymon Kłos <[email protected]>

diff --git a/sc/source/ui/inc/delcodlg.hxx b/sc/source/ui/inc/delcodlg.hxx
index c23deed4fcc6..7c49a79f9d33 100644
--- a/sc/source/ui/inc/delcodlg.hxx
+++ b/sc/source/ui/inc/delcodlg.hxx
@@ -35,7 +35,6 @@ private:
     std::unique_ptr<weld::CheckButton> m_xBtnDelNotes;
     std::unique_ptr<weld::CheckButton> m_xBtnDelAttrs;
     std::unique_ptr<weld::CheckButton> m_xBtnDelObjects;
-    std::unique_ptr<weld::Button> m_xBtnOk;
 
     static bool bPreviousAllCheck;
     static InsertDeleteFlags nPreviousChecks;
diff --git a/sc/source/ui/miscdlgs/delcodlg.cxx 
b/sc/source/ui/miscdlgs/delcodlg.cxx
index 9d804c252419..56334ba9ca9c 100644
--- a/sc/source/ui/miscdlgs/delcodlg.cxx
+++ b/sc/source/ui/miscdlgs/delcodlg.cxx
@@ -37,7 +37,6 @@ ScDeleteContentsDlg::ScDeleteContentsDlg(weld::Window* 
pParent)
     , m_xBtnDelNotes(m_xBuilder->weld_check_button("comments"))
     , m_xBtnDelAttrs(m_xBuilder->weld_check_button("formats"))
     , m_xBtnDelObjects(m_xBuilder->weld_check_button("objects"))
-    , m_xBtnOk(m_xBuilder->weld_button("ok"))
 {
     m_xBtnDelAll->set_active( ScDeleteContentsDlg::bPreviousAllCheck );
     m_xBtnDelStrings->set_active( bool(InsertDeleteFlags::STRING & 
ScDeleteContentsDlg::nPreviousChecks) );
diff --git a/vcl/jsdialog/enabled.cxx b/vcl/jsdialog/enabled.cxx
index 375023636916..47d8e0e08df5 100644
--- a/vcl/jsdialog/enabled.cxx
+++ b/vcl/jsdialog/enabled.cxx
@@ -73,7 +73,8 @@ bool isBuilderEnabled(std::u16string_view rUIFile, bool 
bMobile)
         || rUIFile == u"modules/swriter/ui/insertcaption.ui"
         || rUIFile == u"modules/swriter/ui/captionoptions.ui"
         || rUIFile == u"cui/ui/formatnumberdialog.ui" || rUIFile == 
u"cui/ui/password.ui"
-        || rUIFile == u"cui/ui/numberingformatpage.ui")
+        || rUIFile == u"cui/ui/numberingformatpage.ui"
+        || rUIFile == u"modules/scalc/ui/deletecontents.ui")
     {
         return true;
     }
commit 58ae6705deccb614f33d20bfa4b2ab0923d426e1
Author:     Szymon Kłos <[email protected]>
AuthorDate: Fri Oct 14 14:54:15 2022 +0200
Commit:     Szymon Kłos <[email protected]>
CommitDate: Mon Nov 21 12:36:35 2022 +0100

    lok: allow password reset in properties>change password
    
    Change-Id: I92a3c658e96f602549ff5282b6ed5bc9ee780bbd
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141372
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Andras Timar <[email protected]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142992
    Tested-by: Jenkins
    Reviewed-by: Szymon Kłos <[email protected]>

diff --git a/cui/source/dialogs/passwdomdlg.cxx 
b/cui/source/dialogs/passwdomdlg.cxx
index 163f3961f22e..579af0edc9aa 100644
--- a/cui/source/dialogs/passwdomdlg.cxx
+++ b/cui/source/dialogs/passwdomdlg.cxx
@@ -24,7 +24,7 @@
 
 IMPL_LINK_NOARG(PasswordToOpenModifyDialog, OkBtnClickHdl, weld::Button&, void)
 {
-    bool bInvalidState = !m_xOpenReadonlyCB->get_active() &&
+    bool bInvalidState = !m_xOpenReadonlyCB->get_active() && !m_bAllowEmpty &&
             m_xPasswdToOpenED->get_text().isEmpty() &&
             m_xPasswdToModifyED->get_text().isEmpty();
     if (bInvalidState)
@@ -107,6 +107,7 @@ 
PasswordToOpenModifyDialog::PasswordToOpenModifyDialog(weld::Window * pParent, s
     , m_aInvalidStateForOkButton_v2( CuiResId( 
RID_CUISTR_INVALID_STATE_FOR_OK_BUTTON_V2 ) )
     , m_nMaxPasswdLen(nMaxPasswdLen)
     , m_bIsPasswordToModify( bIsPasswordToModify )
+    , m_bAllowEmpty( false )
 {
     m_xOk->connect_clicked(LINK(this, PasswordToOpenModifyDialog, 
OkBtnClickHdl));
 
@@ -145,6 +146,11 @@ PasswordToOpenModifyDialog::~PasswordToOpenModifyDialog()
     }
 }
 
+void PasswordToOpenModifyDialog::AllowEmpty()
+{
+    m_bAllowEmpty = true;
+}
+
 OUString PasswordToOpenModifyDialog::GetPasswordToOpen() const
 {
     const bool bPasswdOk =
diff --git a/cui/source/factory/dlgfact.cxx b/cui/source/factory/dlgfact.cxx
index 9bd3f0229be4..f0177530fa70 100644
--- a/cui/source/factory/dlgfact.cxx
+++ b/cui/source/factory/dlgfact.cxx
@@ -809,6 +809,11 @@ void 
AbstractPasswordToOpenModifyDialog_Impl::Response(sal_Int32 nResult)
      m_xDlg->response(nResult);
 }
 
+void AbstractPasswordToOpenModifyDialog_Impl::AllowEmpty()
+{
+     m_xDlg->AllowEmpty();
+}
+
 // Create dialogs with simplest interface
 VclPtr<VclAbstractDialog> 
AbstractDialogFactory_Impl::CreateVclDialog(weld::Window* pParent, sal_uInt32 
nResId)
 {
diff --git a/cui/source/factory/dlgfact.hxx b/cui/source/factory/dlgfact.hxx
index 071c71592b50..991ec082ad48 100644
--- a/cui/source/factory/dlgfact.hxx
+++ b/cui/source/factory/dlgfact.hxx
@@ -388,6 +388,7 @@ 
DECL_ABSTDLG_CLASS_SHARED_ASYNC(AbstractPasswordToOpenModifyDialog,AbstractPassw
     virtual OUString  GetPasswordToModify() const override;
     virtual bool      IsRecommendToOpenReadonly() const override;
     virtual void      Response(sal_Int32) override;
+    virtual void      AllowEmpty() override;
 };
 
 // AbstractSvxCharacterMapDialog_Impl
diff --git a/cui/source/inc/passwdomdlg.hxx b/cui/source/inc/passwdomdlg.hxx
index 9b1cd460ea7c..24a1c7b79264 100644
--- a/cui/source/inc/passwdomdlg.hxx
+++ b/cui/source/inc/passwdomdlg.hxx
@@ -45,6 +45,7 @@ class PasswordToOpenModifyDialog : public SfxDialogController
 
     int                         m_nMaxPasswdLen;
     bool                        m_bIsPasswordToModify;
+    bool                        m_bAllowEmpty;
 
 
     DECL_LINK(OkBtnClickHdl, weld::Button&, void);
@@ -64,6 +65,7 @@ public:
     OUString  GetPasswordToOpen() const;
     OUString  GetPasswordToModify() const;
     bool    IsRecommendToOpenReadonly() const;
+    void    AllowEmpty();
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/sfx2/filedlghelper.hxx b/include/sfx2/filedlghelper.hxx
index c89da31ab953..ea84a9450de6 100644
--- a/include/sfx2/filedlghelper.hxx
+++ b/include/sfx2/filedlghelper.hxx
@@ -306,8 +306,9 @@ ErrCode FileOpenDialog_Impl( weld::Window* pParent,
 css::uno::Reference<css::ui::dialogs::XFolderPicker2> SFX2_DLLPUBLIC 
createFolderPicker(const css::uno::Reference<css::uno::XComponentContext>& 
rContext, weld::Window* pPreferredParent);
 
 ErrCode RequestPassword(const std::shared_ptr<const SfxFilter>& 
pCurrentFilter, OUString const & aURL, SfxItemSet* pSet, const 
css::uno::Reference<css::awt::XWindow>& rParent);
-ErrCode SetPassword(const std::shared_ptr<const SfxFilter>& pCurrentFilter,
-    SfxItemSet* pSet, const OUString& rPasswordToOpen, std::u16string_view 
rPasswordToModify);
+ErrCode SetPassword(const std::shared_ptr<const SfxFilter>& pCurrentFilter, 
SfxItemSet* pSet,
+                    const OUString& rPasswordToOpen, std::u16string_view 
rPasswordToModify,
+                    bool bAllowPasswordReset = false);
 bool IsOOXML(const std::shared_ptr<const SfxFilter>& pCurrentFilter);
 bool IsMSType(const std::shared_ptr<const SfxFilter>& pCurrentFilter);
 }
diff --git a/include/vcl/abstdlg.hxx b/include/vcl/abstdlg.hxx
index cb4de91f88e4..9d61077a24c9 100644
--- a/include/vcl/abstdlg.hxx
+++ b/include/vcl/abstdlg.hxx
@@ -100,6 +100,7 @@ public:
     virtual OUString    GetPasswordToModify() const = 0;
     virtual bool        IsRecommendToOpenReadonly() const = 0;
     virtual void        Response(sal_Int32) = 0;
+    virtual void        AllowEmpty() = 0;
 };
 
 class VCL_DLLPUBLIC AbstractScreenshotAnnotationDlg : public VclAbstractDialog
diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx
index 3d1ee1dadac5..3067229b96eb 100644
--- a/sfx2/source/dialog/dinfdlg.cxx
+++ b/sfx2/source/dialog/dinfdlg.cxx
@@ -785,11 +785,13 @@ IMPL_LINK_NOARG(SfxDocumentPage, ChangePassHdl, 
weld::Button&, void)
             // handle the pwd dialog asynchronously
             VclAbstractDialogFactory * pFact = 
VclAbstractDialogFactory::Create();
             m_xPasswordDialog = 
pFact->CreatePasswordToOpenModifyDialog(GetFrameWeld(), maxPwdLen, false);
+            m_xPasswordDialog->AllowEmpty(); // needed to remove password
             m_xPasswordDialog->StartExecuteAsync([this, pFilter, pMedSet, 
pShell](sal_Int32 nResult)
             {
                 if (nResult == RET_OK)
                 {
-                    sfx2::SetPassword(pFilter, pMedSet, 
m_xPasswordDialog->GetPasswordToOpen(), m_xPasswordDialog->GetPasswordToOpen());
+                    sfx2::SetPassword(pFilter, pMedSet, 
m_xPasswordDialog->GetPasswordToOpen(),
+                                      m_xPasswordDialog->GetPasswordToOpen(), 
true);
                     pShell->SetModified();
                 }
                 m_xPasswordDialog->disposeOnce();
diff --git a/sfx2/source/dialog/filedlghelper.cxx 
b/sfx2/source/dialog/filedlghelper.cxx
index 93505057779f..541d26a9ae29 100644
--- a/sfx2/source/dialog/filedlghelper.cxx
+++ b/sfx2/source/dialog/filedlghelper.cxx
@@ -2878,7 +2878,9 @@ bool IsOOXML(const std::shared_ptr<const SfxFilter>& 
pCurrentFilter)
     return IsMSType(pCurrentFilter) && lclSupportsOOXMLEncryption( 
pCurrentFilter->GetFilterName());
 }
 
-ErrCode SetPassword(const std::shared_ptr<const SfxFilter>& pCurrentFilter, 
SfxItemSet* pSet, const OUString& rPasswordToOpen, std::u16string_view 
rPasswordToModify)
+ErrCode SetPassword(const std::shared_ptr<const SfxFilter>& pCurrentFilter, 
SfxItemSet* pSet,
+                    const OUString& rPasswordToOpen, std::u16string_view 
rPasswordToModify,
+                    bool bAllowPasswordReset)
 {
     const bool bMSType = IsMSType(pCurrentFilter);
     const bool bOOXML = IsOOXML(pCurrentFilter);
@@ -2924,6 +2926,17 @@ ErrCode SetPassword(const std::shared_ptr<const 
SfxFilter>& pCurrentFilter, SfxI
                 aEncryptionData, 
comphelper::OStorageHelper::CreatePackageEncryptionData(
                                     rPasswordToOpen)))));
     }
+    else if (bAllowPasswordReset)
+    {
+        // Remove password
+
+        if (pSet->HasItem(SID_ENCRYPTIONDATA))
+            pSet->ClearItem(SID_MODIFYPASSWORDINFO);
+        if (pSet->HasItem(SID_ENCRYPTIONDATA))
+            pSet->ClearItem(SID_ENCRYPTIONDATA);
+
+        return ERRCODE_NONE;
+    }
 
     if ( bMSType )
     {

Reply via email to