diff options
author | Armin Le Grand <alg@apache.org> | 2013-09-05 13:01:45 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-09-06 11:20:47 +0100 |
commit | c77ec4fe42c064adc507caa2760a99e096f8c016 (patch) | |
tree | 8e7b8dc91f83a0b2366331c2bf56fbc67ae4d403 /svx | |
parent | 871cc47c5ea66d1c2f1cbff5d7564202192ea84c (diff) |
Resolves: #i122985# Various speedups for graphic object swapping
(cherry picked from commit f18ad6132d79540431bf04f090a7472e21a23e49)
Conflicts:
svtools/source/filter/jpeg/jpeg.cxx
svx/inc/svx/svdundo.hxx
svx/source/svdraw/svdograf.cxx
vcl/source/gdi/pngread.cxx
Change-Id: I733551fa9447eb8f45e9163a9c0189f013b03e82
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/svdraw/svdograf.cxx | 43 | ||||
-rw-r--r-- | svx/source/svdraw/svdundo.cxx | 37 |
2 files changed, 74 insertions, 6 deletions
diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx index 277833fdabc6..6adf75b55244 100644 --- a/svx/source/svdraw/svdograf.cxx +++ b/svx/source/svdraw/svdograf.cxx @@ -60,6 +60,7 @@ #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; @@ -67,6 +68,40 @@ 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 +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 aFilterName ) { Graphic aGraphic; @@ -333,7 +368,7 @@ SdrGrafObj::SdrGrafObj() { pGraphic = new GraphicObject; mpReplacementGraphic = 0; - pGraphic->SetSwapStreamHdl( LINK( this, SdrGrafObj, ImpSwapHdl ), SWAPGRAPHIC_TIMEOUT ); + pGraphic->SetSwapStreamHdl( LINK( this, SdrGrafObj, ImpSwapHdl ), getCacheTimeInMs() ); onGraphicChanged(); // #i118485# Shear allowed and possible now @@ -357,7 +392,7 @@ SdrGrafObj::SdrGrafObj(const Graphic& rGrf, const Rectangle& rRect) { pGraphic = new GraphicObject( rGrf ); mpReplacementGraphic = 0; - pGraphic->SetSwapStreamHdl( LINK( this, SdrGrafObj, ImpSwapHdl ), SWAPGRAPHIC_TIMEOUT ); + pGraphic->SetSwapStreamHdl( LINK( this, SdrGrafObj, ImpSwapHdl ), getCacheTimeInMs() ); onGraphicChanged(); // #i118485# Shear allowed and possible now @@ -381,7 +416,7 @@ SdrGrafObj::SdrGrafObj( const Graphic& rGrf ) { pGraphic = new GraphicObject( rGrf ); mpReplacementGraphic = 0; - pGraphic->SetSwapStreamHdl( LINK( this, SdrGrafObj, ImpSwapHdl ), SWAPGRAPHIC_TIMEOUT ); + pGraphic->SetSwapStreamHdl( LINK( this, SdrGrafObj, ImpSwapHdl ), getCacheTimeInMs() ); onGraphicChanged(); // #i118485# Shear allowed and possible now @@ -410,7 +445,7 @@ void SdrGrafObj::SetGraphicObject( const GraphicObject& rGrfObj ) *pGraphic = rGrfObj; delete mpReplacementGraphic; mpReplacementGraphic = 0; - pGraphic->SetSwapStreamHdl( LINK( this, SdrGrafObj, ImpSwapHdl ), SWAPGRAPHIC_TIMEOUT ); + pGraphic->SetSwapStreamHdl( LINK( this, SdrGrafObj, ImpSwapHdl ), getCacheTimeInMs() ); pGraphic->SetUserData(); mbIsPreview = false; SetChanged(); diff --git a/svx/source/svdraw/svdundo.cxx b/svx/source/svdraw/svdundo.cxx index fcdf5f09546d..caf3ba46e1bd 100644 --- a/svx/source/svdraw/svdundo.cxx +++ b/svx/source/svdraw/svdundo.cxx @@ -38,8 +38,9 @@ #include <svx/svdocapt.hxx> #include <svl/whiter.hxx> #include <svx/e3dsceneupdater.hxx> - -#include "svx/svdviter.hxx" +#include <svx/svdviter.hxx> +#include <svx/svdograf.hxx> +#include <svx/sdr/contact/viewcontactofgraphic.hxx> //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -887,6 +888,34 @@ void SdrUndoInsertObj::Redo() //////////////////////////////////////////////////////////////////////////////////////////////////// +void SdrUndoDelObj::TryToFlushGraphicContent() +{ + SdrGrafObj* pSdrGrafObj = dynamic_cast< SdrGrafObj* >(pObj); + + if(pSdrGrafObj) + { + sdr::contact::ViewContactOfGraphic* pVC = dynamic_cast< sdr::contact::ViewContactOfGraphic* >(&pSdrGrafObj->GetViewContact()); + + if(pVC) + { + pVC->flushViewObjectContacts(); + pVC->flushGraphicObjects(); + } + + pSdrGrafObj->ForceSwapOut(); + } +} + +SdrUndoDelObj::SdrUndoDelObj(SdrObject& rNewObj, bool bOrdNumDirect) +: SdrUndoRemoveObj(rNewObj,bOrdNumDirect) +{ + SetOwner(true); + + // #i122985# if graphic object is deleted (but goes to undo) flush it's graphic content + // since it is potentially no longer needed + TryToFlushGraphicContent(); +} + void SdrUndoDelObj::Undo() { SdrUndoRemoveObj::Undo(); @@ -899,6 +928,10 @@ void SdrUndoDelObj::Redo() SdrUndoRemoveObj::Redo(); DBG_ASSERT(!IsOwner(),"RedoDeleteObj: pObj already belongs to UndoAction"); SetOwner(sal_True); + + // #i122985# if graphic object is deleted (but goes to undo) flush it's graphic content + // since it is potentially no longer needed + TryToFlushGraphicContent(); } OUString SdrUndoDelObj::GetComment() const |