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 14:10:54 +0000 |
commit | 64bed43ef763f6e4435ae31f705f9639671f14d9 (patch) | |
tree | 3c806ddabb5c684e6753398003cd4bfbb30e6927 | |
parent | b6dae49f3913464dc76992fbb2d1ee8ca9c98f07 (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 and
38faee21e0b874359246e513b0a8c0af399a864d)
Conflicts:
sw/source/filter/html/htmlgrin.cxx
Change-Id: I22a5ded92d9aac4220c0c4fa8bb8a9490f5c61a6
Reviewed-on: https://gerrit.libreoffice.org/11542
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Tested-by: Andras Timar <andras.timar@collabora.com>
-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(); |