From e96918175018ddff6b954c0b980b810f1569178c Mon Sep 17 00:00:00 2001 From: Andre Fischer Date: Mon, 7 Jun 2010 11:03:39 +0200 Subject: [PATCH] renaissance1: #i107215# Fixed updates of slide previews. --- .../slidesorter/cache/SlsGenericPageCache.cxx | 9 +- .../slidesorter/cache/SlsPageCacheManager.cxx | 10 +- .../ui/slidesorter/controller/SlsListener.cxx | 97 +++++++++++++------ .../ui/slidesorter/controller/SlsListener.hxx | 8 +- .../ui/slidesorter/inc/cache/SlsPageCache.hxx | 3 +- .../inc/cache/SlsPageCacheManager.hxx | 2 +- 6 files changed, 89 insertions(+), 40 deletions(-) diff --git a/sd/source/ui/slidesorter/cache/SlsGenericPageCache.cxx b/sd/source/ui/slidesorter/cache/SlsGenericPageCache.cxx index 386adf7d5042..f71bddc2372d 100644 --- a/sd/source/ui/slidesorter/cache/SlsGenericPageCache.cxx +++ b/sd/source/ui/slidesorter/cache/SlsGenericPageCache.cxx @@ -252,7 +252,14 @@ void GenericPageCache::RequestPreviewBitmap ( bool GenericPageCache::InvalidatePreviewBitmap (const CacheKey aKey) { - if (mpBitmapCache.get() != NULL) + // Invalidate the page in all caches that reference it, not just this one. + ::boost::shared_ptr pCacheManager ( + cache::PageCacheManager::Instance()); + if (pCacheManager) + return pCacheManager->InvalidatePreviewBitmap( + mpCacheContext->GetModel(), + aKey); + else if (mpBitmapCache.get() != NULL) return mpBitmapCache->InvalidateBitmap(mpCacheContext->GetPage(aKey)); else return false; diff --git a/sd/source/ui/slidesorter/cache/SlsPageCacheManager.cxx b/sd/source/ui/slidesorter/cache/SlsPageCacheManager.cxx index 820288de331d..97eb70dd7296 100644 --- a/sd/source/ui/slidesorter/cache/SlsPageCacheManager.cxx +++ b/sd/source/ui/slidesorter/cache/SlsPageCacheManager.cxx @@ -353,10 +353,12 @@ void PageCacheManager::ReleaseCache (const ::boost::shared_ptr& rpCache) -void PageCacheManager::InvalidatePreviewBitmap ( +bool PageCacheManager::InvalidatePreviewBitmap ( DocumentKey pDocument, const SdrPage* pKey) { + bool bHasChanged (false); + if (pDocument!=NULL) { // Iterate over all caches that are currently in use and invalidate @@ -364,7 +366,7 @@ void PageCacheManager::InvalidatePreviewBitmap ( PageCacheContainer::iterator iCache; for (iCache=mpPageCaches->begin(); iCache!=mpPageCaches->end(); ++iCache) if (iCache->first.mpDocument == pDocument) - iCache->second->InvalidateBitmap(pKey); + bHasChanged |= iCache->second->InvalidateBitmap(pKey); // Invalidate the previews in the recently used caches belonging to // the given document. @@ -373,9 +375,11 @@ void PageCacheManager::InvalidatePreviewBitmap ( { RecentlyUsedQueue::const_iterator iCache2; for (iCache2=iQueue->second.begin(); iCache2!=iQueue->second.end(); ++iCache2) - iCache2->mpCache->InvalidateBitmap(pKey); + bHasChanged |= iCache2->mpCache->InvalidateBitmap(pKey); } } + + return bHasChanged; } diff --git a/sd/source/ui/slidesorter/controller/SlsListener.cxx b/sd/source/ui/slidesorter/controller/SlsListener.cxx index 0180d2a717a8..726a96adeba7 100644 --- a/sd/source/ui/slidesorter/controller/SlsListener.cxx +++ b/sd/source/ui/slidesorter/controller/SlsListener.cxx @@ -353,9 +353,7 @@ void Listener::Notify ( case HINT_OBJINSERTED: case HINT_OBJREMOVED: case HINT_OBJCHG: - mrSlideSorter.GetView().GetPreviewCache()->InvalidatePreviewBitmap( - rSdrHint.GetPage(), - true); + HandleShapeModification(rSdrHint.GetPage()); break; default: @@ -644,44 +642,85 @@ void Listener::UpdateEditMode (void) +void Listener::HandleObjectModification (void) +{ + ::boost::shared_ptr pInstance ( + cache::PageCacheManager::Instance()); + if ( ! pInstance) + break; + SdDrawDocument* pDocument = mrSlideSorter.GetModel().GetDocument(); + if (pDocument == NULL) + { + OSL_ASSERT(pDocument!=NULL); + break; + } + pInstance->InvalidatePreviewBitmap(pDocument->getUnoModel(), rSdrHint.GetPage()); + mrSlideSorter.GetView().GetPreviewCache()->RequestPreviewBitmap(rSdrHint.GetPage()); + + // When the modified page is a master page then we have to + // invalidate all pages that depend on it. + if (rSdrHint.GetPage()->IsMasterPage()) + { + for (USHORT nIndex=0,nCount=pDocument->GetSdPageCount(PK_STANDARD); + nIndexGetSdPage(nIndex, PK_STANDARD); + if (pPage!=NULL && pPage->TRG_HasMasterPage()) + { + if (&pPage->TRG_GetMasterPage() == rSdrHint.GetPage()) + pInstance->InvalidatePreviewBitmap(pDocument->getUnoModel(), pPage); + } + else + { + OSL_ASSERT(pPage!=NULL && pPage->TRG_HasMasterPage()); + } + } + } +} + + + + void Listener::HandleShapeModification (const SdrPage* pPage) { if (pPage == NULL) return; + // Invalidate the preview of the page (in all slide sorters that display + // it.) + ::boost::shared_ptr pCacheManager (cache::PageCacheManager::Instance()); + if ( ! pCacheManager) + break; + SdDrawDocument* pDocument = mrSlideSorter.GetModel().GetDocument(); + if (pDocument == NULL) + { + OSL_ASSERT(pDocument!=NULL); + break; + } + pCacheManager->InvalidatePreviewBitmap(pDocument->getUnoModel(), rSdrHint.GetPage()); + mrSlideSorter.GetView().GetPreviewCache()->RequestPreviewBitmap(rSdrHint.GetPage()); + + // When the page is a master page then invalidate the previews of all + // pages that are linked to this master page. if (pPage->IsMasterPage()) { - // Invalidate the bitmaps of all pages that are linked to - // this master page. - model::PageEnumeration aAllPages ( - model::PageEnumerationProvider::CreateAllPagesEnumeration( - mrSlideSorter.GetModel())); - ::boost::shared_ptr pCacheManager ( - cache::PageCacheManager::Instance()); - if (pCacheManager) + for (USHORT nIndex=0,nCount=pDocument->GetSdPageCount(PK_STANDARD); + nIndexGetSdPage(nIndex, PK_STANDARD); + if (pPage!=NULL && pPage->TRG_HasMasterPage()) { - model::SharedPageDescriptor pDescriptor (aAllPages.GetNextElement()); - SdrPage* pCandidate = pDescriptor->GetPage(); - if (pCandidate!=NULL - && pCandidate->TRG_HasMasterPage() - && &pCandidate->TRG_GetMasterPage() == pPage) - { - pCacheManager->InvalidatePreviewBitmap( - mrSlideSorter.GetModel().GetDocument()->getUnoModel(), - pCandidate); - } - mrSlideSorter.GetView().GetPreviewCache()->RequestPreviewBitmap(pCandidate); + if (&pPage->TRG_GetMasterPage() == rSdrHint.GetPage()) + pCacheManager->InvalidatePreviewBitmap(pDocument->getUnoModel(), pPage); + } + else + { + OSL_ASSERT(pPage!=NULL && pPage->TRG_HasMasterPage()); } } } - else - { - mrSlideSorter.GetView().GetPreviewCache()->InvalidatePreviewBitmap( - pPage, - true); - } } diff --git a/sd/source/ui/slidesorter/controller/SlsListener.hxx b/sd/source/ui/slidesorter/controller/SlsListener.hxx index 799e151afaac..d10c46fa9423 100644 --- a/sd/source/ui/slidesorter/controller/SlsListener.hxx +++ b/sd/source/ui/slidesorter/controller/SlsListener.hxx @@ -31,9 +31,7 @@ #include "MutexOwner.hxx" #include "controller/SlideSorterController.hxx" #include -#ifndef _COM_SUN_STAR_DOCUMENT_XPROPERTYCHANGELISTENER_HPP_ #include -#endif #include #include #include @@ -171,9 +169,9 @@ private: */ void UpdateEditMode (void); - /** Handle a modification to a shape on the given page. - When this is a regular page then update its preview. When it is a - master page then update the previews of all pages linked to it. + /** Handle a modification to a shape on the given page. When this is a + regular page then update its preview. When it is a master page then + additionally update the previews of all pages linked to it. */ void HandleShapeModification (const SdrPage* pPage); diff --git a/sd/source/ui/slidesorter/inc/cache/SlsPageCache.hxx b/sd/source/ui/slidesorter/inc/cache/SlsPageCache.hxx index a21dd679b16b..48da4faf02e3 100644 --- a/sd/source/ui/slidesorter/inc/cache/SlsPageCache.hxx +++ b/sd/source/ui/slidesorter/inc/cache/SlsPageCache.hxx @@ -141,7 +141,8 @@ public: void RequestPreviewBitmap (const CacheKey aKey); /** Tell the cache that the bitmap associated with the given request - data is not up-to-date anymore. + data is not up-to-date anymore. This will invalidate all previews + in other caches that represent the same page as well. @param bRequestPreview When then a new preview is requested and will lead eventually to a repaint of the associated page object. diff --git a/sd/source/ui/slidesorter/inc/cache/SlsPageCacheManager.hxx b/sd/source/ui/slidesorter/inc/cache/SlsPageCacheManager.hxx index 8e1d827a286f..c6b18eb077bc 100644 --- a/sd/source/ui/slidesorter/inc/cache/SlsPageCacheManager.hxx +++ b/sd/source/ui/slidesorter/inc/cache/SlsPageCacheManager.hxx @@ -103,7 +103,7 @@ public: marked as out-of-date and will be re-created when they are requested the next time. */ - void InvalidatePreviewBitmap ( + bool InvalidatePreviewBitmap ( DocumentKey pDocument, const SdrPage* pPage);