sw/source/filter/html/htmlgrin.cxx | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-)
New commits: commit 0a5c40c9426fd20d463bc0c52b85b139f212e681 Author: Matúš Kukan <matus.ku...@collabora.com> Date: Wed Sep 17 11:57:24 2014 +0200 bnc#580834: HTML import: Embed images if source URL is a local file. Use also INET_PROT_FILE to determine whether to import images as links. (cherry picked from commits 3914a711060341345f15b83656457f90095f32d6 and 72703173066a2db5c977d422ace59d60b998bbfc and 38faee21e0b874359246e513b0a8c0af399a864d) Conflicts: sw/source/filter/html/htmlgrin.cxx Change-Id: I22a5ded92d9aac4220c0c4fa8bb8a9490f5c61a6 Reviewed-on: https://gerrit.libreoffice.org/11513 Reviewed-by: Andras Timar <andras.ti...@collabora.com> Tested-by: Andras Timar <andras.ti...@collabora.com> diff --git a/sw/source/filter/html/htmlgrin.cxx b/sw/source/filter/html/htmlgrin.cxx index be1ac1c..9e95fa8 100644 --- a/sw/source/filter/html/htmlgrin.cxx +++ b/sw/source/filter/html/htmlgrin.cxx @@ -694,8 +694,9 @@ IMAGE_SETEVENT: aFrmSize.SetHeightPercent( nPrcHeight ); aFrmSet.Put( aFrmSize ); - Graphic aEmptyGrf; - if( sGrfNm.startsWith("data:") ) + Graphic aGraphic; + INetURLObject aGraphicURL( sGrfNm ); + if( aGraphicURL.GetProtocol() == INET_PROT_DATA ) { // use embedded base64 encoded data ::com::sun::star::uno::Sequence< sal_Int8 > aPass; @@ -703,15 +704,23 @@ IMAGE_SETEVENT: ::sax::Converter::decodeBase64(aPass, sBase64Data); if( aPass.hasElements() ) { - SvMemoryStream aStream(aPass.getArray(), aPass.getLength(), STREAM_READ); - GraphicFilter::GetGraphicFilter().ImportGraphic( aEmptyGrf, OUString(), aStream ); + SvMemoryStream aStream(aPass.getArray(), aPass.getLength(), STREAM_READ); + if (GRFILTER_OK == GraphicFilter::GetGraphicFilter().ImportGraphic(aGraphic, "", aStream)) + sGrfNm = ""; } } - else + // sBaseURL is empty if the source is clipboard + else if (sBaseURL.isEmpty()) + { + if (GRFILTER_OK == GraphicFilter::GetGraphicFilter().ImportGraphic(aGraphic, aGraphicURL)) + sGrfNm = ""; + } + if (!sGrfNm.isEmpty()) { - aEmptyGrf.SetDefaultType(); + aGraphic.SetDefaultType(); } - SwFrmFmt *pFlyFmt = pDoc->Insert( *pPam, sGrfNm, aEmptyOUStr, &aEmptyGrf, + // passing empty sGrfNm here, means we don't want the graphic to be linked + SwFrmFmt *pFlyFmt = pDoc->Insert( *pPam, sGrfNm, aEmptyOUStr, &aGraphic, &aFrmSet, NULL, NULL ); SwGrfNode *pGrfNd = pDoc->GetNodes()[ pFlyFmt->GetCntnt().GetCntntIdx() ->GetIndex()+1 ]->GetGrfNode();
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits