[Libreoffice-commits] core.git: 5 commits - include/svtools include/tools include/vcl svtools/source svx/source sw/source

Michael Stahl mstahl at redhat.com
Mon Feb 3 03:37:14 PST 2014


 include/svtools/grfmgr.hxx        |    2 -
 include/tools/poly.hxx            |   12 +++++++++
 include/vcl/region.hxx            |   29 ++++++++++++++++++++++
 svtools/source/graphic/grfmgr.cxx |   42 ++++++++++++++++++++++++++++++++-
 svx/source/svdraw/svdograf.cxx    |   48 +++++---------------------------------
 svx/source/svdraw/svdpagv.cxx     |   11 +++++++-
 sw/source/core/graphic/ndgrf.cxx  |    9 ++++---
 7 files changed, 106 insertions(+), 47 deletions(-)

New commits:
commit 66f8b54931f193bdc844c6bca388d9bde98779cd
Author: Michael Stahl <mstahl at redhat.com>
Date:   Mon Feb 3 11:26:59 2014 +0100

    fdo#74435: SdrPageView::DrawLayer(): hack to avoid spuriously visible images
    
    In the TestBook2.odt of fdo#73300 it happens that at some particular
    points when scrolling down, the
    ViewObjectContactOfPageHierarchy::getPrimitive2DSequenceHierarchy()
    will determine that > 200 images are visible; most likely this is due to
    an empty ObjectContactOfPageView::maViewInformation2D::getViewport().
    
    Loading this many images may need more RAM than is available on 32bit
    platforms.
    
    That appears to happen only (but not always) if somehow (not sure
    how exactly) the rectangle passed to SdrPageView::DrawLayer() and the
    existing GetRedrawRegion() do not overlap at all.
    
    (regression from commit 8af09bf33291df2fb2bfbbd6e42f9bf074fcc4fc)
    
    Change-Id: Iafc595241df05204bccec1f2336014fc471b6602

diff --git a/svx/source/svdraw/svdpagv.cxx b/svx/source/svdraw/svdpagv.cxx
index 4a58027..a247258 100644
--- a/svx/source/svdraw/svdpagv.cxx
+++ b/svx/source/svdraw/svdpagv.cxx
@@ -350,7 +350,16 @@ void SdrPageView::DrawLayer(SdrLayerID nID, OutputDevice* pGivenTarget, sdr::con
                     // Copy existing paint region to use the same as prepared in BeginDrawLayer
                     SdrPaintWindow& rExistingPaintWindow = pPreparedTarget->GetPaintWindow();
                     const Region& rExistingRegion = rExistingPaintWindow.GetRedrawRegion();
-                    if ( rRect.IsEmpty() )
+                    bool bUseRect(false);
+                    if (!rRect.IsEmpty())
+                    {
+                        Region r(rExistingRegion);
+                        r.Intersect(rRect);
+                        // fdo#74435: FIXME: visibility check broken if empty
+                        if (!r.IsEmpty())
+                            bUseRect = true;
+                    }
+                    if (!bUseRect)
                         aTemporaryPaintWindow.SetRedrawRegion(rExistingRegion);
                     else
                         aTemporaryPaintWindow.SetRedrawRegion(Region(rRect));
commit 6ef04640ab92ce69000dcff3071eaef4419a9af6
Author: Michael Stahl <mstahl at redhat.com>
Date:   Mon Feb 3 00:12:23 2014 +0100

    remove GraphicObject::SetSwapStreamHdl() timeout parameter
    
    Every call to SetSwapStreamHdl uses the same timeout now so move the
    function that determines that to svtools.
    
    Change-Id: Ib7395d43dd132a9e14e7a7862ff2c2279f319536

diff --git a/include/svtools/grfmgr.hxx b/include/svtools/grfmgr.hxx
index 9a9fdef..8e0a330 100644
--- a/include/svtools/grfmgr.hxx
+++ b/include/svtools/grfmgr.hxx
@@ -324,7 +324,7 @@ public:
 
     sal_Bool                HasSwapStreamHdl() const { return( mpSwapStreamHdl != NULL && mpSwapStreamHdl->IsSet() ); }
     void                    SetSwapStreamHdl();
-    void                    SetSwapStreamHdl( const Link& rHdl, const sal_uLong nSwapOutTimeout = 0UL );
+    void                    SetSwapStreamHdl(const Link& rHdl);
     sal_uLong               GetSwapOutTimeout() const { return( mpSwapOutTimer ? mpSwapOutTimer->GetTimeout() : 0 ); }
 
     void                    FireSwapInRequest();
diff --git a/svtools/source/graphic/grfmgr.cxx b/svtools/source/graphic/grfmgr.cxx
index e681176..41049c7 100644
--- a/svtools/source/graphic/grfmgr.cxx
+++ b/svtools/source/graphic/grfmgr.cxx
@@ -415,10 +415,50 @@ void GraphicObject::SetSwapStreamHdl()
     }
 }
 
-void GraphicObject::SetSwapStreamHdl( const Link& rHdl, const sal_uLong nSwapOutTimeout )
+#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;
+        }
+    }
+
+    return 0;
+}
+
+void GraphicObject::SetSwapStreamHdl(const Link& rHdl)
 {
     delete mpSwapStreamHdl, mpSwapStreamHdl = new Link( rHdl );
 
+    sal_uInt32 const nSwapOutTimeout(GetCacheTimeInMs());
     if( nSwapOutTimeout )
     {
         if( !mpSwapOutTimer )
diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx
index 108917a..7a752b1 100644
--- a/svx/source/svdraw/svdograf.cxx
+++ b/svx/source/svdraw/svdograf.cxx
@@ -61,48 +61,11 @@
 #include <osl/thread.hxx>
 #include <drawinglayer/processor2d/objectinfoextractor2d.hxx>
 #include <drawinglayer/primitive2d/objectinfoprimitive2d.hxx>
-#include <officecfg/Office/Common.hxx>
 
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
 using namespace ::com::sun::star::io;
 
-#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 compromize, see description
-SVX_DLLPUBLIC 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 compromize to me.
-            return nSeconds * 1000 / 12;
-        }
-        else
-        {
-            return SWAPGRAPHIC_TIMEOUT;
-        }
-    }
-
-    return 0;
-}
-
 const Graphic ImpLoadLinkedGraphic( const OUString& aFileName, const OUString& aReferer, const OUString& aFilterName )
 {
     Graphic aGraphic;
@@ -380,7 +343,7 @@ SdrGrafObj::SdrGrafObj()
 {
     pGraphic = new GraphicObject;
     mpReplacementGraphic = 0;
-    pGraphic->SetSwapStreamHdl( LINK( this, SdrGrafObj, ImpSwapHdl ), getCacheTimeInMs() );
+    pGraphic->SetSwapStreamHdl( LINK(this, SdrGrafObj, ImpSwapHdl) );
     onGraphicChanged();
 
     // #i118485# Shear allowed and possible now
@@ -404,7 +367,7 @@ SdrGrafObj::SdrGrafObj(const Graphic& rGrf, const Rectangle& rRect)
 {
     pGraphic = new GraphicObject( rGrf );
     mpReplacementGraphic = 0;
-    pGraphic->SetSwapStreamHdl( LINK( this, SdrGrafObj, ImpSwapHdl ), getCacheTimeInMs() );
+    pGraphic->SetSwapStreamHdl( LINK(this, SdrGrafObj, ImpSwapHdl) );
     onGraphicChanged();
 
     // #i118485# Shear allowed and possible now
@@ -428,7 +391,7 @@ SdrGrafObj::SdrGrafObj( const Graphic& rGrf )
 {
     pGraphic = new GraphicObject( rGrf );
     mpReplacementGraphic = 0;
-    pGraphic->SetSwapStreamHdl( LINK( this, SdrGrafObj, ImpSwapHdl ), getCacheTimeInMs() );
+    pGraphic->SetSwapStreamHdl( LINK(this, SdrGrafObj, ImpSwapHdl) );
     onGraphicChanged();
 
     // #i118485# Shear allowed and possible now
@@ -457,7 +420,7 @@ void SdrGrafObj::SetGraphicObject( const GraphicObject& rGrfObj )
     *pGraphic = rGrfObj;
     delete mpReplacementGraphic;
     mpReplacementGraphic = 0;
-    pGraphic->SetSwapStreamHdl( LINK( this, SdrGrafObj, ImpSwapHdl ), getCacheTimeInMs() );
+    pGraphic->SetSwapStreamHdl( LINK(this, SdrGrafObj, ImpSwapHdl) );
     pGraphic->SetUserData();
     mbIsPreview = false;
     SetChanged();
diff --git a/sw/source/core/graphic/ndgrf.cxx b/sw/source/core/graphic/ndgrf.cxx
index 532ee31..8d2cb3e 100644
--- a/sw/source/core/graphic/ndgrf.cxx
+++ b/sw/source/core/graphic/ndgrf.cxx
@@ -56,8 +56,6 @@
 
 using namespace com::sun::star;
 
-SVX_DLLPUBLIC sal_uInt32 getCacheTimeInMs();
-
 SwGrfNode::SwGrfNode(
         const SwNodeIndex & rWhere,
         const OUString& rGrfName, const OUString& rFltName,
@@ -71,7 +69,7 @@ SwGrfNode::SwGrfNode(
     mbLinkedInputStreamReady( false ),
     mbIsStreamReadOnly( sal_False )
 {
-    maGrfObj.SetSwapStreamHdl( LINK(this, SwGrfNode, SwapGraphic), getCacheTimeInMs() );
+    maGrfObj.SetSwapStreamHdl( LINK(this, SwGrfNode, SwapGraphic) );
     bInSwapIn = bChgTwipSize = bChgTwipSizeFromPixel = bLoadLowResGrf =
         bFrameInPaint = bScaleImageMap = sal_False;
 
@@ -89,7 +87,7 @@ SwGrfNode::SwGrfNode( const SwNodeIndex & rWhere,
     mbLinkedInputStreamReady( false ),
     mbIsStreamReadOnly( sal_False )
 {
-    maGrfObj.SetSwapStreamHdl( LINK(this, SwGrfNode, SwapGraphic), getCacheTimeInMs() );
+    maGrfObj.SetSwapStreamHdl( LINK(this, SwGrfNode, SwapGraphic) );
     if( rGrfObj.HasUserData() && rGrfObj.IsSwappedOut() )
         maGrfObj.SetSwapState();
     bInSwapIn = bChgTwipSize = bChgTwipSizeFromPixel= bLoadLowResGrf =
@@ -114,7 +112,7 @@ SwGrfNode::SwGrfNode( const SwNodeIndex & rWhere,
     mbLinkedInputStreamReady( false ),
     mbIsStreamReadOnly( sal_False )
 {
-    maGrfObj.SetSwapStreamHdl( LINK(this, SwGrfNode, SwapGraphic), getCacheTimeInMs() );
+    maGrfObj.SetSwapStreamHdl( LINK(this, SwGrfNode, SwapGraphic) );
 
     Graphic aGrf; aGrf.SetDefaultType();
     maGrfObj.SetGraphic( aGrf, rGrfName );
commit 2d9d20edc999ef2c2ad2ee628a6a5f27efb801d8
Author: Michael Stahl <mstahl at redhat.com>
Date:   Sun Feb 2 23:59:17 2014 +0100

    fdo#73300: sw: GraphicObjects are never swapped out
    
    In SwNoTxtFrm::PaintPicture() the GraphicObjects are no longer painted
    via GraphicObject::Draw() any more there is the problem that they are
    not cached any more in the display cache of the GraphicManager; that
    used to immediately swap out the Graphic but now they are never swapped
    out.  Since there appears to be no use of the GraphicManager's display
    cache in the new drawinglayer based rendering path i have no idea how to
    swap out the Graphic immediately; instead use the same time-out that
    SdrGrafObj is using already.
    
    This timeout is derived from the setting:
    Tools->Options->LibreOffice->Memory->Graphics cache->"Remove from memory
    after".
    
    (regression from 2e5167528f7566dd9b000e50fc1610b7bf99132a)
    
    Change-Id: I0d9b535a82646d9b6635cfb3917f74dcc3ad8720

diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx
index 949898b..108917a 100644
--- a/svx/source/svdraw/svdograf.cxx
+++ b/svx/source/svdraw/svdograf.cxx
@@ -71,7 +71,7 @@ using namespace ::com::sun::star::io;
 
 // #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 compromize, see description
-sal_uInt32 getCacheTimeInMs()
+SVX_DLLPUBLIC sal_uInt32 getCacheTimeInMs()
 {
     static bool bSetAtAll(true);
 
diff --git a/sw/source/core/graphic/ndgrf.cxx b/sw/source/core/graphic/ndgrf.cxx
index 5d217fb..532ee31 100644
--- a/sw/source/core/graphic/ndgrf.cxx
+++ b/sw/source/core/graphic/ndgrf.cxx
@@ -56,6 +56,8 @@
 
 using namespace com::sun::star;
 
+SVX_DLLPUBLIC sal_uInt32 getCacheTimeInMs();
+
 SwGrfNode::SwGrfNode(
         const SwNodeIndex & rWhere,
         const OUString& rGrfName, const OUString& rFltName,
@@ -69,7 +71,7 @@ SwGrfNode::SwGrfNode(
     mbLinkedInputStreamReady( false ),
     mbIsStreamReadOnly( sal_False )
 {
-    maGrfObj.SetSwapStreamHdl( LINK( this, SwGrfNode, SwapGraphic ) );
+    maGrfObj.SetSwapStreamHdl( LINK(this, SwGrfNode, SwapGraphic), getCacheTimeInMs() );
     bInSwapIn = bChgTwipSize = bChgTwipSizeFromPixel = bLoadLowResGrf =
         bFrameInPaint = bScaleImageMap = sal_False;
 
@@ -87,7 +89,7 @@ SwGrfNode::SwGrfNode( const SwNodeIndex & rWhere,
     mbLinkedInputStreamReady( false ),
     mbIsStreamReadOnly( sal_False )
 {
-    maGrfObj.SetSwapStreamHdl( LINK( this, SwGrfNode, SwapGraphic ) );
+    maGrfObj.SetSwapStreamHdl( LINK(this, SwGrfNode, SwapGraphic), getCacheTimeInMs() );
     if( rGrfObj.HasUserData() && rGrfObj.IsSwappedOut() )
         maGrfObj.SetSwapState();
     bInSwapIn = bChgTwipSize = bChgTwipSizeFromPixel= bLoadLowResGrf =
@@ -112,7 +114,7 @@ SwGrfNode::SwGrfNode( const SwNodeIndex & rWhere,
     mbLinkedInputStreamReady( false ),
     mbIsStreamReadOnly( sal_False )
 {
-    maGrfObj.SetSwapStreamHdl( LINK( this, SwGrfNode, SwapGraphic ) );
+    maGrfObj.SetSwapStreamHdl( LINK(this, SwGrfNode, SwapGraphic), getCacheTimeInMs() );
 
     Graphic aGrf; aGrf.SetDefaultType();
     maGrfObj.SetGraphic( aGrf, rGrfName );
commit e4be770ec8218d80dcc9f1e38fd1c69717beb4fb
Author: Michael Stahl <mstahl at redhat.com>
Date:   Sun Feb 2 22:25:28 2014 +0100

    add std::ostream operators for Region and PolyPolygon
    
    Change-Id: I8f4129b840a27f3029643ad2a4852f9e10604905

diff --git a/include/tools/poly.hxx b/include/tools/poly.hxx
index c677143..ce96dc5 100644
--- a/include/tools/poly.hxx
+++ b/include/tools/poly.hxx
@@ -278,6 +278,18 @@ public:
 
 typedef std::vector< PolyPolygon > PolyPolyVector;
 
+
+template<typename charT, typename traits>
+inline std::basic_ostream<charT, traits> & operator <<(
+    std::basic_ostream<charT, traits> & stream, const PolyPolygon& rPolyPoly)
+{
+    if (!rPolyPoly.Count())
+        stream << "EMPTY";
+    for (sal_uInt16 i = 0; i < rPolyPoly.Count(); ++i)
+        stream << "[" << i << "] " << rPolyPoly.GetObject(i);
+    return stream;
+}
+
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/vcl/region.hxx b/include/vcl/region.hxx
index d3eec64..3a3a64b 100644
--- a/include/vcl/region.hxx
+++ b/include/vcl/region.hxx
@@ -126,6 +126,35 @@ public:
     static Region GetRegionFromPolyPolygon( const PolyPolygon& rPolyPoly );
 };
 
+
+template< typename charT, typename traits >
+inline std::basic_ostream<charT, traits> & operator <<(
+    std::basic_ostream<charT, traits> & stream, const Region& rRegion)
+{
+    if (rRegion.IsEmpty())
+        return stream << "EMPTY";
+    if (rRegion.getB2DPolyPolygon())
+        return stream << "B2DPolyPolygon("
+                      << *rRegion.getB2DPolyPolygon()
+                      << ")";
+    if (rRegion.getPolyPolygon())
+        return stream << "PolyPolygon("
+                      << *rRegion.getPolyPolygon()
+                      << ")";
+    if (rRegion.getRegionBand())
+    {   // inlined because RegionBand is private to vcl
+        stream << "RegionBand(";
+        RectangleVector rects;
+        rRegion.GetRegionRectangles(rects);
+        if (rects.empty())
+            stream << "EMPTY";
+        for (size_t i = 0; i < rects.size(); ++i)
+            stream << "[" << i << "] " << rects[i];
+        stream << ")";
+    }
+    return stream;
+}
+
 #endif // INCLUDED_VCL_REGION_HXX
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 9b9eb2e4f619c63eabdc54b5d749ac55d8eaf333
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Jan 31 23:00:24 2014 +0100

    fdo#73300: sw: don't swap in all images when loading files
    
    (regression from bd55f05b332c1573bd410fd9e21ea7fcf977e1b0)
    
    Change-Id: I55532ac0fe983461e961a61149479343d2b879a1

diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx
index 58688bc..949898b 100644
--- a/svx/source/svdraw/svdograf.cxx
+++ b/svx/source/svdraw/svdograf.cxx
@@ -321,6 +321,9 @@ sdr::contact::ViewContact* SdrGrafObj::CreateObjectSpecificViewContact()
 
 void SdrGrafObj::onGraphicChanged()
 {
+    if (!pGraphic || pGraphic->IsSwappedOut()) // don't force swap-in for this
+        return;
+
     OUString aName;
     OUString aTitle;
     OUString aDesc;
diff --git a/sw/source/core/graphic/ndgrf.cxx b/sw/source/core/graphic/ndgrf.cxx
index 06a10da..5d217fb 100644
--- a/sw/source/core/graphic/ndgrf.cxx
+++ b/sw/source/core/graphic/ndgrf.cxx
@@ -339,6 +339,9 @@ SwGrfNode::~SwGrfNode()
 /// allow reaction on change of content of GraphicObject
 void SwGrfNode::onGraphicChanged()
 {
+    if (GetGrfObj().IsSwappedOut()) // don't force swap-in for this
+        return;
+
     // try to access SwFlyFrmFmt; since title/desc/name are set there, there is no
     // use to continue if it is not yet set. If not yet set, call onGraphicChanged()
     // when it is set.


More information about the Libreoffice-commits mailing list