diff options
-rw-r--r-- | sw/source/filter/html/htmlgrin.cxx | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/sw/source/filter/html/htmlgrin.cxx b/sw/source/filter/html/htmlgrin.cxx index 231555e318ac..d32c473afade 100644 --- a/sw/source/filter/html/htmlgrin.cxx +++ b/sw/source/filter/html/htmlgrin.cxx @@ -696,8 +696,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; @@ -705,15 +706,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(); |