bump product version to 5.0.4.1
[LibreOffice.git] / sd / source / ui / slidesorter / cache / SlsCacheCompactor.hxx
blob783afecba1a018b23690f0bf5ed3a18720e520b7
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 #ifndef INCLUDED_SD_SOURCE_UI_SLIDESORTER_CACHE_SLSCACHECOMPACTOR_HXX
21 #define INCLUDED_SD_SOURCE_UI_SLIDESORTER_CACHE_SLSCACHECOMPACTOR_HXX
23 #include <sal/types.h>
24 #include <vcl/timer.hxx>
25 #include <memory>
27 namespace sd { namespace slidesorter { namespace cache {
29 class BitmapCache;
31 /** This is an interface class whose implementations are created via the
32 Create() factory method.
34 class CacheCompactor
36 public:
37 virtual ~CacheCompactor() {};
39 /** Create a new instance of the CacheCompactor interface class. The
40 type of compaction algorithm used depends on values from the
41 configuration: the SlideSorter/PreviewCache/CompactionPolicy
42 property of the Impress.xcs file currently supports the values
43 "None" and "Compress". With the later the CompressionPolicy
44 property is evaluated which implementation of the BitmapCompress
45 interface class to use as bitmap compressor.
46 @param rCache
47 The bitmap cache on which to operate.
48 @param nMaximalCacheSize
49 The total number of bytes the off-screen bitmaps in the cache
50 may have. When the Run() method is (indirectly) called the
51 compactor tries to reduce that summed size of off-screen bitmaps
52 under this number. However, it is not guaranteed that this
53 works in all cases.
55 static ::std::unique_ptr<CacheCompactor> Create (
56 BitmapCache& rCache,
57 sal_Int32 nMaximalCacheSize);
59 /** Request a compaction of the off-screen previews in the bitmap
60 cache. This calls via a timer the Run() method.
62 virtual void RequestCompaction();
64 protected:
65 BitmapCache& mrCache;
66 sal_Int32 mnMaximalCacheSize;
68 CacheCompactor(
69 BitmapCache& rCache,
70 sal_Int32 nMaximalCacheSize);
72 /** This method actually tries to reduce the total number of bytes used
73 by the off-screen preview bitmaps.
75 virtual void Run() = 0;
77 private:
78 /** This timer is used to collect calles to RequestCompaction() and
79 eventually call Run().
81 Timer maCompactionTimer;
82 bool mbIsCompactionRunning;
83 DECL_LINK_TYPED(CompactionCallback, Timer *, void);
86 } } } // end of namespace ::sd::slidesorter::cache
88 #endif
90 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */