summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorVinaya Mandke <vinaya.mandke@synerzip.com>2014-01-29 12:40:01 +0530
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2014-02-12 02:40:06 +0100
commita5f0344b410e2fbf1e80b18fa6d5094f44cc06bc (patch)
treefecf43e544951226797c92d6ba70f9454397c652 /oox
parentf0d232f7b78edc3a0acff6d2beee97ff8bb2bd94 (diff)
fdo#74115 Fix for DOCX GradientFill for Chart Wall
Fixed import and export for chart wall Gradient Fill in DOCX Added UT for the same. Conflicts: chart2/qa/extras/chart2export.cxx Change-Id: Ie6caa2b238aeb70f7225145da8c5c78003e73002
Diffstat (limited to 'oox')
-rw-r--r--oox/source/drawingml/chart/objectformatter.cxx2
-rw-r--r--oox/source/export/chartexport.cxx61
-rw-r--r--oox/source/export/drawingml.cxx178
3 files changed, 154 insertions, 87 deletions
diff --git a/oox/source/drawingml/chart/objectformatter.cxx b/oox/source/drawingml/chart/objectformatter.cxx
index 29cc07b6e9ec..a840381df2cc 100644
--- a/oox/source/drawingml/chart/objectformatter.cxx
+++ b/oox/source/drawingml/chart/objectformatter.cxx
@@ -467,7 +467,7 @@ static const sal_Int32 spnCommonPropIds[] =
{
PROP_LineStyle, PROP_LineWidth, PROP_LineColor, PROP_LineTransparence, PROP_LineDashName,
PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID,
- PROP_FillStyle, PROP_FillColor, PROP_FillTransparence, PROP_FillGradientName,
+ PROP_FillStyle, PROP_FillColor, PROP_FillTransparence, PROP_INVALID, PROP_FillGradientName,
PROP_FillBitmapName, PROP_FillBitmapMode, PROP_FillBitmapSizeX, PROP_FillBitmapSizeY,
PROP_FillBitmapPositionOffsetX, PROP_FillBitmapPositionOffsetY, PROP_FillBitmapRectanglePoint
};
diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx
index ed5ea8bc9e46..4d8d931a4541 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -25,6 +25,7 @@
#include <cstdio>
+#include <com/sun/star/awt/Gradient.hpp>
#include <com/sun/star/chart/XChartDocument.hpp>
#include <com/sun/star/chart/ChartLegendPosition.hpp>
#include <com/sun/star/chart/XTwoAxisXSupplier.hpp>
@@ -1124,19 +1125,77 @@ void ChartExport::exportPlotArea( )
exportDataTable();
// shape properties
+ /*
+ * Export the Plot area Shape Properties
+ * eg: Fill and Outline
+ */
Reference< ::com::sun::star::chart::X3DDisplay > xWallFloorSupplier( mxDiagram, uno::UNO_QUERY );
if( xWallFloorSupplier.is() )
{
Reference< beans::XPropertySet > xWallPropSet( xWallFloorSupplier->getWall(), uno::UNO_QUERY );
if( xWallPropSet.is() )
{
- exportShapeProps( xWallPropSet );
+ exportPlotAreaShapeProps( xWallPropSet );
}
}
+
pFS->endElement( FSNS( XML_c, XML_plotArea ) );
}
+void ChartExport::exportPlotAreaShapeProps( Reference< XPropertySet > xPropSet )
+{
+ FSHelperPtr pFS = GetFS();
+ pFS->startElement( FSNS( XML_c, XML_spPr ),
+ FSEND );
+
+ exportFill( xPropSet );
+ WriteOutline( xPropSet );
+
+ pFS->endElement( FSNS( XML_c, XML_spPr ) );
+}
+
+void ChartExport::exportFill( Reference< XPropertySet > xPropSet )
+{
+ if ( !GetProperty( xPropSet, "FillStyle" ) )
+ return;
+ FillStyle aFillStyle( FillStyle_NONE );
+ xPropSet->getPropertyValue( "FillStyle" ) >>= aFillStyle;
+ switch( aFillStyle )
+ {
+ case FillStyle_GRADIENT :
+ exportGradientFill( xPropSet );
+ default:
+ WriteFill( xPropSet );
+ }
+}
+
+void ChartExport::exportGradientFill( Reference< XPropertySet > xPropSet )
+{
+ if( xPropSet.is() )
+ {
+ OUString sFillGradientName;
+ xPropSet->getPropertyValue("FillGradientName") >>= sFillGradientName;
+
+ awt::Gradient aGradient;
+ uno::Reference< lang::XMultiServiceFactory > xFact( getModel(), uno::UNO_QUERY );
+ try
+ {
+ uno::Reference< container::XNameAccess > xGradient( xFact->createInstance("com.sun.star.drawing.GradientTable"), uno::UNO_QUERY );
+ uno::Any rValue = xGradient->getByName( sFillGradientName );
+ if( (rValue >>= aGradient) )
+ {
+ WriteGradientFill( aGradient );
+ }
+ }
+ catch( const uno::Exception & rEx )
+ {
+ DBG_WARNING( "Gradient Property not Found; ChartExport::exportPlotAreaGradientFill" );
+ }
+
+ }
+}
+
void ChartExport::exportDataTable( )
{
FSHelperPtr pFS = GetFS();
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 0f95e7018c62..1584356fc767 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -338,102 +338,110 @@ void DrawingML::WriteGradientFill( Reference< XPropertySet > rXPropSet )
aGrabBag[i].Value >>= aOriginalGradient;
}
- mpFS->startElementNS( XML_a, XML_gradFill, FSEND );
-
// check if an ooxml gradient had been imported and if the user has modified it
if( aGradientStops.hasElements() && EqualGradients( aOriginalGradient, aGradient ) )
{
- // write back the original gradient
- mpFS->startElementNS( XML_a, XML_gsLst, FSEND );
+ WriteGrabBagGradientFill(aGradientStops, aGradient);
+ }
+ else
+ WriteGradientFill(aGradient);
+ }
+}
+void DrawingML::WriteGrabBagGradientFill( Sequence< PropertyValue > aGradientStops, awt::Gradient rGradient )
+{
+ mpFS->startElementNS( XML_a, XML_gradFill, FSEND );
+ // write back the original gradient
+ mpFS->startElementNS( XML_a, XML_gsLst, FSEND );
- // get original stops and write them
- for( sal_Int32 i=0; i < aGradientStops.getLength(); ++i )
- {
- Sequence< PropertyValue > aGradientStop;
- aGradientStops[i].Value >>= aGradientStop;
-
- // get values
- OUString sSchemeClr;
- double nPos = 0;
- sal_Int16 nTransparency = 0;
- sal_Int32 nRgbClr = 0;
- Sequence< PropertyValue > aTransformations;
- for( sal_Int32 j=0; j < aGradientStop.getLength(); ++j )
- if( aGradientStop[j].Name == "SchemeClr" )
- aGradientStop[j].Value >>= sSchemeClr;
- else if( aGradientStop[j].Name == "RgbClr" )
- aGradientStop[j].Value >>= nRgbClr;
- else if( aGradientStop[j].Name == "Pos" )
- aGradientStop[j].Value >>= nPos;
- else if( aGradientStop[j].Name == "Transparency" )
- aGradientStop[j].Value >>= nTransparency;
- else if( aGradientStop[j].Name == "Transformations" )
- aGradientStop[j].Value >>= aTransformations;
-
- // write stop
- mpFS->startElementNS( XML_a, XML_gs,
- XML_pos, OString::number( nPos * 100000.0 ).getStr(),
- FSEND );
- if( sSchemeClr.isEmpty() )
- {
- // Calculate alpha value (see oox/source/drawingml/color.cxx : getTransparency())
- sal_Int32 nAlpha = (MAX_PERCENT - ( PER_PERCENT * nTransparency ) );
- WriteColor( nRgbClr, nAlpha );
- }
- else
- WriteColor( sSchemeClr, aTransformations );
- mpFS->endElementNS( XML_a, XML_gs );
- }
- mpFS->endElementNS( XML_a, XML_gsLst );
+ // get original stops and write them
+ for( sal_Int32 i=0; i < aGradientStops.getLength(); ++i )
+ {
+ Sequence< PropertyValue > aGradientStop;
+ aGradientStops[i].Value >>= aGradientStop;
- mpFS->singleElementNS( XML_a, XML_lin,
- XML_ang, I32S( ( ( ( 3600 - aGradient.Angle + 900 ) * 6000 ) % 21600000 ) ),
- FSEND );
+ // get values
+ OUString sSchemeClr;
+ double nPos = 0;
+ sal_Int16 nTransparency = 0;
+ sal_Int32 nRgbClr = 0;
+ Sequence< PropertyValue > aTransformations;
+ for( sal_Int32 j=0; j < aGradientStop.getLength(); ++j )
+ if( aGradientStop[j].Name == "SchemeClr" )
+ aGradientStop[j].Value >>= sSchemeClr;
+ else if( aGradientStop[j].Name == "RgbClr" )
+ aGradientStop[j].Value >>= nRgbClr;
+ else if( aGradientStop[j].Name == "Pos" )
+ aGradientStop[j].Value >>= nPos;
+ else if( aGradientStop[j].Name == "Transparency" )
+ aGradientStop[j].Value >>= nTransparency;
+ else if( aGradientStop[j].Name == "Transformations" )
+ aGradientStop[j].Value >>= aTransformations;
+
+ // write stop
+ mpFS->startElementNS( XML_a, XML_gs,
+ XML_pos, OString::number( nPos * 100000.0 ).getStr(),
+ FSEND );
+ if( sSchemeClr.isEmpty() )
+ {
+ // Calculate alpha value (see oox/source/drawingml/color.cxx : getTransparency())
+ sal_Int32 nAlpha = (MAX_PERCENT - ( PER_PERCENT * nTransparency ) );
+ WriteColor( nRgbClr, nAlpha );
}
else
- switch( aGradient.Style ) {
- default:
- case GradientStyle_LINEAR:
- mpFS->startElementNS( XML_a, XML_gsLst, FSEND );
- WriteGradientStop( 0, ColorWithIntensity( aGradient.StartColor, aGradient.StartIntensity ) );
- WriteGradientStop( 100, ColorWithIntensity( aGradient.EndColor, aGradient.EndIntensity ) );
- mpFS->endElementNS( XML_a, XML_gsLst );
- mpFS->singleElementNS( XML_a, XML_lin,
- XML_ang, I32S( ( ( ( 3600 - aGradient.Angle + 900 ) * 6000 ) % 21600000 ) ),
- FSEND );
- break;
+ WriteColor( sSchemeClr, aTransformations );
+ mpFS->endElementNS( XML_a, XML_gs );
+ }
+ mpFS->endElementNS( XML_a, XML_gsLst );
- case GradientStyle_AXIAL:
- mpFS->startElementNS( XML_a, XML_gsLst, FSEND );
- WriteGradientStop( 0, ColorWithIntensity( aGradient.EndColor, aGradient.EndIntensity ) );
- WriteGradientStop( 50, ColorWithIntensity( aGradient.StartColor, aGradient.StartIntensity ) );
- WriteGradientStop( 100, ColorWithIntensity( aGradient.EndColor, aGradient.EndIntensity ) );
- mpFS->endElementNS( XML_a, XML_gsLst );
- mpFS->singleElementNS( XML_a, XML_lin,
- XML_ang, I32S( ( ( ( 3600 - aGradient.Angle + 900 ) * 6000 ) % 21600000 ) ),
- FSEND );
- break;
+ mpFS->singleElementNS( XML_a, XML_lin,
+ XML_ang, I32S( ( ( ( 3600 - rGradient.Angle + 900 ) * 6000 ) % 21600000 ) ),
+ FSEND );
+ mpFS->endElementNS( XML_a, XML_gradFill );
+}
- /* I don't see how to apply transformation to gradients, so
- * elliptical will end as radial and square as
- * rectangular. also position offsets are not applied */
- case GradientStyle_RADIAL:
- case GradientStyle_ELLIPTICAL:
- case GradientStyle_RECT:
- case GradientStyle_SQUARE:
- mpFS->startElementNS( XML_a, XML_gsLst, FSEND );
- WriteGradientStop( 0, ColorWithIntensity( aGradient.EndColor, aGradient.EndIntensity ) );
- WriteGradientStop( 100, ColorWithIntensity( aGradient.StartColor, aGradient.StartIntensity ) );
- mpFS->endElementNS( XML_a, XML_gsLst );
- mpFS->singleElementNS( XML_a, XML_path,
- XML_path, ( aGradient.Style == awt::GradientStyle_RADIAL || aGradient.Style == awt::GradientStyle_ELLIPTICAL ) ? "circle" : "rect",
- FSEND );
- break;
- }
+void DrawingML::WriteGradientFill( awt::Gradient rGradient )
+{
+ mpFS->startElementNS( XML_a, XML_gradFill, FSEND );
+ switch( rGradient.Style ) {
+ default:
+ case GradientStyle_LINEAR:
+ mpFS->startElementNS( XML_a, XML_gsLst, FSEND );
+ WriteGradientStop( 0, ColorWithIntensity( rGradient.StartColor, rGradient.StartIntensity ) );
+ WriteGradientStop( 100, ColorWithIntensity( rGradient.EndColor, rGradient.EndIntensity ) );
+ mpFS->endElementNS( XML_a, XML_gsLst );
+ mpFS->singleElementNS( XML_a, XML_lin,
+ XML_ang, I32S( ( ( ( 3600 - rGradient.Angle + 900 ) * 6000 ) % 21600000 ) ),
+ FSEND );
+ break;
- mpFS->endElementNS( XML_a, XML_gradFill );
- }
+ case GradientStyle_AXIAL:
+ mpFS->startElementNS( XML_a, XML_gsLst, FSEND );
+ WriteGradientStop( 0, ColorWithIntensity( rGradient.EndColor, rGradient.EndIntensity ) );
+ WriteGradientStop( 50, ColorWithIntensity( rGradient.StartColor, rGradient.StartIntensity ) );
+ WriteGradientStop( 100, ColorWithIntensity( rGradient.EndColor, rGradient.EndIntensity ) );
+ mpFS->endElementNS( XML_a, XML_gsLst );
+ mpFS->singleElementNS( XML_a, XML_lin,
+ XML_ang, I32S( ( ( ( 3600 - rGradient.Angle + 900 ) * 6000 ) % 21600000 ) ),
+ FSEND );
+ break;
+ /* I don't see how to apply transformation to gradients, so
+ * elliptical will end as radial and square as
+ * rectangular. also position offsets are not applied */
+ case GradientStyle_RADIAL:
+ case GradientStyle_ELLIPTICAL:
+ case GradientStyle_RECT:
+ case GradientStyle_SQUARE:
+ mpFS->startElementNS( XML_a, XML_gsLst, FSEND );
+ WriteGradientStop( 0, ColorWithIntensity( rGradient.EndColor, rGradient.EndIntensity ) );
+ WriteGradientStop( 100, ColorWithIntensity( rGradient.StartColor, rGradient.StartIntensity ) );
+ mpFS->endElementNS( XML_a, XML_gsLst );
+ mpFS->singleElementNS( XML_a, XML_path,
+ XML_path, ( rGradient.Style == awt::GradientStyle_RADIAL || rGradient.Style == awt::GradientStyle_ELLIPTICAL ) ? "circle" : "rect",
+ FSEND );
+ break;
+ }
+ mpFS->endElementNS( XML_a, XML_gradFill );
}
void DrawingML::WriteLineArrow( Reference< XPropertySet > rXPropSet, sal_Bool bLineStart )