From 4ca73073a0d7c62b12a7354f76f8f80adc5d98c1 Mon Sep 17 00:00:00 2001 From: Justin Luth Date: Sat, 21 Dec 2019 16:10:03 +0300 Subject: tdf#129522 SvxShadowItem/writerfilter: allow shadow_NONE overrides Both editeng and writerfilter were ignoring the case where NONE should override an inherited shadow location. Of course, this situation is very rare. Nearly all unit tests ran when asserting that eLocation is already NONE. The same is true for DOC, except that it is not affected by SvxShadowItem's PutValue problem (and neither is ODT). RTF is not even removing the borderlines themselves, so no point in worrying about the shadow for RTF. Change-Id: I7c1ae67270dde81915daee2f0282aa2074d2ec8e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/85658 Tested-by: Jenkins Reviewed-by: Justin Luth Reviewed-by: Miklos Vajna --- .../data/tdf129522_removeShadowStyle.odt | Bin 0 -> 14253 bytes sw/qa/extras/ooxmlexport/ooxmlexport14.cxx | 23 +++++++++++++++++++++ .../ww8export/data/tdf129522_removeShadowStyle.odt | Bin 0 -> 14253 bytes sw/qa/extras/ww8export/ww8export3.cxx | 23 +++++++++++++++++++++ 4 files changed, 46 insertions(+) create mode 100644 sw/qa/extras/ooxmlexport/data/tdf129522_removeShadowStyle.odt create mode 100644 sw/qa/extras/ww8export/data/tdf129522_removeShadowStyle.odt (limited to 'sw/qa') diff --git a/sw/qa/extras/ooxmlexport/data/tdf129522_removeShadowStyle.odt b/sw/qa/extras/ooxmlexport/data/tdf129522_removeShadowStyle.odt new file mode 100644 index 000000000000..7ced9fc647c4 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf129522_removeShadowStyle.odt differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx index fb93572bf725..216cdec15c3c 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -79,6 +80,28 @@ DECLARE_OOXMLEXPORT_TEST(testTdf108350_noFontdefaults, "tdf108350_noFontdefaults //CPPUNIT_ASSERT_EQUAL_MESSAGE("Font size", 10.f, getProperty(xStyleProps, "CharHeight")); } +DECLARE_OOXMLEXPORT_TEST(testTdf129522_removeShadowStyle, "tdf129522_removeShadowStyle.odt") +{ + uno::Reference< container::XNameAccess > paragraphStyles = getStyles("ParagraphStyles"); + uno::Reference< beans::XPropertySet > xStyleProps(paragraphStyles->getByName("Shadow"), uno::UNO_QUERY_THROW); + table::ShadowFormat aShadow = getProperty(xStyleProps, "ParaShadowFormat"); + CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadow.Location); + + // Shadows were inherited regardless of whether the style disabled them. + xStyleProps.set(paragraphStyles->getByName("Shadow-removed"), uno::UNO_QUERY_THROW); + aShadow = getProperty(xStyleProps, "ParaShadowFormat"); + CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_NONE, aShadow.Location); + + uno::Reference< container::XNameAccess > characterStyles = getStyles("CharacterStyles"); + xStyleProps.set(characterStyles->getByName("CharShadow"), uno::UNO_QUERY_THROW); + aShadow = getProperty(xStyleProps, "CharShadowFormat"); + CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadow.Location); + + xStyleProps.set(characterStyles->getByName("CharShadow-removed"), uno::UNO_QUERY_THROW); + aShadow = getProperty(xStyleProps, "CharShadowFormat"); + //CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_NONE, aShadow.Location); +} + DECLARE_OOXMLIMPORT_TEST(testTdf125038, "tdf125038.docx") { OUString aActual = getParagraph(1)->getString(); diff --git a/sw/qa/extras/ww8export/data/tdf129522_removeShadowStyle.odt b/sw/qa/extras/ww8export/data/tdf129522_removeShadowStyle.odt new file mode 100644 index 000000000000..7ced9fc647c4 Binary files /dev/null and b/sw/qa/extras/ww8export/data/tdf129522_removeShadowStyle.odt differ diff --git a/sw/qa/extras/ww8export/ww8export3.cxx b/sw/qa/extras/ww8export/ww8export3.cxx index cb04cc83bc20..231aaabe58ad 100644 --- a/sw/qa/extras/ww8export/ww8export3.cxx +++ b/sw/qa/extras/ww8export/ww8export3.cxx @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -285,6 +286,28 @@ DECLARE_WW8EXPORT_TEST(testTdf120711_joinedParagraphWithChangeTracking, "tdf1207 CPPUNIT_ASSERT(style::NumberingType::CHAR_SPECIAL != numFormat); } +DECLARE_WW8EXPORT_TEST(testTdf129522_removeShadowStyle, "tdf129522_removeShadowStyle.odt") +{ + uno::Reference< container::XNameAccess > paragraphStyles = getStyles("ParagraphStyles"); + uno::Reference< beans::XPropertySet > xStyleProps(paragraphStyles->getByName("Shadow"), uno::UNO_QUERY_THROW); + table::ShadowFormat aShadow = getProperty(xStyleProps, "ParaShadowFormat"); + CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadow.Location); + + // Shadows were inherited regardless of whether the style disabled them. + xStyleProps.set(paragraphStyles->getByName("Shadow-removed"), uno::UNO_QUERY_THROW); + aShadow = getProperty(xStyleProps, "ParaShadowFormat"); + CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_NONE, aShadow.Location); + + uno::Reference< container::XNameAccess > characterStyles = getStyles("CharacterStyles"); + xStyleProps.set(characterStyles->getByName("CharShadow"), uno::UNO_QUERY_THROW); + aShadow = getProperty(xStyleProps, "CharShadowFormat"); + CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadow.Location); + + xStyleProps.set(characterStyles->getByName("CharShadow-removed"), uno::UNO_QUERY_THROW); + aShadow = getProperty(xStyleProps, "CharShadowFormat"); + //CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_NONE, aShadow.Location); +} + DECLARE_WW8EXPORT_TEST(testBtlrCell, "btlr-cell.doc") { // Without the accompanying fix in place, this test would have failed, as -- cgit