oox/source/drawingml/fillproperties.cxx |   23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

New commits:
commit 40367b978e4a4ce59a1759248e599af7aecc5ba0
Author:     Gülşah Köse <[email protected]>
AuthorDate: Wed Feb 24 15:05:01 2021 +0300
Commit:     Jan Holesovsky <[email protected]>
CommitDate: Wed Mar 10 11:23:57 2021 +0100

    Reset ShapeProperty priority and handle only crop case.
    
    With 2c96bd26ec488d865370fe9d394e7c4e228e05ab we changed the
    ShapeProperty priority uncessarily. Reset the priority
    as use FillBitmapName if supported.
    
    BlipFillProperties::moFillRect negative GraphicCrop values means
    stretched. BlipFillProperties::moClipRect positive GraphicCrop
    values means stretched. We add a control to handle only stretched
    cases.
    
    Change-Id: I2eb1233d0477acf093ada36b4cc29ff34f767037
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111479
    Tested-by: Jenkins
    Reviewed-by: Gülşah Köse <[email protected]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112236
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Jan Holesovsky <[email protected]>

diff --git a/oox/source/drawingml/fillproperties.cxx 
b/oox/source/drawingml/fillproperties.cxx
index a67f9278b34e..213eaae10584 100644
--- a/oox/source/drawingml/fillproperties.cxx
+++ b/oox/source/drawingml/fillproperties.cxx
@@ -117,6 +117,8 @@ void 
lclCalculateCropPercentage(uno::Reference<graphic::XGraphic> const & xGraph
     aFillRect.Y2 = -nBottomPercentage;
 }
 
+// Crops a piece of the bitmap. Takes negative aFillRect values. Negative 
values means "crop",
+// positive values means "grow" bitmap with empty spaces. lclCropGraphic 
doesn't handle growing.
 Reference< XGraphic > lclCropGraphic(uno::Reference<graphic::XGraphic> const & 
xGraphic, geometry::IntegerRectangle2D aFillRect)
 {
     ::Graphic aGraphic(xGraphic);
@@ -764,11 +766,17 @@ void FillProperties::pushToPropMap( ShapePropertyMap& 
rPropMap,
                                     aGraphCrop.Bottom = static_cast< sal_Int32 
>( ( static_cast< double >( aOriginalSize.Height ) * aFillRect.Y2 ) / 100000 );
                                 rPropMap.setProperty(PROP_GraphicCrop, 
aGraphCrop);
 
-                                if(bIsCustomShape &&
-                                   ( aGraphCrop.Left != 0 || aGraphCrop.Right 
!= 0 || aGraphCrop.Top != 0 || aGraphCrop.Bottom != 0))
+                                bool bHasCropValues = aGraphCrop.Left != 0 || 
aGraphCrop.Right !=0 || aGraphCrop.Top != 0 || aGraphCrop.Bottom != 0;
+                                // Negative GraphicCrop values means "crop" 
here.
+                                bool bNeedCrop = aGraphCrop.Left <= 0 && 
aGraphCrop.Right <= 0 && aGraphCrop.Top <= 0 && aGraphCrop.Bottom <= 0;
+
+                                if(bIsCustomShape && bHasCropValues && 
bNeedCrop)
                                 {
                                     xGraphic = lclCropGraphic(xGraphic, 
aFillRect);
-                                    
rPropMap.setProperty(ShapeProperty::FillBitmap, xGraphic);
+                                    if 
(rPropMap.supportsProperty(ShapeProperty::FillBitmapName))
+                                        
rPropMap.setProperty(ShapeProperty::FillBitmapName, xGraphic);
+                                    else
+                                        
rPropMap.setProperty(ShapeProperty::FillBitmap, xGraphic);
                                 }
                             }
                         }
@@ -873,14 +881,15 @@ void GraphicProperties::pushToPropMap( PropertyMap& 
rPropMap, const GraphicHelpe
                     aGraphCrop.Bottom = rtl::math::round( ( static_cast< 
double >( aOriginalSize.Height ) * oClipRect.Y2 ) / 100000 );
                 rPropMap.setProperty(PROP_GraphicCrop, aGraphCrop);
 
-                if(mbIsCustomShape &&
-                   ( aGraphCrop.Left != 0 || aGraphCrop.Right != 0 || 
aGraphCrop.Top != 0 || aGraphCrop.Bottom != 0))
+                bool bHasCropValues = aGraphCrop.Left != 0 || aGraphCrop.Right 
!=0 || aGraphCrop.Top != 0 || aGraphCrop.Bottom != 0;
+                // Positive GraphicCrop values means "crop" here.
+                bool bNeedCrop = aGraphCrop.Left >= 0 && aGraphCrop.Right >= 0 
&& aGraphCrop.Top >= 0 && aGraphCrop.Bottom >= 0;
+
+                if(mbIsCustomShape && bHasCropValues && bNeedCrop)
                 {
                     geometry::IntegerRectangle2D aCropRect = oClipRect;
                     lclCalculateCropPercentage(xGraphic, aCropRect);
                     xGraphic = lclCropGraphic(xGraphic, aCropRect);
-
-                    rPropMap.setProperty(PROP_FillBitmap, xGraphic);
                 }
             }
         }
_______________________________________________
Libreoffice-commits mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to