3 LO-L3s fixed OBS-URL: https://build.opensuse.org/request/show/703455 OBS-URL: https://build.opensuse.org/package/show/LibreOffice:Factory/libreoffice?expand=0&rev=786
114 lines
5.9 KiB
Diff
114 lines
5.9 KiB
Diff
From 8af919d30f0f17a17ee6f5190bb31652476a52df Mon Sep 17 00:00:00 2001
|
|
From: Tamas Bunth <tamas.bunth@collabora.co.uk>
|
|
Date: Mon, 13 May 2019 01:02:07 +0200
|
|
Subject: ooxml import: supprt cropping to shape
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
Change-Id: I7bdc959921ecb0cbf19037a78b63eaeb8fc52814
|
|
Reviewed-on: https://gerrit.libreoffice.org/72206
|
|
Tested-by: Jenkins
|
|
Reviewed-by: Tamás Bunth <btomi96@gmail.com>
|
|
Reviewed-on: https://gerrit.libreoffice.org/72310
|
|
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
|
|
---
|
|
oox/inc/drawingml/graphicproperties.hxx | 3 ++-
|
|
oox/source/drawingml/fillproperties.cxx | 12 ++++++++++--
|
|
oox/source/drawingml/shape.cxx | 17 ++++++++++++++---
|
|
3 files changed, 26 insertions(+), 6 deletions(-)
|
|
|
|
diff --git a/oox/inc/drawingml/graphicproperties.hxx b/oox/inc/drawingml/graphicproperties.hxx
|
|
index 01dd96c..7a227f8 100644
|
|
--- a/oox/inc/drawingml/graphicproperties.hxx
|
|
+++ b/oox/inc/drawingml/graphicproperties.hxx
|
|
@@ -40,12 +40,13 @@ struct GraphicProperties
|
|
{
|
|
BlipFillProperties maBlipProps; ///< Properties for the graphic.
|
|
OUString m_sMediaPackageURL; ///< Audio/Video URL.
|
|
+ bool mbIsCustomShape = false;
|
|
css::uno::Reference<css::io::XInputStream> m_xMediaStream; ///< Audio/Video input stream.
|
|
|
|
/** Writes the properties to the passed property map. */
|
|
void pushToPropMap(
|
|
PropertyMap& rPropMap,
|
|
- const GraphicHelper& rGraphicHelper ) const;
|
|
+ const GraphicHelper& rGraphicHelper) const;
|
|
};
|
|
|
|
} // namespace drawingml
|
|
diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx
|
|
index a2fb6ee..be91daa 100644
|
|
--- a/oox/source/drawingml/fillproperties.cxx
|
|
+++ b/oox/source/drawingml/fillproperties.cxx
|
|
@@ -703,7 +703,7 @@ void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap,
|
|
}
|
|
}
|
|
|
|
-void GraphicProperties::pushToPropMap( PropertyMap& rPropMap, const GraphicHelper& rGraphicHelper ) const
|
|
+void GraphicProperties::pushToPropMap( PropertyMap& rPropMap, const GraphicHelper& rGraphicHelper) const
|
|
{
|
|
sal_Int16 nBrightness = getLimitedValue< sal_Int16, sal_Int32 >( maBlipProps.moBrightness.get( 0 ) / PER_PERCENT, -100, 100 );
|
|
sal_Int16 nContrast = getLimitedValue< sal_Int16, sal_Int32 >( maBlipProps.moContrast.get( 0 ) / PER_PERCENT, -100, 100 );
|
|
@@ -734,7 +734,15 @@ void GraphicProperties::pushToPropMap( PropertyMap& rPropMap, const GraphicHelpe
|
|
nBrightness = 0;
|
|
nContrast = 0;
|
|
}
|
|
- rPropMap.setProperty(PROP_Graphic, xGraphic);
|
|
+ if(mbIsCustomShape)
|
|
+ {
|
|
+ // it is a cropped graphic.
|
|
+ rPropMap.setProperty(PROP_FillStyle, FillStyle_BITMAP);
|
|
+ rPropMap.setProperty(PROP_FillBitmapMode, BitmapMode_STRETCH);
|
|
+ rPropMap.setProperty(PROP_FillBitmap, xGraphic);
|
|
+ }
|
|
+ else
|
|
+ rPropMap.setProperty(PROP_Graphic, xGraphic);
|
|
|
|
// cropping
|
|
if ( maBlipProps.moClipRect.has() )
|
|
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
|
|
index 933d909..ba3e8d7 100644
|
|
--- a/oox/source/drawingml/shape.cxx
|
|
+++ b/oox/source/drawingml/shape.cxx
|
|
@@ -647,8 +647,18 @@ Reference< XShape > const & Shape::createAndInsert(
|
|
{
|
|
aServiceName = finalizeServiceName( rFilterBase, rServiceName, aShapeRectHmm );
|
|
}
|
|
+ // Use custom shape instead of GraphicObjectShape if the image is cropped to
|
|
+ // shape. Except rectangle, which does not require further cropping
|
|
+ bool bIsCroppedGraphic = (aServiceName == "com.sun.star.drawing.GraphicObjectShape" && mpCustomShapePropertiesPtr->getShapePresetType() >= 0
|
|
+ && mpCustomShapePropertiesPtr->getShapePresetType() != XML_Rect && mpCustomShapePropertiesPtr->getShapePresetType() != XML_rect);
|
|
bool bIsCustomShape = ( aServiceName == "com.sun.star.drawing.CustomShape" ||
|
|
- aServiceName == "com.sun.star.drawing.ConnectorShape" );
|
|
+ aServiceName == "com.sun.star.drawing.ConnectorShape" ||
|
|
+ bIsCroppedGraphic);
|
|
+ if(bIsCroppedGraphic)
|
|
+ {
|
|
+ aServiceName = "com.sun.star.drawing.CustomShape";
|
|
+ mpGraphicPropertiesPtr->mbIsCustomShape = true;
|
|
+ }
|
|
bool bUseRotationTransform = ( !mbWps ||
|
|
aServiceName == "com.sun.star.drawing.LineShape" ||
|
|
aServiceName == "com.sun.star.drawing.GroupShape" ||
|
|
@@ -949,13 +959,14 @@ Reference< XShape > const & Shape::createAndInsert(
|
|
// applying properties
|
|
aShapeProps.assignUsed( getShapeProperties() );
|
|
aShapeProps.assignUsed( maDefaultShapeProperties );
|
|
- if ( bIsEmbMedia || aServiceName == "com.sun.star.drawing.GraphicObjectShape" || aServiceName == "com.sun.star.drawing.OLE2Shape" )
|
|
+ if ( bIsEmbMedia || aServiceName == "com.sun.star.drawing.GraphicObjectShape" || aServiceName == "com.sun.star.drawing.OLE2Shape" || bIsCustomShape )
|
|
mpGraphicPropertiesPtr->pushToPropMap( aShapeProps, rGraphicHelper );
|
|
if ( mpTablePropertiesPtr.get() && aServiceName == "com.sun.star.drawing.TableShape" )
|
|
mpTablePropertiesPtr->pushToPropSet( rFilterBase, xSet, mpMasterTextListStyle );
|
|
|
|
FillProperties aFillProperties = getActualFillProperties(pTheme, &rShapeOrParentShapeFillProps);
|
|
- aFillProperties.pushToPropMap( aShapeProps, rGraphicHelper, mnRotation, nFillPhClr, mbFlipH, mbFlipV );
|
|
+ if(!bIsCroppedGraphic)
|
|
+ aFillProperties.pushToPropMap( aShapeProps, rGraphicHelper, mnRotation, nFillPhClr, mbFlipH, mbFlipV );
|
|
LineProperties aLineProperties = getActualLineProperties(pTheme);
|
|
aLineProperties.pushToPropMap( aShapeProps, rGraphicHelper, nLinePhClr );
|
|
EffectProperties aEffectProperties = getActualEffectProperties(pTheme);
|
|
--
|
|
cgit v1.1
|
|
|