1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SD_SLIDESORTER_CACHE_CONTEXT_HXX
25 #define SD_SLIDESORTER_CACHE_CONTEXT_HXX
26 
27 #include <sal/types.h>
28 #include <com/sun/star/uno/XInterface.hpp>
29 #include <boost/shared_ptr.hpp>
30 #include <vector>
31 
32 class SdrPage;
33 class Bitmap;
34 
35 namespace sd { namespace slidesorter { namespace cache {
36 
37 typedef const SdrPage* CacheKey;
38 
39 /** This interface allows the individualisation of different instances of
40     the PreviewCache.
41 */
42 class CacheContext
43 {
44 public:
45     /** This method is called when the asynchronous creation of a preview
46         has been finished.
47         @param aKey
48             The key of the page for which the preview has been created.
49         @param aPreview
50             The newly created preview.
51     */
52     virtual void NotifyPreviewCreation (
53         CacheKey aKey,
54         const Bitmap& rPreview) = 0;
55 
56     /** Called to determine whether the system is idle and a preview can be
57         created without annoying the user.
58     */
59     virtual bool IsIdle (void) = 0;
60 
61     /** This method is used to determine whether a page is currently visible
62         or not.  It is called when the cache becomes to large and some
63         previews have to be released or scaled down.
64     */
65     virtual bool IsVisible (CacheKey aKey) = 0;
66 
67     /** Return the page associdated with the given key.  Note that different
68         keys may map to a single page (this may be the case with custom
69         slide shows.)
70     */
71     virtual const SdrPage* GetPage (CacheKey aKey) = 0;
72 
73     /** This method is used when the request queue is filled.  It asks for
74         the list of visible entries and maybe for the list of not visible
75         entries and creates preview creation requests for them.
76         @param bVisible
77             When this is <FALSE/> then the implementation can decide whether
78             to allow rendering of previews that are not visible (ahead of
79             time). When not then return an empty pointer or an empty vector.
80     */
81     virtual ::boost::shared_ptr<std::vector<CacheKey> > GetEntryList (bool bVisible) = 0;
82 
83     /** Return the priority that defines the order in which previews are
84         created for different keys/pages.  Typically the visible pages come
85         first, then top-down, left-to-right.
86     */
87     virtual sal_Int32 GetPriority (CacheKey aKey) = 0;
88 
89     /** Return the model to which the pages belong for which the called
90         cache manages the previews.  Different caches that belong to the
91         same model but have different preview sizes may acces previews of
92         each other in order to create fast previews of the previews.
93     */
94     virtual ::com::sun::star::uno::Reference<com::sun::star::uno::XInterface> GetModel (void) = 0;
95 };
96 
97 typedef ::boost::shared_ptr<CacheContext> SharedCacheContext;
98 
99 } } } // end of namespace ::sd::slidesorter::cache
100 
101 #endif
102 
103