Update ooo320-m1
[ooovba.git] / goodies / source / graphic / grfcache.hxx
blobb8a1830414089f266603e185acf51f2041c7d77d
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: grfcache.hxx,v $
10 * $Revision: 1.4 $
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 _GRFCACHE_HXX
32 #define _GRFCACHE_HXX
34 #include <tools/list.hxx>
35 #include <vcl/graph.hxx>
36 #include <vcl/timer.hxx>
37 #include "grfmgr.hxx"
39 // -----------------------
40 // - GraphicManagerCache -
41 // -----------------------
43 class GraphicCacheEntry;
45 class GraphicCache
47 private:
49 GraphicManager& mrMgr;
50 Timer maReleaseTimer;
51 List maGraphicCache;
52 List maDisplayCache;
53 ULONG mnReleaseTimeoutSeconds;
54 ULONG mnMaxDisplaySize;
55 ULONG mnMaxObjDisplaySize;
56 ULONG mnUsedDisplaySize;
58 BOOL ImplFreeDisplayCacheSpace( ULONG nSizeToFree );
59 GraphicCacheEntry* ImplGetCacheEntry( const GraphicObject& rObj );
62 DECL_LINK( ReleaseTimeoutHdl, Timer* pTimer );
64 public:
66 GraphicCache( GraphicManager& rMgr,
67 ULONG nDisplayCacheSize = 10000000UL,
68 ULONG nMaxObjDisplayCacheSize = 2400000UL );
69 ~GraphicCache();
71 public:
73 void AddGraphicObject( const GraphicObject& rObj, Graphic& rSubstitute,
74 const ByteString* pID, const GraphicObject* pCopyObj );
75 void ReleaseGraphicObject( const GraphicObject& rObj );
77 void GraphicObjectWasSwappedOut( const GraphicObject& rObj );
78 BOOL FillSwappedGraphicObject( const GraphicObject& rObj, Graphic& rSubstitute );
79 void GraphicObjectWasSwappedIn( const GraphicObject& rObj );
81 ByteString GetUniqueID( const GraphicObject& rObj ) const;
83 public:
85 void SetMaxDisplayCacheSize( ULONG nNewCacheSize );
86 ULONG GetMaxDisplayCacheSize() const { return mnMaxDisplaySize; };
88 void SetMaxObjDisplayCacheSize( ULONG nNewMaxObjSize, BOOL bDestroyGreaterCached = FALSE );
89 ULONG GetMaxObjDisplayCacheSize() const { return mnMaxObjDisplaySize; }
91 ULONG GetUsedDisplayCacheSize() const { return mnUsedDisplaySize; }
92 ULONG GetFreeDisplayCacheSize() const { return( mnMaxDisplaySize - mnUsedDisplaySize ); }
94 void SetCacheTimeout( ULONG nTimeoutSeconds );
95 ULONG GetCacheTimeout() const { return mnReleaseTimeoutSeconds; }
97 void ClearDisplayCache();
98 BOOL IsDisplayCacheable( OutputDevice* pOut, const Point& rPt, const Size& rSz,
99 const GraphicObject& rObj, const GraphicAttr& rAttr ) const;
100 BOOL IsInDisplayCache( OutputDevice* pOut, const Point& rPt, const Size& rSz,
101 const GraphicObject& rObj, const GraphicAttr& rAttr ) const;
102 BOOL CreateDisplayCacheObj( OutputDevice* pOut, const Point& rPt, const Size& rSz,
103 const GraphicObject& rObj, const GraphicAttr& rAttr,
104 const BitmapEx& rBmpEx );
105 BOOL CreateDisplayCacheObj( OutputDevice* pOut, const Point& rPt, const Size& rSz,
106 const GraphicObject& rObj, const GraphicAttr& rAttr,
107 const GDIMetaFile& rMtf );
108 BOOL DrawDisplayCacheObj( OutputDevice* pOut, const Point& rPt, const Size& rSz,
109 const GraphicObject& rObj, const GraphicAttr& rAttr );
112 #endif // _GRFCACHE_HXX