summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorJustin Luth <justin.luth@collabora.com>2020-05-06 10:45:10 +0300
committerJustin Luth <justin_luth@sil.org>2020-05-07 06:19:06 +0200
commit0f7f3ede6699df09be5b0d9d24818cf1fbbaf6f6 (patch)
treed906dc904f0ee36d6c54b4f03b16ad5c187440f1 /sw
parent7e257697f0006d8247a23ac917bdffb1cda5705d (diff)
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_luth@sil.org>
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/uiwriter/data3/tdf132637_protectTrackChanges.docbin0 -> 26624 bytes
-rw-r--r--sw/qa/extras/uiwriter/uiwriter3.cxx12
-rw-r--r--sw/source/filter/ww8/ww8par.cxx7
3 files changed, 17 insertions, 2 deletions
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
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data3/tdf132637_protectTrackChanges.doc
Binary files 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() )
{