[Libreoffice-commits] core.git: Branch 'libreoffice-5-4' - sw/inc sw/source

Michael Stahl mstahl at redhat.com
Mon Jul 17 10:33:27 UTC 2017


 sw/inc/ndgrf.hxx                 |    1 +
 sw/source/core/graphic/ndgrf.cxx |   26 ++++++++++++++++++++++++++
 2 files changed, 27 insertions(+)

New commits:
commit 524377f1815773a678721c8ad179be9dbdaf7716
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Jul 14 14:32:22 2017 +0200

    sw: make SwGrfNode::mpReplacementGraphic swappable
    
    Same as previous commit, but for sw.
    
    (cherry picked from commit a03a0cfb1e41c357950a40623c2f8b6f5507e97d)
    
    loplugin:staticmethods
    (cherry picked from commit 3039b7cae36abb7e9bfffa4fbbba023721376568)
    
    Change-Id: Id678de3f512204437e37aaedf24e24aff7a9e592
    Reviewed-on: https://gerrit.libreoffice.org/39968
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/sw/inc/ndgrf.hxx b/sw/inc/ndgrf.hxx
index 9b1faeff2999..60ae5ca36cb4 100644
--- a/sw/inc/ndgrf.hxx
+++ b/sw/inc/ndgrf.hxx
@@ -71,6 +71,7 @@ class SW_DLLPUBLIC SwGrfNode: public SwNoTextNode
     bool ImportGraphic( SvStream& rStrm );
 
     DECL_LINK( SwapGraphic, const GraphicObject*, SvStream* );
+    DECL_STATIC_LINK( SwGrfNode, SwapReplacement, const GraphicObject*, SvStream* );
 
     /** helper method to determine stream for the embedded graphic.
 
diff --git a/sw/source/core/graphic/ndgrf.cxx b/sw/source/core/graphic/ndgrf.cxx
index 72c4c3cc3f76..21b46241f253 100644
--- a/sw/source/core/graphic/ndgrf.cxx
+++ b/sw/source/core/graphic/ndgrf.cxx
@@ -401,8 +401,15 @@ const GraphicObject* SwGrfNode::GetReplacementGrfObj() const
             const_cast< SwGrfNode* >(this)->mpReplacementGraphic = new GraphicObject(rSvgDataPtr->getReplacement());
         }
         else if (GetGrfObj().GetGraphic().getPdfData().hasElements())
+        {
             // This returns the bitmap, without the pdf data.
             const_cast<SwGrfNode*>(this)->mpReplacementGraphic = new GraphicObject(GetGrfObj().GetGraphic().GetBitmapEx());
+        }
+        if (mpReplacementGraphic)
+        {
+            mpReplacementGraphic->SetSwapStreamHdl(
+                LINK(const_cast<SwGrfNode*>(this), SwGrfNode, SwapReplacement));
+        }
     }
 
     return mpReplacementGraphic;
@@ -953,6 +960,25 @@ SwContentNode* SwGrfNode::MakeCopy( SwDoc* pDoc, const SwNodeIndex& rIdx ) const
     return pGrfNd;
 }
 
+IMPL_STATIC_LINK(SwGrfNode, SwapReplacement, const GraphicObject*, pGrfObj, SvStream*)
+{
+    // replacement image is always swapped
+    if (pGrfObj->IsInSwapOut())
+    {
+        return GRFMGR_AUTOSWAPSTREAM_TEMP;
+    }
+    else if (pGrfObj->IsInSwapIn())
+    {
+        return GRFMGR_AUTOSWAPSTREAM_TEMP;
+    }
+    else
+    {
+        assert(!"why is swap handler being called?");
+    }
+
+    return GRFMGR_AUTOSWAPSTREAM_NONE;
+}
+
 IMPL_LINK( SwGrfNode, SwapGraphic, const GraphicObject*, pGrfObj, SvStream* )
 {
     SvStream* pRet;


More information about the Libreoffice-commits mailing list