sw/qa/extras/uiwriter/data3/tdf132637_protectTrackChanges.doc |binary
 sw/qa/extras/uiwriter/uiwriter3.cxx                           |   12 ++++++++++
 sw/source/filter/ww8/ww8par.cxx                               |    7 ++++-
 3 files changed, 17 insertions(+), 2 deletions(-)

New commits:
commit 0f7f3ede6699df09be5b0d9d24818cf1fbbaf6f6
Author:     Justin Luth <justin.l...@collabora.com>
AuthorDate: Wed May 6 10:45:10 2020 +0300
Commit:     Justin Luth <justin_l...@sil.org>
CommitDate: Thu May 7 06:19:06 2020 +0200

    tdf#132637 doc import: don't open readonly for lockRev
    
    Just like with forms, the password should not be
    required to make changes when only enforcement of
    track changes is specified. So just grabbag
    the password and let the document open in read-write mode.
    
    TODO for the overly zealous: actually enforce
    file->properties->security->protect track changes,
    and also export it. (This has been done for DOCX.)
    
    Change-Id: Ib68ec5785aa0f5dbac507a3d50059a443f7ff42b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93551
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <justin_l...@sil.org>

diff --git a/sw/qa/extras/uiwriter/data3/tdf132637_protectTrackChanges.doc 
b/sw/qa/extras/uiwriter/data3/tdf132637_protectTrackChanges.doc
new file mode 100644
index 000000000000..2f75e60278e1
Binary files /dev/null and 
b/sw/qa/extras/uiwriter/data3/tdf132637_protectTrackChanges.doc differ
diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx 
b/sw/qa/extras/uiwriter/uiwriter3.cxx
index 7818a1f9cb0e..c60d5f9db739 100644
--- a/sw/qa/extras/uiwriter/uiwriter3.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter3.cxx
@@ -14,6 +14,8 @@
 #include <comphelper/propertysequence.hxx>
 #include <boost/property_tree/json_parser.hpp>
 
+#include <wrtsh.hxx>
+
 namespace
 {
 char const DATA_DIRECTORY[] = "/sw/qa/extras/uiwriter/data3/";
@@ -689,4 +691,14 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf117601)
     CPPUNIT_ASSERT(xCellB1->getString().endsWith("test1"));
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf132637_protectTrackChanges)
+{
+    load(DATA_DIRECTORY, "tdf132637_protectTrackChanges.doc");
+    SwXTextDocument* pTextDoc = 
dynamic_cast<SwXTextDocument*>(mxComponent.get());
+    CPPUNIT_ASSERT(pTextDoc);
+
+    // The password should only prevent turning off track changes, not open as 
read-only
+    CPPUNIT_ASSERT(!pTextDoc->GetDocShell()->IsReadOnly());
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index cad890294a36..514a5ec9e3d1 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -1936,8 +1936,11 @@ void SwWW8ImplReader::ImportDop()
         }
     }
 
-    // Still allow editing of form fields.
-    if (!m_xWDop->fProtEnabled)
+    // The password can force read-only, comments-only, fill-in-form-only, or 
require track-changes.
+    // Treat comments-only like read-only since Writer has no support for that.
+    // Still allow editing of form fields, without requiring the password.
+    // Still allow editing if track-changes is locked on. (Currently LockRev 
is ignored/lost on export anyway.)
+    if (!m_xWDop->fProtEnabled && !m_xWDop->fLockRev)
         m_pDocShell->SetModifyPasswordHash(m_xWDop->lKeyProtDoc);
     else if ( xDocProps.is() )
     {
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to