renaissance1: #i107215# Fixed updates of slide previews.

This commit is contained in:
Andre Fischer
2010-06-07 11:03:39 +02:00
parent 4da1188ef4
commit e969181750
6 changed files with 89 additions and 40 deletions

View File

@@ -252,7 +252,14 @@ void GenericPageCache::RequestPreviewBitmap (
bool GenericPageCache::InvalidatePreviewBitmap (const CacheKey aKey) 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<cache::PageCacheManager> pCacheManager (
cache::PageCacheManager::Instance());
if (pCacheManager)
return pCacheManager->InvalidatePreviewBitmap(
mpCacheContext->GetModel(),
aKey);
else if (mpBitmapCache.get() != NULL)
return mpBitmapCache->InvalidateBitmap(mpCacheContext->GetPage(aKey)); return mpBitmapCache->InvalidateBitmap(mpCacheContext->GetPage(aKey));
else else
return false; return false;

View File

@@ -353,10 +353,12 @@ void PageCacheManager::ReleaseCache (const ::boost::shared_ptr<Cache>& rpCache)
void PageCacheManager::InvalidatePreviewBitmap ( bool PageCacheManager::InvalidatePreviewBitmap (
DocumentKey pDocument, DocumentKey pDocument,
const SdrPage* pKey) const SdrPage* pKey)
{ {
bool bHasChanged (false);
if (pDocument!=NULL) if (pDocument!=NULL)
{ {
// Iterate over all caches that are currently in use and invalidate // Iterate over all caches that are currently in use and invalidate
@@ -364,7 +366,7 @@ void PageCacheManager::InvalidatePreviewBitmap (
PageCacheContainer::iterator iCache; PageCacheContainer::iterator iCache;
for (iCache=mpPageCaches->begin(); iCache!=mpPageCaches->end(); ++iCache) for (iCache=mpPageCaches->begin(); iCache!=mpPageCaches->end(); ++iCache)
if (iCache->first.mpDocument == pDocument) if (iCache->first.mpDocument == pDocument)
iCache->second->InvalidateBitmap(pKey); bHasChanged |= iCache->second->InvalidateBitmap(pKey);
// Invalidate the previews in the recently used caches belonging to // Invalidate the previews in the recently used caches belonging to
// the given document. // the given document.
@@ -373,9 +375,11 @@ void PageCacheManager::InvalidatePreviewBitmap (
{ {
RecentlyUsedQueue::const_iterator iCache2; RecentlyUsedQueue::const_iterator iCache2;
for (iCache2=iQueue->second.begin(); iCache2!=iQueue->second.end(); ++iCache2) for (iCache2=iQueue->second.begin(); iCache2!=iQueue->second.end(); ++iCache2)
iCache2->mpCache->InvalidateBitmap(pKey); bHasChanged |= iCache2->mpCache->InvalidateBitmap(pKey);
} }
} }
return bHasChanged;
} }

View File

@@ -353,9 +353,7 @@ void Listener::Notify (
case HINT_OBJINSERTED: case HINT_OBJINSERTED:
case HINT_OBJREMOVED: case HINT_OBJREMOVED:
case HINT_OBJCHG: case HINT_OBJCHG:
mrSlideSorter.GetView().GetPreviewCache()->InvalidatePreviewBitmap( HandleShapeModification(rSdrHint.GetPage());
rSdrHint.GetPage(),
true);
break; break;
default: default:
@@ -644,44 +642,85 @@ void Listener::UpdateEditMode (void)
void Listener::HandleObjectModification (void)
{
::boost::shared_ptr<cache::PageCacheManager> 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);
nIndex<nCount;
++nIndex)
{
const SdPage* pPage = pDocument->GetSdPage(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) void Listener::HandleShapeModification (const SdrPage* pPage)
{ {
if (pPage == NULL) if (pPage == NULL)
return; return;
// Invalidate the preview of the page (in all slide sorters that display
// it.)
::boost::shared_ptr<cache::PageCacheManager> 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()) if (pPage->IsMasterPage())
{ {
// Invalidate the bitmaps of all pages that are linked to for (USHORT nIndex=0,nCount=pDocument->GetSdPageCount(PK_STANDARD);
// this master page. nIndex<nCount;
model::PageEnumeration aAllPages ( ++nIndex)
model::PageEnumerationProvider::CreateAllPagesEnumeration(
mrSlideSorter.GetModel()));
::boost::shared_ptr<cache::PageCacheManager> pCacheManager (
cache::PageCacheManager::Instance());
if (pCacheManager)
{ {
while (aAllPages.HasMoreElements()) const SdPage* pPage = pDocument->GetSdPage(nIndex, PK_STANDARD);
if (pPage!=NULL && pPage->TRG_HasMasterPage())
{ {
model::SharedPageDescriptor pDescriptor (aAllPages.GetNextElement()); if (&pPage->TRG_GetMasterPage() == rSdrHint.GetPage())
SdrPage* pCandidate = pDescriptor->GetPage(); pCacheManager->InvalidatePreviewBitmap(pDocument->getUnoModel(), pPage);
if (pCandidate!=NULL }
&& pCandidate->TRG_HasMasterPage() else
&& &pCandidate->TRG_GetMasterPage() == pPage) {
{ OSL_ASSERT(pPage!=NULL && pPage->TRG_HasMasterPage());
pCacheManager->InvalidatePreviewBitmap(
mrSlideSorter.GetModel().GetDocument()->getUnoModel(),
pCandidate);
}
mrSlideSorter.GetView().GetPreviewCache()->RequestPreviewBitmap(pCandidate);
} }
} }
} }
else
{
mrSlideSorter.GetView().GetPreviewCache()->InvalidatePreviewBitmap(
pPage,
true);
}
} }

View File

@@ -31,9 +31,7 @@
#include "MutexOwner.hxx" #include "MutexOwner.hxx"
#include "controller/SlideSorterController.hxx" #include "controller/SlideSorterController.hxx"
#include <com/sun/star/document/XEventListener.hpp> #include <com/sun/star/document/XEventListener.hpp>
#ifndef _COM_SUN_STAR_DOCUMENT_XPROPERTYCHANGELISTENER_HPP_
#include <com/sun/star/beans/XPropertyChangeListener.hpp> #include <com/sun/star/beans/XPropertyChangeListener.hpp>
#endif
#include <com/sun/star/accessibility/XAccessibleEventListener.hpp> #include <com/sun/star/accessibility/XAccessibleEventListener.hpp>
#include <com/sun/star/lang/DisposedException.hpp> #include <com/sun/star/lang/DisposedException.hpp>
#include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/beans/XPropertySet.hpp>
@@ -171,9 +169,9 @@ private:
*/ */
void UpdateEditMode (void); void UpdateEditMode (void);
/** Handle a modification to a shape on the given page. /** Handle a modification to a shape on the given page. When this is a
When this is a regular page then update its preview. When it is a regular page then update its preview. When it is a master page then
master page then update the previews of all pages linked to it. additionally update the previews of all pages linked to it.
*/ */
void HandleShapeModification (const SdrPage* pPage); void HandleShapeModification (const SdrPage* pPage);

View File

@@ -141,7 +141,8 @@ public:
void RequestPreviewBitmap (const CacheKey aKey); void RequestPreviewBitmap (const CacheKey aKey);
/** Tell the cache that the bitmap associated with the given request /** 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 @param bRequestPreview
When <TRUE/> then a new preview is requested and will lead When <TRUE/> then a new preview is requested and will lead
eventually to a repaint of the associated page object. eventually to a repaint of the associated page object.

View File

@@ -103,7 +103,7 @@ public:
marked as out-of-date and will be re-created when they are requested marked as out-of-date and will be re-created when they are requested
the next time. the next time.
*/ */
void InvalidatePreviewBitmap ( bool InvalidatePreviewBitmap (
DocumentKey pDocument, DocumentKey pDocument,
const SdrPage* pPage); const SdrPage* pPage);