summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorBalazs Varga <balazs.varga991@gmail.com>2018-10-31 08:43:47 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2018-11-05 12:29:55 +0100
commit1351d5b97fd3e07c2bac1b7659726809bcb1c28d (patch)
tree3e0576c2d2a4e62e3fc36b75d9e8a92244f95dbf /oox
parentb0da1ca2d7a426ff13f39b21362fbcd5c0580c24 (diff)
tdf#108104 OOXML Import: Fix Hatch fill in Charts
Sets an explicit fill hatch, or creates a named fill hatch and stored in a global container. With this patch the SUPPORTED MS Office hatch styles by LibreOffice, or the custom LibreOffice hatches will be appeared correctly instead of the previous display as horizontal lines in LibreOffice. (The background color of the hatch styles are not imported correcty, but that is another BUG.) Change-Id: Ifda9dc805dd08f58db10b35f40d7f511a8614f77 Reviewed-on: https://gerrit.libreoffice.org/62681 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'oox')
-rw-r--r--oox/source/drawingml/chart/objectformatter.cxx14
-rw-r--r--oox/source/drawingml/shapepropertymap.cxx27
-rw-r--r--oox/source/helper/modelobjecthelper.cxx12
-rw-r--r--oox/source/ppt/slidepersist.cxx2
-rw-r--r--oox/source/token/properties.txt2
5 files changed, 45 insertions, 12 deletions
diff --git a/oox/source/drawingml/chart/objectformatter.cxx b/oox/source/drawingml/chart/objectformatter.cxx
index 2e13a0416e6a..a513fdb435a5 100644
--- a/oox/source/drawingml/chart/objectformatter.cxx
+++ b/oox/source/drawingml/chart/objectformatter.cxx
@@ -449,7 +449,8 @@ static const ShapePropertyIds spnCommonPropIds =
PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID,
PROP_FillStyle, PROP_FillColor, PROP_FillTransparence, PROP_INVALID, PROP_FillGradientName,
PROP_FillBitmapName, PROP_FillBitmapMode, PROP_FillBitmapSizeX, PROP_FillBitmapSizeY,
- PROP_FillBitmapPositionOffsetX, PROP_FillBitmapPositionOffsetY, PROP_FillBitmapRectanglePoint
+ PROP_FillBitmapPositionOffsetX, PROP_FillBitmapPositionOffsetY, PROP_FillBitmapRectanglePoint,
+ PROP_FillHatchName
};
static const ShapePropertyIds spnLinearPropIds =
@@ -458,7 +459,8 @@ static const ShapePropertyIds spnLinearPropIds =
PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID,
PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID,
PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID,
- PROP_INVALID, PROP_INVALID, PROP_INVALID
+ PROP_INVALID, PROP_INVALID, PROP_INVALID,
+ PROP_INVALID
};
static const ShapePropertyIds spnFilledPropIds =
@@ -487,15 +489,15 @@ static const ShapePropertyIds spnFilledPropIds =
PROP_FillBitmapPositionOffsetX,
PROP_FillBitmapPositionOffsetY,
PROP_FillBitmapRectanglePoint,
- PROP_FillHatch
+ PROP_HatchName
};
/** Property info for common chart objects, to be used in ShapePropertyMap. */
-static const ShapePropertyInfo saCommonPropInfo( spnCommonPropIds, false, true, true, true );
+static const ShapePropertyInfo saCommonPropInfo( spnCommonPropIds, false, true, true, true, true );
/** Property info for linear data series, to be used in ShapePropertyMap. */
-static const ShapePropertyInfo saLinearPropInfo( spnLinearPropIds, false, true, true, true );
+static const ShapePropertyInfo saLinearPropInfo( spnLinearPropIds, false, true, true, true, true );
/** Property info for filled data series, to be used in ShapePropertyMap. */
-static const ShapePropertyInfo saFilledPropInfo( spnFilledPropIds, false, true, true, true );
+static const ShapePropertyInfo saFilledPropInfo( spnFilledPropIds, false, true, true, true, true );
/** Contains information about formatting of a specific chart object type. */
struct ObjectTypeFormatEntry
diff --git a/oox/source/drawingml/shapepropertymap.cxx b/oox/source/drawingml/shapepropertymap.cxx
index fcb154901c2b..b072403d4142 100644
--- a/oox/source/drawingml/shapepropertymap.cxx
+++ b/oox/source/drawingml/shapepropertymap.cxx
@@ -22,6 +22,7 @@
#include <com/sun/star/awt/Gradient.hpp>
#include <com/sun/star/beans/NamedValue.hpp>
#include <com/sun/star/drawing/LineDash.hpp>
+#include <com/sun/star/drawing/Hatch.hpp>
#include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
#include <com/sun/star/graphic/XGraphic.hpp>
@@ -53,15 +54,16 @@ static const ShapePropertyIds spnDefaultShapeIds =
} // namespace
-ShapePropertyInfo ShapePropertyInfo::DEFAULT( spnDefaultShapeIds, true, false, false, false );
+ShapePropertyInfo ShapePropertyInfo::DEFAULT( spnDefaultShapeIds, true, false, false, false, false );
ShapePropertyInfo::ShapePropertyInfo( const ShapePropertyIds& rnPropertyIds,
- bool bNamedLineMarker, bool bNamedLineDash, bool bNamedFillGradient, bool bNamedFillBitmap ) :
+ bool bNamedLineMarker, bool bNamedLineDash, bool bNamedFillGradient, bool bNamedFillBitmap, bool bNamedFillHatch ) :
mrPropertyIds(rnPropertyIds),
mbNamedLineMarker( bNamedLineMarker ),
mbNamedLineDash( bNamedLineDash ),
mbNamedFillGradient( bNamedFillGradient ),
- mbNamedFillBitmap( bNamedFillBitmap )
+ mbNamedFillBitmap( bNamedFillBitmap ),
+ mbNamedFillHatch( bNamedFillHatch )
{
}
@@ -109,6 +111,9 @@ bool ShapePropertyMap::setAnyProperty( ShapeProperty ePropId, const Any& rValue
case ShapeProperty::FillBitmapName:
return setFillBitmapName(rValue);
+ case ShapeProperty::FillHatch:
+ return setFillHatch( nPropId, rValue );
+
default:; // suppress compiler warnings
}
@@ -168,6 +173,22 @@ bool ShapePropertyMap::setFillGradient( sal_Int32 nPropId, const Any& rValue )
return false;
}
+bool ShapePropertyMap::setFillHatch( sal_Int32 nPropId, const Any& rValue )
+{
+ // push hatch explicitly
+ if( !maShapePropInfo.mbNamedFillHatch )
+ return setAnyProperty( nPropId, rValue );
+
+ // create named hatch and push its name
+ if( rValue.has< Hatch >() )
+ {
+ OUString aHatchName = mrModelObjHelper.insertFillHatch( rValue.get< Hatch >() );
+ return !aHatchName.isEmpty() && setProperty( nPropId, aHatchName );
+ }
+
+ return false;
+}
+
bool ShapePropertyMap::setGradientTrans( sal_Int32 nPropId, const Any& rValue )
{
// create named gradient and push its name
diff --git a/oox/source/helper/modelobjecthelper.cxx b/oox/source/helper/modelobjecthelper.cxx
index 32557dd8dc1c..f8160fa6f7ed 100644
--- a/oox/source/helper/modelobjecthelper.cxx
+++ b/oox/source/helper/modelobjecthelper.cxx
@@ -22,6 +22,7 @@
#include <com/sun/star/awt/Gradient.hpp>
#include <com/sun/star/container/XNameContainer.hpp>
#include <com/sun/star/drawing/LineDash.hpp>
+#include <com/sun/star/drawing/Hatch.hpp>
#include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/graphic/XGraphic.hpp>
@@ -92,13 +93,15 @@ static const OUStringLiteral gaDashNameBase( "msLineDash " ); ///< Bas
static const OUStringLiteral gaGradientNameBase( "msFillGradient " ); ///< Base name for all named fill gradients.
static const OUStringLiteral gaTransGradNameBase( "msTransGradient " ); ///< Base name for all named fill gradients.
static const OUStringLiteral gaBitmapUrlNameBase( "msFillBitmap " ); ///< Base name for all named fill bitmap URLs.
+static const OUStringLiteral gaHatchNameBase( "msFillHatch " ); ///< Base name for all named fill hatches.
ModelObjectHelper::ModelObjectHelper( const Reference< XMultiServiceFactory >& rxModelFactory ) :
maMarkerContainer( rxModelFactory, "com.sun.star.drawing.MarkerTable" ),
maDashContainer( rxModelFactory, "com.sun.star.drawing.DashTable" ),
maGradientContainer( rxModelFactory, "com.sun.star.drawing.GradientTable" ),
- maTransGradContainer( rxModelFactory, "com.sun.star.drawing.TransparencyGradientTable" ),
- maBitmapUrlContainer( rxModelFactory, "com.sun.star.drawing.BitmapTable" )
+ maTransGradContainer( rxModelFactory, "com.sun.star.drawing.TransparencyGradientTable" ),
+ maBitmapUrlContainer( rxModelFactory, "com.sun.star.drawing.BitmapTable" ),
+ maHatchContainer( rxModelFactory, "com.sun.star.drawing.HatchTable" )
{
}
@@ -138,6 +141,11 @@ OUString ModelObjectHelper::insertFillBitmapXGraphic(uno::Reference<graphic::XGr
return OUString();
}
+OUString ModelObjectHelper::insertFillHatch( const Hatch& rHatch )
+{
+ return maHatchContainer.insertObject( gaHatchNameBase, Any( rHatch ), true );
+}
+
uno::Reference<awt::XBitmap> ModelObjectHelper::getFillBitmap(OUString const & rGraphicName)
{
uno::Reference<awt::XBitmap> xBitmap;
diff --git a/oox/source/ppt/slidepersist.cxx b/oox/source/ppt/slidepersist.cxx
index 010f582b838b..b25d00ed3529 100644
--- a/oox/source/ppt/slidepersist.cxx
+++ b/oox/source/ppt/slidepersist.cxx
@@ -172,7 +172,7 @@ void SlidePersist::createBackground( const XmlFilterBase& rFilterBase )
oox::drawingml::ShapePropertyIds aPropertyIds = oox::drawingml::ShapePropertyInfo::DEFAULT.mrPropertyIds;
aPropertyIds[oox::drawingml::ShapeProperty::FillGradient] = PROP_FillGradientName;
- oox::drawingml::ShapePropertyInfo aPropInfo( aPropertyIds, true, false, true, false );
+ oox::drawingml::ShapePropertyInfo aPropInfo( aPropertyIds, true, false, true, false, false );
oox::drawingml::ShapePropertyMap aPropMap( rFilterBase.getModelObjectHelper(), aPropInfo );
mpBackgroundPropertiesPtr->pushToPropMap( aPropMap, rFilterBase.getGraphicHelper(), 0, nPhClr );
PropertySet( mxPage ).setProperty( PROP_Background, aPropMap.makePropertySet() );
diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt
index 86dd843d12b7..1b06aa741d94 100644
--- a/oox/source/token/properties.txt
+++ b/oox/source/token/properties.txt
@@ -171,6 +171,7 @@ FillColor
FillGradient
FillGradientName
FillHatch
+FillHatchName
FillStyle
FillTransparence
FillTransparenceGradient
@@ -202,6 +203,7 @@ GapwidthSequence
GenerateVbaEvents
Geometry3D
GradientName
+HatchName
Graphic
GraphicBitmap
GraphicColorMode