From 5d10a0180f5e9922ca197cdea00ee84bc4b2d313 Mon Sep 17 00:00:00 2001 From: Pallavi Jadhav Date: Fri, 8 Feb 2013 10:11:42 +0530 Subject: fdo#48735: Save crop information in PPTX. fdo#48735: Save crop information in PPTX. Change-Id: I8aee13b11406988ab451034f43ee41c662add5fb --- oox/inc/oox/export/drawingml.hxx | 1 + oox/source/export/drawingml.cxx | 24 ++++++++++++++++++++++++ oox/source/export/shapes.cxx | 2 ++ 3 files changed, 27 insertions(+) (limited to 'oox') diff --git a/oox/inc/oox/export/drawingml.hxx b/oox/inc/oox/export/drawingml.hxx index 6198ec608537..09da104d84e3 100644 --- a/oox/inc/oox/export/drawingml.hxx +++ b/oox/inc/oox/export/drawingml.hxx @@ -106,6 +106,7 @@ public: void WriteGradientFill( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet ); void WriteBlipFill( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet, OUString sURLPropName, sal_Int32 nXmlNamespace ); void WriteBlipFill( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet, OUString sURLPropName ); + void WriteSrcRect( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >, const OUString& ); void WriteOutline( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet ); void WriteStretch(); void WriteLinespacing( ::com::sun::star::style::LineSpacing& rLineSpacing ); diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index d26002af3d07..ead3ed2c490f 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -44,12 +44,14 @@ #include #include #include +#include #include #include #include #include #include #include +#include #include #include #include @@ -83,6 +85,7 @@ using ::com::sun::star::beans::XPropertyState; using ::com::sun::star::container::XEnumeration; using ::com::sun::star::container::XEnumerationAccess; using ::com::sun::star::container::XIndexAccess; +using ::com::sun::star::geometry::IntegerRectangle2D; using ::com::sun::star::io::XOutputStream; using ::com::sun::star::style::LineSpacing; using ::com::sun::star::text::XText; @@ -604,6 +607,27 @@ void DrawingML::WriteBlipFill( Reference< XPropertySet > rXPropSet, OUString sUR } } +void DrawingML::WriteSrcRect( Reference< XPropertySet > rXPropSet, const OUString& rURL ) +{ + Size aOriginalSize( GraphicObject::CreateGraphicObjectFromURL( rURL ).GetPrefSize() ); + + if ( GetProperty( rXPropSet, "GraphicCrop" ) ) + { + ::com::sun::star::text::GraphicCrop aGraphicCropStruct; + mAny >>= aGraphicCropStruct; + + if ( (0 != aGraphicCropStruct.Left) || (0 != aGraphicCropStruct.Top) || (0 != aGraphicCropStruct.Right) || (0 != aGraphicCropStruct.Bottom) ) + { + mpFS->singleElementNS( XML_a, XML_srcRect, + XML_l, I32S(((aGraphicCropStruct.Left) * 100000)/aOriginalSize.Width()), + XML_t, I32S(((aGraphicCropStruct.Top) * 100000)/aOriginalSize.Height()), + XML_r, I32S(((aGraphicCropStruct.Right) * 100000)/aOriginalSize.Width()), + XML_b, I32S(((aGraphicCropStruct.Bottom) * 100000)/aOriginalSize.Height()), + FSEND ); + } + } +} + void DrawingML::WriteStretch() { mpFS->startElementNS( XML_a, XML_stretch, FSEND ); diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx index 89e6440e47c7..f26a5278cb57 100644 --- a/oox/source/export/shapes.cxx +++ b/oox/source/export/shapes.cxx @@ -872,6 +872,8 @@ void ShapeExport::WriteGraphicObjectShapePart( Reference< XShape > xShape, const WriteBlip( xShapeProps, sGraphicURL, pGraphic ); + WriteSrcRect( xShapeProps, sGraphicURL ); + // now we stretch always when we get pGraphic (when changing that // behavior, test n#780830 for regression, where the OLE sheet might get tiled bool bStretch = false; -- cgit v1.2.3