[Libreoffice-commits] core.git: Branch 'feature/image_rework' - 3 commits - include/svtools svtools/source sw/inc sw/source

Zolnai Tamás tamas.zolnai at collabora.com
Mon Oct 27 03:27:56 PDT 2014


 include/svtools/grfmgr.hxx                   |    2 +-
 svtools/source/graphic/grfmgr.cxx            |    3 ++-
 svtools/source/graphic/grfmgr2.cxx           |    4 ++--
 sw/inc/ndgrf.hxx                             |    4 ++--
 sw/source/core/graphic/ndgrf.cxx             |   12 ++++++++++++
 sw/source/filter/ww8/docxattributeoutput.cxx |   10 ++--------
 sw/source/filter/ww8/rtfattributeoutput.cxx  |    6 ------
 sw/source/filter/ww8/wrtw8esh.cxx            |    2 --
 sw/source/filter/ww8/wrtww8gr.cxx            |    2 --
 9 files changed, 21 insertions(+), 24 deletions(-)

New commits:
commit 6836e9d9ff9c1f79f24fb5d53b617da104ba2969
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date:   Mon Oct 27 11:20:49 2014 +0100

    Assign graphic data also during auto swap in
    
    Change-Id: I09b8d11027f4a1e8470b81677388d4a573b372a6

diff --git a/svtools/source/graphic/grfmgr.cxx b/svtools/source/graphic/grfmgr.cxx
index 2886524..68c19ab 100644
--- a/svtools/source/graphic/grfmgr.cxx
+++ b/svtools/source/graphic/grfmgr.cxx
@@ -266,6 +266,7 @@ void GraphicObject::ImplAutoSwapIn()
                 mpMgr->ImplGraphicObjectWasSwappedIn( *this );
         }
     }
+    ImplAssignGraphicData();
 }
 
 bool GraphicObject::ImplGetCropParams( OutputDevice* pOut, Point& rPt, Size& rSz, const GraphicAttr* pAttr,
commit aee25dbf569ef6b5ee80453e4f581f96e80151ae
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date:   Sun Oct 26 12:26:18 2014 +0100

    fdo#46447: do not auto swap out the same image which was swapped in right now
    
    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

diff --git a/include/svtools/grfmgr.hxx b/include/svtools/grfmgr.hxx
index d452276..a8c391c 100644
--- a/include/svtools/grfmgr.hxx
+++ b/include/svtools/grfmgr.hxx
@@ -615,7 +615,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/svtools/source/graphic/grfmgr.cxx b/svtools/source/graphic/grfmgr.cxx
index eb482cf..2886524 100644
--- a/svtools/source/graphic/grfmgr.cxx
+++ b/svtools/source/graphic/grfmgr.cxx
@@ -70,7 +70,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 ) :
diff --git a/svtools/source/graphic/grfmgr2.cxx b/svtools/source/graphic/grfmgr2.cxx
index b61f079..c97a043 100644
--- a/svtools/source/graphic/grfmgr2.cxx
+++ b/svtools/source/graphic/grfmgr2.cxx
@@ -192,7 +192,7 @@ 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
@@ -205,7 +205,7 @@ void GraphicManager::ImplCheckSizeOfSwappedInGraphics()
     for (size_t i = 0, n = maObjList.size(); i < n; ++i)
     {
         pObj = maObjList[i];
-        if (pObj->meType == GRAPHIC_BITMAP && !pObj->IsSwappedOut() && pObj->GetSizeBytes())
+        if (pObj->meType == GRAPHIC_BITMAP && !pObj->IsSwappedOut() && pObj->GetSizeBytes() && pObj != pGraphicToIgnore)
         {
             aCandidates.push_back(pObj);
             size_t const nSize = pObj->GetSizeBytes();
commit 827d11af9b383223a9aa00de7d45079bbaeacc2a
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date:   Mon Oct 27 09:49:55 2014 +0100

    Swap in graphic by SwGrfNode/SwOLENode 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

diff --git a/sw/inc/ndgrf.hxx b/sw/inc/ndgrf.hxx
index 212a612..2b50fce 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() const;
+    const GraphicObject&    GetGrfObj() const;
     const GraphicObject* GetReplacementGrfObj() const;
     virtual SwCntntNode *SplitCntntNode( const SwPosition & ) SAL_OVERRIDE;
 
diff --git a/sw/source/core/graphic/ndgrf.cxx b/sw/source/core/graphic/ndgrf.cxx
index 910d285..ecbc5a0 100644
--- a/sw/source/core/graphic/ndgrf.cxx
+++ b/sw/source/core/graphic/ndgrf.cxx
@@ -396,6 +396,18 @@ void SwGrfNode::SetGraphic(const Graphic& rGraphic, const OUString& rLink)
     onGraphicChanged();
 }
 
+const Graphic& SwGrfNode::GetGrf() const
+{
+    const_cast<SwGrfNode*>(this)->SwapIn();
+    return maGrfObj.GetGraphic();
+}
+
+const GraphicObject& SwGrfNode::GetGrfObj() const
+{
+    const_cast<SwGrfNode*>(this)->SwapIn();
+    return maGrfObj;
+}
+
 const GraphicObject* SwGrfNode::GetReplacementGrfObj() const
 {
     if(!mpReplacementGraphic)
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index d1de991..720f9a0 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -4128,15 +4128,9 @@ 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
 
-            if (pGraphic->IsSwapOut())
+            if (pGraphic->IsSwapOut() && !pGrfNode)
             {
-                if (pGrfNode)
-                {
-                    // always swapin via the Node
-                    const_cast<SwGrfNode*>(pGrfNode)->SwapIn();
-                }
-                else
-                    const_cast<Graphic*>(pGraphic)->SwapIn();
+                const_cast<Graphic*>(pGraphic)->SwapIn();
             }
 
             OUString aImageId = m_rDrawingML.WriteImage( *pGraphic );
diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index 19b32f0..8f06754 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -3657,12 +3657,6 @@ void RtfAttributeOutput::FlyFrameGraphic(const SwFlyFrmFmt* pFlyFrmFmt, const Sw
     if (rGraphic.GetType()==GRAPHIC_NONE)
         return;
 
-    if (rGraphic.IsSwapOut())
-    {
-        // always swapin via the Node
-        const_cast<SwGrfNode*>(pGrfNode)->SwapIn();
-    }
-
     GfxLink aGraphicLink;
     const sal_Char* pBLIPType = 0;
     if (rGraphic.IsLink())
diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx
index 104cdbe..674911b 100644
--- a/sw/source/filter/ww8/wrtw8esh.cxx
+++ b/sw/source/filter/ww8/wrtw8esh.cxx
@@ -1640,8 +1640,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 27ed033..48787f5 100644
--- a/sw/source/filter/ww8/wrtww8gr.cxx
+++ b/sw/source/filter/ww8/wrtww8gr.cxx
@@ -725,8 +725,6 @@ void SwWW8WrGrf::WriteGrfFromGrfNode(SvStream& rStrm, const SwGrfNode &rGrfNd,
         else
         {
             Graphic& rGrf = const_cast<Graphic&>(rGrfNd.GetGrf());
-            // always swapin via the Node
-            const_cast<SwGrfNode&>(rGrfNd).SwapIn();
 
             GDIMetaFile aMeta;
             switch (rGrf.GetType())


More information about the Libreoffice-commits mailing list