diff options
author | Justin Luth <justin.luth@collabora.com> | 2018-10-18 21:26:13 +0300 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-10-24 10:37:05 +0200 |
commit | 0ed56b6a335d963f327d60650752c161654bf223 (patch) | |
tree | fb80dee221ab4b7fc2c0f6ebf6f023ae1e5075d6 | |
parent | 3516e1b2468b21fdab3332dfba5048d5fa845b07 (diff) |
ww8export roundtrip forms password
This was already done for docx in LO6.0 with
commit 2694162969cf86ef366d3ce812fccd0630acc800
Patch initially developed to support tdf#120499 and depnds
on commit 953dad97c7ef7881c2ac6d73fe5266b44b15f3e2
Change-Id: I04b0693ed1e90f70b079040030c5bd9d2ccfbf13
Reviewed-on: https://gerrit.libreoffice.org/61952
Tested-by: Justin Luth <justin_luth@sil.org>
Reviewed-by: Justin Luth <justin_luth@sil.org>
-rw-r--r-- | sw/qa/extras/ww8export/ww8export.cxx | 9 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtww8.cxx | 15 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par.cxx | 6 |
3 files changed, 30 insertions, 0 deletions
diff --git a/sw/qa/extras/ww8export/ww8export.cxx b/sw/qa/extras/ww8export/ww8export.cxx index 33951f4f0666..cb73378615e7 100644 --- a/sw/qa/extras/ww8export/ww8export.cxx +++ b/sw/qa/extras/ww8export/ww8export.cxx @@ -364,6 +364,15 @@ DECLARE_WW8EXPORT_TEST(testCp1000044, "cp1000044.doc") CPPUNIT_ASSERT(pTextDoc); SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc(); CPPUNIT_ASSERT_EQUAL( true, pDoc->getIDocumentSettingAccess().get( DocumentSettingId::PROTECT_FORM ) ); + + uno::Sequence<beans::PropertyValue> aGrabBag = getProperty< uno::Sequence<beans::PropertyValue> >(mxComponent, "InteropGrabBag"); + sal_Int32 nPasswordHash = 0; + for ( sal_Int32 i = 0; i < aGrabBag.getLength(); ++i ) + { + if ( aGrabBag[i].Name == "FormPasswordHash" ) + aGrabBag[i].Value >>= nPasswordHash; + } + CPPUNIT_ASSERT_EQUAL_MESSAGE("Password Hash", sal_Int32(609995782), nPasswordHash); } DECLARE_WW8EXPORT_TEST(testBorderColours, "bordercolours.doc") diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx index 5e22e0bb57a3..e72a5da2a952 100644 --- a/sw/source/filter/ww8/wrtww8.cxx +++ b/sw/source/filter/ww8/wrtww8.cxx @@ -510,6 +510,21 @@ static void WriteDop( WW8Export& rWrt ) rDop.lKeyProtDoc != 0) { rDop.fProtEnabled = true; + // The password was ignored at import if forms protection was enabled, + // so round-trip it since protection is still enabled. + if ( rDop.lKeyProtDoc == 0 && xProps.is() ) + { + uno::Sequence< beans::PropertyValue > aGrabBag; + xProps->getPropertyValue("InteropGrabBag") >>= aGrabBag; + for ( sal_Int32 i = 0; i < aGrabBag.getLength(); ++i ) + { + if ( aGrabBag[i].Name == "FormPasswordHash" ) + { + aGrabBag[i].Value >>= rDop.lKeyProtDoc; + break; + } + } + } } else { diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index b7fa6ed3f00a..a6b49ccf2c5a 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -1919,6 +1919,12 @@ void SwWW8ImplReader::ImportDop() // Still allow editing of form fields. if (!m_xWDop->fProtEnabled) m_pDocShell->SetModifyPasswordHash(m_xWDop->lKeyProtDoc); + else if ( xDocProps.is() ) + { + comphelper::SequenceAsHashMap aGrabBag(xDocProps->getPropertyValue("InteropGrabBag")); + aGrabBag["FormPasswordHash"] <<= m_xWDop->lKeyProtDoc; + xDocProps->setPropertyValue("InteropGrabBag", uno::Any(aGrabBag.getAsConstPropertyValueList())); + } const SvtFilterOptions& rOpt = SvtFilterOptions::Get(); if (rOpt.IsUseEnhancedFields()) |