oox: use a faster color hexification method with hex-in-uppercase.
This reduces the xml diff to MS' generation. Change-Id: I10a3f1db3347d1fb06c0d823e4b5e50104318c91 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191940 Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com> Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Tested-by: Caolán McNamara <caolan.mcnamara@collabora.com> (cherry picked from commit 6219a5d42133048a7e384539f9454e222f96936f) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191944 Tested-by: Jenkins Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
This commit is contained in:
@@ -23,17 +23,29 @@
|
||||
#include <sal/config.h>
|
||||
|
||||
#include <o3tl/unit_conversion.hxx>
|
||||
#include <rtl/strbuf.hxx>
|
||||
#include <rtl/string.hxx>
|
||||
#include <sal/types.h>
|
||||
|
||||
#include <cmath>
|
||||
|
||||
// Only used to output rgb colors as hex
|
||||
inline OString I32SHEX(sal_Int32 x)
|
||||
{
|
||||
OString aStr = OString::number(x, 16);
|
||||
while (aStr.getLength() < 6)
|
||||
aStr = "0" + aStr;
|
||||
return aStr;
|
||||
assert(x <= 0xffffff);
|
||||
rtl::OStringBuffer aRes(6);
|
||||
aRes.setLength(6);
|
||||
sal_Int32 n = 0;
|
||||
for (int nShift = 24-4; nShift >=0; nShift -= 4)
|
||||
{
|
||||
char nDigit = static_cast<char>((x >> nShift) & 0xf);
|
||||
if ( nDigit > 9 )
|
||||
aRes[n] = (nDigit-10) + 'A';
|
||||
else
|
||||
aRes[n] = (nDigit + '0');
|
||||
n++;
|
||||
}
|
||||
return aRes.makeStringAndClear();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -121,17 +121,17 @@ CPPUNIT_TEST_FIXTURE(ThemeImportExportTest, testThemeExportOOXML)
|
||||
OString aClrScheme = "/a:theme/a:themeElements/a:clrScheme"_ostr;
|
||||
assertXPath(pXmlDoc, aClrScheme, "name", u"Office");
|
||||
assertXPath(pXmlDoc, aClrScheme + "/a:dk1/a:srgbClr", "val", u"000000");
|
||||
assertXPath(pXmlDoc, aClrScheme + "/a:lt1/a:srgbClr", "val", u"ffffff");
|
||||
assertXPath(pXmlDoc, aClrScheme + "/a:dk2/a:srgbClr", "val", u"44546a");
|
||||
assertXPath(pXmlDoc, aClrScheme + "/a:lt2/a:srgbClr", "val", u"e7e6e6");
|
||||
assertXPath(pXmlDoc, aClrScheme + "/a:accent1/a:srgbClr", "val", u"4472c4");
|
||||
assertXPath(pXmlDoc, aClrScheme + "/a:accent2/a:srgbClr", "val", u"ed7d31");
|
||||
assertXPath(pXmlDoc, aClrScheme + "/a:accent3/a:srgbClr", "val", u"a5a5a5");
|
||||
assertXPath(pXmlDoc, aClrScheme + "/a:accent4/a:srgbClr", "val", u"ffc000");
|
||||
assertXPath(pXmlDoc, aClrScheme + "/a:accent5/a:srgbClr", "val", u"5b9bd5");
|
||||
assertXPath(pXmlDoc, aClrScheme + "/a:accent6/a:srgbClr", "val", u"70ad47");
|
||||
assertXPath(pXmlDoc, aClrScheme + "/a:hlink/a:srgbClr", "val", u"0563c1");
|
||||
assertXPath(pXmlDoc, aClrScheme + "/a:folHlink/a:srgbClr", "val", u"954f72");
|
||||
assertXPath(pXmlDoc, aClrScheme + "/a:lt1/a:srgbClr", "val", u"FFFFFF");
|
||||
assertXPath(pXmlDoc, aClrScheme + "/a:dk2/a:srgbClr", "val", u"44546A");
|
||||
assertXPath(pXmlDoc, aClrScheme + "/a:lt2/a:srgbClr", "val", u"E7E6E6");
|
||||
assertXPath(pXmlDoc, aClrScheme + "/a:accent1/a:srgbClr", "val", u"4472C4");
|
||||
assertXPath(pXmlDoc, aClrScheme + "/a:accent2/a:srgbClr", "val", u"ED7D31");
|
||||
assertXPath(pXmlDoc, aClrScheme + "/a:accent3/a:srgbClr", "val", u"A5A5A5");
|
||||
assertXPath(pXmlDoc, aClrScheme + "/a:accent4/a:srgbClr", "val", u"FFC000");
|
||||
assertXPath(pXmlDoc, aClrScheme + "/a:accent5/a:srgbClr", "val", u"5B9BD5");
|
||||
assertXPath(pXmlDoc, aClrScheme + "/a:accent6/a:srgbClr", "val", u"70AD47");
|
||||
assertXPath(pXmlDoc, aClrScheme + "/a:hlink/a:srgbClr", "val", u"0563C1");
|
||||
assertXPath(pXmlDoc, aClrScheme + "/a:folHlink/a:srgbClr", "val", u"954F72");
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
@@ -1381,7 +1381,7 @@ CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest2, testTdf112333)
|
||||
"p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/"
|
||||
"p:animClr/p:to/a:srgbClr",
|
||||
"val");
|
||||
CPPUNIT_ASSERT_EQUAL(u"0563c1"_ustr, sTo);
|
||||
CPPUNIT_ASSERT_EQUAL(u"0563C1"_ustr, sTo);
|
||||
|
||||
sAttributeName = getXPathContent(
|
||||
pXmlDocContent, "/p:sld/p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/"
|
||||
@@ -1694,10 +1694,10 @@ CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest2, testAccentColor)
|
||||
u"accent6");
|
||||
xmlDocUniquePtr pXmlDocTheme1 = parseExport(u"ppt/theme/theme1.xml"_ustr);
|
||||
assertXPath(pXmlDocTheme1, "/a:theme/a:themeElements/a:clrScheme/a:accent6/a:srgbClr", "val",
|
||||
u"70ad47");
|
||||
u"70AD47");
|
||||
xmlDocUniquePtr pXmlDocTheme2 = parseExport(u"ppt/theme/theme2.xml"_ustr);
|
||||
assertXPath(pXmlDocTheme2, "/a:theme/a:themeElements/a:clrScheme/a:accent6/a:srgbClr", "val",
|
||||
u"deb340");
|
||||
u"DEB340");
|
||||
|
||||
// Without the accompanying fix in place, this test would have failed with:
|
||||
// - Expected: Motyw pakietu Office
|
||||
@@ -1714,9 +1714,9 @@ CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest2, testThemeColors)
|
||||
|
||||
xmlDocUniquePtr pXmlDocTheme2 = parseExport(u"ppt/theme/theme1.xml"_ustr);
|
||||
assertXPath(pXmlDocTheme2, "/a:theme/a:themeElements/a:clrScheme/a:dk2/a:srgbClr", "val",
|
||||
u"44546a");
|
||||
u"44546A");
|
||||
assertXPath(pXmlDocTheme2, "/a:theme/a:themeElements/a:clrScheme/a:accent3/a:srgbClr", "val",
|
||||
u"a5a5a5");
|
||||
u"A5A5A5");
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest2, testTdf111785)
|
||||
|
||||
@@ -134,7 +134,7 @@ CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testTdf114848)
|
||||
|
||||
xmlDocUniquePtr pXmlDocTheme1 = parseExport(u"ppt/theme/theme1.xml"_ustr);
|
||||
assertXPath(pXmlDocTheme1, "/a:theme/a:themeElements/a:clrScheme/a:dk2/a:srgbClr", "val",
|
||||
u"1f497d");
|
||||
u"1F497D");
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testTdf147586)
|
||||
@@ -755,7 +755,7 @@ CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testTdf118835)
|
||||
xmlDocUniquePtr pXmlDocContent = parseExport(u"ppt/slides/slide1.xml"_ustr);
|
||||
assertXPath(pXmlDocContent, "(//p:animClr)[1]", "clrSpc", u"rgb");
|
||||
assertXPathContent(pXmlDocContent, "(//p:animClr)[1]//p:attrName", u"style.color");
|
||||
assertXPath(pXmlDocContent, "(//p:animClr)[1]//p:to/a:srgbClr", "val", u"ed1c24");
|
||||
assertXPath(pXmlDocContent, "(//p:animClr)[1]//p:to/a:srgbClr", "val", u"ED1C24");
|
||||
|
||||
assertXPath(pXmlDocContent, "(//p:animClr)[2]", "clrSpc", u"rgb");
|
||||
assertXPathContent(pXmlDocContent, "(//p:animClr)[2]//p:attrName", u"stroke.color");
|
||||
@@ -763,7 +763,7 @@ CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testTdf118835)
|
||||
|
||||
assertXPath(pXmlDocContent, "(//p:animClr)[3]", "clrSpc", u"rgb");
|
||||
assertXPathContent(pXmlDocContent, "(//p:animClr)[3]//p:attrName", u"fillcolor");
|
||||
assertXPath(pXmlDocContent, "(//p:animClr)[3]//p:to/a:srgbClr", "val", u"fcd3c1");
|
||||
assertXPath(pXmlDocContent, "(//p:animClr)[3]//p:to/a:srgbClr", "val", u"FCD3C1");
|
||||
|
||||
assertXPath(pXmlDocContent, "(//p:animClr)[5]", "clrSpc", u"hsl");
|
||||
assertXPathContent(pXmlDocContent, "(//p:animClr)[5]//p:attrName", u"fillcolor");
|
||||
|
||||
Reference in New Issue
Block a user