diff options
author | Matúš Kukan <matus.kukan@collabora.com> | 2014-09-17 11:57:24 +0200 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2014-09-23 02:08:18 -0700 |
commit | 374c9f7e023a06cb95694fc65f9232e21b1bad59 (patch) | |
tree | 76451965386711ca1454a0fbf5240fafc228c23e /sw | |
parent | a308c4de399595a346c602ec8500f7e0f2e58ece (diff) |
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)
Conflicts:
sw/source/filter/html/htmlgrin.cxx
Change-Id: I22a5ded92d9aac4220c0c4fa8bb8a9490f5c61a6
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/filter/html/htmlgrin.cxx | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/sw/source/filter/html/htmlgrin.cxx b/sw/source/filter/html/htmlgrin.cxx index ec6c8f9e2e91..4052027f6ffb 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,22 @@ 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 + else if (aGraphicURL.GetProtocol() == INET_PROT_FILE) + { + 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(); |