Kaydet (Commit) 0d6ffe11 authored tarafından Michael Stahl's avatar Michael Stahl Kaydeden (comit) Miklos Vajna

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/51171Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
üst 80f9383f
This diff is collapsed.
......@@ -229,7 +229,7 @@ public:
{
mnGeneratorVersion = SvXMLImport::OOo_34x;
}
else if (nUPD == 400)
else if (nUPD == 400 || nUPD == 401)
{
mnGeneratorVersion = SvXMLImport::AOO_40x;
}
......
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment