diff options
Diffstat (limited to 'sfx2/source/doc/objstor.cxx')
-rw-r--r-- | sfx2/source/doc/objstor.cxx | 30 |
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) |