[Libreoffice-commits] core.git: sw/qa sw/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Jul 18 11:56:11 UTC 2018


 sw/qa/extras/htmlexport/data/transparent-image.odt |binary
 sw/qa/extras/htmlexport/htmlexport.cxx             |   11 +++++++++++
 sw/source/filter/html/htmlflywriter.cxx            |    8 +++++++-
 3 files changed, 18 insertions(+), 1 deletion(-)

New commits:
commit 6af1637d0cf85566ca8482cc284669c4968ae977
Author:     Miklos Vajna <vmiklos at collabora.co.uk>
AuthorDate: Wed Jul 18 11:35:20 2018 +0200
Commit:     Miklos Vajna <vmiklos at collabora.co.uk>
CommitDate: Wed Jul 18 13:55:46 2018 +0200

    sw HTML export: fix writing transparent images
    
    It is possible ImpGraphic::ImplSetPrepared() should handle this
    directly, though.
    
    Change-Id: I1a020a45eaded140493d7207f8e0e0dfe551cc88
    Reviewed-on: https://gerrit.libreoffice.org/57623
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/sw/qa/extras/htmlexport/data/transparent-image.odt b/sw/qa/extras/htmlexport/data/transparent-image.odt
new file mode 100644
index 000000000000..0c5fb8de0790
Binary files /dev/null and b/sw/qa/extras/htmlexport/data/transparent-image.odt differ
diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx
index 0cc519ab288d..9c5724f7212e 100644
--- a/sw/qa/extras/htmlexport/htmlexport.cxx
+++ b/sw/qa/extras/htmlexport/htmlexport.cxx
@@ -589,6 +589,17 @@ DECLARE_HTMLEXPORT_TEST(testList, "list.html")
     CPPUNIT_ASSERT(aStream.indexOf("<li>") != -1);
 }
 
+DECLARE_HTMLEXPORT_TEST(testTransparentImage, "transparent-image.odt")
+{
+    htmlDocPtr pDoc = parseHtml(maTempFile);
+    CPPUNIT_ASSERT(pDoc);
+
+    OUString aSource = getXPath(pDoc, "/html/body/p/img", "src");
+    OUString aMessage = "src attribute is: " + aSource;
+    // This was a jpeg, transparency was lost.
+    CPPUNIT_ASSERT_MESSAGE(aMessage.toUtf8().getStr(), aSource.endsWith(".gif"));
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/html/htmlflywriter.cxx b/sw/source/filter/html/htmlflywriter.cxx
index 42a45951ed81..6db21469f368 100644
--- a/sw/source/filter/html/htmlflywriter.cxx
+++ b/sw/source/filter/html/htmlflywriter.cxx
@@ -1840,7 +1840,13 @@ static Writer& OutHTML_FrameFormatGrfNode( Writer& rWrt, const SwFrameFormat& rF
                 aMimeType = "image/png";
             }
 
-            ErrCode nErr = XOutBitmap::WriteGraphic( pGrfNd->GetGrf(), aGraphicURL,
+            const Graphic& rGraphic = pGrfNd->GetGrf();
+
+            // So that Graphic::IsTransparent() can report true.
+            if (!rGraphic.isAvailable())
+                const_cast<Graphic&>(rGraphic).makeAvailable();
+
+            ErrCode nErr = XOutBitmap::WriteGraphic( rGraphic, aGraphicURL,
                     aFilterName, nFlags, &aMM100Size );
             if( nErr )
             {


More information about the Libreoffice-commits mailing list