sw/source/filter/html/htmlgrin.cxx |   23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

New commits:
commit 64bed43ef763f6e4435ae31f705f9639671f14d9
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/11542
    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 231555e..d32c473 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();
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to