From 61b32a70c92ee1b1148bcd9788561b79dc1910c8 Mon Sep 17 00:00:00 2001 From: Armin Le Grand Date: Thu, 19 Jun 2014 16:49:26 +0000 Subject: i125111 limit mem footprint for GraphicObjects in 32Bit environments --- sw/source/core/doc/notxtfrm.cxx | 3 +++ sw/source/core/graphic/ndgrf.cxx | 36 +++++++++++++++++++++++++++++------- 2 files changed, 32 insertions(+), 7 deletions(-) (limited to 'sw') diff --git a/sw/source/core/doc/notxtfrm.cxx b/sw/source/core/doc/notxtfrm.cxx index 95eb23c471c2..d96023a94bb8 100644 --- a/sw/source/core/doc/notxtfrm.cxx +++ b/sw/source/core/doc/notxtfrm.cxx @@ -1019,6 +1019,9 @@ void SwNoTxtFrm::PaintPicture( OutputDevice* pOut, const SwRect &rGrfArea ) cons aContent, aTargetRange, aTargetRange); + + // need to reset the timer manually (was in original paints at GraphicManager) + rGrfObj.restartSwapOutTimer(); } } else diff --git a/sw/source/core/graphic/ndgrf.cxx b/sw/source/core/graphic/ndgrf.cxx index bf789f1b5b43..2ba45183563e 100644 --- a/sw/source/core/graphic/ndgrf.cxx +++ b/sw/source/core/graphic/ndgrf.cxx @@ -58,14 +58,36 @@ #include #include #include +#include using namespace com::sun::star; +#define SWAPGRAPHIC_TIMEOUT 5000 -// As Writer graphics are no longer painted via the graphic manager - see - -// it is needed to swap out the Writer graphics automatically after a certain amount of time. -// --> 5000ms -#define TIMETOSWAPOUTGRAPHICAUTOMATICALLY 5000 +// For comments see same method used in svx +sal_uInt32 getCacheTimeInMs() +{ + static bool bSetAtAll(true); + + if(bSetAtAll) + { + static bool bSetToPreferenceTime(true); + + if(bSetToPreferenceTime) + { + const SvtCacheOptions aCacheOptions; + const sal_Int32 nSeconds(aCacheOptions.GetGraphicManagerObjectReleaseTime()); + + return nSeconds * 1000 / 12; + } + else + { + return SWAPGRAPHIC_TIMEOUT; + } + } + + return 0; +} // -------------------- // SwGrfNode @@ -83,7 +105,7 @@ SwGrfNode::SwGrfNode( mbLinkedInputStreamReady( false ), mbIsStreamReadOnly( sal_False ) { - maGrfObj.SetSwapStreamHdl( LINK( this, SwGrfNode, SwapGraphic ), TIMETOSWAPOUTGRAPHICAUTOMATICALLY ); + maGrfObj.SetSwapStreamHdl( LINK( this, SwGrfNode, SwapGraphic ), getCacheTimeInMs() ); bInSwapIn = bChgTwipSize = bChgTwipSizeFromPixel = bLoadLowResGrf = bFrameInPaint = bScaleImageMap = sal_False; bGrafikArrived = sal_True; @@ -102,7 +124,7 @@ SwGrfNode::SwGrfNode( mbIsStreamReadOnly( sal_False ) { maGrfObj = rGrfObj; - maGrfObj.SetSwapStreamHdl( LINK( this, SwGrfNode, SwapGraphic ), TIMETOSWAPOUTGRAPHICAUTOMATICALLY ); + maGrfObj.SetSwapStreamHdl( LINK( this, SwGrfNode, SwapGraphic ), getCacheTimeInMs() ); if ( rGrfObj.HasUserData() && rGrfObj.IsSwappedOut() ) maGrfObj.SetSwapState(); bInSwapIn = bChgTwipSize = bChgTwipSizeFromPixel = bLoadLowResGrf = bFrameInPaint = bScaleImageMap = sal_False; @@ -125,7 +147,7 @@ SwGrfNode::SwGrfNode( mbLinkedInputStreamReady( false ), mbIsStreamReadOnly( sal_False ) { - maGrfObj.SetSwapStreamHdl( LINK( this, SwGrfNode, SwapGraphic ), TIMETOSWAPOUTGRAPHICAUTOMATICALLY ); + maGrfObj.SetSwapStreamHdl( LINK( this, SwGrfNode, SwapGraphic ), getCacheTimeInMs() ); Graphic aGrf; aGrf.SetDefaultType(); -- cgit