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
committerVasily Melenchuk <vasily.melenchuk@cib.de>2021-04-15 12:12:49 +0300
commitd5195a73629eff2035152eea7e5c936f3f4baaa9 (patch)
tree8703db2f7b429519e8d641f77a26aa082e161e1e /sfx2
parentcc4987d3e566db2c4aa0675ae94f6c2f713d8a0a (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 c458028b9671..2b601bbf0e6d 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -1154,10 +1154,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)
);
}
@@ -2016,13 +2024,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)