summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRegina Henschel <rb.henschel@t-online.de>2023-05-31 15:16:25 +0200
committerRegina Henschel <rb.henschel@t-online.de>2023-06-01 11:59:32 +0200
commit28f0e847e4e9cebc43cdcf97b8212a70977f2b49 (patch)
treef9dbcd66066bd59c18cf22f729bd159cd4cf9983
parent5e68d6cfade45f40b1ad46025a81afe4cb8dd337 (diff)
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.henschel@t-online.de>
-rw-r--r--xmloff/qa/unit/data/MCGR_Border_restoration.pptxbin0 -> 26853 bytes
-rw-r--r--xmloff/qa/unit/style.cxx39
2 files changed, 39 insertions, 0 deletions
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
--- /dev/null
+++ b/xmloff/qa/unit/data/MCGR_Border_restoration.pptx
Binary files 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: */