summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorJustin Luth <justin.luth@collabora.com>2020-03-11 10:09:29 +0300
committerMiklos Vajna <vmiklos@collabora.com>2020-04-01 10:15:29 +0200
commit3af7be613526404276210a698f77e0187831b9b1 (patch)
treece9c850bb6f77b9084e8d39c7d3d94859103cd3c /writerfilter
parent957092a29ff0626ead52ae776f004c08e93116b0 (diff)
tdf#120852 writerfilter: support read-only docProtection
Setting the document to LoadReadonly nicely does not prompt the user to "press this button to edit". That is what we would generally want when Read-Only is enforced, so lets use that. The user can easily enter edit mode via the edit menu, if they want to temporarily override the protection, which seems natural and discoverable enough. There is a File menu - Properties - Security option that manages the LoadReadonly setting in LO. If the user turns that off, then export will also cancel enforcement of the readOnly grabbag item. The situation where read-only was not enforced before, but now is enforced by LO, is handled by _MarkAsFinal, so that case is ignored. In other words, there was no point in adding a WriterWantsToProtectReadOnly flag. See tdf#107690 for _MarkAsFinal fix. I had started going down the wrong patch of being innovative with boolean &=, not realizing that it now always evaluated the right side. Remove that bad example for other cut-and-pasters. In the end, this logic is much easier to understand anyway. Change-Id: Id26b283078a5fd62d662a26a96cfc461e0ba8459 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90323 Tested-by: Jenkins Reviewed-by: Justin Luth <justin_luth@sil.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx2
-rw-r--r--writerfilter/source/dmapper/SettingsTable.cxx11
-rw-r--r--writerfilter/source/dmapper/SettingsTable.hxx1
3 files changed, 14 insertions, 0 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index fa6d76f13627..a5ba85300ea6 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -6640,6 +6640,8 @@ void DomainMapper_Impl::ApplySettingsTable()
xSettings->setPropertyValue("AddParaTableSpacing", uno::makeAny(m_pSettingsTable->GetDoNotUseHTMLParagraphAutoSpacing()));
if( m_pSettingsTable->GetProtectForm() )
xSettings->setPropertyValue("ProtectForm", uno::makeAny( true ));
+ if( m_pSettingsTable->GetReadOnly() )
+ xSettings->setPropertyValue("LoadReadonly", uno::makeAny( true ));
}
catch(const uno::Exception&)
{
diff --git a/writerfilter/source/dmapper/SettingsTable.cxx b/writerfilter/source/dmapper/SettingsTable.cxx
index aed966abbecf..303de47c8f71 100644
--- a/writerfilter/source/dmapper/SettingsTable.cxx
+++ b/writerfilter/source/dmapper/SettingsTable.cxx
@@ -261,6 +261,7 @@ struct SettingsTable_Impl
bool m_bProtectForm;
bool m_bRedlineProtection;
OUString m_sRedlineProtectionKey;
+ bool m_bReadOnly;
bool m_bDisplayBackgroundShape;
uno::Sequence<beans::PropertyValue> m_pThemeFontLangProps;
@@ -298,6 +299,7 @@ struct SettingsTable_Impl
, m_bProtectForm(false)
, m_bRedlineProtection(false)
, m_sRedlineProtectionKey()
+ , m_bReadOnly(false)
, m_bDisplayBackgroundShape(false)
, m_pThemeFontLangProps(3)
, m_pCurrentCompatSetting(3)
@@ -368,6 +370,7 @@ void SettingsTable::lcl_attribute(Id nName, Value & val)
// multiple DocProtect_edits should not exist. If they do, last one wins
m_pImpl->m_bRedlineProtection = false;
m_pImpl->m_bProtectForm = false;
+ m_pImpl->m_bReadOnly = false;
switch (nIntValue)
{
case NS_ooxml::LN_Value_doc_ST_DocProtect_trackedChanges:
@@ -379,6 +382,9 @@ void SettingsTable::lcl_attribute(Id nName, Value & val)
case NS_ooxml::LN_Value_doc_ST_DocProtect_forms:
m_pImpl->m_bProtectForm = true;
break;
+ case NS_ooxml::LN_Value_doc_ST_DocProtect_readOnly:
+ m_pImpl->m_bReadOnly = true;
+ break;
}
break;
case NS_ooxml::LN_CT_DocProtect_enforcement: // 92039
@@ -661,6 +667,11 @@ bool SettingsTable::GetProtectForm() const
return m_pImpl->m_bProtectForm && m_pImpl->m_DocumentProtection.m_bEnforcement;
}
+bool SettingsTable::GetReadOnly() const
+{
+ return m_pImpl->m_bReadOnly && m_pImpl->m_DocumentProtection.m_bEnforcement;
+}
+
bool SettingsTable::GetNoHyphenateCaps() const
{
return m_pImpl->m_bNoHyphenateCaps;
diff --git a/writerfilter/source/dmapper/SettingsTable.hxx b/writerfilter/source/dmapper/SettingsTable.hxx
index 3489cf0ac34b..e8cbe8abaf6e 100644
--- a/writerfilter/source/dmapper/SettingsTable.hxx
+++ b/writerfilter/source/dmapper/SettingsTable.hxx
@@ -75,6 +75,7 @@ class SettingsTable : public LoggedProperties, public LoggedTable
bool GetDoNotExpandShiftReturn() const;
bool GetNoColumnBalance() const;
bool GetProtectForm() const;
+ bool GetReadOnly() const;
bool GetLongerSpaceSequence() const;
bool GetNoHyphenateCaps() const;
sal_Int16 GetHypenationZone() const;