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-08-06 20:55:36 +0200
commitc3a1c83ff5af05d34f433ac808adbe85f47e8c18 (patch)
tree147639f49bbc1f919d67d5827a4b1b1b2028574b /sfx2
parentc4d82fc21c5e155472f6a30244b3fce806ada85c (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". Change-Id: I2263093687f5a0568ea781ce3ac9b114c9599add 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>
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 9375989e35e3..f3ef1c2992a3 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -1167,10 +1167,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)
);
}
@@ -2017,13 +2025,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)