summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorJan-Marek Glogowski <jan-marek.glogowski@extern.cib.de>2019-10-11 13:09:59 +0200
committerVasily Melenchuk <vasily.melenchuk@cib.de>2021-04-15 12:19:16 +0300
commitfbde1006a233422f9ab66b5f2a8354957d50392e (patch)
treef33659b3406d6a846a80d5c1c6fcfa49e0138652 /sfx2
parentd5195a73629eff2035152eea7e5c936f3f4baaa9 (diff)
tdf#42316 handle saving to template filters
This extends the filter comparison from commit c3a1c83ff5af ("tdf#42316 preserve macro signature of templates"). The original patch just stripped "_template" from the source filter to find equal document types, which just enables the "template => document" case. This patch also strips the "_template" from the target filter, which fixes the "document or template => template" cases. This also extends the signing save tests: * OTT 1.2 => OTT 1.2 - preserve * ODT 1.2 => OTT 1.2 - preserve * OTT 1.0 => OTT 1.0 - preserve * ODT 1.0 => OTT 1.0 - preserve * OTT 1.0 => OTT 1.2 - drop Reviewed-on: https://gerrit.libreoffice.org/80654 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> (cherry picked from commit 4aa6e2cb2245eddab87fb451add94159a7604246) Reviewed-on: https://gerrit.libreoffice.org/80910 Reviewed-by: Michael Stahl <michael.stahl@cib.de> (cherry picked from commit 7b405877b0fa0145513ac0294ab51cf57e6108c6) Change-Id: Ie297258a4d9f9aa4beb25786c6ba240b6f16f49b Reviewed-on: https://gerrit.libreoffice.org/81885 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.cxx15
1 files changed, 11 insertions, 4 deletions
diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx
index 2b601bbf0e6d..2b3c9288c5e6 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -1076,6 +1076,15 @@ private:
};
}
+static OUString lcl_strip_template(const OUString &aString)
+{
+ static const OUString sPostfix("_template");
+ OUString sRes(aString);
+ if (sRes.endsWith(sPostfix))
+ sRes = sRes.copy(0, sRes.getLength() - sPostfix.getLength());
+ return sRes;
+}
+
bool SfxObjectShell::SaveTo_Impl
(
SfxMedium &rMedium, // Medium, in which it will be stored
@@ -1155,10 +1164,8 @@ bool SfxObjectShell::SaveTo_Impl
// preserve only if the same filter has been used
// 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();
+ const OUString aMediumFilter = lcl_strip_template(pMedium->GetFilter()->GetFilterName());
+ bTryToPreserveScriptSignature = pMedium->GetFilter() && pFilter && aMediumFilter == lcl_strip_template(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