[Libreoffice-commits] core.git: Branch 'feature/perfwork5' - 3 commits - filter/source include/svtools include/svx include/vcl include/xmloff oox/source sd/qa svtools/source svx/source sw/inc sw/source vcl/inc vcl/source xmloff/source

Zolnai Tamás tamas.zolnai at collabora.com
Sat Nov 22 04:30:21 PST 2014


 filter/source/msfilter/msdffimp.cxx                   |    2 
 include/svtools/grfmgr.hxx                            |   16 -
 include/svx/svdograf.hxx                              |    3 
 include/svx/svdpage.hxx                               |   17 --
 include/svx/svdundo.hxx                               |    3 
 include/vcl/graph.hxx                                 |    4 
 include/xmloff/txtparae.hxx                           |    4 
 oox/source/export/drawingml.cxx                       |   16 -
 sd/qa/unit/data/xml/fdo64586_0.xml                    |    4 
 sd/qa/unit/data/xml/n758621_0.xml                     |    4 
 sd/qa/unit/data/xml/n758621_1.xml                     |    4 
 sd/qa/unit/data/xml/n819614_0.xml                     |    2 
 svtools/source/graphic/grfmgr.cxx                     |  145 +++--------------
 svtools/source/graphic/grfmgr2.cxx                    |   52 ++----
 svx/source/sdr/contact/viewobjectcontactofgraphic.cxx |   13 -
 svx/source/svdraw/svdograf.cxx                        |   28 ---
 svx/source/svdraw/svdpage.cxx                         |   34 ----
 svx/source/svdraw/svdundo.cxx                         |   28 ---
 svx/source/unodraw/unoshap2.cxx                       |   10 -
 sw/inc/ndgrf.hxx                                      |   13 -
 sw/inc/ndole.hxx                                      |    1 
 sw/source/core/doc/notxtfrm.cxx                       |   30 +--
 sw/source/core/docnode/ndnotxt.cxx                    |    3 
 sw/source/core/edit/editsh.cxx                        |   33 ----
 sw/source/core/frmedt/fefly1.cxx                      |    3 
 sw/source/core/graphic/ndgrf.cxx                      |  146 +++---------------
 sw/source/core/layout/paintfrm.cxx                    |   21 --
 sw/source/core/ole/ndole.cxx                          |    5 
 sw/source/core/undo/unins.cxx                         |    3 
 sw/source/core/unocore/unoframe.cxx                   |   19 --
 sw/source/filter/html/htmlgrin.cxx                    |   10 -
 sw/source/filter/inc/msfilter.hxx                     |   21 --
 sw/source/filter/ww8/docxattributeoutput.cxx          |   15 -
 sw/source/filter/ww8/rtfattributeoutput.cxx           |   14 -
 sw/source/filter/ww8/writerhelper.cxx                 |   25 ---
 sw/source/filter/ww8/wrtw8esh.cxx                     |    2 
 sw/source/filter/ww8/wrtww8gr.cxx                     |    6 
 sw/source/filter/xml/xmltexte.cxx                     |   26 ---
 sw/source/filter/xml/xmltexte.hxx                     |    5 
 vcl/inc/impgraph.hxx                                  |    1 
 vcl/source/gdi/cvtgrf.cxx                             |    2 
 vcl/source/gdi/graph.cxx                              |    6 
 vcl/source/gdi/impgraph.cxx                           |   13 +
 xmloff/source/text/txtparae.cxx                       |    7 
 44 files changed, 145 insertions(+), 674 deletions(-)

New commits:
commit f9c52dd3ad40106e8e7a4e176ce725e507c5d238
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date:   Sat Nov 22 13:29:21 2014 +0100

    Skip time based auto swap out for perf test
    
    Change-Id: I8bcd51cac4d8d8d6ae26397df5b335c64c9b90e1

diff --git a/svtools/source/graphic/grfmgr.cxx b/svtools/source/graphic/grfmgr.cxx
index 5abdd9e..51ac45c 100644
--- a/svtools/source/graphic/grfmgr.cxx
+++ b/svtools/source/graphic/grfmgr.cxx
@@ -454,7 +454,7 @@ void GraphicObject::SetSwapStreamHdl(const Link& rHdl)
 {
     delete mpSwapStreamHdl, mpSwapStreamHdl = new Link( rHdl );
 
-    sal_uInt32 const nSwapOutTimeout(GetCacheTimeInMs());
+/*    sal_uInt32 const nSwapOutTimeout(GetCacheTimeInMs());
     if( nSwapOutTimeout )
     {
         if( !mpSwapOutTimer )
@@ -467,7 +467,7 @@ void GraphicObject::SetSwapStreamHdl(const Link& rHdl)
         mpSwapOutTimer->Start();
     }
     else
-        delete mpSwapOutTimer, mpSwapOutTimer = NULL;
+        delete mpSwapOutTimer, mpSwapOutTimer = NULL;*/
 }
 
 void GraphicObject::FireSwapInRequest()
commit f199ea6ef8d165c7d638532c6d593e163c4e4bf3
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date:   Fri Nov 21 22:18:14 2014 +0100

    Skip size based auto swap out for perf test
    
    Change-Id: I6d92bb57822bd7562f35430c7aa8d07481794619

diff --git a/svtools/source/graphic/grfmgr2.cxx b/svtools/source/graphic/grfmgr2.cxx
index 2ff6192..0d7a8b9 100644
--- a/svtools/source/graphic/grfmgr2.cxx
+++ b/svtools/source/graphic/grfmgr2.cxx
@@ -199,6 +199,7 @@ namespace
 
 void GraphicManager::ImplCheckSizeOfSwappedInGraphics(const GraphicObject* pGraphicToIgnore)
 {
+    return;
     // detect maximum allowed memory footprint. Use the user-settings of MaxCacheSize (defaulted
     // to 20MB) and add a decent multiplicator (experimented to find one). Limit to
     // a useful maximum for 32Bit address space
commit 17281e8202d58ee54064a29d8e7de43cc94aa76d
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date:   Fri Oct 17 10:06:10 2014 +0200

    All image cleanup related change in one commit for perf test
    
    Change-Id: I5baac12f97ea7fa36293844331ca548b7bc2cdfd
    
    Always call ImplAfterDataChange() when data is changed
    
    Call it inside ImplAssignGraphicData() which assign
    GraphicObject members using Graphic's data. With that
    ImplAfterDataChange() method also called in constructors.
    
    It's important to call ImplAfterDataChange(), because this
    will trigger the auto swaping mechanism.
    
    Change-Id: I45af91f8df2fb5b0143fcc5eb05e82e4d408d0bc
    
    Avoid using null pointer as a special indicator
    
    When ImpGraphic::ImplSwapOut() is called with null
    pointer it was assumed that it is becase the graphic is
    a link and so we don't need to swap out it actually (we can
    load it anytime using the link), only clear the graphic's
    internal data.
    
    The problem with that it can happen that ImplSwapOut()
    is called with null pointer accidentally on a non-link
    graphic object which leads to that we loose the graphic.
    Seems more robust to use an explicit indicator
    (GRFMGR_AUTOSWAPSTREAM_LINK) for links swapout.
    indicator
    
    Change-Id: Icf31524a192c7866278ba6a13eb85648aa69f554
    
    Remove manual SwapOut() call in ODF export
    
    We have a good auto swapout mechanism which will
    prevent excessive memory use.
    
    Change-Id: I362f51c724ac31704561abe8b961910f5d490f04
    
    MS export: don't need to manually swapout images after swapin them
    
    We have some good auto mechanisms for that.
    
    Change-Id: I487dbf4a5fc69c7563dfbc5c21f9ebdb05ba6b9e
    
    DOC import: avoid manual swapout call.
    
    No reason to swapout the image directly after the import
    because it will be used for rendering just a second later.
    
    Change-Id: I78c8ef9225c55f306182dc5efd7bcaf0e88521c0
    
    Make SetSwapState() an internal method
    
    So we can be sure it is always called when user data changed.
    
    Change-Id: If107907afffb85a7a57817f5807847a5c028416c
    
    Swap in graphic by SwGrfNode and not manually
    
    It's a Writer specific problem, that images lost during export
    because of not swapped in graphic data.
    Other components (Impress, Calc...) use SdrGrafObj to get the
    graphic and SdrGrafObj calls swap in before retrun with the
    graphic.
    
    Change-Id: I7398d8e3f6535199b10de048acd58543bdb42531
    
    Avoid an image loss situation of auto swapping
    
    Before an image data is used GraphicObject should be swapped in.
    When a GraphicObject is swapped in auto swapping mechanism
    is triggered which can swap out some of the images.
    We should avoid to swap out the same image on which the swap
    in method was called before because the caller code assumes that
    the image data is there.
    
    Change-Id: Ia4addc370742aea5fbf185cf87e3c062a5ebf5be
    
    Assign graphic data also during auto swap in
    
    Change-Id: I09b8d11027f4a1e8470b81677388d4a573b372a6
    
    Ignore the swapped in graphic, but use its size
    
    Change-Id: I75f17ab5e55119965fcede2b220979cefc1e26ab
    
    Remove these useless static bool variables.
    
    Change-Id: I7a8ad7814231f129d5d1146ceb36eb2c22b2aff1
    
    More useless static bool variables.
    
    Change-Id: If09aa23768f73bbf659966e4e5aac82dca83d1b6
    
    Paint background images always via drawinglayer
    
    Painting via GraphicObject is obsolete.
    See fdo#68927 where the problem was the quality of svg
    graphics, it seems a good idea to extend this improvement
    to all graphic type.
    
    Change-Id: I57a26d4fcfea8e4f666504a90281365e8a9a7e1d
    
    Remove unused IsInSwap() method
    
    Change-Id: Ib295bd71b5cf16fd75d04818dfd415ff24cb2655
    
    Printing: remove an other manual swap out call
    
    Change-Id: I2b6d6eaa072d9948eb5734e978d68d3bc37701b2
    
    SvxGraphicObject: remove more manual swap out calls
    
    Tested with importing large *.rtf and *.docx test documents
    with lots of images -> auto swapp out works.
    
    Change-Id: Ib040edaa89c9bcb966c58b75f0392e6d9f7a165e
    
    SdrUndoDelObj: one more manual swap out call
    
    This thing seems a good optimization to me, but
    it would be good to hide all of this swapping thing
    inside GraphicObject class, to make our code more
    robust (e.g. no image loss because of missing
    manual swap in / swap out call).
    Auto swapping mechanism will take care of that, anyway.
    
    Change-Id: I933dafd95597ffff038dc6aeb0a64fcaa3941bd8
    
    Remove duplicated swapping methods
    
    Change-Id: I0e61aeb0705ed13872d252ee1594f9ab4aab4f8a
    
    ForceSwap{In,Out}Objects methods are unused now
    
    They are called only by themselves recuirsively,
    but not from outside.
    
    Change-Id: I1cde392c95bbc60ac7937d0bf3cd4b0fd062568b
    
    More unused swapping related methods / member of SdrPage
    
    Change-Id: I4a979dd09418df4526409d9026d6abb98c6bf954
    
    Make GetTwipSize() call SwapIn() by itself in case of invalid size
    
    Change-Id: I5bc6cf097e61d65007dde531af4a213b19e8ca5b
    
    More replacements of manual swapping with SwGrfNode::GetGrf()/GetGrfObj()
    
    Change-Id: Ie56584c03af8a6d3ea8f8d4294f5492a841933b7
    
    Be explicit here when to swap out as a link
    
    Change-Id: I70dd00d5f82c5f4f622805e1d6ee1dfc30900b31
    
    Remove unused Graphic member of SwOLENode
    
    Change-Id: Iaff7e86a8e11e9befc6feacdafd3a78a1971bbcd
    
    Swapping Graphic is a privilage of GraphicObject.
    
    This means more things:
    * Graphic won't swap out itself, so those classes which uses
    Graphic without GraphicObject won't need to deal with swapping.
    * When a Graphic is queried from GraphicObject the caller won't
    need to deal with swapping, because GraphicObject swaps it in
    before return.
    * GraphicObject will swap in the Graphic always when a swapping
    dependent data is queried (e.g. whole graphic, transformed graphic
    or AnimationNotifyHdl)
    
    Change-Id: I2bf6e37291ec94146f10aac4a35084682437ed16
    
    Why to have this compromise, do that what we say the users we do.
    
    Change-Id: Ia599644ff1f7591ac84bdca988883eaf5860297e
    
    Make SwGrfNode swapping methods private
    
    Change the filter test accordingly.
    
    Conflicts:
    	sw/CppunitTest_sw_globalfilter.mk
    	sw/qa/extras/globalfilter/globalfilter.cxx
    
    Change-Id: Ide3043f2f245c097a7b4c07ba2e0713510296b3e
    
    Remove some useless swapping call inside SwGrfNode
    
    Change-Id: I4cd2677197c7a6cff71e2966c2b2dd2285032c07
    
    Make SdrGrafObj swapping methods private.
    
    Plus remove some useless call of them.
    
    Change the tests accordingly.
    
    Conflicts:
    	sc/qa/unit/data/ods/document_with_two_images.ods
    	sc/qa/unit/subsequent_export-test.cxx
    	sd/qa/unit/export-tests.cxx
    
    Change-Id: I47a50b5734d799ac02ee7221c95f82415afb9497
    
    Optimize ImplCheckSizeOfSwappedInGraphics() a bit
    
    Store used size as a member so we don't need to recalculate it
    all the time and no need to use a size map.
    
    Change-Id: I1f929c5d3a56f545cef123bda087ecaf8ca0be4a
    
    Avoid DelStreamName because it can lead to image loss.
    
    See also:
    f811e628411bda29a76ebb1f72eb107ce67d27f0
    
    The problem is that more images can have the same stream name
    so we can't decide here when to remove one stream name. Better
    to leak in the storage as to loose images (actually we already
    leak here, so)
    
    Change-Id: I2c2afe87e024c2521fe22d62126b567931604101
    
    Set back these lines, later it can be useful
    
    Removed in:
    9dc3b49c891fb9fe45c24de4b7e1e88fe400afe0
    
    Change-Id: Id8cee4e17d214ca0eaa5cd11dc25849e5f68851e
    
    Logically dead code related to embedded stream name in SwGrfNode\SdrGrafObj
    
    See also:
    286e2f5c6ec829bc0987b1be7016699f7ef03e5e
    
    Since embedded URL exists until the first swap in these lines
    are not needed anymore.
    
    Change-Id: Ie6bf8efe7808cf42f20f7b4b3f8cb927555c0ea8
    
    Remove now useless setTextEmbeddedGraphicURL()
    
    Since this commit:
    286e2f5c6ec829bc0987b1be7016699f7ef03e5e
    it's not necessary to update the package URL.
    
    Change-Id: I25c829e9bc0c666838baf19cd60f19938ebb430c

diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx
index 743409f..7eecc3f 100644
--- a/filter/source/msfilter/msdffimp.cxx
+++ b/filter/source/msfilter/msdffimp.cxx
@@ -3970,11 +3970,9 @@ SdrObject* SvxMSDffManager::ImportGraphic( SvStream& rSt, SfxItemSet& rSet, cons
 
         if ( bLinkGrf && !bGrfRead )
         {
-            static_cast<SdrGrafObj*>(pRet)->ForceSwapIn();
             Graphic aGraf(static_cast<SdrGrafObj*>(pRet)->GetGraphic());
             lcl_ApplyCropping( *this, &rSet, aGraf );
         }
-        static_cast<SdrGrafObj*>(pRet)->ForceSwapOut();
     }
 
     return pRet;
diff --git a/include/svtools/grfmgr.hxx b/include/svtools/grfmgr.hxx
index 30ac634..2bdbc9a 100644
--- a/include/svtools/grfmgr.hxx
+++ b/include/svtools/grfmgr.hxx
@@ -313,6 +313,7 @@ protected:
 
     virtual void            GraphicManagerDestroyed();
     virtual SvStream*       GetSwapStream() const;
+    void                    SetSwapState();
 
     virtual void            Load( SvStream& ) SAL_OVERRIDE;
     virtual void            Save( SvStream& ) SAL_OVERRIDE;
@@ -411,7 +412,7 @@ public:
     bool                    IsAnimated() const { return mbAnimated; }
     bool                    IsEPS() const { return mbEPS; }
 
-    Link                    GetAnimationNotifyHdl() const { return maGraphic.GetAnimationNotifyHdl(); }
+    Link                    GetAnimationNotifyHdl() const { return GetGraphic().GetAnimationNotifyHdl(); }
 
     bool                    SwapOut();
     bool                    SwapOut( SvStream* pOStm );
@@ -419,9 +420,7 @@ public:
 
     bool                    IsInSwapIn() const { return mbIsInSwapIn; }
     bool                    IsInSwapOut() const { return mbIsInSwapOut; }
-    bool                    IsInSwap() const { return( mbIsInSwapOut || mbIsInSwapOut ); }
     bool                    IsSwappedOut() const { return( mbAutoSwapped || maGraphic.IsSwapOut() ); }
-    void                    SetSwapState();
 
     bool                    Draw(
                                 OutputDevice* pOut,
@@ -431,14 +430,6 @@ public:
                                 sal_uLong nFlags = GRFMGR_DRAW_STANDARD
                             );
 
-    bool                    DrawWithPDFHandling(
-                                OutputDevice& rOutDev,
-                                const Point& rPt,
-                                const Size& rSz,
-                                const GraphicAttr* pGrfAttr = NULL,
-                                const sal_uLong nFlags = GRFMGR_DRAW_STANDARD
-                            );
-
     /** Draw the graphic repeatedly into the given output rectangle
 
         @param pOut
@@ -529,6 +520,7 @@ class SVT_DLLPUBLIC GraphicManager
 private:
 
     GraphicObjectList_impl  maObjList;
+    sal_uLong               mnUsedSize; // currently used memory footprint of all swapped in graphics
     GraphicCache*           mpCache;
 
                         GraphicManager( const GraphicManager& ) {}
@@ -615,7 +607,7 @@ private:
     // For 32Bit systems this leads to situations where graphics will be missing. This method will actively swap out
     // the longest swapped in graphics until a maximum memory boundary (derived from user settings in tools/options/memory)
     // is no longer exceeded
-    void SVT_DLLPRIVATE ImplCheckSizeOfSwappedInGraphics();
+    void SVT_DLLPRIVATE ImplCheckSizeOfSwappedInGraphics(const GraphicObject* pGraphicToIgnore);
 public:
 
                         GraphicManager( sal_uLong nCacheSize = 10000000UL, sal_uLong nMaxObjCacheSize = 2400000UL );
diff --git a/include/svx/svdograf.hxx b/include/svx/svdograf.hxx
index cd47a207..d6cb3d2 100644
--- a/include/svx/svdograf.hxx
+++ b/include/svx/svdograf.hxx
@@ -69,6 +69,7 @@ private:
 
     // to allow sdr::contact::ViewObjectContactOfGraphic access to ImpUpdateGraphicLink()
     friend class sdr::contact::ViewObjectContactOfGraphic;
+    friend class SdrExchangeView; // Only for a ForceSwapIn() call.
     friend class SdrGraphicLink;
 
 private:
@@ -135,9 +136,11 @@ public:
     void                    SetGrafStreamURL( const OUString& rGraphicStreamURL );
     OUString                GetGrafStreamURL() const;
 
+private:
     void                    ForceSwapIn() const;
     void                    ForceSwapOut() const;
 
+public:
     void                    SetGraphicLink(const OUString& rFileName, const OUString& rReferer, const OUString& rFilterName);
     void                    ReleaseGraphicLink();
     bool IsLinkedGraphic() const;
diff --git a/include/svx/svdpage.hxx b/include/svx/svdpage.hxx
index b098f1b..21fbc35 100644
--- a/include/svx/svdpage.hxx
+++ b/include/svx/svdpage.hxx
@@ -169,14 +169,6 @@ public:
     // Zaehlt alle Objekte inkl. Objekte in Objektgruppen, ...
     size_t CountAllObjects() const;
 
-    // Alle aufgelagerten Teile (z.B. Grafiken) der Liste in den
-    // Speicher laden.
-    void    ForceSwapInObjects() const;
-    void    ForceSwapOutObjects() const;
-
-    void    SwapInAll() const { ForceSwapInObjects(); }
-    void    SwapOutAll() const { ForceSwapOutObjects(); }
-
     /** Makes the object list flat, i.e. the object list content are
         then tree leaves
 
@@ -473,7 +465,6 @@ protected:
     bool                mbMaster : 1;               // flag if this is a MasterPage
     bool                mbInserted : 1;
     bool                mbObjectsNotPersistent : 1;
-    bool                mbSwappingLocked : 1;
 
     // #i93597#
     bool                mbPageBorderOnlyLeftRight : 1;
@@ -549,14 +540,6 @@ public:
     virtual const SdrPageGridFrameList* GetGridFrameList(const SdrPageView* pPV, const Rectangle* pRect) const;
     bool IsObjectsNotPersistent() const          { return mbObjectsNotPersistent; }
     void SetObjectsNotPersistent(bool b)     { mbObjectsNotPersistent = b; }
-    // Durch Setzen dieses Flags, kann das Auslagern (Swappen) von
-    // Teilen der Page (z.B. Grafiken) unterbunden werden.
-    // Es werden hierdurch jedoch nicht automatisch alle ausgelagerten
-    // Teile nachgeladen, dies geschieht erst bei konkretem Bedarf oder
-    // durch Aufruf von SwapInAll().
-    // Fuer die MasterPage(s) der Page muss dies ggf. separat gemacht werden.
-    bool IsSwappingLocked() const { return mbSwappingLocked; }
-    void SetSwappingLocked(bool bLock) { mbSwappingLocked = bLock; }
 
     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getUnoPage();
 
diff --git a/include/svx/svdundo.hxx b/include/svx/svdundo.hxx
index 739244f..c3e4861 100644
--- a/include/svx/svdundo.hxx
+++ b/include/svx/svdundo.hxx
@@ -301,9 +301,6 @@ public:
 
 class SVX_DLLPUBLIC SdrUndoDelObj : public SdrUndoRemoveObj
 {
-private:
-    void TryToFlushGraphicContent();
-
 public:
     SdrUndoDelObj(SdrObject& rNewObj, bool bOrdNumDirect = false);
 
diff --git a/include/vcl/graph.hxx b/include/vcl/graph.hxx
index 24d9e42..8727b9c 100644
--- a/include/vcl/graph.hxx
+++ b/include/vcl/graph.hxx
@@ -176,12 +176,16 @@ public:
     const OUString&       GetDocFileName() const;
     sal_uLong               GetDocFilePos() const;
 
+private:
+    friend class GraphicObject;
     bool                SwapOut();
+    void                SwapOutAsLink();
     bool                SwapOut( SvStream* pOStm );
     bool                SwapIn();
     bool                SwapIn( SvStream* pIStm );
     bool                IsSwapOut() const;
 
+public:
     void                SetLink( const GfxLink& );
     GfxLink             GetLink() const;
     bool                IsLink() const;
diff --git a/include/xmloff/txtparae.hxx b/include/xmloff/txtparae.hxx
index 37ec27b..a7369ea 100644
--- a/include/xmloff/txtparae.hxx
+++ b/include/xmloff/txtparae.hxx
@@ -380,10 +380,6 @@ protected:
         bool bAutoStyles,
         const ::com::sun::star::uno::Reference <
             ::com::sun::star::beans::XPropertySet > *pRangePropSet = 0  );
-    virtual void setTextEmbeddedGraphicURL(
-        const ::com::sun::star::uno::Reference <
-                ::com::sun::star::beans::XPropertySet >& rPropSet,
-        OUString& rStreamName ) const;
 
     /// export a footnote and styles
     void exportTextFootnote(
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 0629f2c..6b0e4dc 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -866,19 +866,6 @@ OUString DrawingML::WriteImage( const Graphic& rGraphic , bool bRelPathToMedia )
             GraphicType aType = rGraphic.GetType();
             if ( aType == GRAPHIC_BITMAP || aType == GRAPHIC_GDIMETAFILE)
             {
-                bool bSwapped = rGraphic.IsSwapOut();
-
-                //Warn rather than just happily swap in because of the comments
-                //in the sw export filters about needing to go through the
-                //hairy SwGrfNode::SwapIn which we would subvert by swapping in
-                //without it knowing about it, so while those ones are fixed we
-                //probably have to assume that we should ideally be presented
-                //here with already swapped in graphics.
-                SAL_WARN_IF(bSwapped, "oox", "attempted to output swapped out graphic");
-
-                if (bSwapped)
-                    const_cast<Graphic&>(rGraphic).SwapIn();
-
                 if ( aType == GRAPHIC_BITMAP )
                 {
                     GraphicConverter::Export( aStream, rGraphic, CVT_PNG );
@@ -891,9 +878,6 @@ OUString DrawingML::WriteImage( const Graphic& rGraphic , bool bRelPathToMedia )
                     sMediaType = "image/x-emf";
                     pExtension = ".emf";
                 }
-
-                if (bSwapped)
-                    const_cast<Graphic&>(rGraphic).SwapOut();
             }
             else
             {
diff --git a/sd/qa/unit/data/xml/fdo64586_0.xml b/sd/qa/unit/data/xml/fdo64586_0.xml
index a248783..7bbf719 100644
--- a/sd/qa/unit/data/xml/fdo64586_0.xml
+++ b/sd/qa/unit/data/xml/fdo64586_0.xml
@@ -4,7 +4,7 @@
   <FillTransparenceGradient style="LINEAR" startColor="000000" endColor="ffffff" angle="0" border="0" xOffset="50" yOffset="50" startIntensity="100" endIntensity="100" stepCount="0"/>
   <FillGradient style="LINEAR" startColor="000000" endColor="ffffff" angle="0" border="0" xOffset="50" yOffset="50" startIntensity="100" endIntensity="100" stepCount="0"/>
   <FillHatch style="SINGLE" color="3465a4" distance="20" angle="0"/>
-  <FillBitmap/>
+  <FillBitmap width="0" height="0"/>
   <LineDash style="RECT" dots="1" dotLen="20" dashes="1" dashLen="20" distance="20"/>
   <LineStart/>
   <LineEnd/>
@@ -18,7 +18,7 @@
   <FillTransparenceGradient style="LINEAR" startColor="000000" endColor="ffffff" angle="0" border="0" xOffset="50" yOffset="50" startIntensity="100" endIntensity="100" stepCount="0"/>
   <FillGradient style="LINEAR" startColor="000000" endColor="ffffff" angle="0" border="0" xOffset="50" yOffset="50" startIntensity="100" endIntensity="100" stepCount="0"/>
   <FillHatch style="SINGLE" color="3465a4" distance="20" angle="0"/>
-  <FillBitmap/>
+  <FillBitmap width="0" height="0"/>
   <LineDash style="RECT" dots="1" dotLen="20" dashes="1" dashLen="20" distance="20"/>
   <LineStart/>
   <LineEnd/>
diff --git a/sd/qa/unit/data/xml/n758621_0.xml b/sd/qa/unit/data/xml/n758621_0.xml
index 754be1d..288bf98 100644
--- a/sd/qa/unit/data/xml/n758621_0.xml
+++ b/sd/qa/unit/data/xml/n758621_0.xml
@@ -4,7 +4,7 @@
   <FillTransparenceGradient style="LINEAR" startColor="000000" endColor="ffffff" angle="0" border="0" xOffset="50" yOffset="50" startIntensity="100" endIntensity="100" stepCount="0"/>
   <FillGradient style="LINEAR" startColor="000000" endColor="ffffff" angle="0" border="0" xOffset="50" yOffset="50" startIntensity="100" endIntensity="100" stepCount="0"/>
   <FillHatch style="SINGLE" color="3465a4" distance="20" angle="0"/>
-  <FillBitmap/>
+  <FillBitmap width="0" height="0"/>
   <LineDash style="RECT" dots="1" dotLen="20" dashes="1" dashLen="20" distance="20"/>
   <LineStart/>
   <LineEnd/>
@@ -18,7 +18,7 @@
   <FillTransparenceGradient style="LINEAR" startColor="000000" endColor="ffffff" angle="0" border="0" xOffset="50" yOffset="50" startIntensity="100" endIntensity="100" stepCount="0"/>
   <FillGradient style="LINEAR" startColor="000000" endColor="ffffff" angle="0" border="0" xOffset="50" yOffset="50" startIntensity="100" endIntensity="100" stepCount="0"/>
   <FillHatch style="SINGLE" color="3465a4" distance="20" angle="0"/>
-  <FillBitmap/>
+  <FillBitmap width="0" height="0"/>
   <LineDash style="RECT" dots="1" dotLen="20" dashes="1" dashLen="20" distance="20"/>
   <LineStart/>
   <LineEnd/>
diff --git a/sd/qa/unit/data/xml/n758621_1.xml b/sd/qa/unit/data/xml/n758621_1.xml
index 0f71931..a124211 100644
--- a/sd/qa/unit/data/xml/n758621_1.xml
+++ b/sd/qa/unit/data/xml/n758621_1.xml
@@ -4,7 +4,7 @@
   <FillTransparenceGradient style="LINEAR" startColor="000000" endColor="ffffff" angle="0" border="0" xOffset="50" yOffset="50" startIntensity="100" endIntensity="100" stepCount="0"/>
   <FillGradient style="LINEAR" startColor="000000" endColor="ffffff" angle="0" border="0" xOffset="50" yOffset="50" startIntensity="100" endIntensity="100" stepCount="0"/>
   <FillHatch style="SINGLE" color="3465a4" distance="20" angle="0"/>
-  <FillBitmap/>
+  <FillBitmap width="0" height="0"/>
   <LineDash style="RECT" dots="1" dotLen="20" dashes="1" dashLen="20" distance="20"/>
   <LineStart/>
   <LineEnd/>
@@ -18,7 +18,7 @@
   <FillTransparenceGradient style="LINEAR" startColor="000000" endColor="ffffff" angle="0" border="0" xOffset="50" yOffset="50" startIntensity="100" endIntensity="100" stepCount="0"/>
   <FillGradient style="LINEAR" startColor="000000" endColor="ffffff" angle="0" border="0" xOffset="50" yOffset="50" startIntensity="100" endIntensity="100" stepCount="0"/>
   <FillHatch style="SINGLE" color="3465a4" distance="20" angle="0"/>
-  <FillBitmap/>
+  <FillBitmap width="0" height="0"/>
   <LineDash style="RECT" dots="1" dotLen="20" dashes="1" dashLen="20" distance="20"/>
   <LineStart/>
   <LineEnd/>
diff --git a/sd/qa/unit/data/xml/n819614_0.xml b/sd/qa/unit/data/xml/n819614_0.xml
index aff9c32..b7005be 100644
--- a/sd/qa/unit/data/xml/n819614_0.xml
+++ b/sd/qa/unit/data/xml/n819614_0.xml
@@ -4,7 +4,7 @@
   <FillTransparenceGradient style="LINEAR" startColor="000000" endColor="ffffff" angle="0" border="0" xOffset="50" yOffset="50" startIntensity="100" endIntensity="100" stepCount="0"/>
   <FillGradient style="LINEAR" startColor="000000" endColor="ffffff" angle="0" border="0" xOffset="50" yOffset="50" startIntensity="100" endIntensity="100" stepCount="0"/>
   <FillHatch style="SINGLE" color="3465a4" distance="20" angle="0"/>
-  <FillBitmap/>
+  <FillBitmap width="0" height="0"/>
   <LineDash style="RECT" dots="1" dotLen="20" dashes="1" dashLen="20" distance="20"/>
   <LineStart/>
   <LineEnd/>
diff --git a/svtools/source/graphic/grfmgr.cxx b/svtools/source/graphic/grfmgr.cxx
index 05c34a3..5abdd9e 100644
--- a/svtools/source/graphic/grfmgr.cxx
+++ b/svtools/source/graphic/grfmgr.cxx
@@ -33,8 +33,6 @@
 #include <vcl/virdev.hxx>
 #include <svtools/grfmgr.hxx>
 
-#include <vcl/pdfextoutdevdata.hxx>
-
 #include <com/sun/star/container/XNameContainer.hpp>
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <boost/scoped_ptr.hpp>
@@ -70,7 +68,7 @@ void GraphicObject::ImplAfterDataChange()
 
     // check memory footprint of all GraphicObjects managed and evtl. take action
     if (mpMgr)
-        mpMgr->ImplCheckSizeOfSwappedInGraphics();
+        mpMgr->ImplCheckSizeOfSwappedInGraphics(this);
 }
 
 GraphicObject::GraphicObject( const GraphicManager* pMgr ) :
@@ -102,6 +100,8 @@ GraphicObject::GraphicObject( const GraphicObject& rGraphicObj, const GraphicMan
     ImplConstruct();
     ImplAssignGraphicData();
     ImplSetGraphicManager( pMgr, NULL, &rGraphicObj );
+    if( rGraphicObj.HasUserData() && rGraphicObj.IsSwappedOut() )
+        SetSwapState();
 }
 
 GraphicObject::GraphicObject( const OString& rUniqueID, const GraphicManager* pMgr ) :
@@ -160,6 +160,9 @@ void GraphicObject::ImplAssignGraphicData()
     mbAnimated = maGraphic.IsAnimated();
     mbEPS = maGraphic.IsEPS();
     mnAnimationLoopCount = ( mbAnimated ? maGraphic.GetAnimationLoopCount() : 0 );
+
+    // Handle evtl. needed AfterDataChanges
+    ImplAfterDataChange();
 }
 
 void GraphicObject::ImplSetGraphicManager( const GraphicManager* pMgr, const OString* pID, const GraphicObject* pCopyObj )
@@ -260,9 +263,7 @@ void GraphicObject::ImplAutoSwapIn()
             if( !mbAutoSwapped && mpMgr )
                 mpMgr->ImplGraphicObjectWasSwappedIn( *this );
         }
-
-        // Handle evtl. needed AfterDataChanges
-        ImplAfterDataChange();
+        ImplAssignGraphicData();
     }
 }
 
@@ -351,8 +352,9 @@ GraphicObject& GraphicObject::operator=( const GraphicObject& rGraphicObj )
         ImplAssignGraphicData();
         mbAutoSwapped = false;
         mpMgr = rGraphicObj.mpMgr;
-
         mpMgr->ImplRegisterObj( *this, maGraphic, NULL, &rGraphicObj );
+        if( rGraphicObj.HasUserData() && rGraphicObj.IsSwappedOut() )
+            SetSwapState();
     }
 
     return *this;
@@ -427,6 +429,7 @@ void GraphicObject::SetUserData()
 void GraphicObject::SetUserData( const OUString& rUserData )
 {
     maUserData = rUserData;
+    SetSwapState();
 }
 
 void GraphicObject::SetSwapStreamHdl()
@@ -438,43 +441,13 @@ void GraphicObject::SetSwapStreamHdl()
     }
 }
 
-#define SWAPGRAPHIC_TIMEOUT     5000
-
-// #i122985# it is not correct to set the swap-timeout to a hard-coded 5000ms
-// as it was before.  Added code and experimented what to do as a good
-// compromise, see description.
 static sal_uInt32 GetCacheTimeInMs()
 {
-    static bool bSetAtAll(true);
-
-    if (bSetAtAll)
-    {
-        static bool bSetToPreferenceTime(true);
-
-        if (bSetToPreferenceTime)
-        {
-            const sal_uInt32 nSeconds =
-                officecfg::Office::Common::Cache::GraphicManager::ObjectReleaseTime::get(
-                    comphelper::getProcessComponentContext());
-
-
-            // The default is 10 minutes. The minimum is one minute, thus 60
-            // seconds. When the minimum should match to the former hard-coded
-            // 5 seconds, we have a divisor of 12 to use. For the default of 10
-            // minutes this would mean 50 seconds. Compared to before this is
-            // ten times more (would allow better navigation by switching
-            // through pages) and is controllable by the user by setting the
-            // tools/options/memory/Remove_from_memory_after setting. Seems to
-            // be a good compromise to me.
-            return nSeconds * 1000 / 12;
-        }
-        else
-        {
-            return SWAPGRAPHIC_TIMEOUT;
-        }
-    }
+    const sal_uInt32 nSeconds =
+        officecfg::Office::Common::Cache::GraphicManager::ObjectReleaseTime::get(
+            comphelper::getProcessComponentContext());
 
-    return 0;
+    return nSeconds * 1000;
 }
 
 void GraphicObject::SetSwapStreamHdl(const Link& rHdl)
@@ -620,67 +593,6 @@ bool GraphicObject::Draw( OutputDevice* pOut, const Point& rPt, const Size& rSz,
     return bRet;
 }
 
-// #i105243#
-bool GraphicObject::DrawWithPDFHandling( OutputDevice& rOutDev,
-                                         const Point& rPt, const Size& rSz,
-                                         const GraphicAttr* pGrfAttr,
-                                         const sal_uLong nFlags )
-{
-    const GraphicAttr aGrfAttr( pGrfAttr ? *pGrfAttr : GetAttr() );
-
-    // Notify PDF writer about linked graphic (if any)
-    bool bWritingPdfLinkedGraphic( false );
-    Point aPt( rPt );
-    Size aSz( rSz );
-    Rectangle aCropRect;
-    vcl::PDFExtOutDevData* pPDFExtOutDevData =
-            dynamic_cast<vcl::PDFExtOutDevData*>(rOutDev.GetExtOutDevData());
-    if( pPDFExtOutDevData )
-    {
-        // only delegate image handling to PDF, if no special treatment is necessary
-        if( GetGraphic().IsLink() &&
-            rSz.Width() > 0L &&
-            rSz.Height() > 0L &&
-            !aGrfAttr.IsSpecialDrawMode() &&
-            !aGrfAttr.IsMirrored() &&
-            !aGrfAttr.IsRotated() &&
-            !aGrfAttr.IsAdjusted() )
-        {
-            bWritingPdfLinkedGraphic = true;
-
-            if( aGrfAttr.IsCropped() )
-            {
-                tools::PolyPolygon aClipPolyPoly;
-                bool bRectClip;
-                const bool bCrop = ImplGetCropParams( &rOutDev,
-                                                      aPt, aSz,
-                                                      &aGrfAttr,
-                                                      aClipPolyPoly,
-                                                      bRectClip );
-                if ( bCrop && bRectClip )
-                {
-                    aCropRect = aClipPolyPoly.GetBoundRect();
-                }
-            }
-
-            pPDFExtOutDevData->BeginGroup();
-        }
-    }
-
-    bool bRet = Draw( &rOutDev, rPt, rSz, &aGrfAttr, nFlags );
-
-    // Notify PDF writer about linked graphic (if any)
-    if( bWritingPdfLinkedGraphic )
-    {
-        pPDFExtOutDevData->EndGroup( const_cast< Graphic& >(GetGraphic()),
-                                     aGrfAttr.GetTransparency(),
-                                     Rectangle( aPt, aSz ),
-                                     aCropRect );
-    }
-
-    return bRet;
-}
-
 bool GraphicObject::DrawTiled( OutputDevice* pOut, const Rectangle& rArea, const Size& rSize,
                                const Size& rOffset, const GraphicAttr* pAttr, sal_uLong nFlags, int nTileCacheSize1D )
 {
@@ -770,9 +682,7 @@ void GraphicObject::StopAnimation( OutputDevice* pOut, long nExtraData )
 const Graphic& GraphicObject::GetGraphic() const
 {
     GraphicObject *pThis = const_cast<GraphicObject*>(this);
-
-    if (mbAutoSwapped)
-        pThis->ImplAutoSwapIn();
+    pThis->SwapIn();
 
     //fdo#50697 If we've been asked to provide the graphic, then reset
     //the cache timeout to start from now and not remain at the
@@ -800,8 +710,7 @@ void GraphicObject::SetGraphic( const Graphic& rGraphic, const GraphicObject* pC
     if( mpSwapOutTimer )
         mpSwapOutTimer->Start();
 
-    // Handle evtl. needed AfterDataChanges
-    ImplAfterDataChange();
+
 }
 
 void GraphicObject::SetGraphic( const Graphic& rGraphic, const OUString& rLink )
@@ -813,7 +722,7 @@ void GraphicObject::SetGraphic( const Graphic& rGraphic, const OUString& rLink )
 Graphic GraphicObject::GetTransformedGraphic( const Size& rDestSize, const MapMode& rDestMap, const GraphicAttr& rAttr ) const
 {
     // #104550# Extracted from svx/source/svdraw/svdograf.cxx
-    Graphic             aTransGraphic( maGraphic );
+    Graphic             aTransGraphic( GetGraphic() );
     const GraphicType   eType = GetType();
     const Size          aSrcSize( aTransGraphic.GetPrefSize() );
 
@@ -1100,7 +1009,16 @@ bool GraphicObject::SwapOut()
 
 bool GraphicObject::SwapOut( SvStream* pOStm )
 {
-    const bool bRet = !mbAutoSwapped && maGraphic.SwapOut( pOStm );
+    bool bRet = !mbAutoSwapped;
+    // swap out as a link
+    if( pOStm == GRFMGR_AUTOSWAPSTREAM_LINK )
+    {
+        maGraphic.SwapOutAsLink();
+    }
+    else
+    {
+        bRet = bRet && maGraphic.SwapOut( pOStm );
+    }
 
     if( bRet && mpMgr )
         mpMgr->ImplGraphicObjectWasSwappedOut( *this );
@@ -1132,9 +1050,6 @@ bool GraphicObject::SwapIn()
     if( bRet )
     {
         ImplAssignGraphicData();
-
-        // Handle evtl. needed AfterDataChanges
-        ImplAfterDataChange();
     }
 
     return bRet;
@@ -1162,7 +1077,7 @@ IMPL_LINK_NOARG(GraphicObject, ImplAutoSwapOutHdl)
         if( GRFMGR_AUTOSWAPSTREAM_NONE != pStream )
         {
             if( GRFMGR_AUTOSWAPSTREAM_LINK == pStream )
-                mbAutoSwapped = SwapOut( NULL );
+                mbAutoSwapped = SwapOut( GRFMGR_AUTOSWAPSTREAM_LINK );
             else
             {
                 if( GRFMGR_AUTOSWAPSTREAM_TEMP == pStream )
diff --git a/svtools/source/graphic/grfmgr2.cxx b/svtools/source/graphic/grfmgr2.cxx
index b61f079..2ff6192 100644
--- a/svtools/source/graphic/grfmgr2.cxx
+++ b/svtools/source/graphic/grfmgr2.cxx
@@ -34,7 +34,6 @@
 #include "grfcache.hxx"
 #include <svtools/grfmgr.hxx>
 #include <boost/scoped_array.hpp>
-#include <boost/unordered_map.hpp>
 
 // - defines -
 
@@ -48,7 +47,8 @@
 
 
 GraphicManager::GraphicManager( sal_uLong nCacheSize, sal_uLong nMaxObjCacheSize ) :
-        mpCache( new GraphicCache( nCacheSize, nMaxObjCacheSize ) )
+    mnUsedSize(0),
+    mpCache( new GraphicCache( nCacheSize, nMaxObjCacheSize ) )
 {
 }
 
@@ -156,6 +156,8 @@ void GraphicManager::ImplRegisterObj( const GraphicObject& rObj, Graphic& rSubst
 
     maObjList.push_back( (GraphicObject*)&rObj );
     mpCache->AddGraphicObject( rObj, rSubstitute, pID, pCopyObj );
+    if( !rObj.IsSwappedOut() )
+        mnUsedSize += rObj.GetSizeBytes();
 }
 
 void GraphicManager::ImplUnregisterObj( const GraphicObject& rObj )
@@ -169,11 +171,14 @@ void GraphicManager::ImplUnregisterObj( const GraphicObject& rObj )
         }
     }
     assert(false); // surely it should have been registered?
+    if( !rObj.IsSwappedOut() )
+        mnUsedSize -= rObj.GetSizeBytes();
 }
 
 void GraphicManager::ImplGraphicObjectWasSwappedOut( const GraphicObject& rObj )
 {
     mpCache->GraphicObjectWasSwappedOut( rObj );
+    mnUsedSize -= rObj.GetSizeBytes();
 }
 
 OString GraphicManager::ImplGetUniqueID( const GraphicObject& rObj ) const
@@ -192,28 +197,8 @@ namespace
     };
 } // end of anonymous namespace
 
-void GraphicManager::ImplCheckSizeOfSwappedInGraphics()
+void GraphicManager::ImplCheckSizeOfSwappedInGraphics(const GraphicObject* pGraphicToIgnore)
 {
-    // get the currently used memory footprint of all swapped in bitmap graphics
-    // of this graphic manager. Remember candidates in a vector. The size in bytes is
-    // already available, thus this loop is not expensive to execute
-    sal_uLong nUsedSize(0);
-    GraphicObject* pObj = 0;
-    std::vector< GraphicObject* > aCandidates;
-    boost::unordered_map<GraphicObject *, size_t> sizes;
-
-    for (size_t i = 0, n = maObjList.size(); i < n; ++i)
-    {
-        pObj = maObjList[i];
-        if (pObj->meType == GRAPHIC_BITMAP && !pObj->IsSwappedOut() && pObj->GetSizeBytes())
-        {
-            aCandidates.push_back(pObj);
-            size_t const nSize = pObj->GetSizeBytes();
-            nUsedSize += nSize;
-            sizes.insert(std::make_pair(pObj, nSize));
-        }
-    }
-
     // detect maximum allowed memory footprint. Use the user-settings of MaxCacheSize (defaulted
     // to 20MB) and add a decent multiplicator (experimented to find one). Limit to
     // a useful maximum for 32Bit address space
@@ -229,30 +214,33 @@ void GraphicManager::ImplCheckSizeOfSwappedInGraphics()
     // calc max allowed cache size
     const sal_uLong nMaxCacheSize(::std::min(GetMaxCacheSize() * aMultiplicator, aMaxSize32Bit));
 
-    if(nUsedSize >= nMaxCacheSize && !aCandidates.empty())
+    if(mnUsedSize >= nMaxCacheSize)
     {
+        // Copy the object list for now, because maObjList can change in the meantime unexpectedly.
+        std::vector< GraphicObject* > aCandidates(maObjList.begin(), maObjList.end());
         // if we use more currently, sort by last DataChangeTimeStamp
         // sort by DataChangeTimeStamp so that the oldest get removed first
         ::std::sort(aCandidates.begin(), aCandidates.end(), simpleSortByDataChangeTimeStamp());
 
-        for(sal_uInt32 a(0); nUsedSize >= nMaxCacheSize && a < aCandidates.size(); a++)
+        for(sal_uInt32 a(0); mnUsedSize >= nMaxCacheSize && a < aCandidates.size(); a++)
         {
             // swap out until we have no more or the goal to use less than nMaxCacheSize
             // is reached
-            pObj = aCandidates[a];
+            GraphicObject* pObj = aCandidates[a];
+            if( pObj == pGraphicToIgnore )
+            {
+                continue;
+            }
             if (std::find(maObjList.begin(), maObjList.end(), pObj) == maObjList.end())
             {
                 // object has been deleted when swapping out another one
-                nUsedSize = (sizes[pObj] < nUsedSize) ? nUsedSize - sizes[pObj] : 0;
                 continue;
             }
-            const sal_uLong nSizeBytes(pObj->GetSizeBytes());
 
             // do not swap out when we have less than 16KB data objects
-            if(nSizeBytes >= (16 * 1024))
+            if(pObj->GetSizeBytes() >= (16 * 1024))
             {
                 pObj->FireSwapOutRequest();
-                nUsedSize = (nSizeBytes < nUsedSize) ? nUsedSize - nSizeBytes : 0;
             }
         }
     }
@@ -266,6 +254,7 @@ bool GraphicManager::ImplFillSwappedGraphicObject( const GraphicObject& rObj, Gr
 void GraphicManager::ImplGraphicObjectWasSwappedIn( const GraphicObject& rObj )
 {
     mpCache->GraphicObjectWasSwappedIn( rObj );
+    mnUsedSize += rObj.GetSizeBytes();
 }
 
 bool GraphicManager::ImplDraw( OutputDevice* pOut, const Point& rPt,
@@ -276,7 +265,7 @@ bool GraphicManager::ImplDraw( OutputDevice* pOut, const Point& rPt,
     const Graphic&  rGraphic = rObj.GetGraphic();
     bool            bRet = false;
 
-    if( rGraphic.IsSupportedGraphic() && !rGraphic.IsSwapOut() )
+    if( rGraphic.IsSupportedGraphic() && !rObj.IsSwappedOut() )
     {
         if( GRAPHIC_BITMAP == rGraphic.GetType() )
         {
diff --git a/svx/source/sdr/contact/viewobjectcontactofgraphic.cxx b/svx/source/sdr/contact/viewobjectcontactofgraphic.cxx
index a445b75..c95b42d 100644
--- a/svx/source/sdr/contact/viewobjectcontactofgraphic.cxx
+++ b/svx/source/sdr/contact/viewobjectcontactofgraphic.cxx
@@ -245,8 +245,6 @@ namespace sdr
             // prepare primitive generation with evtl. loading the graphic when it's swapped out
             SdrGrafObj& rGrafObj = const_cast< ViewObjectContactOfGraphic* >(this)->getSdrGrafObj();
             bool bDoAsynchronGraphicLoading(rGrafObj.GetModel() && rGrafObj.GetModel()->IsSwapGraphics());
-            bool bSwapInDone(false);
-            bool bSwapInExclusive(false);
 
             if( bDoAsynchronGraphicLoading && rGrafObj.IsSwappedOut() )
             {
@@ -262,16 +260,15 @@ namespace sdr
                     || GetObjectContact().isOutputToPDFFile() )
                 {
                     bDoAsynchronGraphicLoading = false;
-                    bSwapInExclusive = true;
                 }
             }
             if( bDoAsynchronGraphicLoading )
             {
-                bSwapInDone = const_cast< ViewObjectContactOfGraphic* >(this)->impPrepareGraphicWithAsynchroniousLoading();
+                const_cast< ViewObjectContactOfGraphic* >(this)->impPrepareGraphicWithAsynchroniousLoading();
             }
             else
             {
-                bSwapInDone = const_cast< ViewObjectContactOfGraphic* >(this)->impPrepareGraphicWithSynchroniousLoading();
+                const_cast< ViewObjectContactOfGraphic* >(this)->impPrepareGraphicWithSynchroniousLoading();
             }
 
             // get return value by calling parent
@@ -294,12 +291,6 @@ namespace sdr
                 }
             }
 
-            // if swap in was forced only for printing metafile and pdf, swap out again
-            if( bSwapInDone && bSwapInExclusive )
-            {
-                rGrafObj.ForceSwapOut();
-            }
-
             return xRetval;
         }
 
diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx
index d5eb41f..7cf57b0 100644
--- a/svx/source/svdraw/svdograf.cxx
+++ b/svx/source/svdraw/svdograf.cxx
@@ -552,10 +552,6 @@ void SdrGrafObj::SetGrafStreamURL( const OUString& rGraphicStreamURL )
     else if( pModel->IsSwapGraphics() )
     {
         pGraphic->SetUserData( rGraphicStreamURL );
-
-        // set state of graphic object to 'swapped out'
-        if( pGraphic->GetType() == GRAPHIC_NONE )
-            pGraphic->SetSwapState();
     }
 }
 
@@ -574,7 +570,6 @@ void SdrGrafObj::ForceSwapIn() const
         Graphic aEmpty;
         pGraphic->SetGraphic( aEmpty );
         pGraphic->SetUserData( aUserData );
-        pGraphic->SetSwapState();
 
         const_cast< SdrGrafObj* >( this )->mbIsPreview = false;
     }
@@ -634,9 +629,6 @@ void SdrGrafObj::SetGraphicLink(const OUString& rFileName, const OUString& rRefe
     aFilterName = rFilterName;
     ImpLinkAnmeldung();
     pGraphic->SetUserData();
-
-    // A linked graphic is per definition swapped out (has to be loaded)
-    pGraphic->SetSwapState();
 }
 
 void SdrGrafObj::ReleaseGraphicLink()
@@ -1004,7 +996,6 @@ void SdrGrafObj::SetModel( SdrModel* pNewModel )
         if( pGraphic->HasUserData() )
         {
             ForceSwapIn();
-            pGraphic->SetUserData();
         }
 
         if( pGraphicLink != NULL )
@@ -1295,7 +1286,7 @@ IMPL_LINK( SdrGrafObj, ImpSwapHdl, GraphicObject*, pO )
             {
                 const sal_uIntPtr   nSwapMode = pModel->GetSwapGraphicsMode();
 
-                if( ( pGraphic->HasUserData() || pGraphicLink ) &&
+                if( ( pGraphicLink ) &&
                     ( nSwapMode & SDR_SWAPGRAPHICSMODE_PURGE ) )
                 {
                     pRet = GRFMGR_AUTOSWAPSTREAM_LINK;
@@ -1405,22 +1396,7 @@ Reference< XInputStream > SdrGrafObj::getInputStream()
 
     if( pModel )
     {
-        // can be loaded from the original document stream later
-        if( pGraphic && pGraphic->HasUserData() )
-        {
-            ::comphelper::LifecycleProxy proxy;
-            xStream.set(
-                pModel->GetDocumentStream(pGraphic->GetUserData(), proxy));
-            // fdo#46340: this may look completely insane, and it is,
-            // but it also prevents a crash: the LifecycleProxy will go out
-            // of scope, but the xStream must be returned; the UcbStreamHelper
-            // will actually copy the xStream to a temp file (because it is
-            // not seekable), which makes it not crash...
-            SvStream *const pStream =
-                utl::UcbStreamHelper::CreateStream(xStream);
-            xStream.set(new utl::OInputStreamWrapper(pStream, true));
-        }
-        else if( pGraphic && GetGraphic().IsLink() )
+        if( pGraphic && GetGraphic().IsLink() )
         {
             Graphic aGraphic( GetGraphic() );
             GfxLink aLink( aGraphic.GetLink() );
diff --git a/svx/source/svdraw/svdpage.cxx b/svx/source/svdraw/svdpage.cxx
index 1653fab..46ed346 100644
--- a/svx/source/svdraw/svdpage.cxx
+++ b/svx/source/svdraw/svdpage.cxx
@@ -735,37 +735,6 @@ size_t SdrObjList::CountAllObjects() const
     return nCnt;
 }
 
-void SdrObjList::ForceSwapInObjects() const
-{
-    for (size_t nObjNum=GetObjCount(); nObjNum>0;) {
-        SdrObject* pObj=GetObj(--nObjNum);
-        SdrGrafObj* pGrafObj=PTR_CAST(SdrGrafObj,pObj);
-        if (pGrafObj!=NULL) {
-            pGrafObj->ForceSwapIn();
-        }
-        SdrObjList* pOL=pObj->GetSubList();
-        if (pOL!=NULL) {
-            pOL->ForceSwapInObjects();
-        }
-    }
-}
-
-void SdrObjList::ForceSwapOutObjects() const
-{
-    const size_t nObjAnz = GetObjCount();
-    for (size_t nObjNum=nObjAnz; nObjNum>0;) {
-        SdrObject* pObj=GetObj(--nObjNum);
-        SdrGrafObj* pGrafObj=PTR_CAST(SdrGrafObj,pObj);
-        if (pGrafObj!=NULL) {
-            pGrafObj->ForceSwapOut();
-        }
-        SdrObjList* pOL=pObj->GetSubList();
-        if (pOL!=NULL) {
-            pOL->ForceSwapOutObjects();
-        }
-    }
-}
-
 void SdrObjList::FlattenGroups()
 {
     const size_t nObj = GetObjCount();
@@ -1248,7 +1217,6 @@ SdrPage::SdrPage(SdrModel& rNewModel, bool bMasterPage)
     mbMaster(bMasterPage),
     mbInserted(false),
     mbObjectsNotPersistent(false),
-    mbSwappingLocked(false),
     mbPageBorderOnlyLeftRight(false)
 {
     aPrefVisiLayers.SetAll();
@@ -1274,7 +1242,6 @@ SdrPage::SdrPage(const SdrPage& rSrcPage)
     mbMaster(rSrcPage.mbMaster),
     mbInserted(false),
     mbObjectsNotPersistent(rSrcPage.mbObjectsNotPersistent),
-    mbSwappingLocked(rSrcPage.mbSwappingLocked),
     mbPageBorderOnlyLeftRight(rSrcPage.mbPageBorderOnlyLeftRight)
 {
     aPrefVisiLayers.SetAll();
@@ -1370,7 +1337,6 @@ SdrPage& SdrPage::operator=(const SdrPage& rSrcPage)
     // a valid copy of source page before copying and inserting
     // the contained objects
     mbMaster = rSrcPage.mbMaster;
-    mbSwappingLocked = rSrcPage.mbSwappingLocked;
     mbPageBorderOnlyLeftRight = rSrcPage.mbPageBorderOnlyLeftRight;
     aPrefVisiLayers = rSrcPage.aPrefVisiLayers;
     nWdt = rSrcPage.nWdt;
diff --git a/svx/source/svdraw/svdundo.cxx b/svx/source/svdraw/svdundo.cxx
index e8a84e5..c88d2c3 100644
--- a/svx/source/svdraw/svdundo.cxx
+++ b/svx/source/svdraw/svdundo.cxx
@@ -889,34 +889,10 @@ void SdrUndoInsertObj::Redo()
     ImpShowPageOfThisObject();
 }
 
-
-
-void SdrUndoDelObj::TryToFlushGraphicContent()
-{
-    SdrGrafObj* pSdrGrafObj = dynamic_cast< SdrGrafObj* >(pObj);
-
-    if(pSdrGrafObj)
-    {
-        sdr::contact::ViewContactOfGraphic* pVC = dynamic_cast< sdr::contact::ViewContactOfGraphic* >(&pSdrGrafObj->GetViewContact());
-
-        if(pVC)
-        {
-            pVC->flushViewObjectContacts();
-            pVC->flushGraphicObjects();
-        }
-
-        pSdrGrafObj->ForceSwapOut();
-    }
-}
-
 SdrUndoDelObj::SdrUndoDelObj(SdrObject& rNewObj, bool bOrdNumDirect)
 :   SdrUndoRemoveObj(rNewObj,bOrdNumDirect)
 {
     SetOwner(true);
-
-    // #i122985# if graphic object is deleted (but goes to undo) flush it's graphic content
-    // since it is potentially no longer needed
-    TryToFlushGraphicContent();
 }
 
 void SdrUndoDelObj::Undo()
@@ -931,10 +907,6 @@ void SdrUndoDelObj::Redo()
     SdrUndoRemoveObj::Redo();
     DBG_ASSERT(!IsOwner(),"RedoDeleteObj: pObj already belongs to UndoAction");
     SetOwner(true);
-
-    // #i122985# if graphic object is deleted (but goes to undo) flush it's graphic content
-    // since it is potentially no longer needed
-    TryToFlushGraphicContent();
 }
 
 OUString SdrUndoDelObj::GetComment() const
diff --git a/svx/source/unodraw/unoshap2.cxx b/svx/source/unodraw/unoshap2.cxx
index 7ef7831..263ec03 100644
--- a/svx/source/unodraw/unoshap2.cxx
+++ b/svx/source/unodraw/unoshap2.cxx
@@ -1537,7 +1537,6 @@ bool SvxGraphicObject::setPropertyValueImpl( const OUString& rName, const SfxIte
             if( mpObj.is() )
             {
                 static_cast<SdrGrafObj*>(mpObj.get())->SetGrafStreamURL( aStreamURL );
-                static_cast<SdrGrafObj*>(mpObj.get())->ForceSwapOut();
             }
             bOk = true;
         }
@@ -1575,7 +1574,6 @@ bool SvxGraphicObject::getPropertyValueImpl( const OUString& rName, const SfxIte
     {
     case OWN_ATTR_VALUE_FILLBITMAP:
     {
-        bool bSwapped = static_cast< SdrGrafObj* >( mpObj.get() )->IsSwappedOut();
         const Graphic& rGraphic = static_cast< SdrGrafObj*>( mpObj.get() )->GetGraphic();
 
         if(rGraphic.GetType() != GRAPHIC_GDIMETAFILE)
@@ -1594,8 +1592,6 @@ bool SvxGraphicObject::getPropertyValueImpl( const OUString& rName, const SfxIte
                 aDestStrm.GetEndOfData());
             rValue <<= aSeq;
         }
-        if ( bSwapped )
-            static_cast< SdrGrafObj* >( mpObj.get() )->ForceSwapOut();
         break;
     }
 
@@ -1607,13 +1603,10 @@ bool SvxGraphicObject::getPropertyValueImpl( const OUString& rName, const SfxIte
         }
         else
         {
-            bool bSwapped = static_cast< SdrGrafObj* >( mpObj.get() )->IsSwappedOut();
             const GraphicObject& rGrafObj = static_cast< SdrGrafObj*>( mpObj.get() )->GetGraphicObject(true);
             OUString aURL( UNO_NAME_GRAPHOBJ_URLPREFIX);
             aURL += OStringToOUString(rGrafObj.GetUniqueID(), RTL_TEXTENCODING_ASCII_US);
             rValue <<= aURL;
-            if ( bSwapped )
-                static_cast< SdrGrafObj* >( mpObj.get() )->ForceSwapOut();
         }
         break;
     }
@@ -1642,11 +1635,8 @@ bool SvxGraphicObject::getPropertyValueImpl( const OUString& rName, const SfxIte
 
     case OWN_ATTR_VALUE_GRAPHIC:
     {
-        bool bSwapped = static_cast< SdrGrafObj* >( mpObj.get() )->IsSwappedOut();
         Reference< graphic::XGraphic > xGraphic( static_cast< SdrGrafObj* >( mpObj.get() )->GetGraphic().GetXGraphic() );
         rValue <<= xGraphic;
-        if ( bSwapped )
-            static_cast< SdrGrafObj* >( mpObj.get() )->ForceSwapOut();
         break;
     }
 
diff --git a/sw/inc/ndgrf.hxx b/sw/inc/ndgrf.hxx
index 212a612..0a49823 100644
--- a/sw/inc/ndgrf.hxx
+++ b/sw/inc/ndgrf.hxx
@@ -123,8 +123,8 @@ class SW_DLLPUBLIC SwGrfNode: public SwNoTxtNode
 
 public:
     virtual ~SwGrfNode();
-    const Graphic&          GetGrf() const      { return maGrfObj.GetGraphic(); }
-    const GraphicObject&    GetGrfObj() const   { return maGrfObj; }
+    const Graphic&          GetGrf(bool bWait = false) const;
+    const GraphicObject&    GetGrfObj(bool bWait = false) const;
     const GraphicObject* GetReplacementGrfObj() const;
     virtual SwCntntNode *SplitCntntNode( const SwPosition & ) SAL_OVERRIDE;
 
@@ -169,16 +169,15 @@ public:
                  const Graphic* pGraphic = 0,
                  const GraphicObject* pGrfObj = 0,
                  bool bModify = true );
+private:
     /// Loading of graphic immediately before displaying.
     bool SwapIn( bool bWaitForData = false );
     /// Remove graphic in order to free memory.
     bool SwapOut();
+
+public:
     bool HasEmbeddedStreamName() const { return maGrfObj.HasUserData(); }
-    /// applying new stream name for embedded graphic - needed as saving the document might change this stream name
-    void ApplyNewEmbeddedStreamName(const OUString& r)
-    {
-        maGrfObj.SetUserData(r);
-    }
+
     /// Is this node selected by any shell?
     bool IsSelected() const;
 
diff --git a/sw/inc/ndole.hxx b/sw/inc/ndole.hxx
index a3622e1..65189ee 100644
--- a/sw/inc/ndole.hxx
+++ b/sw/inc/ndole.hxx
@@ -71,7 +71,6 @@ class SW_DLLPUBLIC SwOLENode: public SwNoTxtNode
 {
     friend class SwNodes;
     mutable SwOLEObj aOLEObj;
-    Graphic*    pGraphic;
     OUString sChartTblName;     ///< with chart objects: name of referenced table.
     bool   bOLESizeInvalid; /**< Should be considered at SwDoc::PrtOLENotify
                                    (e.g. copied). Is not persistent. */
diff --git a/sw/source/core/doc/notxtfrm.cxx b/sw/source/core/doc/notxtfrm.cxx
index 7f86660..9f45a32 100644
--- a/sw/source/core/doc/notxtfrm.cxx
+++ b/sw/source/core/doc/notxtfrm.cxx
@@ -599,8 +599,6 @@ void SwNoTxtFrm::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew )
                         }
                     } while( pVSh != (pSh = (SwViewShell*)pSh->GetNext() ));
                 }
-                else
-                    pNd->SwapIn();
             }
         }
         break;
@@ -878,8 +876,8 @@ void SwNoTxtFrm::PaintPicture( OutputDevice* pOut, const SwRect &rGrfArea ) cons
             pOut->SetAntialiasing( nFormerAntialiasingAtOutput | ANTIALIASING_ENABLE_B2DDRAW );
         }
 
-        bool bForceSwap = false, bContinue = true;
-        const GraphicObject& rGrfObj = pGrfNd->GetGrfObj();
+        bool bContinue = true;
+        const GraphicObject& rGrfObj = pGrfNd->GetGrfObj(bPrn);
 
         GraphicAttr aGrfAttr;
         pGrfNd->GetGraphicAttr( aGrfAttr, this );
@@ -917,9 +915,7 @@ void SwNoTxtFrm::PaintPicture( OutputDevice* pOut, const SwRect &rGrfArea ) cons
 
         if( bContinue )
         {
-            const bool bSwapped = rGrfObj.IsSwappedOut();
-            const bool bSwappedIn = pGrfNd->SwapIn( bPrn );
-            if( bSwappedIn && rGrfObj.GetGraphic().IsSupportedGraphic())
+            if( rGrfObj.GetGraphic().IsSupportedGraphic())
             {
                 const bool bAnimate = rGrfObj.IsAnimated() &&
                                          !pShell->IsPreview() &&
@@ -956,13 +952,12 @@ void SwNoTxtFrm::PaintPicture( OutputDevice* pOut, const SwRect &rGrfArea ) cons
             else
             {
                 sal_uInt16 nResId = 0;
-                if( bSwappedIn )
-                {
-                    if( GRAPHIC_NONE == rGrfObj.GetType() )
-                        nResId = STR_COMCORE_READERROR;
-                    else if ( !rGrfObj.GetGraphic().IsSupportedGraphic() )
-                        nResId = STR_COMCORE_CANT_SHOW;
-                }
+
+                if( GRAPHIC_NONE == rGrfObj.GetType() )
+                    nResId = STR_COMCORE_READERROR;
+                else if ( !rGrfObj.GetGraphic().IsSupportedGraphic() )
+                    nResId = STR_COMCORE_CANT_SHOW;
+
                 ((SwNoTxtFrm*)this)->nWeight = -1;
                 OUString aText;
                 if ( !nResId &&
@@ -976,15 +971,8 @@ void SwNoTxtFrm::PaintPicture( OutputDevice* pOut, const SwRect &rGrfArea ) cons
 
                 ::lcl_PaintReplacement( aAlignedGrfArea, aText, *pShell, this, true );
             }
-
-            // When printing, we must not collect the graphics
-            if( bSwapped && bPrn )
-                bForceSwap = true;
         }
 
-        if( bForceSwap )
-            pGrfNd->SwapOut();
-
         if ( pShell->Imp()->GetDrawView()->IsAntiAliasing() )
             pOut->SetAntialiasing( nFormerAntialiasingAtOutput );
     }
diff --git a/sw/source/core/docnode/ndnotxt.cxx b/sw/source/core/docnode/ndnotxt.cxx
index 7a325c9..dfb38b1 100644
--- a/sw/source/core/docnode/ndnotxt.cxx
+++ b/sw/source/core/docnode/ndnotxt.cxx
@@ -251,8 +251,7 @@ Graphic SwNoTxtNode::GetGraphic() const
     Graphic aRet;
     if ( GetGrfNode() )
     {
-        ((SwGrfNode*)this)->SwapIn( true );
-        aRet = ((SwGrfNode*)this)->GetGrf();
+        aRet = ((SwGrfNode*)this)->GetGrf(true);
     }
     else
     {
diff --git a/sw/source/core/edit/editsh.cxx b/sw/source/core/edit/editsh.cxx
index c59b59c..f9df512 100644
--- a/sw/source/core/edit/editsh.cxx
+++ b/sw/source/core/edit/editsh.cxx
@@ -238,28 +238,7 @@ const Graphic* SwEditShell::GetGraphic( bool bWait ) const
     const Graphic* pGrf( 0L );
     if ( pGrfNode )
     {
-        pGrf = &(pGrfNode->GetGrf());
-        // --> #i73788#
-        // no load of linked graphic, if its not needed now (bWait = sal_False).
-        if ( bWait )
-        {
-            if( pGrf->IsSwapOut() ||
-                ( pGrfNode->IsLinkedFile() && GRAPHIC_DEFAULT == pGrf->GetType() ) )
-            {
-                bool const bResult = pGrfNode->SwapIn(bWait);
-                OSL_ENSURE(bResult || !bWait, "Graphic could not be loaded" );
-                (void) bResult; // unused in non-debug
-            }
-        }
-        else
-        {
-            if ( pGrf->IsSwapOut() && !pGrfNode->IsLinkedFile() )
-            {
-                bool const bResult = pGrfNode->SwapIn(bWait);
-                OSL_ENSURE(bResult || !bWait, "Graphic could not be loaded" );
-                (void) bResult; // unused in non-debug
-            }
-        }
+        pGrf = &(pGrfNode->GetGrf(bWait && GRAPHIC_DEFAULT == pGrfNode->GetGrf().GetType()));
     }
     return pGrf;
 }
@@ -611,15 +590,7 @@ Graphic SwEditShell::GetIMapGraphic() const
         if( rNd.IsGrfNode() )
         {
             SwGrfNode & rGrfNode(static_cast<SwGrfNode&>(rNd));
-            const Graphic& rGrf = rGrfNode.GetGrf();
-            if( rGrf.IsSwapOut() || ( rGrfNode.IsLinkedFile() &&
-                                    GRAPHIC_DEFAULT == rGrf.GetType() ) )
-            {
-                bool const bResult = rGrfNode.SwapIn(true);
-                OSL_ENSURE(bResult, "Graphic could not be loaded" );
-                (void) bResult; // unused in non-debug
-            }
-            aRet = rGrf;
+            aRet = rGrfNode.GetGrf(GRAPHIC_DEFAULT == rGrfNode.GetGrf().GetType());
         }
         else if ( rNd.IsOLENode() )
         {
diff --git a/sw/source/core/frmedt/fefly1.cxx b/sw/source/core/frmedt/fefly1.cxx
index 0f77236..8c104cb 100644
--- a/sw/source/core/frmedt/fefly1.cxx
+++ b/sw/source/core/frmedt/fefly1.cxx
@@ -1557,8 +1557,7 @@ const Graphic *SwFEShell::GetGrfAtPos( const Point &rPt,
                 pNd->GetFileFilterNms( &rName, 0 );
                 if ( rName.isEmpty() )
                     rName = pFly->GetFmt()->GetName();
-                pNd->SwapIn( true );
-                return &pNd->GetGrf();
+                return &pNd->GetGrf(true);
             }
         }
     }
diff --git a/sw/source/core/graphic/ndgrf.cxx b/sw/source/core/graphic/ndgrf.cxx
index 96b18dc..49ae0a1 100644
--- a/sw/source/core/graphic/ndgrf.cxx
+++ b/sw/source/core/graphic/ndgrf.cxx
@@ -91,8 +91,6 @@ SwGrfNode::SwGrfNode( const SwNodeIndex & rWhere,
     mbIsStreamReadOnly( false )
 {
     maGrfObj.SetSwapStreamHdl( LINK(this, SwGrfNode, SwapGraphic) );
-    if( rGrfObj.HasUserData() && rGrfObj.IsSwappedOut() )
-        maGrfObj.SetSwapState();
     bInSwapIn = bChgTwipSize = bChgTwipSizeFromPixel =
         bFrameInPaint = bScaleImageMap = false;
     bGraphicArrived = true;
@@ -194,8 +192,6 @@ bool SwGrfNode::ReRead(
         else if( pGrfObj )
         {
             maGrfObj = *pGrfObj;
-            if( pGrfObj->HasUserData() && pGrfObj->IsSwappedOut() )
-                maGrfObj.SetSwapState();
             maGrfObj.SetLink( rGrfName );
             onGraphicChanged();
             bReadGrf = true;
@@ -226,24 +222,14 @@ bool SwGrfNode::ReRead(
     }
     else if( pGraphic && rGrfName.isEmpty() )
     {
-        // Old stream must be deleted before the new one is set.
-        if( HasEmbeddedStreamName() )
-            DelStreamName();
-
         maGrfObj.SetGraphic( *pGraphic );
         onGraphicChanged();
         bReadGrf = true;
     }
     else if( pGrfObj && rGrfName.isEmpty() )
     {
-        // Old stream must be deleted before the new one is set.
-        if( HasEmbeddedStreamName() )
-            DelStreamName();
-
         maGrfObj = *pGrfObj;
         onGraphicChanged();
-        if( pGrfObj->HasUserData() && pGrfObj->IsSwappedOut() )
-            maGrfObj.SetSwapState();
         bReadGrf = true;
     }
     // Was the graphic already loaded?
@@ -251,9 +237,6 @@ bool SwGrfNode::ReRead(
         return true;
     else
     {
-        if( HasEmbeddedStreamName() )
-            DelStreamName();
-
         // create new link for the graphic object
         InsertLink( rGrfName, rFltName );
 
@@ -347,7 +330,6 @@ void SwGrfNode::onGraphicChanged()
 
     if(pFlyFmt)
     {
-        const bool bWasSwappedOut = GetGrfObj().IsSwappedOut();
         OUString aName;
         OUString aTitle;
         OUString aDesc;
@@ -388,11 +370,6 @@ void SwGrfNode::onGraphicChanged()
         {
             SetDescription(aDesc);
         }
-
-        if (bWasSwappedOut)
-        {
-            SwapOut();
-        }
     }
 }
 
@@ -402,6 +379,18 @@ void SwGrfNode::SetGraphic(const Graphic& rGraphic, const OUString& rLink)
     onGraphicChanged();
 }
 
+const Graphic& SwGrfNode::GetGrf(bool bWait) const
+{
+    const_cast<SwGrfNode*>(this)->SwapIn(bWait);
+    return maGrfObj.GetGraphic();
+}
+
+const GraphicObject& SwGrfNode::GetGrfObj(bool bWait) const
+{
+    const_cast<SwGrfNode*>(this)->SwapIn(bWait);
+    return maGrfObj;
+}
+
 const GraphicObject* SwGrfNode::GetReplacementGrfObj() const
 {
     if(!mpReplacementGraphic)
@@ -453,6 +442,10 @@ SwGrfNode * SwNodes::MakeGrfNode( const SwNodeIndex & rWhere,
 
 Size SwGrfNode::GetTwipSize() const
 {
+    if( !nGrfSize.Width() && !nGrfSize.Height() )
+    {
+        const_cast<SwGrfNode*>(this)->SwapIn();
+    }
     return nGrfSize;
 }
 
@@ -467,7 +460,6 @@ bool SwGrfNode::ImportGraphic( SvStream& rStrm )
         mpReplacementGraphic = 0;
 
         maGrfObj.SetGraphic( aGraphic );
-        maGrfObj.SetUserData( aURL );
         onGraphicChanged();
         return true;
     }
@@ -615,17 +607,16 @@ bool SwGrfNode::SwapOut()
         maGrfObj.GetType() != GRAPHIC_NONE &&
         !maGrfObj.IsSwappedOut() && !bInSwapIn )
     {
-        if( !refLink.Is() )
+        if( refLink.Is() )
+        {
+            // written graphics and links are removed here
+            return maGrfObj.SwapOut( GRFMGR_AUTOSWAPSTREAM_LINK );
+        }
+        else
         {
-            // Swapping is only needed for embedded pictures.
-            // The graphic will be written into a temp file if it is new, i.e.
-            // if there is no stream name in the storage yet
-            if( !HasEmbeddedStreamName() )
-                if( !maGrfObj.SwapOut() )
-                    return false;
+            return maGrfObj.SwapOut();
         }
-        // written graphics and links are removed here
-        return maGrfObj.SwapOut( NULL );
+
     }
     return true;
 }
@@ -671,7 +662,7 @@ bool SwGrfNode::SavePersistentData()
         return true;
     }
 
-    // swap in first if already in storage
+    // swap in first if in storage
     if( HasEmbeddedStreamName() && !SwapIn() )
         return false;
 
@@ -860,36 +851,6 @@ void SwGrfNode::ScaleImageMap()
     }
 }
 
-void SwGrfNode::DelStreamName()
-{
-    if( HasEmbeddedStreamName() )
-    {
-        // then remove graphic from storage
-        uno::Reference < embed::XStorage > xDocStg = GetDoc()->GetDocStorage();
-        if( xDocStg.is() )
-        {
-            try
-            {
-                const StreamAndStorageNames aNames = lcl_GetStreamStorageNames( maGrfObj.GetUserData() );
-                uno::Reference < embed::XStorage > refPics = xDocStg;
-                if ( !aNames.sStorage.isEmpty() )
-                    refPics = xDocStg->openStorageElement( aNames.sStorage, embed::ElementModes::READWRITE );
-                refPics->removeElement( aNames.sStream );
-                uno::Reference < embed::XTransactedObject > xTrans( refPics, uno::UNO_QUERY );
-                if ( xTrans.is() )
-                    xTrans->commit();
-            }
-            catch (const uno::Exception&)
-            {
-                // #i48434#
-                OSL_FAIL( "<SwGrfNode::DelStreamName()> - unhandled exception!" );
-            }
-        }
-
-        maGrfObj.SetUserData();
-    }
-}
-
 /** helper method to get a substorage of the document storage for readonly access.
 
     OD, MAV 2005-08-17 #i53025#
@@ -969,34 +930,7 @@ SwCntntNode* SwGrfNode::MakeCopy( SwDoc* pDoc, const SwNodeIndex& rIdx ) const
     // copy formats into the other document
     SwGrfFmtColl* pColl = pDoc->CopyGrfColl( *GetGrfColl() );
 
-    Graphic aTmpGrf;
-    SwBaseLink* pLink = (SwBaseLink*)(::sfx2::SvBaseLink*) refLink;
-    if( !pLink && HasEmbeddedStreamName() )
-    {
-        try
-        {
-            const StreamAndStorageNames aNames = lcl_GetStreamStorageNames( maGrfObj.GetUserData() );
-            uno::Reference < embed::XStorage > refPics = _GetDocSubstorageOrRoot( aNames.sStorage );
-            SvStream* pStrm = _GetStreamForEmbedGrf( refPics, aNames.sStream );
-            if ( pStrm )
-            {
-                const OUString aURL(maGrfObj.GetUserData());
-                GraphicFilter::GetGraphicFilter().ImportGraphic(aTmpGrf, aURL, *pStrm);
-                delete pStrm;
-            }
-        }
-        catch (const uno::Exception& e)
-        {
-            // #i48434#
-            SAL_WARN("sw.core", "<SwGrfNode::MakeCopy(..)> - unhandled exception!" << e.Message);
-        }
-    }
-    else
-    {
-        if( maGrfObj.IsSwappedOut() )
-            const_cast<SwGrfNode*>(this)->SwapIn();
-        aTmpGrf = maGrfObj.GetGraphic();
-    }
+    Graphic aTmpGrf = GetGrf();
 
     const sfx2::LinkManager& rMgr = getIDocumentLinksAdministration()->GetLinkManager();
     OUString sFile, sFilter;
@@ -1049,34 +983,6 @@ IMPL_LINK( SwGrfNode, SwapGraphic, GraphicObject*, pGrfObj )
     else
     {
         pRet = GRFMGR_AUTOSWAPSTREAM_TEMP;
-
-        if( HasEmbeddedStreamName() )
-        {
-            try
-            {
-                const StreamAndStorageNames aNames = lcl_GetStreamStorageNames( maGrfObj.GetUserData() );
-                uno::Reference < embed::XStorage > refPics = _GetDocSubstorageOrRoot( aNames.sStorage );
-                SvStream* pStrm = _GetStreamForEmbedGrf( refPics, aNames.sStream );
-                if ( pStrm )
-                {
-                    if( pGrfObj->IsInSwapOut() )
-                    {
-                        pRet = GRFMGR_AUTOSWAPSTREAM_LINK;
-                    }
-                    else
-                    {
-                        ImportGraphic( *pStrm );
-                        pRet = GRFMGR_AUTOSWAPSTREAM_LOADED;
-                    }
-                    delete pStrm;
-                }
-            }
-            catch (const uno::Exception&)
-            {
-                // #i48434#
-                OSL_FAIL( "<SwapGraphic> - unhandled exception!" );
-            }
-        }
     }
 
     return (sal_IntPtr)pRet;
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index ec7adfa..0272522 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -1824,15 +1824,8 @@ static void lcl_DrawGraphic( const SvxBrushItem& rBrush, OutputDevice *pOut,
     // used, these coordinates have to be determined on pixel level.
     ::SwAlignGrfRect( &aAlignedGrfRect, *pOut );
 
-    if (pGrf->GetGraphic().getSvgData().get())
-    {   // fdo#68927 - SVGs are rasterized badly by DrawWithPDFHandling
-        paintGraphicUsingPrimitivesHelper(*pOut,
-                *pGrf, pGrf->GetAttr(), aAlignedGrfRect);
-    }
-    else
-    {
-        pGrf->DrawWithPDFHandling( *pOut, aAlignedGrfRect.Pos(), aAlignedGrfRect.SSize() );
-    }
+    paintGraphicUsingPrimitivesHelper(*pOut,
+        *pGrf, pGrf->GetAttr(), aAlignedGrfRect);
 
     if ( bNotInside )
         pOut->Pop();
@@ -1844,10 +1837,7 @@ bool DrawFillAttributes(
     const SwRect& rPaintRect,
     OutputDevice& rOut)
 {
-    static bool bUseNew(true);
-    static bool bReturnWhenNew(true);
-
-    if(bUseNew && rFillAttributes.get() && rFillAttributes->isUsed())
+    if(rFillAttributes.get() && rFillAttributes->isUsed())
     {
         basegfx::B2DRange aPaintRange(
             rPaintRect.Left(),
@@ -1917,10 +1907,7 @@ bool DrawFillAttributes(
 
                     delete pProcessor;
 
-                    if(bReturnWhenNew)
-                    {
-                        return true;
-                    }
+                    return true;
                 }
             }
         }
diff --git a/sw/source/core/ole/ndole.cxx b/sw/source/core/ole/ndole.cxx
index 35df868..3963946 100644
--- a/sw/source/core/ole/ndole.cxx
+++ b/sw/source/core/ole/ndole.cxx
@@ -211,7 +211,6 @@ SwOLENode::SwOLENode( const SwNodeIndex &rWhere,
                     SwAttrSet* pAutoAttr ) :
     SwNoTxtNode( rWhere, ND_OLENODE, pGrfColl, pAutoAttr ),
     aOLEObj( xObj ),
-    pGraphic(0),
     bOLESizeInvalid( false ),
     mpObjectLink( NULL )
 {
@@ -225,7 +224,6 @@ SwOLENode::SwOLENode( const SwNodeIndex &rWhere,
                     SwAttrSet* pAutoAttr ) :
     SwNoTxtNode( rWhere, ND_OLENODE, pGrfColl, pAutoAttr ),
     aOLEObj( rString, nAspect ),
-    pGraphic(0),
     bOLESizeInvalid( false ),
     mpObjectLink( NULL )
 {
@@ -235,14 +233,13 @@ SwOLENode::SwOLENode( const SwNodeIndex &rWhere,
 SwOLENode::~SwOLENode()
 {
     DisconnectFileLink_Impl();
-    delete pGraphic;
 }
 
 const Graphic* SwOLENode::GetGraphic()
 {
     if ( aOLEObj.GetOleRef().is() )
         return aOLEObj.xOLERef.GetGraphic();
-    return pGraphic;
+    return 0;
 }
 
 SwCntntNode *SwOLENode::SplitCntntNode( const SwPosition & )
diff --git a/sw/source/core/undo/unins.cxx b/sw/source/core/undo/unins.cxx
index 06694b3..cd9c856 100644
--- a/sw/source/core/undo/unins.cxx
+++ b/sw/source/core/undo/unins.cxx
@@ -851,8 +851,7 @@ void SwUndoReRead::SaveGraphicData( const SwGrfNode& rGrfNd )
     }
     else
     {
-        ((SwGrfNode&)rGrfNd).SwapIn( true );
-        pGrf = new Graphic( rGrfNd.GetGrf() );
+        pGrf = new Graphic( rGrfNd.GetGrf(true) );
         pNm = pFltr = 0;
     }
     nMirr = rGrfNd.GetSwAttrSet().GetMirrorGrf().GetValue();
diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx
index 8e4d879..db5cb5b 100644
--- a/sw/source/core/unocore/unoframe.cxx
+++ b/sw/source/core/unocore/unoframe.cxx
@@ -1558,7 +1558,6 @@ void SwXFrame::setPropertyValue(const :: OUString& rPropertyName, const :: uno::
                 {
                     pGrfObj = new GraphicObject;
                     pGrfObj->SetUserData( sTmp );
-                    pGrfObj->SetSwapState();
                     sGrfName = "";
                 }
                 else if( sTmp.startsWith(sGraphicObjectProtocol) )
@@ -2131,22 +2130,7 @@ uno::Any SwXFrame::getPropertyValue(const OUString& rPropertyName)
             if(pIdx)
             {
                 SwNodeIndex aIdx(*pIdx, 1);
-                // --> OD #i85105#
-                Size aActSize;
-                {
-                    SwGrfNode* pGrfNode = dynamic_cast<SwGrfNode*>(aIdx.GetNode().GetNoTxtNode());
-                    if ( pGrfNode )
-                    {
-                        aActSize = pGrfNode->GetTwipSize();
-                        if ( aActSize.Width() == 0 && aActSize.Height() == 0 &&
-                             pGrfNode->IsLinkedFile() )
-                        {
-                            pGrfNode->SwapIn( true );
-                            aActSize = pGrfNode->GetTwipSize();
-                        }
-                    }
-                }
-                // <--
+                Size aActSize = aIdx.GetNode().GetNoTxtNode()->GetTwipSize();
                 awt::Size aTmp;
                 aTmp.Width = convertTwipToMm100(aActSize.Width());
                 aTmp.Height = convertTwipToMm100(aActSize.Height());
@@ -2822,7 +2806,6 @@ void SwXFrame::attachToRange(const uno::Reference< text::XTextRange > & xTextRan
                 {
                     pGrfObj = new GraphicObject;
                     pGrfObj->SetUserData( sGraphicURL );
-                    pGrfObj->SetSwapState();
                     sGraphicURL = "";
                 }
                 else if( sGraphicURL.startsWith(sGraphicObjectProtocol) )
diff --git a/sw/source/filter/html/htmlgrin.cxx b/sw/source/filter/html/htmlgrin.cxx
index 83db824..5755bcd 100644
--- a/sw/source/filter/html/htmlgrin.cxx
+++ b/sw/source/filter/html/htmlgrin.cxx
@@ -563,7 +563,6 @@ IMAGE_SETEVENT:
     Size aGrfSz( 0, 0 );
     bool bSetTwipSize = true;       // Twip-Size am Node setzen?
     bool bChangeFrmSize = false;    // Frame-Format nachtraeglich anpassen?
-    bool bRequestGrfNow = false;
     bool bSetScaleImageMap = false;
     sal_uInt8 nPrcWidth = 0, nPrcHeight = 0;
 
@@ -575,7 +574,6 @@ IMAGE_SETEVENT:
         // Tabelle layoutet wird.
         if( pTable!=0 && !nWidth )
         {
-            bRequestGrfNow = true;
             IncGrfsThatResizeTable();
         }
 
@@ -799,14 +797,6 @@ IMAGE_SETEVENT:
     if( !aMacroItem.GetMacroTable().empty() )
         pFlyFmt->SetFmtAttr( aMacroItem );
 
-    // Wenn die Grafik gleich angeforder wird, muss dies geschehen,
-    // nachdem das Format vollstaendig aufgebaut ist, weil es evtl.
-    // gleich (synchron) angepasst wird (war bug #40983#)
-    if (bRequestGrfNow && pGrfNd)
-    {
-        pGrfNd->SwapIn();
-    }
-
     // Ggf. Frames anlegen und Auto-gebundenen Rahmen registrieren
     RegisterFlyFrm( pFlyFmt );
 
diff --git a/sw/source/filter/inc/msfilter.hxx b/sw/source/filter/inc/msfilter.hxx
index 8ff19a0..4b9e916 100644
--- a/sw/source/filter/inc/msfilter.hxx
+++ b/sw/source/filter/inc/msfilter.hxx
@@ -415,27 +415,6 @@ namespace sw
             virtual void Write(Writer &rWrt) = 0;
         };
 
-        /** Given a SwNoTxtNode (ole/graphic) get original size
-
-            Get the uncropped and unscaled size of the underlying graphic or
-            ole object associated with a given SwNoTxtNode.
-
-            This function will swap in the graphic if it is swapped out from
-            the graphic or object cache, but will swap it out if that was the
-            case, i.e.  rNd is logically unchanged before and after
-            GetSwappedInSize, though not physically const
-
-            @param rNd
-                the SwNoTxtNode whose objects original size we want
-
-            @return
-                the uncropped unscaled size of the SwNoTxtNode
-
-            @author
-                <a href="mailto:cmc at openoffice.org">Caolán McNamara</a>
-        */
-        Size GetSwappedInSize(const SwNoTxtNode& rNd);
-
         struct CharRunEntry
         {
             sal_Int32 mnEndPos;
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 2c50867..e7305fd 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -4089,23 +4089,8 @@ void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode* pGrfNode, const Size
             // Not in cache, then need to write it.
             m_rDrawingML.SetFS( m_pSerializer ); // to be sure that we write to the right stream
 
-            bool bSwapped = pGraphic->IsSwapOut();
-            if (bSwapped)
-            {
-                if (pGrfNode)
-                {
-                    // always swapin via the Node
-                    const_cast<SwGrfNode*>(pGrfNode)->SwapIn();
-                }
-                else
-                    const_cast<Graphic*>(pGraphic)->SwapIn();
-            }
-
             OUString aImageId = m_rDrawingML.WriteImage( *pGraphic );
 
-            if (bSwapped)
-                const_cast<Graphic*>(pGraphic)->SwapOut();
-
             aRelId = OUStringToOString( aImageId, RTL_TEXTENCODING_UTF8 );
             m_aRelIdCache[pGraphic] = aRelId;
         }
diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index dfd6c88..cee683b 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -3560,7 +3560,7 @@ static OString ExportPICT(const SwFlyFrmFmt* pFlyFrmFmt, const Size& rOrig, cons
 void RtfAttributeOutput::FlyFrameOLEReplacement(const SwFlyFrmFmt* pFlyFrmFmt, SwOLENode& rOLENode, const Size& rSize)
 {
     m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_SHPPICT);
-    Size aSize(sw::util::GetSwappedInSize(rOLENode));
+    Size aSize(rOLENode.GetTwipSize());
     Size aRendered(aSize);
     aRendered.Width() = rSize.Width();
     aRendered.Height() = rSize.Height();
@@ -3641,13 +3641,6 @@ void RtfAttributeOutput::FlyFrameGraphic(const SwFlyFrmFmt* pFlyFrmFmt, const Sw
     if (rGraphic.GetType()==GRAPHIC_NONE)
         return;
 
-    bool bSwapped = rGraphic.IsSwapOut();
-    if (bSwapped)
-    {
-        // always swapin via the Node
-        const_cast<SwGrfNode*>(pGrfNode)->SwapIn();
-    }
-
     GfxLink aGraphicLink;
     const sal_Char* pBLIPType = 0;
     if (rGraphic.IsLink())
@@ -3704,7 +3697,7 @@ void RtfAttributeOutput::FlyFrameGraphic(const SwFlyFrmFmt* pFlyFrmFmt, const Sw
     const SwCropGrf& rCr = (const SwCropGrf&)pGrfNode->GetAttr(RES_GRFATR_CROPGRF);
 
     //Get original size in twips
-    Size aSize(sw::util::GetSwappedInSize(*pGrfNode));
+    Size aSize(pGrfNode->GetTwipSize());
     Size aRendered(aSize);
 
     const SwFmtFrmSize& rS = pFlyFrmFmt->GetFrmSize();
@@ -3818,9 +3811,6 @@ void RtfAttributeOutput::FlyFrameGraphic(const SwFlyFrmFmt* pFlyFrmFmt, const Sw
     else
         m_rExport.Strm().WriteCharPtr("}}}}"); // Close SV, SP, SHPINST and SHP.
 
-    if (bSwapped)
-        const_cast<Graphic&>(rGraphic).SwapOut();
-
     m_rExport.Strm().WriteCharPtr(SAL_NEWLINE_STRING);
 }
 
diff --git a/sw/source/filter/ww8/writerhelper.cxx b/sw/source/filter/ww8/writerhelper.cxx
index 0fc558f..3d52fecd 100644
--- a/sw/source/filter/ww8/writerhelper.cxx
+++ b/sw/source/filter/ww8/writerhelper.cxx
@@ -205,7 +205,6 @@ namespace sw
                 {
                     SwNodeIndex aIdx(*pIdx, 1);
                     const SwNode &rNd = aIdx.GetNode();
-                    using sw::util::GetSwappedInSize;
                     // #i43447# - determine layout size
                     {
                         SwRect aLayRect( rFmt.FindLayoutRect() );
@@ -222,11 +221,11 @@ namespace sw
                     {
                         case ND_GRFNODE:
                             meWriterType = eGraphic;
-                            maSize = GetSwappedInSize(*rNd.GetNoTxtNode());
+                            maSize = rNd.GetNoTxtNode()->GetTwipSize();
                             break;
                         case ND_OLENODE:
                             meWriterType = eOle;
-                            maSize = GetSwappedInSize(*rNd.GetNoTxtNode());
+                            maSize = rNd.GetNoTxtNode()->GetTwipSize();
                             break;
                         default:
                             meWriterType = eTxtBox;
@@ -692,26 +691,6 @@ namespace sw
             return aPoly;
         }
 
-        Size GetSwappedInSize(const SwNoTxtNode& rNd)
-        {
-            Size aGrTwipSz(rNd.GetTwipSize());
-            if ((!aGrTwipSz.Width() || !aGrTwipSz.Height()))
-            {
-                SwGrfNode *pGrfNode = const_cast<SwGrfNode*>(rNd.GetGrfNode());
-                if (pGrfNode && (GRAPHIC_NONE != pGrfNode->GetGrf().GetType()))
-                {
-                    bool bWasSwappedOut = pGrfNode->GetGrfObj().IsSwappedOut();
-                    pGrfNode->SwapIn();
-                    aGrTwipSz = pGrfNode->GetTwipSize();
-                    if (bWasSwappedOut)
-                        pGrfNode->SwapOut();
-                }
-            }
-
-            OSL_ENSURE(aGrTwipSz.Width() && aGrTwipSz.Height(), "0 x 0 graphic ?");
-            return aGrTwipSz;
-        }
-
         void RedlineStack::open(const SwPosition& rPos, const SfxPoolItem& rAttr)
         {
             OSL_ENSURE(rAttr.Which() == RES_FLTR_REDLINE, "not a redline");
diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx
index 240168e..a2dd8ee 100644
--- a/sw/source/filter/ww8/wrtw8esh.cxx
+++ b/sw/source/filter/ww8/wrtw8esh.cxx
@@ -1639,8 +1639,6 @@ sal_Int32 SwBasicEscherEx::WriteGrfFlyFrame(const SwFrmFmt& rFmt, sal_uInt32 nSh
     }
     else
     {
-        pGrfNd->SwapIn(true);
-
         Graphic         aGraphic(pGrfNd->GetGrf());
         GraphicObject   aGraphicObject( aGraphic );
         OString aUniqueId = aGraphicObject.GetUniqueID();
diff --git a/sw/source/filter/ww8/wrtww8gr.cxx b/sw/source/filter/ww8/wrtww8gr.cxx
index fad72e8..48787f5 100644
--- a/sw/source/filter/ww8/wrtww8gr.cxx
+++ b/sw/source/filter/ww8/wrtww8gr.cxx
@@ -725,9 +725,6 @@ void SwWW8WrGrf::WriteGrfFromGrfNode(SvStream& rStrm, const SwGrfNode &rGrfNd,
         else
         {
             Graphic& rGrf = const_cast<Graphic&>(rGrfNd.GetGrf());
-            bool bSwapped = rGrf.IsSwapOut();
-            // always swapin via the Node
-            const_cast<SwGrfNode&>(rGrfNd).SwapIn();
 
             GDIMetaFile aMeta;
             switch (rGrf.GetType())
@@ -753,9 +750,6 @@ void SwWW8WrGrf::WriteGrfFromGrfNode(SvStream& rStrm, const SwGrfNode &rGrfNd,
             WritePICFHeader(rStrm, rFly, 8, nWidth, nHeight,
                 rGrfNd.GetpSwAttrSet());
             WriteWindowMetafileBits(rStrm, aMeta);
-
-            if (bSwapped)
-                rGrf.SwapOut();
         }
     }
 }
diff --git a/sw/source/filter/xml/xmltexte.cxx b/sw/source/filter/xml/xmltexte.cxx
index 9198d7a..79ea895 100644
--- a/sw/source/filter/xml/xmltexte.cxx
+++ b/sw/source/filter/xml/xmltexte.cxx
@@ -188,32 +188,6 @@ SwXMLTextParagraphExport::~SwXMLTextParagraphExport()
 {
 }
 
-void SwXMLTextParagraphExport::setTextEmbeddedGraphicURL(
-    const Reference < XPropertySet >& rPropSet,
-    OUString& rURL) const
-{
-    if( rURL.isEmpty() )
-        return;
-
-    SwGrfNode *pGrfNd = GetNoTxtNode( rPropSet )->GetGrfNode();
-    if (pGrfNd && !pGrfNd->IsGrfLink())
-    {
-        // Apply new embedded stream name, only if graphic node already has one.
-        // - The saving of recovery information triggers this method, but for a newly created
-        //   document the new embedded stream name shall not be applied.
-        // - The saving of a newly created document to own format (ODF) triggers this method,
-        //   but the embedded stream name is not needed as its original inserted data is still in use.
-        if (pGrfNd->HasEmbeddedStreamName())
-        {
-            pGrfNd->ApplyNewEmbeddedStreamName("vnd.sun.star.Package:" + rURL);
-        }
-
-        // #i15411# save-as will swap all graphics in; we need to swap
-        // them out again, to prevent excessive memory use
-        pGrfNd->SwapOut();
-    }
-}
-
 static void lcl_addURL ( SvXMLExport &rExport, const OUString &rURL,
                          bool bToRel = true )
 {
diff --git a/sw/source/filter/xml/xmltexte.hxx b/sw/source/filter/xml/xmltexte.hxx
index cb00746..17f45d9 100644
--- a/sw/source/filter/xml/xmltexte.hxx
+++ b/sw/source/filter/xml/xmltexte.hxx
@@ -69,11 +69,6 @@ public:
         SwXMLExport& rExp,
          SvXMLAutoStylePoolP& rAutoStylePool );
     virtual ~SwXMLTextParagraphExport();
-
-    virtual void setTextEmbeddedGraphicURL(
-        const ::com::sun::star::uno::Reference <
-                ::com::sun::star::beans::XPropertySet >& rPropSet,
-        OUString& rStreamName ) const SAL_OVERRIDE;
 };
 
 #endif // INCLUDED_SW_SOURCE_FILTER_XML_XMLTEXTE_HXX
diff --git a/vcl/inc/impgraph.hxx b/vcl/inc/impgraph.hxx
index 2242b44..513074d 100644
--- a/vcl/inc/impgraph.hxx
+++ b/vcl/inc/impgraph.hxx
@@ -143,6 +143,7 @@ private:
     bool                ImplSwapIn( SvStream* pIStm );
 
     bool                ImplSwapOut();
+    void                ImplSwapOutAsLink();
     bool                ImplSwapOut( SvStream* pOStm );
 
     bool                ImplIsSwapOut() const { return mbSwapOut;}
diff --git a/vcl/source/gdi/cvtgrf.cxx b/vcl/source/gdi/cvtgrf.cxx
index 68e4e07..65cc919 100644
--- a/vcl/source/gdi/cvtgrf.cxx
+++ b/vcl/source/gdi/cvtgrf.cxx
@@ -56,8 +56,6 @@ sal_uLong GraphicConverter::Import( SvStream& rIStm, Graphic& rGraphic, sal_uLon
 
 sal_uLong GraphicConverter::Export( SvStream& rOStm, const Graphic& rGraphic, sal_uLong nFormat )
 {
-    SAL_WARN_IF(rGraphic.IsSwapOut(), "vcl.filter", "exporting a swapped out graphic!");
-
     GraphicConverter*   pCvt = ImplGetSVData()->maGDIData.mpGrfConverter;
     sal_uLong               nRet = ERRCODE_IO_GENERAL;
 
diff --git a/vcl/source/gdi/graph.cxx b/vcl/source/gdi/graph.cxx
index 4fe916a..2e39e5e 100644
--- a/vcl/source/gdi/graph.cxx
+++ b/vcl/source/gdi/graph.cxx
@@ -522,6 +522,12 @@ bool Graphic::SwapOut()
     return mpImpGraphic->ImplSwapOut();
 }
 
+void Graphic::SwapOutAsLink()
+{
+    ImplTestRefCount();
+    mpImpGraphic->ImplSwapOutAsLink();
+}
+
 bool Graphic::SwapOut( SvStream* pOStream )
 {
     ImplTestRefCount();
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index d484329..9a1b818 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -141,7 +141,7 @@ ImpGraphic::ImpGraphic( const Bitmap& rBitmap ) :
         mpContext       ( NULL ),
         mpSwapFile      ( NULL ),
         mpGfxLink       ( NULL ),
-        meType          ( !rBitmap ? GRAPHIC_NONE : GRAPHIC_BITMAP ),
+        meType          ( GRAPHIC_BITMAP ),
         mnDocFilePos    ( 0UL ),
         mnSizeBytes     ( 0UL ),
         mnRefCount      ( 1UL ),
@@ -156,7 +156,7 @@ ImpGraphic::ImpGraphic( const BitmapEx& rBitmapEx ) :
         mpContext       ( NULL ),
         mpSwapFile      ( NULL ),
         mpGfxLink       ( NULL ),
-        meType          ( !rBitmapEx ? GRAPHIC_NONE : GRAPHIC_BITMAP ),
+        meType          ( GRAPHIC_BITMAP ),
         mnDocFilePos    ( 0UL ),
         mnSizeBytes     ( 0UL ),
         mnRefCount      ( 1UL ),
@@ -1349,6 +1349,12 @@ bool ImpGraphic::ImplSwapOut()
     return bRet;
 }
 
+void ImpGraphic::ImplSwapOutAsLink()
+{
+    ImplClearGraphics( true );
+    mbSwapOut = true;
+}
+
 bool ImpGraphic::ImplSwapOut( SvStream* pOStm )
 {
     bool bRet = false;
@@ -1370,8 +1376,7 @@ bool ImpGraphic::ImplSwapOut( SvStream* pOStm )
     }
     else
     {
-        ImplClearGraphics( true );
-        bRet = mbSwapOut = true;
+        SAL_WARN("vcl.gdi", "Graphic SwapOut: No stream for swap out!");
     }
 
     return bRet;
diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx
index c13e687..9322617 100644
--- a/xmloff/source/text/txtparae.cxx
+++ b/xmloff/source/text/txtparae.cxx
@@ -3084,7 +3084,6 @@ void XMLTextParagraphExport::_exportTextGraphic(
     OUString sOrigURL;
     rPropSet->getPropertyValue( sGraphicURL ) >>= sOrigURL;
     OUString sURL(GetExport().AddEmbeddedGraphicObject( sOrigURL ));
-    setTextEmbeddedGraphicURL( rPropSet, sURL );
 
     // If there still is no url, then then graphic is empty
     if( !sURL.isEmpty() )
@@ -3205,12 +3204,6 @@ void XMLTextParagraphExport::exportTitleAndDescription(
     }
 }
 
-void XMLTextParagraphExport::setTextEmbeddedGraphicURL(
-    const Reference < XPropertySet >&,
-    OUString& /*rStreamName*/ ) const
-{
-}
-
 bool XMLTextParagraphExport::addHyperlinkAttributes(
     const Reference< XPropertySet > & rPropSet,
     const Reference< XPropertyState > & rPropState,


More information about the Libreoffice-commits mailing list