From f27cba26afe416de48b7ff2cded69ae60ae14fd4 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 25 Aug 2015 19:08:00 +0200 Subject: [PATCH 3/5] tdf#92379: sw: ODF import: fix fo:background-color="transparent" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The problem is that if the FillStyle is NONE, setting only ParaBackTransparent but not ParaBackColor does absolutely nothing. This means that if a parent style sets a background color, then a derived style cannot override it to be transparent. Cause is that getSvxBrushItemFromSourceSet() defaults to setting a 0xFF transparency on the SvxBrushItem. There is still a problem that getSvxBrushItemFromSourceSet() sets the pool default item's color and that is also exported to ODF again as draw:fill-color, but together with draw:fill="none" it should not cause harm, at least for consumers that prefer draw:fill attributes like LO >= 4.4. (regression from 7d9bb549d498d6beed2c4050c402d09643febdfa) Change-Id: I5312901166a0e6f0cf02369b173dc8498e4113ed (cherry picked from commit f38f018053a43d1f7b473103e936abe2d4d8fa05) Reviewed-on: https://gerrit.libreoffice.org/18043 Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- sw/qa/extras/odfexport/data/tdf92379.fodt | 26 +++++++++++++++++++ sw/qa/extras/odfexport/odfexport.cxx | 43 ++++++++++++++++++++++++++++++- sw/source/core/unocore/unostyle.cxx | 6 ++++- 3 files changed, 73 insertions(+), 2 deletions(-) diff --git a/sw/qa/extras/odfexport/data/tdf92379.fodt b/sw/qa/extras/odfexport/data/tdf92379.fodt index 280dc5a..8aeb9c4 100644 --- a/sw/qa/extras/odfexport/data/tdf92379.fodt +++ b/sw/qa/extras/odfexport/data/tdf92379.fodt @@ -37,6 +37,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx index c1dc7ab..308a83d 100644 --- a/sw/qa/extras/odfexport/odfexport.cxx +++ b/sw/qa/extras/odfexport/odfexport.cxx @@ -82,7 +82,48 @@ DECLARE_ODFEXPORT_TEST(testTdf92379, "tdf92379.fodt") CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty(xStyle, "BackColorTransparency")); CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, getProperty(xStyle, "FillStyle")); CPPUNIT_ASSERT_EQUAL(sal_Int32(0xffcc99), getProperty(xStyle, "FillColor")); - CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty(xStyle, "FillTransparence")); + CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty(xStyle, "FillTransparence")); + + // paragraph style fo:background-color was wrongly inherited despite being + // overridden in derived style + uno::Reference xParaStyles(getStyles("ParagraphStyles")); + uno::Reference xStyle1(xParaStyles->getByName( + "Titre Avis expert"), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0x661900), getProperty(xStyle1, "ParaBackColor")); + CPPUNIT_ASSERT_EQUAL(false, getProperty(xStyle1, "ParaBackTransparent")); + CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, getProperty(xStyle1, "FillStyle")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0x661900), getProperty(xStyle1, "FillColor")); + CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty(xStyle1, "FillTransparence")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0xffffff), getProperty(xStyle1, "CharColor")); + + uno::Reference xStyle2(xParaStyles->getByName( + "Avis expert questions"), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_TRANSPARENT), getProperty(xStyle2, "ParaBackColor")); + CPPUNIT_ASSERT_EQUAL(true, getProperty(xStyle2, "ParaBackTransparent")); + CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, getProperty(xStyle2, "FillStyle")); +// unfortunately this is actually the pool default value, which would be hard to fix - but it isn't a problem because style is NONE +// CPPUNIT_ASSERT_EQUAL(sal_Int32(0xffffff), getProperty(xStyle2, "FillColor")); +// CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty(xStyle2, "FillTransparence")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0x661900), getProperty(xStyle2, "CharColor")); + + uno::Reference xStyle31(xParaStyles->getByName( + "avis expert questions non cadres"), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0x801900), getProperty(xStyle31, "ParaBackColor")); + CPPUNIT_ASSERT_EQUAL(false, getProperty(xStyle31, "ParaBackTransparent")); + CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, getProperty(xStyle31, "FillStyle")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0x801900), getProperty(xStyle31, "FillColor")); + CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty(xStyle31, "FillTransparence")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0x661900), getProperty(xStyle31, "CharColor")); + + uno::Reference xStyle32(xParaStyles->getByName( + "Avis expert rXponses"), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_TRANSPARENT), getProperty(xStyle32, "ParaBackColor")); + CPPUNIT_ASSERT_EQUAL(true, getProperty(xStyle32, "ParaBackTransparent")); + CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, getProperty(xStyle32, "FillStyle")); +// unfortunately this is actually the pool default value, which would be hard to fix - but it isn't a problem because style is NONE +// CPPUNIT_ASSERT_EQUAL(sal_Int32(0xffffff), getProperty(xStyle32, "FillColor")); +// CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty(xStyle32, "FillTransparence")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0x461900), getProperty(xStyle32, "CharColor")); } DECLARE_ODFEXPORT_TEST(testFdo79358, "fdo79358.odt") diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index a4c670b..28f25eb 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -1764,7 +1764,11 @@ static void lcl_SetStyleProperty(const SfxItemPropertySimpleEntry& rEntry, aChangedBrushItem.PutValue(aValue, nMemberId); - if(!(aChangedBrushItem == aOriginalBrushItem)) + if (!(aChangedBrushItem == aOriginalBrushItem) || + // 0xff is already the default - but if BackTransparent is set + // to true, it must be applied in the item set on ODF import + // to potentially override parent style, which is unknown yet + (MID_GRAPHIC_TRANSPARENT == nMemberId && aValue.has() && aValue.get())) { setSvxBrushItemAsFillAttributesToTargetSet(aChangedBrushItem, rStyleSet); } -- 2.4.3