From 0f7f3ede6699df09be5b0d9d24818cf1fbbaf6f6 Mon Sep 17 00:00:00 2001 From: Justin Luth Date: Wed, 6 May 2020 10:45:10 +0300 Subject: 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 --- .../uiwriter/data3/tdf132637_protectTrackChanges.doc | Bin 0 -> 26624 bytes sw/qa/extras/uiwriter/uiwriter3.cxx | 12 ++++++++++++ sw/source/filter/ww8/ww8par.cxx | 7 +++++-- 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 sw/qa/extras/uiwriter/data3/tdf132637_protectTrackChanges.doc (limited to 'sw') 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 #include +#include + 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(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() ) { -- cgit