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