merge the formfield patch from ooo-build
[ooovba.git] / sd / source / ui / slidesorter / cache / SlsGenericPageCache.hxx
blob860bfd5c2a57cbfb771b08e76782b274849795d8
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: SlsGenericPageCache.hxx,v $
10 * $Revision: 1.11 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SD_SLIDESORTER_GENERIC_PAGE_CACHE_HXX
32 #define SD_SLIDESORTER_GENERIC_PAGE_CACHE_HXX
34 #include "SlideSorter.hxx"
35 #include "SlsRequestQueue.hxx"
36 #include "SlsQueueProcessor.hxx"
37 #include <boost/function.hpp>
38 #include <boost/scoped_ptr.hpp>
40 namespace sd { namespace slidesorter { namespace cache {
42 class BitmapCache;
43 class QueueProcessor;
45 /** This basically is the implementation class for the PageCache class.
47 class GenericPageCache
49 public:
50 /** The page chache is created with references both to the SlideSorter.
51 This allows access to both view and model and the cache can so fill
52 itself with requests for all or just the visible pages.
54 GenericPageCache (
55 const Size& rPreviewSize,
56 const SharedCacheContext& rpCacheContext);
58 ~GenericPageCache (void);
60 /** Change the size of the preview bitmaps. This may be caused by a
61 resize of the slide sorter window or a change of the number of
62 columns.
64 void ChangePreviewSize (const Size& rPreviewSize);
66 /** Request a preview bitmap for the specified page object in the
67 specified size. The returned bitmap may be preview of the preview,
68 i.e. either a scaled (up or down) version of a previous preview (of
69 the wrong size) or an empty bitmap. In this case a request for the
70 generation of a new preview is created and inserted into the request
71 queue. When the preview is available the page shape will be told to
72 paint itself again. When it then calls this method again if
73 receives the correctly sized preview bitmap.
74 @param rRequestData
75 This data is used to determine the preview.
76 @param rSize
77 The size of the requested preview bitmap.
78 @return
79 Returns a bitmap that is either empty, contains a scaled (up or
80 down) version or is the requested bitmap.
82 BitmapEx GetPreviewBitmap (
83 CacheKey aKey,
84 const Size& rSize);
86 /** When the requested preview bitmap does not yet exist or is not
87 up-to-date then the rendering of one is scheduled. Otherwise this
88 method does nothing.
89 @param rRequestData
90 This data is used to determine the preview.
91 @param rSize
92 The size of the requested preview bitmap in pixel coordinates.
93 @param bMayBeUpToDate
94 This flag helps the method to determine whether an existing
95 preview that matches the request is up to date. If the caller
96 know that it is not then by passing <FALSE/> he tells us that we
97 do not have to check the up-to-date flag a second time. If
98 unsure pass <TRUE/>.
100 void RequestPreviewBitmap (
101 CacheKey aKey,
102 const Size& rSize,
103 bool bMayBeUpToDate = true);
105 /** Tell the cache to replace the bitmap associated with the given
106 request data with a new one that reflects recent changes in the
107 content of the page object.
109 void InvalidatePreviewBitmap (CacheKey aKey);
111 /** Call this method when a view-object-contact object is being deleted
112 and does not need (a) its current bitmap in the cache and (b) a
113 requested a new bitmap.
115 void ReleasePreviewBitmap (CacheKey aKey);
117 /** Call this method when all preview bitmaps have to be generated anew.
118 This is the case when the size of the page objects on the screen has
119 changed or when the model has changed.
121 void InvalidateCache (bool bUpdateCache);
123 /** With the precious flag you can control whether a bitmap can be
124 removed from the cache or reduced in size to make room for other
125 bitmaps or is so precious that it will not be touched. A typical
126 use is to set the precious flag for the visible pages.
128 void SetPreciousFlag (CacheKey aKey, bool bIsPrecious);
130 /** Return <TRUE/> when there is no preview bitmap in the cache.
132 bool IsEmpty (void) const;
134 void Pause (void);
135 void Resume (void);
137 private:
138 ::boost::shared_ptr<BitmapCache> mpBitmapCache;
140 RequestQueue maRequestQueue;
142 ::boost::scoped_ptr<QueueProcessor> mpQueueProcessor;
144 SharedCacheContext mpCacheContext;
146 /** The current size of preview bitmaps.
148 Size maPreviewSize;
150 /** Both bitmap cache and queue processor are created on demand by this
151 method.
153 void ProvideCacheAndProcessor (void);
157 } } } // end of namespace ::sd::slidesorter::cache
159 #endif