Do not link html images only when pasting from clipboard (bnc#580834)

Change-Id: I020c4e6ed6d468e553dedd7c91979b081d6b4725
diff --git a/sw/qa/extras/htmlimport/data/picture.html b/sw/qa/extras/htmlimport/data/picture.html
index c0b2e6cd..53f0c64 100644
--- a/sw/qa/extras/htmlimport/data/picture.html
+++ b/sw/qa/extras/htmlimport/data/picture.html
@@ -3,17 +3,14 @@
  <body>
    <div>
      <p>
        This document should contain only one link. (Edit -> Links...)
        This document should contain two links. (Edit -> Links...)
      </p>
      <p>
        The picture below is supposed to be fully inserted into the document, not just as a link.
        <br/>
        <a style="display:inline-block;" href="http://www.libreoffice.org/" title="Go to the Home of LibreOffice and the LibreOffice Community page">
          <img src="../../../../../odk/docs/images/sdk_head-1.png" width="377" height="120px"/>
        </a>
      </p>
        This one is supposed to be inserted as a link, since the source is "http://..." URL.
        <br/>
      <p>
        <a style="display:inline-block;" href="http://www.libreoffice.org/" title="Go to the Home of LibreOffice and the LibreOffice Community page">
          <img src="http://www.libreoffice.org/themes/libo/images/logo.png" width="218px" height="45px"/>
        </a>
diff --git a/sw/qa/extras/htmlimport/htmlimport.cxx b/sw/qa/extras/htmlimport/htmlimport.cxx
index 592aa53..1b1459f 100644
--- a/sw/qa/extras/htmlimport/htmlimport.cxx
+++ b/sw/qa/extras/htmlimport/htmlimport.cxx
@@ -29,9 +29,16 @@ DECLARE_HTMLIMPORT_TEST(testPictureImport, "picture.html")
{
    SwXTextDocument* pTxtDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get());
    CPPUNIT_ASSERT(pTxtDoc);
    // The document contains one embeded picture and one stored as a link.
    const sfx2::LinkManager& rLinkManager = pTxtDoc->GetDocShell()->GetDoc()->GetEditShell()->GetLinkManager();
    CPPUNIT_ASSERT_EQUAL(size_t(1), rLinkManager.GetLinks().size());
    // The document contains two pictures stored as a link.
    sfx2::LinkManager& rLinkManager = pTxtDoc->GetDocShell()->GetDoc()->GetEditShell()->GetLinkManager();
    CPPUNIT_ASSERT_EQUAL(size_t(2), rLinkManager.GetLinks().size());
    rLinkManager.Remove(0,2);
    CPPUNIT_ASSERT_EQUAL(size_t(0), rLinkManager.GetLinks().size());

    // TODO: Get the data into clipboard in html format and paste

    // But when pasting we don't want images to be linked.
    CPPUNIT_ASSERT_EQUAL(size_t(0), rLinkManager.GetLinks().size());
}

DECLARE_HTMLIMPORT_TEST(testInlinedImage, "inlined_image.html")
diff --git a/sw/source/filter/html/htmlgrin.cxx b/sw/source/filter/html/htmlgrin.cxx
index f4e1e44..4e136a4 100644
--- a/sw/source/filter/html/htmlgrin.cxx
+++ b/sw/source/filter/html/htmlgrin.cxx
@@ -706,7 +706,8 @@ IMAGE_SETEVENT:
            free( aStream );
        }
    }
    else if (aGraphicURL.GetProtocol() == INET_PROT_FILE)
    // sBaseURL is empty if the source is clipboard
    else if (sBaseURL.isEmpty())
    {
        if (GRFILTER_OK == GraphicFilter::GetGraphicFilter().ImportGraphic(aGraphic, aGraphicURL))
            sGrfNm = "";