xmloff/qa/unit/data/MCGR_Border_restoration.pptx |binary xmloff/qa/unit/style.cxx | 39 +++++++++++++++++++++++ 2 files changed, 39 insertions(+)
New commits: commit 28f0e847e4e9cebc43cdcf97b8212a70977f2b49 Author: Regina Henschel <rb.hensc...@t-online.de> AuthorDate: Wed May 31 15:16:25 2023 +0200 Commit: Regina Henschel <rb.hensc...@t-online.de> CommitDate: Thu Jun 1 11:59:32 2023 +0200 MCGR: Unit test for 'Use tryToRecreateBorder for...' Unit test for commit 8259a99f41367a1d8326c9157fe1902915715879. Change-Id: Iba3367fe42b5014b98cf575f53006fc09a79d6ee Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152428 Tested-by: Jenkins Reviewed-by: Regina Henschel <rb.hensc...@t-online.de> diff --git a/xmloff/qa/unit/data/MCGR_Border_restoration.pptx b/xmloff/qa/unit/data/MCGR_Border_restoration.pptx new file mode 100644 index 000000000000..b43e15145f89 Binary files /dev/null and b/xmloff/qa/unit/data/MCGR_Border_restoration.pptx differ diff --git a/xmloff/qa/unit/style.cxx b/xmloff/qa/unit/style.cxx index 8d0a19d26624..f4b7f8f08012 100644 --- a/xmloff/qa/unit/style.cxx +++ b/xmloff/qa/unit/style.cxx @@ -22,6 +22,7 @@ #include <officecfg/Office/Common.hxx> #include <rtl/character.hxx> +#include <unotools/saveopt.hxx> using namespace ::com::sun::star; @@ -514,6 +515,44 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testMCGR_threeStops) CPPUNIT_ASSERT_EQUAL(0.0, aColorStop.StopColor.Blue); } +CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testBorderRestoration) +{ + // Load document. It has a shape with color gradient build from color stop yellow at offset 0.5 + // and color stop red at offset 1.0. For better backward compatibility such gradient has to be + // exported to ODF with a border of 50%. + // When gradient-stops are integrated in ODF strict, the test needs to be adapted. + + loadFromURL(u"MCGR_Border_restoration.pptx"); + + // Backup original ODF default version + const SvtSaveOptions::ODFDefaultVersion nCurrentODFVersion(GetODFDefaultVersion()); + + // Save to ODF_LATEST which is currently ODF 1.3 extended. Make sure gradient-stop elements have + // offsets 0 and 1, and border is written as 50%. + SetODFDefaultVersion(SvtSaveOptions::ODFDefaultVersion::ODFVER_LATEST); + save("impress8"); + xmlDocUniquePtr pXmlDoc = parseExport("styles.xml"); + OString sPath + = "/office:document-styles/office:styles/draw:gradient[@draw:name='Gradient_20_1']"; + assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[2]", "color-value", "#ff0000"); + assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[2]", "offset", "1"); + assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[1]", "color-value", "#ffff00"); + assertXPath(pXmlDoc, sPath + "/loext:gradient-stop[1]", "offset", "0"); + assertXPath(pXmlDoc, sPath, "border", "50%"); + + // Save to ODF 1.3 strict and make sure border, start-color and end-color are suitable set. + SetODFDefaultVersion(SvtSaveOptions::ODFDefaultVersion::ODFVER_013); + save("impress8"); + pXmlDoc = parseExport("styles.xml"); + assertXPath(pXmlDoc, sPath + "/loext:gradient-stop", 0); + assertXPath(pXmlDoc, sPath, "start-color", "#ffff00"); + assertXPath(pXmlDoc, sPath, "end-color", "#ff0000"); + assertXPath(pXmlDoc, sPath, "border", "50%"); + + // Set back to original ODF default version. + SetODFDefaultVersion(nCurrentODFVersion); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */