diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2018-02-13 21:49:57 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2018-02-14 07:47:26 +0100 |
commit | 1b02ba03bd62a712e15c15384a3d105d2c088120 (patch) | |
tree | b46f383c7ea60de65dbbede5b658a7babd813610 /oox | |
parent | 733d77570771e2536d5ce1f18ba82f68ac6c22ee (diff) |
shapes: don't use "GraphicURL" property, always use "Graphic"
With GraphicURL property on shapes (XShape) we transported the
external or internal URL to the model, which also included the
GraphicObject uniqueID style URLs. This changes that - now we
always use "Graphic" property and transfer XGraphic to and from
graphic filters. "Graphic" property is already present for XShape
so it wasn't needed to add it.
Filters changed are: OOXML (oox), ODF (xmloff), RTF and
binary MS (esherex).
Also start using originURL on Graphic which now transports the
URL of the external (linked) graphic/image if it was created that
way.
Change-Id: Ic338c60b7cfaaae354cf1e1ca3ae7a6373220230
Reviewed-on: https://gerrit.libreoffice.org/49648
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/export/drawingml.cxx | 33 | ||||
-rw-r--r-- | oox/source/export/shapes.cxx | 19 |
2 files changed, 41 insertions, 11 deletions
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index d56077c5240a..0503a088faf7 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -1325,18 +1325,16 @@ void DrawingML::WritePattFill(const Reference<XPropertySet>& rXPropSet, const cs mpFS->endElementNS( XML_a , XML_pattFill ); } -void DrawingML::WriteSrcRect( const Reference< XPropertySet >& rXPropSet, const OUString& rURL ) +void DrawingML::WriteGraphicCropProperties(uno::Reference<beans::XPropertySet> const & rXPropSet, Size const & rOriginalSize, MapMode const & rMapMode) { - GraphicObject aGraphicObject = GraphicObject::CreateGraphicObjectFromURL(rURL); - Size aOriginalSize = aGraphicObject.GetPrefSize(); - const MapMode& rMapMode = aGraphicObject.GetPrefMapMode(); + if (GetProperty(rXPropSet, "GraphicCrop")) + { + Size aOriginalSize(rOriginalSize); - // GraphicCrop is in mm100, so in case the original size is in pixels, convert it over. - if (rMapMode.GetMapUnit() == MapUnit::MapPixel) - aOriginalSize = Application::GetDefaultDevice()->PixelToLogic(aOriginalSize, MapMode(MapUnit::Map100thMM)); + // GraphicCrop is in mm100, so in case the original size is in pixels, convert it over. + if (rMapMode.GetMapUnit() == MapUnit::MapPixel) + aOriginalSize = Application::GetDefaultDevice()->PixelToLogic(aOriginalSize, MapMode(MapUnit::Map100thMM)); - if ( GetProperty( rXPropSet, "GraphicCrop" ) ) - { css::text::GraphicCrop aGraphicCropStruct; mAny >>= aGraphicCropStruct; @@ -1352,6 +1350,23 @@ void DrawingML::WriteSrcRect( const Reference< XPropertySet >& rXPropSet, const } } +void DrawingML::WriteSrcRect(const uno::Reference<beans::XPropertySet>& rxPropertySet, const OUString& rURL) +{ + GraphicObject aGraphicObject = GraphicObject::CreateGraphicObjectFromURL(rURL); + Size aOriginalSize = aGraphicObject.GetPrefSize(); + const MapMode& rMapMode = aGraphicObject.GetPrefMapMode(); + WriteGraphicCropProperties(rxPropertySet, aOriginalSize, rMapMode); +} + +void DrawingML::WriteSrcRectXGraphic(uno::Reference<beans::XPropertySet> const & rxPropertySet, + uno::Reference<graphic::XGraphic> const & rxGraphic) +{ + Graphic aGraphic(rxGraphic); + Size aOriginalSize = aGraphic.GetPrefSize(); + const MapMode& rMapMode = aGraphic.GetPrefMapMode(); + WriteGraphicCropProperties(rxPropertySet, aOriginalSize, rMapMode); +} + void DrawingML::WriteStretch( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet, const OUString& rURL ) { mpFS->startElementNS( XML_a, XML_stretch, FSEND ); diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx index 8199221686f3..e922a3bce934 100644 --- a/oox/source/export/shapes.cxx +++ b/oox/source/export/shapes.cxx @@ -1098,13 +1098,20 @@ void ShapeExport::WriteGraphicObjectShapePart( const Reference< XShape >& xShape SAL_INFO("oox.shape", "graphicObject without text"); OUString sGraphicURL; + uno::Reference<graphic::XGraphic> xGraphic; OUString sMediaURL; + Reference< XPropertySet > xShapeProps( xShape, UNO_QUERY ); bool bHasGraphicURL = xShapeProps.is() && xShapeProps->getPropertySetInfo()->hasPropertyByName("GraphicURL") && (xShapeProps->getPropertyValue("GraphicURL") >>= sGraphicURL); + + if (xShapeProps.is() && xShapeProps->getPropertySetInfo()->hasPropertyByName("Graphic")) + xShapeProps->getPropertyValue("Graphic") >>= xGraphic; + + bool bHasAnyGraphic = bHasGraphicURL || xGraphic.is(); bool bHasMediaURL = xShapeProps.is() && xShapeProps->getPropertySetInfo()->hasPropertyByName("MediaURL") && (xShapeProps->getPropertyValue("MediaURL") >>= sMediaURL); - if (!pGraphic && !bHasGraphicURL && !bHasMediaURL) + if (!pGraphic && !bHasAnyGraphic && !bHasMediaURL) { SAL_INFO("oox.shape", "no graphic or media URL found"); return; @@ -1158,8 +1165,14 @@ void ShapeExport::WriteGraphicObjectShapePart( const Reference< XShape >& xShape pFS->startElementNS( mnXmlNamespace, XML_blipFill, FSEND ); - if (pGraphic || bHasGraphicURL) + if (xGraphic.is()) + { + WriteXGraphicBlip(xShapeProps, xGraphic, false); + } + else if (pGraphic || bHasGraphicURL) + { WriteBlip(xShapeProps, sGraphicURL, false, pGraphic); + } else if (bHasMediaURL) { Reference<graphic::XGraphic> rGraphic; @@ -1172,6 +1185,8 @@ void ShapeExport::WriteGraphicObjectShapePart( const Reference< XShape >& xShape if (bHasGraphicURL) WriteSrcRect(xShapeProps, sGraphicURL); + else if (xGraphic.is()) + WriteSrcRectXGraphic(xShapeProps, xGraphic); // now we stretch always when we get pGraphic (when changing that // behavior, test n#780830 for regression, where the OLE sheet might get tiled |