1 |
From 89e2e2f59738adee91282c19e7d43e98784fdacb Mon Sep 17 00:00:00 2001 |
2 |
From: Michael Stahl <mstahl@redhat.com> |
3 |
Date: Fri, 21 Aug 2015 18:28:23 +0200 |
4 |
Subject: [PATCH 2/5] tdf#92379: svx: don't overwrite fo:background-color on |
5 |
ODF import |
6 |
MIME-Version: 1.0 |
7 |
Content-Type: text/plain; charset=UTF-8 |
8 |
Content-Transfer-Encoding: 8bit |
9 |
|
10 |
getSvxBrushItemFromSourceSet() is called once for each property of a |
11 |
frame style that is set, and the "solid" fill-style is set by first |
12 |
applying the BackColorRGB and then BackTransparency property. So there |
13 |
is an intermediate state that has fill-style NONE but a XFillColorItem |
14 |
set - don't reset the color to white in that case! |
15 |
|
16 |
Apparently writerfilter generally relies on the current reset-to-AUTO |
17 |
implementation (loads of test failures), so for now limit the fix for |
18 |
when we know that a frame style is imported from ODF. |
19 |
|
20 |
(regression from 3d399b0e45720354fc64dc3d121ee486e01eff89) |
21 |
|
22 |
(cherry picked from commit 79fb61efb847405fa47235002b52ee8efad5e339) |
23 |
|
24 |
tdf#92379: sw: unit test for frame style background color |
25 |
|
26 |
(cherry picked from commit 982537d77c2db463cc053cfdcd522530a3834c9e) |
27 |
|
28 |
Change-Id: Ia987fe586ec819a1f3cd85acdbfb03c74ca0ec2c |
29 |
Reviewed-on: https://gerrit.libreoffice.org/18042 |
30 |
Reviewed-by: Caolán McNamara <caolanm@redhat.com> |
31 |
Tested-by: Caolán McNamara <caolanm@redhat.com> |
32 |
--- |
33 |
include/svx/unobrushitemhelper.hxx | 3 +- |
34 |
svx/source/unodraw/unobrushitemhelper.cxx | 6 ++-- |
35 |
sw/CppunitTest_sw_odfexport.mk | 3 ++ |
36 |
sw/qa/extras/odfexport/data/tdf92379.fodt | 58 +++++++++++++++++++++++++++++++ |
37 |
sw/qa/extras/odfexport/odfexport.cxx | 13 +++++++ |
38 |
sw/source/core/unocore/unostyle.cxx | 4 +-- |
39 |
6 files changed, 81 insertions(+), 6 deletions(-) |
40 |
create mode 100644 sw/qa/extras/odfexport/data/tdf92379.fodt |
41 |
|
42 |
diff --git a/include/svx/unobrushitemhelper.hxx b/include/svx/unobrushitemhelper.hxx |
43 |
index eea95b6..4055c45 100644 |
44 |
--- a/include/svx/unobrushitemhelper.hxx |
45 |
+++ b/include/svx/unobrushitemhelper.hxx |
46 |
@@ -46,7 +46,8 @@ SVX_DLLPUBLIC void setSvxBrushItemAsFillAttributesToTargetSet( |
47 |
SVX_DLLPUBLIC SvxBrushItem getSvxBrushItemFromSourceSet( |
48 |
const SfxItemSet& rSourceSet, |
49 |
sal_uInt16 nBackgroundID, |
50 |
- bool bSearchInParents = true); |
51 |
+ bool bSearchInParents = true, |
52 |
+ bool bXMLImportHack = false); |
53 |
|
54 |
#endif // _UNOBRUSHITEMHELPER_HXX |
55 |
|
56 |
diff --git a/svx/source/unodraw/unobrushitemhelper.cxx b/svx/source/unodraw/unobrushitemhelper.cxx |
57 |
index d10aab6..fb6728d 100644 |
58 |
--- a/svx/source/unodraw/unobrushitemhelper.cxx |
59 |
+++ b/svx/source/unodraw/unobrushitemhelper.cxx |
60 |
@@ -192,7 +192,7 @@ SvxBrushItem getSvxBrushItemForSolid(const SfxItemSet& rSourceSet, bool bSearchI |
61 |
} |
62 |
|
63 |
//UUUU |
64 |
-SvxBrushItem getSvxBrushItemFromSourceSet(const SfxItemSet& rSourceSet, sal_uInt16 nBackgroundID, bool bSearchInParents) |
65 |
+SvxBrushItem getSvxBrushItemFromSourceSet(const SfxItemSet& rSourceSet, sal_uInt16 nBackgroundID, bool bSearchInParents, bool bXMLImportHack) |
66 |
{ |
67 |
const XFillStyleItem* pXFillStyleItem(static_cast< const XFillStyleItem* >(rSourceSet.GetItem(XATTR_FILLSTYLE, bSearchInParents))); |
68 |
|
69 |
@@ -201,8 +201,8 @@ SvxBrushItem getSvxBrushItemFromSourceSet(const SfxItemSet& rSourceSet, sal_uInt |
70 |
// no fill, still need to rescue the evtl. set RGB color, but use as transparent color (we have drawing::FillStyle_NONE) |
71 |
Color aFillColor(static_cast< const XFillColorItem& >(rSourceSet.Get(XATTR_FILLCOLOR, bSearchInParents)).GetColorValue()); |
72 |
|
73 |
- // when fill style is none, then don't allow anything other than 0 or auto. |
74 |
- if (aFillColor.GetColor() != 0) |
75 |
+ // for writerfilter: when fill style is none, then don't allow anything other than 0 or auto. |
76 |
+ if (!bXMLImportHack && aFillColor.GetColor() != 0) |
77 |
aFillColor.SetColor(COL_AUTO); |
78 |
|
79 |
aFillColor.SetTransparency(0xff); |
80 |
diff --git a/sw/CppunitTest_sw_odfexport.mk b/sw/CppunitTest_sw_odfexport.mk |
81 |
index 7bc7ed8..c6ec626 100644 |
82 |
--- a/sw/CppunitTest_sw_odfexport.mk |
83 |
+++ b/sw/CppunitTest_sw_odfexport.mk |
84 |
@@ -56,6 +56,9 @@ $(eval $(call gb_CppunitTest_use_components,sw_odfexport,\ |
85 |
embeddedobj/util/embobj \ |
86 |
filter/source/config/cache/filterconfig1 \ |
87 |
filter/source/storagefilterdetect/storagefd \ |
88 |
+ filter/source/odfflatxml/odfflatxml \ |
89 |
+ filter/source/xmlfilterdetect/xmlfd \ |
90 |
+ filter/source/xmlfilteradaptor/xmlfa \ |
91 |
framework/util/fwk \ |
92 |
i18npool/util/i18npool \ |
93 |
linguistic/source/lng \ |
94 |
diff --git a/sw/qa/extras/odfexport/data/tdf92379.fodt b/sw/qa/extras/odfexport/data/tdf92379.fodt |
95 |
new file mode 100644 |
96 |
index 0000000..280dc5a |
97 |
--- /dev/null |
98 |
+++ b/sw/qa/extras/odfexport/data/tdf92379.fodt |
99 |
@@ -0,0 +1,58 @@ |
100 |
+<?xml version="1.0" encoding="UTF-8"?> |
101 |
+ |
102 |
+<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rpt="http://openoffice.org/2005/report" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:officeooo="http://openoffice.org/2009/office" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:drawooo="http://openoffice.org/2010/draw" xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:css3t="http://www.w3.org/TR/css3-text/" office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.text"> |
103 |
+ <office:meta><meta:initial-creator>ms </meta:initial-creator><meta:creation-date>2015-08-24T21:49:45.305718699</meta:creation-date><meta:document-statistic meta:table-count="0" meta:image-count="0" meta:object-count="0" meta:page-count="1" meta:paragraph-count="0" meta:word-count="0" meta:character-count="0" meta:non-whitespace-character-count="0"/><meta:generator>LibreOfficeDev/4.3.7.2$Linux_X86_64 LibreOffice_project/8a35821d8636a03b8bf4e15b48f59794652c68ba</meta:generator></office:meta> |
104 |
+ <office:font-face-decls> |
105 |
+ <style:font-face style:name="Lohit Devanagari1" svg:font-family="'Lohit Devanagari'"/> |
106 |
+ <style:font-face style:name="Liberation Serif" svg:font-family="'Liberation Serif'" style:font-family-generic="roman" style:font-pitch="variable"/> |
107 |
+ <style:font-face style:name="Liberation Sans" svg:font-family="'Liberation Sans'" style:font-family-generic="swiss" style:font-pitch="variable"/> |
108 |
+ <style:font-face style:name="Lohit Devanagari" svg:font-family="'Lohit Devanagari'" style:font-family-generic="system" style:font-pitch="variable"/> |
109 |
+ <style:font-face style:name="Source Han Sans CN Regular" svg:font-family="'Source Han Sans CN Regular'" style:font-family-generic="system" style:font-pitch="variable"/> |
110 |
+ </office:font-face-decls> |
111 |
+ <office:styles> |
112 |
+ <style:default-style style:family="graphic"> |
113 |
+ <style:graphic-properties svg:stroke-color="#3465a4" draw:fill-color="#729fcf" fo:wrap-option="no-wrap" draw:shadow-offset-x="0.3cm" draw:shadow-offset-y="0.3cm" draw:start-line-spacing-horizontal="0.283cm" draw:start-line-spacing-vertical="0.283cm" draw:end-line-spacing-horizontal="0.283cm" draw:end-line-spacing-vertical="0.283cm" style:flow-with-text="false"/> |
114 |
+ <style:paragraph-properties style:text-autospace="ideograph-alpha" style:line-break="strict" style:writing-mode="lr-tb" style:font-independent-line-spacing="false"> |
115 |
+ <style:tab-stops/> |
116 |
+ </style:paragraph-properties> |
117 |
+ <style:text-properties style:use-window-font-color="true" style:font-name="Liberation Serif" fo:font-size="12pt" fo:language="de" fo:country="DE" style:letter-kerning="true" style:font-name-asian="Source Han Sans CN Regular" style:font-size-asian="10.5pt" style:language-asian="zh" style:country-asian="CN" style:font-name-complex="Lohit Devanagari" style:font-size-complex="12pt" style:language-complex="hi" style:country-complex="IN"/> |
118 |
+ </style:default-style> |
119 |
+ <style:default-style style:family="paragraph"> |
120 |
+ <style:paragraph-properties fo:hyphenation-ladder-count="no-limit" style:text-autospace="ideograph-alpha" style:punctuation-wrap="hanging" style:line-break="strict" style:tab-stop-distance="1.251cm" style:writing-mode="page"/> |
121 |
+ <style:text-properties style:use-window-font-color="true" style:font-name="Liberation Serif" fo:font-size="12pt" fo:language="de" fo:country="DE" style:letter-kerning="true" style:font-name-asian="Source Han Sans CN Regular" style:font-size-asian="10.5pt" style:language-asian="zh" style:country-asian="CN" style:font-name-complex="Lohit Devanagari" style:font-size-complex="12pt" style:language-complex="hi" style:country-complex="IN" fo:hyphenate="false" fo:hyphenation-remain-char-count="2" fo:hyphenation-push-char-count="2"/> |
122 |
+ </style:default-style> |
123 |
+ <style:default-style style:family="table"> |
124 |
+ <style:table-properties table:border-model="collapsing"/> |
125 |
+ </style:default-style> |
126 |
+ <style:default-style style:family="table-row"> |
127 |
+ <style:table-row-properties fo:keep-together="auto"/> |
128 |
+ </style:default-style> |
129 |
+ <style:style style:name="Standard" style:family="paragraph" style:class="text"/> |
130 |
+ |
131 |
+ <!-- "encarts" from bugdoc --> |
132 |
+ <style:style style:name="encarts" style:family="graphic"> |
133 |
+ <style:graphic-properties svg:width="3.9701in" svg:height="0.1402in" text:anchor-type="paragraph" fo:background-color="#ffcc99" style:background-transparency="0%" draw:fill="solid" fo:padding="0.0193in" fo:border="0.79pt solid #661900" style:shadow="none" draw:shadow-opacity="100%"> |
134 |
+ <style:background-image/> |
135 |
+ <style:columns fo:column-count="1" fo:column-gap="0in"/> |
136 |
+ </style:graphic-properties> |
137 |
+ </style:style> |
138 |
+ |
139 |
+ </office:styles> |
140 |
+ <office:automatic-styles> |
141 |
+ <style:page-layout style:name="pm1"> |
142 |
+ <style:page-layout-properties fo:page-width="21.001cm" fo:page-height="29.7cm" style:num-format="1" style:print-orientation="portrait" fo:margin-top="2cm" fo:margin-bottom="2cm" fo:margin-left="2cm" fo:margin-right="2cm" style:writing-mode="lr-tb" style:footnote-max-height="0cm"> |
143 |
+ <style:footnote-sep style:width="0.018cm" style:distance-before-sep="0.101cm" style:distance-after-sep="0.101cm" style:line-style="solid" style:adjustment="left" style:rel-width="25%" style:color="#000000"/> |
144 |
+ </style:page-layout-properties> |
145 |
+ <style:header-style/> |
146 |
+ <style:footer-style/> |
147 |
+ </style:page-layout> |
148 |
+ </office:automatic-styles> |
149 |
+ <office:master-styles> |
150 |
+ <style:master-page style:name="Standard" style:page-layout-name="pm1"/> |
151 |
+ </office:master-styles> |
152 |
+ <office:body> |
153 |
+ <office:text> |
154 |
+ <text:p text:style-name="Standard"/> |
155 |
+ </office:text> |
156 |
+ </office:body> |
157 |
+</office:document> |
158 |
diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx |
159 |
index a7c1a18..c1dc7ab 100644 |
160 |
--- a/sw/qa/extras/odfexport/odfexport.cxx |
161 |
+++ b/sw/qa/extras/odfexport/odfexport.cxx |
162 |
@@ -72,6 +72,19 @@ DECLARE_ODFEXPORT_TEST(testFdo38244, "fdo38244.odt") |
163 |
CPPUNIT_ASSERT_EQUAL(OUString("M"), getProperty<OUString>(xPropertySet, "Initials")); |
164 |
} |
165 |
|
166 |
+DECLARE_ODFEXPORT_TEST(testTdf92379, "tdf92379.fodt") |
167 |
+{ |
168 |
+ // frame style fo:background-color was not imported |
169 |
+ uno::Reference<container::XNameAccess> xStyles(getStyles("FrameStyles")); |
170 |
+ uno::Reference<beans::XPropertySet> xStyle(xStyles->getByName("encarts"), |
171 |
+ uno::UNO_QUERY); |
172 |
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0xffcc99), getProperty<sal_Int32>(xStyle, "BackColorRGB")); |
173 |
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xStyle, "BackColorTransparency")); |
174 |
+ CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, getProperty<drawing::FillStyle>(xStyle, "FillStyle")); |
175 |
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0xffcc99), getProperty<sal_Int32>(xStyle, "FillColor")); |
176 |
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xStyle, "FillTransparence")); |
177 |
+} |
178 |
+ |
179 |
DECLARE_ODFEXPORT_TEST(testFdo79358, "fdo79358.odt") |
180 |
{ |
181 |
// the boolean properties of the index were not exported properly |
182 |
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx |
183 |
index 2329c74..a4c670b 100644 |
184 |
--- a/sw/source/core/unocore/unostyle.cxx |
185 |
+++ b/sw/source/core/unocore/unostyle.cxx |
186 |
@@ -1759,7 +1759,7 @@ static void lcl_SetStyleProperty(const SfxItemPropertySimpleEntry& rEntry, |
187 |
{ |
188 |
//UUUU |
189 |
SfxItemSet& rStyleSet = rBase.GetItemSet(); |
190 |
- const SvxBrushItem aOriginalBrushItem(getSvxBrushItemFromSourceSet(rStyleSet, RES_BACKGROUND)); |
191 |
+ const SvxBrushItem aOriginalBrushItem(getSvxBrushItemFromSourceSet(rStyleSet, RES_BACKGROUND, true, pDoc->IsInXMLImport())); |
192 |
SvxBrushItem aChangedBrushItem(aOriginalBrushItem); |
193 |
|
194 |
aChangedBrushItem.PutValue(aValue, nMemberId); |
195 |
@@ -4298,7 +4298,7 @@ uno::Reference< style::XAutoStyle > SwXAutoStyleFamily::insertStyle( |
196 |
case RES_BACKGROUND: |
197 |
{ |
198 |
//UUUU |
199 |
- const SvxBrushItem aOriginalBrushItem(getSvxBrushItemFromSourceSet(aSet, RES_BACKGROUND)); |
200 |
+ const SvxBrushItem aOriginalBrushItem(getSvxBrushItemFromSourceSet(aSet, RES_BACKGROUND, true, pDocShell->GetDoc()->IsInXMLImport())); |
201 |
SvxBrushItem aChangedBrushItem(aOriginalBrushItem); |
202 |
|
203 |
aChangedBrushItem.PutValue(aValue, nMemberId); |
204 |
-- |
205 |
2.4.3 |
206 |
|