tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / sd / source / ui / slidesorter / cache / SlsGenericPageCache.hxx
blob900d402686d76bdd9e16ff72b576427f7c4fca90
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #pragma once
22 #include "SlsRequestQueue.hxx"
23 #include <memory>
25 #include <vcl/bitmapex.hxx>
27 namespace sd::slidesorter::cache {
29 class BitmapCache;
30 class QueueProcessor;
32 /** This basically is the implementation class for the PageCache class.
34 class GenericPageCache
36 public:
37 /** The page cache is created with a reference to the SlideSorter and
38 thus has access to both view and model. This allows the cache to
39 fill itself with requests for all pages or just the visible ones.
40 @param rPreviewSize
41 The size of the previews is expected in pixel values.
42 @param bDoSuperSampling
43 When <TRUE/> the previews are rendered larger and then scaled
44 down to the requested size to improve image quality.
46 GenericPageCache (
47 const Size& rPreviewSize,
48 const bool bDoSuperSampling,
49 const SharedCacheContext& rpCacheContext);
51 ~GenericPageCache();
53 /** Change the size of the preview bitmaps. This may be caused by a
54 resize of the slide sorter window or a change of the number of
55 columns.
57 void ChangePreviewSize (
58 const Size& rPreviewSize,
59 const bool bDoSuperSampling);
61 /** Request a preview bitmap for the specified page object in the
62 specified size. The returned bitmap may be a preview of the preview,
63 i.e. either a scaled (up or down) version of a previous preview (of
64 the wrong size) or an empty bitmap. In this case a request for the
65 generation of a new preview is created and inserted into the request
66 queue. When the preview is available the page shape will be told to
67 paint itself again. When it then calls this method again if
68 receives the correctly sized preview bitmap.
69 @param rRequestData
70 This data is used to determine the preview.
71 @param bResize
72 When <TRUE/> then when the available bitmap has not the
73 requested size, it is scaled before it is returned. When
74 <FALSE/> then the bitmap is returned in the wrong size and it is
75 the task of the caller to scale it.
76 @return
77 Returns a bitmap that is either empty, contains a scaled (up or
78 down) version or is the requested bitmap.
80 BitmapEx GetPreviewBitmap (
81 const CacheKey aKey,
82 const bool bResize);
83 BitmapEx GetMarkedPreviewBitmap (
84 const CacheKey aKey);
85 void SetMarkedPreviewBitmap (
86 const CacheKey aKey,
87 const BitmapEx& rMarkedBitmap);
89 /** When the requested preview bitmap does not yet exist or is not
90 up-to-date then the rendering of one is scheduled. Otherwise this
91 method does nothing.
92 @param rRequestData
93 This data is used to determine the preview.
94 @param bMayBeUpToDate
95 This flag helps the method to determine whether an existing
96 preview that matches the request is up to date. If the caller
97 knows that it is not then by passing <FALSE/> he tells us that we
98 do not have to check the up-to-date flag a second time. If
99 unsure use <TRUE/>.
101 void RequestPreviewBitmap (
102 const CacheKey aKey,
103 const bool bMayBeUpToDate);
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.
108 @return
109 When the key is known then return <TRUE/>.
111 bool InvalidatePreviewBitmap (const CacheKey aKey);
113 /** Call this method when all preview bitmaps have to be generated anew.
114 This is the case when the size of the page objects on the screen has
115 changed or when the model has changed.
117 void InvalidateCache ();
119 /** With the precious flag you can control whether a bitmap can be
120 removed from the cache or reduced in size to make room for other
121 bitmaps or is so precious that it will not be touched. A typical
122 use is to set the precious flag for the visible pages.
124 void SetPreciousFlag (const CacheKey aKey, const bool bIsPrecious);
126 void Pause();
127 void Resume();
129 private:
130 std::shared_ptr<BitmapCache> mpBitmapCache;
132 RequestQueue maRequestQueue;
134 std::unique_ptr<QueueProcessor> mpQueueProcessor;
136 SharedCacheContext mpCacheContext;
138 /** The current size of preview bitmaps.
140 Size maPreviewSize;
142 bool mbDoSuperSampling;
144 /** Both bitmap cache and queue processor are created on demand by this
145 method.
147 void ProvideCacheAndProcessor();
150 } // end of namespace ::sd::slidesorter::cache
152 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */