summaryrefslogtreecommitdiff
path: root/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2020-05-08 23:25:17 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2020-05-11 00:12:33 +0200
commit5952331844450dad93e21d2e329d51841ae1700e (patch)
treeee95ae8c96b27928ba6ae30620e9e524c1982d3e /sw/qa/extras/ooxmlexport/ooxmlexport7.cxx
parentce0933c0d8cc0d51774d0168a8be4e9bb3153463 (diff)
tdf#49247: implement soft edges document model and import/export
... for ODF and OOXML. Two object properties added: SoftEdge (boolean, effect enabled/disabled) SoftEdgeRad (sal_Int32, effect radius in 100ths of mm) Two corresponding ODF attributes added: loext:softedge ("visible"/"hidden") loext:softedge-radius (metric) Change-Id: I0dc4d7fc3e5b0c2c36092d430568ebcfd3a68c9c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93833 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sw/qa/extras/ooxmlexport/ooxmlexport7.cxx')
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport7.cxx35
1 files changed, 24 insertions, 11 deletions
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx
index 32dfd9b1c925..572f19026653 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx
@@ -32,6 +32,18 @@ protected:
// If the testcase is stored in some other format, it's pointless to test.
return OString(filename).endsWith(".docx");
}
+
+ // We import OOXML's EMUs into integral mm100 internal representation, then export back into
+ // EMUs. This results in inaccuracies.
+ void assertXPathHasApproxEMU(const xmlDocUniquePtr& pXmlDoc, const OString& rXPath,
+ const OString& rAttribute, sal_Int64 nAttributeVal)
+ {
+ OUString val = getXPath(pXmlDoc, rXPath, rAttribute);
+ // Use precision of 1/2 of 100th of mm, which is 180 EMU
+ CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE(
+ OString("XPath: " + rXPath + "\nAttribute: " + rAttribute).getStr(), nAttributeVal,
+ val.toInt64(), 180);
+ }
};
DECLARE_OOXMLEXPORT_EXPORTONLY_TEST( testChildNodesOfCubicBezierTo, "FDO74774.docx")
@@ -216,9 +228,11 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testShapeEffectPreservation, "shape-effect-p
"val", "50000");
// 4th shape with soft edge
- assertXPath(pXmlDoc, "/w:document/w:body/w:p[5]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
- "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:softEdge",
- "rad", "127000");
+ assertXPathHasApproxEMU(
+ pXmlDoc,
+ "/w:document/w:body/w:p[5]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
+ "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:softEdge",
+ "rad", 127000); // actually, it returns 127080
assertXPath(pXmlDoc, "/w:document/w:body/w:p[5]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
"wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:softEdge/*",
0 ); // should not be present
@@ -246,13 +260,10 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testShapeEffectPreservation, "shape-effect-p
0 ); // should not be present
// 7th shape with several effects: glow, inner shadow and reflection
- // We import glow radius (in EMU in OOXML) into integral mm100 internal representation, then
- // export back into EMUs. This results in inaccuracies.
- OUString rad = getXPath(pXmlDoc,
+ assertXPathHasApproxEMU(pXmlDoc,
"/w:document/w:body/w:p[8]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
"wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:glow",
- "rad");
- CPPUNIT_ASSERT_DOUBLES_EQUAL(63500, rad.toInt64(), 150); // actually, it returns 63360
+ "rad", 63500); // actually, it returns 63360
assertXPath(pXmlDoc, "/w:document/w:body/w:p[8]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
"wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:glow/a:srgbClr",
"val", "eb2722");
@@ -433,9 +444,11 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testPictureEffectPreservation, "picture-effe
0 ); // should not be present
// third picture: soft edge effect
- assertXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
- "wp:anchor/a:graphic/a:graphicData/pic:pic/pic:spPr/a:effectLst/a:softEdge",
- "rad", "63500");
+ assertXPathHasApproxEMU(
+ pXmlDoc,
+ "/w:document/w:body/w:p[3]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
+ "wp:anchor/a:graphic/a:graphicData/pic:pic/pic:spPr/a:effectLst/a:softEdge",
+ "rad", 63500); // actually, it returns 63360
}
DECLARE_OOXMLEXPORT_TEST(testPictureArtisticEffectPreservation, "picture-artistic-effects-preservation.docx")