merge the formfield patch from ooo-build
[ooovba.git] / sd / source / ui / slidesorter / cache / SlsCacheCompactor.hxx
blobebaef64bd8040c48f1751c643669f79177aad4e3
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: SlsCacheCompactor.hxx,v $
10 * $Revision: 1.5 $
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_CACHE_COMPACTOR_HXX
32 #define SD_SLIDESORTER_CACHE_COMPACTOR_HXX
34 #include <sal/types.h>
35 #include <vcl/timer.hxx>
36 #include <memory>
38 namespace sd { namespace slidesorter { namespace cache {
40 class BitmapCache;
41 class BitmapCompressor;
43 /** This is an interface class whose implementations are created via the
44 Create() factory method.
46 class CacheCompactor
48 public:
49 virtual ~CacheCompactor (void) {};
51 /** Create a new instance of the CacheCompactor interface class. The
52 type of compaction algorithm used depends on values from the
53 configuration: the SlideSorter/PreviewCache/CompactionPolicy
54 property of the Impress.xcs file currently supports the values
55 "None" and "Compress". With the later the CompressionPolicy
56 property is evaluated which implementation of the BitmapCompress
57 interface class to use as bitmap compressor.
58 @param rCache
59 The bitmap cache on which to operate.
60 @param nMaximalCacheSize
61 The total number of bytes the off-screen bitmaps in the cache
62 may have. When the Run() method is (indirectly) called the
63 compactor tries to reduce that summed size of off-screen bitmaps
64 under this number. However, it is not guaranteed that this
65 works in all cases.
67 static ::std::auto_ptr<CacheCompactor> Create (
68 BitmapCache& rCache,
69 sal_Int32 nMaximalCacheSize);
71 /** Request a compaction of the off-screen previews in the bitmap
72 cache. This calls via a timer the Run() method.
74 virtual void RequestCompaction (void);
76 protected:
77 BitmapCache& mrCache;
78 sal_Int32 mnMaximalCacheSize;
80 CacheCompactor(
81 BitmapCache& rCache,
82 sal_Int32 nMaximalCacheSize);
84 /** This method actually tries to reduce the total number of bytes used
85 by the off-screen preview bitmaps.
87 virtual void Run (void) = 0;
89 private:
90 /** This timer is used to collect calles to RequestCompaction() and
91 eventually call Run().
93 Timer maCompactionTimer;
94 bool mbIsCompactionRunning;
95 DECL_LINK(CompactionCallback, Timer*);
101 } } } // end of namespace ::sd::slidesorter::cache
103 #endif