diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2018-02-01 15:28:53 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2018-02-01 11:54:22 +0100 |
commit | e02efb621fe672aa52e56caa916cf5c3fd0a9cb8 (patch) | |
tree | 725947b541b4774722d9d4a9d11a2ac58463a753 /oox/source/drawingml | |
parent | a61747c2c375d1fe404c976d2a03125e4dc78d8f (diff) |
Change bitmap table to store XBitmap instead of GraphicObject URL
As we want to get rid of GraphicObject URLs for the more robust
image life-cycle handling, it was necessary to change the way
bitmap table stores and handles images, so that they always
store a Graphic object (wrapped in UNO object that provides the
XGraphic and XBitmap interface).
In addition this changes loading and saving from ODF (xmloff) and
OOXML (oox) filters so they don't depend on GraphicObject URL
anymore, but load or save directly to / from XGraphic or XBitmap.
Change-Id: I2b88e10056e7d6c920249d59188f86b1a5a32d21
Reviewed-on: https://gerrit.libreoffice.org/49074
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'oox/source/drawingml')
-rw-r--r-- | oox/source/drawingml/fillproperties.cxx | 19 | ||||
-rw-r--r-- | oox/source/drawingml/shapepropertymap.cxx | 11 |
2 files changed, 22 insertions, 8 deletions
diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx index d2d2775a3e3d..acb0b25e7526 100644 --- a/oox/source/drawingml/fillproperties.cxx +++ b/oox/source/drawingml/fillproperties.cxx @@ -28,6 +28,7 @@ #include <com/sun/star/awt/Gradient.hpp> #include <com/sun/star/text/GraphicCrop.hpp> #include <com/sun/star/awt/Size.hpp> +#include <com/sun/star/awt/XBitmap.hpp> #include <com/sun/star/drawing/BitmapMode.hpp> #include <com/sun/star/drawing/ColorMode.hpp> #include <com/sun/star/drawing/FillStyle.hpp> @@ -600,14 +601,24 @@ void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap, if( maBlipProps.mxGraphic.is() && rPropMap.supportsProperty( ShapeProperty::FillBitmapUrl ) ) { Reference< XGraphic > xGraphic = lclCheckAndApplyDuotoneTransform( maBlipProps, maBlipProps.mxGraphic, rGraphicHelper, nPhClr ); + uno::Reference<awt::XBitmap> xBitmap(xGraphic, uno::UNO_QUERY); // TODO: "rotate with shape" is not possible with our current core OUString aGraphicUrl = rGraphicHelper.createGraphicObject( xGraphic ); // push bitmap or named bitmap to property map - if( !aGraphicUrl.isEmpty() && rPropMap.supportsProperty( ShapeProperty::FillBitmapNameFromUrl ) && rPropMap.setProperty( ShapeProperty::FillBitmapNameFromUrl, aGraphicUrl ) ) - eFillStyle = FillStyle_BITMAP; - else if( !aGraphicUrl.isEmpty() && rPropMap.setProperty( ShapeProperty::FillBitmapUrl, aGraphicUrl ) ) - eFillStyle = FillStyle_BITMAP; + + if (!aGraphicUrl.isEmpty()) + { + if (rPropMap.supportsProperty(ShapeProperty::FillBitmapNameFromUrl) && + rPropMap.setProperty(ShapeProperty::FillBitmapNameFromUrl, xGraphic)) + { + eFillStyle = FillStyle_BITMAP; + } + else if (rPropMap.setProperty(ShapeProperty::FillBitmapUrl, aGraphicUrl)) + { + eFillStyle = FillStyle_BITMAP; + } + } // set other bitmap properties, if bitmap has been inserted into the map if( eFillStyle == FillStyle_BITMAP ) diff --git a/oox/source/drawingml/shapepropertymap.cxx b/oox/source/drawingml/shapepropertymap.cxx index b1cf0239237e..53226434dfb1 100644 --- a/oox/source/drawingml/shapepropertymap.cxx +++ b/oox/source/drawingml/shapepropertymap.cxx @@ -23,6 +23,8 @@ #include <com/sun/star/beans/NamedValue.hpp> #include <com/sun/star/drawing/LineDash.hpp> #include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp> +#include <com/sun/star/graphic/XGraphic.hpp> + #include <oox/helper/modelobjecthelper.hxx> #include <oox/token/properties.hxx> @@ -194,12 +196,13 @@ bool ShapePropertyMap::setFillBitmapUrl( sal_Int32 nPropId, const Any& rValue ) return false; } -bool ShapePropertyMap::setFillBitmapNameFromUrl( const Any& rValue ) +bool ShapePropertyMap::setFillBitmapNameFromUrl(const Any& rValue) { - if( rValue.has< OUString >() ) + if (rValue.has<uno::Reference<graphic::XGraphic>>()) { - OUString aBitmapUrlName = mrModelObjHelper.insertFillBitmapUrl( rValue.get< OUString >() ); - return !aBitmapUrlName.isEmpty() && setProperty( PROP_FillBitmapName, aBitmapUrlName ); + auto xGraphic = rValue.get<uno::Reference<graphic::XGraphic>>(); + OUString aBitmapUrlName = mrModelObjHelper.insertFillBitmapXGraphic(xGraphic); + return !aBitmapUrlName.isEmpty() && setProperty(PROP_FillBitmapName, aBitmapUrlName); } return false; } |