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

Zolnai Tamás tamas.zolnai at collabora.com
Fri Oct 31 17:17:37 PDT 2014


 include/svtools/grfmgr.hxx                   |    2 +-
 include/vcl/graph.hxx                        |    3 +++
 oox/source/export/drawingml.cxx              |   13 -------------
 svtools/source/graphic/grfmgr.cxx            |   20 +++-----------------
 svtools/source/graphic/grfmgr2.cxx           |    2 +-
 sw/inc/ndole.hxx                             |    1 -
 sw/source/core/graphic/ndgrf.cxx             |   16 +++++++---------
 sw/source/core/ole/ndole.cxx                 |    5 +----
 sw/source/filter/ww8/docxattributeoutput.cxx |    5 -----
 vcl/source/gdi/cvtgrf.cxx                    |    2 --
 10 files changed, 16 insertions(+), 53 deletions(-)

New commits:
commit 31c848450f4afa52fae39546d8f37763208cf384
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date:   Sat Nov 1 01:08:49 2014 +0100

    Why to have this compromise, do that what we say the users we do.
    
    Change-Id: Ia599644ff1f7591ac84bdca988883eaf5860297e

diff --git a/svtools/source/graphic/grfmgr.cxx b/svtools/source/graphic/grfmgr.cxx
index 588e521..a524c00 100644
--- a/svtools/source/graphic/grfmgr.cxx
+++ b/svtools/source/graphic/grfmgr.cxx
@@ -441,25 +441,13 @@ void GraphicObject::SetSwapStreamHdl()
     }
 }
 
-// #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()
 {
     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;
+    return nSeconds * 1000;
 }
 
 void GraphicObject::SetSwapStreamHdl(const Link& rHdl)
commit 3f6f23a06fe9a95ec74593057dd3473f2a912c6b
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date:   Sat Nov 1 01:07:48 2014 +0100

    Swaping 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

diff --git a/include/svtools/grfmgr.hxx b/include/svtools/grfmgr.hxx
index d9c1954..d515773 100644
--- a/include/svtools/grfmgr.hxx
+++ b/include/svtools/grfmgr.hxx
@@ -412,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 );
diff --git a/include/vcl/graph.hxx b/include/vcl/graph.hxx
index b55e7901..8727b9c 100644
--- a/include/vcl/graph.hxx
+++ b/include/vcl/graph.hxx
@@ -176,6 +176,8 @@ public:
     const OUString&       GetDocFileName() const;
     sal_uLong               GetDocFilePos() const;
 
+private:
+    friend class GraphicObject;
     bool                SwapOut();
     void                SwapOutAsLink();
     bool                SwapOut( SvStream* pOStm );
@@ -183,6 +185,7 @@ public:
     bool                SwapIn( SvStream* pIStm );
     bool                IsSwapOut() const;
 
+public:
     void                SetLink( const GfxLink& );
     GfxLink             GetLink() const;
     bool                IsLink() const;
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 3c38c4d..5ca7c83 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 );
diff --git a/svtools/source/graphic/grfmgr.cxx b/svtools/source/graphic/grfmgr.cxx
index 64f2b10..588e521 100644
--- a/svtools/source/graphic/grfmgr.cxx
+++ b/svtools/source/graphic/grfmgr.cxx
@@ -694,9 +694,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
@@ -736,7 +734,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() );
 
diff --git a/svtools/source/graphic/grfmgr2.cxx b/svtools/source/graphic/grfmgr2.cxx
index 7f93bf9..d054ab3 100644
--- a/svtools/source/graphic/grfmgr2.cxx
+++ b/svtools/source/graphic/grfmgr2.cxx
@@ -279,7 +279,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/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 720f9a0..53c9e01 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -4128,11 +4128,6 @@ 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() && !pGrfNode)
-            {
-                const_cast<Graphic*>(pGraphic)->SwapIn();
-            }
-
             OUString aImageId = m_rDrawingML.WriteImage( *pGraphic );
 
             aRelId = OUStringToOString( aImageId, RTL_TEXTENCODING_UTF8 );
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;
 
commit 3ba3092d13442bc91c746bdb9e8b3efa612c027b
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date:   Fri Oct 31 18:27:30 2014 +0100

    Remove unused Graphic member of SwOLENode
    
    Change-Id: Iaff7e86a8e11e9befc6feacdafd3a78a1971bbcd

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/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 & )
commit fa14d751d9a7723265eb5fee1c7dee3e94563207
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date:   Fri Oct 31 18:20:51 2014 +0100

    Avoid a potential image loss in SwGrfNode::SwapOut() method.
    
    It's better to be explicit when to swap out as a link.
    Before if an embedded image swap out failed (e.g. i/o error)
    than swap out it as a link could lead to image loss.
    
    Change-Id: I70dd00d5f82c5f4f622805e1d6ee1dfc30900b31

diff --git a/sw/source/core/graphic/ndgrf.cxx b/sw/source/core/graphic/ndgrf.cxx
index 3cd7ef9..bb7a9081 100644
--- a/sw/source/core/graphic/ndgrf.cxx
+++ b/sw/source/core/graphic/ndgrf.cxx
@@ -620,17 +620,15 @@ bool SwGrfNode::SwapOut()
         maGrfObj.GetType() != GRAPHIC_NONE &&
         !maGrfObj.IsSwappedOut() && !bInSwapIn )
     {
-        if( !refLink.Is() )
+        if( refLink.Is() || HasEmbeddedStreamName() )
         {
-            // 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;
+            // written graphics and links are removed here
+            return maGrfObj.SwapOut( GRFMGR_AUTOSWAPSTREAM_LINK );
         }
-        // written graphics and links are removed here
-        return maGrfObj.SwapOut( GRFMGR_AUTOSWAPSTREAM_LINK );
+        {
+            return maGrfObj.SwapOut();
+        }
+
     }
     return true;
 }


More information about the Libreoffice-commits mailing list