summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorMatúš Kukan <matus.kukan@collabora.com>2014-09-09 10:37:23 +0200
committerMatúš Kukan <matus.kukan@collabora.com>2014-09-09 11:05:56 +0200
commit43efd9b40d40b791a2c2deedcac36b99f7efb2cf (patch)
tree39856f63c35024a0273534479cc528cdac57ff50 /oox
parent24077ffc063990f9de11c6819432219a59d809f8 (diff)
bnc#480256: OOXML import: Respect table background properties a bit more
Only getBackgroundFillProperties() (fill) was used. Use also getBackgroundFillStyleRef() (fillRef). Also, do not replace table background color value with cell color, we have to interpolate the two colors (if cell color is transparent). Unfortunately, we don't use background table property in LibreOffice, so this seems to be a best workaround. Change-Id: I21bcc87a149c9f6d865ebee4012132ccc3a54af2
Diffstat (limited to 'oox')
-rw-r--r--oox/source/drawingml/fillproperties.cxx8
-rw-r--r--oox/source/drawingml/table/tablebackgroundstylecontext.cxx1
-rw-r--r--oox/source/drawingml/table/tablecell.cxx34
3 files changed, 37 insertions, 6 deletions
diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx
index 83ab6a42c03e..8401d7a294fb 100644
--- a/oox/source/drawingml/fillproperties.cxx
+++ b/oox/source/drawingml/fillproperties.cxx
@@ -222,7 +222,13 @@ Color FillProperties::getBestSolidColor() const
break;
case XML_gradFill:
if( !maGradientProps.maGradientStops.empty() )
- aSolidColor = maGradientProps.maGradientStops.begin()->second;
+ {
+ GradientFillProperties::GradientStopMap::const_iterator aGradientStop =
+ maGradientProps.maGradientStops.begin();
+ if (maGradientProps.maGradientStops.size() > 2)
+ ++aGradientStop;
+ aSolidColor = aGradientStop->second;
+ }
break;
case XML_pattFill:
aSolidColor = maPatternProps.maPattBgColor.isUsed() ? maPatternProps.maPattBgColor : maPatternProps.maPattFgColor;
diff --git a/oox/source/drawingml/table/tablebackgroundstylecontext.cxx b/oox/source/drawingml/table/tablebackgroundstylecontext.cxx
index a91da191476a..4e4cf3cd1091 100644
--- a/oox/source/drawingml/table/tablebackgroundstylecontext.cxx
+++ b/oox/source/drawingml/table/tablebackgroundstylecontext.cxx
@@ -34,6 +34,7 @@ TableBackgroundStyleContext::TableBackgroundStyleContext( ContextHandler2Helper&
: ContextHandler2( rParent )
, mrTableStyle( rTableStyle )
{
+ mrTableStyle.getBackgroundFillStyleRef().mnThemedIdx = 0;
}
TableBackgroundStyleContext::~TableBackgroundStyleContext()
diff --git a/oox/source/drawingml/table/tablecell.cxx b/oox/source/drawingml/table/tablecell.cxx
index 033434a7a49c..40533259b9b3 100644
--- a/oox/source/drawingml/table/tablecell.cxx
+++ b/oox/source/drawingml/table/tablecell.cxx
@@ -19,10 +19,13 @@
#include "drawingml/table/tablecell.hxx"
#include "drawingml/table/tableproperties.hxx"
+#include <basegfx/color/bcolor.hxx>
#include "oox/drawingml/shapepropertymap.hxx"
#include "oox/drawingml/textbody.hxx"
+#include "oox/drawingml/theme.hxx"
#include "oox/core/xmlfilterbase.hxx"
#include "oox/helper/propertyset.hxx"
+#include <tools/color.hxx>
#include <com/sun/star/container/XNameContainer.hpp>
#include <com/sun/star/beans/XMultiPropertySet.hpp>
#include <com/sun/star/table/XTable.hpp>
@@ -99,7 +102,7 @@ void applyTableStylePart( oox::drawingml::FillProperties& rFillProperties,
oox::drawingml::LineProperties& rBottomLeftToTopRightBorder,
TableStylePart& rTableStylePart )
{
- boost::shared_ptr< ::oox::drawingml::FillProperties >& rPartFillPropertiesPtr( rTableStylePart.getFillProperties() );
+ ::oox::drawingml::FillPropertiesPtr& rPartFillPropertiesPtr( rTableStylePart.getFillProperties() );
if ( rPartFillPropertiesPtr.get() )
rFillProperties.assignUsed( *rPartFillPropertiesPtr );
@@ -168,10 +171,6 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, ::oo
oox::drawingml::LineProperties aLinePropertiesTopLeftToBottomRight;
oox::drawingml::LineProperties aLinePropertiesBottomLeftToTopRight;
- boost::shared_ptr< ::oox::drawingml::FillProperties >& rBackgroundFillPropertiesPtr( rTable.getBackgroundFillProperties() );
- if ( rBackgroundFillPropertiesPtr.get() )
- aFillProperties.assignUsed( *rBackgroundFillPropertiesPtr );
-
applyTableStylePart( aFillProperties, aTextStyleProps,
aLinePropertiesLeft,
aLinePropertiesRight,
@@ -352,6 +351,31 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, ::oo
aFillProperties.assignUsed( maFillProperties );
ShapePropertyMap aPropMap( rFilterBase.getModelObjectHelper() );
+
+ Color aBgColor;
+ sal_Int32 nPhClr = API_RGB_TRANSPARENT;
+ boost::shared_ptr< ::oox::drawingml::FillProperties >& rBackgroundFillPropertiesPtr( rTable.getBackgroundFillProperties() );
+ ::oox::drawingml::ShapeStyleRef& rBackgroundFillStyle( rTable.getBackgroundFillStyleRef() );
+ if (rBackgroundFillPropertiesPtr.get())
+ aBgColor = rBackgroundFillPropertiesPtr->getBestSolidColor();
+ else if (rBackgroundFillStyle.mnThemedIdx != 0)
+ if (const Theme* pTheme = rFilterBase.getCurrentTheme())
+ {
+ aBgColor = pTheme->getFillStyle(rBackgroundFillStyle.mnThemedIdx)->getBestSolidColor();
+ nPhClr = rBackgroundFillStyle.maPhClr.getColor(rFilterBase.getGraphicHelper());
+ }
+ if (aBgColor.isUsed())
+ {
+ const Color& rCellColor = aFillProperties.getBestSolidColor();
+ const double fTransparency = rCellColor.isUsed() ? 0.01 * rCellColor.getTransparency() : 1.0;
+ ::Color nBgColor( aBgColor.getColor(rFilterBase.getGraphicHelper(), nPhClr) );
+ ::Color nCellColor( rCellColor.getColor(rFilterBase.getGraphicHelper()) );
+ ::Color aResult( basegfx::interpolate(nBgColor.getBColor(), nCellColor.getBColor(), 1.0 - fTransparency) );
+ aFillProperties.maFillColor.clearTransformations();
+ aFillProperties.maFillColor.setSrgbClr(aResult.GetRGBColor());
+ aFillProperties.moFillType.set(XML_solidFill);
+ }
+
// TODO: phClr?
aFillProperties.pushToPropMap( aPropMap, rFilterBase.getGraphicHelper() );
PropertySet( xPropSet ).setProperties( aPropMap );