Hi, I have submitted a patch for review:
https://gerrit.libreoffice.org/2050 To pull it, you can do: git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/50/2050/1 Crop issue resolved Change-Id: Ia822f87c3b29acd80c50a64edb617344c3e4507b --- M oox/inc/oox/export/drawingml.hxx M oox/source/export/drawingml.cxx M oox/source/export/shapes.cxx 3 files changed, 54 insertions(+), 0 deletions(-) diff --git a/oox/inc/oox/export/drawingml.hxx b/oox/inc/oox/export/drawingml.hxx index 6198ec6..5dc79b0 100644 --- a/oox/inc/oox/export/drawingml.hxx +++ b/oox/inc/oox/export/drawingml.hxx @@ -106,6 +106,7 @@ 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 >, 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 8389b3a..72bba35 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -70,6 +70,10 @@ #include <svx/unoapi.hxx> #include <svx/svdoashp.hxx> +#include <com/sun/star/text/GraphicCrop.hpp> +#include <com/sun/star/geometry/IntegerRectangle2D.hpp> +using ::com::sun::star::geometry::IntegerRectangle2D; + using namespace ::com::sun::star; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::drawing; @@ -605,6 +609,49 @@ } } + +void DrawingML::WriteSrcRect( Reference< XPropertySet > rXPropSet, OUString& rURL ) +{ + + Size aOriginalSize; + rtl::OString aURLBS(rtl::OUStringToOString(rURL, RTL_TEXTENCODING_UTF8)); + + const char aURLBegin[] = "vnd.sun.star.GraphicObject:"; + sal_Int32 index = aURLBS.indexOfL(RTL_CONSTASCII_STRINGPARAM(aURLBegin)); + + if ( index != -1 ) + { + DBG(printf ("begin: %ld %s\n", long( sizeof( aURLBegin ) ), USS( rURL ) + RTL_CONSTASCII_LENGTH( aURLBegin ) )); + GraphicObject aGraphic = GraphicObject( aURLBS.copy(RTL_CONSTASCII_LENGTH(aURLBegin)) ); + + aOriginalSize = aGraphic.GetPrefSize(); + } + + bool bCrop,IsCropped=true; + + ::com::sun::star::text::GraphicCrop aGraphicCropStruct; + + if ( ( bCrop= GetProperty( rXPropSet, "GraphicCrop" ) ) ) + { + mAny >>= aGraphicCropStruct; + + if( (0 == aGraphicCropStruct.Left) && (0 == aGraphicCropStruct.Top) && (0 == aGraphicCropStruct.Right) && (0 == aGraphicCropStruct.Bottom) ) + { + IsCropped=false; + } + else + { + 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 41d505a..f9e6d8d5 100644 --- a/oox/source/export/shapes.cxx +++ b/oox/source/export/shapes.cxx @@ -873,6 +873,12 @@ 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; -- To view, visit https://gerrit.libreoffice.org/2050 To unsubscribe, visit https://gerrit.libreoffice.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia822f87c3b29acd80c50a64edb617344c3e4507b Gerrit-PatchSet: 1 Gerrit-Project: core Gerrit-Branch: master Gerrit-Owner: pallavi jadhav <pallavi.jad...@synerzip.com> _______________________________________________ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice