summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatúš Kukan <matus.kukan@collabora.com>2014-09-17 11:57:24 +0200
committerAndras Timar <andras.timar@collabora.com>2014-09-23 14:31:37 +0000
commit0a5c40c9426fd20d463bc0c52b85b139f212e681 (patch)
tree67d2edf656f00063970995fa0f89d9b9ff38bf31
parent446a0a0c9e77bc891e4011747e9255701c494509 (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/11513 Reviewed-by: Andras Timar <andras.timar@collabora.com> Tested-by: Andras Timar <andras.timar@collabora.com>
-rw-r--r--sw/source/filter/html/htmlgrin.cxx23
1 files changed, 16 insertions, 7 deletions
diff --git a/sw/source/filter/html/htmlgrin.cxx b/sw/source/filter/html/htmlgrin.cxx
index be1ac1c01714..9e95fa8678cf 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();