[Libreoffice-commits] core.git: sw/qa sw/source writerfilter/source
Oliver Specht
oliver.specht at cib.de
Fri Apr 29 06:13:18 UTC 2016
sw/qa/extras/ooxmlexport/data/protectedform.docx |binary
sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 10 ++++++++++
sw/source/filter/ww8/docxexport.cxx | 6 ++++++
sw/source/filter/ww8/wrtw8sty.cxx | 5 ++++-
writerfilter/source/dmapper/DomainMapper_Impl.cxx | 3 ++-
writerfilter/source/dmapper/SettingsTable.cxx | 10 ++++++++++
writerfilter/source/dmapper/SettingsTable.hxx | 1 +
7 files changed, 33 insertions(+), 2 deletions(-)
New commits:
commit 523a3d18e98cd51aa8bf76cf76314a22ddc2b2cf
Author: Oliver Specht <oliver.specht at cib.de>
Date: Mon Apr 25 13:25:39 2016 +0200
tdf#99434: import/export documentProtection-forms from .docx incl. test
the setting <w:documentProtection w:edit="forms"> disables editing of content
outside of form controls.
Change-Id: I0d11373d9010778ed5798598020e453cde06fa0f
Reviewed-on: https://gerrit.libreoffice.org/24365
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Oliver Specht <oliver.specht at cib.de>
diff --git a/sw/qa/extras/ooxmlexport/data/protectedform.docx b/sw/qa/extras/ooxmlexport/data/protectedform.docx
new file mode 100755
index 0000000..a67d880
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/protectedform.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index f4174d61..fcfcfbd 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -793,6 +793,16 @@ DECLARE_OOXMLEXPORT_TEST(testTdf91594, "tdf91594.docx")
CPPUNIT_ASSERT_EQUAL(OUString("Wingdings"), getProperty<OUString>(xRun, "CharFontNameAsian"));
CPPUNIT_ASSERT_EQUAL(OUString("Wingdings"), getProperty<OUString>(xRun, "CharFontNameComplex"));
}
+DECLARE_OOXMLEXPORT_TEST(testTDF99434, "protectedform.docx")
+{
+ css::uno::Reference<css::lang::XMultiServiceFactory> m_xTextFactory(mxComponent, uno::UNO_QUERY);
+ uno::Reference< beans::XPropertySet > xSettings(m_xTextFactory->createInstance("com.sun.star.document.Settings"), uno::UNO_QUERY);
+ uno::Any aProtect = xSettings->getPropertyValue("ProtectForm");
+ bool bProt = false;
+ aProtect >>= bProt;
+ CPPUNIT_ASSERT(bProt);
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx
index b23506e..6ae3f99 100644
--- a/sw/source/filter/ww8/docxexport.cxx
+++ b/sw/source/filter/ww8/docxexport.cxx
@@ -855,6 +855,12 @@ void DocxExport::WriteSettings()
pFS->singleElementNS( XML_w, XML_defaultTabStop, FSNS( XML_w, XML_val ),
OString::number( m_aSettings.defaultTabStop).getStr(), FSEND );
+ // Protect form
+ if( m_pDoc->getIDocumentSettingAccess().get( DocumentSettingId::PROTECT_FORM ))
+ {
+ pFS->singleElementNS( XML_w, XML_documentProtection, FSNS(XML_w, XML_edit), "forms", FSNS(XML_w, XML_enforcement), "1", FSEND );
+ }
+
// Automatic hyphenation: it's a global setting in Word, it's a paragraph setting in Writer.
// Use the setting from the default style.
SwTextFormatColl* pColl = m_pDoc->getIDocumentStylePoolAccess().GetTextCollFromPool(RES_POOLCOLL_STANDARD, /*bRegardLanguage=*/false);
diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx
index 19abee1..632ed2e 100644
--- a/sw/source/filter/ww8/wrtw8sty.cxx
+++ b/sw/source/filter/ww8/wrtw8sty.cxx
@@ -69,6 +69,7 @@
#include "ww8attributeoutput.hxx"
#include "docxattributeoutput.hxx"
#include "rtfattributeoutput.hxx"
+#include <IDocumentSettingAccess.hxx>
#include <unordered_set>
@@ -1527,7 +1528,9 @@ void MSWordExportBase::SectionProperties( const WW8_SepInfo& rSepInfo, WW8_PdAtt
AttrOutput().SectFootnoteEndnotePr();
// forms
- AttrOutput().SectionFormProtection( rSepInfo.IsProtected() );
+ bool formProtection = m_pDoc->getIDocumentSettingAccess().get( DocumentSettingId::PROTECT_FORM );
+ formProtection |= rSepInfo.IsProtected();
+ AttrOutput().SectionFormProtection( formProtection );
// line numbers
const SwLineNumberInfo& rLnNumInfo = m_pDoc->GetLineNumberInfo();
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index e3cadff..59526fd 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -5028,10 +5028,11 @@ void DomainMapper_Impl::ApplySettingsTable()
if( m_pSettingsTable->GetEmbedSystemFonts())
xSettings->setPropertyValue( getPropertyName( PROP_EMBED_SYSTEM_FONTS ), uno::makeAny(true) );
xSettings->setPropertyValue("AddParaTableSpacing", uno::makeAny(m_pSettingsTable->GetDoNotUseHTMLParagraphAutoSpacing()));
-
// Web Layout.
if (m_pSettingsTable->GetView() == NS_ooxml::LN_Value_doc_ST_View_web)
xSettings->setPropertyValue("InBrowseMode", uno::makeAny(true));
+ if( m_pSettingsTable->GetProtectForm() )
+ xSettings->setPropertyValue("ProtectForm", uno::makeAny( true ));
}
catch(const uno::Exception&)
{
diff --git a/writerfilter/source/dmapper/SettingsTable.cxx b/writerfilter/source/dmapper/SettingsTable.cxx
index 7dbda36..a8889e1 100644
--- a/writerfilter/source/dmapper/SettingsTable.cxx
+++ b/writerfilter/source/dmapper/SettingsTable.cxx
@@ -64,6 +64,8 @@ struct SettingsTable_Impl
bool m_bWidowControl;
bool m_bSplitPgBreakAndParaMark;
bool m_bMirrorMargin;
+ bool m_bProtectForm;
+
uno::Sequence<beans::PropertyValue> m_pThemeFontLangProps;
std::vector<beans::PropertyValue> m_aCompatSettings;
@@ -88,6 +90,7 @@ struct SettingsTable_Impl
, m_bWidowControl(false)
, m_bSplitPgBreakAndParaMark(false)
, m_bMirrorMargin(false)
+ , m_bProtectForm(false)
, m_pThemeFontLangProps(3)
, m_pCurrentCompatSetting(3)
{}
@@ -143,6 +146,9 @@ void SettingsTable::lcl_attribute(Id nName, Value & val)
m_pImpl->m_pCurrentCompatSetting[2].Name = "val";
m_pImpl->m_pCurrentCompatSetting[2].Value <<= sStringValue;
break;
+ case NS_ooxml::LN_CT_DocProtect_edit:
+ m_pImpl->m_bProtectForm = val.getInt() == NS_ooxml::LN_Value_doc_ST_DocProtect_forms;
+ break;
default:
{
#ifdef DEBUG_WRITERFILTER
@@ -340,6 +346,10 @@ bool SettingsTable::GetMirrorMarginSettings() const
return m_pImpl->m_bMirrorMargin;
}
+bool SettingsTable::GetProtectForm() const
+{
+ return m_pImpl->m_bProtectForm;
+}
uno::Sequence<beans::PropertyValue> SettingsTable::GetThemeFontLangProperties() const
{
return m_pImpl->m_pThemeFontLangProps;
diff --git a/writerfilter/source/dmapper/SettingsTable.hxx b/writerfilter/source/dmapper/SettingsTable.hxx
index 813f8dd..648bf6d 100644
--- a/writerfilter/source/dmapper/SettingsTable.hxx
+++ b/writerfilter/source/dmapper/SettingsTable.hxx
@@ -71,6 +71,7 @@ class SettingsTable : public LoggedProperties, public LoggedTable
bool GetSplitPgBreakAndParaMark() const;
bool GetMirrorMarginSettings() const;
bool GetNoColumnBalance() const;
+ bool GetProtectForm() const;
css::uno::Sequence<css::beans::PropertyValue> GetThemeFontLangProperties() const;
More information about the Libreoffice-commits
mailing list