1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef SD_SLIDESORTER_CACHE_CONTEXT_HXX
29 #define SD_SLIDESORTER_CACHE_CONTEXT_HXX
30 
31 #include <sal/types.h>
32 #include <com/sun/star/uno/XInterface.hpp>
33 #include <boost/shared_ptr.hpp>
34 #include <vector>
35 
36 class SdrPage;
37 class Bitmap;
38 
39 namespace sd { namespace slidesorter { namespace cache {
40 
41 typedef const SdrPage* CacheKey;
42 
43 /** This interface allows the individualisation of different instances of
44     the PreviewCache.
45 */
46 class CacheContext
47 {
48 public:
49     /** This method is called when the asynchronous creation of a preview
50         has been finished.
51         @param aKey
52             The key of the page for which the preview has been created.
53         @param aPreview
54             The newly created preview.
55     */
56     virtual void NotifyPreviewCreation (
57         CacheKey aKey,
58         const Bitmap& rPreview) = 0;
59 
60     /** Called to determine whether the system is idle and a preview can be
61         created without annoying the user.
62     */
63     virtual bool IsIdle (void) = 0;
64 
65     /** This method is used to determine whether a page is currently visible
66         or not.  It is called when the cache becomes to large and some
67         previews have to be released or scaled down.
68     */
69     virtual bool IsVisible (CacheKey aKey) = 0;
70 
71     /** Return the page associdated with the given key.  Note that different
72         keys may map to a single page (this may be the case with custom
73         slide shows.)
74     */
75     virtual const SdrPage* GetPage (CacheKey aKey) = 0;
76 
77     /** This method is used when the request queue is filled.  It asks for
78         the list of visible entries and maybe for the list of not visible
79         entries and creates preview creation requests for them.
80         @param bVisible
81             When this is <FALSE/> then the implementation can decide whether
82             to allow rendering of previews that are not visible (ahead of
83             time). When not then return an empty pointer or an empty vector.
84     */
85     virtual ::boost::shared_ptr<std::vector<CacheKey> > GetEntryList (bool bVisible) = 0;
86 
87     /** Return the priority that defines the order in which previews are
88         created for different keys/pages.  Typically the visible pages come
89         first, then top-down, left-to-right.
90     */
91     virtual sal_Int32 GetPriority (CacheKey aKey) = 0;
92 
93     /** Return the model to which the pages belong for which the called
94         cache manages the previews.  Different caches that belong to the
95         same model but have different preview sizes may acces previews of
96         each other in order to create fast previews of the previews.
97     */
98     virtual ::com::sun::star::uno::Reference<com::sun::star::uno::XInterface> GetModel (void) = 0;
99 };
100 
101 typedef ::boost::shared_ptr<CacheContext> SharedCacheContext;
102 
103 } } } // end of namespace ::sd::slidesorter::cache
104 
105 #endif
106 
107