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

New commits:
commit 45d7ffb7f238fbb8cf99cdcd386c496223915ab7
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:25:04 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/+/153917
    Tested-by: Jenkins
    Reviewed-by: Jaume Pujantell <jaume.pujant...@collabora.com>

diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx
index f8caa35aad90..800f912b2ac9 100644
--- a/sfx2/source/dialog/dinfdlg.cxx
+++ b/sfx2/source/dialog/dinfdlg.cxx
@@ -1024,6 +1024,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 == "txt" || sExtension == "csv")
+                m_xChangePassBtn->set_sensitive(false);
+        }
     }
     else
     {

Reply via email to