incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From liji...@apache.org
Subject svn commit: r1373695 - in /incubator/ooo/trunk/main: filter/inc/filter/msfilter/escherex.hxx filter/inc/filter/msfilter/msdffimp.hxx filter/source/msfilter/escherex.cxx filter/source/msfilter/msdffimp.cxx sd/source/filter/eppt/epptso.cxx
Date Thu, 16 Aug 2012 02:13:03 GMT
Author: lijiany
Date: Thu Aug 16 02:13:03 2012
New Revision: 1373695

URL: http://svn.apache.org/viewvc?rev=1373695&view=rev
Log:
#120554# Shape Gradient MS2003 import/export Enhancement
Reported by: Jianyuan Li
Patch by: Jianyuan Li
Review by: SunYing

Modified:
    incubator/ooo/trunk/main/filter/inc/filter/msfilter/escherex.hxx
    incubator/ooo/trunk/main/filter/inc/filter/msfilter/msdffimp.hxx
    incubator/ooo/trunk/main/filter/source/msfilter/escherex.cxx
    incubator/ooo/trunk/main/filter/source/msfilter/msdffimp.cxx
    incubator/ooo/trunk/main/sd/source/filter/eppt/epptso.cxx

Modified: incubator/ooo/trunk/main/filter/inc/filter/msfilter/escherex.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/filter/inc/filter/msfilter/escherex.hxx?rev=1373695&r1=1373694&r2=1373695&view=diff
==============================================================================
--- incubator/ooo/trunk/main/filter/inc/filter/msfilter/escherex.hxx (original)
+++ incubator/ooo/trunk/main/filter/inc/filter/msfilter/escherex.hxx Thu Aug 16 02:13:03 2012
@@ -1222,9 +1222,10 @@ class MSFILTER_DLLPUBLIC EscherPropertyC
 		static sal_uInt32 GetGradientColor( const ::com::sun::star::awt::Gradient* pGradient, sal_uInt32
nStartColor );
 
         void        CreateGradientProperties( const ::com::sun::star::awt::Gradient &
rGradient );
-		void		CreateGradientProperties( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet
> & );
+		void		CreateGradientProperties( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet
> & , sal_Bool bTransparentGradient = sal_False );
 		void		CreateLineProperties( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet
> &, sal_Bool bEdge );
-		void		CreateFillProperties( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet
> &, sal_Bool bEdge );
+		void		CreateFillProperties( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet
> &, sal_Bool bEdge , sal_Bool bTransparentGradient = sal_False );
+		void		CreateFillProperties( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet
> &, sal_Bool bEdge ,  const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape
> & rXShape );
 		void		CreateTextProperties( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet
> &, sal_uInt32 nText,
 						const sal_Bool bIsCustomShape = sal_False, const sal_Bool bIsTextFrame = sal_True );
 

Modified: incubator/ooo/trunk/main/filter/inc/filter/msfilter/msdffimp.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/filter/inc/filter/msfilter/msdffimp.hxx?rev=1373695&r1=1373694&r2=1373695&view=diff
==============================================================================
--- incubator/ooo/trunk/main/filter/inc/filter/msfilter/msdffimp.hxx (original)
+++ incubator/ooo/trunk/main/filter/inc/filter/msfilter/msdffimp.hxx Thu Aug 16 02:13:03 2012
@@ -80,6 +80,7 @@ class MSFILTER_DLLPUBLIC DffPropertyRead
 public:
 
 	sal_Int32					mnFix16Angle;
+	sal_Bool					mbRotateGranientFillWithAngle;
 
 	DffPropertyReader( const SvxMSDffManager& rManager );
 	~DffPropertyReader();
@@ -94,6 +95,7 @@ public:
 	void		SetDefaultPropSet( SvStream& rIn, sal_uInt32 nOffDgg ) const;
 	void		ApplyAttributes( SvStream& rIn, SfxItemSet& rSet ) const;
 	void		ApplyAttributes( SvStream& rIn, SfxItemSet& rSet, DffObjData& rObjData
) const;
+	void		ImportGradientColor( SfxItemSet& aSet, MSO_FillType eMSO_FillType, double dTrans
= 1.0 , double dBackTrans = 1.0 ) const;
 };
 
 

Modified: incubator/ooo/trunk/main/filter/source/msfilter/escherex.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/filter/source/msfilter/escherex.cxx?rev=1373695&r1=1373694&r2=1373695&view=diff
==============================================================================
--- incubator/ooo/trunk/main/filter/source/msfilter/escherex.cxx (original)
+++ incubator/ooo/trunk/main/filter/source/msfilter/escherex.cxx Thu Aug 16 02:13:03 2012
@@ -24,6 +24,7 @@
 // MARKER(update_precomp.py): autogen include statement, do not remove
 #include "precompiled_filter.hxx"
 #include "eschesdo.hxx"
+#include <svx/xflftrit.hxx>
 #include <filter/msfilter/escherex.hxx>
 #include <svx/unoapi.hxx>
 #include <svx/svdobj.hxx>
@@ -438,21 +439,158 @@ void EscherPropertyContainer::CreateGrad
 }
 
 void EscherPropertyContainer::CreateGradientProperties(
-    const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
& rXPropSet )
+	const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > &
rXPropSet , sal_Bool bTransparentGradient)
 {
-    ::com::sun::star::uno::Any aAny;
-    ::com::sun::star::awt::Gradient aGradient;
-    if ( EscherPropertyValueHelper::GetPropertyValue(
-            aAny, rXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "FillGradient" ) ), sal_False
) )
-    {
-        aGradient = *static_cast< const ::com::sun::star::awt::Gradient* >( aAny.getValue()
);
-    }
-    CreateGradientProperties( aGradient );
-};
+	::com::sun::star::uno::Any			aAny;
+	::com::sun::star::awt::Gradient*	pGradient = NULL;
+
+	sal_uInt32  nFillType = ESCHER_FillShadeScale;
+	sal_Int32  nAngle = 0;
+	sal_uInt32  nFillFocus = 0;
+	sal_uInt32  nFillLR = 0;
+	sal_uInt32  nFillTB = 0;
+	sal_uInt32	nFirstColor = 0;//like the control var nChgColors in import logic
+	bool        bWriteFillTo = false;
+
+	//Transparency gradient: Means the third setting in transparency page is set
+	if (bTransparentGradient &&  EscherPropertyValueHelper::GetPropertyValue(
+		aAny, rXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "FillTransparenceGradient" ) ), sal_False
) )
+	{
+		pGradient = (::com::sun::star::awt::Gradient*)aAny.getValue();
+				
+		::com::sun::star::uno::Any			aAnyTemp;
+		const rtl::OUString aPropName( String( RTL_CONSTASCII_USTRINGPARAM( "FillStyle" ) ) );
+		if ( EscherPropertyValueHelper::GetPropertyValue(
+			aAnyTemp, rXPropSet, aPropName, sal_False ) )
+		{
+			::com::sun::star::drawing::FillStyle eFS;
+			if ( ! ( aAnyTemp >>= eFS ) )
+				eFS = ::com::sun::star::drawing::FillStyle_SOLID;
+			//solid and transparency
+			if ( eFS == ::com::sun::star::drawing::FillStyle_SOLID)
+			{
+				if ( EscherPropertyValueHelper::GetPropertyValue(
+					aAnyTemp, rXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "FillColor" ) ), sal_False
) )
+				{
+					pGradient->StartColor = ImplGetColor( *((sal_uInt32*)aAnyTemp.getValue()), sal_False
);
+					pGradient->EndColor = ImplGetColor( *((sal_uInt32*)aAnyTemp.getValue()), sal_False
);
+				}
+			}
+			//gradient and transparency.
+			else if( eFS == ::com::sun::star::drawing::FillStyle_GRADIENT )
+			{
+				if ( EscherPropertyValueHelper::GetPropertyValue(
+					aAny, rXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "FillGradient" ) ), sal_False
) )
+					pGradient = (::com::sun::star::awt::Gradient*)aAny.getValue();
+			}
+		}
+		
+	}
+	//Not transparency gradient
+	else if ( EscherPropertyValueHelper::GetPropertyValue(
+		aAny, rXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "FillGradient" ) ), sal_False ) )
+	{
+		pGradient = (::com::sun::star::awt::Gradient*)aAny.getValue();
+	}
+	
+	if ( pGradient )
+	{
+		switch ( pGradient->Style )
+		{
+		case ::com::sun::star::awt::GradientStyle_LINEAR :
+		case ::com::sun::star::awt::GradientStyle_AXIAL :
+			{
+				nFillType = ESCHER_FillShadeScale;
+				nAngle = pGradient->Angle;
+				while ( nAngle > 0 ) nAngle -= 3600;
+				while ( nAngle <= -3600 ) nAngle += 3600;
+				//Value of the real number = Integral + (Fractional / 65536.0)
+				nAngle = ( nAngle * 0x10000) / 10;
+
+				nFillFocus = (pGradient->Style == GradientStyle_LINEAR) ? 
+							( pGradient->XOffset + pGradient->YOffset )/2 : -50;
+				if( !nFillFocus )
+					nFirstColor=nFirstColor ^ 1;
+				if ( !nAngle )
+					nFirstColor=nFirstColor ^ 1;
+			}
+			break;
+		case ::com::sun::star::awt::GradientStyle_RADIAL :
+		case ::com::sun::star::awt::GradientStyle_ELLIPTICAL :
+		case ::com::sun::star::awt::GradientStyle_SQUARE :
+		case ::com::sun::star::awt::GradientStyle_RECT :
+			{
+				//according to the import logic and rect type fill** value
+				nFillLR = (pGradient->XOffset * 0x10000) / 100;
+				nFillTB = (pGradient->YOffset * 0x10000) / 100;
+				if ( ((nFillLR > 0) && (nFillLR < 0x10000)) || ((nFillTB > 0) &&
(nFillTB < 0x10000)) )
+					nFillType = ESCHER_FillShadeShape;
+				else
+					nFillType = ESCHER_FillShadeCenter;
+				nFirstColor = 1;
+				bWriteFillTo = true;
+			}
+			break;
+		}
+	}
+	
+	AddOpt( ESCHER_Prop_fillType, nFillType );
+	AddOpt( ESCHER_Prop_fillAngle, nAngle );
+	AddOpt( ESCHER_Prop_fillColor, GetGradientColor( pGradient, nFirstColor ) );
+	AddOpt( ESCHER_Prop_fillBackColor, GetGradientColor( pGradient, nFirstColor ^ 1 ) );
+	AddOpt( ESCHER_Prop_fillFocus, nFillFocus );
+	if ( bWriteFillTo )
+	{
+		//according to rect type fillTo** value
+		if(nFillLR)
+		{
+			AddOpt( ESCHER_Prop_fillToLeft, nFillLR );
+			AddOpt( ESCHER_Prop_fillToRight, nFillLR );
+		}
+		if(nFillTB)
+		{
+			AddOpt( ESCHER_Prop_fillToTop, nFillTB );
+			AddOpt( ESCHER_Prop_fillToBottom, nFillTB );
+		}
+	}
+
+	//Transparency gradient
+	if (bTransparentGradient &&  EscherPropertyValueHelper::GetPropertyValue(
+		aAny, rXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "FillTransparenceGradient" ) ), sal_False
) )
+	{
+		pGradient = (::com::sun::star::awt::Gradient*)aAny.getValue();
+		if ( pGradient )
+		{
+			sal_uInt32	nBlue =	 GetGradientColor( pGradient, nFirstColor ) >> 16;
+			AddOpt( ESCHER_Prop_fillOpacity,( ( 100 - ( nBlue * 100 / 255 ) ) << 16 ) / 100
);
+			nBlue =	 GetGradientColor( pGradient, nFirstColor ^ 1 ) >>16 ;
+			AddOpt( ESCHER_Prop_fillBackOpacity,( ( 100 - ( nBlue * 100 / 255 ) ) << 16 )/ 100
);
+		}
+	}
+}
+
+void	EscherPropertyContainer::CreateFillProperties( 
+	const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > &
rXPropSet,
+	sal_Bool bEdge ,  const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape
> & rXShape )
+{
+	if ( rXShape.is() )
+	{
+		SdrObject* pObj = GetSdrObjectFromXShape( rXShape );
+		if ( pObj )
+		{
+			SfxItemSet aAttr( pObj->GetMergedItemSet() );
+			//tranparency with gradient. Means the third setting in transparency page is set
+			sal_Bool bTransparentGradient =  ( aAttr.GetItemState( XATTR_FILLFLOATTRANSPARENCE ) ==
SFX_ITEM_SET ) &&
+				( (const XFillFloatTransparenceItem&) aAttr.Get( XATTR_FILLFLOATTRANSPARENCE ) ).IsEnabled();
+			CreateFillProperties(  rXPropSet, bEdge, bTransparentGradient );
+		}
+	}
+}
 
 void EscherPropertyContainer::CreateFillProperties(
-	const uno::Reference< beans::XPropertySet > & rXPropSet,
-		sal_Bool bEdge )
+	const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > &
rXPropSet,
+	sal_Bool bEdge , sal_Bool bTransparentGradient)
+
 {
 	::com::sun::star::uno::Any aAny;
     AddOpt( ESCHER_Prop_WrapText, ESCHER_WrapNone );
@@ -471,7 +609,7 @@ void EscherPropertyContainer::CreateFill
         {
             case ::com::sun::star::drawing::FillStyle_GRADIENT :
             {
-				CreateGradientProperties( rXPropSet );
+				CreateGradientProperties( rXPropSet , bTransparentGradient );
                 AddOpt( ESCHER_Prop_fNoFillHitTest, 0x140014 );
             }
             break;
@@ -491,20 +629,25 @@ void EscherPropertyContainer::CreateFill
             case ::com::sun::star::drawing::FillStyle_SOLID :
             default:
             {
-				::com::sun::star::beans::PropertyState ePropState = EscherPropertyValueHelper::GetPropertyState(
-					rXPropSet, aPropName );
-				if ( ePropState == ::com::sun::star::beans::PropertyState_DIRECT_VALUE )
-	                AddOpt( ESCHER_Prop_fillType, ESCHER_FillSolid );
-
-				if ( EscherPropertyValueHelper::GetPropertyValue(
-						aAny, rXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "FillColor" ) ), sal_False )
)
+				if ( bTransparentGradient )
+					CreateGradientProperties( rXPropSet , bTransparentGradient );
+				else
 				{
-                    sal_uInt32 nFillColor = ImplGetColor( *((sal_uInt32*)aAny.getValue())
);
-                    nFillBackColor = nFillColor ^ 0xffffff;
-                    AddOpt( ESCHER_Prop_fillColor, nFillColor );
+					::com::sun::star::beans::PropertyState ePropState = EscherPropertyValueHelper::GetPropertyState(
+						rXPropSet, aPropName );
+					if ( ePropState == ::com::sun::star::beans::PropertyState_DIRECT_VALUE )
+						AddOpt( ESCHER_Prop_fillType, ESCHER_FillSolid );
+
+					if ( EscherPropertyValueHelper::GetPropertyValue(
+							aAny, rXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( "FillColor" ) ), sal_False )
)
+					{
+						sal_uInt32 nFillColor = ImplGetColor( *((sal_uInt32*)aAny.getValue()) );
+						nFillBackColor = nFillColor ^ 0xffffff;
+						AddOpt( ESCHER_Prop_fillColor, nFillColor );
+					}
+					AddOpt( ESCHER_Prop_fNoFillHitTest, 0x100010 );
+					AddOpt( ESCHER_Prop_fillBackColor, nFillBackColor );
 				}
-                AddOpt( ESCHER_Prop_fNoFillHitTest, 0x100010 );
-                AddOpt( ESCHER_Prop_fillBackColor, nFillBackColor );
                 break;
             }
             case ::com::sun::star::drawing::FillStyle_NONE :

Modified: incubator/ooo/trunk/main/filter/source/msfilter/msdffimp.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/filter/source/msfilter/msdffimp.cxx?rev=1373695&r1=1373694&r2=1373695&view=diff
==============================================================================
--- incubator/ooo/trunk/main/filter/source/msfilter/msdffimp.cxx (original)
+++ incubator/ooo/trunk/main/filter/source/msfilter/msdffimp.cxx Thu Aug 16 02:13:03 2012
@@ -218,6 +218,7 @@ void Impl_OlePres::Write( SvStream & rSt
 
 DffPropertyReader::DffPropertyReader( const SvxMSDffManager& rMan ) :
 	rManager( rMan ),
+	mbRotateGranientFillWithAngle ( 0 ),
 	pDefaultPropSet( NULL )
 {
 	InitializePropSet( DFF_msofbtOPT );
@@ -1350,6 +1351,9 @@ void DffPropertyReader::ApplyFillAttribu
 			break;
 			case mso_fillShadeCenter :		// Shade from bounding rectangle to end point
 			{
+				//If it is imported as a bitmap, it will not work well with transparecy especially 100
+				//But the gradient look well comparing with imported as gradient. And rotate with shape
+				//also works better. So here just keep it.
 				if ( rObjData.aBoundRect.IsEmpty() )// size of object needed to be able
 					eXFill = XFILL_GRADIENT;		// to create a bitmap substitution
 				else
@@ -1367,13 +1371,21 @@ void DffPropertyReader::ApplyFillAttribu
 		}
 		rSet.Put( XFillStyleItem( eXFill ) );
 
-        if (IsProperty(DFF_Prop_fillOpacity))
-        {
-			double nTrans = GetPropertyValue(DFF_Prop_fillOpacity);
-            nTrans = (nTrans * 100) / 65536;
-			rSet.Put(XFillTransparenceItem(
-                sal_uInt16(100 - ::rtl::math::round(nTrans))));
-        }
+		double dTrans  = 1.0;
+		double dBackTrans = 1.0;
+		if (IsProperty(DFF_Prop_fillOpacity))
+		{
+			dTrans = GetPropertyValue(DFF_Prop_fillOpacity) / 65536.0;			
+			if ( eXFill != XFILL_GRADIENT )
+			{
+				dTrans = dTrans * 100;
+				rSet.Put(XFillTransparenceItem(
+					sal_uInt16(100 - ::rtl::math::round(dTrans))));
+			}
+		}
+
+		if ( IsProperty(DFF_Prop_fillBackOpacity) )
+			dBackTrans = GetPropertyValue(DFF_Prop_fillBackOpacity) / 65536.0;
 
 		if ( ( eMSO_FillType == mso_fillShadeCenter ) && ( eXFill == XFILL_BITMAP ) )
 		{
@@ -1381,63 +1393,7 @@ void DffPropertyReader::ApplyFillAttribu
 		}
 		else if ( eXFill == XFILL_GRADIENT )
 		{
-			sal_Int32 nAngle = 3600 - ( ( Fix16ToAngle( GetPropertyValue( DFF_Prop_fillAngle, 0 )
) + 5 ) / 10 );
-
-			// Rotationswinkel in Bereich zwingen
-			while ( nAngle >= 3600 )
-				nAngle -= 3600;
-			while ( nAngle < 0 )
-				nAngle += 3600;
-
-			sal_Int32 nFocus = GetPropertyValue( DFF_Prop_fillFocus, 0 );
-			XGradientStyle eGrad = XGRAD_LINEAR;
-			sal_Int32 nChgColors = 0;
-
-			if ( nFocus < 0 )		// Bei negativem Focus sind die Farben zu tauschen
-			{
-				nFocus =- nFocus;
-				nChgColors ^= 1;
-			}
-			if( nFocus > 40 && nFocus < 60 )
-			{
-				eGrad = XGRAD_AXIAL;	// Besser gehts leider nicht
-			}
-
-			sal_uInt16 nFocusX = (sal_uInt16)nFocus;
-			sal_uInt16 nFocusY = (sal_uInt16)nFocus;
-
-			switch( eMSO_FillType )
-			{
-				case mso_fillShadeShape :
-				{
-					eGrad = XGRAD_RECT;
-					nFocusY = nFocusX = 50;
-					nChgColors ^= 1;
-				}
-				break;
-				case mso_fillShadeCenter :
-				{
-					eGrad = XGRAD_RECT;
-					nFocusX = ( IsProperty( DFF_Prop_fillToRight ) ) ? 100 : 0;
-					nFocusY = ( IsProperty( DFF_Prop_fillToBottom ) ) ? 100 : 0;
-					nChgColors ^= 1;
-				}
-				break;
-				default: break;
-			}
-			Color aCol1( rManager.MSO_CLR_ToColor( GetPropertyValue( DFF_Prop_fillColor, COL_WHITE
), DFF_Prop_fillColor ) );
-			Color aCol2( rManager.MSO_CLR_ToColor( GetPropertyValue( DFF_Prop_fillBackColor, COL_WHITE
), DFF_Prop_fillBackColor ) );
-
-			if ( nChgColors )
-			{
-				Color aZwi( aCol1 );
-				aCol1 = aCol2;
-				aCol2 = aZwi;
-			}
-			XGradient aGrad( aCol2, aCol1, eGrad, nAngle, nFocusX, nFocusY );
-			aGrad.SetStartIntens( 100 );
-			aGrad.SetEndIntens( 100 );
-			rSet.Put( XFillGradientItem( String(), aGrad ) );
+			ImportGradientColor ( rSet, eMSO_FillType, dTrans , dBackTrans );
 		}
 		else if ( eXFill == XFILL_BITMAP )
 		{
@@ -2889,6 +2845,113 @@ void DffPropertyReader::CheckAndCorrectE
 	}
 }
 
+
+void DffPropertyReader::ImportGradientColor( SfxItemSet& aSet,MSO_FillType eMSO_FillType,
double dTrans , double dBackTrans) const
+{
+	//MS Focus prop will impact the start and end color position. And AOO does not
+	//support this prop. So need some swap for the two color to keep fidelity with AOO and MS
shape.
+	//So below var is defined.
+	sal_Int32 nChgColors = 0;
+	sal_Int32 nAngle = GetPropertyValue( DFF_Prop_fillAngle, 0 );
+	sal_Int32 nRotateAngle = 0;
+	if(nAngle >= 0)
+		nChgColors ^= 1;
+
+	//Translate a MS clockwise(+) or count clockwise angle(-) into a AOO count clock wise angle
+	nAngle=3600 - ( ( Fix16ToAngle(nAngle) + 5 ) / 10 );
+	//Make sure this angle belongs to 0~3600
+	while ( nAngle >= 3600 ) nAngle -= 3600;
+	while ( nAngle < 0 ) nAngle += 3600;
+
+	//Rotate angle
+	if ( mbRotateGranientFillWithAngle )
+	{
+		nRotateAngle = GetPropertyValue( DFF_Prop_Rotation, 0 );
+		if(nRotateAngle)//fixed point number
+			nRotateAngle = ( (sal_Int16)( nRotateAngle >> 16) * 100L ) + ( ( ( nRotateAngle
& 0x0000ffff) * 100L ) >> 16 );
+		nRotateAngle = ( nRotateAngle + 5 ) / 10 ;//round up
+		//nAngle is a clockwise angle. If nRotateAngle is a clockwise angle, then gradient need
be rotated a little less
+		//Or it need be rotated a little more
+		nAngle -=  nRotateAngle;
+	}
+	while ( nAngle >= 3600 ) nAngle -= 3600;
+	while ( nAngle < 0 ) nAngle += 3600;
+
+	XGradientStyle eGrad = XGRAD_LINEAR;
+	
+	sal_Int32 nFocus = GetPropertyValue( DFF_Prop_fillFocus, 0 );	
+	if ( !nFocus )
+		nChgColors ^= 1;
+	else if ( nFocus < 0 )//If it is a negative focus, the color will be swapped
+	{
+		nFocus =- nFocus;
+		nChgColors ^= 1;
+	}
+	
+	if( nFocus > 40 && nFocus < 60 )
+	{
+		eGrad = XGRAD_AXIAL;//A axial gradient other than linear
+		nChgColors ^= 1;
+	}
+	//if the type is linear or axial, just save focus to nFocusX and nFocusY for export
+	//Core function does no need them. They serves for rect gradient(CenterXY).
+	sal_uInt16 nFocusX = (sal_uInt16)nFocus;
+	sal_uInt16 nFocusY = (sal_uInt16)nFocus;
+	
+	switch( eMSO_FillType )
+	{
+	case mso_fillShadeShape :
+		{
+			eGrad = XGRAD_RECT;
+			nFocusY = nFocusX = 50;
+			nChgColors ^= 1;
+		}
+		break;
+	case mso_fillShadeCenter :
+		{
+			eGrad = XGRAD_RECT;
+			//A MS fillTo prop specifies the relative position of the left boundary 
+			//of the center rectangle in a concentric shaded fill. Use 100 or 0 to keep fidelity
+			nFocusX=(GetPropertyValue( DFF_Prop_fillToRight, 0 )==0x10000) ? 100 : 0;
+			nFocusY=(GetPropertyValue( DFF_Prop_fillToBottom,0 )==0x10000) ? 100 : 0;			
+			nChgColors ^= 1;
+		}
+		break;
+	}
+
+	Color aCol1( rManager.MSO_CLR_ToColor( GetPropertyValue( DFF_Prop_fillColor, COL_WHITE ),
DFF_Prop_fillColor ) );
+	Color aCol2( rManager.MSO_CLR_ToColor( GetPropertyValue( DFF_Prop_fillBackColor, COL_WHITE
), DFF_Prop_fillBackColor ) );	
+	if ( nChgColors )
+	{
+		//Swap start and end color
+		Color aZwi( aCol1 );
+		aCol1 = aCol2;
+		aCol2 = aZwi;
+		//Swap two colors' transparency
+		double dTemp = dTrans;
+		dTrans = dBackTrans;
+		dBackTrans = dTemp;
+	}
+	
+	//Construct gradient item
+	XGradient aGrad( aCol2, aCol1, eGrad, nAngle, nFocusX, nFocusY );
+	//Intensity has been merged into color. So here just set is as 100
+	aGrad.SetStartIntens( 100 );
+	aGrad.SetEndIntens( 100 );
+	aSet.Put( XFillGradientItem( String(), aGrad ) );
+	//Construct tranparency item. This item can coodinate with both solid and gradient.
+	if ( dTrans < 1.0 || dBackTrans < 1.0 )
+	{
+		sal_uInt8 nStartCol = (sal_uInt8)( (1 - dTrans )* 255 );
+		sal_uInt8 nEndCol = (sal_uInt8)( ( 1- dBackTrans ) * 255 );
+		aCol1 = Color(nStartCol, nStartCol, nStartCol);
+		aCol2 = Color(nEndCol, nEndCol, nEndCol);
+		
+		XGradient aGrad2( aCol2 ,  aCol1 , eGrad, nAngle, nFocusX, nFocusY );
+		aSet.Put( XFillFloatTransparenceItem( String(), aGrad2 ) );
+	}
+}
+
 //---------------------------------------------------------------------------
 //- Record Manager ----------------------------------------------------------
 //---------------------------------------------------------------------------
@@ -4213,6 +4276,29 @@ SdrObject* SvxMSDffManager::ImportShape(
 	DffObjData aObjData( rHd, rClientRect, nCalledByGroup );
 	aObjData.bRotateTextWithShape = ( GetSvxMSDffSettings() & SVXMSDFF_SETTINGS_IMPORT_EXCEL
) == 0;
 	maShapeRecords.Consume( rSt, sal_False );
+	if( maShapeRecords.SeekToContent( rSt,
+		DFF_msofbtUDefProp,
+		SEEK_FROM_BEGINNING ) )
+	{
+		sal_uInt32  nBytesLeft = maShapeRecords.Current()->nRecLen;
+		sal_uInt32	nUDData;
+		sal_uInt16  nPID;
+		while( 5 < nBytesLeft )
+		{
+			rSt >> nPID;
+			if ( rSt.GetError() != 0 )
+				break;
+			rSt >> nUDData;						
+			if ( rSt.GetError() != 0 )
+				break;
+			if ( nPID == 447 ) // 
+			{
+				mbRotateGranientFillWithAngle = nUDData & 0x20;
+				break;
+			}
+			nBytesLeft  -= 6;
+		}
+	}
 	aObjData.bShapeType = maShapeRecords.SeekToContent( rSt, DFF_msofbtSp, SEEK_FROM_BEGINNING
);
 	if ( aObjData.bShapeType )
 	{

Modified: incubator/ooo/trunk/main/sd/source/filter/eppt/epptso.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sd/source/filter/eppt/epptso.cxx?rev=1373695&r1=1373694&r2=1373695&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sd/source/filter/eppt/epptso.cxx (original)
+++ incubator/ooo/trunk/main/sd/source/filter/eppt/epptso.cxx Thu Aug 16 02:13:03 2012
@@ -4132,7 +4132,7 @@ sal_Bool PPTWriter::ImplCreatePresentati
 		aPropOpt.AddOpt( ESCHER_Prop_fNoFillHitTest, 0x110001 );
 		aPropOpt.AddOpt( ESCHER_Prop_lineColor, 0x8000001 );
 		aPropOpt.AddOpt( ESCHER_Prop_shadowColor, 0x8000002 );
-		aPropOpt.CreateFillProperties( mXPropSet, sal_True );
+		aPropOpt.CreateFillProperties( mXPropSet, sal_True, mXShape );
 		sal_uInt32 nLineFlags = 0x90001;
 		if ( aPropOpt.GetOpt( ESCHER_Prop_fNoLineDrawDash, nLineFlags ) )
 			nLineFlags |= 0x10001;  // draw dashed line if no line
@@ -4191,7 +4191,7 @@ void PPTWriter::ImplCreateTextShape( Esc
     mpPptEscherEx->OpenContainer( ESCHER_SpContainer );
     ImplCreateShape( ESCHER_ShpInst_TextBox, 0xa00, rSolver );
     if ( bFill )
-        rPropOpt.CreateFillProperties( mXPropSet, sal_True );
+        rPropOpt.CreateFillProperties( mXPropSet, sal_True, mXShape );
 	if ( ImplGetText() )
 		rPropOpt.CreateTextProperties( mXPropSet, mnTxId += 0x60, sal_False, sal_True );
 }
@@ -4353,7 +4353,7 @@ void PPTWriter::ImplWritePage( const PHL
 				{
 	                ImplCreateShape( eShapeType, nMirrorFlags | 0xa00, aSolverContainer );
 					aPropOpt.CreateCustomShapeProperties( eShapeType, mXShape );
-					aPropOpt.CreateFillProperties( mXPropSet, sal_True );
+					aPropOpt.CreateFillProperties( mXPropSet, sal_True, mXShape);
 					if ( ImplGetText() )
 					{
 						if ( !aPropOpt.IsFontWork() )
@@ -4387,7 +4387,7 @@ void PPTWriter::ImplWritePage( const PHL
                 {
                     ImplCreateShape( ESCHER_ShpInst_Rectangle, 0xa00, aSolverContainer );
         // Flags: Connector | HasSpt
                 }
-                aPropOpt.CreateFillProperties( mXPropSet, sal_True );
+                aPropOpt.CreateFillProperties( mXPropSet, sal_True, mXShape );
 				if ( ImplGetText() )
 					aPropOpt.CreateTextProperties( mXPropSet, mnTxId += 0x60, sal_False, sal_False );
             }
@@ -4425,7 +4425,7 @@ void PPTWriter::ImplWritePage( const PHL
                 {
                     mpPptEscherEx->OpenContainer( ESCHER_SpContainer );
                     ImplCreateShape( ESCHER_ShpInst_Ellipse, 0xa00, aSolverContainer ); 
          // Flags: Connector | HasSpt
-                    aPropOpt.CreateFillProperties( mXPropSet, sal_True );
+                    aPropOpt.CreateFillProperties( mXPropSet, sal_True, mXShape );
 					if ( ImplGetText() )
 						aPropOpt.CreateTextProperties( mXPropSet, mnTxId += 0x60, sal_False, sal_False );
 				}
@@ -4477,7 +4477,7 @@ void PPTWriter::ImplWritePage( const PHL
                         case POLY_CHORD :
                         {
                             if ( aPropOpt.CreatePolygonProperties( mXPropSet, ESCHER_CREATEPOLYGON_POLYPOLYGON,
sal_False, aNewRect, &aPolygon ) )
-                                aPropOpt.CreateFillProperties( mXPropSet, sal_True );
+                                aPropOpt.CreateFillProperties( mXPropSet, sal_True , mXShape
);
                         }
                         break;
 
@@ -4690,7 +4690,7 @@ void PPTWriter::ImplWritePage( const PHL
                 maRect = ImplMapRectangle( aNewRect );
                 maPosition = ::com::sun::star::awt::Point( maRect.Left(), maRect.Top() );
                 maSize = ::com::sun::star::awt::Size( maRect.GetWidth(), maRect.GetHeight()
);
-                aPropOpt.CreateFillProperties( mXPropSet, sal_True );
+                aPropOpt.CreateFillProperties( mXPropSet, sal_True , mXShape );
                 mnAngle = 0;
             }
             else if ( bPolyLine )
@@ -4750,7 +4750,7 @@ void PPTWriter::ImplWritePage( const PHL
                 maRect = ImplMapRectangle( aNewRect );
                 maPosition = ::com::sun::star::awt::Point( maRect.Left(), maRect.Top() );
                 maSize = ::com::sun::star::awt::Size( maRect.GetWidth(), maRect.GetHeight()
);
-                aPropOpt.CreateFillProperties( mXPropSet, sal_True );
+                aPropOpt.CreateFillProperties( mXPropSet, sal_True , mXShape );
                 mnAngle = 0;
             }
             else if ( ( mType == "drawing.GraphicObject" ) || ( mType == "presentation.GraphicObject"
) )
@@ -4863,7 +4863,7 @@ void PPTWriter::ImplWritePage( const PHL
 								aPropertyOptions.AddOpt( ESCHER_Prop_fNoFillHitTest, 0x110001 );
 								aPropertyOptions.AddOpt( ESCHER_Prop_lineColor, 0x8000001 );
 								aPropertyOptions.AddOpt( ESCHER_Prop_shadowColor, 0x8000002 );
-								aPropertyOptions.CreateFillProperties( mXPropSet, sal_True );
+								aPropertyOptions.CreateFillProperties( mXPropSet, sal_True, mXShape );
 								sal_uInt32 nLineFlags = 0x90001;
 								if ( aPropertyOptions.GetOpt( ESCHER_Prop_fNoLineDrawDash, nLineFlags ) )
 									nLineFlags |= 0x10001;  // draw dashed line if no line
@@ -4908,7 +4908,7 @@ void PPTWriter::ImplWritePage( const PHL
 							nPlaceHolderAtom = rLayout.nTypeOfTitle;
 							ImplCreateShape( ESCHER_ShpInst_Rectangle, 0x220, aSolverContainer );          //
Flags: HaveAnchor | HaveMaster
 							aPropOpt.AddOpt( ESCHER_Prop_hspMaster, mnShapeMasterTitle );
-							aPropOpt.CreateFillProperties( mXPropSet, sal_True );
+							aPropOpt.CreateFillProperties( mXPropSet, sal_True, mXShape );
 							aPropOpt.CreateTextProperties( mXPropSet, mnTxId += 0x60, sal_False, sal_True );
 							ImplAdjustFirstLineLineSpacing( aTextObj, aPropOpt );
 							if ( mbEmptyPresObj )
@@ -4957,7 +4957,7 @@ void PPTWriter::ImplWritePage( const PHL
 								aPropOpt2.AddOpt( ESCHER_Prop_lineColor, 0x8000001 );
 								aPropOpt2.AddOpt( ESCHER_Prop_fNoLineDrawDash, 0x90001 );
 								aPropOpt2.AddOpt( ESCHER_Prop_shadowColor, 0x8000002 );
-								aPropOpt2.CreateFillProperties( mXPropSet, sal_True );
+								aPropOpt2.CreateFillProperties( mXPropSet, sal_True, mXShape  );
 								sal_uInt32 nLineFlags = 0x90001;
 								if ( aPropOpt2.GetOpt( ESCHER_Prop_fNoLineDrawDash, nLineFlags ) )
 									nLineFlags |= 0x10001;  // draw dashed line if no line
@@ -5006,7 +5006,7 @@ void PPTWriter::ImplWritePage( const PHL
 							mpPptEscherEx->OpenContainer( ESCHER_SpContainer );
 							ImplCreateShape( ESCHER_ShpInst_Rectangle, 0x220, aSolverContainer );          //
Flags: HaveAnchor | HaveMaster
 							aPropOpt.AddOpt( ESCHER_Prop_hspMaster, mnShapeMasterBody );
-							aPropOpt.CreateFillProperties( mXPropSet, sal_True );
+							aPropOpt.CreateFillProperties( mXPropSet, sal_True, mXShape );
 							aPropOpt.CreateTextProperties( mXPropSet, mnTxId += 0x60, sal_False, sal_True );
 							ImplAdjustFirstLineLineSpacing( aTextObj, aPropOpt );
 							if ( mbEmptyPresObj )



Mime
View raw message