1 |
From c1f4c6db1fff37496b9b954ca21e958865078d2d Mon Sep 17 00:00:00 2001 |
2 |
From: Michael Stahl <mstahl@redhat.com> |
3 |
Date: Wed, 26 Aug 2015 19:04:50 +0200 |
4 |
Subject: [PATCH 5/5] ODF import: workaround dubious draw:fill="solid" on frame |
5 |
styles |
6 |
MIME-Version: 1.0 |
7 |
Content-Type: text/plain; charset=UTF-8 |
8 |
Content-Transfer-Encoding: 8bit |
9 |
|
10 |
Since the gradient frame backgrounds were added in LO 4.1, we export |
11 |
this: |
12 |
|
13 |
fo:background-color="transparent" draw:fill="solid" |
14 |
|
15 |
Which doesn't make a whole lot of sense as this is really a "none" fill, |
16 |
and now with the backward compatibility stuff in the style import code |
17 |
we get the pool default color added when setting the BackTransparent |
18 |
property, and with the draw:fill="solid" it becomes visible and the |
19 |
background color is now Sky Blue 1. |
20 |
|
21 |
So try to detect draw:fill="solid" without draw:fill-color attribute |
22 |
and contradicting transparent legacy attribute and nerf it. This way |
23 |
we also export draw:fill="none" again, although still with a bogus |
24 |
draw:fill-color but that shouldn't cause any harm. |
25 |
|
26 |
(cherry picked from commit 68efa6f5128abf4cd097ae81a4cfd7fecbcb2a80) |
27 |
|
28 |
Change-Id: I1c2bea46ba7d9a3f042b875df0ca12c7f6037909 |
29 |
Reviewed-on: https://gerrit.libreoffice.org/18045 |
30 |
Reviewed-by: Caolán McNamara <caolanm@redhat.com> |
31 |
Tested-by: Caolán McNamara <caolanm@redhat.com> |
32 |
--- |
33 |
include/xmloff/txtprmap.hxx | 2 ++ |
34 |
sw/qa/extras/odfexport/data/tdf92379.fodt | 5 +++++ |
35 |
sw/qa/extras/odfexport/odfexport.cxx | 17 +++++++++++++++++ |
36 |
xmloff/source/draw/sdpropls.cxx | 4 ++-- |
37 |
xmloff/source/text/txtimppr.cxx | 14 ++++++++++++++ |
38 |
5 files changed, 40 insertions(+), 2 deletions(-) |
39 |
|
40 |
diff --git a/include/xmloff/txtprmap.hxx b/include/xmloff/txtprmap.hxx |
41 |
index dc8de70..c473f15 100644 |
42 |
--- a/include/xmloff/txtprmap.hxx |
43 |
+++ b/include/xmloff/txtprmap.hxx |
44 |
@@ -196,6 +196,8 @@ |
45 |
#define CTF_CHARBOTTOMBORDER (XML_TEXT_CTF_START + 167) |
46 |
#define CTF_RELWIDTHREL (XML_TEXT_CTF_START + 168) |
47 |
#define CTF_RELHEIGHTREL (XML_TEXT_CTF_START + 169) |
48 |
+#define CTF_FILLSTYLE (XML_TEXT_CTF_START + 172) |
49 |
+#define CTF_FILLCOLOR (XML_TEXT_CTF_START + 173) |
50 |
|
51 |
|
52 |
#define TEXT_PROP_MAP_TEXT 0 |
53 |
diff --git a/sw/qa/extras/odfexport/data/tdf92379.fodt b/sw/qa/extras/odfexport/data/tdf92379.fodt |
54 |
index 8aeb9c4..762a04d 100644 |
55 |
--- a/sw/qa/extras/odfexport/data/tdf92379.fodt |
56 |
+++ b/sw/qa/extras/odfexport/data/tdf92379.fodt |
57 |
@@ -36,6 +36,11 @@ |
58 |
<style:columns fo:column-count="1" fo:column-gap="0in"/> |
59 |
</style:graphic-properties> |
60 |
</style:style> |
61 |
+ <style:style style:name="Untitled1" style:family="graphic" style:parent-style-name="encarts"> |
62 |
+ <style:graphic-properties fo:background-color="transparent" style:background-transparency="100%" draw:fill="solid"> |
63 |
+ <style:background-image/> |
64 |
+ </style:graphic-properties> |
65 |
+ </style:style> |
66 |
|
67 |
<!-- "Titre Avis expert" and derived styles from bugdoc --> |
68 |
<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=""> |
69 |
diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx |
70 |
index d3ee3ee..22083c7 100644 |
71 |
--- a/sw/qa/extras/odfexport/odfexport.cxx |
72 |
+++ b/sw/qa/extras/odfexport/odfexport.cxx |
73 |
@@ -84,6 +84,23 @@ DECLARE_ODFEXPORT_TEST(testTdf92379, "tdf92379.fodt") |
74 |
CPPUNIT_ASSERT_EQUAL(sal_Int32(0xffcc99), getProperty<sal_Int32>(xStyle, "FillColor")); |
75 |
CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty<sal_Int16>(xStyle, "FillTransparence")); |
76 |
|
77 |
+ uno::Reference<beans::XPropertySet> xFrameStyle2(xStyles->getByName("Untitled1"), |
78 |
+ uno::UNO_QUERY); |
79 |
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0xffffff), getProperty<sal_Int32>(xFrameStyle2, "BackColorRGB")); |
80 |
+ CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xFrameStyle2, "BackTransparent")); |
81 |
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty<sal_Int32>(xFrameStyle2, "BackColorTransparency")); |
82 |
+ CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, getProperty<drawing::FillStyle>(xFrameStyle2, "FillStyle")); |
83 |
+// unfortunately this is actually the pool default value, which would be hard to fix - but it isn't a problem because style is NONE |
84 |
+// CPPUNIT_ASSERT_EQUAL(sal_Int32(0xffffff), getProperty<sal_Int32>(xFrameStyle2, "FillColor")); |
85 |
+// CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty<sal_Int16>(xFrameStyle2, "FillTransparence")); |
86 |
+ |
87 |
+ if (xmlDocPtr pXmlDoc = parseExport("styles.xml")) |
88 |
+ { |
89 |
+ // check that fo:background-color attribute is exported properly |
90 |
+ assertXPath(pXmlDoc, "//style:style[@style:family='graphic' and @style:name='encarts']/style:graphic-properties[@fo:background-color='#ffcc99']", 1); |
91 |
+ assertXPath(pXmlDoc, "//style:style[@style:family='graphic' and @style:name='Untitled1']/style:graphic-properties[@fo:background-color='transparent']", 1); |
92 |
+ } |
93 |
+ |
94 |
// paragraph style fo:background-color was wrongly inherited despite being |
95 |
// overridden in derived style |
96 |
uno::Reference<container::XNameAccess> xParaStyles(getStyles("ParagraphStyles")); |
97 |
diff --git a/xmloff/source/draw/sdpropls.cxx b/xmloff/source/draw/sdpropls.cxx |
98 |
index 27b2de0..065d3dd 100644 |
99 |
--- a/xmloff/source/draw/sdpropls.cxx |
100 |
+++ b/xmloff/source/draw/sdpropls.cxx |
101 |
@@ -106,8 +106,8 @@ const XMLPropertyMapEntry aXMLSDProperties[] = |
102 |
GMAP( "LineCap", XML_NAMESPACE_SVG , XML_STROKE_LINECAP, XML_SD_TYPE_LINECAP, 0 ), |
103 |
|
104 |
// fill attributes |
105 |
- GMAP( "FillStyle", XML_NAMESPACE_DRAW, XML_FILL, XML_SD_TYPE_FILLSTYLE, 0 ), |
106 |
- GMAP_D("FillColor", XML_NAMESPACE_DRAW, XML_FILL_COLOR, XML_TYPE_COLOR, 0), |
107 |
+ GMAP( "FillStyle", XML_NAMESPACE_DRAW, XML_FILL, XML_SD_TYPE_FILLSTYLE, CTF_FILLSTYLE ), |
108 |
+ GMAP_D("FillColor", XML_NAMESPACE_DRAW, XML_FILL_COLOR, XML_TYPE_COLOR, CTF_FILLCOLOR ), |
109 |
GMAP_D("FillColor2", XML_NAMESPACE_DRAW, XML_SECONDARY_FILL_COLOR, XML_TYPE_COLOR, 0), |
110 |
GMAP( "FillGradientName", XML_NAMESPACE_DRAW, XML_FILL_GRADIENT_NAME, XML_TYPE_STYLENAME|MID_FLAG_NO_PROPERTY_IMPORT, CTF_FILLGRADIENTNAME ), |
111 |
GMAP( "FillGradientStepCount", XML_NAMESPACE_DRAW, XML_GRADIENT_STEP_COUNT, XML_TYPE_NUMBER16, 0 ), |
112 |
diff --git a/xmloff/source/text/txtimppr.cxx b/xmloff/source/text/txtimppr.cxx |
113 |
index 11b00e4..9278950 100644 |
114 |
--- a/xmloff/source/text/txtimppr.cxx |
115 |
+++ b/xmloff/source/text/txtimppr.cxx |
116 |
@@ -22,6 +22,7 @@ |
117 |
#include <osl/thread.h> |
118 |
#include <com/sun/star/awt/FontFamily.hpp> |
119 |
#include <com/sun/star/awt/FontPitch.hpp> |
120 |
+#include <com/sun/star/drawing/FillStyle.hpp> |
121 |
#include <com/sun/star/table/BorderLine2.hpp> |
122 |
#include <com/sun/star/text/VertOrientation.hpp> |
123 |
#include <com/sun/star/text/SizeType.hpp> |
124 |
@@ -399,6 +400,8 @@ void XMLTextImportPropertyMapper::finished( |
125 |
XMLPropertyState* pAllMargin = 0; |
126 |
XMLPropertyState* pMargins[4] = { 0, 0, 0, 0 }; |
127 |
::std::unique_ptr<XMLPropertyState> pNewMargins[4]; |
128 |
+ XMLPropertyState* pFillStyle(nullptr); |
129 |
+ XMLPropertyState* pFillColor(nullptr); |
130 |
|
131 |
for( ::std::vector< XMLPropertyState >::iterator aIter = rProperties.begin(); |
132 |
aIter != rProperties.end(); |
133 |
@@ -482,6 +485,8 @@ void XMLTextImportPropertyMapper::finished( |
134 |
bHasAnyWidth = true; break; |
135 |
case CTF_BACKGROUND_TRANSPARENCY: pBackTransparency = property; break; |
136 |
case CTF_BACKGROUND_TRANSPARENT: pBackTransparent = property; break; |
137 |
+ case CTF_FILLSTYLE: pFillStyle = property; break; |
138 |
+ case CTF_FILLCOLOR: pFillColor = property; break; |
139 |
case CTF_PARAMARGINALL: |
140 |
case CTF_PARAMARGINALL_REL: |
141 |
pAllParaMargin = property; break; |
142 |
@@ -646,6 +651,15 @@ void XMLTextImportPropertyMapper::finished( |
143 |
pFontStyleNameCTL, pFontFamilyCTL, pFontPitchCTL, pFontCharSetCTL, |
144 |
&pNewFontStyleNameCTL, &pNewFontFamilyCTL, &pNewFontPitchCTL, &pNewFontCharSetCTL ); |
145 |
|
146 |
+ if (pFillStyle && !pFillColor && pBackTransparent |
147 |
+ && drawing::FillStyle_SOLID == pFillStyle->maValue.get<drawing::FillStyle>() |
148 |
+ && pBackTransparent->maValue.get<bool>()) |
149 |
+ { |
150 |
+ // fo:background="transparent", draw:fill="solid" without draw:fill-color |
151 |
+ // prevent getSvxBrushItemFromSourceSet from adding bogus default color |
152 |
+ pFillStyle->mnIndex = -1; |
153 |
+ } |
154 |
+ |
155 |
// #i5775# don't overwrite %transparency with binary transparency |
156 |
if( ( pBackTransparency != NULL ) && ( pBackTransparent != NULL ) ) |
157 |
{ |
158 |
-- |
159 |
2.4.3 |
160 |
|