diff options
author | Oliver Specht <oliver.specht@cib.de> | 2016-04-25 13:25:39 +0200 |
---|---|---|
committer | Oliver Specht <oliver.specht@cib.de> | 2016-04-29 06:12:55 +0000 |
commit | 523a3d18e98cd51aa8bf76cf76314a22ddc2b2cf (patch) | |
tree | 287df68a893b7f657cec9bee1147906a5c2b880b /sw | |
parent | 16777b6bb0267c2b0602f1007a1e1fecac81329b (diff) |
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@libreoffice.org>
Reviewed-by: Oliver Specht <oliver.specht@cib.de>
Diffstat (limited to 'sw')
-rwxr-xr-x | sw/qa/extras/ooxmlexport/data/protectedform.docx | bin | 0 -> 18511 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 10 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxexport.cxx | 6 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtw8sty.cxx | 5 |
4 files changed, 20 insertions, 1 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/protectedform.docx b/sw/qa/extras/ooxmlexport/data/protectedform.docx Binary files differnew file mode 100755 index 000000000000..a67d88006c6f --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/protectedform.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index f4174d61d09d..fcfcfbdf7548 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 b23506ec4a1c..6ae3f99bcef3 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 19abee180f3a..632ed2e71f53 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(); |