Author: alg
Date: Wed Sep 26 12:26:49 2012
New Revision: 1390434

URL: http://svn.apache.org/viewvc?rev=1390434&view=rev
Log:
#119750# corrected opacity import for SC comment shapes and their shadow 
visualisation

Modified:
    incubator/ooo/trunk/main/oox/source/vml/vmlshapecontext.cxx
    
incubator/ooo/trunk/main/svx/source/sdr/contact/viewcontactofsdrcaptionobj.cxx

Modified: incubator/ooo/trunk/main/oox/source/vml/vmlshapecontext.cxx
URL: 
http://svn.apache.org/viewvc/incubator/ooo/trunk/main/oox/source/vml/vmlshapecontext.cxx?rev=1390434&r1=1390433&r2=1390434&view=diff
==============================================================================
--- incubator/ooo/trunk/main/oox/source/vml/vmlshapecontext.cxx (original)
+++ incubator/ooo/trunk/main/oox/source/vml/vmlshapecontext.cxx Wed Sep 26 
12:26:49 2012
@@ -63,6 +63,35 @@ OptValue< double > lclDecodePercent( con
     return OptValue< double >();
 }
 
+/** #119750# Special method for opacity; it *should* be a percentage value, 
but there are cases
+    where a value relative to 0xffff (65536) is used, ending with an 'f'
+ */
+OptValue< double > lclDecodeOpacity( const AttributeList& rAttribs, sal_Int32 
nToken, double fDefValue )
+{
+    OptValue< OUString > oValue = rAttribs.getString( nToken );
+    double fRetval(fDefValue);
+
+    if( oValue.has() ) 
+    {
+        const OUString aString(oValue.get());
+        const sal_Int32 nLength(aString.getLength());
+
+        if(nLength > 0)
+        {
+            if(aString.endsWithAsciiL(RTL_CONSTASCII_STRINGPARAM("f")))
+            {
+                fRetval = std::max(0.0, std::min(1.0, aString.toDouble() / 
65536.0));
+            }
+            else
+            {
+                fRetval = ConversionHelper::decodePercent( aString, fDefValue 
);
+            }
+        }
+    }
+
+    return OptValue< double >(fRetval);
+}
+
 /** Returns the integer value pair from the specified VML attribute (if 
present).
  */
 OptValue< Int32Pair > lclDecodeInt32Pair( const AttributeList& rAttribs, 
sal_Int32 nToken )
@@ -284,7 +313,7 @@ ContextHandlerRef ShapeTypeContext::onCr
             mrTypeModel.maStrokeModel.maEndArrow.moArrowWidth = 
rAttribs.getToken( XML_endarrowwidth );
             mrTypeModel.maStrokeModel.maEndArrow.moArrowLength = 
rAttribs.getToken( XML_endarrowlength );
             mrTypeModel.maStrokeModel.moColor.assignIfUsed( 
rAttribs.getString( XML_color ) );
-            mrTypeModel.maStrokeModel.moOpacity = lclDecodePercent( rAttribs, 
XML_opacity, 1.0 );
+            mrTypeModel.maStrokeModel.moOpacity = lclDecodeOpacity( rAttribs, 
XML_opacity, 1.0 );
             mrTypeModel.maStrokeModel.moWeight.assignIfUsed( 
rAttribs.getString( XML_weight ) );
             mrTypeModel.maStrokeModel.moDashStyle = rAttribs.getString( 
XML_dashstyle );
             mrTypeModel.maStrokeModel.moLineStyle = rAttribs.getToken( 
XML_linestyle );
@@ -294,9 +323,9 @@ ContextHandlerRef ShapeTypeContext::onCr
         case VML_TOKEN( fill ):
             mrTypeModel.maFillModel.moFilled.assignIfUsed( lclDecodeBool( 
rAttribs, XML_on ) );
             mrTypeModel.maFillModel.moColor.assignIfUsed( rAttribs.getString( 
XML_color ) );
-            mrTypeModel.maFillModel.moOpacity = lclDecodePercent( rAttribs, 
XML_opacity, 1.0 );
+            mrTypeModel.maFillModel.moOpacity = lclDecodeOpacity( rAttribs, 
XML_opacity, 1.0 );
             mrTypeModel.maFillModel.moColor2 = rAttribs.getString( XML_color2 
);
-            mrTypeModel.maFillModel.moOpacity2 = lclDecodePercent( rAttribs, 
XML_opacity2, 1.0 );
+            mrTypeModel.maFillModel.moOpacity2 = lclDecodeOpacity( rAttribs, 
XML_opacity2, 1.0 );
             mrTypeModel.maFillModel.moType = rAttribs.getToken( XML_type );
             mrTypeModel.maFillModel.moAngle = rAttribs.getInteger( XML_angle );
             mrTypeModel.maFillModel.moFocus = lclDecodePercent( rAttribs, 
XML_focus, 0.0 );

Modified: 
incubator/ooo/trunk/main/svx/source/sdr/contact/viewcontactofsdrcaptionobj.cxx
URL: 
http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svx/source/sdr/contact/viewcontactofsdrcaptionobj.cxx?rev=1390434&r1=1390433&r2=1390434&view=diff
==============================================================================
--- 
incubator/ooo/trunk/main/svx/source/sdr/contact/viewcontactofsdrcaptionobj.cxx 
(original)
+++ 
incubator/ooo/trunk/main/svx/source/sdr/contact/viewcontactofsdrcaptionobj.cxx 
Wed Sep 26 12:26:49 2012
@@ -40,6 +40,7 @@
 #include <svx/xfltrit.hxx>
 #include <basegfx/polygon/b2dpolygontools.hxx>
 #include <svx/sdr/primitive2d/sdrdecompositiontools.hxx>
+#include <basegfx/polygon/b2dpolygonclipper.hxx>
 
 //////////////////////////////////////////////////////////////////////////////
 
@@ -104,32 +105,32 @@ namespace sdr
                                // for SC, the caption object may have a 
specialized shadow. The usual object shadow is off
                                // and a specialized shadow gets created here 
(see old paint)
                                const SdrShadowColorItem& rShadColItem = 
(SdrShadowColorItem&)(rItemSet.Get(SDRATTR_SHADOWCOLOR));
-                               const sal_uInt16 
nTransp(((SdrShadowTransparenceItem&)(rItemSet.Get(SDRATTR_SHADOWTRANSPARENCE))).GetValue());
-                               const Color 
aShadCol(rShadColItem.GetColorValue());
-                               const XFillStyle eStyle = 
((XFillStyleItem&)(rItemSet.Get(XATTR_FILLSTYLE))).GetValue();
+                               const sal_uInt16 
nShadowTransparence(((SdrShadowTransparenceItem&)(rItemSet.Get(SDRATTR_SHADOWTRANSPARENCE))).GetValue());
+                               const Color 
aShadowColor(rShadColItem.GetColorValue());
+                               const XFillStyle eShadowStyle = 
((XFillStyleItem&)(rItemSet.Get(XATTR_FILLSTYLE))).GetValue();
 
                                // Create own ItemSet and modify as needed
                                // Always hide lines for special calc shadow
                                SfxItemSet aSet(rItemSet);
                                aSet.Put(XLineStyleItem(XLINE_NONE));
 
-                               if(XFILL_HATCH == eStyle)
+                               if(XFILL_HATCH == eShadowStyle)
                                {
                                        // #41666# Hatch color is set hard to 
shadow color
                                        XHatch aHatch = 
((XFillHatchItem&)(rItemSet.Get(XATTR_FILLHATCH))).GetHatchValue();
-                                       aHatch.SetColor(aShadCol);
+                                       aHatch.SetColor(aShadowColor);
                                        
aSet.Put(XFillHatchItem(String(),aHatch));
                                }
                                else
                                {
-                                       if(XFILL_NONE != eStyle && XFILL_SOLID 
!= eStyle)
+                                       if(XFILL_SOLID != eShadowStyle)
                                        {
-                                               // force fill to solid (for 
Gradient and Bitmap)
+                                               // force fill to solid (for 
Gradient, Bitmap and *no* fill (#119750# not filled comments *have* shadow))
                                                
aSet.Put(XFillStyleItem(XFILL_SOLID));
                                        }
 
-                                       
aSet.Put(XFillColorItem(String(),aShadCol));
-                                       
aSet.Put(XFillTransparenceItem(nTransp));
+                                       
aSet.Put(XFillColorItem(String(),aShadowColor));
+                                       
aSet.Put(XFillTransparenceItem(nShadowTransparence));
                                }
 
                                // crete FillAttribute from modified ItemSet
@@ -142,18 +143,43 @@ namespace sdr
                                        // add shadow offset to object matrix
                                        const sal_uInt32 
nXDist(((SdrShadowXDistItem&)(rItemSet.Get(SDRATTR_SHADOWXDIST))).GetValue());
                                        const sal_uInt32 
nYDist(((SdrShadowYDistItem&)(rItemSet.Get(SDRATTR_SHADOWYDIST))).GetValue());
-                                       aObjectMatrix.translate(nXDist, nYDist);
-                                       
-                                       // create unit outline polygon as 
geometry (see SdrCaptionPrimitive2D::create2DDecomposition)
-                                       basegfx::B2DPolygon 
aUnitOutline(basegfx::tools::createPolygonFromRect(
-                                               basegfx::B2DRange(0.0, 0.0, 
1.0, 1.0), fCornerRadiusX, fCornerRadiusY));
-
-                                       // create the specialized shadow 
primitive
-                                       xSpecialShadow = 
drawinglayer::primitive2d::createPolyPolygonFillPrimitive(
-                                               
basegfx::B2DPolyPolygon(aUnitOutline), 
-                                               aObjectMatrix, 
-                                               aFill,
-                                               
drawinglayer::attribute::FillGradientAttribute());
+
+                    if(nXDist || nYDist)
+                    {
+                        // #119750# create obect and shadow outline, clip 
shadow outline
+                        // on object outline. If there is a rest, create 
shadow. Do this to
+                        // emulate that shadow is *not* visible behind the 
object for
+                        // transparent object fill for comments in excel
+                        basegfx::B2DPolygon aObjectOutline(
+                            basegfx::tools::createPolygonFromRect(
+                                basegfx::B2DRange(0.0, 0.0, 1.0, 1.0), 
+                                fCornerRadiusX, 
+                                fCornerRadiusY));
+                        aObjectOutline.transform(aObjectMatrix);
+
+                        // create shadow outline
+                        basegfx::B2DPolygon aShadowOutline(aObjectOutline);
+                        aShadowOutline.transform(
+                            
basegfx::tools::createTranslateB2DHomMatrix(nXDist, nYDist));
+
+                        // clip shadow outline against object outline
+                        const basegfx::B2DPolyPolygon aClippedShadow(
+                            basegfx::tools::clipPolygonOnPolyPolygon(
+                                aShadowOutline, 
+                                basegfx::B2DPolyPolygon(aObjectOutline), 
+                                false, // take the outside
+                                false));
+
+                        if(aClippedShadow.count())
+                        {
+                            // if there is shadow, create the specialized 
shadow primitive
+                            xSpecialShadow = 
drawinglayer::primitive2d::createPolyPolygonFillPrimitive(
+                                aClippedShadow, 
+                                basegfx::B2DHomMatrix(), 
+                                aFill,
+                                
drawinglayer::attribute::FillGradientAttribute());
+                        }
+                    }
                                }
 
                                if(xSpecialShadow.is())


Reply via email to