[Libreoffice-commits] core.git: Branch 'feature/perfwork4' - 10 commits - filter/source include/svtools include/vcl oox/source svtools/source svx/source sw/inc sw/qa sw/source vcl/inc vcl/source

Zolnai Tamás tamas.zolnai at collabora.com
Sun Oct 19 23:07:45 PDT 2014


 filter/source/msfilter/msdffimp.cxx          |    1 
 include/svtools/grfmgr.hxx                   |    2 -
 include/vcl/graph.hxx                        |    1 
 oox/source/export/drawingml.cxx              |    3 --
 svtools/source/graphic/grfmgr.cxx            |   31 ++++++++++++++--------
 svx/source/svdraw/svdograf.cxx               |    8 -----
 sw/inc/editsh.hxx                            |    2 -
 sw/qa/extras/odfexport/data/some_images.odt  |binary
 sw/qa/extras/odfexport/odfexport.cxx         |   38 +++++++++++++++++++++++++++
 sw/source/core/edit/editsh.cxx               |    6 ++--
 sw/source/core/graphic/ndgrf.cxx             |    9 ------
 sw/source/core/unocore/unoframe.cxx          |    2 -
 sw/source/filter/ww8/docxattributeoutput.cxx |    6 ----
 sw/source/filter/ww8/rtfattributeoutput.cxx  |    6 ----
 sw/source/filter/ww8/writerhelper.cxx        |    3 --
 sw/source/filter/ww8/wrtww8gr.cxx            |    4 --
 sw/source/filter/xml/xmltexte.cxx            |    4 --
 sw/source/ui/frmdlg/wrap.cxx                 |    2 -
 sw/source/uibase/shells/basesh.cxx           |    4 +-
 vcl/inc/impgraph.hxx                         |    1 
 vcl/source/gdi/graph.cxx                     |    6 ++++
 vcl/source/gdi/impgraph.cxx                  |   13 ++++++---
 22 files changed, 86 insertions(+), 66 deletions(-)

New commits:
commit 19e933854e46b6f1de72a4286bb58defd9c07033
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date:   Sat Oct 18 14:51:38 2014 +0200

    Don't call SetUserData() when it actually does not change
    
    This call leads to infinite loop, because SetUserDat() set
    graphic state to swapped out which triggers ImportGraphic..
    
    Change-Id: Id49c38e60a0bb924ff5ec0465e4fb141df61abe5

diff --git a/sw/source/core/graphic/ndgrf.cxx b/sw/source/core/graphic/ndgrf.cxx
index 1b62098..abf38d3 100644
--- a/sw/source/core/graphic/ndgrf.cxx
+++ b/sw/source/core/graphic/ndgrf.cxx
@@ -461,7 +461,6 @@ bool SwGrfNode::ImportGraphic( SvStream& rStrm )
         mpReplacementGraphic = 0;
 
         maGrfObj.SetGraphic( aGraphic );
-        maGrfObj.SetUserData( aURL );
         onGraphicChanged();
         return true;
     }
commit 671301283fe37c796f251526279f477d5578a3d5
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date:   Sat Oct 18 15:08:39 2014 +0200

    Make SetSwapState() an internal method
    
    So we can be sure it is always called when user data changed.
    
    Change-Id: If107907afffb85a7a57817f5807847a5c028416c

diff --git a/include/svtools/grfmgr.hxx b/include/svtools/grfmgr.hxx
index 30ac634..d452276 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;
@@ -421,7 +422,6 @@ public:
     bool                    IsInSwapOut() const { return mbIsInSwapOut; }
     bool                    IsInSwap() const { return( mbIsInSwapOut || mbIsInSwapOut ); }
     bool                    IsSwappedOut() const { return( mbAutoSwapped || maGraphic.IsSwapOut() ); }
-    void                    SetSwapState();
 
     bool                    Draw(
                                 OutputDevice* pOut,
diff --git a/svtools/source/graphic/grfmgr.cxx b/svtools/source/graphic/grfmgr.cxx
index ef2f9fd..45367cd 100644
--- a/svtools/source/graphic/grfmgr.cxx
+++ b/svtools/source/graphic/grfmgr.cxx
@@ -102,6 +102,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 ) :
@@ -351,8 +353,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 +430,7 @@ void GraphicObject::SetUserData()
 void GraphicObject::SetUserData( const OUString& rUserData )
 {
     maUserData = rUserData;
+    SetSwapState();
 }
 
 void GraphicObject::SetSwapStreamHdl()
diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx
index b101d03..acbc721 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()
diff --git a/sw/source/core/graphic/ndgrf.cxx b/sw/source/core/graphic/ndgrf.cxx
index 37e813e..1b62098 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;
@@ -242,8 +238,6 @@ bool SwGrfNode::ReRead(
 
         maGrfObj = *pGrfObj;
         onGraphicChanged();
-        if( pGrfObj->HasUserData() && pGrfObj->IsSwappedOut() )
-            maGrfObj.SetSwapState();
         bReadGrf = true;
     }
     // Was the graphic already loaded?
diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx
index 93271c0..62a4bc4 100644
--- a/sw/source/core/unocore/unoframe.cxx
+++ b/sw/source/core/unocore/unoframe.cxx
@@ -1561,7 +1561,6 @@ void SwXFrame::setPropertyValue(const :: OUString& rPropertyName, const :: uno::
                 {
                     pGrfObj = new GraphicObject;
                     pGrfObj->SetUserData( sTmp );
-                    pGrfObj->SetSwapState();
                     sGrfName = "";
                 }
                 else if( sTmp.startsWith(sGraphicObjectProtocol) )
@@ -2825,7 +2824,6 @@ void SwXFrame::attachToRange(const uno::Reference< text::XTextRange > & xTextRan
                 {
                     pGrfObj = new GraphicObject;
                     pGrfObj->SetUserData( sGraphicURL );
-                    pGrfObj->SetSwapState();
                     sGraphicURL = "";
                 }
                 else if( sGraphicURL.startsWith(sGraphicObjectProtocol) )
commit c04e7eefe03b33f771923721d8de506f0f99a73d
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date:   Sun Oct 19 18:30:47 2014 +0200

    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

diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx
index 96b5554..bd047f6 100644
--- a/filter/source/msfilter/msdffimp.cxx
+++ b/filter/source/msfilter/msdffimp.cxx
@@ -3944,7 +3944,6 @@ SdrObject* SvxMSDffManager::ImportGraphic( SvStream& rSt, SfxItemSet& rSet, cons
             Graphic aGraf(static_cast<SdrGrafObj*>(pRet)->GetGraphic());
             lcl_ApplyCropping( *this, &rSet, aGraf );
         }
-        static_cast<SdrGrafObj*>(pRet)->ForceSwapOut();
     }
 
     return pRet;
commit 5bc33c79d9db93225109686007fe565f1a935f6c
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date:   Sat Oct 18 15:07:42 2014 +0200

    MS export: don't need to manually swapout images after swapin them
    
    We have some good auto mechanisms for that.
    
    Change-Id: I487dbf4a5fc69c7563dfbc5c21f9ebdb05ba6b9e

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index f1ff69b..3c38c4d 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -891,9 +891,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/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 8843331..9f85112 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -4126,8 +4126,7 @@ 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 (pGraphic->IsSwapOut())
             {
                 if (pGrfNode)
                 {
@@ -4140,9 +4139,6 @@ void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode* pGrfNode, const Size
 
             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 a7eecbc..d2e392f 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -3630,8 +3630,7 @@ void RtfAttributeOutput::FlyFrameGraphic(const SwFlyFrmFmt* pFlyFrmFmt, const Sw
     if (rGraphic.GetType()==GRAPHIC_NONE)
         return;
 
-    bool bSwapped = rGraphic.IsSwapOut();
-    if (bSwapped)
+    if (rGraphic.IsSwapOut())
     {
         // always swapin via the Node
         const_cast<SwGrfNode*>(pGrfNode)->SwapIn();
@@ -3807,9 +3806,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 aa0362d..be85c1f 100644
--- a/sw/source/filter/ww8/writerhelper.cxx
+++ b/sw/source/filter/ww8/writerhelper.cxx
@@ -700,11 +700,8 @@ namespace sw
                 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();
                 }
             }
 
diff --git a/sw/source/filter/ww8/wrtww8gr.cxx b/sw/source/filter/ww8/wrtww8gr.cxx
index fad72e8..27ed033 100644
--- a/sw/source/filter/ww8/wrtww8gr.cxx
+++ b/sw/source/filter/ww8/wrtww8gr.cxx
@@ -725,7 +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();
 
@@ -753,9 +752,6 @@ void SwWW8WrGrf::WriteGrfFromGrfNode(SvStream& rStrm, const SwGrfNode &rGrfNd,
             WritePICFHeader(rStrm, rFly, 8, nWidth, nHeight,
                 rGrfNd.GetpSwAttrSet());
             WriteWindowMetafileBits(rStrm, aMeta);
-
-            if (bSwapped)
-                rGrf.SwapOut();
         }
     }
 }
commit 9f3aa6293120974b2c18c2449e459aeaddbfbcc1
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date:   Sat Oct 18 15:06:57 2014 +0200

    Remove manual SwapOut() call in ODF export
    
    We have a good auto swapout mechanism which will
    prevent excessive memory use.
    
    Change-Id: I362f51c724ac31704561abe8b961910f5d490f04

diff --git a/sw/source/filter/xml/xmltexte.cxx b/sw/source/filter/xml/xmltexte.cxx
index 9198d7a..c830e1d 100644
--- a/sw/source/filter/xml/xmltexte.cxx
+++ b/sw/source/filter/xml/xmltexte.cxx
@@ -207,10 +207,6 @@ void SwXMLTextParagraphExport::setTextEmbeddedGraphicURL(
         {
             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();
     }
 }
 
commit 5365808770052fea83a52818f364e35cafac4574
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date:   Fri Oct 17 17:46:34 2014 +0200

    Test ODF import / export of images
    
    Change-Id: Ib3ac4f285a49e5f7b2a6613466080329bdb490ac

diff --git a/sw/qa/extras/odfexport/data/some_images.odt b/sw/qa/extras/odfexport/data/some_images.odt
new file mode 100644
index 0000000..be4028c
Binary files /dev/null and b/sw/qa/extras/odfexport/data/some_images.odt differ
diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx
index c140540..4d2c762 100644
--- a/sw/qa/extras/odfexport/odfexport.cxx
+++ b/sw/qa/extras/odfexport/odfexport.cxx
@@ -17,6 +17,8 @@
 #include <com/sun/star/text/RelOrientation.hpp>
 #include <com/sun/star/text/XDocumentIndex.hpp>
 #include <com/sun/star/drawing/TextVerticalAdjust.hpp>
+#include <com/sun/star/awt/XBitmap.hpp>
+#include <com/sun/star/graphic/XGraphic.hpp>
 
 class Test : public SwModelTestBase
 {
@@ -401,6 +403,42 @@ DECLARE_ODFEXPORT_TEST(testTextboxRoundedCorners, "textbox-rounded-corners.odt")
     CPPUNIT_ASSERT_EQUAL(OUString("a"), xCell->getString());
 }
 
+DECLARE_ODFEXPORT_TEST(testSomeImage, "some_images.odt")
+{
+    // Check whether all of the image are imported / exported well
+    uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(8), xDraws->getCount());
+
+    // Check more info about some of the imported images
+    // First image
+    uno::Reference<drawing::XShape> xImage = getShape(1);
+    CPPUNIT_ASSERT_EQUAL(OUString("vnd.sun.star.GraphicObject:10000000000002620000017D9A839ABB"),
+                                  getProperty< OUString >(xImage, "GraphicURL"));
+    uno::Reference<graphic::XGraphic> xGraphic = getProperty<uno::Reference<graphic::XGraphic> >(xImage, "Graphic");
+    uno::Reference<awt::XBitmap> xBitmap(xGraphic, uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int32>(610), xBitmap->getSize().Width );
+    CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int32>(381), xBitmap->getSize().Height );
+
+    // Fourth image
+    xImage = getShape(4);
+    CPPUNIT_ASSERT_EQUAL(OUString("vnd.sun.star.GraphicObject:100000000000026200000157866F4A80"),
+                                  getProperty< OUString >(xImage, "GraphicURL"));
+    xGraphic = getProperty<uno::Reference<graphic::XGraphic> >(xImage, "Graphic");
+    xBitmap.set(xGraphic, uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int32>(610), xBitmap->getSize().Width );
+    CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int32>(343), xBitmap->getSize().Height );
+
+    // Eigth image
+    xImage = getShape(8);
+    CPPUNIT_ASSERT_EQUAL(OUString("vnd.sun.star.GraphicObject:10000000000002620000017DF31E19E0"),
+                                  getProperty< OUString >(xImage, "GraphicURL"));
+    xGraphic = getProperty<uno::Reference<graphic::XGraphic> >(xImage, "Graphic");
+    xBitmap.set(xGraphic, uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int32>(610), xBitmap->getSize().Width );
+    CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int32>(381), xBitmap->getSize().Height );
+}
+
 #endif
 
 CPPUNIT_PLUGIN_IMPLEMENT();
commit c34e4b1a93a8c4f1cbc31f34a5ca45eefa14e5cd
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date:   Sun Oct 19 18:25:23 2014 +0200

    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

diff --git a/include/vcl/graph.hxx b/include/vcl/graph.hxx
index 24d9e42..b55e7901 100644
--- a/include/vcl/graph.hxx
+++ b/include/vcl/graph.hxx
@@ -177,6 +177,7 @@ public:
     sal_uLong               GetDocFilePos() const;
 
     bool                SwapOut();
+    void                SwapOutAsLink();
     bool                SwapOut( SvStream* pOStm );
     bool                SwapIn();
     bool                SwapIn( SvStream* pIStm );
diff --git a/svtools/source/graphic/grfmgr.cxx b/svtools/source/graphic/grfmgr.cxx
index be0d711..ef2f9fd 100644
--- a/svtools/source/graphic/grfmgr.cxx
+++ b/svtools/source/graphic/grfmgr.cxx
@@ -1099,7 +1099,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 );
@@ -1158,7 +1167,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/sw/source/core/graphic/ndgrf.cxx b/sw/source/core/graphic/ndgrf.cxx
index d4cc181..37e813e 100644
--- a/sw/source/core/graphic/ndgrf.cxx
+++ b/sw/source/core/graphic/ndgrf.cxx
@@ -621,7 +621,7 @@ bool SwGrfNode::SwapOut()
                     return false;
         }
         // written graphics and links are removed here
-        return maGrfObj.SwapOut( NULL );
+        return maGrfObj.SwapOut( GRFMGR_AUTOSWAPSTREAM_LINK );
     }
     return true;
 }
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/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 88a2bf6..1877b5b 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -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;
commit 43ab49b7b68b44a59353321eb2867978722d6f0c
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date:   Sat Oct 18 15:05:12 2014 +0200

    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 triger the auto swaping mechanism.
    
    Change-Id: I45af91f8df2fb5b0143fcc5eb05e82e4d408d0bc

diff --git a/svtools/source/graphic/grfmgr.cxx b/svtools/source/graphic/grfmgr.cxx
index be4baa3..be0d711 100644
--- a/svtools/source/graphic/grfmgr.cxx
+++ b/svtools/source/graphic/grfmgr.cxx
@@ -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,6 @@ void GraphicObject::ImplAutoSwapIn()
             if( !mbAutoSwapped && mpMgr )
                 mpMgr->ImplGraphicObjectWasSwappedIn( *this );
         }
-
-        // Handle evtl. needed AfterDataChanges
-        ImplAfterDataChange();
     }
 }
 
@@ -800,8 +800,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 )
@@ -1132,9 +1131,6 @@ bool GraphicObject::SwapIn()
     if( bRet )
     {
         ImplAssignGraphicData();
-
-        // Handle evtl. needed AfterDataChanges
-        ImplAfterDataChange();
     }
 
     return bRet;
commit ae72de8d10acd088d0a5f46880b8c4a3c8fd2c24
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date:   Fri Oct 17 10:06:10 2014 +0200

    Do not check a reference
    
    Change-Id: I5baac12f97ea7fa36293844331ca548b7bc2cdfd

diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index 9ec9a288..88a2bf6 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 ),
commit 648ee5c1bb58683add9433c3c7e83fe1acc2a010
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date:   Fri Oct 10 17:04:29 2014 +0200

    Don't swap in graphic when only the type is needed.
    
    Change-Id: I0066e7ffff216e02c75561844650127c3d866c10

diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx
index b869896..8117d4d 100644
--- a/sw/inc/editsh.hxx
+++ b/sw/inc/editsh.hxx
@@ -619,7 +619,7 @@ public:
 
     // #i73788#
     /// Remove default parameter, because method always called this default value.
-    Graphic GetIMapGraphic() const; ///< @return a graphic for all Flys!
+    Graphic GetIMapGraphic(bool bSwapIn = true) const; ///< @return a graphic for all Flys!
     const SwFlyFrmFmt* FindFlyByName( const OUString& rName, sal_uInt8 nNdTyp = 0 ) const;
 
     /** @return a ClientObject, if CurCrsr->Point() points to a SwOLENode
diff --git a/sw/source/core/edit/editsh.cxx b/sw/source/core/edit/editsh.cxx
index c59b59c..2b804ea 100644
--- a/sw/source/core/edit/editsh.cxx
+++ b/sw/source/core/edit/editsh.cxx
@@ -599,7 +599,7 @@ void *SwEditShell::GetIMapInventor() const
 }
 
 // #i73788#
-Graphic SwEditShell::GetIMapGraphic() const
+Graphic SwEditShell::GetIMapGraphic(bool bSwapIn) const
 {
     // returns always a graphic if the cursor is in a Fly
     SET_CURR_SHELL( (SwViewShell*)this );
@@ -612,8 +612,8 @@ Graphic SwEditShell::GetIMapGraphic() const
         {
             SwGrfNode & rGrfNode(static_cast<SwGrfNode&>(rNd));
             const Graphic& rGrf = rGrfNode.GetGrf();
-            if( rGrf.IsSwapOut() || ( rGrfNode.IsLinkedFile() &&
-                                    GRAPHIC_DEFAULT == rGrf.GetType() ) )
+            if( bSwapIn && (rGrf.IsSwapOut() || ( rGrfNode.IsLinkedFile() &&
+                                    GRAPHIC_DEFAULT == rGrf.GetType() ) ) )
             {
                 bool const bResult = rGrfNode.SwapIn(true);
                 OSL_ENSURE(bResult, "Graphic could not be loaded" );
diff --git a/sw/source/ui/frmdlg/wrap.cxx b/sw/source/ui/frmdlg/wrap.cxx
index 9d0b32a..ba6b6b1 100644
--- a/sw/source/ui/frmdlg/wrap.cxx
+++ b/sw/source/ui/frmdlg/wrap.cxx
@@ -159,7 +159,7 @@ void SwWrapTabPage::Reset(const SfxItemSet *rSet)
             int nSelType = pWrtSh->GetSelectionType();
             if( ( nSelType & nsSelectionType::SEL_GRF ) ||
                 ( nSelType & nsSelectionType::SEL_OLE && GRAPHIC_NONE !=
-                            pWrtSh->GetIMapGraphic().GetType() ))
+                            pWrtSh->GetIMapGraphic(false).GetType() ))
                 bShowCB = true;
         }
         if( bShowCB )
diff --git a/sw/source/uibase/shells/basesh.cxx b/sw/source/uibase/shells/basesh.cxx
index 96f5218..366feec 100644
--- a/sw/source/uibase/shells/basesh.cxx
+++ b/sw/source/uibase/shells/basesh.cxx
@@ -1509,7 +1509,7 @@ void SwBaseShell::GetState( SfxItemSet &rSet )
                         if ( nSel & nsSelectionType::SEL_GRF )
                             bDisable = GRAPHIC_NONE == rSh.GetGraphicType();
                         else
-                            bDisable = GRAPHIC_NONE == rSh.GetIMapGraphic().GetType();
+                            bDisable = GRAPHIC_NONE == rSh.GetIMapGraphic(false).GetType();
                     }
 
                     if( bDisable )
@@ -1695,7 +1695,7 @@ void SwBaseShell::GetState( SfxItemSet &rSet )
                                     // #i102253# applied patch from OD (see task)
                                     bDisable =
                                         nSel & nsSelectionType::SEL_FRM ||
-                                        GRAPHIC_NONE == rSh.GetIMapGraphic().GetType();
+                                        GRAPHIC_NONE == rSh.GetIMapGraphic(false).GetType();
                                 }
                             }
                             bSet = bDisable ? sal_False : rWrap.IsContour();


More information about the Libreoffice-commits mailing list