Kaydet (Commit) 0ed56b6a authored tarafından Justin Luth's avatar Justin Luth Kaydeden (comit) Miklos Vajna

ww8export roundtrip forms password

This was already done for docx in LO6.0 with
commit 26941629

Patch initially developed to support tdf#120499 and depnds
on commit 953dad97c7ef7881c2ac6d73fe5266b44b15f3e2

Change-Id: I04b0693ed1e90f70b079040030c5bd9d2ccfbf13
Reviewed-on: https://gerrit.libreoffice.org/61952Tested-by: 's avatarJustin Luth <justin_luth@sil.org>
Reviewed-by: 's avatarJustin Luth <justin_luth@sil.org>
üst 3516e1b2
...@@ -364,6 +364,15 @@ DECLARE_WW8EXPORT_TEST(testCp1000044, "cp1000044.doc") ...@@ -364,6 +364,15 @@ DECLARE_WW8EXPORT_TEST(testCp1000044, "cp1000044.doc")
CPPUNIT_ASSERT(pTextDoc); CPPUNIT_ASSERT(pTextDoc);
SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc(); SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc();
CPPUNIT_ASSERT_EQUAL( true, pDoc->getIDocumentSettingAccess().get( DocumentSettingId::PROTECT_FORM ) ); 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") DECLARE_WW8EXPORT_TEST(testBorderColours, "bordercolours.doc")
......
...@@ -510,6 +510,21 @@ static void WriteDop( WW8Export& rWrt ) ...@@ -510,6 +510,21 @@ static void WriteDop( WW8Export& rWrt )
rDop.lKeyProtDoc != 0) rDop.lKeyProtDoc != 0)
{ {
rDop.fProtEnabled = true; 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 else
{ {
......
...@@ -1919,6 +1919,12 @@ void SwWW8ImplReader::ImportDop() ...@@ -1919,6 +1919,12 @@ void SwWW8ImplReader::ImportDop()
// Still allow editing of form fields. // Still allow editing of form fields.
if (!m_xWDop->fProtEnabled) if (!m_xWDop->fProtEnabled)
m_pDocShell->SetModifyPasswordHash(m_xWDop->lKeyProtDoc); 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(); const SvtFilterOptions& rOpt = SvtFilterOptions::Get();
if (rOpt.IsUseEnhancedFields()) if (rOpt.IsUseEnhancedFields())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment