diff options
author | Michael Stahl <mstahl@redhat.com> | 2014-02-03 00:12:23 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2014-02-03 12:34:07 +0100 |
commit | 6ef04640ab92ce69000dcff3071eaef4419a9af6 (patch) | |
tree | 60aeee18c60f1922cb73ad2dc3cd11c3a7e3c5cb | |
parent | 2d9d20edc999ef2c2ad2ee628a6a5f27efb801d8 (diff) |
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
-rw-r--r-- | include/svtools/grfmgr.hxx | 2 | ||||
-rw-r--r-- | svtools/source/graphic/grfmgr.cxx | 42 | ||||
-rw-r--r-- | svx/source/svdraw/svdograf.cxx | 45 | ||||
-rw-r--r-- | sw/source/core/graphic/ndgrf.cxx | 8 |
4 files changed, 49 insertions, 48 deletions
diff --git a/include/svtools/grfmgr.hxx b/include/svtools/grfmgr.hxx index 9a9fdefeefb8..8e0a330e1596 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 e6811764e087..41049c7afb0f 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 108917ad0855..7a752b1b2f3a 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 532ee3176606..8d2cb3e1aa04 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 ); |