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

New commits:
commit 8017dc98b9037fff3df24ef7cc5a575dc40d2bb8
Author:     Ashod Nakashian <ashod.nakash...@collabora.co.uk>
AuthorDate: Tue Jul 4 02:13:28 2023 -0400
Commit:     Ashod Nakashian <a...@collabora.com>
CommitDate: Fri Jul 7 21:37: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/+/153918
    Reviewed-by: Jaume Pujantell <jaume.pujant...@collabora.com>
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>

diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx
index 71eeafc6ff6f..c8f68fdaa9ba 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