[Libreoffice-commits] core.git: sw/qa writerfilter/source
László Németh (via logerrit)
logerrit at kemper.freedesktop.org
Sat Oct 12 07:30:53 UTC 2019
sw/qa/extras/uiwriter/data2/tdf106843.docx |binary
sw/qa/extras/uiwriter/uiwriter2.cxx | 17 +++++++++++++++++
writerfilter/source/dmapper/SettingsTable.cxx | 17 ++++++++++++++++-
3 files changed, 33 insertions(+), 1 deletion(-)
New commits:
commit d416250f4f1766e2d596ea3feef6a94b7adf29f4
Author: László Németh <nemeth at numbertext.org>
AuthorDate: Fri Oct 11 09:21:18 2019 +0200
Commit: László Németh <nemeth at numbertext.org>
CommitDate: Sat Oct 12 09:29:44 2019 +0200
tdf#106843 DOCX: forbid disabling protected Record Changes
Password protection of enabled record changes has been grab-
bagged, yet, but it was possible to disable the protection
without password verification, eg. by a simple click on
Record Track Changes. Now it's forbidden to disable the
protected Record Changes, using a dummy password temporarily.
Change-Id: Ibc1c9016ea164ebb588265579fb9fa589ddee114
Reviewed-on: https://gerrit.libreoffice.org/80643
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth at numbertext.org>
diff --git a/sw/qa/extras/uiwriter/data2/tdf106843.docx b/sw/qa/extras/uiwriter/data2/tdf106843.docx
new file mode 100644
index 000000000000..339ebd594168
Binary files /dev/null and b/sw/qa/extras/uiwriter/data2/tdf106843.docx differ
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index 50df467a168f..83cc90bc5d84 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -1745,6 +1745,23 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf120336)
CPPUNIT_ASSERT_EQUAL(2, getPages());
}
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf106843)
+{
+ load(DATA_DIRECTORY, "tdf106843.docx");
+
+ SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+ CPPUNIT_ASSERT(pTextDoc);
+
+ SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc();
+
+ // try to turn off red-lining
+ lcl_dispatchCommand(mxComponent, ".uno:TrackChanges", {});
+
+ // but the protection doesn't allow it
+ CPPUNIT_ASSERT_MESSAGE("redlining should be on",
+ pDoc->getIDocumentRedlineAccess().IsRedlineOn());
+}
+
CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testImageComment)
{
// Load a document with an as-char image in it.
diff --git a/writerfilter/source/dmapper/SettingsTable.cxx b/writerfilter/source/dmapper/SettingsTable.cxx
index 665f61568109..5e14f3c1b7be 100644
--- a/writerfilter/source/dmapper/SettingsTable.cxx
+++ b/writerfilter/source/dmapper/SettingsTable.cxx
@@ -115,7 +115,7 @@ namespace dmapper
bool isNone() const { return m_nEdit == NS_ooxml::LN_Value_doc_ST_DocProtect_none; };
// bool isReadOnly() const { return m_nEdit == NS_ooxml::LN_Value_doc_ST_DocProtect_readOnly; };
// bool isComments() const { return m_nEdit == NS_ooxml::LN_Value_doc_ST_DocProtect_comments; };
- // bool isTrackChanges() const { return m_nEdit == NS_ooxml::LN_Value_doc_ST_DocProtect_trackedChanges; };
+ bool isTrackChanges() const { return m_nEdit == NS_ooxml::LN_Value_doc_ST_DocProtect_trackedChanges; };
bool isForms() const { return m_nEdit == NS_ooxml::LN_Value_doc_ST_DocProtect_forms; };
};
@@ -253,6 +253,7 @@ struct SettingsTable_Impl
bool m_bMirrorMargin;
bool m_bDoNotExpandShiftReturn;
bool m_bProtectForm;
+ bool m_bRedlineProtection;
bool m_bDisplayBackgroundShape;
uno::Sequence<beans::PropertyValue> m_pThemeFontLangProps;
@@ -284,6 +285,7 @@ struct SettingsTable_Impl
, m_bMirrorMargin(false)
, m_bDoNotExpandShiftReturn(false)
, m_bProtectForm(false)
+ , m_bRedlineProtection(false)
, m_bDisplayBackgroundShape(false)
, m_pThemeFontLangProps(3)
, m_pCurrentCompatSetting(3)
@@ -348,10 +350,12 @@ void SettingsTable::lcl_attribute(Id nName, Value & val)
case NS_ooxml::LN_CT_DocProtect_edit: // 92037
m_pImpl->m_DocumentProtection.m_nEdit = nIntValue;
m_pImpl->m_bProtectForm = m_pImpl->m_DocumentProtection.isForms();
+ m_pImpl->m_bRedlineProtection = m_pImpl->m_DocumentProtection.isTrackChanges();
break;
case NS_ooxml::LN_CT_DocProtect_enforcement: // 92039
m_pImpl->m_DocumentProtection.m_bEnforcement = (nIntValue != 0);
m_pImpl->m_bProtectForm &= static_cast<bool>(nIntValue);
+ m_pImpl->m_bRedlineProtection &= static_cast<bool>(nIntValue);
break;
case NS_ooxml::LN_CT_DocProtect_formatting: // 92038
m_pImpl->m_DocumentProtection.m_bFormatting = (nIntValue != 0);
@@ -660,7 +664,18 @@ void SettingsTable::ApplyProperties(uno::Reference<text::XTextDocument> const& x
// Record changes value
if (xDocProps.is())
+ {
xDocProps->setPropertyValue("RecordChanges", uno::makeAny( m_pImpl->m_bRecordChanges ) );
+ // Password protected Record changes
+ if ( m_pImpl->m_bRecordChanges && m_pImpl->m_bRedlineProtection )
+ {
+ // use dummy protection key to forbid disabling of Record changes (extending the recent GrabBag support)
+ // TODO support password verification and DOCX export of RedlineProtectionKey...
+ css::uno::Sequence<sal_Int8> aDummyKey(1);
+ aDummyKey[0] = 1;
+ xDocProps->setPropertyValue("RedlineProtectionKey", uno::makeAny( aDummyKey ));
+ }
+ }
// Auto hyphenation: turns on hyphenation by default, <w:suppressAutoHyphens/> may still disable it at a paragraph level.
// Situation is similar for RTF_WIDOWCTRL, which turns on widow / orphan control by default.
More information about the Libreoffice-commits
mailing list