sfx2/source/dialog/dinfdlg.cxx |   10 ++++++++++
 1 file changed, 10 insertions(+)

New commits:
commit 1b7d41abd0f281651dca1c8c7b7b62f952e8022b
Author:     Ashod Nakashian <ashod.nakash...@collabora.co.uk>
AuthorDate: Tue Jul 4 02:13:28 2023 -0400
Commit:     Ashod Nakashian <a...@collabora.com>
CommitDate: Thu Jul 6 11:26:26 2023 +0200

    sfx2: disable setting password on text documents
    
    Since we can't preserve the password in a plain-text
    file, we should disable the ability to set/change
    it. Otherwise, it's misleading to users.
    
    Signed-off-by: Ashod Nakashian <ashod.nakash...@collabora.co.uk>
    Change-Id: I3176243ddd2826eb07def1ff5ab251e33cb7125e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153941
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Jaume Pujantell <jaume.pujant...@collabora.com>

diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx
index 85b9e50fc941..52416c1f55d0 100644
--- a/sfx2/source/dialog/dinfdlg.cxx
+++ b/sfx2/source/dialog/dinfdlg.cxx
@@ -1025,6 +1025,16 @@ void SfxDocumentPage::Reset( const SfxItemSet* rSet )
     {
         m_xFileValEd->set_label(aName);
         m_xFileValEd->set_uri(aName);
+
+        // Disable setting/changing password on text files.
+        // Perhaps this needs to be done for both Online and Desktop.
+        OUString sExtension(INetURLObject(rMainURL).getExtension());
+        if (!sExtension.isEmpty())
+        {
+            sExtension = sExtension.toAsciiLowerCase();
+            if (sExtension.equalsAscii("txt") || sExtension.equalsAscii("csv"))
+                m_xChangePassBtn->set_sensitive(false);
+        }
     }
     else
     {

Reply via email to