summaryrefslogtreecommitdiff
path: root/xmloff/source/meta
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2018-03-12 20:03:34 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2018-03-14 08:59:38 +0100
commit0d6ffe118fd1d03e22fcda2f06d49b4c932d2018 (patch)
tree06ae21314dad378580a37e646f791ea895a7ef74 /xmloff/source/meta
parent80f9383f1adf3a42c22765c7c8bee8e705e39d0b (diff)
xmloff: ODF import: improve meta:generator checks
Instead of a hard-coded check for (effectively) one project name "LibreOffice" (which is build-time configurable), check for the string "LibreOffice_project", which has been produced hard-coded ever since LO 3.3.0. This now recognises additional downstreams "LibreOffice_Vanilla" and "Collabora_Office", and also historic "BrOffice". An important point here is that the build-time configurable version numbers of any downstream that retains the hard-coded "LibreOffice_project" *MUST* be the same as the upstream's at least in their major and minor versions (micro and further digits are currently not used), and that such downstreams don't backport changes with ODF export compatibility impact further than upstream. Add a unit test too, with a representative sample of 4372 distinct generators in bugzilla attachments. This revealed that StarOffice 6 and AOO 4.0.1 were falling through the cracks and not recognised, so fix that too. Change-Id: I8105222d3428e7b20cc4a6b8e76732c697812594 Reviewed-on: https://gerrit.libreoffice.org/51171 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'xmloff/source/meta')
-rw-r--r--xmloff/source/meta/xmlmetai.cxx19
1 files changed, 11 insertions, 8 deletions
diff --git a/xmloff/source/meta/xmlmetai.cxx b/xmloff/source/meta/xmlmetai.cxx
index ba733bd73a20..1f9a1b9604e2 100644
--- a/xmloff/source/meta/xmlmetai.cxx
+++ b/xmloff/source/meta/xmlmetai.cxx
@@ -256,6 +256,8 @@ void SvXMLMetaDocumentContext::setBuildId(OUString const& i_rBuildId, const uno:
{
if ( i_rBuildId.startsWith("StarOffice 7")
|| i_rBuildId.startsWith("StarSuite 7")
+ || i_rBuildId.startsWith("StarOffice 6")
+ || i_rBuildId.startsWith("StarSuite 6")
|| i_rBuildId.startsWith("OpenOffice.org 1"))
{
sBuildId = "645$8687";
@@ -266,19 +268,20 @@ void SvXMLMetaDocumentContext::setBuildId(OUString const& i_rBuildId, const uno:
}
}
- OUString rest;
- if (i_rBuildId.startsWith("LibreOffice/", &rest) ||
- i_rBuildId.startsWith("LibreOfficeDev/", &rest) ||
- i_rBuildId.startsWith("LOdev/", &rest))
+ // "LibreOffice_project" was hard-coded since LO 3.3.0
+ // see utl::DocInfoHelper::GetGeneratorString()
+ if (i_rBuildId.indexOf("LibreOffice_project/") != -1)
{
OUStringBuffer sNumber;
- for (sal_Int32 i = 0; i < rest.getLength(); ++i)
+ auto const firstSlash = i_rBuildId.indexOf("/");
+ assert(firstSlash != -1);
+ for (sal_Int32 i = firstSlash + 1; i < i_rBuildId.getLength(); ++i)
{
- if (rtl::isAsciiDigit(rest[i]))
+ if (rtl::isAsciiDigit(i_rBuildId[i]))
{
- sNumber.append(rest[i]);
+ sNumber.append(i_rBuildId[i]);
}
- else if ('.' != rest[i])
+ else if ('.' != i_rBuildId[i])
{
break;
}