summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorJan-Marek Glogowski <jan-marek.glogowski@extern.cib.de>2019-07-19 15:28:45 +0200
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2019-10-01 17:13:25 +0200
commit9850e0b0d725de00fde34f4bbcffc8fd65b81331 (patch)
treea519f3bf46a1d5b0c4e3882cee61068ea63e1f44 /sfx2
parent3ab5486449d1f3ca0247a9c133da746401c57e28 (diff)
tdf#42316 preserve macro signature of templates
When comparing the filter of the current and the target document we have to strip the '_template' from the filter name. Still this won't preserve the signature of the document attached to tdf#42316, as this is a ODF 1.0 OTT, which doesn't have a valid signature in ODF 1.2, as the signature doesn't match the ODF 1.2 namespace for signatures and the default LO ODF version is ODF 1.2 extended. In theory the signature itself could even be converted most times, but that can be done in an additional patch, if needed. Since the code literally saves a template to an internal document, SfxObjectShell::DoSaveCompleted must keep the signature of the template. Eventually it'll be dropped on save of the template as a document later. The signing tests check "OTT 1.0 => ODT 1.0: preserve", "OTT 1.2 => ODT 1.2: preserve" and "OTT 1.0 => ODT 1.2: drop". Reviewed-on: https://gerrit.libreoffice.org/75958 Tested-by: Jenkins Reviewed-by: Michael Stahl <Michael.Stahl@cib.de> Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de> (cherry picked from commit c3a1c83ff5af05d34f433ac808adbe85f47e8c18) Reviewed-on: https://gerrit.libreoffice.org/77112 Conflicts: xmlsecurity/qa/unit/signing/signing.cxx Change-Id: I2263093687f5a0568ea781ce3ac9b114c9599add Reviewed-on: https://gerrit.libreoffice.org/79371 Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de> Tested-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/doc/objstor.cxx30
1 files changed, 23 insertions, 7 deletions
diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx
index 716455cda9ae..fa08ceb42a4a 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -1160,10 +1160,18 @@ bool SfxObjectShell::SaveTo_Impl
{}
// preserve only if the same filter has been used
- bTryToPreserveScriptSignature = pMedium->GetFilter() && pFilter && pMedium->GetFilter()->GetFilterName() == pFilter->GetFilterName();
-
+ // for templates, strip the _template from the filter name for comparison
+ OUString aMediumFilter = pMedium->GetFilter()->GetFilterName();
+ if (aMediumFilter.endsWith("_template"))
+ aMediumFilter = aMediumFilter.copy(0, aMediumFilter.getLength() - 9);
+ bTryToPreserveScriptSignature = pMedium->GetFilter() && pFilter && aMediumFilter == pFilter->GetFilterName();
+
+ // signatures were specified in ODF 1.2 but were used since much longer.
+ // LO will still correctly validate an old style signature on an ODF 1.2
+ // document, but technically this is not correct, so this prevents old
+ // signatures to be copied over to a version 1.2 document
bNoPreserveForOasis = (
- (aODFVersion == ODFVER_012_TEXT && nVersion == SvtSaveOptions::ODFVER_011) ||
+ (aODFVersion == ODFVER_012_TEXT && nVersion < SvtSaveOptions::ODFVER_012) ||
(aODFVersion.isEmpty() && nVersion >= SvtSaveOptions::ODFVER_012)
);
}
@@ -2026,13 +2034,21 @@ bool SfxObjectShell::DoSaveCompleted( SfxMedium* pNewMed, bool bRegisterRecent )
{}
}
+ const SfxBoolItem* pTemplateItem = SfxItemSet::GetItem<SfxBoolItem>(pMedium->GetItemSet(), SID_TEMPLATE, false);
+ bool bTemplate = pTemplateItem && pTemplateItem->GetValue();
+
// before the title regenerated the document must lose the signatures
pImpl->nDocumentSignatureState = SignatureState::NOSIGNATURES;
- pImpl->nScriptingSignatureState = pNewMed->GetCachedSignatureState_Impl();
- OSL_ENSURE( pImpl->nScriptingSignatureState != SignatureState::BROKEN, "The signature must not be broken at this place" );
+ if (!bTemplate)
+ {
+ pImpl->nScriptingSignatureState = pNewMed->GetCachedSignatureState_Impl();
+ OSL_ENSURE( pImpl->nScriptingSignatureState != SignatureState::BROKEN, "The signature must not be broken at this place" );
- // TODO/LATER: in future the medium must control own signature state, not the document
- pNewMed->SetCachedSignatureState_Impl( SignatureState::NOSIGNATURES ); // set the default value back
+ // TODO/LATER: in future the medium must control own signature state, not the document
+ pNewMed->SetCachedSignatureState_Impl( SignatureState::NOSIGNATURES ); // set the default value back
+ }
+ else
+ pNewMed->SetCachedSignatureState_Impl( pImpl->nScriptingSignatureState );
// Set new title
if (!pNewMed->GetName().isEmpty() && SfxObjectCreateMode::EMBEDDED != eCreateMode)