Kaydet (Commit) 68e756de authored tarafından Muthu Subramanian's avatar Muthu Subramanian

n#657896 - Gradient Transparencies and Muticolor Gradient fills.

- Assumes axial gradient fills when more than 3 colors are present.
- Implements importing of Transparency Gradients.
üst a54cb659
...@@ -59,6 +59,7 @@ enum ShapePropertyId ...@@ -59,6 +59,7 @@ enum ShapePropertyId
SHAPEPROP_FillStyle, SHAPEPROP_FillStyle,
SHAPEPROP_FillColor, SHAPEPROP_FillColor,
SHAPEPROP_FillTransparency, SHAPEPROP_FillTransparency,
SHAPEPROP_GradientTransparency,
SHAPEPROP_FillGradient, /// Explicit fill gradient or name of a fill gradient stored in a global container. SHAPEPROP_FillGradient, /// Explicit fill gradient or name of a fill gradient stored in a global container.
SHAPEPROP_FillBitmapUrl, /// Explicit fill bitmap URL or name of a fill bitmap URL stored in a global container. SHAPEPROP_FillBitmapUrl, /// Explicit fill bitmap URL or name of a fill bitmap URL stored in a global container.
SHAPEPROP_FillBitmapMode, SHAPEPROP_FillBitmapMode,
...@@ -128,6 +129,8 @@ private: ...@@ -128,6 +129,8 @@ private:
bool setLineDash( sal_Int32 nPropId, const ::com::sun::star::uno::Any& rValue ); bool setLineDash( sal_Int32 nPropId, const ::com::sun::star::uno::Any& rValue );
/** Sets an explicit fill gradient, or creates a named fill gradient. */ /** Sets an explicit fill gradient, or creates a named fill gradient. */
bool setFillGradient( sal_Int32 nPropId, const ::com::sun::star::uno::Any& rValue ); bool setFillGradient( sal_Int32 nPropId, const ::com::sun::star::uno::Any& rValue );
/** Creates a named transparency gradient. */
bool setGradientTrans( sal_Int32 nPropId, const ::com::sun::star::uno::Any& rValue );
/** Sets an explicit fill bitmap URL, or creates a named fill bitmap URL. */ /** Sets an explicit fill bitmap URL, or creates a named fill bitmap URL. */
bool setFillBitmapUrl( sal_Int32 nPropId, const ::com::sun::star::uno::Any& rValue ); bool setFillBitmapUrl( sal_Int32 nPropId, const ::com::sun::star::uno::Any& rValue );
......
...@@ -109,6 +109,8 @@ public: ...@@ -109,6 +109,8 @@ public:
an internal constant name with a new unused index appended. */ an internal constant name with a new unused index appended. */
::rtl::OUString insertFillGradient( const ::com::sun::star::awt::Gradient& rGradient ); ::rtl::OUString insertFillGradient( const ::com::sun::star::awt::Gradient& rGradient );
::rtl::OUString insertTransGrandient( const ::com::sun::star::awt::Gradient& rGradient );
/** Inserts a new named fill bitmap URL, returns the bitmap name, based on /** Inserts a new named fill bitmap URL, returns the bitmap name, based on
an internal constant name with a new unused index appended. */ an internal constant name with a new unused index appended. */
::rtl::OUString insertFillBitmapUrl( const ::rtl::OUString& rGraphicUrl ); ::rtl::OUString insertFillBitmapUrl( const ::rtl::OUString& rGraphicUrl );
...@@ -117,9 +119,11 @@ private: ...@@ -117,9 +119,11 @@ private:
ObjectContainer maMarkerContainer; /// Contains all named line markers (line end polygons). ObjectContainer maMarkerContainer; /// Contains all named line markers (line end polygons).
ObjectContainer maDashContainer; /// Contains all named line dsahes. ObjectContainer maDashContainer; /// Contains all named line dsahes.
ObjectContainer maGradientContainer; /// Contains all named fill gradients. ObjectContainer maGradientContainer; /// Contains all named fill gradients.
ObjectContainer maTransGradContainer; /// Contains all named transparency Gradients.
ObjectContainer maBitmapUrlContainer; /// Contains all named fill bitmap URLs. ObjectContainer maBitmapUrlContainer; /// Contains all named fill bitmap URLs.
const ::rtl::OUString maDashNameBase; /// Base name for all named line dashes. const ::rtl::OUString maDashNameBase; /// Base name for all named line dashes.
const ::rtl::OUString maGradientNameBase; /// Base name for all named fill gradients. const ::rtl::OUString maGradientNameBase; /// Base name for all named fill gradients.
const ::rtl::OUString maTransGradNameBase; /// Base name for all named fill gradients.
const ::rtl::OUString maBitmapUrlNameBase; /// Base name for all named fill bitmap URLs. const ::rtl::OUString maBitmapUrlNameBase; /// Base name for all named fill bitmap URLs.
}; };
......
...@@ -217,6 +217,8 @@ void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap, ...@@ -217,6 +217,8 @@ void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap,
// do not create gradient struct if property is not supported... // do not create gradient struct if property is not supported...
if( rPropMap.supportsProperty( SHAPEPROP_FillGradient ) ) if( rPropMap.supportsProperty( SHAPEPROP_FillGradient ) )
{ {
sal_Int32 nEndTrans = 0;
sal_Int32 nStartTrans = 0;
awt::Gradient aGradient; awt::Gradient aGradient;
aGradient.Angle = 900; aGradient.Angle = 900;
aGradient.StartIntensity = 100; aGradient.StartIntensity = 100;
...@@ -227,6 +229,10 @@ void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap, ...@@ -227,6 +229,10 @@ void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap,
{ {
aGradient.StartColor = maGradientProps.maGradientStops.begin()->second.getColor( rGraphicHelper, nPhClr ); aGradient.StartColor = maGradientProps.maGradientStops.begin()->second.getColor( rGraphicHelper, nPhClr );
aGradient.EndColor = maGradientProps.maGradientStops.rbegin()->second.getColor( rGraphicHelper, nPhClr ); aGradient.EndColor = maGradientProps.maGradientStops.rbegin()->second.getColor( rGraphicHelper, nPhClr );
if( maGradientProps.maGradientStops.rbegin()->second.hasTransparency() )
nEndTrans = maGradientProps.maGradientStops.rbegin()->second.getTransparency()*255/100;
if( maGradientProps.maGradientStops.begin()->second.hasTransparency() )
nStartTrans = maGradientProps.maGradientStops.begin()->second.getTransparency()*255/100;
} }
// "rotate with shape" not set, or set to false -> do not rotate // "rotate with shape" not set, or set to false -> do not rotate
...@@ -244,29 +250,55 @@ void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap, ...@@ -244,29 +250,55 @@ void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap,
sal_Int32 nCenterY = (MAX_PERCENT + aFillToRect.Y1 - aFillToRect.Y2) / 2; sal_Int32 nCenterY = (MAX_PERCENT + aFillToRect.Y1 - aFillToRect.Y2) / 2;
aGradient.YOffset = getLimitedValue< sal_Int16, sal_Int32 >( nCenterY / PER_PERCENT, 30, 70 ); aGradient.YOffset = getLimitedValue< sal_Int16, sal_Int32 >( nCenterY / PER_PERCENT, 30, 70 );
::std::swap( aGradient.StartColor, aGradient.EndColor ); ::std::swap( aGradient.StartColor, aGradient.EndColor );
::std::swap( nStartTrans, nEndTrans );
nDmlAngle = nShapeRotation; nDmlAngle = nShapeRotation;
} }
else else
{ {
/* Try to detect a VML axial gradient. This type of /* Try to detect a VML axial gradient. This type of
gradient is simulated by a 3-point linear gradient gradient is simulated by a 3-point linear gradient.
with equal start and end color. */ Even if its a multi-color linear gradient, its probably better to assume
bool bAxial = (nColorCount == 3) && (aGradient.StartColor == aGradient.EndColor); axial gradient, when there are 3 or more points.
*/
bool bAxial = (nColorCount >= 3);
aGradient.Style = bAxial ? awt::GradientStyle_AXIAL : awt::GradientStyle_LINEAR; aGradient.Style = bAxial ? awt::GradientStyle_AXIAL : awt::GradientStyle_LINEAR;
nDmlAngle = maGradientProps.moShadeAngle.get( 0 ) - nShapeRotation;
// convert DrawingML angle (in 1/60000 degrees) to API angle (in 1/10 degrees)
aGradient.Angle = static_cast< sal_Int16 >( (4500 - (nDmlAngle / (PER_DEGREE / 10))) % 3600 );
if( bAxial ) if( bAxial )
{ {
GradientFillProperties::GradientStopMap::const_iterator aIt = maGradientProps.maGradientStops.begin(); GradientFillProperties::GradientStopMap::const_iterator aIt = maGradientProps.maGradientStops.begin();
// Try to find the axial median
for(size_t i=0;i<nColorCount;i+=3)
aIt++;
// API StartColor is inner color in axial gradient // API StartColor is inner color in axial gradient
aGradient.StartColor = (++aIt)->second.getColor( rGraphicHelper, nPhClr ); // aIt->second.hasColor() kind would be better than Color != API_RGB_WHITE
if( aGradient.StartColor == aGradient.EndColor &&
( !aIt->second.hasTransparency() || aIt->second.getColor( rGraphicHelper, nPhClr ) != API_RGB_WHITE ) )
{
aGradient.StartColor = aIt->second.getColor( rGraphicHelper, nPhClr );
}
if( nStartTrans == nEndTrans && aIt->second.hasTransparency() )
nStartTrans = aIt->second.getTransparency()*255/100;
} }
nDmlAngle = maGradientProps.moShadeAngle.get( 0 ) - nShapeRotation;
} }
// convert DrawingML angle (in 1/60000 degrees) to API angle (in 1/10 degrees)
aGradient.Angle = static_cast< sal_Int16 >( (4500 - (nDmlAngle / (PER_DEGREE / 10))) % 3600 );
// push gradient or named gradient to property map // push gradient or named gradient to property map
if( rPropMap.setProperty( SHAPEPROP_FillGradient, aGradient ) ) if( rPropMap.setProperty( SHAPEPROP_FillGradient, aGradient ) )
eFillStyle = FillStyle_GRADIENT; eFillStyle = FillStyle_GRADIENT;
// push gradient transparency to property map
if( nStartTrans != 0 || nEndTrans != 0 )
{
awt::Gradient aGrad(aGradient);
uno::Any aVal;
aGrad.EndColor = (sal_Int32)( nEndTrans | nEndTrans << 8 | nEndTrans << 16 );
aGrad.StartColor = (sal_Int32)( nStartTrans | nStartTrans << 8 | nStartTrans << 16 );
aVal <<= aGrad;
rPropMap.setProperty( SHAPEPROP_GradientTransparency, aGrad );
}
} }
break; break;
......
...@@ -53,7 +53,7 @@ static const sal_Int32 spnDefaultShapeIds[ SHAPEPROP_END ] = ...@@ -53,7 +53,7 @@ static const sal_Int32 spnDefaultShapeIds[ SHAPEPROP_END ] =
{ {
PROP_LineStyle, PROP_LineWidth, PROP_LineColor, PROP_LineTransparence, PROP_LineDash, PROP_LineJoint, PROP_LineStyle, PROP_LineWidth, PROP_LineColor, PROP_LineTransparence, PROP_LineDash, PROP_LineJoint,
PROP_LineStartName, PROP_LineStartWidth, PROP_LineStartCenter, PROP_LineEndName, PROP_LineEndWidth, PROP_LineEndCenter, PROP_LineStartName, PROP_LineStartWidth, PROP_LineStartCenter, PROP_LineEndName, PROP_LineEndWidth, PROP_LineEndCenter,
PROP_FillStyle, PROP_FillColor, PROP_FillTransparence, PROP_FillGradient, PROP_FillStyle, PROP_FillColor, PROP_FillTransparence, PROP_FillTransparenceGradientName, PROP_FillGradient,
PROP_FillBitmapURL, PROP_FillBitmapMode, PROP_FillBitmapSizeX, PROP_FillBitmapSizeY, PROP_FillBitmapURL, PROP_FillBitmapMode, PROP_FillBitmapSizeX, PROP_FillBitmapSizeY,
PROP_FillBitmapPositionOffsetX, PROP_FillBitmapPositionOffsetY, PROP_FillBitmapRectanglePoint PROP_FillBitmapPositionOffsetX, PROP_FillBitmapPositionOffsetY, PROP_FillBitmapRectanglePoint
}; };
...@@ -110,6 +110,9 @@ bool ShapePropertyMap::setAnyProperty( ShapePropertyId ePropId, const Any& rValu ...@@ -110,6 +110,9 @@ bool ShapePropertyMap::setAnyProperty( ShapePropertyId ePropId, const Any& rValu
case SHAPEPROP_FillGradient: case SHAPEPROP_FillGradient:
return setFillGradient( nPropId, rValue ); return setFillGradient( nPropId, rValue );
case SHAPEPROP_GradientTransparency:
return setGradientTrans( nPropId, rValue );
case SHAPEPROP_FillBitmapUrl: case SHAPEPROP_FillBitmapUrl:
return setFillBitmapUrl( nPropId, rValue ); return setFillBitmapUrl( nPropId, rValue );
...@@ -172,6 +175,18 @@ bool ShapePropertyMap::setFillGradient( sal_Int32 nPropId, const Any& rValue ) ...@@ -172,6 +175,18 @@ bool ShapePropertyMap::setFillGradient( sal_Int32 nPropId, const Any& rValue )
return false; return false;
} }
bool ShapePropertyMap::setGradientTrans( sal_Int32 nPropId, const Any& rValue )
{
// create named gradient and push its name
if( rValue.has< Gradient >() )
{
OUString aGradientName = mrModelObjHelper.insertTransGrandient( rValue.get< Gradient >() );
return ( aGradientName.getLength() > 0 ) && setProperty( nPropId, aGradientName );
}
return false;
}
bool ShapePropertyMap::setFillBitmapUrl( sal_Int32 nPropId, const Any& rValue ) bool ShapePropertyMap::setFillBitmapUrl( sal_Int32 nPropId, const Any& rValue )
{ {
// push bitmap URL explicitly // push bitmap URL explicitly
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
* *
************************************************************************/ ************************************************************************/
#include <com/sun/star/container/XNameContainer.hpp>
#include "oox/helper/graphichelper.hxx" #include "oox/helper/graphichelper.hxx"
#include <com/sun/star/awt/Point.hpp> #include <com/sun/star/awt/Point.hpp>
......
...@@ -112,9 +112,11 @@ ModelObjectHelper::ModelObjectHelper( const Reference< XMultiServiceFactory >& r ...@@ -112,9 +112,11 @@ ModelObjectHelper::ModelObjectHelper( const Reference< XMultiServiceFactory >& r
maMarkerContainer( rxModelFactory, CREATE_OUSTRING( "com.sun.star.drawing.MarkerTable" ) ), maMarkerContainer( rxModelFactory, CREATE_OUSTRING( "com.sun.star.drawing.MarkerTable" ) ),
maDashContainer( rxModelFactory, CREATE_OUSTRING( "com.sun.star.drawing.DashTable" ) ), maDashContainer( rxModelFactory, CREATE_OUSTRING( "com.sun.star.drawing.DashTable" ) ),
maGradientContainer( rxModelFactory, CREATE_OUSTRING( "com.sun.star.drawing.GradientTable" ) ), maGradientContainer( rxModelFactory, CREATE_OUSTRING( "com.sun.star.drawing.GradientTable" ) ),
maTransGradContainer( rxModelFactory, CREATE_OUSTRING( "com.sun.star.drawing.TransparencyGradientTable" ) ),
maBitmapUrlContainer( rxModelFactory, CREATE_OUSTRING( "com.sun.star.drawing.BitmapTable" ) ), maBitmapUrlContainer( rxModelFactory, CREATE_OUSTRING( "com.sun.star.drawing.BitmapTable" ) ),
maDashNameBase( CREATE_OUSTRING( "msLineDash " ) ), maDashNameBase( CREATE_OUSTRING( "msLineDash " ) ),
maGradientNameBase( CREATE_OUSTRING( "msFillGradient " ) ), maGradientNameBase( CREATE_OUSTRING( "msFillGradient " ) ),
maTransGradNameBase( CREATE_OUSTRING( "msTransGradient " ) ),
maBitmapUrlNameBase( CREATE_OUSTRING( "msFillBitmap " ) ) maBitmapUrlNameBase( CREATE_OUSTRING( "msFillBitmap " ) )
{ {
} }
...@@ -142,6 +144,11 @@ OUString ModelObjectHelper::insertFillGradient( const Gradient& rGradient ) ...@@ -142,6 +144,11 @@ OUString ModelObjectHelper::insertFillGradient( const Gradient& rGradient )
return maGradientContainer.insertObject( maGradientNameBase, Any( rGradient ), true ); return maGradientContainer.insertObject( maGradientNameBase, Any( rGradient ), true );
} }
OUString ModelObjectHelper::insertTransGrandient( const Gradient& rGradient )
{
return maTransGradContainer.insertObject( maTransGradNameBase, Any( rGradient ), true );
}
OUString ModelObjectHelper::insertFillBitmapUrl( const OUString& rGraphicUrl ) OUString ModelObjectHelper::insertFillBitmapUrl( const OUString& rGraphicUrl )
{ {
if( rGraphicUrl.getLength() > 0 ) if( rGraphicUrl.getLength() > 0 )
......
...@@ -156,6 +156,8 @@ FillGradient ...@@ -156,6 +156,8 @@ FillGradient
FillGradientName FillGradientName
FillStyle FillStyle
FillTransparence FillTransparence
FillTransparenceGradient
FillTransparenceGradientName
Filter Filter
FilterCriteriaSource FilterCriteriaSource
FilterOptions FilterOptions
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment