LibreOffice Module sd (master) 1
Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
sd::slidesorter::cache::PageCacheManager Class Reference

Provide and manage the preview bitmap caches for all slide sorter instances. More...

#include <SlsPageCacheManager.hxx>

Classes

class  Deleter
 
class  PageCacheContainer
 Container for the active caches. More...
 
class  RecentlyUsedPageCaches
 The recently used caches are stored in one queue for each document. More...
 

Public Types

typedef std::vector< std::pair< Size, std::shared_ptr< BitmapCache > > > BestFittingPageCaches
 
typedef css::uno::Reference< css::uno::XInterface > DocumentKey
 

Public Member Functions

std::shared_ptr< BitmapCacheGetCache (const DocumentKey &pDocument, const Size &rPreviewSize)
 Look up the cache for the given model in which the previews have the specified size. More...
 
void ReleaseCache (const std::shared_ptr< BitmapCache > &rpCache)
 Tell the cache manager to release its own reference to the specified cache. More...
 
std::shared_ptr< BitmapCacheChangeSize (const std::shared_ptr< BitmapCache > &rpCache, const Size &rOldPreviewSize, const Size &rNewPreviewSize)
 This is an information to the cache manager that the size of preview bitmaps in the specified cache has changed. More...
 
bool InvalidatePreviewBitmap (const DocumentKey &pDocument, const SdrPage *pPage)
 Invalidate the preview bitmap for one slide that belongs to the specified document. More...
 
void InvalidateAllPreviewBitmaps (const DocumentKey &pDocument)
 Invalidate the preview bitmaps for all slides that belong to the specified document. More...
 
void InvalidateAllCaches ()
 Invalidate all the caches that are currently in use and destroy those that are not. More...
 
void ReleasePreviewBitmap (const SdrPage *pPage)
 Call this method when a page has been deleted and its preview is not needed anymore. More...
 

Static Public Member Functions

static std::shared_ptr< PageCacheManagerInstance ()
 Return the one instance of the PageCacheManager class. More...
 

Private Member Functions

 PageCacheManager ()
 
 ~PageCacheManager ()
 
std::shared_ptr< BitmapCacheGetRecentlyUsedCache (const DocumentKey &pDocument, const Size &rSize)
 
void PutRecentlyUsedCache (DocumentKey const &pDocument, const Size &rPreviewSize, const std::shared_ptr< BitmapCache > &rpCache)
 Add the given cache to the list of recently used caches for the document. More...
 
void Recycle (const std::shared_ptr< BitmapCache > &rpCache, const DocumentKey &pDocument, const Size &rPreviewSize)
 This method is used internally to initialize a newly created BitmapCache with already existing previews. More...
 

Private Attributes

std::unique_ptr< PageCacheContainermpPageCaches
 
std::unique_ptr< RecentlyUsedPageCachesmpRecentlyUsedPageCaches
 

Static Private Attributes

static std::weak_ptr< PageCacheManagermpInstance
 Singleton instance of the cache manager. More...
 
static const sal_uInt32 mnMaximalRecentlyCacheCount = 2
 The maximal number of recently used caches that are kept alive after they have become inactive, i.e. More...
 

Friends

class Deleter
 

Detailed Description

Provide and manage the preview bitmap caches for all slide sorter instances.

There is one cache per active slide sorter plus a small number of caches that are no longer in use. The later are kept to speed up the switching between views.

Definition at line 39 of file SlsPageCacheManager.hxx.

Member Typedef Documentation

◆ BestFittingPageCaches

typedef std::vector< std::pair<Size, std::shared_ptr<BitmapCache> > > sd::slidesorter::cache::PageCacheManager::BestFittingPageCaches

Definition at line 42 of file SlsPageCacheManager.hxx.

◆ DocumentKey

typedef css::uno::Reference<css::uno::XInterface> sd::slidesorter::cache::PageCacheManager::DocumentKey

Definition at line 43 of file SlsPageCacheManager.hxx.

Constructor & Destructor Documentation

◆ PageCacheManager()

sd::slidesorter::cache::PageCacheManager::PageCacheManager ( )
private

Definition at line 183 of file SlsPageCacheManager.cxx.

Referenced by Instance().

◆ ~PageCacheManager()

sd::slidesorter::cache::PageCacheManager::~PageCacheManager ( )
private

Definition at line 189 of file SlsPageCacheManager.cxx.

Member Function Documentation

◆ ChangeSize()

std::shared_ptr< BitmapCache > sd::slidesorter::cache::PageCacheManager::ChangeSize ( const std::shared_ptr< BitmapCache > &  rpCache,
const Size rOldPreviewSize,
const Size rNewPreviewSize 
)

This is an information to the cache manager that the size of preview bitmaps in the specified cache has changed.

Definition at line 273 of file SlsPageCacheManager.cxx.

References comphelper::LibreOfficeKit::isActive(), and mpPageCaches.

◆ GetCache()

std::shared_ptr< BitmapCache > sd::slidesorter::cache::PageCacheManager::GetCache ( const DocumentKey pDocument,
const Size rPreviewSize 
)

Look up the cache for the given model in which the previews have the specified size.

If no such cache exists, then one is created. When a new BitmapCache is created its Recycle() method is called with a sorted list of existing caches from which the new one initialize its previews.

Returns
The returned cache lives as long as somebody keeps a shared pointer and the ReleaseCache() method has not been called.

Definition at line 193 of file SlsPageCacheManager.cxx.

References GetRecentlyUsedCache(), mpPageCaches, and Recycle().

◆ GetRecentlyUsedCache()

std::shared_ptr< BitmapCache > sd::slidesorter::cache::PageCacheManager::GetRecentlyUsedCache ( const DocumentKey pDocument,
const Size rSize 
)
private

Definition at line 379 of file SlsPageCacheManager.cxx.

References mpRecentlyUsedPageCaches.

Referenced by GetCache().

◆ Instance()

std::shared_ptr< PageCacheManager > sd::slidesorter::cache::PageCacheManager::Instance ( )
static

◆ InvalidateAllCaches()

void sd::slidesorter::cache::PageCacheManager::InvalidateAllCaches ( )

Invalidate all the caches that are currently in use and destroy those that are not.

This is used for example when the high contrast mode is turned on or off.

Definition at line 361 of file SlsPageCacheManager.cxx.

References mpPageCaches, and mpRecentlyUsedPageCaches.

◆ InvalidateAllPreviewBitmaps()

void sd::slidesorter::cache::PageCacheManager::InvalidateAllPreviewBitmaps ( const DocumentKey pDocument)

Invalidate the preview bitmaps for all slides that belong to the specified document.

This is necessary after model changes that affect e.g. page number fields.

Definition at line 340 of file SlsPageCacheManager.cxx.

References mpPageCaches, and mpRecentlyUsedPageCaches.

◆ InvalidatePreviewBitmap()

bool sd::slidesorter::cache::PageCacheManager::InvalidatePreviewBitmap ( const DocumentKey pDocument,
const SdrPage pPage 
)

Invalidate the preview bitmap for one slide that belongs to the specified document.

The bitmaps for this slide in all caches are marked as out-of-date and will be re-created when they are requested the next time.

Definition at line 313 of file SlsPageCacheManager.cxx.

References mpPageCaches, and mpRecentlyUsedPageCaches.

◆ PutRecentlyUsedCache()

void sd::slidesorter::cache::PageCacheManager::PutRecentlyUsedCache ( DocumentKey const &  pDocument,
const Size rPreviewSize,
const std::shared_ptr< BitmapCache > &  rpCache 
)
private

Add the given cache to the list of recently used caches for the document.

There is one such list per document. Each least has at most mnMaximalRecentlyCacheCount members.

Definition at line 401 of file SlsPageCacheManager.cxx.

References mnMaximalRecentlyCacheCount, and mpRecentlyUsedPageCaches.

Referenced by ReleaseCache().

◆ Recycle()

void sd::slidesorter::cache::PageCacheManager::Recycle ( const std::shared_ptr< BitmapCache > &  rpCache,
const DocumentKey pDocument,
const Size rPreviewSize 
)
private

This method is used internally to initialize a newly created BitmapCache with already existing previews.

Definition at line 224 of file SlsPageCacheManager.cxx.

References mpPageCaches, and mpRecentlyUsedPageCaches.

Referenced by GetCache().

◆ ReleaseCache()

void sd::slidesorter::cache::PageCacheManager::ReleaseCache ( const std::shared_ptr< BitmapCache > &  rpCache)

Tell the cache manager to release its own reference to the specified cache.

After that the cache will live as long as the caller (and maybe others) holds its reference.

Definition at line 256 of file SlsPageCacheManager.cxx.

References mpPageCaches, and PutRecentlyUsedCache().

◆ ReleasePreviewBitmap()

void sd::slidesorter::cache::PageCacheManager::ReleasePreviewBitmap ( const SdrPage pPage)

Call this method when a page has been deleted and its preview is not needed anymore.

Definition at line 373 of file SlsPageCacheManager.cxx.

References mpPageCaches.

Friends And Related Function Documentation

◆ Deleter

friend class Deleter
friend

Definition at line 129 of file SlsPageCacheManager.hxx.

Member Data Documentation

◆ mnMaximalRecentlyCacheCount

const sal_uInt32 sd::slidesorter::cache::PageCacheManager::mnMaximalRecentlyCacheCount = 2
staticprivate

The maximal number of recently used caches that are kept alive after they have become inactive, i.e.

after they are not used anymore by a slide sorter.

Definition at line 123 of file SlsPageCacheManager.hxx.

Referenced by PutRecentlyUsedCache().

◆ mpInstance

std::weak_ptr< PageCacheManager > sd::slidesorter::cache::PageCacheManager::mpInstance
staticprivate

Singleton instance of the cache manager.

Note that this is a weak pointer. The (implementation class of) ViewShellBase holds a shared_ptr so that the cache manager has the same life time as the ViewShellBase.

Definition at line 109 of file SlsPageCacheManager.hxx.

Referenced by Instance().

◆ mpPageCaches

std::unique_ptr<PageCacheContainer> sd::slidesorter::cache::PageCacheManager::mpPageCaches
private

◆ mpRecentlyUsedPageCaches

std::unique_ptr<RecentlyUsedPageCaches> sd::slidesorter::cache::PageCacheManager::mpRecentlyUsedPageCaches
private

The documentation for this class was generated from the following files: