summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2015-08-26 19:04:50 +0200
committerMichael Stahl <mstahl@redhat.com>2015-08-26 23:00:35 +0200
commit68efa6f5128abf4cd097ae81a4cfd7fecbcb2a80 (patch)
tree0b7a3bba7b3dc99ab4441f07a4f085bd5d123087
parentrelated: tdf#92379: sw: backward compatible ODF export of overriding (diff)
downloadcore-68efa6f5128abf4cd097ae81a4cfd7fecbcb2a80.tar.gz
core-68efa6f5128abf4cd097ae81a4cfd7fecbcb2a80.zip
ODF import: workaround dubious draw:fill="solid" on frame styles
Since the gradient frame backgrounds were added in LO 4.1, we export this: fo:background-color="transparent" draw:fill="solid" Which doesn't make a whole lot of sense as this is really a "none" fill, and now with the backward compatibility stuff in the style import code we get the pool default color added when setting the BackTransparent property, and with the draw:fill="solid" it becomes visible and the background color is now Sky Blue 1. So try to detect draw:fill="solid" without draw:fill-color attribute and contradicting transparent legacy attribute and nerf it. This way we also export draw:fill="none" again, although still with a bogus draw:fill-color but that shouldn't cause any harm. Change-Id: I1c2bea46ba7d9a3f042b875df0ca12c7f6037909
-rw-r--r--include/xmloff/txtprmap.hxx2
-rw-r--r--sw/qa/extras/odfexport/data/tdf92379.fodt5
-rw-r--r--sw/qa/extras/odfexport/odfexport.cxx17
-rw-r--r--xmloff/source/draw/sdpropls.cxx4
-rw-r--r--xmloff/source/text/txtimppr.cxx14
5 files changed, 40 insertions, 2 deletions
diff --git a/include/xmloff/txtprmap.hxx b/include/xmloff/txtprmap.hxx
index 2562abb5f1ef..5fa8e3cbb509 100644
--- a/include/xmloff/txtprmap.hxx
+++ b/include/xmloff/txtprmap.hxx
@@ -198,6 +198,8 @@
#define CTF_RELHEIGHTREL (XML_TEXT_CTF_START + 169)
#define CTF_CHAR_BACKGROUND (XML_TEXT_CTF_START + 170)
#define CTF_CHAR_HIGHLIGHT (XML_TEXT_CTF_START + 171)
+#define CTF_FILLSTYLE (XML_TEXT_CTF_START + 172)
+#define CTF_FILLCOLOR (XML_TEXT_CTF_START + 173)
enum class TextPropMap {
diff --git a/sw/qa/extras/odfexport/data/tdf92379.fodt b/sw/qa/extras/odfexport/data/tdf92379.fodt
index 8aeb9c45187c..762a04d57752 100644
--- a/sw/qa/extras/odfexport/data/tdf92379.fodt
+++ b/sw/qa/extras/odfexport/data/tdf92379.fodt
@@ -36,6 +36,11 @@
<style:columns fo:column-count="1" fo:column-gap="0in"/>
</style:graphic-properties>
</style:style>
+ <style:style style:name="Untitled1" style:family="graphic" style:parent-style-name="encarts">
+ <style:graphic-properties fo:background-color="transparent" style:background-transparency="100%" draw:fill="solid">
+ <style:background-image/>
+ </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="">
diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx
index a18b3b336aa7..bfb24d10ec25 100644
--- a/sw/qa/extras/odfexport/odfexport.cxx
+++ b/sw/qa/extras/odfexport/odfexport.cxx
@@ -280,6 +280,23 @@ DECLARE_ODFEXPORT_TEST(testTdf92379, "tdf92379.fodt")
CPPUNIT_ASSERT_EQUAL(sal_Int32(0xffcc99), getProperty<sal_Int32>(xStyle, "FillColor"));
CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty<sal_Int16>(xStyle, "FillTransparence"));
+ uno::Reference<beans::XPropertySet> xFrameStyle2(xStyles->getByName("Untitled1"),
+ uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0xffffff), getProperty<sal_Int32>(xFrameStyle2, "BackColorRGB"));
+ CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xFrameStyle2, "BackTransparent"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty<sal_Int32>(xFrameStyle2, "BackColorTransparency"));
+ CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, getProperty<drawing::FillStyle>(xFrameStyle2, "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>(xFrameStyle2, "FillColor"));
+// CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty<sal_Int16>(xFrameStyle2, "FillTransparence"));
+
+ if (xmlDocPtr pXmlDoc = parseExport("styles.xml"))
+ {
+ // check that fo:background-color attribute is exported properly
+ assertXPath(pXmlDoc, "//style:style[@style:family='graphic' and @style:name='encarts']/style:graphic-properties[@fo:background-color='#ffcc99']", 1);
+ assertXPath(pXmlDoc, "//style:style[@style:family='graphic' and @style:name='Untitled1']/style:graphic-properties[@fo:background-color='transparent']", 1);
+ }
+
// paragraph style fo:background-color was wrongly inherited despite being
// overridden in derived style
uno::Reference<container::XNameAccess> xParaStyles(getStyles("ParagraphStyles"));
diff --git a/xmloff/source/draw/sdpropls.cxx b/xmloff/source/draw/sdpropls.cxx
index 45920d967ea9..442e5db00457 100644
--- a/xmloff/source/draw/sdpropls.cxx
+++ b/xmloff/source/draw/sdpropls.cxx
@@ -106,8 +106,8 @@ const XMLPropertyMapEntry aXMLSDProperties[] =
GMAP( "LineCap", XML_NAMESPACE_SVG , XML_STROKE_LINECAP, XML_SD_TYPE_LINECAP, 0 ),
// fill attributes
- GMAP( "FillStyle", XML_NAMESPACE_DRAW, XML_FILL, XML_SD_TYPE_FILLSTYLE, 0 ),
- GMAP_D("FillColor", XML_NAMESPACE_DRAW, XML_FILL_COLOR, XML_TYPE_COLOR, 0),
+ GMAP( "FillStyle", XML_NAMESPACE_DRAW, XML_FILL, XML_SD_TYPE_FILLSTYLE, CTF_FILLSTYLE ),
+ GMAP_D("FillColor", XML_NAMESPACE_DRAW, XML_FILL_COLOR, XML_TYPE_COLOR, CTF_FILLCOLOR ),
GMAP_D("FillColor2", XML_NAMESPACE_DRAW, XML_SECONDARY_FILL_COLOR, XML_TYPE_COLOR, 0),
GMAP( "FillGradientName", XML_NAMESPACE_DRAW, XML_FILL_GRADIENT_NAME, XML_TYPE_STYLENAME|MID_FLAG_NO_PROPERTY_IMPORT, CTF_FILLGRADIENTNAME ),
GMAP( "FillGradientStepCount", XML_NAMESPACE_DRAW, XML_GRADIENT_STEP_COUNT, XML_TYPE_NUMBER16, 0 ),
diff --git a/xmloff/source/text/txtimppr.cxx b/xmloff/source/text/txtimppr.cxx
index 1a0f67ef2414..7e65d799d74b 100644
--- a/xmloff/source/text/txtimppr.cxx
+++ b/xmloff/source/text/txtimppr.cxx
@@ -20,6 +20,7 @@
#include <osl/thread.h>
#include <com/sun/star/awt/FontFamily.hpp>
#include <com/sun/star/awt/FontPitch.hpp>
+#include <com/sun/star/drawing/FillStyle.hpp>
#include <com/sun/star/table/BorderLine2.hpp>
#include <com/sun/star/text/VertOrientation.hpp>
#include <com/sun/star/text/SizeType.hpp>
@@ -410,6 +411,8 @@ void XMLTextImportPropertyMapper::finished(
XMLPropertyState* pAllMargin = 0;
XMLPropertyState* pMargins[4] = { 0, 0, 0, 0 };
::std::unique_ptr<XMLPropertyState> pNewMargins[4];
+ XMLPropertyState* pFillStyle(nullptr);
+ XMLPropertyState* pFillColor(nullptr);
for( ::std::vector< XMLPropertyState >::iterator aIter = rProperties.begin();
aIter != rProperties.end();
@@ -493,6 +496,8 @@ void XMLTextImportPropertyMapper::finished(
bHasAnyWidth = true; break;
case CTF_BACKGROUND_TRANSPARENCY: pBackTransparency = property; break;
case CTF_BACKGROUND_TRANSPARENT: pBackTransparent = property; break;
+ case CTF_FILLSTYLE: pFillStyle = property; break;
+ case CTF_FILLCOLOR: pFillColor = property; break;
case CTF_PARAMARGINALL:
case CTF_PARAMARGINALL_REL:
pAllParaMargin = property; break;
@@ -655,6 +660,15 @@ void XMLTextImportPropertyMapper::finished(
pFontStyleNameCTL, pFontFamilyCTL, pFontPitchCTL, pFontCharSetCTL,
&pNewFontStyleNameCTL, &pNewFontFamilyCTL, &pNewFontPitchCTL, &pNewFontCharSetCTL );
+ if (pFillStyle && !pFillColor && pBackTransparent
+ && drawing::FillStyle_SOLID == pFillStyle->maValue.get<drawing::FillStyle>()
+ && pBackTransparent->maValue.get<bool>())
+ {
+ // fo:background="transparent", draw:fill="solid" without draw:fill-color
+ // prevent getSvxBrushItemFromSourceSet from adding bogus default color
+ pFillStyle->mnIndex = -1;
+ }
+
// #i5775# don't overwrite %transparency with binary transparency
if( ( pBackTransparency != NULL ) && ( pBackTransparent != NULL ) )
{