summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2015-08-25 19:08:00 +0200
committerMichael Stahl <mstahl@redhat.com>2015-08-26 23:00:34 +0200
commitf38f018053a43d1f7b473103e936abe2d4d8fa05 (patch)
treeeeb05f2b5d2c153061e5cf79ff02fc1f539f3f71
parent982537d77c2db463cc053cfdcd522530a3834c9e (diff)
tdf#92379: sw: ODF import: fix fo:background-color="transparent"
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
-rw-r--r--sw/qa/extras/odfexport/data/tdf92379.fodt26
-rw-r--r--sw/qa/extras/odfexport/odfexport.cxx43
-rw-r--r--sw/source/core/unocore/unostyle.cxx6
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 280dc5ad893c..8aeb9c45187c 100644
--- a/sw/qa/extras/odfexport/data/tdf92379.fodt
+++ b/sw/qa/extras/odfexport/data/tdf92379.fodt
@@ -37,6 +37,32 @@
</style:graphic-properties>
</style:style>
+ <!-- "Titre Avis expert" and derived styles from bugdoc -->
+ <style:style style:name="Titre_20_Avis_20_expert" style:display-name="Titre Avis expert" style:family="paragraph" style:parent-style-name="Standard" style:master-page-name="">
+ <style:paragraph-properties fo:text-align="start" style:justify-single-word="false" style:page-number="auto" fo:background-color="#661900">
+ <style:background-image/>
+ </style:paragraph-properties>
+ <style:text-properties fo:color="#ffffff" />
+ </style:style>
+ <style:style style:name="Avis_20_expert_20_questions" style:display-name="Avis expert questions" style:family="paragraph" style:parent-style-name="Titre_20_Avis_20_expert" style:master-page-name="">
+ <style:paragraph-properties fo:line-height="100%" fo:text-align="start" style:justify-single-word="false" style:page-number="auto" fo:background-color="transparent">
+ <style:background-image/>
+ </style:paragraph-properties>
+ <style:text-properties fo:color="#661900" />
+ </style:style>
+ <style:style style:name="avis_20_expert_20_questions_20_non_20_cadres" style:display-name="avis expert questions non cadres" style:family="paragraph" style:parent-style-name="Avis_20_expert_20_questions" style:master-page-name="">
+ <style:paragraph-properties style:page-number="auto" fo:background-color="#801900" style:shadow="none">
+ <style:tab-stops/>
+ <style:background-image/>
+ </style:paragraph-properties>
+ </style:style>
+ <style:style style:name="Avis_20_expert_20_rXponses" style:display-name="Avis expert rXponses" style:family="paragraph" style:parent-style-name="Avis_20_expert_20_questions" style:master-page-name="">
+ <style:paragraph-properties fo:line-height="100%" fo:text-align="justify" style:justify-single-word="false" fo:orphans="0" fo:widows="0" fo:hyphenation-ladder-count="1" style:page-number="auto" fo:background-color="transparent">
+ <style:background-image/>
+ </style:paragraph-properties>
+ <style:text-properties fo:color="#461900" fo:hyphenate="true" fo:hyphenation-remain-char-count="2" fo:hyphenation-push-char-count="2"/>
+ </style:style>
+
</office:styles>
<office:automatic-styles>
<style:page-layout style:name="pm1">
diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx
index d313f374a29e..956548c057a0 100644
--- a/sw/qa/extras/odfexport/odfexport.cxx
+++ b/sw/qa/extras/odfexport/odfexport.cxx
@@ -278,7 +278,48 @@ DECLARE_ODFEXPORT_TEST(testTdf92379, "tdf92379.fodt")
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xStyle, "BackColorTransparency"));
CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, getProperty<drawing::FillStyle>(xStyle, "FillStyle"));
CPPUNIT_ASSERT_EQUAL(sal_Int32(0xffcc99), getProperty<sal_Int32>(xStyle, "FillColor"));
- CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xStyle, "FillTransparence"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty<sal_Int16>(xStyle, "FillTransparence"));
+
+ // paragraph style fo:background-color was wrongly inherited despite being
+ // overridden in derived style
+ uno::Reference<container::XNameAccess> xParaStyles(getStyles("ParagraphStyles"));
+ uno::Reference<beans::XPropertySet> xStyle1(xParaStyles->getByName(
+ "Titre Avis expert"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0x661900), getProperty<sal_Int32>(xStyle1, "ParaBackColor"));
+ CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(xStyle1, "ParaBackTransparent"));
+ CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, getProperty<drawing::FillStyle>(xStyle1, "FillStyle"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0x661900), getProperty<sal_Int32>(xStyle1, "FillColor"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty<sal_Int16>(xStyle1, "FillTransparence"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0xffffff), getProperty<sal_Int32>(xStyle1, "CharColor"));
+
+ uno::Reference<beans::XPropertySet> xStyle2(xParaStyles->getByName(
+ "Avis expert questions"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_TRANSPARENT), getProperty<sal_Int32>(xStyle2, "ParaBackColor"));
+ CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xStyle2, "ParaBackTransparent"));
+ CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, getProperty<drawing::FillStyle>(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<sal_Int32>(xStyle2, "FillColor"));
+// CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty<sal_Int16>(xStyle2, "FillTransparence"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0x661900), getProperty<sal_Int32>(xStyle2, "CharColor"));
+
+ uno::Reference<beans::XPropertySet> xStyle31(xParaStyles->getByName(
+ "avis expert questions non cadres"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0x801900), getProperty<sal_Int32>(xStyle31, "ParaBackColor"));
+ CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(xStyle31, "ParaBackTransparent"));
+ CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, getProperty<drawing::FillStyle>(xStyle31, "FillStyle"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0x801900), getProperty<sal_Int32>(xStyle31, "FillColor"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty<sal_Int16>(xStyle31, "FillTransparence"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0x661900), getProperty<sal_Int32>(xStyle31, "CharColor"));
+
+ uno::Reference<beans::XPropertySet> xStyle32(xParaStyles->getByName(
+ "Avis expert rXponses"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_TRANSPARENT), getProperty<sal_Int32>(xStyle32, "ParaBackColor"));
+ CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xStyle32, "ParaBackTransparent"));
+ CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, getProperty<drawing::FillStyle>(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<sal_Int32>(xStyle32, "FillColor"));
+// CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty<sal_Int16>(xStyle32, "FillTransparence"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0x461900), getProperty<sal_Int32>(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 da3d56ff5bb8..815b2743c931 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -1766,7 +1766,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<bool>() && aValue.get<bool>()))
{
setSvxBrushItemAsFillAttributesToTargetSet(aChangedBrushItem, rStyleSet);
}