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
This commit is contained in:
Michael Stahl
2014-02-03 00:12:23 +01:00
parent 2d9d20edc9
commit 6ef04640ab
4 changed files with 49 additions and 48 deletions

View File

@@ -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();

View File

@@ -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 )

View File

@@ -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();

View File

@@ -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 );