tdf#101181: unit test for glow attributes in ODF
Tests loext:glow,
loext:glow-radius,
loext:glow-color,
loext:glow-transparency
There's original decision to keep EMUs in GlowEffectRad property,
which makes this to be stored as hundreds of cm in ODF. I suppose
we should change this in a follow-up to use mm100s instead.
Change-Id: I47bf6530799ed16a55d58d0be5a8a7c3446d2df9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93633
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
diff --git a/schema/libreoffice/OpenDocument-schema-v1.3+libreoffice.rng b/schema/libreoffice/OpenDocument-schema-v1.3+libreoffice.rng
index a61f6da..5e1a587 100644
--- a/schema/libreoffice/OpenDocument-schema-v1.3+libreoffice.rng
+++ b/schema/libreoffice/OpenDocument-schema-v1.3+libreoffice.rng
@@ -920,6 +920,30 @@ xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.
<rng:ref name="boolean"/>
</rng:attribute>
</rng:optional>
<!-- TODO: no proposal for loext:glow* -->
<rng:optional>
<rng:attribute name="loext:glow">
<rng:choice>
<rng:value>visible</rng:value>
<rng:value>hidden</rng:value>
</rng:choice>
</rng:attribute>
</rng:optional>
<rng:optional>
<rng:attribute name="loext:glow-radius">
<rng:ref name="length"/>
</rng:attribute>
</rng:optional>
<rng:optional>
<rng:attribute name="loext:glow-color">
<rng:ref name="color"/>
</rng:attribute>
</rng:optional>
<rng:optional>
<rng:attribute name="loext:glow-transparency">
<rng:ref name="zeroToHundredPercent"/>
</rng:attribute>
</rng:optional>
</rng:interleave>
</rng:define>
diff --git a/sd/qa/unit/data/odg/glow.odg b/sd/qa/unit/data/odg/glow.odg
new file mode 100644
index 0000000..11d697c
--- /dev/null
+++ b/sd/qa/unit/data/odg/glow.odg
Binary files differ
diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx
index 285294b..de09259 100644
--- a/sd/qa/unit/export-tests.cxx
+++ b/sd/qa/unit/export-tests.cxx
@@ -74,6 +74,7 @@ public:
void testTdf123557();
void testTdf113822();
void testTdf126761();
void testGlow();
CPPUNIT_TEST_SUITE(SdExportTest);
@@ -108,6 +109,7 @@ public:
CPPUNIT_TEST(testTdf123557);
CPPUNIT_TEST(testTdf113822);
CPPUNIT_TEST(testTdf126761);
CPPUNIT_TEST(testGlow);
CPPUNIT_TEST_SUITE_END();
@@ -1257,6 +1259,54 @@ void SdExportTest::testTdf126761()
xDocShRef->DoClose();
}
void SdExportTest::testGlow()
{
auto xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/odg/glow.odg"), ODG);
utl::TempFile tempFile;
xDocShRef = saveAndReload(xDocShRef.get(), ODG, &tempFile);
uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(0, 0, xDocShRef));
// Check glow properties
bool bGlowEffect = false;
CPPUNIT_ASSERT(xShape->getPropertyValue("GlowEffect") >>= bGlowEffect);
CPPUNIT_ASSERT(bGlowEffect);
sal_Int32 nGlowEffectRad = 0;
CPPUNIT_ASSERT(xShape->getPropertyValue("GlowEffectRad") >>= nGlowEffectRad);
CPPUNIT_ASSERT_EQUAL(sal_Int32(190500), nGlowEffectRad); // 15 pt = 190500 EMU
sal_Int32 nGlowEffectColor = 0;
CPPUNIT_ASSERT(xShape->getPropertyValue("GlowEffectColor") >>= nGlowEffectColor);
CPPUNIT_ASSERT_EQUAL(sal_Int32(0x00FF4000), nGlowEffectColor); // "Brick"
sal_Int16 nGlowEffectTransparency = 0;
CPPUNIT_ASSERT(xShape->getPropertyValue("GlowEffectTransparency") >>= nGlowEffectTransparency);
CPPUNIT_ASSERT_EQUAL(sal_Int16(60), nGlowEffectTransparency); // 60%
// Test ODF element
xmlDocPtr pXmlDoc = parseExport(tempFile, "content.xml");
// check that we actually test graphic style
assertXPath(pXmlDoc, "/office:document-content/office:automatic-styles/style:style[2]",
"family", "graphic");
// check loext graphic attributes
assertXPath(
pXmlDoc,
"/office:document-content/office:automatic-styles/style:style[2]/style:graphic-properties",
"glow", "visible");
assertXPath(
pXmlDoc,
"/office:document-content/office:automatic-styles/style:style[2]/style:graphic-properties",
"glow-radius", "190.5cm"); // ???
assertXPath(
pXmlDoc,
"/office:document-content/office:automatic-styles/style:style[2]/style:graphic-properties",
"glow-color", "#ff4000");
assertXPath(
pXmlDoc,
"/office:document-content/office:automatic-styles/style:style[2]/style:graphic-properties",
"glow-transparency", "60%");
xDocShRef->DoClose();
}
CPPUNIT_TEST_SUITE_REGISTRATION(SdExportTest);
CPPUNIT_PLUGIN_IMPLEMENT();