summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
Diffstat (limited to 'oox')
-rw-r--r--oox/inc/drawingml/fillproperties.hxx2
-rw-r--r--oox/source/drawingml/fillproperties.cxx89
-rw-r--r--oox/source/drawingml/shape.cxx6
-rw-r--r--oox/source/ppt/slidepersist.cxx7
-rw-r--r--oox/source/shape/WpsContext.cxx3
5 files changed, 90 insertions, 17 deletions
diff --git a/oox/inc/drawingml/fillproperties.hxx b/oox/inc/drawingml/fillproperties.hxx
index 828c858e12f2..3323907fcad8 100644
--- a/oox/inc/drawingml/fillproperties.hxx
+++ b/oox/inc/drawingml/fillproperties.hxx
@@ -24,6 +24,7 @@
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/geometry/IntegerRectangle2D.hpp>
+#include <com/sun/star/awt/Size.hpp>
#include <com/sun/star/uno/Any.hxx>
#include <com/sun/star/uno/Reference.hxx>
#include <oox/drawingml/color.hxx>
@@ -147,6 +148,7 @@ struct FillProperties
const GraphicHelper& rGraphicHelper,
sal_Int32 nShapeRotation = 0,
::Color nPhClr = API_RGB_TRANSPARENT,
+ const css::awt::Size& rSize = {},
sal_Int16 nPhClrTheme = -1,
bool bFlipH = false,
bool bFlipV = false,
diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx
index d193653d7189..98a048d7f8ac 100644
--- a/oox/source/drawingml/fillproperties.cxx
+++ b/oox/source/drawingml/fillproperties.cxx
@@ -423,9 +423,10 @@ Color FillProperties::getBestSolidColor() const
return aSolidColor;
}
-void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap,
- const GraphicHelper& rGraphicHelper, sal_Int32 nShapeRotation, ::Color nPhClr, sal_Int16 nPhClrTheme,
- bool bFlipH, bool bFlipV, bool bIsCustomShape) const
+void FillProperties::pushToPropMap(ShapePropertyMap& rPropMap, const GraphicHelper& rGraphicHelper,
+ sal_Int32 nShapeRotation, ::Color nPhClr,
+ const css::awt::Size& rSize, sal_Int16 nPhClrTheme, bool bFlipH,
+ bool bFlipV, bool bIsCustomShape) const
{
if( !moFillType.has_value() )
return;
@@ -824,7 +825,6 @@ void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap,
{
// bitmap mode (single, repeat, stretch)
BitmapMode eBitmapMode = lclGetBitmapMode( maBlipProps.moBitmapMode.value_or( XML_TOKEN_INVALID ) );
- rPropMap.setProperty( ShapeProperty::FillBitmapMode, eBitmapMode );
// additional settings for repeated bitmap
if( eBitmapMode == BitmapMode_REPEAT )
@@ -872,21 +872,82 @@ void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap,
// Negative GraphicCrop values means "crop" here.
bool bNeedCrop = aGraphCrop.Left <= 0 && aGraphCrop.Right <= 0 && aGraphCrop.Top <= 0 && aGraphCrop.Bottom <= 0;
- if(bIsCustomShape && bHasCropValues && bNeedCrop)
+ if (bHasCropValues)
{
- // Physically crop the image
- // In this case, don't set the PROP_GraphicCrop because that
- // would lead to applying the crop twice after roundtrip
- xGraphic = lclCropGraphic(xGraphic, CropQuotientsFromFillRect(aFillRect));
- if (rPropMap.supportsProperty(ShapeProperty::FillBitmapName))
- rPropMap.setProperty(ShapeProperty::FillBitmapName, xGraphic);
+ if (bIsCustomShape && bNeedCrop)
+ {
+ // Physically crop the image
+ // In this case, don't set the PROP_GraphicCrop because that
+ // would lead to applying the crop twice after roundtrip
+ xGraphic = lclCropGraphic(xGraphic, CropQuotientsFromFillRect(aFillRect));
+ if (rPropMap.supportsProperty(ShapeProperty::FillBitmapName))
+ rPropMap.setProperty(ShapeProperty::FillBitmapName, xGraphic);
+ else
+ rPropMap.setProperty(ShapeProperty::FillBitmap, xGraphic);
+ }
+ else if ((aFillRect.X1 != 0 && aFillRect.X2 != 0
+ && aFillRect.X1 != aFillRect.X2)
+ || (aFillRect.Y1 != 0 && aFillRect.Y2 != 0
+ && aFillRect.Y1 != aFillRect.Y2))
+ {
+ rPropMap.setProperty(PROP_GraphicCrop, aGraphCrop);
+ }
else
- rPropMap.setProperty(ShapeProperty::FillBitmap, xGraphic);
+ {
+ double nL = aFillRect.X1 / static_cast<double>(MAX_PERCENT);
+ double nT = aFillRect.Y1 / static_cast<double>(MAX_PERCENT);
+ double nR = aFillRect.X2 / static_cast<double>(MAX_PERCENT);
+ double nB = aFillRect.Y2 / static_cast<double>(MAX_PERCENT);
+
+ sal_Int32 nSizeX;
+ if (nL || nR)
+ nSizeX = rSize.Width * (1 - (nL + nR));
+ else
+ nSizeX = rSize.Width;
+ rPropMap.setProperty(ShapeProperty::FillBitmapSizeX, nSizeX);
+
+ sal_Int32 nSizeY;
+ if (nT || nB)
+ nSizeY = rSize.Height * (1 - (nT + nB));
+ else
+ nSizeY = rSize.Height;
+ rPropMap.setProperty(ShapeProperty::FillBitmapSizeY, nSizeY);
+
+ RectanglePoint eRectPoint;
+ if (!aFillRect.X1 && aFillRect.X2)
+ {
+ if (!aFillRect.Y1 && aFillRect.Y2)
+ eRectPoint = lclGetRectanglePoint(XML_tl);
+ else if (aFillRect.Y1 && !aFillRect.Y2)
+ eRectPoint = lclGetRectanglePoint(XML_bl);
+ else
+ eRectPoint = lclGetRectanglePoint(XML_l);
+ }
+ else if (aFillRect.X1 && !aFillRect.X2)
+ {
+ if (!aFillRect.Y1 && aFillRect.Y2)
+ eRectPoint = lclGetRectanglePoint(XML_tr);
+ else if (aFillRect.Y1 && !aFillRect.Y2)
+ eRectPoint = lclGetRectanglePoint(XML_br);
+ else
+ eRectPoint = lclGetRectanglePoint(XML_r);
+ }
+ else
+ {
+ if (!aFillRect.Y1 && aFillRect.Y2)
+ eRectPoint = lclGetRectanglePoint(XML_t);
+ else if (aFillRect.Y1 && !aFillRect.Y2)
+ eRectPoint = lclGetRectanglePoint(XML_b);
+ else
+ eRectPoint = lclGetRectanglePoint(XML_ctr);
+ }
+ rPropMap.setProperty(ShapeProperty::FillBitmapRectanglePoint, eRectPoint);
+ eBitmapMode = BitmapMode_NO_REPEAT;
+ }
}
- else
- rPropMap.setProperty(PROP_GraphicCrop, aGraphCrop);
}
}
+ rPropMap.setProperty(ShapeProperty::FillBitmapMode, eBitmapMode);
}
if (maBlipProps.moAlphaModFix.has_value())
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 18e087dc2207..b8cac0d8f385 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -719,6 +719,7 @@ static void lcl_copyCharPropsToShape(const uno::Reference<drawing::XShape>& xSha
rCharProps.maFillProperties.pushToPropMap(aFillShapeProps, rFilter.getGraphicHelper(),
/*nShapeRotation*/ 0,
/*nPhClr*/ API_RGB_TRANSPARENT,
+ /*aShapeSize*/ css::awt::Size(0, 0),
/*nPhClrTheme*/ -1,
/*bFlipH*/ false, /*bFlipV*/ false,
/*bIsCustomShape*/ true);
@@ -1286,7 +1287,10 @@ Reference< XShape > const & Shape::createAndInsert(
if (getFillProperties().moFillType.has_value() && getFillProperties().moFillType.value() == XML_grpFill)
getFillProperties().assignUsed(aFillProperties);
if(!bIsCroppedGraphic)
- aFillProperties.pushToPropMap( aShapeProps, rGraphicHelper, mnRotation, nFillPhClr, nFillPhClrTheme, mbFlipH, mbFlipV, bIsCustomShape );
+ aFillProperties.pushToPropMap(aShapeProps, rGraphicHelper, mnRotation, nFillPhClr,
+ css::awt::Size(aShapeRectHmm.Width, aShapeRectHmm.Height),
+ nFillPhClrTheme, mbFlipH, mbFlipV, bIsCustomShape);
+
LineProperties aLineProperties = getActualLineProperties(pTheme);
aLineProperties.pushToPropMap( aShapeProps, rGraphicHelper, nLinePhClr, nLinePhClrTheme);
EffectProperties aEffectProperties = getActualEffectProperties(pTheme);
diff --git a/oox/source/ppt/slidepersist.cxx b/oox/source/ppt/slidepersist.cxx
index 7298eea1247c..bb673b52442e 100644
--- a/oox/source/ppt/slidepersist.cxx
+++ b/oox/source/ppt/slidepersist.cxx
@@ -193,11 +193,16 @@ void SlidePersist::createBackground( const XmlFilterBase& rFilterBase )
::Color nPhClr = maBackgroundColor.isUsed() ?
maBackgroundColor.getColor( rFilterBase.getGraphicHelper() ) : API_RGB_TRANSPARENT;
+ css::awt::Size aSize;
+ Reference< css::beans::XPropertySet > xSet(mxPage, UNO_QUERY);
+ xSet->getPropertyValue("Width") >>= aSize.Width;
+ xSet->getPropertyValue("Height") >>= aSize.Height;
+
oox::drawingml::ShapePropertyIds aPropertyIds = oox::drawingml::ShapePropertyInfo::DEFAULT.mrPropertyIds;
aPropertyIds[oox::drawingml::ShapeProperty::FillGradient] = PROP_FillGradientName;
oox::drawingml::ShapePropertyInfo aPropInfo( aPropertyIds, true, false, true, false, false );
oox::drawingml::ShapePropertyMap aPropMap( rFilterBase.getModelObjectHelper(), aPropInfo );
- mpBackgroundPropertiesPtr->pushToPropMap( aPropMap, rFilterBase.getGraphicHelper(), 0, nPhClr );
+ mpBackgroundPropertiesPtr->pushToPropMap( aPropMap, rFilterBase.getGraphicHelper(), 0, nPhClr, aSize);
PropertySet( mxPage ).setProperty( PROP_Background, aPropMap.makePropertySet() );
}
}
diff --git a/oox/source/shape/WpsContext.cxx b/oox/source/shape/WpsContext.cxx
index ca87085165d8..e207f185d8fc 100644
--- a/oox/source/shape/WpsContext.cxx
+++ b/oox/source/shape/WpsContext.cxx
@@ -931,7 +931,8 @@ void WpsContext::onEndElement()
= lcl_generateFillPropertiesFromTextProps(aTextPropMap);
aCreatedFillProperties.pushToPropMap(aFillShapeProps, getFilter().getGraphicHelper(),
/*nShapeRotation*/ 0,
- /*nPhClr*/ API_RGB_TRANSPARENT, /*nPhClrTheme*/ -1,
+ /*nPhClr*/ API_RGB_TRANSPARENT,
+ /*aShapeSize*/ css::awt::Size(0, 0), /*nPhClrTheme*/ -1,
pCustomShape->IsMirroredX(), pCustomShape->IsMirroredY(),
/*bIsCustomShape*/ true);
lcl_applyShapePropsToShape(xShapePropertySet, aFillShapeProps);