diff options
Diffstat (limited to 'oox/source/export')
-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 |