summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorZolnai Tamás <tamas.zolnai@collabora.com>2014-02-13 12:54:19 +0100
committerZolnai Tamás <tamas.zolnai@collabora.com>2014-02-13 15:25:58 +0100
commitf16368777b8b03164e3485143f014486e7cc69e2 (patch)
treed30d23a9fb83be8f08545782642bfb38bc99bcbe /oox
parent4a25c65fcd7ce0852ce61dbc4956adb1cba2e54b (diff)
drawingML export: hatching of shapes
Change-Id: I7111d4064d033e27659c7b45650d596df22c593f
Diffstat (limited to 'oox')
-rw-r--r--oox/source/drawingml/drawingmltypes.cxx115
-rw-r--r--oox/source/export/drawingml.cxx28
2 files changed, 139 insertions, 4 deletions
diff --git a/oox/source/drawingml/drawingmltypes.cxx b/oox/source/drawingml/drawingmltypes.cxx
index a96eaf382ffd..70216f979ef9 100644
--- a/oox/source/drawingml/drawingmltypes.cxx
+++ b/oox/source/drawingml/drawingmltypes.cxx
@@ -252,7 +252,120 @@ TabAlign GetTabAlign( sal_Int32 aToken )
return nEnum;
}
-// --------------------------------------------------------------------
+const char* GetHatchPattern( const Hatch& rHatch )
+{
+ const char* sPattern = 0;
+ const sal_Int32 nAngle = rHatch.Angle > 1800 ? rHatch.Angle - 1800 : rHatch.Angle;
+ // Angle ~ 0° (horizontal)
+ if( (nAngle >= 0 && nAngle < 225) || nAngle >= 1575 )
+ {
+ switch( rHatch.Style )
+ {
+ case HatchStyle_SINGLE:
+ {
+ if( rHatch.Distance < 75 )
+ sPattern = "ltHorz";
+ else
+ sPattern = "horz";
+
+ break;
+ }
+ case HatchStyle_DOUBLE:
+ case HatchStyle_TRIPLE:
+ {
+ if( rHatch.Distance < 75 )
+ sPattern = "smGrid";
+ else
+ sPattern = "lgGrid";
+
+ break;
+ }
+ default: break;
+ }
+ }
+ // Angle ~ 45° (upward diagonal)
+ else if( nAngle < 675 )
+ {
+ switch( rHatch.Style )
+ {
+ case HatchStyle_SINGLE:
+ {
+ if( rHatch.Distance < 75 )
+ sPattern = "ltUpDiag";
+ else
+ sPattern = "wdUpDiag";
+
+ break;
+ }
+ case HatchStyle_DOUBLE:
+ case HatchStyle_TRIPLE:
+ {
+ if( rHatch.Distance < 75 )
+ sPattern = "smCheck";
+ else
+ sPattern = "openDmnd";
+
+ break;
+ }
+ default: break;
+ }
+ }
+ // Angle ~ 90° (vertical)
+ else if( nAngle < 1125 )
+ {
+ switch( rHatch.Style )
+ {
+ case HatchStyle_SINGLE:
+ {
+ if( rHatch.Distance < 75 )
+ sPattern = "ltVert";
+ else
+ sPattern = "vert";
+
+ break;
+ }
+ case HatchStyle_DOUBLE:
+ case HatchStyle_TRIPLE:
+ {
+ if( rHatch.Distance < 75 )
+ sPattern = "smGrid";
+ else
+ sPattern = "lgGrid";
+
+ break;
+ }
+ default: break;
+ }
+ }
+ // Angle ~ 135° (downward diagonal)
+ else if( nAngle < 1575 )
+ {
+ switch( rHatch.Style )
+ {
+ case HatchStyle_SINGLE:
+ {
+ if( rHatch.Distance < 75 )
+ sPattern = "ltDnDiag";
+ else
+ sPattern = "wdDnDiag";
+
+ break;
+ }
+ case HatchStyle_DOUBLE:
+ case HatchStyle_TRIPLE:
+ {
+ if( rHatch.Distance < 75 )
+ sPattern = "smCheck";
+ else
+ sPattern = "openDmnd";
+
+ break;
+ }
+ default: break;
+ }
+ }
+ return sPattern;
+}
/** converts the attributes from a CT_RelativeRect to an IntegerRectangle2D */
IntegerRectangle2D GetRelativeRect( const Reference< XFastAttributeList >& xAttribs )
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 3e869854adcf..bdec63d80e1a 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -881,6 +881,28 @@ void DrawingML::WriteBlipFill( Reference< XPropertySet > rXPropSet, OUString sBi
}
}
+void DrawingML::WritePattFill( Reference< XPropertySet > rXPropSet )
+{
+ if ( GetProperty( rXPropSet, "FillHatch" ) )
+ {
+ drawing::Hatch aHatch;
+ mAny >>= aHatch;
+
+ mpFS->startElementNS( XML_a , XML_pattFill, XML_prst, GetHatchPattern(aHatch), FSEND );
+
+ mpFS->startElementNS( XML_a , XML_fgClr, FSEND );
+ WriteColor(aHatch.Color);
+ mpFS->endElementNS( XML_a , XML_fgClr );
+
+ // In Writer hatching has no background so use white as a default value.
+ mpFS->startElementNS( XML_a , XML_bgClr, FSEND );
+ WriteColor(COL_WHITE);
+ mpFS->endElementNS( XML_a , XML_bgClr );
+
+ mpFS->endElementNS( XML_a , XML_pattFill );
+ }
+}
+
void DrawingML::WriteSrcRect( Reference< XPropertySet > rXPropSet, const OUString& rURL )
{
Size aOriginalSize( GraphicObject::CreateGraphicObjectFromURL( rURL ).GetPrefSize() );
@@ -1885,9 +1907,6 @@ void DrawingML::WriteFill( Reference< XPropertySet > xPropSet )
FillStyle aFillStyle( FillStyle_NONE );
xPropSet->getPropertyValue( "FillStyle" ) >>= aFillStyle;
- if( aFillStyle == FillStyle_HATCH )
- return;
-
if ( aFillStyle == FillStyle_SOLID && GetProperty( xPropSet, "FillTransparence" ) )
{
// map full transparent background to no fill
@@ -1908,6 +1927,9 @@ void DrawingML::WriteFill( Reference< XPropertySet > xPropSet )
case FillStyle_BITMAP :
WriteBlipFill( xPropSet, "FillBitmapURL" );
break;
+ case FillStyle_HATCH :
+ WritePattFill( xPropSet );
+ break;
case FillStyle_NONE:
mpFS->singleElementNS( XML_a, XML_noFill, FSEND );
break;