summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2017-07-14 14:32:22 +0200
committerMichael Stahl <mstahl@redhat.com>2017-07-14 16:20:44 +0200
commita03a0cfb1e41c357950a40623c2f8b6f5507e97d (patch)
tree863e5f8f184ee7c5c665b05e99d092b439982a49
parentc96e3e226fe4eb8f25c54cce4d653d12eda63ce2 (diff)
sw: make SwGrfNode::mpReplacementGraphic swappable
Same as previous commit, but for sw. Change-Id: Id678de3f512204437e37aaedf24e24aff7a9e592
-rw-r--r--sw/inc/ndgrf.hxx1
-rw-r--r--sw/source/core/graphic/ndgrf.cxx26
2 files changed, 27 insertions, 0 deletions
diff --git a/sw/inc/ndgrf.hxx b/sw/inc/ndgrf.hxx
index 9b1faeff2999..d80d77d4db27 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_LINK( 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 49052dfa0e23..6976b4510a04 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_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;